Skip to content

Commit

Permalink
DO NOT MERGE BACK INTO MASTER!
Browse files Browse the repository at this point in the history
Backport of mlibc managarm#311 for x86_64 only!
This will enter through abi-breaks on master, do not submit back into upstream!
DO NOT MERGE BACK INTO MASTER!
  • Loading branch information
Dennisbonke authored and no92 committed Jul 8, 2022
1 parent f3bdbde commit ea1d424
Show file tree
Hide file tree
Showing 8 changed files with 335 additions and 86 deletions.
8 changes: 4 additions & 4 deletions options/ansi/generic/stdio-stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,10 @@ static int do_scanf(H &handler, const char *fmt, __gnuc_va_list args) {
res = res * 16 + (c - '0');
} else if (c >= 'a' && c <= 'f') {
handler.consume();
res = res * 16 + (c - 'a');
res = res * 16 + (c - 'a' + 10);
} else if (c >= 'A' && c <= 'F') {
handler.consume();
res = res * 16 + (c - 'A');
res = res * 16 + (c - 'A' + 10);
} else {
break;
}
Expand Down Expand Up @@ -539,10 +539,10 @@ static int do_scanf(H &handler, const char *fmt, __gnuc_va_list args) {
res = res * 16 + (c - '0');
} else if (c >= 'a' && c <= 'f') {
handler.consume();
res = res * 16 + (c - 'a');
res = res * 16 + (c - 'a' + 10);
} else if (c >= 'A' && c <= 'F') {
handler.consume();
res = res * 16 + (c - 'A');
res = res * 16 + (c - 'A' + 10);
} else {
break;
}
Expand Down
4 changes: 4 additions & 0 deletions options/internal/include/mlibc/tcb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ struct Tcb {
uint64_t generation;
};
frg::array<LocalKey, PTHREAD_KEYS_MAX> *localKeys;

size_t stackSize;
void *stackAddr;
size_t guardSize;
};

// There are a few places where we assume the layout of the TCB:
Expand Down
6 changes: 6 additions & 0 deletions options/internal/x86_64-include/mlibc/thread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@ inline Tcb *get_current_tcb() {
return reinterpret_cast<Tcb *>(ptr);
}

inline uintptr_t get_sp() {
uintptr_t rsp;
asm ("mov %%rsp, %0" : "=r"(rsp));
return rsp;
}

} // namespace mlibc
Loading

0 comments on commit ea1d424

Please sign in to comment.