diff options
author | Rich Felker <dalias@aerifal.cx> | 2018-05-09 00:33:54 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2018-05-09 00:37:49 -0400 |
commit | 40bae2d32fd6f3ffea437fa745ad38a1fe77b27e (patch) | |
tree | a69ba86fa80860f0248778a782c0b18a226bc0c2 /src/thread/pthread_attr_setinheritsched.c | |
parent | b8742f32602add243ee2ce74d804015463726899 (diff) | |
download | musl-40bae2d32fd6f3ffea437fa745ad38a1fe77b27e.tar.gz musl-40bae2d32fd6f3ffea437fa745ad38a1fe77b27e.tar.bz2 musl-40bae2d32fd6f3ffea437fa745ad38a1fe77b27e.tar.xz musl-40bae2d32fd6f3ffea437fa745ad38a1fe77b27e.zip |
make linking of thread-start with explicit scheduling conditional
the wrapper start function that performs scheduling operations is
unreachable if pthread_attr_setinheritsched is never called, so move
it there rather than the pthread_create source file, saving some code
size for static-linked programs.
Diffstat (limited to 'src/thread/pthread_attr_setinheritsched.c')
-rw-r--r-- | src/thread/pthread_attr_setinheritsched.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/thread/pthread_attr_setinheritsched.c b/src/thread/pthread_attr_setinheritsched.c index c91d8f83..e540e846 100644 --- a/src/thread/pthread_attr_setinheritsched.c +++ b/src/thread/pthread_attr_setinheritsched.c @@ -1,4 +1,25 @@ #include "pthread_impl.h" +#include "syscall.h" + +__attribute__((__visibility__("hidden"))) +void *__start_sched(void *p) +{ + struct start_sched_args *ssa = p; + void *start_arg = ssa->start_arg; + void *(*start_fn)(void *) = ssa->start_fn; + pthread_t self = __pthread_self(); + + int ret = -__syscall(SYS_sched_setscheduler, self->tid, + ssa->attr->_a_policy, &ssa->attr->_a_prio); + if (!ret) __restore_sigs(&ssa->mask); + a_store(&ssa->futex, ret); + __wake(&ssa->futex, 1, 1); + if (ret) { + self->detach_state = DT_DYNAMIC; + return 0; + } + return start_fn(start_arg); +} int pthread_attr_setinheritsched(pthread_attr_t *a, int inherit) { |