Skip to content

Commit

Permalink
Merge pull request #311 from Geertiebear/pthread_attr
Browse files Browse the repository at this point in the history
All pthread_attr_* support
  • Loading branch information
Geertiebear authored Jul 7, 2022
2 parents 74f7648 + 7df85a1 commit 58ceb66
Show file tree
Hide file tree
Showing 26 changed files with 721 additions and 166 deletions.
1 change: 1 addition & 0 deletions ABI_BREAKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ This document lists the ABI breaks that were made in each mlibc major version.
- [#452](https://github.com/managarm/mlibc/pull/452): The functions `FD_{CLR,ISSET,SET,ZERO}` were renamed to `__FD_{CLR,ISSET,SET,ZERO}` and replaced by macros to match Wine's assumptions.
- [#511](https://github.com/managarm/mlibc/pull/511): Musl's regex engine was added, implementing `regcomp` and `regexec`. This required some changes to the `regex_t` struct.
- [#504](https://github.com/managarm/mlibc/pull/504), [#580](https://github.com/managarm/mlibc/pull/580): In both the mlibc and Linux ABIs, a `domainname` member was added to `struct utsname`, which is a glibc extension.
- [#311](https://github.com/managarm/mlibc/pull/311): Added all necessary fields in `pthread_attr_t` required for implementing all `pthread_attr` functions.
1 change: 1 addition & 0 deletions abis/dripos/errno.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,6 @@
#define ELNRNG 113
#define ENOTUNIQ 114
#define ERESTART 115
#define ENOTSUP 116

#endif
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
6 changes: 6 additions & 0 deletions options/internal/aarch64-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 sp;
asm ("mov %0, sp" : "=r"(sp));
return sp;
}

} // namespace mlibc
6 changes: 5 additions & 1 deletion 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 All @@ -125,7 +129,7 @@ static_assert(offsetof(Tcb, dtvPointers) == 16);
// we need to access specific fields that means that the value in
// sysdeps/linux/riscv64/cp_syscall.S needs to be updated whenever
// the struct is expanded.
static_assert(sizeof(Tcb) - offsetof(Tcb, cancelBits) == 56);
static_assert(sizeof(Tcb) - offsetof(Tcb, cancelBits) == 80);
#else
#error "Missing architecture specific code."
#endif
6 changes: 6 additions & 0 deletions options/internal/riscv64-include/mlibc/thread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@ inline Tcb *get_current_tcb() {
return tcb;
}

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

} // namespace mlibc
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 58ceb66

Please sign in to comment.