struct __libc {
int *(*errno_location)(void);
- void (*testcancel)(void);
int threaded;
int canceldisable;
- void (*fork_handler)(int);
int (*atexit)(void (*)(void));
void (*fini)(void);
void (*ldso_fini)(void);
#include "libc.h"
#include "pthread_impl.h"
+static void dummy(int x)
+{
+}
+
+weak_alias(dummy, __fork_handler);
+
pid_t fork(void)
{
pid_t ret;
- if (libc.fork_handler) libc.fork_handler(-1);
+ __fork_handler(-1);
ret = syscall(SYS_fork);
if (libc.main_thread && !ret) {
pthread_t self = __pthread_self();
libc.threads_minus_1 = 0;
libc.main_thread = self;
}
- if (libc.fork_handler) libc.fork_handler(!ret);
+ __fork_handler(!ret);
return ret;
}
}
weak_alias(sccp, __syscall_cp);
+
+static void dummy()
+{
+}
+
+weak_alias(dummy, __testcancel);
__syscall(SYS_tgkill, self->pid, self->tid, SIGCANCEL);
}
-static void testcancel()
+void __testcancel()
{
pthread_t self = __pthread_self();
if (self->cancel && !self->canceldisable)
};
sigfillset(&sa.sa_mask);
__libc_sigaction(SIGCANCEL, &sa, 0);
- libc.testcancel = testcancel;
}
int pthread_cancel(pthread_t t)
static int lock;
-static void fork_handler(int who)
+void __fork_handler(int who)
{
struct atfork_funcs *p;
+ if (!funcs) return;
if (who < 0) {
LOCK(&lock);
for (p=funcs; p; p = p->next) {
if (!new) return -1;
LOCK(&lock);
- libc.fork_handler = fork_handler;
new->next = funcs;
new->prev = 0;
new->prepare = prepare;
#include "pthread_impl.h"
+void __testcancel(void);
+
void pthread_testcancel()
{
- if (libc.testcancel) libc.testcancel();
+ __testcancel();
}