use weak aliases rather than function pointers to simplify some code
[musl] / src / process / fork.c
1 #include <unistd.h>
2 #include "syscall.h"
3 #include "libc.h"
4 #include "pthread_impl.h"
5
6 static void dummy(int x)
7 {
8 }
9
10 weak_alias(dummy, __fork_handler);
11
12 pid_t fork(void)
13 {
14         pid_t ret;
15         __fork_handler(-1);
16         ret = syscall(SYS_fork);
17         if (libc.main_thread && !ret) {
18                 pthread_t self = __pthread_self();
19                 self->tid = self->pid = syscall(SYS_getpid);
20                 memset(&self->robust_list, 0, sizeof self->robust_list);
21                 libc.threads_minus_1 = 0;
22                 libc.main_thread = self;
23         }
24         __fork_handler(!ret);
25         return ret;
26 }