mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-29 00:32:29 +00:00
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:
parent
5ea618f0af
commit
c260345e06
35 changed files with 369 additions and 258 deletions
|
@ -4,6 +4,7 @@
|
|||
#define LOCALTIME_IMPLEMENTATION
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/intrin/pthread.h"
|
||||
#include "libc/intrin/spinlock.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.h"
|
||||
|
@ -42,15 +43,15 @@ STATIC_YOINK("usr/share/zoneinfo/UTC");
|
|||
** POSIX-style TZ environment variable handling from Guy Harris.
|
||||
*/
|
||||
|
||||
_Alignas(64) static int locallock;
|
||||
static pthread_mutex_t locallock;
|
||||
|
||||
static int lock(void) {
|
||||
_spinlock(&locallock);
|
||||
pthread_mutex_lock(&locallock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void unlock(void) {
|
||||
_spunlock(&locallock);
|
||||
pthread_mutex_unlock(&locallock);
|
||||
}
|
||||
|
||||
#ifndef TZ_ABBR_MAX_LEN
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue