cosmopolitan/libc/mem
Justine Tunney 60cb435cb4
Implement pthread_atfork()
If threads are being used, then fork() will now acquire and release and
runtime locks so that fork() may be safely used from threads. This also
makes vfork() thread safe, because pthread mutexes will do nothing when
the process is a child of vfork(). More torture tests have been written
to confirm this all works like a charm. Additionally:

- Invent hexpcpy() api
- Rename nsync_malloc_() to kmalloc()
- Complete posix named semaphore implementation
- Make pthread_create() asynchronous signal safe
- Add rm, rmdir, and touch to command interpreter builtins
- Invent sigisprecious() and modify sigset functions to use it
- Add unit tests for posix_spawn() attributes and fix its bugs

One unresolved problem is the reclaiming of *NSYNC waiter memory in the
forked child processes, within apps which have threads waiting on locks
2022-10-16 12:25:13 -07:00
..
cxx Correct more typos (#500) 2022-07-21 20:53:30 -07:00
hook Reduce build graph by another 14 percent 2022-08-17 20:01:21 -07:00
_gc_free.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
alg.h Pay off more technical debt 2022-09-12 23:36:56 -07:00
aligned_alloc.c Use re-entrant locks on stdio 2022-05-22 08:28:33 -07:00
alloca.h Initial import 2020-06-15 07:18:57 -07:00
arena.c Fix bugs and make code tinier 2022-10-09 23:21:34 -07:00
arena.h Make fixes, improvements, and chibicc python bindings 2021-10-08 08:41:57 -07:00
arraylist.internal.h Fold LIBC_ALG into LIBC_MEM 2022-08-13 08:32:34 -07:00
arraylist2.internal.h Fold LIBC_ALG into LIBC_MEM 2022-08-13 08:32:34 -07:00
asprintf.c Use re-entrant locks on stdio 2022-05-22 08:28:33 -07:00
balloc.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
bfree.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
bisect.internal.h Fold LIBC_ALG into LIBC_MEM 2022-08-13 08:32:34 -07:00
bisectcarleft.internal.h Fold LIBC_ALG into LIBC_MEM 2022-08-13 08:32:34 -07:00
bsearch.c Fold LIBC_ALG into LIBC_MEM 2022-08-13 08:32:34 -07:00
bsearch_r.c Fold LIBC_ALG into LIBC_MEM 2022-08-13 08:32:34 -07:00
bulk_free.S Make fixes, improvements, and chibicc python bindings 2021-10-08 08:41:57 -07:00
calloc.S Use re-entrant locks on stdio 2022-05-22 08:28:33 -07:00
copyfd.c Improve system call wrappers 2022-09-19 15:06:25 -07:00
copyfd.internal.h Improve system call wrappers 2022-09-19 15:06:25 -07:00
critbit0.h Fold LIBC_ALG into LIBC_MEM 2022-08-13 08:32:34 -07:00
critbit0_allprefixed.c Fold LIBC_ALG into LIBC_MEM 2022-08-13 08:32:34 -07:00
critbit0_clear.c Fold LIBC_ALG into LIBC_MEM 2022-08-13 08:32:34 -07:00
critbit0_contains.c Fold LIBC_ALG into LIBC_MEM 2022-08-13 08:32:34 -07:00
critbit0_delete.c Fold LIBC_ALG into LIBC_MEM 2022-08-13 08:32:34 -07:00
critbit0_emplace.c Fold LIBC_ALG into LIBC_MEM 2022-08-13 08:32:34 -07:00
critbit0_get.c Fold LIBC_ALG into LIBC_MEM 2022-08-13 08:32:34 -07:00
critbit0_insert.c Fold LIBC_ALG into LIBC_MEM 2022-08-13 08:32:34 -07:00
fmt.h Make Cosmopolitan ANSI C89 compatible 2021-02-03 17:48:59 -08:00
free.S WIP: Correct all typos (#498) 2022-07-20 14:01:15 -07:00
gc.c Fix bugs and make code tinier 2022-10-09 23:21:34 -07:00
gc.h Pay off more technical debt 2022-09-12 23:36:56 -07:00
gc.internal.h Pay off more technical debt 2022-09-12 23:36:56 -07:00
get_current_dir_name.c Use re-entrant locks on stdio 2022-05-22 08:28:33 -07:00
heapsort.c Import OpenBSD sorting algorithms 2022-09-06 17:52:26 -07:00
internal.h Fold LIBC_ALG into LIBC_MEM 2022-08-13 08:32:34 -07:00
mallinfo.c Improve synchronization 2022-04-15 15:31:55 -07:00
malloc.S Use re-entrant locks on stdio 2022-05-22 08:28:33 -07:00
malloc_inspect_all.c Improve synchronization 2022-04-15 15:31:55 -07:00
malloc_trim.S Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
malloc_usable_size.S Use re-entrant locks on stdio 2022-05-22 08:28:33 -07:00
mem.h Implement pthread_atfork() 2022-10-16 12:25:13 -07:00
mem.mk Fold LIBC_RAND into LIBC_STDIO/TINYMATH/INTRIN 2022-08-11 12:32:00 -07:00
memalign.S Use re-entrant locks on stdio 2022-05-22 08:28:33 -07:00
mergesort.c Import OpenBSD sorting algorithms 2022-09-06 17:52:26 -07:00
posix_memalign.c Use re-entrant locks on stdio 2022-05-22 08:28:33 -07:00
putenv.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
pvalloc.c Optimize memory layout 2022-09-12 04:26:52 -07:00
qsort.c Polyfill IPv6 on non-Linux 2022-09-08 06:06:22 -07:00
realloc.S Use re-entrant locks on stdio 2022-05-22 08:28:33 -07:00
realloc_in_place.S Use re-entrant locks on stdio 2022-05-22 08:28:33 -07:00
reallocarray.c Use re-entrant locks on stdio 2022-05-22 08:28:33 -07:00
replacestr.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
reverse.internal.h Fold LIBC_ALG into LIBC_MEM 2022-08-13 08:32:34 -07:00
setenv.c Greatly expand system() shell code features 2022-10-11 21:30:31 -07:00
shuffle.internal.h Fold LIBC_ALG into LIBC_MEM 2022-08-13 08:32:34 -07:00
strdup.c Use re-entrant locks on stdio 2022-05-22 08:28:33 -07:00
strndup.c Use re-entrant locks on stdio 2022-05-22 08:28:33 -07:00
tarjan.c Fix bugs and make code tinier 2022-10-09 23:21:34 -07:00
unhexstr.c Fix bugs and make code tinier 2022-10-09 23:21:34 -07:00
valloc.c Optimize memory layout 2022-09-12 04:26:52 -07:00
vasprintf.c Fix bugs and make code tinier 2022-10-09 23:21:34 -07:00
wcsdup.c Fix wcsdup malloc size (#641) 2022-10-02 00:47:05 -07:00