Make _Thread_local work on windows haven't tested tho

This commit is contained in:
bumbread 2022-06-22 00:40:10 +11:00
parent 7cb9dc133f
commit 5cf93a6532
4 changed files with 6 additions and 4 deletions

View File

@ -5,5 +5,4 @@
#define EILSEQ 2
#define ERANGE 3
// TODO: make it thread-local
extern int errno;
extern _Thread_local int errno;

View File

@ -1,4 +1,4 @@
#include <errno.h>
int errno;
_Thread_local int errno;

View File

@ -8,6 +8,8 @@
#include <win.h>
#include <threads.h>
DWORD _tls_index = 0;
void mtx_destroy(mtx_t *mtx) {
CloseHandle(mtx->semaphore);
}

View File

@ -1,7 +1,7 @@
#include <assert.h>
#include <stddef.h>
#include <errno.h>
void do_more_stuff(char *ptr) {
assert(ptr != NULL);
}
@ -11,6 +11,7 @@ void do_stuff() {
}
int main() {
errno = 0;
assert(2+2 == 4);
do_stuff();
}