mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-29 08:42:28 +00:00
Clean up some of the threading code
This commit is contained in:
parent
0547eabcd6
commit
9f963dc597
62 changed files with 175 additions and 582 deletions
|
@ -17,11 +17,11 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/intrin/promises.internal.h"
|
||||
#include "libc/intrin/spinlock.h"
|
||||
#include "libc/intrin/pthread.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
@ -32,7 +32,7 @@
|
|||
#include "libc/zipos/zipos.internal.h"
|
||||
#include "third_party/zlib/puff.h"
|
||||
|
||||
static int g_lock;
|
||||
static pthread_spinlock_t g_lock;
|
||||
hidden struct SymbolTable *__symtab; // for kprintf
|
||||
|
||||
/**
|
||||
|
@ -125,7 +125,7 @@ static struct SymbolTable *GetSymbolTableFromElf(void) {
|
|||
*/
|
||||
struct SymbolTable *GetSymbolTable(void) {
|
||||
struct Zipos *z;
|
||||
if (_trylock(&g_lock)) return 0;
|
||||
if (pthread_spin_trylock(&g_lock)) return 0;
|
||||
if (!__symtab && !__isworker) {
|
||||
if (weaken(__zipos_get) && (z = weaken(__zipos_get)())) {
|
||||
if ((__symtab = GetSymbolTableFromZip(z))) {
|
||||
|
@ -139,7 +139,7 @@ struct SymbolTable *GetSymbolTable(void) {
|
|||
__symtab = GetSymbolTableFromElf();
|
||||
}
|
||||
}
|
||||
_spunlock(&g_lock);
|
||||
pthread_spin_unlock(&g_lock);
|
||||
return __symtab;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue