Support thread local storage

This commit is contained in:
Justine Tunney 2022-05-16 13:20:08 -07:00
parent 91ee2b19d4
commit 55de4ca6b5
197 changed files with 1483 additions and 874 deletions

View file

@ -20,6 +20,7 @@
#include "libc/calls/internal.h"
#include "libc/calls/strace.internal.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/kprintf.h"
#include "libc/runtime/internal.h"
@ -35,15 +36,17 @@
* @return 0 on success, or -1 w/ errno
* @see mmap()
*/
privileged int mprotect(void *addr, size_t size, int prot) {
int mprotect(void *addr, size_t size, int prot) {
int64_t rc;
if (SupportsWindows() && (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC |
PROT_GROWSDOWN | PROT_GROWSUP))) {
rc = einval(); // unix checks prot before checking size
errno = EINVAL; // unix checks prot before checking size
rc = -1;
} else if (!size) {
return 0; // make new technology consistent with unix
} else if (UNLIKELY((intptr_t)addr & 4095)) {
rc = einval();
errno = EINVAL; // unix checks prot before checking size
rc = -1;
} else if (!IsWindows()) {
rc = sys_mprotect(addr, size, prot);
} else {