Make locks more reliable

This change switches most of the core locks to be re-entrant, in order
to reduce the chance of deadlocking code that does, clever things with
asynchronous signal handlers. This change implements it it in pthreads
so we're one step closer to having a standardized threading primitives
This commit is contained in:
Justine Tunney 2022-06-11 01:59:26 -07:00
parent 5ea618f0af
commit c260345e06
35 changed files with 369 additions and 258 deletions

View file

@ -1,6 +1,7 @@
#ifndef COSMOPOLITAN_LIBC_STDIO_STDIO_H_
#define COSMOPOLITAN_LIBC_STDIO_STDIO_H_
#include "libc/fmt/pflink.h"
#include "libc/intrin/pthread.h"
#include "libc/runtime/symbolic.h"
#define FILENAME_MAX PATH_MAX
@ -24,9 +25,8 @@ typedef struct FILE {
uint32_t size; /* 0x20 */
uint32_t nofree; /* 0x24 */
int pid; /* 0x28 */
int lock; /* 0x2c */
int reent; /* 0x30 */
char *getln; /* 0x38 */
char *getln;
pthread_mutex_t lock;
} FILE;
extern FILE *stdin;