From: Rich Felker Date: Wed, 14 Nov 2012 19:01:39 +0000 (-0500) Subject: Merge remote-tracking branch 'ppc-port/ppc-squashed' X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=c6d441e3a246370d9c459396ec22b096db93850e;hp=1c8eb8bad791fe9d01d0d4ab77882db634fa933d;p=musl Merge remote-tracking branch 'ppc-port/ppc-squashed' --- diff --git a/configure b/configure index 288d65d9..08ef19a2 100755 --- a/configure +++ b/configure @@ -50,9 +50,8 @@ fnmatch () { eval "case \"\$2\" in $1) return 0 ;; *) return 1 ;; esac" ; } cmdexists () { type "$1" >/dev/null 2>&1 ; } trycc () { test -z "$CC" && cmdexists "$1" && CC=$1 ; } -setdir () { -if eval "test -z \"\${$1}\"" ; then eval "$1=\$2" -else eval "fnmatch '*/' \"\${$1}\"" && eval "$1=\${$1%/}" ; fi +stripdir () { +while eval "fnmatch '*/' \"\${$1}\"" ; do eval "$1=\${$1%/}" ; done } tryflag () { @@ -90,15 +89,15 @@ fi CFLAGS_C99FSE= CFLAGS_AUTO= LDFLAGS_AUTO= -prefix= -exec_prefix= -bindir= -libdir= -includedir= -syslibdir= +prefix=/usr/local/musl +exec_prefix='$(prefix)' +bindir='$(exec_prefix)/bin' +libdir='$(prefix)/lib' +includedir='$(prefix)/include' +syslibdir='/lib' target= debug=no -warnings= +warnings=no shared=yes static=yes @@ -135,12 +134,9 @@ LIBCC=*) LIBCC=${arg#*=} ;; esac done -setdir prefix /usr/local/musl -setdir exec_prefix '$(prefix)' -setdir bindir '$(exec_prefix)/bin' -setdir libdir '$(prefix)/lib' -setdir includedir '$(prefix)/include' -setdir syslibdir '/lib' +for i in prefix exec_prefix bindir libdir includedir syslibdir ; do +stripdir $i +done # # Get a temp filename we can use diff --git a/include/pthread.h b/include/pthread.h index 74d86006..660a64d9 100644 --- a/include/pthread.h +++ b/include/pthread.h @@ -91,6 +91,10 @@ int pthread_setcanceltype(int, int *); void pthread_testcancel(void); int pthread_cancel(pthread_t); +int pthread_getschedparam(pthread_t, int *__restrict, struct sched_param *__restrict); +int pthread_setschedparam(pthread_t, int, const struct sched_param *); +int pthread_setschedprio(pthread_t, int); + int pthread_once(pthread_once_t *, void (*)(void)); int pthread_mutex_init(pthread_mutex_t *__restrict, const pthread_mutexattr_t *__restrict); diff --git a/include/sched.h b/include/sched.h index 3df4c7bd..994260d0 100644 --- a/include/sched.h +++ b/include/sched.h @@ -32,6 +32,9 @@ int sched_yield(void); #define SCHED_OTHER 0 #define SCHED_FIFO 1 #define SCHED_RR 2 +#define SCHED_BATCH 3 +#define SCHED_IDLE 5 +#define SCHED_RESET_ON_FORK 0x40000000 #ifdef _GNU_SOURCE #define CSIGNAL 0x000000ff diff --git a/include/spawn.h b/include/spawn.h index a28ae691..92b77f79 100644 --- a/include/spawn.h +++ b/include/spawn.h @@ -55,6 +55,11 @@ int posix_spawnattr_getsigmask(const posix_spawnattr_t *__restrict, sigset_t *__ int posix_spawnattr_setsigdefault(posix_spawnattr_t *__restrict, const sigset_t *__restrict); int posix_spawnattr_getsigdefault(const posix_spawnattr_t *__restrict, sigset_t *__restrict); +int posix_spawnattr_setschedparam(posix_spawnattr_t *__restrict, const struct sched_param *__restrict); +int posix_spawnattr_getschedparam(const posix_spawnattr_t *__restrict, struct sched_param *__restrict); +int posix_spawnattr_setschedpolicy(posix_spawnattr_t *__restrict, int); +int posix_spawnattr_getschedpolicy(const posix_spawnattr_t *__restrict, int *); + int posix_spawn_file_actions_init(posix_spawn_file_actions_t *); int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *); diff --git a/include/unistd.h b/include/unistd.h index bb741e4b..2791c3de 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -225,6 +225,7 @@ void syncfs(int); #define _POSIX_THREAD_SAFE_FUNCTIONS _POSIX_VERSION #define _POSIX_THREAD_ATTR_STACKADDR _POSIX_VERSION #define _POSIX_THREAD_ATTR_STACKSIZE _POSIX_VERSION +#define _POSIX_THREAD_PRIORITY_SCHEDULING _POSIX_VERSION #define _POSIX_TIMERS _POSIX_VERSION #define _POSIX_TIMEOUTS _POSIX_VERSION #define _POSIX_MONOTONIC_CLOCK _POSIX_VERSION diff --git a/src/aio/aio_readwrite.c b/src/aio/aio_readwrite.c index 584ccb3d..e4c95aa2 100644 --- a/src/aio/aio_readwrite.c +++ b/src/aio/aio_readwrite.c @@ -1,5 +1,8 @@ #include #include +#include +#include +#include #include "pthread_impl.h" static void dummy(void) diff --git a/src/aio/lio_listio.c b/src/aio/lio_listio.c index 30f7cc05..53f9f502 100644 --- a/src/aio/lio_listio.c +++ b/src/aio/lio_listio.c @@ -1,5 +1,8 @@ #include #include +#include +#include +#include #include "pthread_impl.h" struct lio_state { diff --git a/src/conf/sysconf.c b/src/conf/sysconf.c index d6691df8..9f0d97b2 100644 --- a/src/conf/sysconf.c +++ b/src/conf/sysconf.c @@ -89,9 +89,9 @@ long sysconf(int name) [_SC_THREAD_KEYS_MAX] = PTHREAD_KEYS_MAX, [_SC_THREAD_STACK_MIN] = PTHREAD_STACK_MIN, [_SC_THREAD_THREADS_MAX] = -1, - [_SC_THREAD_ATTR_STACKADDR] = -1, + [_SC_THREAD_ATTR_STACKADDR] = VER, [_SC_THREAD_ATTR_STACKSIZE] = VER, - [_SC_THREAD_PRIORITY_SCHEDULING] = -1, + [_SC_THREAD_PRIORITY_SCHEDULING] = VER, [_SC_THREAD_PRIO_INHERIT] = -1, [_SC_THREAD_PRIO_PROTECT] = -1, [_SC_THREAD_PROCESS_SHARED] = VER, diff --git a/src/env/__init_tls.c b/src/env/__init_tls.c index c71f49c1..3a1b1f56 100644 --- a/src/env/__init_tls.c +++ b/src/env/__init_tls.c @@ -1,5 +1,7 @@ #include #include +#include +#include #include "pthread_impl.h" #include "libc.h" #include "atomic.h" diff --git a/src/internal/floatscan.c b/src/internal/floatscan.c index 08251213..f6e331d4 100644 --- a/src/internal/floatscan.c +++ b/src/internal/floatscan.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "shgetc.h" #include "floatscan.h" diff --git a/src/internal/i386/syscall.s b/src/internal/i386/syscall.s index 291168c3..2914acee 100644 --- a/src/internal/i386/syscall.s +++ b/src/internal/i386/syscall.s @@ -16,7 +16,8 @@ __vsyscall: mov 12(%esp),%edi push %eax call 1f -2: pop %ebx +2: mov %ebx,%edx + pop %ebx pop %ebx pop %edi ret diff --git a/src/internal/intscan.c b/src/internal/intscan.c index 178cdf0d..69350efa 100644 --- a/src/internal/intscan.c +++ b/src/internal/intscan.c @@ -1,5 +1,6 @@ #include #include +#include #include "shgetc.h" /* Lookup table for digit values. -1==255>=36 -> invalid */ diff --git a/src/internal/pthread_impl.h b/src/internal/pthread_impl.h index 0f10cc48..4215e67a 100644 --- a/src/internal/pthread_impl.h +++ b/src/internal/pthread_impl.h @@ -2,17 +2,9 @@ #define _PTHREAD_IMPL_H #include -#include #include -#include -#include #include #include -#include -#include -#include -#include -#include #include "libc.h" #include "syscall.h" #include "atomic.h" @@ -48,6 +40,8 @@ struct pthread { locale_t locale; int killlock[2]; int exitlock[2]; + int startlock[2]; + unsigned long sigmask[__SYSCALL_SSLEN/sizeof(long)]; }; struct __timer { @@ -61,6 +55,9 @@ struct __timer { #define _a_guardsize __u.__s[1] #define _a_stackaddr __u.__s[2] #define _a_detach __u.__i[3*__SU+0] +#define _a_sched __u.__i[3*__SU+1] +#define _a_policy __u.__i[3*__SU+2] +#define _a_prio __u.__i[3*__SU+3] #define _m_type __u.__i[0] #define _m_lock __u.__i[1] #define _m_waiters __u.__i[2] diff --git a/src/internal/stdio_impl.h b/src/internal/stdio_impl.h index e9045f27..c9d20fac 100644 --- a/src/internal/stdio_impl.h +++ b/src/internal/stdio_impl.h @@ -2,23 +2,6 @@ #define _STDIO_IMPL_H #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "syscall.h" #include "libc.h" diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c index 625f80cc..ba2f6129 100644 --- a/src/ldso/dynlink.c +++ b/src/ldso/dynlink.c @@ -478,13 +478,16 @@ static struct dso *load_library(const char *name) if (!sys_path) { FILE *f = fopen(ETC_LDSO_PATH, "rbe"); if (f) { - if (getline(&sys_path, (size_t[1]){0}, f) > 0) - sys_path[strlen(sys_path)-1]=0; + if (getline(&sys_path, (size_t[1]){0}, f) > 0) { + size_t l = strlen(sys_path); + if (l && sys_path[l-1]=='\n') + sys_path[-1] = 0; + } fclose(f); } } - if (sys_path) fd = path_open(name, sys_path, buf, sizeof buf); - else fd = path_open(name, "/lib:/usr/local/lib:/usr/lib", buf, sizeof buf); + if (!sys_path) sys_path = "/lib:/usr/local/lib:/usr/lib"; + fd = path_open(name, sys_path, buf, sizeof buf); } pathname = buf; } diff --git a/src/process/fork.c b/src/process/fork.c index a8bdbe0b..fb8a430a 100644 --- a/src/process/fork.c +++ b/src/process/fork.c @@ -1,4 +1,5 @@ #include +#include #include "syscall.h" #include "libc.h" #include "pthread_impl.h" diff --git a/src/process/posix_spawnattr_sched.c b/src/process/posix_spawnattr_sched.c new file mode 100644 index 00000000..e2ba0d19 --- /dev/null +++ b/src/process/posix_spawnattr_sched.c @@ -0,0 +1,25 @@ +#include +#include +#include + +int posix_spawnattr_getschedparam(const posix_spawnattr_t *restrict attr, + struct sched_param *restrict schedparam) +{ + return ENOSYS; +} + +int posix_spawnattr_setschedparam(posix_spawnattr_t *restrict attr, + const struct sched_param *restrict schedparam) +{ + return ENOSYS; +} + +int posix_spawnattr_getschedpolicy(const posix_spawnattr_t *restrict attr, int *policy) +{ + return ENOSYS; +} + +int posix_spawnattr_setschedpolicy(posix_spawnattr_t *restrict attr, int policy) +{ + return ENOSYS; +} diff --git a/src/sched/sched_get_priority_max.c b/src/sched/sched_get_priority_max.c index 64cbca93..30ae5100 100644 --- a/src/sched/sched_get_priority_max.c +++ b/src/sched/sched_get_priority_max.c @@ -1,11 +1,12 @@ #include +#include "syscall.h" int sched_get_priority_max(int policy) { - return 0; + return syscall(SYS_sched_get_priority_max, policy); } int sched_get_priority_min(int policy) { - return 0; + return syscall(SYS_sched_get_priority_min, policy); } diff --git a/src/sched/sched_getparam.c b/src/sched/sched_getparam.c index 65be1075..76f10e49 100644 --- a/src/sched/sched_getparam.c +++ b/src/sched/sched_getparam.c @@ -1,7 +1,8 @@ #include +#include #include "syscall.h" int sched_getparam(pid_t pid, struct sched_param *param) { - return syscall(SYS_sched_getparam, pid, param); + return __syscall_ret(-ENOSYS); } diff --git a/src/sched/sched_getscheduler.c b/src/sched/sched_getscheduler.c index 4c922f69..394e508b 100644 --- a/src/sched/sched_getscheduler.c +++ b/src/sched/sched_getscheduler.c @@ -1,7 +1,8 @@ #include +#include #include "syscall.h" int sched_getscheduler(pid_t pid) { - return syscall(SYS_sched_getscheduler, pid); + return __syscall_ret(-ENOSYS); } diff --git a/src/sched/sched_rr_get_interval.c b/src/sched/sched_rr_get_interval.c index 43bc4904..4b01028f 100644 --- a/src/sched/sched_rr_get_interval.c +++ b/src/sched/sched_rr_get_interval.c @@ -5,4 +5,3 @@ int sched_rr_get_interval(pid_t pid, struct timespec *ts) { return syscall(SYS_sched_rr_get_interval, pid, ts); } - diff --git a/src/sched/sched_setparam.c b/src/sched/sched_setparam.c index 07d61aea..18623ee4 100644 --- a/src/sched/sched_setparam.c +++ b/src/sched/sched_setparam.c @@ -1,8 +1,8 @@ #include +#include #include "syscall.h" int sched_setparam(pid_t pid, const struct sched_param *param) { - static const struct sched_param def; - return syscall(SYS_sched_setparam, pid, &def); + return __syscall_ret(-ENOSYS); } diff --git a/src/sched/sched_setscheduler.c b/src/sched/sched_setscheduler.c index 19580660..4435f216 100644 --- a/src/sched/sched_setscheduler.c +++ b/src/sched/sched_setscheduler.c @@ -1,8 +1,8 @@ #include +#include #include "syscall.h" int sched_setscheduler(pid_t pid, int sched, const struct sched_param *param) { - static const struct sched_param def; - return syscall(SYS_sched_setscheduler, pid, 0, &def); + return __syscall_ret(-ENOSYS); } diff --git a/src/signal/sigaction.c b/src/signal/sigaction.c index d9535032..7a72a44b 100644 --- a/src/signal/sigaction.c +++ b/src/signal/sigaction.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "syscall.h" #include "pthread_impl.h" #include "libc.h" diff --git a/src/stdio/__fdopen.c b/src/stdio/__fdopen.c index df6ed71d..59690f6d 100644 --- a/src/stdio/__fdopen.c +++ b/src/stdio/__fdopen.c @@ -1,4 +1,10 @@ #include "stdio_impl.h" +#include +#include +#include +#include +#include +#include FILE *__fdopen(int fd, const char *mode) { diff --git a/src/stdio/__fopen_rb_ca.c b/src/stdio/__fopen_rb_ca.c index a1b1b3b6..9202c8ce 100644 --- a/src/stdio/__fopen_rb_ca.c +++ b/src/stdio/__fopen_rb_ca.c @@ -1,4 +1,6 @@ #include "stdio_impl.h" +#include +#include FILE *__fopen_rb_ca(const char *filename, FILE *f, unsigned char *buf, size_t len) { diff --git a/src/stdio/__stdio_read.c b/src/stdio/__stdio_read.c index c99ca9a9..05e56f92 100644 --- a/src/stdio/__stdio_read.c +++ b/src/stdio/__stdio_read.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include #include static void cleanup(void *p) diff --git a/src/stdio/__stdio_write.c b/src/stdio/__stdio_write.c index cef7bbdc..e52e91ae 100644 --- a/src/stdio/__stdio_write.c +++ b/src/stdio/__stdio_write.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include #include static void cleanup(void *p) diff --git a/src/stdio/__stdout_write.c b/src/stdio/__stdout_write.c index 0cf71236..200fe2c9 100644 --- a/src/stdio/__stdout_write.c +++ b/src/stdio/__stdout_write.c @@ -1,4 +1,6 @@ #include "stdio_impl.h" +#include +#include size_t __stdout_write(FILE *f, const unsigned char *buf, size_t len) { diff --git a/src/stdio/__string_read.c b/src/stdio/__string_read.c index de002fc1..7b50a7e1 100644 --- a/src/stdio/__string_read.c +++ b/src/stdio/__string_read.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include size_t __string_read(FILE *f, unsigned char *buf, size_t len) { diff --git a/src/stdio/fgetln.c b/src/stdio/fgetln.c index 06b88837..a2e4bd3c 100644 --- a/src/stdio/fgetln.c +++ b/src/stdio/fgetln.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include char *fgetln(FILE *f, size_t *plen) { diff --git a/src/stdio/fgets.c b/src/stdio/fgets.c index ee0ac30e..b01a4187 100644 --- a/src/stdio/fgets.c +++ b/src/stdio/fgets.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include #define MIN(a,b) ((a)<(b) ? (a) : (b)) diff --git a/src/stdio/fgetwc.c b/src/stdio/fgetwc.c index 6f9f9ec2..8626d54c 100644 --- a/src/stdio/fgetwc.c +++ b/src/stdio/fgetwc.c @@ -1,4 +1,6 @@ #include "stdio_impl.h" +#include +#include wint_t __fgetwc_unlocked(FILE *f) { diff --git a/src/stdio/fgetws.c b/src/stdio/fgetws.c index fab9bd0f..195cb435 100644 --- a/src/stdio/fgetws.c +++ b/src/stdio/fgetws.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include wint_t __fgetwc_unlocked(FILE *); diff --git a/src/stdio/fmemopen.c b/src/stdio/fmemopen.c index 770fd995..d7849609 100644 --- a/src/stdio/fmemopen.c +++ b/src/stdio/fmemopen.c @@ -1,4 +1,7 @@ #include "stdio_impl.h" +#include +#include +#include struct cookie { size_t pos, len, size; @@ -105,12 +108,13 @@ FILE *fmemopen(void *restrict buf, size_t size, const char *restrict mode) f->seek = mseek; f->close = mclose; - if (!libc.threaded) { - f->lock = -1; - f->next = libc.ofl_head; - if (libc.ofl_head) libc.ofl_head->prev = f; - libc.ofl_head = f; - } + if (!libc.threaded) f->lock = -1; + + OFLLOCK(); + f->next = libc.ofl_head; + if (libc.ofl_head) libc.ofl_head->prev = f; + libc.ofl_head = f; + OFLUNLOCK(); return f; } diff --git a/src/stdio/fopen.c b/src/stdio/fopen.c index c741aede..da17ce8b 100644 --- a/src/stdio/fopen.c +++ b/src/stdio/fopen.c @@ -1,4 +1,7 @@ #include "stdio_impl.h" +#include +#include +#include FILE *fopen(const char *restrict filename, const char *restrict mode) { diff --git a/src/stdio/fputs.c b/src/stdio/fputs.c index b41bc8c7..1112b192 100644 --- a/src/stdio/fputs.c +++ b/src/stdio/fputs.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include int fputs(const char *restrict s, FILE *restrict f) { diff --git a/src/stdio/fputwc.c b/src/stdio/fputwc.c index 45ea8c23..7b621dd2 100644 --- a/src/stdio/fputwc.c +++ b/src/stdio/fputwc.c @@ -1,4 +1,7 @@ #include "stdio_impl.h" +#include +#include +#include wint_t __fputwc_unlocked(wchar_t c, FILE *f) { diff --git a/src/stdio/fputws.c b/src/stdio/fputws.c index 0b593c08..5723cbcd 100644 --- a/src/stdio/fputws.c +++ b/src/stdio/fputws.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include int fputws(const wchar_t *restrict ws, FILE *restrict f) { diff --git a/src/stdio/fread.c b/src/stdio/fread.c index 3f31af8a..c461256c 100644 --- a/src/stdio/fread.c +++ b/src/stdio/fread.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include #define MIN(a,b) ((a)<(b) ? (a) : (b)) diff --git a/src/stdio/freopen.c b/src/stdio/freopen.c index 7ae116d8..6c1b575f 100644 --- a/src/stdio/freopen.c +++ b/src/stdio/freopen.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include /* The basic idea of this implementation is to open a new FILE, * hack the necessary parts of the new FILE into the old one, then diff --git a/src/stdio/ftell.c b/src/stdio/ftell.c index 3904a1d8..82371e37 100644 --- a/src/stdio/ftell.c +++ b/src/stdio/ftell.c @@ -1,4 +1,6 @@ #include "stdio_impl.h" +#include +#include off_t __ftello_unlocked(FILE *f) { diff --git a/src/stdio/ftrylockfile.c b/src/stdio/ftrylockfile.c index 725c4c3e..eef4e250 100644 --- a/src/stdio/ftrylockfile.c +++ b/src/stdio/ftrylockfile.c @@ -1,5 +1,6 @@ #include "stdio_impl.h" #include "pthread_impl.h" +#include int ftrylockfile(FILE *f) { diff --git a/src/stdio/fwrite.c b/src/stdio/fwrite.c index 8027b306..d5f6542d 100644 --- a/src/stdio/fwrite.c +++ b/src/stdio/fwrite.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include size_t __fwritex(const unsigned char *restrict s, size_t l, FILE *restrict f) { diff --git a/src/stdio/getdelim.c b/src/stdio/getdelim.c index 5015c3a6..26093a6c 100644 --- a/src/stdio/getdelim.c +++ b/src/stdio/getdelim.c @@ -1,4 +1,7 @@ #include "stdio_impl.h" +#include +#include +#include #define MIN(a,b) ((a)<(b) ? (a) : (b)) diff --git a/src/stdio/gets.c b/src/stdio/gets.c index 24319eb2..6c4645e5 100644 --- a/src/stdio/gets.c +++ b/src/stdio/gets.c @@ -1,4 +1,6 @@ #include "stdio_impl.h" +#include +#include char *gets(char *s) { diff --git a/src/stdio/getwc.c b/src/stdio/getwc.c index a2818bc4..a5008f0e 100644 --- a/src/stdio/getwc.c +++ b/src/stdio/getwc.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include wint_t getwc(FILE *f) { diff --git a/src/stdio/getwchar.c b/src/stdio/getwchar.c index 2295bd40..bd89e0ec 100644 --- a/src/stdio/getwchar.c +++ b/src/stdio/getwchar.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include wint_t getwchar(void) { diff --git a/src/stdio/open_memstream.c b/src/stdio/open_memstream.c index 687e818d..9eafdfba 100644 --- a/src/stdio/open_memstream.c +++ b/src/stdio/open_memstream.c @@ -1,4 +1,7 @@ #include "stdio_impl.h" +#include +#include +#include struct cookie { char **bufp; @@ -74,12 +77,13 @@ FILE *open_memstream(char **bufp, size_t *sizep) f->seek = ms_seek; f->close = ms_close; - if (!libc.threaded) { - f->lock = -1; - f->next = libc.ofl_head; - if (libc.ofl_head) libc.ofl_head->prev = f; - libc.ofl_head = f; - } + if (!libc.threaded) f->lock = -1; + + OFLLOCK(); + f->next = libc.ofl_head; + if (libc.ofl_head) libc.ofl_head->prev = f; + libc.ofl_head = f; + OFLUNLOCK(); return f; } diff --git a/src/stdio/open_wmemstream.c b/src/stdio/open_wmemstream.c index a830b143..35370309 100644 --- a/src/stdio/open_wmemstream.c +++ b/src/stdio/open_wmemstream.c @@ -1,4 +1,8 @@ #include "stdio_impl.h" +#include +#include +#include +#include struct cookie { wchar_t **bufp; @@ -75,12 +79,13 @@ FILE *open_wmemstream(wchar_t **bufp, size_t *sizep) f->seek = wms_seek; f->close = wms_close; - if (!libc.threaded) { - f->lock = -1; - f->next = libc.ofl_head; - if (libc.ofl_head) libc.ofl_head->prev = f; - libc.ofl_head = f; - } + if (!libc.threaded) f->lock = -1; + + OFLLOCK(); + f->next = libc.ofl_head; + if (libc.ofl_head) libc.ofl_head->prev = f; + libc.ofl_head = f; + OFLUNLOCK(); return f; } diff --git a/src/stdio/pclose.c b/src/stdio/pclose.c index 7fb76ed4..080a4262 100644 --- a/src/stdio/pclose.c +++ b/src/stdio/pclose.c @@ -1,5 +1,6 @@ #include "stdio_impl.h" -#include "syscall.h" +#include +#include int pclose(FILE *f) { diff --git a/src/stdio/popen.c b/src/stdio/popen.c index ca3cdf9d..ed20f5a1 100644 --- a/src/stdio/popen.c +++ b/src/stdio/popen.c @@ -1,4 +1,7 @@ #include +#include +#include +#include #include "stdio_impl.h" #include "pthread_impl.h" #include "syscall.h" diff --git a/src/stdio/putwc.c b/src/stdio/putwc.c index 80b54a47..4bb74733 100644 --- a/src/stdio/putwc.c +++ b/src/stdio/putwc.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include wint_t putwc(wchar_t c, FILE *f) { diff --git a/src/stdio/putwchar.c b/src/stdio/putwchar.c index 3aacc1cf..b249c4ac 100644 --- a/src/stdio/putwchar.c +++ b/src/stdio/putwchar.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include wint_t putwchar(wchar_t c) { diff --git a/src/stdio/ungetwc.c b/src/stdio/ungetwc.c index 5282fee1..8cc85a6b 100644 --- a/src/stdio/ungetwc.c +++ b/src/stdio/ungetwc.c @@ -1,4 +1,8 @@ #include "stdio_impl.h" +#include +#include +#include +#include wint_t ungetwc(wint_t c, FILE *f) { diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c index 4a2752b2..1e7e6a47 100644 --- a/src/stdio/vfprintf.c +++ b/src/stdio/vfprintf.c @@ -1,4 +1,13 @@ #include "stdio_impl.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include /* Some useful macros */ diff --git a/src/stdio/vfscanf.c b/src/stdio/vfscanf.c index 54d08495..fe071e95 100644 --- a/src/stdio/vfscanf.c +++ b/src/stdio/vfscanf.c @@ -1,4 +1,3 @@ -#include #include #include #include @@ -9,6 +8,7 @@ #include #include #include +#include #include "stdio_impl.h" #include "shgetc.h" diff --git a/src/stdio/vfwprintf.c b/src/stdio/vfwprintf.c index a42ba195..eb079312 100644 --- a/src/stdio/vfwprintf.c +++ b/src/stdio/vfwprintf.c @@ -1,4 +1,11 @@ #include "stdio_impl.h" +#include +#include +#include +#include +#include +#include +#include /* Convenient bit representation for modifier flags, which all fall * within 31 codepoints of the space character. */ diff --git a/src/stdio/vsnprintf.c b/src/stdio/vsnprintf.c index 6f19b028..be2c44eb 100644 --- a/src/stdio/vsnprintf.c +++ b/src/stdio/vsnprintf.c @@ -1,4 +1,8 @@ #include "stdio_impl.h" +#include +#include +#include +#include static size_t sn_write(FILE *f, const unsigned char *s, size_t l) { diff --git a/src/stdio/vswprintf.c b/src/stdio/vswprintf.c index f3d4fec1..7d237bae 100644 --- a/src/stdio/vswprintf.c +++ b/src/stdio/vswprintf.c @@ -1,4 +1,9 @@ #include "stdio_impl.h" +#include +#include +#include +#include +#include struct cookie { wchar_t *ws; diff --git a/src/stdio/vswscanf.c b/src/stdio/vswscanf.c index a205200a..7a2f7c7a 100644 --- a/src/stdio/vswscanf.c +++ b/src/stdio/vswscanf.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include static size_t wstring_read(FILE *f, unsigned char *buf, size_t len) { diff --git a/src/stdlib/strtol.c b/src/stdlib/strtol.c index 23a2f3b6..7ee88794 100644 --- a/src/stdlib/strtol.c +++ b/src/stdlib/strtol.c @@ -1,6 +1,9 @@ #include "stdio_impl.h" #include "intscan.h" #include "shgetc.h" +#include +#include +#include static unsigned long long strtox(const char *s, char **p, int base, unsigned long long lim) { diff --git a/src/stdlib/wcstod.c b/src/stdlib/wcstod.c index 03670b0b..83f308d3 100644 --- a/src/stdlib/wcstod.c +++ b/src/stdlib/wcstod.c @@ -1,6 +1,7 @@ #include "shgetc.h" #include "floatscan.h" #include "stdio_impl.h" +#include /* This read function heavily cheats. It knows: * (1) len will always be 1 diff --git a/src/stdlib/wcstol.c b/src/stdlib/wcstol.c index 3d7c97da..4443f577 100644 --- a/src/stdlib/wcstol.c +++ b/src/stdlib/wcstol.c @@ -1,6 +1,10 @@ #include "stdio_impl.h" #include "intscan.h" #include "shgetc.h" +#include +#include +#include +#include /* This read function heavily cheats. It knows: * (1) len will always be 1 diff --git a/src/thread/__wake.c b/src/thread/__wake.c index 8fd0599c..d8bf70f7 100644 --- a/src/thread/__wake.c +++ b/src/thread/__wake.c @@ -1,4 +1,5 @@ #include "pthread_impl.h" +#include void __wake(volatile int *addr, int cnt, int priv) { diff --git a/src/thread/pthread_attr_get.c b/src/thread/pthread_attr_get.c new file mode 100644 index 00000000..f81103d8 --- /dev/null +++ b/src/thread/pthread_attr_get.c @@ -0,0 +1,93 @@ +#include "pthread_impl.h" + +int pthread_attr_getdetachstate(const pthread_attr_t *a, int *state) +{ + *state = a->_a_detach; + return 0; +} +int pthread_attr_getguardsize(const pthread_attr_t *restrict a, size_t *restrict size) +{ + *size = a->_a_guardsize + DEFAULT_GUARD_SIZE; + return 0; +} + +int pthread_attr_getinheritsched(const pthread_attr_t *a, int *inherit) +{ + *inherit = a->_a_sched; + return 0; +} + +int pthread_attr_getschedparam(const pthread_attr_t *restrict a, struct sched_param *restrict param) +{ + param->sched_priority = a->_a_prio; + return 0; +} + +int pthread_attr_getschedpolicy(const pthread_attr_t *a, int *policy) +{ + *policy = a->_a_policy; + return 0; +} + +int pthread_attr_getscope(const pthread_attr_t *restrict a, int *restrict scope) +{ + *scope = PTHREAD_SCOPE_SYSTEM; + return 0; +} + +int pthread_attr_getstack(const pthread_attr_t *restrict a, void **restrict addr, size_t *restrict size) +{ + if (!a->_a_stackaddr) + return EINVAL; + *size = a->_a_stacksize + DEFAULT_STACK_SIZE; + *addr = (void *)(a->_a_stackaddr - *size); + return 0; +} + +int pthread_attr_getstacksize(const pthread_attr_t *restrict a, size_t *restrict size) +{ + *size = a->_a_stacksize + DEFAULT_STACK_SIZE; + return 0; +} + +int pthread_barrierattr_getpshared(const pthread_barrierattr_t *restrict a, int *restrict pshared) +{ + *pshared = !!*a; + return 0; +} + +int pthread_condattr_getclock(const pthread_condattr_t *restrict a, clockid_t *restrict clk) +{ + *clk = *a & 0x7fffffff; + return 0; +} + +int pthread_condattr_getpshared(const pthread_condattr_t *restrict a, int *restrict pshared) +{ + *pshared = *a>>31; + return 0; +} + +int pthread_mutexattr_getpshared(const pthread_mutexattr_t *restrict a, int *restrict pshared) +{ + *pshared = *a>>31; + return 0; +} + +int pthread_mutexattr_getrobust(const pthread_mutexattr_t *restrict a, int *restrict robust) +{ + *robust = *a / 4U % 2; + return 0; +} + +int pthread_mutexattr_gettype(const pthread_mutexattr_t *restrict a, int *restrict type) +{ + *type = *a & 3; + return 0; +} + +int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *restrict a, int *restrict pshared) +{ + *pshared = *(int *)a; + return 0; +} diff --git a/src/thread/pthread_attr_getdetachstate.c b/src/thread/pthread_attr_getdetachstate.c deleted file mode 100644 index 47c4c023..00000000 --- a/src/thread/pthread_attr_getdetachstate.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "pthread_impl.h" - -int pthread_attr_getdetachstate(const pthread_attr_t *a, int *state) -{ - *state = a->_a_detach; - return 0; -} diff --git a/src/thread/pthread_attr_getguardsize.c b/src/thread/pthread_attr_getguardsize.c deleted file mode 100644 index 93ba05dd..00000000 --- a/src/thread/pthread_attr_getguardsize.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "pthread_impl.h" - -int pthread_attr_getguardsize(const pthread_attr_t *restrict a, size_t *restrict size) -{ - *size = a->_a_guardsize + DEFAULT_GUARD_SIZE; - return 0; -} diff --git a/src/thread/pthread_attr_getschedparam.c b/src/thread/pthread_attr_getschedparam.c deleted file mode 100644 index 5806bdf1..00000000 --- a/src/thread/pthread_attr_getschedparam.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "pthread_impl.h" - -int pthread_attr_getschedparam(const pthread_attr_t *restrict a, struct sched_param *restrict param) -{ - param->sched_priority = 0; - return 0; -} diff --git a/src/thread/pthread_attr_getscope.c b/src/thread/pthread_attr_getscope.c deleted file mode 100644 index c0167b6a..00000000 --- a/src/thread/pthread_attr_getscope.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "pthread_impl.h" - -int pthread_attr_getscope(const pthread_attr_t *restrict a, int *restrict scope) -{ - return 0; -} diff --git a/src/thread/pthread_attr_getstack.c b/src/thread/pthread_attr_getstack.c deleted file mode 100644 index 70adbb03..00000000 --- a/src/thread/pthread_attr_getstack.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "pthread_impl.h" - -int pthread_attr_getstack(const pthread_attr_t *restrict a, void **restrict addr, size_t *restrict size) -{ - if (!a->_a_stackaddr) - return EINVAL; - *size = a->_a_stacksize + DEFAULT_STACK_SIZE; - *addr = (void *)(a->_a_stackaddr - *size); - return 0; -} diff --git a/src/thread/pthread_attr_getstacksize.c b/src/thread/pthread_attr_getstacksize.c deleted file mode 100644 index f69cc1e6..00000000 --- a/src/thread/pthread_attr_getstacksize.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "pthread_impl.h" - -int pthread_attr_getstacksize(const pthread_attr_t *restrict a, size_t *restrict size) -{ - *size = a->_a_stacksize + DEFAULT_STACK_SIZE; - return 0; -} diff --git a/src/thread/pthread_attr_init.c b/src/thread/pthread_attr_init.c index d91bf157..66934889 100644 --- a/src/thread/pthread_attr_init.c +++ b/src/thread/pthread_attr_init.c @@ -1,7 +1,8 @@ #include "pthread_impl.h" +#include int pthread_attr_init(pthread_attr_t *a) { - memset(a, 0, sizeof *a); + *a = (pthread_attr_t){0}; return 0; } diff --git a/src/thread/pthread_attr_setinheritsched.c b/src/thread/pthread_attr_setinheritsched.c new file mode 100644 index 00000000..c91d8f83 --- /dev/null +++ b/src/thread/pthread_attr_setinheritsched.c @@ -0,0 +1,8 @@ +#include "pthread_impl.h" + +int pthread_attr_setinheritsched(pthread_attr_t *a, int inherit) +{ + if (inherit > 1U) return EINVAL; + a->_a_sched = inherit; + return 0; +} diff --git a/src/thread/pthread_attr_setschedparam.c b/src/thread/pthread_attr_setschedparam.c index 77ce9c98..d4c1204f 100644 --- a/src/thread/pthread_attr_setschedparam.c +++ b/src/thread/pthread_attr_setschedparam.c @@ -2,6 +2,6 @@ int pthread_attr_setschedparam(pthread_attr_t *restrict a, const struct sched_param *restrict param) { - if (param->sched_priority) return ENOTSUP; + a->_a_prio = param->sched_priority; return 0; } diff --git a/src/thread/pthread_attr_setschedpolicy.c b/src/thread/pthread_attr_setschedpolicy.c new file mode 100644 index 00000000..bb71f393 --- /dev/null +++ b/src/thread/pthread_attr_setschedpolicy.c @@ -0,0 +1,7 @@ +#include "pthread_impl.h" + +int pthread_attr_setschedpolicy(pthread_attr_t *a, int policy) +{ + a->_a_policy = policy; + return 0; +} diff --git a/src/thread/pthread_attr_setscope.c b/src/thread/pthread_attr_setscope.c index d56ee391..46b520c0 100644 --- a/src/thread/pthread_attr_setscope.c +++ b/src/thread/pthread_attr_setscope.c @@ -2,6 +2,12 @@ int pthread_attr_setscope(pthread_attr_t *a, int scope) { - if (scope > 1U) return EINVAL; - return 0; + switch (scope) { + case PTHREAD_SCOPE_SYSTEM: + return 0; + case PTHREAD_SCOPE_PROCESS: + return ENOTSUP; + default: + return EINVAL; + } } diff --git a/src/thread/pthread_barrierattr_getpshared.c b/src/thread/pthread_barrierattr_getpshared.c deleted file mode 100644 index df337c29..00000000 --- a/src/thread/pthread_barrierattr_getpshared.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "pthread_impl.h" - -int pthread_barrierattr_getpshared(const pthread_barrierattr_t *restrict a, int *restrict pshared) -{ - *pshared = !!*a; - return 0; -} diff --git a/src/thread/pthread_barrierattr_init.c b/src/thread/pthread_barrierattr_init.c index f2698272..fa742bb7 100644 --- a/src/thread/pthread_barrierattr_init.c +++ b/src/thread/pthread_barrierattr_init.c @@ -2,6 +2,6 @@ int pthread_barrierattr_init(pthread_barrierattr_t *a) { - memset(a, 0, sizeof *a); + *a = (pthread_barrierattr_t){0}; return 0; } diff --git a/src/thread/pthread_cond_init.c b/src/thread/pthread_cond_init.c index 2eac30f1..71489bca 100644 --- a/src/thread/pthread_cond_init.c +++ b/src/thread/pthread_cond_init.c @@ -2,7 +2,7 @@ int pthread_cond_init(pthread_cond_t *restrict c, const pthread_condattr_t *restrict a) { - memset(c, 0, sizeof *c); + *c = (pthread_cond_t){0}; if (a) { c->_c_clock = *a & 0x7fffffff; if (*a>>31) c->_c_mutex = (void *)-1; diff --git a/src/thread/pthread_condattr_getclock.c b/src/thread/pthread_condattr_getclock.c deleted file mode 100644 index d2933843..00000000 --- a/src/thread/pthread_condattr_getclock.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "pthread_impl.h" - -int pthread_condattr_getclock(const pthread_condattr_t *restrict a, clockid_t *restrict clk) -{ - *clk = *a & 0x7fffffff; - return 0; -} diff --git a/src/thread/pthread_condattr_getpshared.c b/src/thread/pthread_condattr_getpshared.c deleted file mode 100644 index 4991e495..00000000 --- a/src/thread/pthread_condattr_getpshared.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "pthread_impl.h" - -int pthread_condattr_getpshared(const pthread_condattr_t *restrict a, int *restrict pshared) -{ - *pshared = *a>>31; - return 0; -} diff --git a/src/thread/pthread_condattr_init.c b/src/thread/pthread_condattr_init.c index 6d09ac1e..a41741b4 100644 --- a/src/thread/pthread_condattr_init.c +++ b/src/thread/pthread_condattr_init.c @@ -2,6 +2,6 @@ int pthread_condattr_init(pthread_condattr_t *a) { - memset(a, 0, sizeof *a); + *a = (pthread_condattr_t){0}; return 0; } diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c index e67616e7..a65e88e1 100644 --- a/src/thread/pthread_create.c +++ b/src/thread/pthread_create.c @@ -1,5 +1,6 @@ #include "pthread_impl.h" #include "stdio_impl.h" +#include static void dummy_0() { @@ -61,6 +62,15 @@ void __do_cleanup_pop(struct __ptcb *cb) static int start(void *p) { pthread_t self = p; + if (self->startlock[0]) { + __wait(self->startlock, 0, 1, 1); + if (self->startlock[0]) { + self->detached = 2; + pthread_exit(0); + } + __syscall(SYS_rt_sigprocmask, SIG_SETMASK, + self->sigmask, 0, __SYSCALL_SSLEN); + } if (self->unblock_cancel) __syscall(SYS_rt_sigprocmask, SIG_UNBLOCK, SIGPT_SET, 0, __SYSCALL_SSLEN); @@ -94,6 +104,7 @@ int pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict attr, struct pthread *self = pthread_self(), *new; unsigned char *map, *stack, *tsd; unsigned flags = 0x7d8f00; + int do_sched = 0; if (!self) return ENOSYS; if (!libc.threaded) { @@ -143,6 +154,11 @@ int pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict attr, new->detached = 1; flags -= 0x200000; } + if (attr && attr->_a_sched) { + do_sched = new->startlock[0] = 1; + __syscall(SYS_rt_sigprocmask, SIG_BLOCK, + SIGALL_SET, self->sigmask, __SYSCALL_SSLEN); + } new->unblock_cancel = self->cancel; new->canary = self->canary; @@ -151,11 +167,25 @@ int pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict attr, __release_ptc(); + if (do_sched) { + __syscall(SYS_rt_sigprocmask, SIG_SETMASK, + new->sigmask, 0, __SYSCALL_SSLEN); + } + if (ret < 0) { a_dec(&libc.threads_minus_1); munmap(map, size); return EAGAIN; } + + if (do_sched) { + ret = __syscall(SYS_sched_setscheduler, new->tid, + attr->_a_policy, &attr->_a_prio); + a_store(new->startlock, ret<0 ? 2 : 0); + __wake(new->startlock, 1, 1); + if (ret < 0) return -ret; + } + *res = new; return 0; } diff --git a/src/thread/pthread_getschedparam.c b/src/thread/pthread_getschedparam.c new file mode 100644 index 00000000..7b6a95f1 --- /dev/null +++ b/src/thread/pthread_getschedparam.c @@ -0,0 +1,17 @@ +#include "pthread_impl.h" + +int pthread_getschedparam(pthread_t t, int *restrict policy, struct sched_param *restrict param) +{ + int r; + __lock(t->killlock); + if (t->dead) { + r = ESRCH; + } else { + r = -__syscall(SYS_sched_getparam, t->tid, ¶m); + if (!r) { + *policy = __syscall(SYS_sched_getscheduler, t->tid); + } + } + __unlock(t->killlock); + return r; +} diff --git a/src/thread/pthread_join.c b/src/thread/pthread_join.c index 86191f25..719c91ca 100644 --- a/src/thread/pthread_join.c +++ b/src/thread/pthread_join.c @@ -1,4 +1,5 @@ #include "pthread_impl.h" +#include static void dummy(void *p) { diff --git a/src/thread/pthread_mutex_init.c b/src/thread/pthread_mutex_init.c index fb689271..a7ba39ba 100644 --- a/src/thread/pthread_mutex_init.c +++ b/src/thread/pthread_mutex_init.c @@ -2,7 +2,7 @@ int pthread_mutex_init(pthread_mutex_t *restrict m, const pthread_mutexattr_t *restrict a) { - memset(m, 0, sizeof *m); + *m = (pthread_mutex_t){0}; if (a) m->_m_type = *a & 7; return 0; } diff --git a/src/thread/pthread_mutexattr_getpshared.c b/src/thread/pthread_mutexattr_getpshared.c deleted file mode 100644 index e7340b1a..00000000 --- a/src/thread/pthread_mutexattr_getpshared.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "pthread_impl.h" - -int pthread_mutexattr_getpshared(const pthread_mutexattr_t *restrict a, int *restrict pshared) -{ - *pshared = *a>>31; - return 0; -} diff --git a/src/thread/pthread_mutexattr_getrobust.c b/src/thread/pthread_mutexattr_getrobust.c deleted file mode 100644 index 4d176f20..00000000 --- a/src/thread/pthread_mutexattr_getrobust.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "pthread_impl.h" - -int pthread_mutexattr_getrobust(const pthread_mutexattr_t *restrict a, int *restrict robust) -{ - *robust = *a / 4U % 2; - return 0; -} diff --git a/src/thread/pthread_mutexattr_gettype.c b/src/thread/pthread_mutexattr_gettype.c deleted file mode 100644 index 7688b068..00000000 --- a/src/thread/pthread_mutexattr_gettype.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "pthread_impl.h" - -int pthread_mutexattr_gettype(const pthread_mutexattr_t *restrict a, int *restrict type) -{ - *type = *a & 3; - return 0; -} diff --git a/src/thread/pthread_mutexattr_init.c b/src/thread/pthread_mutexattr_init.c index ea631069..0b72c1ba 100644 --- a/src/thread/pthread_mutexattr_init.c +++ b/src/thread/pthread_mutexattr_init.c @@ -2,6 +2,6 @@ int pthread_mutexattr_init(pthread_mutexattr_t *a) { - memset(a, 0, sizeof *a); + *a = (pthread_mutexattr_t){0}; return 0; } diff --git a/src/thread/pthread_rwlock_init.c b/src/thread/pthread_rwlock_init.c index 29003bc6..82df52e2 100644 --- a/src/thread/pthread_rwlock_init.c +++ b/src/thread/pthread_rwlock_init.c @@ -2,7 +2,7 @@ int pthread_rwlock_init(pthread_rwlock_t *restrict rw, const pthread_rwlockattr_t *restrict a) { - memset(rw, 0, sizeof *rw); + *rw = (pthread_rwlock_t){0}; if (a) { } return 0; diff --git a/src/thread/pthread_rwlockattr_getpshared.c b/src/thread/pthread_rwlockattr_getpshared.c deleted file mode 100644 index 02fd8c80..00000000 --- a/src/thread/pthread_rwlockattr_getpshared.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "pthread_impl.h" - -int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *restrict a, int *restrict pshared) -{ - *pshared = *(int *)a; - return 0; -} diff --git a/src/thread/pthread_rwlockattr_init.c b/src/thread/pthread_rwlockattr_init.c index e0893d67..e7420694 100644 --- a/src/thread/pthread_rwlockattr_init.c +++ b/src/thread/pthread_rwlockattr_init.c @@ -2,6 +2,6 @@ int pthread_rwlockattr_init(pthread_rwlockattr_t *a) { - memset(a, 0, sizeof *a); + *a = (pthread_rwlockattr_t){0}; return 0; } diff --git a/src/thread/pthread_setschedparam.c b/src/thread/pthread_setschedparam.c new file mode 100644 index 00000000..8e8b5a19 --- /dev/null +++ b/src/thread/pthread_setschedparam.c @@ -0,0 +1,10 @@ +#include "pthread_impl.h" + +int pthread_setschedparam(pthread_t t, int policy, const struct sched_param *param) +{ + int r; + __lock(t->killlock); + r = t->dead ? ESRCH : -__syscall(SYS_sched_setscheduler, t->tid, policy, ¶m); + __unlock(t->killlock); + return r; +} diff --git a/src/thread/pthread_setschedprio.c b/src/thread/pthread_setschedprio.c new file mode 100644 index 00000000..e0bdc03b --- /dev/null +++ b/src/thread/pthread_setschedprio.c @@ -0,0 +1,10 @@ +#include "pthread_impl.h" + +int pthread_setschedprio(pthread_t t, int prio) +{ + int r; + __lock(t->killlock); + r = t->dead ? ESRCH : -__syscall(SYS_sched_setparam, t->tid, &prio); + __unlock(t->killlock); + return r; +} diff --git a/src/thread/synccall.c b/src/thread/synccall.c index 2b7eac25..dc59863f 100644 --- a/src/thread/synccall.c +++ b/src/thread/synccall.c @@ -1,5 +1,6 @@ #include "pthread_impl.h" #include +#include static struct chain { struct chain *next; diff --git a/src/time/timer_create.c b/src/time/timer_create.c index 560f1a84..60a18c71 100644 --- a/src/time/timer_create.c +++ b/src/time/timer_create.c @@ -1,4 +1,5 @@ #include +#include #include "pthread_impl.h" struct ksigevent {