Hunt down more bugs

After going through the MODE=dbg and MODE=zero build modes, a bunch of
little issues were identified, which have been addressed. Fixing those
issues created even more troubles for the project, because it improved
our ability to detect latent problems which are getting fixed so fast.
This commit is contained in:
Justine Tunney 2023-07-03 17:35:11 -07:00
parent 73c0faa1b5
commit 97b7116953
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
39 changed files with 557 additions and 754 deletions

View file

@ -75,15 +75,22 @@ static errno_t pthread_getname_impl(pthread_t thread, char *name, size_t size) {
}
return 0;
} else if (IsNetbsd()) {
} else if (IsNetbsd() || IsOpenbsd()) {
int ax;
char cf;
int ax, dx;
long dx, si;
if (IsNetbsd()) {
ax = 324; // _lwp_getname
} else {
ax = 142; // sys_getthrname
}
// NetBSD doesn't document the subtleties of its nul-terminator
// behavior, so like Linux we shall take the paranoid approach.
dx = size - 1;
si = (long)name;
asm volatile(CFLAG_ASM("syscall")
: CFLAG_CONSTRAINT(cf), "=a"(ax), "=d"(dx)
: "1"(324 /* _lwp_getname */), "D"(tid), "S"(name),
"d"(size - 1)
: CFLAG_CONSTRAINT(cf), "+a"(ax), "+D"(tid), "+S"(si), "+d"(dx)
: /* no outputs */
: "rcx", "r8", "r9", "r10", "r11", "memory");
if (!cf) {
// if size + our nul + kernel's nul is the buffer size, then we
@ -116,7 +123,7 @@ static errno_t pthread_getname_impl(pthread_t thread, char *name, size_t size) {
* @return 0 on success, or errno on error
* @raise ERANGE if `size` wasn't large enough, in which case your
* result will still be returned truncated if possible
* @raise ENOSYS on MacOS, Windows, FreeBSD, and OpenBSD
* @raise ENOSYS on MacOS, Windows, and FreeBSD
*/
errno_t pthread_getname_np(pthread_t thread, char *name, size_t size) {
errno_t rc;