mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 10:37:45 +00:00
LibC+LibPthread: Implement pthread_atfork()
This required a bit of rearchitecture, as pthread_atfork() required a mutex, and duplicating a mutex impl for it was silly. As such, this patch moves some standalone bits of pthread into LibC and uses those to implement atfork(). It should be noted that for programs that don't use atfork(), this mechanism only costs two atomic loads (as opposed to the normal mutex lock+unlock) :^)
This commit is contained in:
parent
8e074f8665
commit
bb777459a0
6 changed files with 231 additions and 37 deletions
|
@ -26,6 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <bits/pthread_integration.h>
|
||||
#include <sched.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
@ -75,13 +76,11 @@ int pthread_setspecific(pthread_key_t key, const void* value);
|
|||
int pthread_getschedparam(pthread_t thread, int* policy, struct sched_param* param);
|
||||
int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param* param);
|
||||
|
||||
#define PTHREAD_MUTEX_NORMAL 0
|
||||
#define PTHREAD_MUTEX_RECURSIVE 1
|
||||
#define PTHREAD_MUTEX_NORMAL __PTHREAD_MUTEX_NORMAL
|
||||
#define PTHREAD_MUTEX_RECURSIVE __PTHREAD_MUTEX_RECURSIVE
|
||||
#define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL
|
||||
#define PTHREAD_MUTEX_INITIALIZER \
|
||||
{ \
|
||||
0, 0, 0, PTHREAD_MUTEX_DEFAULT \
|
||||
}
|
||||
#define PTHREAD_MUTEX_INITIALIZER __PTHREAD_MUTEX_INITIALIZER
|
||||
|
||||
#define PTHREAD_COND_INITIALIZER \
|
||||
{ \
|
||||
0, 0, CLOCK_MONOTONIC_COARSE \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue