mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-03 03:02:28 +00:00
Introduce ctl::set and ctl::map
We now have a C++ red-black tree implementation that implements standard template library compatible APIs while compiling 10x faster than libcxx. It's not as beautiful as the red-black tree implementation in Plinko but this will get the job done and the test proves it upholds all invariants This change also restores CheckForMemoryLeaks() support and fixes a real actual bug I discovered with Doug Lea's dlmalloc_inspect_all() function.
This commit is contained in:
parent
388e236360
commit
c4c812c154
45 changed files with 2358 additions and 135 deletions
|
@ -44,27 +44,6 @@ void _pthread_unwind(struct PosixThread *pt) {
|
|||
}
|
||||
}
|
||||
|
||||
void _pthread_unkey(struct CosmoTib *tib) {
|
||||
void *val;
|
||||
int i, j, gotsome;
|
||||
pthread_key_dtor dtor;
|
||||
for (j = 0; j < PTHREAD_DESTRUCTOR_ITERATIONS; ++j) {
|
||||
for (gotsome = i = 0; i < PTHREAD_KEYS_MAX; ++i) {
|
||||
if ((val = tib->tib_keys[i]) &&
|
||||
(dtor = atomic_load_explicit(_pthread_key_dtor + i,
|
||||
memory_order_relaxed)) &&
|
||||
dtor != (pthread_key_dtor)-1) {
|
||||
gotsome = 1;
|
||||
tib->tib_keys[i] = 0;
|
||||
dtor(val);
|
||||
}
|
||||
}
|
||||
if (!gotsome) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Terminates current POSIX thread.
|
||||
*
|
||||
|
@ -111,14 +90,7 @@ wontreturn void pthread_exit(void *rc) {
|
|||
|
||||
// free resources
|
||||
_pthread_unwind(pt);
|
||||
if (_weaken(__cxa_thread_finalize)) {
|
||||
_weaken(__cxa_thread_finalize)();
|
||||
}
|
||||
_pthread_unkey(tib);
|
||||
if (tib->tib_nsync) {
|
||||
nsync_waiter_destroy(tib->tib_nsync);
|
||||
}
|
||||
_pthread_ungarbage();
|
||||
__cxa_thread_finalize();
|
||||
_pthread_decimate();
|
||||
|
||||
// run atexit handlers if orphaned thread
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue