projects
/
musl
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
338b663
)
use weak aliases rather than function pointers to simplify some code
author
Rich Felker
<dalias@aerifal.cx>
Sun, 7 Aug 2011 00:09:51 +0000
(20:09 -0400)
committer
Rich Felker
<dalias@aerifal.cx>
Sun, 7 Aug 2011 00:09:51 +0000
(20:09 -0400)
src/internal/libc.h
patch
|
blob
|
history
src/process/fork.c
patch
|
blob
|
history
src/thread/cancel_dummy.c
patch
|
blob
|
history
src/thread/cancel_impl.c
patch
|
blob
|
history
src/thread/pthread_atfork.c
patch
|
blob
|
history
src/thread/pthread_testcancel.c
patch
|
blob
|
history
diff --git
a/src/internal/libc.h
b/src/internal/libc.h
index
929ff97
..
07ed70c
100644
(file)
--- a/
src/internal/libc.h
+++ b/
src/internal/libc.h
@@
-6,10
+6,8
@@
struct __libc {
int *(*errno_location)(void);
struct __libc {
int *(*errno_location)(void);
- void (*testcancel)(void);
int threaded;
int canceldisable;
int threaded;
int canceldisable;
- void (*fork_handler)(int);
int (*atexit)(void (*)(void));
void (*fini)(void);
void (*ldso_fini)(void);
int (*atexit)(void (*)(void));
void (*fini)(void);
void (*ldso_fini)(void);
diff --git
a/src/process/fork.c
b/src/process/fork.c
index
7530ff9
..
a8bdbe0
100644
(file)
--- a/
src/process/fork.c
+++ b/
src/process/fork.c
@@
-3,10
+3,16
@@
#include "libc.h"
#include "pthread_impl.h"
#include "libc.h"
#include "pthread_impl.h"
+static void dummy(int x)
+{
+}
+
+weak_alias(dummy, __fork_handler);
+
pid_t fork(void)
{
pid_t ret;
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();
ret = syscall(SYS_fork);
if (libc.main_thread && !ret) {
pthread_t self = __pthread_self();
@@
-15,6
+21,6
@@
pid_t fork(void)
libc.threads_minus_1 = 0;
libc.main_thread = self;
}
libc.threads_minus_1 = 0;
libc.main_thread = self;
}
-
if (libc.fork_handler) libc.
fork_handler(!ret);
+
__
fork_handler(!ret);
return ret;
}
return ret;
}
diff --git
a/src/thread/cancel_dummy.c
b/src/thread/cancel_dummy.c
index
a39117e
..
047692c
100644
(file)
--- 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);
}
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
9a02e1a
..
4f78a63
100644
(file)
--- 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);
}
__syscall(SYS_tgkill, self->pid, self->tid, SIGCANCEL);
}
-
static void
testcancel()
+
void __
testcancel()
{
pthread_t self = __pthread_self();
if (self->cancel && !self->canceldisable)
{
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);
};
sigfillset(&sa.sa_mask);
__libc_sigaction(SIGCANCEL, &sa, 0);
- libc.testcancel = testcancel;
}
int pthread_cancel(pthread_t t)
}
int pthread_cancel(pthread_t t)
diff --git
a/src/thread/pthread_atfork.c
b/src/thread/pthread_atfork.c
index
0773dc8
..
a7a8201
100644
(file)
--- a/
src/thread/pthread_atfork.c
+++ b/
src/thread/pthread_atfork.c
@@
-10,9
+10,10
@@
static struct atfork_funcs {
static int lock;
static int lock;
-
static void
fork_handler(int who)
+
void __
fork_handler(int who)
{
struct atfork_funcs *p;
{
struct atfork_funcs *p;
+ if (!funcs) return;
if (who < 0) {
LOCK(&lock);
for (p=funcs; p; p = p->next) {
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);
if (!new) return -1;
LOCK(&lock);
- libc.fork_handler = fork_handler;
new->next = funcs;
new->prev = 0;
new->prepare = prepare;
new->next = funcs;
new->prev = 0;
new->prepare = prepare;
diff --git
a/src/thread/pthread_testcancel.c
b/src/thread/pthread_testcancel.c
index
c6b250b
..
33238c0
100644
(file)
--- a/
src/thread/pthread_testcancel.c
+++ b/
src/thread/pthread_testcancel.c
@@
-1,6
+1,8
@@
#include "pthread_impl.h"
#include "pthread_impl.h"
+void __testcancel(void);
+
void pthread_testcancel()
{
void pthread_testcancel()
{
-
if (libc.testcancel) libc.
testcancel();
+
__
testcancel();
}
}