From 98acf04fc00cbded6169056f2cd541d31725c091 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sat, 6 Aug 2011 20:09:51 -0400 Subject: use weak aliases rather than function pointers to simplify some code --- src/thread/cancel_dummy.c | 6 ++++++ src/thread/cancel_impl.c | 3 +-- src/thread/pthread_atfork.c | 4 ++-- src/thread/pthread_testcancel.c | 4 +++- 4 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src/thread') diff --git a/src/thread/cancel_dummy.c b/src/thread/cancel_dummy.c index a39117e7..047692c4 100644 --- a/src/thread/cancel_dummy.c +++ b/src/thread/cancel_dummy.c @@ -6,3 +6,9 @@ static long sccp(long nr, long u, long v, long w, long x, long y, long z) } weak_alias(sccp, __syscall_cp); + +static void dummy() +{ +} + +weak_alias(dummy, __testcancel); diff --git a/src/thread/cancel_impl.c b/src/thread/cancel_impl.c index 9a02e1a1..4f78a63a 100644 --- a/src/thread/cancel_impl.c +++ b/src/thread/cancel_impl.c @@ -58,7 +58,7 @@ static void cancel_handler(int sig, siginfo_t *si, void *ctx) __syscall(SYS_tgkill, self->pid, self->tid, SIGCANCEL); } -static void testcancel() +void __testcancel() { pthread_t self = __pthread_self(); if (self->cancel && !self->canceldisable) @@ -73,7 +73,6 @@ static void init_cancellation() }; sigfillset(&sa.sa_mask); __libc_sigaction(SIGCANCEL, &sa, 0); - libc.testcancel = testcancel; } int pthread_cancel(pthread_t t) diff --git a/src/thread/pthread_atfork.c b/src/thread/pthread_atfork.c index 0773dc8f..a7a82016 100644 --- a/src/thread/pthread_atfork.c +++ b/src/thread/pthread_atfork.c @@ -10,9 +10,10 @@ static struct atfork_funcs { 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) { @@ -35,7 +36,6 @@ int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(vo if (!new) return -1; LOCK(&lock); - libc.fork_handler = fork_handler; new->next = funcs; new->prev = 0; new->prepare = prepare; diff --git a/src/thread/pthread_testcancel.c b/src/thread/pthread_testcancel.c index c6b250b2..33238c0f 100644 --- a/src/thread/pthread_testcancel.c +++ b/src/thread/pthread_testcancel.c @@ -1,6 +1,8 @@ #include "pthread_impl.h" +void __testcancel(void); + void pthread_testcancel() { - if (libc.testcancel) libc.testcancel(); + __testcancel(); } -- cgit v1.2.1