diff options
author | Marco S Hyman <marc@cvs.openbsd.org> | 2003-01-20 18:14:08 +0000 |
---|---|---|
committer | Marco S Hyman <marc@cvs.openbsd.org> | 2003-01-20 18:14:08 +0000 |
commit | c5096ab4c44e5aed99315679574e81e270fb4809 (patch) | |
tree | 86b207068338df3afac4a3efdab88bb8b6eed0ee | |
parent | d3bdabb3046fb37820a5c22ffb36e55c5c3f7fa1 (diff) |
bye-bye libc_r sources.
the sources have been moved (with history) to /usr/src/lib/libpthread
244 files changed, 0 insertions, 25476 deletions
diff --git a/lib/libc_r/BENCH/Makefile b/lib/libc_r/BENCH/Makefile deleted file mode 100644 index ce0bbe95024..00000000000 --- a/lib/libc_r/BENCH/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# $OpenBSD: Makefile,v 1.3 2000/10/12 01:41:20 brad Exp $ - -DEBUG = -ggdb -CFLAGS += -Wall -LDFLAGS += -pthread -METRICS = null once_overhead self_overhead mutex_nocont mutex_cont\ - cond_nowait cond_timed -MKDEP = -p -SRCS = ${METRICS:=.c} -CLEANFILES += ${METRICS} - -all: ${METRICS} - @${SUDO} /usr/bin/nice -n -19 sh -c \ - 'ulimit -d 65536; for m in ${METRICS}; do ${.OBJDIR}/$$m || exit; done' - -.include <bsd.prog.mk> diff --git a/lib/libc_r/BENCH/bench.h b/lib/libc_r/BENCH/bench.h deleted file mode 100644 index 6e8eb581cb8..00000000000 --- a/lib/libc_r/BENCH/bench.h +++ /dev/null @@ -1,69 +0,0 @@ - -/* The default number of cycles per test */ -#define BENCH_LOOPS (100000) - -#include <sys/time.h> - -typedef struct { - int i; /* loop counter */ - int n; /* loop maximum */ - int divisor; /* operations per cycle */ - struct timeval start; /* start time */ - struct timeval end; /* end time */ - char *name; /* benchmark title */ - char *doc; /* benchmark description */ - char *units; /* measurement units information */ -} bench_t; - -#define bench_now(tvp) \ - gettimeofday((tvp),0) - -/* - * Repeat the body of the loop 'max' times, with a few extra 'warm up' - * cycles to negate cache effects. - */ -#define bench_amortize(b, max) \ - for ((b)->i = -64, \ - (b)->n = (max); \ - (b)->i < (b)->n; \ - (b)->i ++, \ - ((b)->i == 0 ? bench_now(&(b)->start) : \ - ((b)->i == (b)->n ? bench_now(&(b)->end) \ - :0))\ - ) - -#define bench_init(b, nm, dc, un) do { \ - (b)->name = (nm); \ - (b)->doc = (dc); \ - (b)->units = (un); \ - timerclear(&(b)->start); \ - timerclear(&(b)->end); \ - (b)->n = (b)->i = 0; \ - (b)->divisor = 1; \ -} while (0) - -#define bench_header(b) \ - printf("----------------------------------------------------\n" \ - "Name:\t%s\nDesc:%s\n", (b)->name, (b)->doc) - -#define bench_report(b) do { \ - bench_t overhead; \ - struct timeval oh_elapsed; \ - struct timeval elapsed; \ - struct timeval normal; \ - double average; \ - \ - /* compute the loop overhead */ \ - bench_amortize(&overhead, (b)->n) { /* nothing */ } \ - \ - /* compute the test time */ \ - timersub(&(b)->end, &(b)->start, &elapsed); \ - timersub(&overhead.end, &overhead.start, &oh_elapsed); \ - timersub(&elapsed, &oh_elapsed, &normal); \ - \ - average = ((double)normal.tv_sec * 1000000.0 + \ - normal.tv_usec) / (double)((b)->divisor) / \ - (double)((b)->n); \ - \ - printf("Time: %f usec %s\n", average, (b)->units); \ -} while (0) diff --git a/lib/libc_r/BENCH/cond_nowait.c b/lib/libc_r/BENCH/cond_nowait.c deleted file mode 100644 index 88c1769c502..00000000000 --- a/lib/libc_r/BENCH/cond_nowait.c +++ /dev/null @@ -1,35 +0,0 @@ -#include <pthread.h> -#include <string.h> -#include <err.h> -#include "bench.h" - -static char name[] = "Condition Variable Signal/Broadcast, No Waiters"; -static char doc[] = -"\tThis is the amount of time needed to execute pthread_cond_signal()\n" -"\tor pthread_cond_broadcast() if there are no threads blocked on\n" -"\tthe condition."; - -int -main() { - pthread_cond_t c; - bench_t b; - - bench_init(&b, name, doc, "per call of pthread_cond_signal()"); - bench_header(&b); - pthread_cond_init(&c, NULL); - bench_amortize(&b, BENCH_LOOPS) { - pthread_cond_signal(&c); - } - bench_report(&b); - - bench_init(&b, NULL, NULL, "per call of pthread_cond_broadcast()"); - pthread_cond_init(&c, NULL); - bench_amortize(&b, BENCH_LOOPS) { - pthread_cond_broadcast(&c); - } - bench_report(&b); - - exit(0); -} - - diff --git a/lib/libc_r/BENCH/cond_timed.c b/lib/libc_r/BENCH/cond_timed.c deleted file mode 100644 index 9eb30098ef1..00000000000 --- a/lib/libc_r/BENCH/cond_timed.c +++ /dev/null @@ -1,80 +0,0 @@ -#include <stdio.h> -#include <pthread.h> -#include <sched.h> -#include <string.h> -#include <err.h> -#include "bench.h" - -static char name[] = "Time of Wakeup After Timed Wait"; -static char doc[] = -"\tThe time required for the highest-priority thread to resume\n" -"\texecution after a call to pthread_cond_timedwait(). Metrics\n" -"\tare provided for both the cases when the pthread_cond_timedwait()\n" -"\tcall is awakened by a call to pthread_cond_signal() and when\n" -"\tthe absolute time to be awaited has already passed at the time\n" -"\tof the call."; - -pthread_mutex_t m1, m2; -pthread_cond_t c; -bench_t b; -struct timespec waketime; - -void * -other_thread(arg) - void *arg; -{ - - pthread_set_name_np(pthread_self(), "oth"); - pthread_mutex_lock(&m2); - - bench_amortize(&b, BENCH_LOOPS) { - pthread_cond_timedwait(&c, &m2, &waketime); - pthread_cond_signal(&c); - } - pthread_mutex_unlock(&m2); -} - -int -main() { - pthread_t other; - pthread_mutex_t m; - struct timespec ts; - - bench_init(&b, name, doc, "from signal to wait inclusive"); - b.n = BENCH_LOOPS; - bench_header(&b); - pthread_cond_init(&c, NULL); - pthread_mutex_init(&m1, NULL); - pthread_mutex_init(&m2, NULL); - - clock_gettime(CLOCK_REALTIME, &waketime); - waketime.tv_sec += 10000; /* shouldn't take this long! */ - pthread_mutex_lock(&m1); - - pthread_create(&other, NULL, other_thread, NULL); - sched_yield(); - while (b.i < b.n) { - pthread_cond_signal(&c); - pthread_cond_timedwait(&c, &m1, &waketime); - } - pthread_join(other, NULL); - pthread_mutex_unlock(&m1); - - b.divisor = 2; - bench_report(&b); - - /* expired test */ - bench_init(&b, NULL, NULL, "per call when already expired"); - pthread_mutex_init(&m, NULL); - pthread_mutex_lock(&m); - timespecclear(&ts); /* 1 Jan, 1970 */ - bench_amortize(&b, BENCH_LOOPS) { - pthread_cond_timedwait(&c, &m, &ts); - } - pthread_mutex_unlock(&m); - bench_report(&b); - - exit(0); -} - - diff --git a/lib/libc_r/BENCH/cond_wake.c b/lib/libc_r/BENCH/cond_wake.c deleted file mode 100644 index c654a674bd2..00000000000 --- a/lib/libc_r/BENCH/cond_wake.c +++ /dev/null @@ -1,63 +0,0 @@ -#include <stdio.h> -#include <pthread.h> -#include <sched.h> -#include <string.h> -#include <err.h> -#include "bench.h" - -static char name[] = "Condition Variable, Wake Up"; -static char doc[] = -"\tThis is the amount of time from when one thread calls\n" -"\tpthread_cond_signal() and a thread blocked on that condition\n" -"\tvariable returns from its pthread_cond_wait() call. The condition\n" -"\tand its associated mutex should not be used by any other thread.\n" -"\tMetrics shall be provided for both the case when the\n" -"\tpthread_cond_signal() call is executed under the associated mutex,\n" -"\tas well as not under the mutex."; - -/* BROKEN */ - -pthread_mutex_t m1, m2; -pthread_cond_t c; -bench_t b; - -void * -other_thread(arg) - void *arg; -{ - - pthread_set_name_np(pthread_self(), "oth"); - pthread_mutex_lock(&m2); - - bench_amortize(&b, BENCH_LOOPS) { - pthread_cond_wait(&c, &m2); - pthread_cond_signal(&c); - } - pthread_mutex_unlock(&m2); -} - -int -main() { - pthread_t other; - bench_init(&b, name, doc, "per call"); - b.n = BENCH_LOOPS; - bench_header(&b); - pthread_cond_init(&c, NULL); - pthread_mutex_init(&m1, NULL); - pthread_mutex_init(&m2, NULL); - pthread_mutex_lock(&m1); - pthread_create(&other, NULL, other_thread, NULL); - - sched_yield(); - while (b.i < b.n) { - pthread_cond_signal(&c); - pthread_cond_wait(&c, &m1); - } - - b.divisor = 2; - bench_report(&b); - pthread_join(other, NULL); - exit(0); -} - - diff --git a/lib/libc_r/BENCH/mutex_cont.c b/lib/libc_r/BENCH/mutex_cont.c deleted file mode 100644 index 3bb32b68469..00000000000 --- a/lib/libc_r/BENCH/mutex_cont.c +++ /dev/null @@ -1,129 +0,0 @@ -#include <stdio.h> -#include <pthread.h> -#include <sched.h> -#include <string.h> -#include <err.h> -#include "bench.h" - -static char name[] = "Mutex Lock/Unlock, Contention"; -static char doc[] = -"\tThis is the time interval between when one thread calls\n" -"\tpthread_mutex_unlock() and another thread that was blocked\n" -"\ton pthread_mutex_lock() returns with the lock held."; - -/* - -The order of locking looks like this: - - A B 1 2 3 - =============== =============== == == == - lock(2) A - yield() A - lock(1) A B - lock(3) B A B - yield() B A B - lock(1) Ba A B -------- - unlock(1) a A B - lock(2) a Ab B - ^ A Ab B - unlock(2) A b B - lock(3) A b Ba - ^ A B Ba - unlock(3) A B a - lock(1) Ab B a - ^ Ab B A - unlock(1) b B A - lock(2) b Ba A - ^ B Ba A - unlock(2) B a A - lock(3) B a Ab - ^ B A Ab - unlock(3) B A b - lock(1) Ba A b - ^ Ba A B -------- - unlock(1) a A B - unlock(3) a A - exit - ^ A A - unlock(1) A - unlock(2) - exit - - In every cycle, there will be 6 transitions and 6 lock/unlock - pairs. So, to compute the transition time, we subtract the - lock/unlock time computed without contention. -*/ - -static pthread_mutex_t m1, m2, m3; -static bench_t ba, bb; - -void * -thread_a(arg) -{ - pthread_set_name_np(pthread_self(), "ta"); - pthread_mutex_lock(&m2); - sched_yield(); - - pthread_mutex_lock(&m1); - bench_amortize(&ba, BENCH_LOOPS) { - pthread_mutex_unlock(&m2); - pthread_mutex_lock(&m3); - pthread_mutex_unlock(&m1); - pthread_mutex_lock(&m2); - pthread_mutex_unlock(&m3); - pthread_mutex_lock(&m1); - } - pthread_mutex_unlock(&m1); - pthread_mutex_unlock(&m2); - return (NULL); -} - -void * -thread_b(arg) -{ - pthread_set_name_np(pthread_self(), "tb"); - pthread_mutex_lock(&m1); - pthread_mutex_lock(&m3); - sched_yield(); - - bench_amortize(&bb, BENCH_LOOPS) { - pthread_mutex_unlock(&m1); - pthread_mutex_lock(&m2); - pthread_mutex_unlock(&m3); - pthread_mutex_lock(&m1); - pthread_mutex_unlock(&m2); - pthread_mutex_lock(&m3); - } - pthread_mutex_unlock(&m1); - pthread_mutex_unlock(&m3); - return (NULL); -} - -int -main() { - pthread_t ta, tb; - - bench_init(&ba, name, doc, "from unlock to lock inclusive"); - bench_init(&bb, NULL, NULL, NULL); - - bench_header(&ba); - - pthread_mutex_init(&m1, NULL); - pthread_mutex_init(&m2, NULL); - pthread_mutex_init(&m3, NULL); - - pthread_create(&ta, NULL, thread_a, NULL); - pthread_create(&tb, NULL, thread_b, NULL); - - pthread_join(ta, NULL); - pthread_join(tb, NULL); - - ba.divisor = bb.divisor = 6; - - bench_report(&ba); -/* bench_report(&bb); */ - exit(0); -} - diff --git a/lib/libc_r/BENCH/mutex_nocont.c b/lib/libc_r/BENCH/mutex_nocont.c deleted file mode 100644 index 46f13791296..00000000000 --- a/lib/libc_r/BENCH/mutex_nocont.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <pthread.h> -#include <string.h> -#include <err.h> -#include "bench.h" - -static char name[] = "Mutex Lock/Unlock, No Contention"; -static char doc[] = -"\tThis is the time interval needed to call pthread_mutex_lock()\n" -"\tfollowed immediately by pthread_mutex_unlock() on a mutex that\n" -"\tis unowned and which is only being used by the thread doing\n" -"\tthe test."; - -int -main() { - pthread_mutex_t m; - bench_t b; - - bench_init(&b, name, doc, "from lock to unlock inclusive"); - bench_header(&b); - pthread_mutex_init(&m, NULL); - bench_amortize(&b, BENCH_LOOPS) { - pthread_mutex_lock(&m); - pthread_mutex_unlock(&m); - } - bench_report(&b); - exit(0); -} - - diff --git a/lib/libc_r/BENCH/null.c b/lib/libc_r/BENCH/null.c deleted file mode 100644 index 15436e18a66..00000000000 --- a/lib/libc_r/BENCH/null.c +++ /dev/null @@ -1,27 +0,0 @@ -#include <stdio.h> -#include <pthread.h> -#include <err.h> -#include "bench.h" - -static char name[] = "Null test"; -static char doc[] = -"\tThe time needed for performing a tight empty loop. This indicates\n" -"\tthe overhead incurred by the measurement harness. It should be zero,\n" -"\tand may even be negative."; - - - -int -main() { - bench_t b; - - bench_init(&b, name, doc, "per cycle"); - bench_header(&b); - bench_amortize(&b, BENCH_LOOPS) { - /* nothng */ - } - bench_report(&b); - exit(0); -} - - diff --git a/lib/libc_r/BENCH/once_overhead.c b/lib/libc_r/BENCH/once_overhead.c deleted file mode 100644 index c353ffb8d52..00000000000 --- a/lib/libc_r/BENCH/once_overhead.c +++ /dev/null @@ -1,30 +0,0 @@ - -#include <pthread.h> -#include "bench.h" - -static char name[] = "Once Overhead"; -static char doc[] = -"\tThe time needed for the highest priority thread to execute the\n" -"\tpthread_once() function when the init_routine has already been\n" -"\texecuted."; - -void -init_routine() -{ -} - -int -main() { - pthread_once_t once_control = PTHREAD_ONCE_INIT; - bench_t b; - bench_init(&b, name, doc, "per call"); - bench_header(&b); - pthread_once(&once_control, init_routine); - bench_amortize(&b, BENCH_LOOPS) { - pthread_once(&once_control, init_routine); - } - bench_report(&b); - exit(0); -} - - diff --git a/lib/libc_r/BENCH/self_overhead.c b/lib/libc_r/BENCH/self_overhead.c deleted file mode 100644 index f48bd166a5d..00000000000 --- a/lib/libc_r/BENCH/self_overhead.c +++ /dev/null @@ -1,81 +0,0 @@ -#include <stdio.h> -#include <pthread.h> -#include <sched.h> -#include <string.h> -#include <err.h> -#include "bench.h" - -static char name[] = "Self Overhead"; -static char doc[] = -"\tThe time needed for the highest priority thread to perform the\n" -"\tpthread_self() operation, for the following numbers of threads:\n" -"\t1, 21, 101, 1023"; - - -static int nthreads = 1; -pthread_t children[1024]; - -void * -child() { - pause(); -} - -void -numthreads(n) - int n; -{ - int error; - pthread_attr_t small_stack_attr; - - pthread_attr_init(&small_stack_attr); - pthread_attr_setstacksize(&small_stack_attr, PTHREAD_STACK_MIN); - - while (nthreads < n) { - error = pthread_create(&children[nthreads], - &small_stack_attr, child, NULL); - if (error != 0) - errx(1, "pthread_create #%d: %s", nthreads, - strerror(error)); - sched_yield(); - nthreads++; - } - - while (nthreads > n) { - error = pthread_cancel(children[nthreads - 1]); - if (error != 0) - errx(1, "pthread_cancel: %s", strerror(error)); - sched_yield(); - nthreads --; - } - - printf("\n#threads: %d\n", nthreads); -} - -void -doit(b, n) - bench_t *b; - int n; -{ - - numthreads(n); - bench_amortize(b, BENCH_LOOPS) { - pthread_self(); - } - bench_report(b); -} - -int -main() { - bench_t b; - - bench_init(&b, name, doc, "per call"); - bench_header(&b); - - doit(&b, 1); - doit(&b, 21); - doit(&b, 101); - doit(&b, 1023); - exit(0); -} - - diff --git a/lib/libc_r/BENCH/yield.c b/lib/libc_r/BENCH/yield.c deleted file mode 100644 index c197afd2b2d..00000000000 --- a/lib/libc_r/BENCH/yield.c +++ /dev/null @@ -1,55 +0,0 @@ -#include <pthread.h> -#include <sched.h> -#include <string.h> -#include <err.h> -#include "bench.h" - -static char name[] = "Thread Yield Time (Busy)"; -static char doc[] = -"\tThread yield time is defined as the amount of time between that\n" -"\tpoint when a running thread voluntarily gives up the CPU until\n" -"\tthe highest priority runnable thread begins execution of its\n" -"\tapplication code."; - -#ifdef DEBUG -volatile int state = 0; -#endif -bench_t b; - -void * -other_thread(arg) - void *arg; -{ - - pthread_set_name_np(pthread_self(), "oth"); - bench_amortize(&b, BENCH_LOOPS) { -#ifdef DEBUG - if (state != 0) abort(); - state = 1; -#endif - sched_yield(); - } -} - -int -main() { - pthread_t other; - - bench_init(&b, name, doc, "per yield"); - b.n = BENCH_LOOPS; - bench_header(&b); - pthread_create(&other, NULL, other_thread, NULL); - while (b.i < b.n) { -#ifdef DEBUG - if (state != 1) abort(); - state = 0; -#endif - sched_yield(); - } - pthread_join(other, NULL); - b.divisor = 2; - bench_report(&b); - exit(0); -} - - diff --git a/lib/libc_r/Makefile b/lib/libc_r/Makefile deleted file mode 100644 index 8778a9bde5a..00000000000 --- a/lib/libc_r/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -# $OpenBSD: Makefile,v 1.12 2002/01/15 22:37:02 fgsch Exp $ - -# libc_r will be depreceated and replaced by libpthread -# when all supported architectures support weak symbols. -# See also comments in ../libc/Makefile. - -.include <bsd.own.mk> - -LIBCSRCDIR = ${.CURDIR}/../libc -LIBC_RSRCDIR = ${.CURDIR} - -LIB= c_r -LINTFLAGS= -z -CFLAGS+= -DPTHREAD_KERNEL -D_POSIX_THREADS -D_THREAD_SAFE -CFLAGS+= -I${LIBC_RSRCDIR}/uthread -I${LIBC_RSRCDIR}/include -CFLAGS+= -I${LIBCSRCDIR}/include - -# Uncomment this if you want libc_r to contain debug information for -# thread locking. -CFLAGS+= -D_LOCK_DEBUG -#DEBUG= -ggdb -Wall - -# enable extra internal consistency checks -CFLAGS+= -D_PTHREADS_INVARIANTS - -.include "${LIBCSRCDIR}/Makefile.inc" - -# annul man pages that are built/installed by libc -MAN= -MLINKS= - -# XXX bogus version number! -SHLIB_MAJOR != . ${LIBC_RSRCDIR}/shlib_version ; echo $$major -SHLIB_MINOR != . ${LIBC_RSRCDIR}/shlib_version ; echo $$minor - -AINC+= -I${LIBC_RSRCDIR}/uthread - -.include "${LIBC_RSRCDIR}/uthread/Makefile.inc" -.include "${LIBC_RSRCDIR}/sys/Makefile.inc" -.include "${LIBC_RSRCDIR}/thread/Makefile.inc" -.include "${LIBC_RSRCDIR}/man/Makefile.inc" -.include "${LIBC_RSRCDIR}/include/Makefile.inc" - -.include <bsd.lib.mk> diff --git a/lib/libc_r/NOTES b/lib/libc_r/NOTES deleted file mode 100644 index f2479e4ff49..00000000000 --- a/lib/libc_r/NOTES +++ /dev/null @@ -1,184 +0,0 @@ - -Notes on the OpenBSD threaded C library (-lc_r) -================================================ - -Sources - - The main bulk of this library came from: - . FreeBSD's libc_r (John Birrell) - - The scheduler and locking code in the uthread directory. - - Some of the manual pages in the man directory. - - <pthreads.h> - . MIT pthreads (Chris Provenzano) - - The test code in the regress/lib/libc_r directory - - I'm mainly tracking changes in FreeBSD's libc_r and integrating - them as I can. The major changes are outlined at the end of this - file. - -Standards - - This implementation has also been mindful of: - . Posix Threads[1] - . Single Unix Specification[2] - -Conformance - - Only the absolutely required re-entrant functions have been added - to the C library interface headers (in /usr/src/include). - - The conformance goals used were: minimal implementation; strict - conformance with standard; provide reasonable utility when standards - are spineless (e.g., our asynchronous cancel is eager even though - POSIX says async cancels may be acted upon at any time -- ie - never.) - - The widely used, but non-standard, gethostbyname_r() has been - half-heartily added (but not prototyped in a header - see source - for details). Please contact me if you have pointers to - standards/comments about this function. - - Re-entrant functions added for the standards have also been made - available to libc (i.e. without the need to define _POSIX_THREADS). - -Change strategy in libc - - The approach taken in making the libc functions re-entrant was to - develop some macros that handle: - . file locking - . monitors (thread-shared data structure locking) - . per-thread private data structure allocation - - These macros were used to avoid copious amounts of #ifdef - statements[3]. - - In the non-threaded libc, file locking and the monitors are no-ops; - the per-thread private data structures were previously declared - static and the macros maintain this. - - In the threaded libc_r, file locking is as per the FreeBSD file - descriptor locking, and the monitors are pthread_mutex operations. - Per-thread private data structures use the pthread_specific - functions to dynamically allocate memory on their first use, - initialising them from the static (and hidden) per-compilation-unit - data structures. In this way, each thread appears to have its - very own private libc state. - -Errno - - Unlike the FreeBSD and MIT pthreads package, errno is not a macro - like __error(); instead it is part of the per-thread context: - saved and restored like a register. This has several advantages - over the errno-as-a-macro method: - - - The syscall/cerror code does not have to be re-written - - Libraries compiled without thread support will still work - - Easier to port old packages that use errno, but don't include - <errno.h> to get the macro - - No need to go through all sources and find where errno is - used as a field name or formal parameter name. - - The overhead of saving and restoring an integer was considered - too tiny to worry about in comparison to the huge penalty hit of - handling a signal and restoring the rest of a thread's context. - - It has been pointed out that this technique will not work in a - mutiprocessor environment, and this is quite true. However the - following reasons are quite persuasive: - - - OpenBSD does not do MP (yet) - - This (FreeBSD uthread) implementation will not work in an MP - environment anyway because _thread_run is not a cpu-local - variable. - - There is a lot of coupling between binary ports, the 'old' - libc and other standard libraries. It is predicted that it - will be a huge headache to come up with a scheme that when - someone tries to upgrade, everything won't break in a spectacular - fashion, leaving bits of crippled ports, executables and - shattered libraries everywhere. - -Compiler support - - The in-tree gcc had its config/openbsd.h modified to support a - `-pthread' switch. Using this switch defines _POSIX_THREADS for - cpp, and replaces the normal -lc linker option with -lc_r. - - The objective-C component was also made aware of posix threads, - via the configure switch --enable-threads=posix. {This has not - been well tested though.} - -Debugger support - - The in-tree gdb has been augmented to recognise when a executable - linked with -lc_r is being debugged. All the documented gdb threads - commands will then work. (Except you can't resume/step execution - in a thread other than the 'current' one.) - - To get detailed state information, issue: - - (gdb) call _thread_dump_info() - - This will show what mutexes, condvars or file locks each process - is waiting on. If you use _flockfile_debug() instead of flockfile() - in your programs, source code references will appear in here too. - (see <stdio.h>) - -Changes to FreeBSD uthreads - - Although this implementation tracks the FreeBSD libc_r tree to - a large extent, the following significant changes have been made - to John Birrell's uthreads implementation that have yet to appear - (or may never appear) in FreeBSD's implementation: - - - architecture independent code generalised and moved out of - #ifdef's[3] (now support for sparc, mips, m68k, powerpc added - to i386, alpha) - - the SIGINFO handler generates much more friendly/useful output - - an implementation of poll() {probably bogus, but X11 seems to - work} - - an implementation of pthread_cancel() - - an implementation of pthread_[gs]etscope() {bogus} - - removal of the freebsd's support for init(8) {i.e., pid == 1} - -Caveats - - This library is not 100% standards compliant - yet. It is certainly - moving in that direction though. There are still some unresolved - isseues, and the interested reader is directed towards the TODO - file. - -Standard disclaimer - - This software is made available by the author to the public for - free and "as is". All users of this free software are solely - and entirely responsible for their own choice and use of this - software for their own purposes. By using this software, each - user agrees that the author shall not be liable for damages of - any kind in relation to its use or performance. - - Some parts of this software bear their own copyright which is - different to the above disclaimer. - -References - - [1] P1003.1c/D10 IEEE Draft Standard for Information Technology-- - Portable Operating System Interface (POSIX) -- Part 1: System - Application Program Interface (API) -- Ammendment 2: Threads - Extension [C Language]. IEEE Standards, September 1994. - [2] T912, The Single UNIX(R) Specification, Version 2. The Open - Group, February 1997. http://www.opengroup.org/pubs/catalog/t912.htm - [3] #ifdef Considered Harmful, or Portability Experience with C - News. H. Spencer and G. Collyer, Proc. of the Summer 1992 - USENIX Conference, San Antionio, Texas, 1992. pp. 185-198 - -Acknowledgements - - Lots of kudos to Chris Provenzano et al. for the original - MIT-pthreads implementation that I still read to get ideas; and - also to John Birrell and the other FreeBSD developers who - consistently write high quality code. The help rendered from the - OpenBSD developers was greatly appreciated - especially from - Todd Fries. - -David Leonard <leonard@csee.uq.edu.au> -$OpenBSD: NOTES,v 1.4 2001/08/15 14:43:15 fgsch Exp $ diff --git a/lib/libc_r/TODO b/lib/libc_r/TODO deleted file mode 100644 index 58cbf89baac..00000000000 --- a/lib/libc_r/TODO +++ /dev/null @@ -1,106 +0,0 @@ -$OpenBSD: TODO,v 1.17 2002/02/22 04:25:20 brad Exp $ - -This is a list of things that still need to be done: - -* fix the signal handling re-entrancy bug that FreeBSD have left in :( - -* wrap vfork (basically the same as fork()) - -* wrap itimer() syscalls so that the _ITIMER_SCHED_TIMER can't be trashed - -* Move the md include stuff so that it appears in /usr/include/<arch>/ - That way, gdb's thread stuff can be built sanely and maybe other - uthread-aware stuff can make use of it? - -* Move to using -lpthread. Needs weak symbol support in all as and ld.so - implementations. - [espie@ looking at unifying toolchain] - [weak symbols put into libc. libpthread built. everything works on i386] - -* Add - pthread_condattr_[gs]etpshared() -- and add warn_references - pthread_mutexattr_[gs]etpshared() - sched_setparam() - sched_setscheduler() - -* Add _warn_references to the schedprio stuff - -* shouldn't pthread_yield() be marked depreciated? - [it is draft 4.] - -* Add thread stuff to the other archs in libc/arch/; ie change - some usages of ENTRY to SYSENTRY in some .S files and add - the new macros to their SYS.h. - [wip] - -* Test that thread_init is automatically called on every arch, regardless - of whether the exe is statically linked or not. - [problems with new egcs?] - -* Add UNIX98's pthread_attr_[sg]etguardsize(). This would probably be - straightforward. - -* Keep a handle on how netbsd are going with their kernel threads - [argument is that openbsd is not multi-processor, so user threads will - retain stability and still give reasonable performance. talked to mwp@] - -* Look into how asynchronous I/O can help us. In particular, the - (unimplemented) aio*() functions. - [doesn't help very much for 1003.1c.] - -* Update the libc manual pages to describe the posix re-entrant functions. - Although this is actually trivial to do, I have to decide on a - consistent way of adding them - maybe `.Sh THREAD-SAFE FUNCTIONS' ? - Should look into standards to see what they suggest/did.. - May also need to document "This is not thread-safe" for some library - functions (yet to be identified). - [Need to ask aaron@ for his opinion.] - -* Find out where freebsd/netbsd use pread() and pwrite().. i think - its in the database routines mostly. - -* Figure out what to do with the configuration system variables (_SC_*) - that are defined by POSIX 1003.1c (at least update sysconf(3)) - -* Compare with PTL (http://www.media.osaka-cu.ac.jp/~k-abe/PTL/) - [snarfed some sparc md stuff] - -* Verify that threads work with: - - perl (in-tree) [almost] - - objc (in-tree gcc) - - ssl (in-tree) [triv] - - gdb - - ports - - audio/xmms - - bechmarks/iozone - - databases/mysql - - devel/glib [yes] - - devel/sdl [yes] - - graphics/ggi - - graphics/gii - - lang/tcl/8.3 - - lang/python/2.1 - - lang/python/2.2 - - net/icecast [partially] - - net/mrtd - - net/xchat - - net/pdnsd - -* Some ideas: - + http://www.cs.wustl.edu/~schmidt/locking-patterns.ps.gz - http://www.cs.wustl.edu/~schmidt/TSS-pattern.ps.gz - http://www.cs.wustl.edu/~schmidt/DC-Locking.ps.gz - + http://guir.cs.berkeley.edu/projects/osprelims/papers/Scheduler.pdf.gz - "Scheduler Activations: Effective Kernel Support for the User-Level - Management of Parallelism" by Thomas E. Anderson, Brian N. Bershad, - Edward D. Lazowska, and Henry M. Levy -* Fix ufs_select and nfs_select in the kernel to give REAL answers. [ha!] - -* Clean up the way that signals are delivered to threads. Yuk. - -* Make getaddrinfo(3) thread-safe. - -* What to do with gethostby*_r(3)? - -* Look into getpw*_r(3). - diff --git a/lib/libc_r/arch/alpha/_atomic_lock.c b/lib/libc_r/arch/alpha/_atomic_lock.c deleted file mode 100644 index 5de2960abdc..00000000000 --- a/lib/libc_r/arch/alpha/_atomic_lock.c +++ /dev/null @@ -1,6 +0,0 @@ -/* $OpenBSD: _atomic_lock.c,v 1.7 2002/10/11 19:08:41 marc Exp $ */ -/* - * Atomi lock for alpha. - */ - -/* _atomic lock is implemented in assembler. */ diff --git a/lib/libc_r/arch/alpha/uthread_machdep.c b/lib/libc_r/arch/alpha/uthread_machdep.c deleted file mode 100644 index fa9c604d06f..00000000000 --- a/lib/libc_r/arch/alpha/uthread_machdep.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: uthread_machdep.c,v 1.2 2002/05/10 10:17:22 art Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -/* - * Machine-dependent thread state functions for OpenBSD/alpha - */ - -#include <pthread.h> -#include "pthread_private.h" - -#define ALIGNBYTES 15 - -struct frame { - long ra; - long s[7]; - long t12; - long fs[8]; -}; - -/* - * Given a stack and an entry function, initialise a state - * structure that can be later switched to. - */ -void -_thread_machdep_init(statep, base, len, entry) - struct _machdep_state* statep; - void *base; - int len; - void (*entry)(void); -{ - struct frame *f; - - f = (struct frame *)(((u_int64_t)base + len - sizeof *f) & ~ALIGNBYTES); - f->ra = f->t12 = (u_int64_t)entry; - - statep->sp = (u_int64_t)f; -} - -void -_thread_machdep_save_float_state(statep) - struct _machdep_state* statep; -{ -} - -void -_thread_machdep_restore_float_state(statep) - struct _machdep_state* statep; -{ -} diff --git a/lib/libc_r/arch/alpha/uthread_machdep.h b/lib/libc_r/arch/alpha/uthread_machdep.h deleted file mode 100644 index 9bd580d5f1c..00000000000 --- a/lib/libc_r/arch/alpha/uthread_machdep.h +++ /dev/null @@ -1,6 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.8 2002/01/04 14:46:18 art Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -struct _machdep_state { - u_int64_t sp; -}; diff --git a/lib/libc_r/arch/alpha/uthread_machdep_asm.S b/lib/libc_r/arch/alpha/uthread_machdep_asm.S deleted file mode 100644 index 054d8a52d22..00000000000 --- a/lib/libc_r/arch/alpha/uthread_machdep_asm.S +++ /dev/null @@ -1,79 +0,0 @@ -/* $OpenBSD: uthread_machdep_asm.S,v 1.4 2002/12/12 18:26:18 marc Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -#include <machine/asm.h> - -#define INTOFF(n) ((n)*8) -#define FPOFF(n) (INTOFF(9) + (n)*8) -#define ALIGN(x) (((x)+15)&~15) -#define FRAMESIZE ALIGN(FPOFF(8)) - - .set noreorder - .globl _thread_machdep_switch - .ent _thread_machdep_switch, 2 -_thread_machdep_switch: - .frame sp, FRAMESIZE, ra - ldgp gp, 0(pv) - lda sp, -FRAMESIZE(sp) - - stq ra, INTOFF(0)(sp) - stq s0, INTOFF(1)(sp) - stq s1, INTOFF(2)(sp) - stq s2, INTOFF(3)(sp) - stq s3, INTOFF(4)(sp) - stq s4, INTOFF(5)(sp) - stq s5, INTOFF(6)(sp) - stq s6, INTOFF(7)(sp) - stq t12, INTOFF(8)(sp) - - stt fs0, FPOFF(0)(sp) - stt fs1, FPOFF(1)(sp) - stt fs2, FPOFF(2)(sp) - stt fs3, FPOFF(3)(sp) - stt fs4, FPOFF(4)(sp) - stt fs5, FPOFF(5)(sp) - stt fs6, FPOFF(6)(sp) - stt fs7, FPOFF(7)(sp) - - stq sp, 0(a1) - or a0, zero, pv - ldq sp, 0(a0) - - ldt fs7, FPOFF(7)(sp) - ldt fs6, FPOFF(6)(sp) - ldt fs5, FPOFF(5)(sp) - ldt fs4, FPOFF(4)(sp) - ldt fs3, FPOFF(3)(sp) - ldt fs2, FPOFF(2)(sp) - ldt fs1, FPOFF(1)(sp) - ldt fs0, FPOFF(0)(sp) - - ldq t12, INTOFF(8)(sp) - ldq s6, INTOFF(7)(sp) - ldq s5, INTOFF(6)(sp) - ldq s4, INTOFF(5)(sp) - ldq s3, INTOFF(4)(sp) - ldq s2, INTOFF(3)(sp) - ldq s1, INTOFF(2)(sp) - ldq s0, INTOFF(1)(sp) - ldq ra, INTOFF(0)(sp) - - lda sp,FRAMESIZE(sp) - RET - - .end _thread_machdep_switch - -LEAF(_atomic_lock,1) - LDGP(pv) - - /* NOTE: using ldl_l/stl_c instead of - ldq_l and ldq_c as machine/spinlock.h - defines _spinlock_lock_t as int */ -0: ldl_l v0, 0(a0) /* read existing lock value */ - mov 1, t0 /* locked value to store */ - stl_c t0, 0(a0) /* attempt to store, status in t0 */ - beq t0, 1f /* branch forward to optimise prediction */ - mb /* sync with other processors */ - RET /* return with v0==0 if lock obtained */ -1: br 0b /* loop to try again */ -END(_atomic_lock) diff --git a/lib/libc_r/arch/hppa/_atomic_lock.c b/lib/libc_r/arch/hppa/_atomic_lock.c deleted file mode 100644 index 9882303e388..00000000000 --- a/lib/libc_r/arch/hppa/_atomic_lock.c +++ /dev/null @@ -1,15 +0,0 @@ -/* $OpenBSD: _atomic_lock.c,v 1.2 2002/10/11 19:08:41 marc Exp $ */ -/* - * Atomic lock for hppa - */ -#include "spinlock.h" - -int -_atomic_lock(volatile register_t *lock) -{ - register register_t old; - - __asm__("ldcws 0(%1), %0" : "=r" (old): "r" (lock)); - - return (old == _SPINLOCK_LOCKED); -} diff --git a/lib/libc_r/arch/hppa/uthread_machdep.h b/lib/libc_r/arch/hppa/uthread_machdep.h deleted file mode 100644 index cb9325f7c7c..00000000000 --- a/lib/libc_r/arch/hppa/uthread_machdep.h +++ /dev/null @@ -1,7 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.6 2002/11/01 00:05:45 mickey Exp $ */ - -struct _machdep_state { - u_long sp; - u_long fp; - u_int64_t fpregs[32]; -}; diff --git a/lib/libc_r/arch/hppa/uthread_machdep_asm.S b/lib/libc_r/arch/hppa/uthread_machdep_asm.S deleted file mode 100644 index 875ceb11dd9..00000000000 --- a/lib/libc_r/arch/hppa/uthread_machdep_asm.S +++ /dev/null @@ -1,157 +0,0 @@ -/* $OpenBSD: uthread_machdep_asm.S,v 1.2 2003/01/16 19:16:02 mickey Exp $ */ -/* Michael Shalayeff <mickey@openbsd.org>. Public Domain. */ - -#include <machine/asm.h> -#define _LOCORE -#include <machine/frame.h> - -#define FRAMESIZE 0x60 - -/* - * void _thread_machdep_init(statep, base, len, entry) - * struct _machdep_state *statep; - * void *base; - * int len; - * void (*entry)(void); - */ -ENTRY(_thread_machdep_init,FRAMESIZE) - ldo 7(arg1), arg1 - dep r0, 31, 3, arg1 - ldo FRAMESIZE(arg1), t1 - stw t1, 0(arg0) - stw arg1, 4(arg0) - bv r0(rp) - stw arg3, 0(arg1) -EXIT(_thread_machdep_init) - -/* - * void _thread_machdep_switch(newstate, oldstate); - * struct _machdep_state *newstate, *oldstate; - */ -ENTRY(_thread_machdep_switch,0) - copy sp, t1 - ldo FRAMESIZE(sp), sp - stw sp, 0(arg1) - stw t1, 4(arg1) - stw r2, 0x00(t1) - stw r3, 0x04(t1) - stw r4, 0x08(t1) - stw r5, 0x0c(t1) - stw r6, 0x10(t1) - stw r7, 0x14(t1) - stw r8, 0x18(t1) - stw r9, 0x1c(t1) - stw r10, 0x20(t1) - stw r11, 0x24(t1) - stw r12, 0x28(t1) - stw r13, 0x2c(t1) - stw r14, 0x30(t1) - stw r15, 0x34(t1) - stw r16, 0x38(t1) - stw r17, 0x3c(t1) - stw r18, 0x40(t1) - - ldw 0(arg0), sp - ldw 4(arg0), t1 - ldw 0x00(t1), r2 - ldw 0x04(t1), r3 - ldw 0x08(t1), r4 - ldw 0x0c(t1), r5 - ldw 0x10(t1), r6 - ldw 0x14(t1), r7 - ldw 0x18(t1), r8 - ldw 0x1c(t1), r9 - ldw 0x20(t1), r10 - ldw 0x24(t1), r11 - ldw 0x28(t1), r12 - ldw 0x2c(t1), r13 - ldw 0x30(t1), r14 - ldw 0x34(t1), r15 - ldw 0x38(t1), r16 - ldw 0x3c(t1), r17 - ldw 0x40(t1), r18 - bv r0(rp) - ldo -FRAMESIZE(sp), sp -EXIT(_thread_machdep_switch) - -/* - * void _thread_machdep_save_float_state(struct _machdep_state* statep); - */ -ENTRY(_thread_machdep_save_float_state,0) - ldo 8(arg0), arg0 - fstds,ma fr0 , 8(arg0) - fstds,ma fr1 , 8(arg0) - fstds,ma fr2 , 8(arg0) - fstds,ma fr3 , 8(arg0) - fstds,ma fr4 , 8(arg0) - fstds,ma fr5 , 8(arg0) - fstds,ma fr6 , 8(arg0) - fstds,ma fr7 , 8(arg0) - fstds,ma fr8 , 8(arg0) - fstds,ma fr9 , 8(arg0) - fstds,ma fr10, 8(arg0) - fstds,ma fr11, 8(arg0) - fstds,ma fr12, 8(arg0) - fstds,ma fr13, 8(arg0) - fstds,ma fr14, 8(arg0) - fstds,ma fr15, 8(arg0) - fstds,ma fr16, 8(arg0) - fstds,ma fr17, 8(arg0) - fstds,ma fr18, 8(arg0) - fstds,ma fr19, 8(arg0) - fstds,ma fr20, 8(arg0) - fstds,ma fr21, 8(arg0) - fstds,ma fr22, 8(arg0) - fstds,ma fr23, 8(arg0) - fstds,ma fr24, 8(arg0) - fstds,ma fr25, 8(arg0) - fstds,ma fr26, 8(arg0) - fstds,ma fr27, 8(arg0) - fstds,ma fr28, 8(arg0) - fstds,ma fr29, 8(arg0) - fstds,ma fr30, 8(arg0) - bv r0(rp) - fstd,ma fr31, 8(arg0) -EXIT(_thread_machdep_save_float_state) - -/* - * void _thread_machdep_restore_float_state(struct _machdep_state* statep); - */ -ENTRY(_thread_machdep_restore_float_state,0) - ldo 8*32(arg0), arg0 - fldds,ma -8(arg0), fr31 - fldds,ma -8(arg0), fr30 - fldds,ma -8(arg0), fr29 - fldds,ma -8(arg0), fr28 - fldds,ma -8(arg0), fr27 - fldds,ma -8(arg0), fr26 - fldds,ma -8(arg0), fr25 - fldds,ma -8(arg0), fr24 - fldds,ma -8(arg0), fr23 - fldds,ma -8(arg0), fr22 - fldds,ma -8(arg0), fr21 - fldds,ma -8(arg0), fr20 - fldds,ma -8(arg0), fr19 - fldds,ma -8(arg0), fr18 - fldds,ma -8(arg0), fr17 - fldds,ma -8(arg0), fr16 - fldds,ma -8(arg0), fr15 - fldds,ma -8(arg0), fr14 - fldds,ma -8(arg0), fr13 - fldds,ma -8(arg0), fr12 - fldds,ma -8(arg0), fr11 - fldds,ma -8(arg0), fr10 - fldds,ma -8(arg0), fr9 - fldds,ma -8(arg0), fr8 - fldds,ma -8(arg0), fr7 - fldds,ma -8(arg0), fr6 - fldds,ma -8(arg0), fr5 - fldds,ma -8(arg0), fr4 - fldds,ma -8(arg0), fr3 - fldds,ma -8(arg0), fr2 - fldds,ma -8(arg0), fr1 - bv %r0(rp) - fldds,ma -8(arg0), fr0 -EXIT(_thread_machdep_restore_float_state) - - .end diff --git a/lib/libc_r/arch/i386/_atomic_lock.c b/lib/libc_r/arch/i386/_atomic_lock.c deleted file mode 100644 index 8e97ec7c3e9..00000000000 --- a/lib/libc_r/arch/i386/_atomic_lock.c +++ /dev/null @@ -1,25 +0,0 @@ -/* $OpenBSD: _atomic_lock.c,v 1.7 2002/10/11 19:08:41 marc Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -/* - * Atomic lock for i386 - */ - -#include "spinlock.h" - -int -_atomic_lock(volatile _spinlock_lock_t *lock) -{ - _spinlock_lock_t old; - - /* - * Use the eXCHanGe instruction to swap the lock value with - * a local variable containing the locked state. - */ - old = _SPINLOCK_LOCKED; - __asm__("xchg %0,%1" - : "=r" (old), "=m" (*lock) - : "0" (old), "1" (*lock)); - - return (old != _SPINLOCK_UNLOCKED); -} diff --git a/lib/libc_r/arch/i386/uthread_machdep.c b/lib/libc_r/arch/i386/uthread_machdep.c deleted file mode 100644 index 2b0847b3804..00000000000 --- a/lib/libc_r/arch/i386/uthread_machdep.c +++ /dev/null @@ -1,80 +0,0 @@ -/* $OpenBSD: uthread_machdep.c,v 1.2 2001/03/13 00:05:51 d Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -/* - * Machine-dependent thread state functions for OpenBSD/i386. - */ - -#include <machine/param.h> -#include <pthread.h> -#include "pthread_private.h" - -struct frame { - int fr_gs; - int fr_fs; - int fr_es; - int fr_ds; - - int fr_edi; - int fr_esi; - int fr_ebp; - int fr_esp; - int fr_ebx; - int fr_edx; - int fr_ecx; - int fr_eax; - - int fr_eip; - int fr_cs; /* XXX unreachable? */ -}; - -#define copyreg(reg, lval) \ - __asm__("mov %%" #reg ", %0" : "=g"(lval)) - -/* - * Given a stack and an entry function, initialise a state - * structure that can be later switched to. - */ -void -_thread_machdep_init(statep, base, len, entry) - struct _machdep_state* statep; - void *base; - int len; - void (*entry)(void); -{ - struct frame *f; - - /* Locate the initial frame, aligned at the top of the stack */ - f = (struct frame *)(((int)base + len - sizeof *f) & ~ALIGNBYTES); - - /* Set up initial frame */ - f->fr_esp = (int)&f->fr_edi; - copyreg(cs, f->fr_cs); - copyreg(ds, f->fr_ds); - copyreg(es, f->fr_es); - copyreg(fs, f->fr_fs); - copyreg(gs, f->fr_gs); - f->fr_ebp = (int)-1; - f->fr_eip = (int)entry; - - statep->esp = (int)f; -} - -void -_thread_machdep_save_float_state(ms) - struct _machdep_state *ms; -{ - char *fdata = (char *)&ms->fpreg; - - __asm__("fsave %0"::"m" (*fdata)); -} - -void -_thread_machdep_restore_float_state(ms) - struct _machdep_state *ms; -{ - char *fdata = (char *)&ms->fpreg; - - __asm__("frstor %0"::"m" (*fdata)); -} - diff --git a/lib/libc_r/arch/i386/uthread_machdep.h b/lib/libc_r/arch/i386/uthread_machdep.h deleted file mode 100644 index 22d48624d0d..00000000000 --- a/lib/libc_r/arch/i386/uthread_machdep.h +++ /dev/null @@ -1,10 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.7 2000/10/04 05:55:34 d Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -#include <machine/reg.h> - -struct _machdep_state { - int esp; - struct fpreg fpreg; -}; - diff --git a/lib/libc_r/arch/i386/uthread_machdep_asm.S b/lib/libc_r/arch/i386/uthread_machdep_asm.S deleted file mode 100644 index 06652fd210f..00000000000 --- a/lib/libc_r/arch/i386/uthread_machdep_asm.S +++ /dev/null @@ -1,27 +0,0 @@ -/* $OpenBSD: uthread_machdep_asm.S,v 1.1 2000/09/25 01:16:40 d Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -#include <machine/asm.h> - -/* - * Switch stacks - */ - -/* void _thread_machdep_switch(new, oldsave); */ -ENTRY(_thread_machdep_switch) - pushal /* pushl %eax,%ecx,%edx,%ebx,%esp,%ebp,%esi,%edi */ - pushl %ds - pushl %es - pushl %fs - pushl %gs -#define DISTANCE ((8+1+1+1+1)*4) - movl (DISTANCE+8)(%esp), %eax /* %eax = arg2 */ - movl %esp, 0(%eax) /* *arg2 = %esp */ - movl (DISTANCE+4)(%esp), %eax /* %eax = arg1 */ - movl 0(%eax), %esp /* %esp = *arg1 */ - popl %gs - popl %fs - popl %es - popl %ds - popal /* popl %edi,%esi,%ebp,%esp,%ebx,%edx,%ecx,%eax */ - ret diff --git a/lib/libc_r/arch/m68k/_atomic_lock.c b/lib/libc_r/arch/m68k/_atomic_lock.c deleted file mode 100644 index af162f36091..00000000000 --- a/lib/libc_r/arch/m68k/_atomic_lock.c +++ /dev/null @@ -1,36 +0,0 @@ -/* $OpenBSD: _atomic_lock.c,v 1.6 2002/10/11 19:08:41 marc Exp $ */ -/* - * Atomic lock for m68k - */ - -#include "spinlock.h" - -int -_atomic_lock(volatile _spinlock_lock_t *lock) -{ - _spinlock_lock_t old; - - /* - * The Compare And Swap instruction (mc68020 and above) - * compares its first operand with the memory addressed by - * the third. If they are the same value, the second operand - * is stored at the address. Otherwise the 1st operand (register) - * is loaded with the contents of the 3rd operand. - * - * old = 0; - * CAS(old, 1, *lock); - * if (old == 1) { lock was acquired } - * - * From the MC68030 User's Manual (Motorola), page `3-13': - * CAS Dc,Du,<ea>: - * (<ea> - Dc) -> cc; - * if Z then Du -> <ea> - * else <ea> -> Dc; - */ - old = _SPINLOCK_UNLOCKED; - __asm__("casl %0, %2, %1" : "=d" (old), "=m" (*lock) - : "d" (_SPINLOCK_LOCKED), - "0" (old), "1" (*lock) - : "cc"); - return (old != _SPINLOCK_UNLOCKED); -} diff --git a/lib/libc_r/arch/m68k/uthread_machdep.c b/lib/libc_r/arch/m68k/uthread_machdep.c deleted file mode 100644 index 8afde2443f3..00000000000 --- a/lib/libc_r/arch/m68k/uthread_machdep.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: uthread_machdep.c,v 1.1 2000/09/25 09:03:44 d Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -/* - * Machine-dependent thread state functions for OpenBSD/m68k - */ - -#include "uthread_machdep.h" -#define ALIGNBYTES 0x3 - -struct frame { - int d2,d3,d4,d5,d6,d7; - int a2,a3,a4,a5,fp; - int link; /* frame link */ - int ra; -}; - -/* - * Given a stack and an entry function, initialise a state - * structure that can be later switched to. - */ -void -_thread_machdep_init(statep, base, len, entry) - struct _machdep_state* statep; - void *base; - int len; - void (*entry)(void); -{ - struct frame *f; - - /* Locate the initial frame, aligned at the top of the stack */ - f = (struct frame *)(((int)base + len - sizeof *f) & ~ALIGNBYTES); - - f->ra = (int)entry; - f->link = 0; - f->fp = (int)&f->link; - statep->sp = (int)f; -} - -void -_thread_machdep_save_float_state(statep) - struct _machdep_state* statep; -{ - /* fsave is a privileged instruction */ -} - -void -_thread_machdep_restore_float_state(statep) - struct _machdep_state* statep; -{ - /* frestore is a privileged instruction */ -} diff --git a/lib/libc_r/arch/m68k/uthread_machdep.h b/lib/libc_r/arch/m68k/uthread_machdep.h deleted file mode 100644 index d9bb9935ca6..00000000000 --- a/lib/libc_r/arch/m68k/uthread_machdep.h +++ /dev/null @@ -1,6 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.4 2000/10/04 05:55:34 d Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -struct _machdep_state { - int sp; -}; diff --git a/lib/libc_r/arch/m68k/uthread_machdep_asm.S b/lib/libc_r/arch/m68k/uthread_machdep_asm.S deleted file mode 100644 index 30e4397b838..00000000000 --- a/lib/libc_r/arch/m68k/uthread_machdep_asm.S +++ /dev/null @@ -1,18 +0,0 @@ -/* $OpenBSD: uthread_machdep_asm.S,v 1.1 2000/09/25 09:03:44 d Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -#include <machine/asm.h> - -#define SA(x) (((x)+3)&~3) -#define FRAMESIZE 4*11 - -ENTRY(_thread_machdep_switch) - link a6, #-SA(FRAMESIZE) - moveml #0x7CFC, sp@ /* d2-d7,a2-a6 */ - movel a6@(8), a0 - movel a6@(12), a1 - movel sp, a1@ - movel a0@, sp - moveml sp@, #0x7CFC - unlk a6 - rts diff --git a/lib/libc_r/arch/m88k/_atomic_lock.c b/lib/libc_r/arch/m88k/_atomic_lock.c deleted file mode 100644 index 8d4d0ba2182..00000000000 --- a/lib/libc_r/arch/m88k/_atomic_lock.c +++ /dev/null @@ -1,12 +0,0 @@ -/* $OpenBSD: _atomic_lock.c,v 1.2 2002/10/11 19:08:41 marc Exp $ */ -/* - * Atomic lock for m68k - */ - -#include "spinlock.h" - -int -_atomic_lock(volatile _spinlock_lock_t *lock) -{ - return (_thread_slow_atomic_lock(lock)); -} diff --git a/lib/libc_r/arch/m88k/uthread_machdep.h b/lib/libc_r/arch/m88k/uthread_machdep.h deleted file mode 100644 index a08aebd4b9a..00000000000 --- a/lib/libc_r/arch/m88k/uthread_machdep.h +++ /dev/null @@ -1,4 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.4 2001/02/21 00:24:38 miod Exp $ */ - -struct _machdep_state { -}; diff --git a/lib/libc_r/arch/mips/_atomic_lock.c b/lib/libc_r/arch/mips/_atomic_lock.c deleted file mode 100644 index 8eec2084c82..00000000000 --- a/lib/libc_r/arch/mips/_atomic_lock.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $OpenBSD: _atomic_lock.c,v 1.7 2002/10/11 19:08:41 marc Exp $ */ -/* - * Atomic lock for mips - */ - -#include "pthread.h" -#include "pthread_private.h" -#include "spinlock.h" -#include <signal.h> - -/* - * uthread atomic lock: - * attempt to acquire a lock (by giving it a non-zero value). - * Return zero on success, or the lock's value on failure - */ -int -_atomic_lock(volatile _spinlock_lock_t *lock) -{ -#if __mips >= 2 - _spinlock_lock_t old; - _spinlock_lock_t temp; - - do { - /* - * On a mips2 machine and above, we can use ll/sc. - * Read the lock and tag the cache line with a 'load linked' - * instruction. (Register 17 (LLAddr) will hold the - * physical address of lock for diagnostic purposes); - * (Under pathologically heavy swapping, the physaddr may - * change! XXX) - */ - __asm__("ll %0, %1" : "=r"(old) : "m"(*lock)); - if (old != _SPINLOCK_UNLOCKED) - break; /* already locked */ - /* - * Try and store a 1 at the tagged lock address. If - * anyone else has since written it, the tag on the cache - * line will have been wiped, and temp will be set to zero - * by the 'store conditional' instruction. - */ - temp = _SPINLOCK_LOCKED; - __asm__("sc %0, %1" : "=r"(temp), "=m"(*lock) - : "0"(temp)); - } while (temp == 0); - - return (old != _SPINLOCK_UNLOCKED); -#else - /* - * Older MIPS cpus have no way of doing an atomic lock - * without some kind of shift to supervisor mode. - */ - - return (_thread_slow_atomic_lock(lock)); -#endif -} diff --git a/lib/libc_r/arch/mips/_spinlock.h b/lib/libc_r/arch/mips/_spinlock.h deleted file mode 100644 index 06f9ffeb540..00000000000 --- a/lib/libc_r/arch/mips/_spinlock.h +++ /dev/null @@ -1,6 +0,0 @@ -/* $OpenBSD: _spinlock.h,v 1.1 1998/12/21 07:37:00 d Exp $ */ - -#define _SPINLOCK_UNLOCKED (0) -#define _SPINLOCK_LOCKED (1) -typedef int _spinlock_lock_t; - diff --git a/lib/libc_r/arch/mips/uthread_machdep.c b/lib/libc_r/arch/mips/uthread_machdep.c deleted file mode 100644 index fdbc4f279d8..00000000000 --- a/lib/libc_r/arch/mips/uthread_machdep.c +++ /dev/null @@ -1,56 +0,0 @@ -/* $OpenBSD: uthread_machdep.c,v 1.1 2000/10/03 02:44:15 d Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -/* - * Machine-dependent thread state functions for OpenBSD/mips - */ - -#include <pthread.h> -#include "pthread_private.h" - -#define ALIGNBYTES 0x3 - -struct frame { - int s[9]; /* s0..s7 */ - int _fill; - double f[3]; /* $f0..$f2 */ - int t9; /* XXX only used when bootstrapping */ - int ra; - - int arg[4], cra, cfp; /* ABI space for debuggers */ -}; - -/* - * Given a stack and an entry function, initialise a state - * structure that can be later switched to. - */ -void -_thread_machdep_init(statep, base, len, entry) - struct _machdep_state* statep; - void *base; - int len; - void (*entry)(void); -{ - struct frame *f; - - /* Locate the initial frame, aligned at the top of the stack */ - f = (struct frame *)(((int)base + len - sizeof *f) & ~ALIGNBYTES); - - f->cra = f->cfp = 0; /* for debugger */ - f->ra = (int)entry; - f->t9 = (int)entry; - - statep->frame = (int)f; -} - -void -_thread_machdep_save_float_state(statep) - struct _machdep_state* statep; -{ -} - -void -_thread_machdep_restore_float_state(statep) - struct _machdep_state* statep; -{ -} diff --git a/lib/libc_r/arch/mips/uthread_machdep.h b/lib/libc_r/arch/mips/uthread_machdep.h deleted file mode 100644 index 113a83dc815..00000000000 --- a/lib/libc_r/arch/mips/uthread_machdep.h +++ /dev/null @@ -1,6 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.5 2000/10/04 05:55:34 d Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -struct _machdep_state { - int frame; -}; diff --git a/lib/libc_r/arch/mips/uthread_machdep_asm.S b/lib/libc_r/arch/mips/uthread_machdep_asm.S deleted file mode 100644 index d7fc757f1ba..00000000000 --- a/lib/libc_r/arch/mips/uthread_machdep_asm.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: uthread_machdep_asm.S,v 1.1 2000/10/03 02:44:15 d Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -#include <machine/asm.h> - -#define SOFF(n) ((n)*4) -#define FPOFF(n) (SOFF(9) + 4 + (n)*8) -#define REGOFF(n) (FPOFF(3) + (n)*4) - -#define FRAMESIZE (REGOFF(2) + 4*4+4+4) - -NON_LEAF(_thread_machdep_switch, FRAMESIZE, ra) - add sp, sp, -FRAMESIZE - - sw s0, SOFF(0)(sp) - sw s1, SOFF(1)(sp) - sw s2, SOFF(2)(sp) - sw s3, SOFF(3)(sp) - sw s4, SOFF(4)(sp) - sw s5, SOFF(5)(sp) - sw s6, SOFF(6)(sp) - sw s7, SOFF(7)(sp) - sw s8, SOFF(8)(sp) - s.d $f0, FPOFF(0)(sp) /* XXX why? */ - s.d $f2, FPOFF(1)(sp) - s.d $f4, FPOFF(2)(sp) - sw t9, REGOFF(0)(sp) - sw ra, REGOFF(1)(sp) - - sw sp, 0(a1) - lw sp, 0(a0) - - .set noreorder /* avoid nops */ - lw ra, REGOFF(1)(sp) - lw t9, REGOFF(0)(sp) - l.d $f4, FPOFF(2)(sp) - l.d $f2, FPOFF(1)(sp) - l.d $f0, FPOFF(0)(sp) - lw s8, SOFF(8)(sp) - lw s7, SOFF(7)(sp) - lw s6, SOFF(6)(sp) - lw s5, SOFF(5)(sp) - lw s4, SOFF(4)(sp) - lw s3, SOFF(3)(sp) - lw s2, SOFF(2)(sp) - lw s1, SOFF(1)(sp) - lw s0, SOFF(0)(sp) - .set reorder - - add sp, sp, FRAMESIZE - j ra -END(_thread_machdep_switch) diff --git a/lib/libc_r/arch/powerpc/_atomic_lock.c b/lib/libc_r/arch/powerpc/_atomic_lock.c deleted file mode 100644 index d248b4725cf..00000000000 --- a/lib/libc_r/arch/powerpc/_atomic_lock.c +++ /dev/null @@ -1,37 +0,0 @@ -/* $OpenBSD: _atomic_lock.c,v 1.5 2002/11/12 18:56:28 drahn Exp $ */ -/* - * Atomic lock for powerpc - */ - -#include "spinlock.h" - -int -_atomic_lock(volatile _spinlock_lock_t *lock) -{ - _spinlock_lock_t old; - - __asm__("1: lwarx 0,0,%1 \n" - " stwcx. %2,0,%1 \n" - " bne- 1b \n" - " mr %0, 0 \n" - : "=r" (old), "=r" (lock) - : "r" (_SPINLOCK_LOCKED), "1" (lock) : "0" - ); - - return (old != _SPINLOCK_UNLOCKED); - - /* - * Dale <rahnds@openbsd.org> says: - * Side note. to prevent two processes from accessing - * the same address with the lwarx in one instrution - * and the stwcx in another process, the current powerpc - * kernel uses a stwcx instruction without the corresponding - * lwarx which causes any reservation of a process - * to be removed. if a context switch occurs - * between the two accesses the store will not occur - * and the condition code will cause it to loop. If on - * a dual processor machine, the reserve will cause - * appropriate bus cycle accesses to notify other - * processors. - */ -} diff --git a/lib/libc_r/arch/powerpc/uthread_machdep.c b/lib/libc_r/arch/powerpc/uthread_machdep.c deleted file mode 100644 index 845567a2913..00000000000 --- a/lib/libc_r/arch/powerpc/uthread_machdep.c +++ /dev/null @@ -1,82 +0,0 @@ -/* $OpenBSD: uthread_machdep.c,v 1.3 2000/10/05 04:59:34 rahnds Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain */ - -#include <pthread.h> -#include "pthread_private.h" - -#define ALIGNBYTES 0xf - -/* Register save frame as it appears on the stack */ -struct frame { - int r1; - int reserved; - int gp[32-14]; - int lr, cr, ctr, xer; - long fp[32-14]; - long fs; - /* The rest are only valid in the initial frame */ - int next_r1; - int next_lr; -}; - -/* - * Given a stack and an entry function, initialise a state - * structure that can be later switched to. - */ -void -_thread_machdep_init(statep, base, len, entry) - struct _machdep_state* statep; - void *base; - int len; - void (*entry)(void); -{ - struct frame *f; - - /* Locate the initial frame, aligned at the top of the stack */ - f = (struct frame *)(((int)base + len - sizeof *f) & ~ALIGNBYTES); - - f->r1 = (int)&f->next_r1; - f->reserved = 0; - f->lr = (int)entry; - f->next_r1 = 0; /* for gdb */ - f->next_lr = 0; /* for gdb */ - - /* Initialise the new thread with all the state from this thread. */ - -#define copyreg(x) __asm__ volatile ("stw " #x ", %0" : "=m"(f->gp[x-14])) - copyreg(14); copyreg(15); copyreg(16); copyreg(17); copyreg(18); - copyreg(19); copyreg(20); copyreg(21); copyreg(22); copyreg(23); - copyreg(24); copyreg(25); copyreg(26); copyreg(27); copyreg(28); - copyreg(29); copyreg(30); copyreg(31); - -#define copysreg(nm) __asm__ volatile ("mf" #nm " %0" : "=r"(f->nm)) - copysreg(cr); copysreg(ctr); copysreg(xer); - -#define copyfreg(x) __asm__ volatile ("stfd " #x ", %0" : "=m"(f->fp[x-14])) - copyfreg(14); copyfreg(15); copyfreg(16); copyfreg(17); copyfreg(18); - copyfreg(19); copyfreg(20); copyfreg(21); copyfreg(22); copyfreg(23); - copyfreg(24); copyfreg(25); copyfreg(26); copyfreg(27); copyfreg(28); - copyfreg(29); copyfreg(30); copyfreg(31); - - __asm__ volatile ("mffs 0; stfd 0, %0" : "=m"(f->fs)); - - statep->frame = (int)f; -} - - -/* - * No-op float saves. - * (Floating point registers were saved in _thread_machdep_switch()) - */ - -void -_thread_machdep_save_float_state(statep) - struct _machdep_state* statep; -{ -} - -void -_thread_machdep_restore_float_state(statep) - struct _machdep_state* statep; -{ -} diff --git a/lib/libc_r/arch/powerpc/uthread_machdep.h b/lib/libc_r/arch/powerpc/uthread_machdep.h deleted file mode 100644 index 54c864e71a4..00000000000 --- a/lib/libc_r/arch/powerpc/uthread_machdep.h +++ /dev/null @@ -1,7 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.5 2000/10/04 05:55:35 d Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -struct _machdep_state { - int frame; -}; - diff --git a/lib/libc_r/arch/powerpc/uthread_machdep_asm.S b/lib/libc_r/arch/powerpc/uthread_machdep_asm.S deleted file mode 100644 index 21cd4f0889e..00000000000 --- a/lib/libc_r/arch/powerpc/uthread_machdep_asm.S +++ /dev/null @@ -1,106 +0,0 @@ -/* $OpenBSD: uthread_machdep_asm.S,v 1.1 2000/09/25 01:16:40 d Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -#include <machine/asm.h> - -/* These need to be kept in sync with uthread_machdep.c */ -#define REGOFF(n) (2*4 + (n-14)*4) -#define FPOFF(n) (REGOFF(36) + (n-14)*4) -#define FRAMESIZE FPOFF(33) - -#define SA(x) (((x)+0xf)&~0xf) - -ENTRY(_thread_machdep_switch) - stwu 1, -SA(FRAMESIZE)(1) - - /* Save context into frame */ - stw 14, REGOFF(14)(1) - stw 15, REGOFF(15)(1) - stw 16, REGOFF(16)(1) - stw 17, REGOFF(17)(1) - stw 18, REGOFF(18)(1) - stw 19, REGOFF(19)(1) - stw 20, REGOFF(20)(1) - stw 21, REGOFF(21)(1) - stw 22, REGOFF(22)(1) - stw 23, REGOFF(23)(1) - stw 24, REGOFF(24)(1) - stw 25, REGOFF(25)(1) - stw 26, REGOFF(26)(1) - stw 27, REGOFF(27)(1) - stw 28, REGOFF(28)(1) - stw 29, REGOFF(29)(1) - stw 30, REGOFF(30)(1) - stw 31, REGOFF(31)(1) - mflr 0; stw 0, REGOFF(32)(1) - mfcr 0; stw 0, REGOFF(33)(1) - mfctr 0; stw 0, REGOFF(34)(1) - mfxer 0; stw 0, REGOFF(35)(1) - stfd 14, FPOFF(14)(1) - stfd 15, FPOFF(15)(1) - stfd 16, FPOFF(16)(1) - stfd 17, FPOFF(17)(1) - stfd 18, FPOFF(18)(1) - stfd 19, FPOFF(19)(1) - stfd 20, FPOFF(20)(1) - stfd 21, FPOFF(21)(1) - stfd 22, FPOFF(22)(1) - stfd 23, FPOFF(23)(1) - stfd 24, FPOFF(24)(1) - stfd 25, FPOFF(25)(1) - stfd 26, FPOFF(26)(1) - stfd 27, FPOFF(27)(1) - stfd 28, FPOFF(28)(1) - stfd 29, FPOFF(29)(1) - stfd 30, FPOFF(30)(1) - stfd 31, FPOFF(31)(1) - mffs 0; stfd 0, FPOFF(32)(1) - - /* Switch stacks */ - stw 1, 0(4) - lwz 1, 0(3) - - /* Restore context from the frame */ - lfd 0, FPOFF(32)(1); mtfsf 0xff, 0 - lfd 31, FPOFF(31)(1) - lfd 30, FPOFF(30)(1) - lfd 29, FPOFF(29)(1) - lfd 28, FPOFF(28)(1) - lfd 27, FPOFF(27)(1) - lfd 26, FPOFF(26)(1) - lfd 25, FPOFF(25)(1) - lfd 24, FPOFF(24)(1) - lfd 23, FPOFF(23)(1) - lfd 22, FPOFF(22)(1) - lfd 21, FPOFF(21)(1) - lfd 20, FPOFF(20)(1) - lfd 19, FPOFF(19)(1) - lfd 18, FPOFF(18)(1) - lfd 17, FPOFF(17)(1) - lfd 16, FPOFF(16)(1) - lfd 15, FPOFF(15)(1) - lfd 14, FPOFF(14)(1) - lwz 0, REGOFF(35)(1); mtxer 0 - lwz 0, REGOFF(34)(1); mtctr 0 - lwz 0, REGOFF(33)(1); mtcr 0 - lwz 0, REGOFF(32)(1); mtlr 0 - lwz 31, REGOFF(31)(1) - lwz 30, REGOFF(30)(1) - lwz 29, REGOFF(29)(1) - lwz 28, REGOFF(28)(1) - lwz 27, REGOFF(27)(1) - lwz 26, REGOFF(26)(1) - lwz 25, REGOFF(25)(1) - lwz 24, REGOFF(24)(1) - lwz 23, REGOFF(23)(1) - lwz 22, REGOFF(22)(1) - lwz 21, REGOFF(21)(1) - lwz 20, REGOFF(20)(1) - lwz 19, REGOFF(19)(1) - lwz 18, REGOFF(18)(1) - lwz 17, REGOFF(17)(1) - lwz 16, REGOFF(16)(1) - lwz 15, REGOFF(15)(1) - lwz 14, REGOFF(14)(1) - la 1, SA(FRAMESIZE)(1) - blr diff --git a/lib/libc_r/arch/sparc/_atomic_lock.c b/lib/libc_r/arch/sparc/_atomic_lock.c deleted file mode 100644 index 09ef32393eb..00000000000 --- a/lib/libc_r/arch/sparc/_atomic_lock.c +++ /dev/null @@ -1,41 +0,0 @@ -/* $OpenBSD: _atomic_lock.c,v 1.7 2002/10/11 19:08:41 marc Exp $ */ -/* - * Atomic lock for sparc - */ - -#include "spinlock.h" - -int -_atomic_lock(volatile _spinlock_lock_t * lock) -{ - _spinlock_lock_t old; - - /* - * " ldstub [address], reg_rd - * - * The atomic load-store instructions copy a byte from memory - * into r[rd]m then rewrite the addressed byte in memory to all - * ones [_SPINLOCK_LOCKED]. The operation is performed - * atomically, that is, without allowing intervening interrupts - * or deferred traps. In a multiprocessor system, two or more - * processors executing atomic load-store unsigned byte [...] - * addressing the same byte [...] simultaneously are guaranteed - * to execute them in an undefined, but serial order." - * - p101, The SPARC Architecure Manual (version 8) Prentice-Hall - * - * "LDSTUB loads a byte value from memory to a register and writes - * the value FF_16 into the addressed byte atomically. LDSTUB - * is the classic test-and-set instruction. Like SWAP, it has - * a consensus number of two and so cannot resolve more than - * two contending processes in a wait-free fashion." - * - p129, The SPARC Architecture Manual (version 9) Prentice-Hall - * (See also section J.6 (spinlocks)) - * - * (No change to the condition codes are documented.) - */ - __asm__("ldstub %0,%1" - : "=m" (*lock), "=r" (old) - : "0" (*lock)); - - return (old == _SPINLOCK_LOCKED); -} diff --git a/lib/libc_r/arch/sparc/uthread_machdep.c b/lib/libc_r/arch/sparc/uthread_machdep.c deleted file mode 100644 index 789a1d3efd1..00000000000 --- a/lib/libc_r/arch/sparc/uthread_machdep.c +++ /dev/null @@ -1,44 +0,0 @@ -/* $OpenBSD: uthread_machdep.c,v 1.1 2000/09/25 01:16:40 d Exp $ */ - -/* - * Machine-dependent thread state functions for OpenBSD/sparc. - */ - -#include <machine/frame.h> -#include <machine/param.h> -#include <pthread.h> -#include "pthread_private.h" - -/* - * Given a stack and an entry function, initialise a state - * structure that can be later switched to. - */ -void -_thread_machdep_init(statep, base, len, entry) - struct _machdep_state* statep; - void *base; - int len; - void (*entry)(void); -{ - struct frame *f; - - /* Locate the initial frame, aligned at the top of the stack */ - f = (struct frame *)(((int)base + len - sizeof *f) & ~ALIGNBYTES); - - f->fr_fp = (struct frame *)-1; /* purposefully misaligned */ - f->fr_pc = -1; /* for gdb */ - statep->fp = (int)f; - statep->pc = -8 + (int)entry; -} - -void -_thread_machdep_save_float_state(statep) - struct _machdep_state* statep; -{ -} - -void -_thread_machdep_restore_float_state(statep) - struct _machdep_state* statep; -{ -} diff --git a/lib/libc_r/arch/sparc/uthread_machdep.h b/lib/libc_r/arch/sparc/uthread_machdep.h deleted file mode 100644 index cb43f3a0463..00000000000 --- a/lib/libc_r/arch/sparc/uthread_machdep.h +++ /dev/null @@ -1,7 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.5 2000/10/04 05:55:35 d Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -struct _machdep_state { - int fp; /* frame pointer */ - int pc; /* program counter */ -}; diff --git a/lib/libc_r/arch/sparc/uthread_machdep_asm.S b/lib/libc_r/arch/sparc/uthread_machdep_asm.S deleted file mode 100644 index f7a81f99b08..00000000000 --- a/lib/libc_r/arch/sparc/uthread_machdep_asm.S +++ /dev/null @@ -1,42 +0,0 @@ -/* $OpenBSD: uthread_machdep_asm.S,v 1.5 2001/12/18 06:24:13 fgsch Exp $ */ -/* David Leonard <d@csee.uq.edu.au>. Public domain. */ - -#include <machine/asm.h> -#include <machine/trap.h> - -/* - * Switch stacks. - * On sparc this also means we switch register windows. - */ - -#ifdef __sparcv9__ -#define flushw .word 0x81580000 -#else -#define flushw t ST_FLUSHWIN -#endif - -#define SA(x) (((x)+7)&(~0x7)) -#define MINFRAME ((16+1+6)*4) - -/* - * void _thread_machdep_switch(newstate, oldstate); - * struct _machdep_state *newstate, *oldstate; - */ -ENTRY(_thread_machdep_switch) - - /* new window */ - save %sp, -SA(MINFRAME), %sp - - /* flush all windows (except current one) into memory frames */ - flushw - - /* switch the stack pointer and return address */ - st %fp, [%i1 + 0] - st %i7, [%i1 + 4] - ld [%i0 + 0], %fp - ld [%i0 + 4], %i7 - - /* return to saved window at new %fp */ - ret - restore - diff --git a/lib/libc_r/arch/sparc64/_atomic_lock.c b/lib/libc_r/arch/sparc64/_atomic_lock.c deleted file mode 100644 index 5e4115cf0fb..00000000000 --- a/lib/libc_r/arch/sparc64/_atomic_lock.c +++ /dev/null @@ -1,41 +0,0 @@ -/* $OpenBSD: _atomic_lock.c,v 1.2 2002/10/11 19:08:41 marc Exp $ */ -/* - * Atomic lock for sparc - */ - -#include "spinlock.h" - -int -_atomic_lock(volatile _spinlock_lock_t * lock) -{ - _spinlock_lock_t old; - - /* - * " ldstub [address], reg_rd - * - * The atomic load-store instructions copy a byte from memory - * into r[rd]m then rewrite the addressed byte in memory to all - * ones [_SPINLOCK_LOCKED]. The operation is performed - * atomically, that is, without allowing intervening interrupts - * or deferred traps. In a multiprocessor system, two or more - * processors executing atomic load-store unsigned byte [...] - * addressing the same byte [...] simultaneously are guaranteed - * to execute them in an undefined, but serial order." - * - p101, The SPARC Architecure Manual (version 8) Prentice-Hall - * - * "LDSTUB loads a byte value from memory to a register and writes - * the value FF_16 into the addressed byte atomically. LDSTUB - * is the classic test-and-set instruction. Like SWAP, it has - * a consensus number of two and so cannot resolve more than - * two contending processes in a wait-free fashion." - * - p129, The SPARC Architecture Manual (version 9) Prentice-Hall - * (See also section J.6 (spinlocks)) - * - * (No change to the condition codes are documented.) - */ - __asm__("ldstub %0,%1" - : "=m" (*lock), "=r" (old) - : "0" (*lock)); - - return (old == _SPINLOCK_LOCKED); -} diff --git a/lib/libc_r/arch/sparc64/uthread_machdep.c b/lib/libc_r/arch/sparc64/uthread_machdep.c deleted file mode 100644 index fc754003744..00000000000 --- a/lib/libc_r/arch/sparc64/uthread_machdep.c +++ /dev/null @@ -1,45 +0,0 @@ -/* $OpenBSD: uthread_machdep.c,v 1.2 2002/01/02 19:12:43 art Exp $ */ - -/* - * Machine-dependent thread state functions for OpenBSD/sparc. - */ - -#include <sys/types.h> -#include <machine/frame.h> -#include <machine/param.h> -#include <pthread.h> -#include "pthread_private.h" - -/* - * Given a stack and an entry function, initialise a state - * structure that can be later switched to. - */ -void -_thread_machdep_init(statep, base, len, entry) - struct _machdep_state* statep; - void *base; - int len; - void (*entry)(void); -{ - struct frame64 *f; - - /* Locate the initial frame, aligned at the top of the stack */ - f = (struct frame64 *)(((long)base + len - sizeof *f) & ~ALIGNBYTES); - - f->fr_fp = 0; /* purposefully misaligned */ - f->fr_pc = -1; /* for gdb */ - statep->fp = (u_long)f - BIAS; - statep->pc = -8 + (u_long)entry; -} - -void -_thread_machdep_save_float_state(statep) - struct _machdep_state* statep; -{ -} - -void -_thread_machdep_restore_float_state(statep) - struct _machdep_state* statep; -{ -} diff --git a/lib/libc_r/arch/sparc64/uthread_machdep.h b/lib/libc_r/arch/sparc64/uthread_machdep.h deleted file mode 100644 index 1343341f34e..00000000000 --- a/lib/libc_r/arch/sparc64/uthread_machdep.h +++ /dev/null @@ -1,7 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.2 2002/01/02 19:11:13 art Exp $ */ -/* Arutr Grabowski <art@openbsd.org>. Public domain. */ - -struct _machdep_state { - long fp; /* frame pointer */ - long pc; /* program counter */ -}; diff --git a/lib/libc_r/arch/sparc64/uthread_machdep_asm.S b/lib/libc_r/arch/sparc64/uthread_machdep_asm.S deleted file mode 100644 index 774083a13af..00000000000 --- a/lib/libc_r/arch/sparc64/uthread_machdep_asm.S +++ /dev/null @@ -1,39 +0,0 @@ -/* $OpenBSD: uthread_machdep_asm.S,v 1.4 2002/08/25 22:10:44 brad Exp $ */ -/* David Leonard <d@csee.uq.edu.au>. Public domain. */ - -#include <machine/asm.h> -#include <machine/trap.h> -#include <machine/frame.h> - -/* - * Switch stacks. - * On sparc this also means we switch register windows. - */ - -#ifdef __sparcv9__ -#define flushw .word 0x81580000 -#else -#define flushw t T_FLUSHWIN -#endif - -/* - * void _thread_machdep_switch(long newstate[2], long savestate[2], int flags); - */ -ENTRY(_thread_machdep_switch) - - /* new window */ - save %sp, -CC64FSZ, %sp - - /* flush all windows (except current one) into memory frames */ - flushw - - /* switch the stack pointer and return address */ - stx %fp, [%i1 + 0] - stx %i7, [%i1 + 8] - ldx [%i0 + 0], %fp - ldx [%i0 + 8], %i7 - - /* return to saved window at new %fp */ - ret - restore - diff --git a/lib/libc_r/arch/vax/_atomic_lock.c b/lib/libc_r/arch/vax/_atomic_lock.c deleted file mode 100644 index b85f55e744f..00000000000 --- a/lib/libc_r/arch/vax/_atomic_lock.c +++ /dev/null @@ -1,41 +0,0 @@ -/* $OpenBSD: _atomic_lock.c,v 1.3 2002/11/01 20:14:59 miod Exp $ */ - -/* - * Atomic lock for vax - */ - -#include "spinlock.h" - -int -_atomic_lock(volatile _spinlock_lock_t *lock) -{ - _spinlock_lock_t old; - - /* - * The Branch on Bit Set and Set Interlocked instruction - * sets a given bit in a register or a memory location, as an - * atomic, interlocked operation. - * If the bit was set, execution continues at the branch - * location. - * - * For more details, please refer to the Vax Architecture - * Reference Manual, chapter 3 (Instructions), section - * ``Control instructions''. - */ - __asm__ ( - "movl $1, %1\n" /* _SPINLOCK_LOCKED */ - "bbssi $0, %0, 1f\n" - "movl $0, %1\n" /* _SPINLOCK_UNLOCKED */ - "1: \n" - : "=m" (*lock), "=r" (old) : "0" (*lock) - ); - - return (old != _SPINLOCK_UNLOCKED); -} - -int -_atomic_is_locked(volatile _spinlock_lock_t *lock) -{ - - return (*lock != _SPINLOCK_UNLOCKED); -} diff --git a/lib/libc_r/arch/vax/uthread_machdep.h b/lib/libc_r/arch/vax/uthread_machdep.h deleted file mode 100644 index 75fefff1655..00000000000 --- a/lib/libc_r/arch/vax/uthread_machdep.h +++ /dev/null @@ -1,6 +0,0 @@ -/* $OpenBSD: uthread_machdep.h,v 1.1 2001/01/27 21:23:57 hugh Exp $ */ -/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ - -struct _machdep_state { - int frame; -}; diff --git a/lib/libc_r/include/Makefile.inc b/lib/libc_r/include/Makefile.inc deleted file mode 100644 index 5bf12b96d4b..00000000000 --- a/lib/libc_r/include/Makefile.inc +++ /dev/null @@ -1,12 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.4 2002/01/18 00:36:36 fgsch Exp $ - -includes: - @cd ${LIBC_RSRCDIR}/include; \ - for h in pthread.h pthread_np.h sched.h semaphore.h spinlock.h; do \ - cmp -s $$h ${DESTDIR}/usr/include/$$h > /dev/null 2>&1 || \ - (echo ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} \ - -m 444 $$h ${DESTDIR}/usr/include; \ - ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 \ - $$h ${DESTDIR}/usr/include) || exit 1; \ - done - diff --git a/lib/libc_r/include/pthread.h b/lib/libc_r/include/pthread.h deleted file mode 100644 index 4a3f470c741..00000000000 --- a/lib/libc_r/include/pthread.h +++ /dev/null @@ -1,344 +0,0 @@ -/* $OpenBSD: pthread.h,v 1.16 2002/02/17 19:42:24 millert Exp $ */ - -/* - * Copyright (c) 1993, 1994 by Chris Provenzano, proven@mit.edu - * Copyright (c) 1995-1998 by John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Chris Provenzano. - * 4. The name of Chris Provenzano may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL CHRIS PROVENZANO BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: pthread.h,v 1.13 1999/07/31 08:36:07 rse Exp $ - */ -#ifndef _PTHREAD_H_ -#define _PTHREAD_H_ - -/* Previous releases of OpenBSD used a hacked gcc that defined this */ -#ifdef _POSIX_THREADS -#undef _POSIX_THREADS /* Allow to be defined below */ -#endif - -/* - * Header files. - */ -#include <sys/cdefs.h> -#include <sys/types.h> -#include <sys/time.h> -#include <sys/signal.h> -#include <limits.h> -#include <sched.h> - -/* - * Run-time invariant values: - */ -#define PTHREAD_DESTRUCTOR_ITERATIONS 4 -#define PTHREAD_KEYS_MAX 256 -#define PTHREAD_STACK_MIN 1024 -#define PTHREAD_THREADS_MAX ULONG_MAX - -/* - * Compile time symbolic constants for portability specifications: - * - * Note that those commented out are not currently supported by the - * implementation. - */ -#define _POSIX_THREADS -#define _POSIX_THREAD_ATTR_STACKADDR -#define _POSIX_THREAD_ATTR_STACKSIZE -#define _POSIX_THREAD_PRIORITY_SCHEDULING -#define _POSIX_THREAD_PRIO_INHERIT -#define _POSIX_THREAD_PRIO_PROTECT -/* #define _POSIX_THREAD_PROCESS_SHARED */ -#define _POSIX_THREAD_SAFE_FUNCTIONS - -/* - * Flags for threads and thread attributes. - */ -#define PTHREAD_DETACHED 0x1 -#define PTHREAD_SCOPE_SYSTEM 0x2 -#define PTHREAD_INHERIT_SCHED 0x4 -#define PTHREAD_NOFLOAT 0x8 - -#define PTHREAD_CREATE_DETACHED PTHREAD_DETACHED -#define PTHREAD_CREATE_JOINABLE 0 -#define PTHREAD_SCOPE_PROCESS 0 -#define PTHREAD_EXPLICIT_SCHED 0 - -/* - * Flags for read/write lock attributes - */ -#define PTHREAD_PROCESS_PRIVATE 0 -#define PTHREAD_PROCESS_SHARED 1 - -/* - * Flags for cancelling threads - */ -#define PTHREAD_CANCEL_ENABLE 0 -#define PTHREAD_CANCEL_DISABLE 1 -#define PTHREAD_CANCEL_DEFERRED 0 -#define PTHREAD_CANCEL_ASYNCHRONOUS 2 -#define PTHREAD_CANCELED ((void *) 1) - -/* - * Forward structure definitions. - * - * These are mostly opaque to the user. - */ -struct pthread; -struct pthread_attr; -struct pthread_cond; -struct pthread_cond_attr; -struct pthread_mutex; -struct pthread_mutex_attr; -struct pthread_once; -struct pthread_rwlock; -struct pthread_rwlockattr; - -/* - * Primitive system data type definitions required by P1003.1c. - * - * Note that P1003.1c specifies that there are no defined comparison - * or assignment operators for the types pthread_attr_t, pthread_cond_t, - * pthread_condattr_t, pthread_mutex_t, pthread_mutexattr_t. - */ -typedef struct pthread *pthread_t; -typedef struct pthread_attr *pthread_attr_t; -typedef volatile struct pthread_mutex *pthread_mutex_t; -typedef struct pthread_mutex_attr *pthread_mutexattr_t; -typedef struct pthread_cond *pthread_cond_t; -typedef struct pthread_cond_attr *pthread_condattr_t; -typedef volatile int pthread_key_t; -typedef struct pthread_once pthread_once_t; -typedef struct pthread_rwlock *pthread_rwlock_t; -typedef struct pthread_rwlockattr *pthread_rwlockattr_t; - -/* - * Additional type definitions: - * - * Note that P1003.1c reserves the prefixes pthread_ and PTHREAD_ for - * use in header symbols. - */ -typedef void *pthread_addr_t; -typedef void *(*pthread_startroutine_t)(void *); - -/* - * Once definitions. - */ -struct pthread_once { - int state; - pthread_mutex_t mutex; -}; - -/* - * Flags for once initialization. - */ -#define PTHREAD_NEEDS_INIT 0 -#define PTHREAD_DONE_INIT 1 - -/* - * Static once initialization values. - */ -#define PTHREAD_ONCE_INIT { PTHREAD_NEEDS_INIT, PTHREAD_MUTEX_INITIALIZER } - -/* - * Static initialization values. - */ -#define PTHREAD_MUTEX_INITIALIZER NULL -#define PTHREAD_COND_INITIALIZER NULL -#define PTHREAD_RWLOCK_INITIALIZER NULL - -#define PTHREAD_PRIO_NONE 0 -#ifdef _POSIX_THREAD_PRIO_PROTECT -#define PTHREAD_PRIO_INHERIT 1 -#define PTHREAD_PRIO_PROTECT 2 -#endif - -/* - * Mutex types (Single UNIX Specification, Version 2, 1997). - * - * Note that a mutex attribute with one of the following types: - * - * PTHREAD_MUTEX_NORMAL - * PTHREAD_MUTEX_RECURSIVE - * MUTEX_TYPE_FAST (deprecated) - * MUTEX_TYPE_COUNTING_FAST (deprecated) - * - * will deviate from POSIX specified semantics. - */ -enum pthread_mutextype { - PTHREAD_MUTEX_ERRORCHECK = 1, /* Default POSIX mutex */ - PTHREAD_MUTEX_RECURSIVE = 2, /* Recursive mutex */ - PTHREAD_MUTEX_NORMAL = 3, /* No error checking */ - MUTEX_TYPE_MAX -}; - -#define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_ERRORCHECK -#define MUTEX_TYPE_FAST PTHREAD_MUTEX_NORMAL -#define MUTEX_TYPE_COUNTING_FAST PTHREAD_MUTEX_RECURSIVE - -/* - * Thread function prototype definitions: - */ -__BEGIN_DECLS -int pthread_attr_destroy(pthread_attr_t *); -int pthread_attr_getstacksize(pthread_attr_t *, size_t *); -int pthread_attr_getstackaddr(pthread_attr_t *, void **); -int pthread_attr_getdetachstate(const pthread_attr_t *, int *); -int pthread_attr_init(pthread_attr_t *); -int pthread_attr_setstacksize(pthread_attr_t *, size_t); -int pthread_attr_setstackaddr(pthread_attr_t *, void *); -int pthread_attr_setdetachstate(pthread_attr_t *, int); -void pthread_cleanup_pop(int execute); -void pthread_cleanup_push(void (*routine)(void *), - void *routine_arg); -int pthread_condattr_destroy(pthread_condattr_t *attr); -int pthread_condattr_init(pthread_condattr_t *attr); - -#if defined(_POSIX_THREAD_PROCESS_SHARED) -int pthread_condattr_getpshared(const pthread_condattr_t *attr, - int *pshared); -int pthread_condattr_setpshared(pthread_condattr_t *attr, - int pshared); -#endif - -int pthread_cond_broadcast(pthread_cond_t *); -int pthread_cond_destroy(pthread_cond_t *); -int pthread_cond_init(pthread_cond_t *, const pthread_condattr_t *); -int pthread_cond_signal(pthread_cond_t *); -int pthread_cond_timedwait(pthread_cond_t *, - pthread_mutex_t *, const struct timespec * abstime); -int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *); -int pthread_create(pthread_t *, const pthread_attr_t *, - void *(*start_routine) (void *), void *); -int pthread_detach(pthread_t); -int pthread_equal(pthread_t, pthread_t); -__dead void pthread_exit(void *) __attribute__((__noreturn__)); -void *pthread_getspecific(pthread_key_t); -int pthread_join(pthread_t, void **); -int pthread_key_create(pthread_key_t *, void (*routine)(void *)); -int pthread_key_delete(pthread_key_t); -int pthread_kill(struct pthread *, int); -int pthread_mutexattr_init(pthread_mutexattr_t *); -int pthread_mutexattr_destroy(pthread_mutexattr_t *); -int pthread_mutexattr_gettype(pthread_mutexattr_t *, int *); -int pthread_mutexattr_settype(pthread_mutexattr_t *, int); -int pthread_mutex_destroy(pthread_mutex_t *); -int pthread_mutex_init(pthread_mutex_t *, - const pthread_mutexattr_t *); -int pthread_mutex_lock(pthread_mutex_t *); -int pthread_mutex_trylock(pthread_mutex_t *); -int pthread_mutex_unlock(pthread_mutex_t *); -int pthread_once(pthread_once_t *, void (*)(void)); -int pthread_rwlock_destroy(pthread_rwlock_t *); -int pthread_rwlock_init(pthread_rwlock_t *, - const pthread_rwlockattr_t *); -int pthread_rwlock_rdlock(pthread_rwlock_t *); -int pthread_rwlock_tryrdlock(pthread_rwlock_t *); -int pthread_rwlock_trywrlock(pthread_rwlock_t *); -int pthread_rwlock_unlock(pthread_rwlock_t *); -int pthread_rwlock_wrlock(pthread_rwlock_t *); -int pthread_rwlockattr_init(pthread_rwlockattr_t *); -int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *, - int *); -int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int); -int pthread_rwlockattr_destroy(pthread_rwlockattr_t *); -pthread_t pthread_self(void); -int pthread_setspecific(pthread_key_t, const void *); -int pthread_sigmask(int, const sigset_t *, sigset_t *); - -int pthread_cancel(pthread_t); -int pthread_setcancelstate(int, int *); -int pthread_setcanceltype(int, int *); -void pthread_testcancel(void); - -int pthread_getprio(pthread_t); -int pthread_setprio(pthread_t, int); -void pthread_yield(void); - -#if defined(_POSIX_THREAD_PROCESS_SHARED) -int pthread_mutexattr_getpshared(pthread_mutexattr_t *, - int *pshared); -int pthread_mutexattr_setpshared(pthread_mutexattr_t *, - int pshared); -#endif - -#if defined(_POSIX_THREAD_PRIO_PROTECT) -int pthread_mutexattr_getprioceiling(pthread_mutexattr_t *, - int *prioceiling); -int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, - int prioceiling); -int pthread_mutex_getprioceiling(pthread_mutex_t *, int *); -int pthread_mutex_setprioceiling(pthread_mutex_t *, int, int *); -#endif - -#if defined(_POSIX_THREAD_PRIO_PROTECT) || defined (_POSIX_THREAD_PRIO_INHERIT) -int pthread_mutexattr_getprotocol(pthread_mutexattr_t *, - int *protocol); -int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, - int protocol); -#endif - -int pthread_getschedparam(pthread_t pthread, int *policy, - struct sched_param * param); -int pthread_setschedparam(pthread_t pthread, int policy, - const struct sched_param * param); - -#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) -int pthread_attr_getinheritsched(const pthread_attr_t *, int *); -int pthread_attr_getschedparam(const pthread_attr_t *, - struct sched_param *); -int pthread_attr_getschedpolicy(const pthread_attr_t *, int *); -int pthread_attr_getscope(const pthread_attr_t *, int *); -int pthread_attr_setinheritsched(pthread_attr_t *, int); -int pthread_attr_setschedparam(pthread_attr_t *, - const struct sched_param *); -int pthread_attr_setschedpolicy(pthread_attr_t *, int); -int pthread_attr_setscope(pthread_attr_t *, int); -#endif - -int pthread_attr_setfloatstate(pthread_attr_t *, int); -int pthread_attr_getfloatstate(pthread_attr_t *, int *); -int pthread_attr_setcleanup(pthread_attr_t *, - void (*routine)(void *), void *); - - -#ifdef notyet -/* - * Single Unix Specification v2 (UNIX98) defines these: - */ -#define PTHREAD_PRIO_INHERIT -#define PTHREAD_PRIO_NONE -#define PTHREAD_PRIO_PROTECT -int pthread_attr_getguardsize(const pthread_attr_t *, size_t *); -int pthread_attr_setguardsize(const pthread_attr_t *, size_t); -int pthread_getconcurrency(void); -int pthread_setconcurrency(int); -#endif /* susv2 */ - -__END_DECLS - -#endif /* _PTHREAD_H_ */ diff --git a/lib/libc_r/include/pthread_np.h b/lib/libc_r/include/pthread_np.h deleted file mode 100644 index a7eded4b025..00000000000 --- a/lib/libc_r/include/pthread_np.h +++ /dev/null @@ -1,59 +0,0 @@ -/* $OpenBSD: pthread_np.h,v 1.5 2002/02/16 21:27:25 millert Exp $ */ -/* - * Copyright (c) 1996-98 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ -#ifndef _PTHREAD_NP_H_ -#define _PTHREAD_NP_H_ - -/* - * Non-POSIX type definitions: - */ -typedef void (*pthread_switch_routine_t)(pthread_t, pthread_t); - -/* - * Non-POSIX thread function prototype definitions: - */ -__BEGIN_DECLS -int pthread_attr_setcreatesuspend_np(pthread_attr_t *); -int pthread_multi_np(void); -int pthread_resume_np(pthread_t); -int pthread_single_np(void); -int pthread_suspend_np(pthread_t); -int pthread_mutexattr_getkind_np(pthread_mutexattr_t); -int pthread_mutexattr_setkind_np(pthread_mutexattr_t *, int); -void pthread_set_name_np(pthread_t, char *); -int pthread_switch_add_np(pthread_switch_routine_t); -int pthread_switch_delete_np(pthread_switch_routine_t); -int pthread_main_np(void); -__END_DECLS - -#endif diff --git a/lib/libc_r/include/sched.h b/lib/libc_r/include/sched.h deleted file mode 100644 index 81b91b2a682..00000000000 --- a/lib/libc_r/include/sched.h +++ /dev/null @@ -1,78 +0,0 @@ -/* $OpenBSD: sched.h,v 1.6 2002/02/16 21:27:25 millert Exp $ */ - -/* sched.h: POSIX 1003.1b Process Scheduling header */ - -/*- - * Copyright (c) 1996, 1997 - * HD Associates, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by HD Associates, Inc - * and Jukka Antero Ukkonen. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL HD ASSOCIATES OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#ifndef _SCHED_H_ -#define _SCHED_H_ - -#include <sys/types.h> /* For pid_t */ - -#ifndef KERNEL -#include <time.h> /* Per P1003.4 */ -#endif - -/* Scheduling policies - */ -#define SCHED_FIFO 1 -#define SCHED_OTHER 2 -#define SCHED_RR 3 - -struct sched_param -{ - int sched_priority; -}; - -#ifndef KERNEL -#include <sys/cdefs.h> - -__BEGIN_DECLS -int sched_setparam(pid_t, const struct sched_param *); -int sched_getparam(pid_t, struct sched_param *); - -int sched_setscheduler(pid_t, int, const struct sched_param *); -int sched_getscheduler(pid_t); - -int sched_yield(void); -int sched_get_priority_max(int); -int sched_get_priority_min(int); -struct timespec; -int sched_rr_get_interval(pid_t, struct timespec *); -__END_DECLS - -#endif /* KERNEL */ - -#endif /* _SCHED_H_ */ diff --git a/lib/libc_r/include/semaphore.h b/lib/libc_r/include/semaphore.h deleted file mode 100644 index 4735f9c29f9..00000000000 --- a/lib/libc_r/include/semaphore.h +++ /dev/null @@ -1,68 +0,0 @@ -/* $OpenBSD: semaphore.h,v 1.3 2002/02/16 21:27:25 millert Exp $ */ - -/* semaphore.h: POSIX 1003.1b semaphores */ - -/*- - * Copyright (c) 1996, 1997 - * HD Associates, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by HD Associates, Inc - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL HD ASSOCIATES OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: semaphore.h,v 1.6 2000/01/20 07:55:42 jasone Exp $ - */ - -#ifndef _SEMAPHORE_H_ -#define _SEMAPHORE_H_ - -#include <machine/limits.h> - -/* Opaque type definition. */ -struct sem; -typedef struct sem *sem_t; - -#define SEM_FAILED ((sem_t *)0) -#define SEM_VALUE_MAX UINT_MAX - -#ifndef _KERNEL -#include <sys/cdefs.h> - -__BEGIN_DECLS -int sem_init(sem_t *, int, unsigned int); -int sem_destroy(sem_t *); -sem_t *sem_open(const char *, int, ...); -int sem_close(sem_t *); -int sem_unlink(const char *); -int sem_wait(sem_t *); -int sem_trywait(sem_t *); -int sem_post(sem_t *); -int sem_getvalue(sem_t *, int *); -__END_DECLS - -#endif /* _KERNEL */ - -#endif /* _SEMAPHORE_H_ */ diff --git a/lib/libc_r/include/spinlock.h b/lib/libc_r/include/spinlock.h deleted file mode 100644 index 8c87e963de1..00000000000 --- a/lib/libc_r/include/spinlock.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $Id: spinlock.h,v 1.7 2002/02/16 21:27:25 millert Exp $ - * $OpenBSD: spinlock.h,v 1.7 2002/02/16 21:27:25 millert Exp $ - * - * Lock definitions used in both libc and libpthread. - * - */ - -#ifndef _SPINLOCK_H_ -#define _SPINLOCK_H_ -#include <sys/cdefs.h> -#include <sys/types.h> -#include <machine/spinlock.h> - -/* - * Lock structure with room for debugging information. - */ -typedef volatile struct { - _spinlock_lock_t access_lock; - void * lock_owner; - char * fname; - int lineno; -} spinlock_t; - -#define _SPINLOCK_INITIALIZER { _SPINLOCK_UNLOCKED, 0, 0, 0 } - -#define _SPINUNLOCK(_lck) (_lck)->access_lock = _SPINLOCK_UNLOCKED -#ifdef _LOCK_DEBUG -#define _SPINLOCK(_lck) _spinlock_debug(_lck, __FILE__, __LINE__) -#else -#define _SPINLOCK(_lck) _spinlock(_lck) -#endif - -#define _SPINLOCK_INIT(_lck) _SPINUNLOCK(_lck) - -/* - * Thread function prototype definitions: - */ -__BEGIN_DECLS -void _spinlock(spinlock_t *); -void _spinlock_debug(spinlock_t *, char *, int); - -/* lock() functions return 0 if lock was acquired. */ -/* is_locked functions() return 1 if lock is locked. */ -int _atomic_lock(volatile _spinlock_lock_t *); -int _atomic_is_locked(volatile _spinlock_lock_t *); -__END_DECLS - -#endif /* _SPINLOCK_H_ */ diff --git a/lib/libc_r/man/Makefile.inc b/lib/libc_r/man/Makefile.inc deleted file mode 100644 index b0d611a0adb..00000000000 --- a/lib/libc_r/man/Makefile.inc +++ /dev/null @@ -1,98 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.15 2002/02/20 05:16:20 fgsch Exp $ -# $FreeBSD: Makefile.inc,v 1.6 1999/08/28 00:03:02 peter Exp $ - -# POSIX thread man files - -.PATH: ${LIBC_RSRCDIR}/man - -MAN+= \ - pthread_attr_init.3 \ - pthread_attr_setstackaddr.3 \ - pthread_attr_setstacksize.3 \ - pthread_attr_setdetachstate.3 \ - pthread_cleanup_pop.3 \ - pthread_cleanup_push.3 \ - pthread_cond_broadcast.3 \ - pthread_cond_destroy.3 \ - pthread_cond_init.3 \ - pthread_cond_signal.3 \ - pthread_cond_timedwait.3 \ - pthread_cond_wait.3 \ - pthread_cancel.3 \ - pthread_create.3 \ - pthread_detach.3 \ - pthread_equal.3 \ - pthread_exit.3 \ - pthread_getspecific.3 \ - pthread_join.3 \ - pthread_key_create.3 \ - pthread_key_delete.3 \ - pthread_kill.3 \ - pthread_main_np.3 \ - pthread_mutexattr.3 \ - pthread_mutex_destroy.3 \ - pthread_mutex_init.3 \ - pthread_mutex_lock.3 \ - pthread_mutex_trylock.3 \ - pthread_mutex_unlock.3 \ - pthread_once.3 \ - pthread_rwlock_destroy.3 \ - pthread_rwlock_init.3 \ - pthread_rwlock_rdlock.3 \ - pthread_rwlock_unlock.3 \ - pthread_rwlock_wrlock.3 \ - pthread_rwlockattr_destroy.3 \ - pthread_rwlockattr_getpshared.3 \ - pthread_rwlockattr_init.3 \ - pthread_rwlockattr_setpshared.3 \ - pthread_schedparam.3 \ - pthread_self.3 \ - pthread_set_name_np.3 \ - pthread_setspecific.3 \ - pthread_sigmask.3 \ - pthread_single_np.3 \ - pthread_suspend_np.3 \ - pthread_testcancel.3 \ - sem_destroy.3 \ - sem_getvalue.3 \ - sem_init.3 \ - sem_open.3 \ - sem_post.3 \ - sem_wait.3 - -MAN+= pthreads.3 \ - sigwait.3 \ - flockfile.3 \ - getc_unlocked.3 \ - putc_unlocked.3 - -MLINKS+=flockfile.3 funlockfile.3 \ - flockfile.3 ftrylockfile.3 \ - pthread_rwlock_rdlock.3 pthread_rwlock_tryrdlock.3 \ - pthread_rwlock_wrlock.3 pthread_rwlock_trywrlock.3 \ - getc_unlocked.3 getchar_unlocked.3 \ - putc_unlocked.3 putchar_unlocked.3 \ - pthread_suspend_np.3 pthread_resume_np.3 \ - pthread_single_np.3 pthread_multi_np.3 \ - pthread_attr_init.3 pthread_attr_destroy.3 \ - pthread_attr_setstackaddr.3 pthread_attr_getstackaddr.3 \ - pthread_attr_setstacksize.3 pthread_attr_getstacksize.3 \ - pthread_attr_setdetachstate.3 pthread_attr_getdetachstate.3 \ - pthread_mutexattr.3 pthread_mutexattr_init.3 \ - pthread_mutexattr.3 pthread_mutexattr_destroy.3 \ - pthread_mutexattr.3 pthread_mutexattr_getprioceiling.3 \ - pthread_mutexattr.3 pthread_mutexattr_getprotocol.3 \ - pthread_mutexattr.3 pthread_mutexattr_getpshared.3 \ - pthread_mutexattr.3 pthread_mutexattr_gettype.3 \ - pthread_mutexattr.3 pthread_mutexattr_setprioceiling.3 \ - pthread_mutexattr.3 pthread_mutexattr_setprotocol.3 \ - pthread_mutexattr.3 pthread_mutexattr_setpshared.3 \ - pthread_mutexattr.3 pthread_mutexattr_settype.3 \ - pthread_schedparam.3 pthread_getschedparam.3 \ - pthread_schedparam.3 pthread_setschedparam.3 \ - pthread_testcancel.3 pthread_setcancelstate.3 \ - pthread_testcancel.3 pthread_setcanceltype.3 \ - sem_open.3 sem_close.3 \ - sem_open.3 sem_unlink.3 \ - sem_wait.3 sem_trywait.3 - diff --git a/lib/libc_r/man/flockfile.3 b/lib/libc_r/man/flockfile.3 deleted file mode 100644 index 83785f65e5f..00000000000 --- a/lib/libc_r/man/flockfile.3 +++ /dev/null @@ -1,118 +0,0 @@ -.\" $OpenBSD: flockfile.3,v 1.7 2002/05/01 08:03:30 mpech Exp $ -.\" David Leonard <d@openbsd.org>, 1998. Public domain. -.Dd August 20, 1998 -.Dt FLOCKFILE 3 -.Os -.Sh NAME -.Nm flockfile , -.Nm ftrylockfile , -.Nm funlockfile -.Nd application level locking of stdio files -.Sh SYNOPSIS -.Fd #include <stdio.h> -.Ft void -.Fn flockfile "FILE *file" -.Ft int -.Fn ftrylockfile "FILE *file" -.Ft void -.Fn funlockfile "FILE *file" -.Sh DESCRIPTION -The -.Fn flockfile , -.Fn ftrylockfile , -and -.Fn funlockfile -functions provide for explicit application-level locking of stdio -.Ft "FILE *" -objects. -These functions can be used by a thread to delineate a sequence -of I/O statements that are to be executed as a unit. -.Pp -The -.Fn flockfile -function is used by a thread to acquire ownership of a -.Ft "FILE *" -object. -.Pp -The -.Fn ftrylockfile -function is used by a thread to acquire ownership of a -.Ft "FILE *" -object if the object is available; -.Fn ftrylockfile -is a non-blocking version of -.Fn flockfile . -.Pp -The -.Fn funlockfile -function is used to relinquish the ownership granted to the thread. -The behaviour is undefined if a thread other than the current owner calls the -.Fn funlockfile -function. -.Pp -Logically, there is a lock count associated with each -.Ft "FILE *" -object. -This count is implicitly intialized to zero when the -.Ft "FILE *" -object is created. -The -.Ft "FILE *" -object is unlocked when the count is zero. -When the count is positive, a single thread owns the -.Ft "FILE *" -object. -When the -.Fn flockfile -function is called, if the count is zero or if the count is positive and -the caller owns the -.Ft "FILE *" -object, the count is incremented. -Otherwise, the calling thread is suspended, waiting for the count to -return to zero. -Each call to -.Fn funlockfile -decrements the count. -This allows matching calls to -.Fn flockfile -(or successful calls to -.Fn ftrylockfile ) -and -.Fn funlockfile -to be nested. -.Pp -Library functions that reference -.Ft "FILE *" -behave as if they use -.Fn flockfile -and -.Fn funlockfile -internally to obtain ownership of these -.Ft "FILE *" -objects. -.Sh RETURN VALUES -None for -.Fn flockfile -and -.Fn funlockfile . -The function -.Fn ftrylock -returns zero for success and non-zero to indicate that the lock cannot -be acquired. -.Sh ERRORS -None. -.Sh SEE ALSO -.Xr getc_unlocked 3 , -.Xr getchar_unlocked 3 , -.Xr pthreads 3 , -.Xr putc_unlocked 3 , -.Xr putchar_unlocked 3 -.Sh STANDARDS -.Fn flockfile , -.Fn ftrylockfile -and -.Fn funlockfile -conform to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1c/D10. -.\" Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libc_r/man/getc_unlocked.3 b/lib/libc_r/man/getc_unlocked.3 deleted file mode 100644 index 95c01e82af8..00000000000 --- a/lib/libc_r/man/getc_unlocked.3 +++ /dev/null @@ -1,47 +0,0 @@ -.\" $OpenBSD: getc_unlocked.3,v 1.2 1999/07/07 10:50:05 aaron Exp $ -.\" David Leonard <d@openbsd.org>, 1999. Public domain. -.Dd March 20, 1999 -.Dt GETC_UNLOCKED 3 -.Os -.Sh NAME -.Nm getc_unlocked , -.Nm getchar_unlocked -.Nd get next character from stream, efficiently -.Sh SYNOPSIS -.Fd #include <stdio.h> -.Ft int -.Fn getc_unlocked "FILE *stream" -.Ft int -.Fn getchar_unlocked -.Sh DESCRIPTION -The -.Fn getc_unlocked -and -.Fn getchar_unlocked -functions are equivalent to their locked counterparts, -.Xr getc 3 -and -.Xr getchar 3 . -However, -.Fn getc_unlocked -and -.Fn getchar_unlocked -assume that the relevant stream has either been previous locked -with -.Xr flockfile 3 , -or that it will not be accessed by any other thread. -.Sh RETURN VALUES -The return values are as described for -.Xr getc 3 -and -.Xr getchar 3 . -.Sh SEE ALSO -.Xr getc 3 , -.Xr getchar 3 -.Sh STANDARDS -.Fn getc_unlocked -and -.Fn getchar_unlocked -conform to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libc_r/man/pthread_attr_init.3 b/lib/libc_r/man/pthread_attr_init.3 deleted file mode 100644 index 318b27d5a6b..00000000000 --- a/lib/libc_r/man/pthread_attr_init.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" $OpenBSD: pthread_attr_init.3,v 1.3 2002/05/01 08:03:30 mpech Exp $ -.\" Manual page derived from TOG's UNIX98 documentation. -.Dd January 6, 2000 -.Dt PTHREAD_ATTR_INIT 3 -.Os -.Sh NAME -.Nm pthread_attr_init , -.Nm pthread_attr_destroy -.Nd initialise and destroy threads attribute object -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_attr_init "pthread_attr_t *attr" -.Ft int -.Fn pthread_attr_destroy "pthread_attr_t *attr" -.Sh DESCRIPTION -The function -.Fn pthread_attr_init -initialises a thread attributes -object -.Fa attr -with the default value for all of the individual -attributes used by a given implementation. -.Pp -The resulting attribute object (possibly modified by setting -individual attribute values), when used by -.Xr pthread_create 3 , -defines the attributes of the thread created. -A single attributes object can be used in multiple simultaneous calls to -.Xr pthread_create 3 . -.Pp -The -.Fn pthread_attr_destroy -function is used to destroy a thread -attributes object. An implementation may cause -.Fn pthread_attr_destroy -to set -.Fa attr -to an implementation-dependent -invalid value. -The behaviour of using the attribute after it has -been destroyed is undefined. -.Sh RETURN VALUE -Upon successful completion, -.Fn pthread_attr_init -and -.Fn pthread_attr_destroy -return a value of 0. -Otherwise, an error number is returned to indicate the error. -.Sh ERRORS -The -.Fn pthread_attr_init -function will fail if: -.Bl -tag -width Er -.It Bq Er ENOMEM -Insufficient memory exists to initialise the thread attributes -object. -.El -.Pp -These functions will not return an error code of -.Bq Er EINTR . -.Sh SEE ALSO -.Xr pthread_attr_setstackaddr 3 , -.Xr pthread_attr_setstacksize 3 , -.Xr pthread_attr_setdetachstate 3 , -.Xr pthread_create 3 , -.Xr pthreads 3 -.Sh STANDARDS -.Fn pthread_create -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libc_r/man/pthread_attr_setdetachstate.3 b/lib/libc_r/man/pthread_attr_setdetachstate.3 deleted file mode 100644 index 1f0dfa45ef8..00000000000 --- a/lib/libc_r/man/pthread_attr_setdetachstate.3 +++ /dev/null @@ -1,98 +0,0 @@ -.\" $OpenBSD: pthread_attr_setdetachstate.3,v 1.4 2002/05/01 08:03:30 mpech Exp $ -.\" Manual page derived from TOG's UNIX98 documentation. -.Dd January 6, 2000 -.Dt PTHREAD_ATTR_SETDETACHSTATE 3 -.Os -.Sh NAME -.Nm pthread_attr_setdetachstate , -.Nm pthread_attr_getdetachstate -.Nd set and get detachstate attribute -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_attr_setdetachstate "pthread_attr_t *attr" "int detachstate" -.Ft int -.Fn pthread_attr_getdetachstate "pthread_attr_t *attr" "int *detachstate" -.Sh DESCRIPTION -The -.Va detachstate -attribute controls whether the thread is created in -a detached state. -If the thread is created detached, then use of -the ID of the newly created thread by the -.Xr pthread_detach 3 -or -.Xr pthread_join 3 -function is an error. -.Pp -The -.Fn pthread_attr_setdetachstate -and -.Fn pthread_attr_getdetachstate -functions, respectively, set and get the -.Va detachstate -attribute in the -.Fa attr -object. -.Pp -The -.Fa detachstate -can be set to either -.Dv PTHREAD_CREATE_DETACHED -or -.Dv PTHREAD_CREATE_JOINABLE . -A value of -.Dv PTHREAD_CREATE_DETACHED -causes -all threads created with -.Fa attr -to be in the detached state, whereas -using a value of -.Dv PTHREAD_CREATE_JOINABLE -causes all threads created -with -.Fa attr -to be in the joinable state. -The default value of the -.Va detachstate -attribute is -.Dv PTHREAD_CREATE_JOINABLE . -.Sh RETURN VALUE -Upon successful completion, -.Fn pthread_attr_setdetachstate -and -.Fn pthread_attr_getdetachstate -return a value of 0. Otherwise, an -error number is returned to indicate the error. -.Pp -The -.Fn pthread_attr_getdetachstate -function stores the value of the -.Va detachstate -attribute in -.Fa detachstate -if successful. -.Sh ERRORS -The -.Fn pthread_attr_setdetachstate -function will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value of -.Fa detachstate -was not valid. -.El -.Pp -These functions will not return an error code of -.Bq Er EINTR . -.Sh SEE ALSO -.Xr pthread_attr_init 3 , -.Xr pthread_attr_setstackaddr 3 , -.Xr pthread_attr_setstacksize 3 , -.Xr pthread_create 3 , -.Xr pthreads 3 -.Sh STANDARDS -.Fn pthread_create -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libc_r/man/pthread_attr_setstackaddr.3 b/lib/libc_r/man/pthread_attr_setstackaddr.3 deleted file mode 100644 index 7254e83cceb..00000000000 --- a/lib/libc_r/man/pthread_attr_setstackaddr.3 +++ /dev/null @@ -1,64 +0,0 @@ -.\" $OpenBSD: pthread_attr_setstackaddr.3,v 1.4 2002/05/01 08:03:30 mpech Exp $ -.\" Manual page derived from TOG's UNIX98 documentation. -.Dd January 6, 2000 -.Dt PTHREAD_ATTR_SETSTACKADDR 3 -.Os -.Sh NAME -.Nm pthread_attr_setstackaddr , -.Nm pthread_attr_getstackaddr -.Nd set and get stackaddr attribute -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_attr_setstackaddr "pthread_attr_t *attr" "void *stackaddr" -.Ft int -.Fn pthread_attr_getstackaddr "pthread_attr_t *attr" "void **stackaddr" -.Sh DESCRIPTION -The functions -.Fn pthread_attr_setstackaddr -and -.Fn pthread_attr_getstackaddr , -respectively, set and get the thread -creation -.Va stackaddr -attribute in the -.Fa attr -object. -.Pp -The -.Va stackaddr -attribute specifies the location of storage to be -used for the created thread's stack. -The size of the storage is at least -.Dv PTHREAD_STACK_MIN . -.Sh RETURN VALUE -Upon successful completion, -.Fn pthread_attr_setstackaddr -and -.Fn pthread_attr_getstackaddr -return a value of 0. Otherwise, an error -number is returned to indicate the error. -.Pp -The -.Fn pthread_attr_getstackaddr -function stores the -.Va stackaddr -attribute value in -.Fa stackaddr -if successful. -.Sh ERRORS -No errors are defined. -.Pp -These functions will not return an error code of -.Bq Er EINTR . -.Sh SEE ALSO -.Xr pthread_attr_init 3 , -.Xr pthread_attr_setdetachstate 3 , -.Xr pthread_attr_setstacksize 3 , -.Xr pthread_create 3 , -.Xr pthreads 3 -.Sh STANDARDS -.Fn pthread_create -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libc_r/man/pthread_attr_setstacksize.3 b/lib/libc_r/man/pthread_attr_setstacksize.3 deleted file mode 100644 index 4b3edc8818a..00000000000 --- a/lib/libc_r/man/pthread_attr_setstacksize.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" $OpenBSD: pthread_attr_setstacksize.3,v 1.3 2001/06/24 18:17:30 jasoni Exp $ -.\" Manual page derived from TOG's UNIX98 documentation. -.Dd January 6, 2000 -.Dt PTHREAD_ATTR_SETSTACKSIZE 3 -.Os -.Sh NAME -.Nm pthread_attr_setstacksize , -.Nm pthread_attr_getstacksize -.Nd set and get stacksize attribute -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_attr_setstacksize "pthread_attr_t *attr" "size_t stacksize" -.Ft int -.Fn pthread_attr_getstacksize "pthread_attr_t *attr" "size_t *stacksize" -.Sh DESCRIPTION -The functions -.Fn pthread_attr_setstacksize -and -.Fn pthread_attr_getstacksize , -respectively, set and get the thread -creation -.Va stacksize -attribute in the -.Fa attr -object. -.Pp -The -.Va stacksize -attribute defines the minimum stack size (in bytes) -allocated for the created thread's stack. -.Sh RETURN VALUE -Upon successful completion, -.Fn pthread_attr_setstacksize -and -.Fn pthread_attr_getstacksize -return a value of 0. Otherwise, an error -number is returned to indicate the error. -.Pp -The -.Fn pthread_attr_getstacksize -function stores the -.Va stacksize -attribute value in -.Fa stacksize -if successful. -.Sh ERRORS -The -.Fn pthread_attr_setstacksize -function will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value of -.Fa stacksize -is less than -.Dv PTHREAD_STACK_MIN -or exceeds a system-imposed limit. -.El -.Pp -These functions will not return an error code of -.Bq Er EINTR . -.Sh SEE ALSO -.Xr pthread_attr_init 3 , -.Xr pthread_attr_setdetachstate 3 , -.Xr pthread_attr_setstackaddr 3 , -.Xr pthread_create 3 , -.Xr pthreads 3 -.Sh STANDARDS -.Fn pthread_create -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libc_r/man/pthread_cancel.3 b/lib/libc_r/man/pthread_cancel.3 deleted file mode 100644 index 1d9fad5c5ce..00000000000 --- a/lib/libc_r/man/pthread_cancel.3 +++ /dev/null @@ -1,68 +0,0 @@ -.\" $OpenBSD: pthread_cancel.3,v 1.10 2002/05/01 08:03:30 mpech Exp $ -.\" -.Dd January 17, 1999 -.Dt PTHREAD_CANCEL 3 -.Os -.Sh NAME -.Nm pthread_cancel -.Nd cancel execution of a thread -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_cancel "pthread_t thread" -.Sh DESCRIPTION -The -.Fn pthread_cancel -function requests that -.Fa thread -be cancelled. -The target thread's cancelability state and type determines -when the cancellation takes effect. -When the cancellation is acted on, the cancellation cleanup handlers for -.Fa thread -are called. -When the last cancellation cleanup handler returns, -the thread-specific data destructor functions will be called for -.Fa thread . -When the last destructor function returns, -.Fa thread -will be terminated. -.Pp -The cancellation processing in the target thread runs asynchronously with -respect to the calling thread returning from -.Fn pthread_cancel . -.Pp -A status of -.Dv PTHREAD_CANCELED -is made available to any threads joining with the target. -The symbolic constant -.Dv PTHREAD_CANCELED -expands to a constant expression of type -.Ft "(void *)" -whose value matches no pointer to an object in memory nor the value -.Dv NULL . -.Sh RETURN VALUES -If successful, the -.Fn pthread_cancel -functions will return zero. -Otherwise an error number will be returned to indicate the error. -.Sh ERRORS -.Fn pthread_cancel -will fail if: -.Bl -tag -width Er -.It Bq Er ESRCH -No thread could be found corresponding to that specified by the given -thread ID. -.El -.Sh SEE ALSO -.Xr pthread_cleanup_pop 3 , -.Xr pthread_cleanup_push 3 , -.Xr pthread_exit 3 , -.Xr pthread_join 3 , -.Xr pthread_setcancelstate 3 , -.Xr pthread_setcanceltype 3 , -.Xr pthread_testcancel 3 -.Sh STANDARDS -.Fn pthread_cancel -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_cleanup_pop.3 b/lib/libc_r/man/pthread_cleanup_pop.3 deleted file mode 100644 index ec6ebbb0f61..00000000000 --- a/lib/libc_r/man/pthread_cleanup_pop.3 +++ /dev/null @@ -1,63 +0,0 @@ -.\" $OpenBSD: pthread_cleanup_pop.3,v 1.7 2002/05/01 08:03:30 mpech Exp $ -.\" -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_cleanup_pop.3,v 1.4 1999/08/28 00:03:02 peter Exp $ -.\" -.Dd July 30, 1998 -.Dt PTHREAD_CLEANUP_POP 3 -.Os -.Sh NAME -.Nm pthread_cleanup_pop -.Nd call the first cleanup routine -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft void -.Fn pthread_cleanup_pop "int execute" -.Sh DESCRIPTION -The -.Fn pthread_cleanup_pop -function pops the top cleanup routine off of the current thread's cleanup -routine stack, and, if -.Fa execute -is non-zero, it will execute the function. -If there is no cleanup routine then -.Fn pthread_cleanup_pop -does nothing. -.Sh RETURN VALUES -.Fn pthread_cleanup_pop -does not return any value. -.Sh ERRORS -None -.Sh SEE ALSO -.Xr pthread_cleanup_push 3 , -.Xr pthread_exit 3 -.Sh STANDARDS -.Fn pthread_cleanup_pop -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_cleanup_push.3 b/lib/libc_r/man/pthread_cleanup_push.3 deleted file mode 100644 index d599d11c722..00000000000 --- a/lib/libc_r/man/pthread_cleanup_push.3 +++ /dev/null @@ -1,66 +0,0 @@ -.\" $OpenBSD: pthread_cleanup_push.3,v 1.5 2002/02/21 09:06:31 fgsch Exp $ -.\" -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_cleanup_push.3,v 1.5 1999/08/28 00:03:02 peter Exp $ -.\" -.Dd July 30, 1998 -.Dt PTHREAD_CLEANUP_PUSH 3 -.Os -.Sh NAME -.Nm pthread_cleanup_push -.Nd add a cleanup function for thread exit -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft void -.Fn pthread_cleanup_push "void (*cleanup_routine)(void *)" "void *arg" -.Sh DESCRIPTION -The -.Fn pthread_cleanup_push -function adds -.Fa cleanup_routine -to the top of the stack of cleanup handlers that -get called when the current thread exits. -.Pp -When -.Fa cleanup_routine -is called, it is passed -.Fa arg -as its only argument. -.Sh RETURN VALUES -.Fn pthread_cleanup_push -does not return any value. -.Sh ERRORS -None -.Sh SEE ALSO -.Xr pthread_cleanup_pop 3 , -.Xr pthread_exit 3 -.Sh STANDARDS -.Fn pthread_cleanup_push -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_cond_broadcast.3 b/lib/libc_r/man/pthread_cond_broadcast.3 deleted file mode 100644 index 11c8910989c..00000000000 --- a/lib/libc_r/man/pthread_cond_broadcast.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" $OpenBSD: pthread_cond_broadcast.3,v 1.6 2002/02/21 20:12:19 fgsch Exp $ -.\" -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_cond_broadcast.3,v 1.5 1999/08/28 00:03:03 peter Exp $ -.\" -.Dd July 28, 1998 -.Dt PTHREAD_COND_BROADCAST 3 -.Os -.Sh NAME -.Nm pthread_cond_broadcast -.Nd unblock all threads waiting for a condition variable -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_cond_broadcast "pthread_cond_t *cond" -.Sh DESCRIPTION -The -.Fn pthread_cond_broadcast -function unblocks all threads waiting for the condition variable -.Fa cond . -.Sh RETURN VALUES -If successful, the -.Fn pthread_cond_broadcast -function will return zero, otherwise an error number will be returned -to indicate the error. -.Sh ERRORS -.Fn pthread_cond_broadcast -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa cond -is invalid. -.El -.Sh SEE ALSO -.Xr pthread_cond_destroy 3 , -.Xr pthread_cond_init 3 , -.Xr pthread_cond_signal 3 , -.Xr pthread_cond_timedwait 3 , -.Xr pthread_cond_wait 3 -.Sh STANDARDS -.Fn pthread_cond_broadcast -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_cond_destroy.3 b/lib/libc_r/man/pthread_cond_destroy.3 deleted file mode 100644 index 3ec164b6ee3..00000000000 --- a/lib/libc_r/man/pthread_cond_destroy.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" $OpenBSD: pthread_cond_destroy.3,v 1.7 2002/02/21 20:12:19 fgsch Exp $ -.\" -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_cond_destroy.3,v 1.5 1999/08/28 00:03:03 peter Exp $ -.\" -.Dd July 28, 1998 -.Dt PTHREAD_COND_DESTROY 3 -.Os -.Sh NAME -.Nm pthread_cond_destroy -.Nd destroy a condition variable -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_cond_destroy "pthread_cond_t *cond" -.Sh DESCRIPTION -The -.Fn pthread_cond_destroy -function frees the resources allocated by the condition variable -.Fa cond . -.Sh RETURN VALUES -If successful, the -.Fn pthread_cond_destroy -function will return zero, otherwise an error number will be returned -to indicate the error. -.Sh ERRORS -.Fn pthread_cond_destroy -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa cond -is invalid. -.It Bq Er EBUSY -The variable -.Fa cond -is locked by another thread. -.El -.Sh SEE ALSO -.Xr pthread_cond_broadcast 3 , -.Xr pthread_cond_init 3 , -.Xr pthread_cond_signal 3 , -.Xr pthread_cond_timedwait 3 , -.Xr pthread_cond_wait 3 -.Sh STANDARDS -.Fn pthread_cond_destroy -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_cond_init.3 b/lib/libc_r/man/pthread_cond_init.3 deleted file mode 100644 index c88490c6b69..00000000000 --- a/lib/libc_r/man/pthread_cond_init.3 +++ /dev/null @@ -1,82 +0,0 @@ -.\" $OpenBSD: pthread_cond_init.3,v 1.9 2002/04/30 16:31:42 mpech Exp $ -.\" -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_cond_init.3,v 1.6 1999/08/28 00:03:03 peter Exp $ -.\" -.Dd July 28, 1998 -.Dt PTHREAD_COND_INIT 3 -.Os -.Sh NAME -.Nm pthread_cond_init -.Nd create a condition variable -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_cond_init "pthread_cond_t *cond" "const pthread_condattr_t *attr" -.Sh DESCRIPTION -The -.Fn pthread_cond_init -function creates a new condition variable, with attributes specified with -.Fa attr . -If -.Fa attr -is -.Dv NULL -the default attributes are used. -.Sh RETURN VALUES -If successful, the -.Fn pthread_cond_init -function will return zero and put the new condition variable ID into -.Fa cond , -otherwise an error number will be returned to indicate the error. -.Sh ERRORS -.Fn pthread_cond_init -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa attr -is invalid. -.It Bq Er ENOMEM -The process cannot allocate enough memory to create another condition -variable. -.It Bq Er EAGAIN -The system temporarily lacks the resources to create another condition -variable. -.El -.Sh SEE ALSO -.Xr pthread_cond_broadcast 3 , -.Xr pthread_cond_destroy 3 , -.Xr pthread_cond_signal 3 , -.Xr pthread_cond_timedwait 3 , -.Xr pthread_cond_wait 3 -.Sh STANDARDS -.Fn pthread_cond_init -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_cond_signal.3 b/lib/libc_r/man/pthread_cond_signal.3 deleted file mode 100644 index 23c62192ebd..00000000000 --- a/lib/libc_r/man/pthread_cond_signal.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" $OpenBSD: pthread_cond_signal.3,v 1.6 2002/02/21 20:12:19 fgsch Exp $ -.\" -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_cond_signal.3,v 1.5 1999/08/28 00:03:04 peter Exp $ -.\" -.Dd July 28, 1998 -.Dt PTHREAD_COND_SIGNAL 3 -.Os -.Sh NAME -.Nm pthread_cond_signal -.Nd unblock a thread waiting for a condition variable -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_cond_signal "pthread_cond_t *cond" -.Sh DESCRIPTION -The -.Fn pthread_cond_signal -function unblocks one thread waiting for the condition variable -.Fa cond . -.Sh RETURN VALUES -If successful, the -.Fn pthread_cond_signal -function will return zero, otherwise an error number will be returned -to indicate the error. -.Sh ERRORS -.Fn pthread_cond_signal -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa cond -is invalid. -.El -.Sh SEE ALSO -.Xr pthread_cond_broadcast 3 , -.Xr pthread_cond_destroy 3 , -.Xr pthread_cond_init 3 , -.Xr pthread_cond_timedwait 3 , -.Xr pthread_cond_wait 3 -.Sh STANDARDS -.Fn pthread_cond_signal -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_cond_timedwait.3 b/lib/libc_r/man/pthread_cond_timedwait.3 deleted file mode 100644 index 83f380643b3..00000000000 --- a/lib/libc_r/man/pthread_cond_timedwait.3 +++ /dev/null @@ -1,88 +0,0 @@ -.\" $OpenBSD: pthread_cond_timedwait.3,v 1.9 2002/06/04 00:09:07 deraadt Exp $ -.\" -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_cond_timedwait.3,v 1.6 1999/08/28 00:03:04 peter Exp $ -.\" -.Dd July 28, 1998 -.Dt PTHREAD_COND_TIMEDWAIT 3 -.Os -.Sh NAME -.Nm pthread_cond_timedwait -.Nd "wait on a condition variable for a specific amount of time" -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_cond_timedwait "pthread_cond_t *cond" "pthread_mutex_t *mutex" "const struct timespec *abstime" -.Sh DESCRIPTION -The -.Fn pthread_cond_timedwait -function atomically blocks the current thread waiting on the condition -variable specified by -.Fa cond , -and unblocks the mutex specified by -.Fa mutex . -The waiting thread unblocks only after another thread calls -.Xr pthread_cond_signal 3 , -or -.Xr pthread_cond_broadcast 3 -with the same condition variable, or if the system time reaches the -time specified in -.Fa abstime , -and the current thread reacquires the lock on -.Fa mutex . -.Sh RETURN VALUES -If successful, the -.Fn pthread_cond_timedwait -function will return zero. -Otherwise an error number will be returned to indicate the error. -.Sh ERRORS -.Fn pthread_cond_timedwait -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa cond , -.Fa mutex -or -.Fa abstime -is invalid. -.It Bq Er ETIMEDOUT -The system time has reached or exceeded the time specified in -.Fa abstime . -.El -.Sh SEE ALSO -.Xr pthread_cond_broadcast 3 , -.Xr pthread_cond_destroy 3 , -.Xr pthread_cond_init 3 , -.Xr pthread_cond_signal 3 , -.Xr pthread_cond_wait 3 -.Sh STANDARDS -.Fn pthread_cond_timedwait -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_cond_wait.3 b/lib/libc_r/man/pthread_cond_wait.3 deleted file mode 100644 index a9158c1a554..00000000000 --- a/lib/libc_r/man/pthread_cond_wait.3 +++ /dev/null @@ -1,82 +0,0 @@ -.\" $OpenBSD: pthread_cond_wait.3,v 1.8 2002/05/01 08:03:30 mpech Exp $ -.\" -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_cond_wait.3,v 1.6 1999/08/28 00:03:04 peter Exp $ -.\" -.Dd July 28, 1998 -.Dt PTHREAD_COND_WAIT 3 -.Os -.Sh NAME -.Nm pthread_cond_wait -.Nd wait on a condition variable -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_cond_wait "pthread_cond_t *cond" "pthread_mutex_t *mutex" -.Sh DESCRIPTION -The -.Fn pthread_cond_wait -function atomically blocks the current thread waiting on the condition -variable specified by -.Fa cond , -and unblocks the mutex specified by -.Fa mutex . -The waiting thread unblocks only after another thread calls -.Xr pthread_cond_signal 3 , -or -.Xr pthread_cond_broadcast 3 -with the same condition variable, and the current thread reacquires the lock -on -.Fa mutex . -.Sh RETURN VALUES -If successful, the -.Fn pthread_cond_wait -function will return zero. -Otherwise an error number will be returned to indicate the error. -.Sh ERRORS -.Fn pthread_cond_wait -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa cond -or the value specified by -.Fa mutex -is invalid. -.El -.Sh SEE ALSO -.Xr pthread_cond_broadcast 3 , -.Xr pthread_cond_destroy 3 , -.Xr pthread_cond_init 3 , -.Xr pthread_cond_signal 3 , -.Xr pthread_cond_timedwait 3 -.Sh STANDARDS -.Fn pthread_cond_wait -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_create.3 b/lib/libc_r/man/pthread_create.3 deleted file mode 100644 index 71eeb0ee11d..00000000000 --- a/lib/libc_r/man/pthread_create.3 +++ /dev/null @@ -1,122 +0,0 @@ -.\" $OpenBSD: pthread_create.3,v 1.9 2002/05/01 08:03:30 mpech Exp $ -.\" -.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by John Birrell. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_create.3,v 1.8 1999/08/28 00:03:04 peter Exp $ -.\" -.Dd April 4, 1996 -.Dt PTHREAD_CREATE 3 -.Os -.Sh NAME -.Nm pthread_create -.Nd create a new thread -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_create "pthread_t *thread" "const pthread_attr_t *attr" "void *(*start_routine)(void *)" "void *arg" -.Sh DESCRIPTION -The -.Fn pthread_create -function is used to create a new thread, with attributes specified by -.Fa attr , -within a process. -If -.Fa attr -is NULL, the default attributes are used. If the attributes specified by -.Fa attr -are modified later, the thread's attributes are not affected. -Upon successful completion -.Fn pthread_create -will store the ID of the created thread in the location specified by -.Fa thread . -.Pp -The thread is created executing -.Fa start_routine -with -.Fa arg -as its sole argument. -If the -.Fa start_routine -returns, the effect is as if there was an implicit call to -.Fn pthread_exit -using the return value of -.Fa start_routine -as the exit status. -Note that the thread in which -.Fn main -was originally invoked differs from this. -When it returns from -.Fn main , -the effect is as if there was an implicit call to -.Fn exit -using the return value of -.Fn main -as the exit status. -.Pp -The signal state of the new thread is initialized as: -.Bl -bullet -offset indent -.It -The signal mask is inherited from the creating thread. -.It -The set of signals pending for the new thread is empty. -.El -.Sh RETURN VALUES -If successful, the -.Fn pthread_create -function will return zero. -Otherwise an error number will be returned to indicate the error. -.Sh ERRORS -.Fn pthread_create -will fail if: -.Bl -tag -width Er -.It Bq Er EAGAIN -The system lacked the necessary resources to create another thread, or -the system-imposed limit on the total number of threads in a process -[PTHREAD_THREADS_MAX] would be exceeded. -.It Bq Er EINVAL -The value specified by -.Fa attr -is invalid. -.El -.Sh SEE ALSO -.Xr fork 2 , -.Xr pthread_attr_init 3 , -.Xr pthread_attr_setdetachstate 3 , -.Xr pthread_attr_setstackaddr 3 , -.Xr pthread_attr_setstacksize 3 , -.Xr pthread_cleanup_pop 3 , -.Xr pthread_cleanup_push 3 , -.Xr pthread_exit 3 , -.Xr pthread_join 3 -.Sh STANDARDS -.Fn pthread_create -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_detach.3 b/lib/libc_r/man/pthread_detach.3 deleted file mode 100644 index cd30b2c6e7b..00000000000 --- a/lib/libc_r/man/pthread_detach.3 +++ /dev/null @@ -1,89 +0,0 @@ -.\" $OpenBSD: pthread_detach.3,v 1.10 2002/05/01 08:03:30 mpech Exp $ -.\" -.\" Copyright (c) 1996-1998 John Birrell <jb@cimlogic.com.au>. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by John Birrell. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_detach.3,v 1.5 1999/08/28 00:03:05 peter Exp $ -.\" -.Dd April 4, 1996 -.Dt PTHREAD_DETACH 3 -.Os -.Sh NAME -.Nm pthread_detach -.Nd detach a thread -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_detach "pthread_t thread" -.Sh DESCRIPTION -The -.Fn pthread_detach -function is used to indicate to the implementation that storage for the -thread -.Fa thread -can be reclaimed when the thread terminates. -If -.Fa thread -has not terminated, -.Fn pthread_detach -will not cause it to terminate. -The effect of multiple -.Fn pthread_detach -calls on the same target thread is unspecified. -.Sh RETURN VALUES -If successful, the -.Fn pthread_detach -function will return zero. -Otherwise an error number will be returned to indicate the error. -Note that the function does not change the value -of -.Va errno -as it did for some drafts of the standard. -These early drafts also passed a pointer to pthread_t as the argument. -Beware! -.Sh ERRORS -.Fn pthread_detach -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The implementation has detected that the value specified by -.Fa thread -does not refer to a joinable thread. -.It Bq Er ESRCH -No thread could be found corresponding to that specified by the given -thread ID, -.Fa thread . -.El -.Sh SEE ALSO -.Xr pthread_join 3 -.Sh STANDARDS -.Fn pthread_detach -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_equal.3 b/lib/libc_r/man/pthread_equal.3 deleted file mode 100644 index ef469ed6687..00000000000 --- a/lib/libc_r/man/pthread_equal.3 +++ /dev/null @@ -1,68 +0,0 @@ -.\" $OpenBSD: pthread_equal.3,v 1.8 2002/04/30 16:31:42 mpech Exp $ -.\" -.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by John Birrell. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_equal.3,v 1.4 1999/08/28 00:03:05 peter Exp $ -.\" -.Dd April 4, 1996 -.Dt PTHREAD_EQUAL 3 -.Os -.Sh NAME -.Nm pthread_equal -.Nd compare thread IDs -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_equal "pthread_t t1" "pthread_t t2" -.Sh DESCRIPTION -The -.Fn pthread_equal -function compares the thread IDs -.Fa t1 -and -.Fa t2 . -.Sh RETURN VALUES -The -.Fn pthread_equal -function will return non-zero if the thread IDs -.Fa t1 -and -.Fa t2 -correspond to the same thread, otherwise it will return zero. -.Sh ERRORS -None. -.Sh SEE ALSO -.Xr pthread_create 3 , -.Xr pthread_exit 3 -.Sh STANDARDS -.Fn pthread_equal -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_exit.3 b/lib/libc_r/man/pthread_exit.3 deleted file mode 100644 index 6c1153e9e94..00000000000 --- a/lib/libc_r/man/pthread_exit.3 +++ /dev/null @@ -1,104 +0,0 @@ -.\" $OpenBSD: pthread_exit.3,v 1.10 2002/05/01 08:03:30 mpech Exp $ -.\" -.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by John Birrell. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_exit.3,v 1.7 1999/08/28 00:03:06 peter Exp $ -.\" -.Dd April 4, 1996 -.Dt PTHREAD_EXIT 3 -.Os -.Sh NAME -.Nm pthread_exit -.Nd terminate the calling thread -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft void -.Fn pthread_exit "void *value_ptr" -.Sh DESCRIPTION -The -.Fn pthread_exit -function terminates the calling thread and makes the value -.Fa value_ptr -available to any successful join with the terminating thread. -Any -cancellation cleanup handlers that have been pushed and are not yet popped -are popped in the reverse order that they were pushed and then executed. -After all cancellation handlers have been executed, if the thread has any -thread-specific data, appropriate destructor functions are called in an -unspecified order. -Thread termination does not release any application -visible process resources, including, but not limited to, mutexes and -file descriptors, nor does it perform any process level cleanup -actions, including, but not limited to, calling -.Fn atexit -routines that may exist. -.Pp -An implicit call to -.Fn pthread_exit -is made when a thread other than the thread in which -.Fn main -was first invoked returns from the start routine that was used to create -it. The function's return value serves as the thread's exit status. -.Pp -The behavior of -.Fn pthread_exit -is undefined if called from a cancellation handler or destructor function -that was invoked as the result of an implicit or explicit call to -.Fn pthread_exit . -.Pp -After a thread has terminated, the result of access to local (auto) -variables of the thread is undefined. -Thus, references to local variables -of the exiting thread should not be used for the -.Fn pthread_exit -.Fa value_ptr -parameter value. -.Pp -The process will exit with an exit status of 0 after the last thread has -been terminated. -The behavior is as if the implementation called -.Fn exit -with a zero argument at thread termination time. -.Sh RETURN VALUES -The -.Fn pthread_exit -function cannot return to its caller. -.Sh ERRORS -None. -.Sh SEE ALSO -.Xr _exit 2 , -.Xr exit 3 , -.Xr pthread_create 3 , -.Xr pthread_join 3 -.Sh STANDARDS -.Fn pthread_exit -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_getspecific.3 b/lib/libc_r/man/pthread_getspecific.3 deleted file mode 100644 index bf319ffc029..00000000000 --- a/lib/libc_r/man/pthread_getspecific.3 +++ /dev/null @@ -1,83 +0,0 @@ -.\" $OpenBSD: pthread_getspecific.3,v 1.5 2002/02/21 20:12:19 fgsch Exp $ -.\" -.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by John Birrell. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_getspecific.3,v 1.6 1999/08/28 00:03:06 peter Exp $ -.\" -.Dd April 4, 1996 -.Dt PTHREAD_GETSPECIFIC 3 -.Os -.Sh NAME -.Nm pthread_getspecific -.Nd get a thread-specific data value -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft void * -.Fn pthread_getspecific "pthread_key_t key" -.Sh DESCRIPTION -The -.Fn pthread_getspecific -function returns the value currently bound to the specified -.Fa key -on behalf of the calling thread. -.Pp -The effect of calling -.Fn pthread_getspecific -with a -.Fa key -value not obtained from -.Fn pthread_key_create -or after -.Fa key -has been deleted with -.Fn pthread_key_delete -is undefined. -.Pp -.Fn pthread_getspecific -may be called from a thread-specific data destructor function. -.Sh RETURN VALUES -The -.Fn pthread_getspecific -function will return the thread-specific data value associated with the given -.Fa key . -If no thread-specific data value is associated with -.Fa key , -then the value NULL is returned. -.Sh ERRORS -None. -.Sh SEE ALSO -.Xr pthread_key_create 3 , -.Xr pthread_key_delete 3 , -.Xr pthread_setspecific 3 -.Sh STANDARDS -.Fn pthread_getspecific -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_join.3 b/lib/libc_r/man/pthread_join.3 deleted file mode 100644 index 5af3f3e28b9..00000000000 --- a/lib/libc_r/man/pthread_join.3 +++ /dev/null @@ -1,102 +0,0 @@ -.\" $OpenBSD: pthread_join.3,v 1.8 2002/05/01 08:03:30 mpech Exp $ -.\" -.\" Copyright (c) 1996-1998 John Birrell <jb@cimlogic.com.au>. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by John Birrell. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_join.3,v 1.6 1999/08/28 00:03:06 peter Exp $ -.\" -.Dd April 4, 1996 -.Dt PTHREAD_JOIN 3 -.Os -.Sh NAME -.Nm pthread_join -.Nd wait for thread termination -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_join "pthread_t thread" "void **value_ptr" -.Sh DESCRIPTION -The -.Fn pthread_join -function suspends execution of the calling thread until the target -.Fa thread -terminates unless the target -.Fa thread -has already terminated. -.Pp -On return from a successful -.Fn pthread_join -call with a non-NULL -.Fa value_ptr -argument, the value passed to -.Fn pthread_exit -by the terminating thread is stored in the location referenced by -.Fa value_ptr . -When a -.Fn pthread_join -returns successfully, the target thread has been terminated. -The results of multiple simultaneous calls to -.Fn pthread_join -specifying the same target thread are undefined. -If the thread calling -.Fn pthread_join -is cancelled, then the target thread is not detached. -.Pp -A thread that has exited but remains unjoined counts against -[_POSIX_THREAD_THREADS_MAX]. -.Sh RETURN VALUES -If successful, the -.Fn pthread_join -function will return zero. -Otherwise an error number will be returned to indicate the error. -.Sh ERRORS -.Fn pthread_join -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The implementation has detected that the value specified by -.Fa thread -does not refer to a joinable thread. -.It Bq Er ESRCH -No thread could be found corresponding to that specified by the given -thread ID, -.Fa thread . -.It Bq Er EDEADLK -A deadlock was detected or the value of -.Fa thread -specifies the calling thread. -.El -.Sh SEE ALSO -.Xr wait 2 , -.Xr pthread_create 3 -.Sh STANDARDS -.Fn pthread_join -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_key_create.3 b/lib/libc_r/man/pthread_key_create.3 deleted file mode 100644 index 0f5aa51c5dc..00000000000 --- a/lib/libc_r/man/pthread_key_create.3 +++ /dev/null @@ -1,104 +0,0 @@ -.\" $OpenBSD: pthread_key_create.3,v 1.7 2002/05/01 08:03:30 mpech Exp $ -.\" -.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by John Birrell. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_key_create.3,v 1.5 1999/08/28 00:03:06 peter Exp $ -.\" -.Dd April 4, 1996 -.Dt PTHREAD_KEY_CREATE 3 -.Os -.Sh NAME -.Nm pthread_key_create -.Nd thread-specific data key creation -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_key_create "pthread_key_t *key" "void (*destructor)(void *)" -.Sh DESCRIPTION -The -.Fn pthread_key_create -function creates a thread-specific data key visible to all threads in the -process. -Key values provided by -.Fn pthread_key_create -are opaque objects used to locate thread-specific data. -Although the same -key value may be used by different threads, the values bound to the key -by -.Fn pthread_setspecific -are maintained on a per-thread basis and persist for the life of the calling -thread. -.Pp -Upon key creation, the value NULL is associated with the new key in all -active threads. -Upon thread creation, the value NULL is associated with all -defined keys in the new thread. -.Pp -An optional destructor function may be associated with each key value. -At thread exit, if a key value has a non-NULL destructor pointer, and the -thread has a non-NULL value associated with the key, the function pointed -to is called with the current associated value as its sole argument. -The order of destructor calls is unspecified if more than one destructor exists -for a thread when it exits. -.Pp -If, after all the destructors have been called for all non-NULL values -with associated destructors, there are still some non-NULL values with -associated destructors, then the process is repeated. -If, after at least -[PTHREAD_DESTRUCTOR_ITERATIONS] iterations of destructor calls for -outstanding non-NULL values, there are still some non-NULL values with -associated destructors, the implementation stops calling destructors. -.Sh RETURN VALUES -If successful, the -.Fn pthread_key_create -function will store the newly created key value at the location specified by -.Fa key -and returns zero. -Otherwise an error number will be returned to indicate the error. -.Sh ERRORS -.Fn pthread_key_create -will fail if: -.Bl -tag -width Er -.It Bq Er EAGAIN -The system lacked the necessary resources to create another thread-specific -data key, or the system-imposed limit on the total number of keys per process -[PTHREAD_KEYS_MAX] would be exceeded. -.It Bq Er ENOMEM -Insufficient memory exists to create the key. -.El -.Sh SEE ALSO -.Xr pthread_getspecific 3 , -.Xr pthread_key_delete 3 , -.Xr pthread_setspecific 3 -.Sh STANDARDS -.Fn pthread_key_create -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_key_delete.3 b/lib/libc_r/man/pthread_key_delete.3 deleted file mode 100644 index 121c2d87253..00000000000 --- a/lib/libc_r/man/pthread_key_delete.3 +++ /dev/null @@ -1,96 +0,0 @@ -.\" $OpenBSD: pthread_key_delete.3,v 1.8 2002/05/01 08:03:30 mpech Exp $ -.\" -.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by John Birrell. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_key_delete.3,v 1.5 1999/08/28 00:03:06 peter Exp $ -.\" -.Dd April 4, 1996 -.Dt PTHREAD_KEY_DELETE 3 -.Os -.Sh NAME -.Nm pthread_key_delete -.Nd delete a thread-specific data key -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_key_delete "pthread_key_t key" -.Sh DESCRIPTION -The -.Fn pthread_key_delete -function deletes a thread-specific data key previously returned by -.Fn pthread_key_create . -The thread-specific data values associated with -.Fa key -need not be NULL at the time that -.Fn pthread_key_delete -is called. -It is the responsibility of the application to free any -application storage or perform any cleanup actions for data structures -related to the deleted key or associated thread-specific data in any threads; -this cleanup can be done either before or after -.Fn pthread_key_delete -is called. -Any attempt to use -.Fa key -following the call to -.Fn pthread_key_delete -results in undefined behavior. -.Pp -The -.Fn pthread_key_delete -function is callable from within destructor functions. -Destructor functions are not invoked by -.Fn pthread_key_delete . -Any destructor function that may have been associated with -.Fa key -will no longer be called upon thread exit. -.Sh RETURN VALUES -If successful, the -.Fn pthread_key_delete -function will return zero. -Otherwise an error number will be returned to indicate the error. -.Sh ERRORS -.Fn pthread_key_delete -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The -.Fa key -value is invalid. -.El -.Sh SEE ALSO -.Xr pthread_getspecific 3 , -.Xr pthread_key_create 3 , -.Xr pthread_setspecific 3 -.Sh STANDARDS -.Fn pthread_key_delete -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_kill.3 b/lib/libc_r/man/pthread_kill.3 deleted file mode 100644 index 7560d665cec..00000000000 --- a/lib/libc_r/man/pthread_kill.3 +++ /dev/null @@ -1,75 +0,0 @@ -.\" $OpenBSD: pthread_kill.3,v 1.1 2002/02/20 05:16:20 fgsch Exp $ -.\" -.\" Copyright (C) 2000 Jason Evans <jasone@FreeBSD.org>. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice(s), this list of conditions and the following disclaimer as -.\" the first lines of this file unmodified other than the possible -.\" addition of one or more copyright notices. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice(s), this list of conditions and the following disclaimer in -.\" the documentation and/or other materials provided with the -.\" distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD: src/lib/libc_r/man/pthread_kill.3,v 1.8 2001/10/01 16:09:09 ru Exp $ -.Dd April 27, 2000 -.Dt PTHREAD_KILL 3 -.Os -.Sh NAME -.Nm pthread_kill -.Nd send a signal to a specified thread -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Fd #include <signal.h> -.Ft int -.Fn pthread_kill "pthread_t thread" "int sig" -.Sh DESCRIPTION -The -.Fn pthread_kill -function sends a signal, specified by -.Fa sig , -to a thread, specified by -.Fa thread . -If -.Fa sig -is 0, error checking is performed, but no signal is actually sent. -.Sh RETURN VALUES -If successful, -.Fn pthread_kill -returns 0. -Otherwise, an error number is returned. -.Sh ERRORS -.Fn pthread_kill -will fail if: -.Bl -tag -width Er -.It Bq Er ESRCH -.Fa thread -is an invalid thread ID. -.It Bq Er EINVAL -.Fa sig -is an invalid or unsupported signal number. -.El -.Sh SEE ALSO -.Xr kill 2 , -.Xr pthread_self 3 , -.Xr raise 3 -.Sh STANDARDS -.Fn pthread_kill -conforms to -.St -p1003.1-96 diff --git a/lib/libc_r/man/pthread_main_np.3 b/lib/libc_r/man/pthread_main_np.3 deleted file mode 100644 index 76e73a3676e..00000000000 --- a/lib/libc_r/man/pthread_main_np.3 +++ /dev/null @@ -1,43 +0,0 @@ -.\" $OpenBSD: pthread_main_np.3,v 1.3 2002/05/01 08:03:30 mpech Exp $ -.\" -.\" Copyright (c) 2001 Peter Valchev <pvalchev@openbsd.org>. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted. -.\" -.Dd August 17, 2001 -.Dt PTHREAD_MAIN_NP 3 -.Os -.Sh NAME -.Nm pthread_main_np -.Nd identify the main thread -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Fd #include <pthread_np.h> -.Ft int -.Fn pthread_main_np "void" -.Sh DESCRIPTION -The -.Fn pthread_main_np -function identifies the main thread. -.Sh RETURN VALUES -The -.Fn pthread_main_np -function returns: -.Bl -tag -width hrmf -.It 1 -if the calling thread is the main thread -.It 0 -if the calling thread is not the main thread -.It -1 -if the thread initialization has not completed -.El -.Sh SEE ALSO -.Xr pthread_self 3 , -.Xr pthreads 3 -.Sh STANDARDS -The -.Fn pthread_main_np -function is non-portable and may not be supported with the above -semantics on other POSIX systems. diff --git a/lib/libc_r/man/pthread_mutex_destroy.3 b/lib/libc_r/man/pthread_mutex_destroy.3 deleted file mode 100644 index 66ad2ea04b7..00000000000 --- a/lib/libc_r/man/pthread_mutex_destroy.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" $OpenBSD: pthread_mutex_destroy.3,v 1.7 2002/02/21 20:12:19 fgsch Exp $ -.\" -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_mutex_destroy.3,v 1.5 1999/08/28 00:03:07 peter Exp $ -.\" -.Dd July 29, 1998 -.Dt PTHREAD_MUTEX_DESTROY 3 -.Os -.Sh NAME -.Nm pthread_mutex_destroy -.Nd free resources allocated for a mutex -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_mutex_destroy "pthread_mutex_t *mutex" -.Sh DESCRIPTION -The -.Fn pthread_mutex_destroy -function frees the resources allocated for -.Fa mutex . -.Sh RETURN VALUES -If successful, -.Fn pthread_mutex_destroy -will return zero, otherwise an error number will be returned to -indicate the error. -.Sh ERRORS -.Fn pthread_mutex_destroy -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa mutex -is invalid. -.It Bq Er EBUSY -.Fa mutex -is locked by another thread. -.El -.Sh SEE ALSO -.Xr pthread_mutex_init 3 , -.Xr pthread_mutex_lock 3 , -.Xr pthread_mutex_trylock 3 , -.Xr pthread_mutex_unlock 3 -.Sh STANDARDS -.Fn pthread_mutex_destroy -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_mutex_init.3 b/lib/libc_r/man/pthread_mutex_init.3 deleted file mode 100644 index 55cb09bdf62..00000000000 --- a/lib/libc_r/man/pthread_mutex_init.3 +++ /dev/null @@ -1,79 +0,0 @@ -.\" $OpenBSD: pthread_mutex_init.3,v 1.7 2002/02/21 20:12:19 fgsch Exp $ -.\" -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_mutex_init.3,v 1.6 1999/08/28 00:03:07 peter Exp $ -.\" -.Dd July 29, 1998 -.Dt PTHREAD_MUTEX_INIT 3 -.Os -.Sh NAME -.Nm pthread_mutex_init -.Nd create a mutex -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_mutex_init "pthread_mutex_t *mutex" "const pthread_mutexattr_t *attr" -.Sh DESCRIPTION -The -.Fn pthread_mutex_init -function creates a new mutex, with attributes specified with -.Fa attr . -If -.Fa attr -is -.Dv NULL -the default attributes are used. -.Sh RETURN VALUES -If successful, -.Fn pthread_mutex_init -will return zero and put the new mutex ID into -.Fa mutex , -otherwise an error number will be returned to indicate the error. -.Sh ERRORS -.Fn pthread_mutex_init -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa attr -is invalid. -.It Bq Er ENOMEM -The process cannot allocate enough memory to create another mutex. -.It Bq Er EAGAIN -The temporarily lacks the resources to create another mutex. -.El -.Sh SEE ALSO -.Xr pthread_mutex_destroy 3 , -.Xr pthread_mutex_lock 3 , -.Xr pthread_mutex_trylock 3 , -.Xr pthread_mutex_unlock 3 -.Sh STANDARDS -.Fn pthread_mutex_init -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_mutex_lock.3 b/lib/libc_r/man/pthread_mutex_lock.3 deleted file mode 100644 index d506ce0d0fa..00000000000 --- a/lib/libc_r/man/pthread_mutex_lock.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" $OpenBSD: pthread_mutex_lock.3,v 1.6 2002/02/21 20:12:19 fgsch Exp $ -.\" -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_mutex_lock.3,v 1.5 1999/08/28 00:03:07 peter Exp $ -.\" -.Dd July 30, 1998 -.Dt PTHREAD_MUTEX_LOCK 3 -.Os -.Sh NAME -.Nm pthread_mutex_lock -.Nd lock a mutex -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_mutex_lock "pthread_mutex_t *mutex" -.Sh DESCRIPTION -The -.Fn pthread_mutex_lock -function locks -.Fa mutex . -If the mutex is already locked, the calling thread will block until the -mutex becomes available. -.Sh RETURN VALUES -If successful, -.Fn pthread_mutex_lock -will return zero, otherwise an error number will be returned to -indicate the error. -.Sh ERRORS -.Fn pthread_mutex_lock -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa mutex -is invalid. -.It Bq Er EDEADLK -A deadlock would occur if the thread blocked waiting for -.Fa mutex . -.El -.Sh SEE ALSO -.Xr pthread_mutex_destroy 3 , -.Xr pthread_mutex_init 3 , -.Xr pthread_mutex_trylock 3 , -.Xr pthread_mutex_unlock 3 -.Sh STANDARDS -.Fn pthread_mutex_lock -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_mutex_trylock.3 b/lib/libc_r/man/pthread_mutex_trylock.3 deleted file mode 100644 index ade8afec404..00000000000 --- a/lib/libc_r/man/pthread_mutex_trylock.3 +++ /dev/null @@ -1,75 +0,0 @@ -.\" $OpenBSD: pthread_mutex_trylock.3,v 1.7 2002/02/21 20:12:19 fgsch Exp $ -.\" -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_mutex_trylock.3,v 1.5 1999/08/28 00:03:08 peter Exp $ -.\" -.Dd July 30, 1998 -.Dt PTHREAD_MUTEX_TRYLOCK 3 -.Os -.Sh NAME -.Nm pthread_mutex_trylock -.Nd attempt to lock a mutex without blocking -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_mutex_trylock "pthread_mutex_t *mutex" -.Sh DESCRIPTION -The -.Fn pthread_mutex_trylock -function locks -.Fa mutex . -If the mutex is already locked, -.Fn pthread_mutex_trylock -will not block waiting for the mutex, but will return an error condition. -.Sh RETURN VALUES -If successful, -.Fn pthread_mutex_trylock -will return zero, otherwise an error number will be returned to -indicate the error. -.Sh ERRORS -.Fn pthread_mutex_trylock -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa mutex -is invalid. -.It Bq Er EBUSY -.Fa mutex -is already locked. -.El -.Sh SEE ALSO -.Xr pthread_mutex_destroy 3 , -.Xr pthread_mutex_init 3 , -.Xr pthread_mutex_lock 3 , -.Xr pthread_mutex_unlock 3 -.Sh STANDARDS -.Fn pthread_mutex_trylock -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_mutex_unlock.3 b/lib/libc_r/man/pthread_mutex_unlock.3 deleted file mode 100644 index 09b1a3f33a4..00000000000 --- a/lib/libc_r/man/pthread_mutex_unlock.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" $OpenBSD: pthread_mutex_unlock.3,v 1.6 2002/02/21 20:12:19 fgsch Exp $ -.\" -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_mutex_unlock.3,v 1.5 1999/08/28 00:03:08 peter Exp $ -.\" -.Dd July 30, 1998 -.Dt PTHREAD_MUTEX_UNLOCK 3 -.Os -.Sh NAME -.Nm pthread_mutex_unlock -.Nd unlock a mutex -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_mutex_unlock "pthread_mutex_t *mutex" -.Sh DESCRIPTION -If the current thread holds the lock on -.Fa mutex , -then the -.Fn pthread_mutex_unlock -function unlocks -.Fa mutex . -.Sh RETURN VALUES -If successful, -.Fn pthread_mutex_unlock -will return zero, otherwise an error number will be returned to -indicate the error. -.Sh ERRORS -.Fn pthread_mutex_trylock -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa mutex -is invalid. -.It Bq Er EPERM -The current thread does not hold a lock on -.Fa mutex . -.El -.Sh SEE ALSO -.Xr pthread_mutex_destroy 3 , -.Xr pthread_mutex_init 3 , -.Xr pthread_mutex_lock 3 , -.Xr pthread_mutex_trylock 3 -.Sh STANDARDS -.Fn pthread_mutex_unlock -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_mutexattr.3 b/lib/libc_r/man/pthread_mutexattr.3 deleted file mode 100644 index 09b0a1a4b25..00000000000 --- a/lib/libc_r/man/pthread_mutexattr.3 +++ /dev/null @@ -1,177 +0,0 @@ -.\" $OpenBSD: pthread_mutexattr.3,v 1.2 2002/02/21 20:12:19 fgsch Exp $ -.\" -.\" Copyright (C) 2000 Jason Evans <jasone@freebsd.org>. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice(s), this list of conditions and the following disclaimer as -.\" the first lines of this file unmodified other than the possible -.\" addition of one or more copyright notices. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice(s), this list of conditions and the following disclaimer in -.\" the documentation and/or other materials provided with the -.\" distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_mutexattr.3,v 1.5 2001/07/15 07:53:26 dd Exp $ -.Dd May 1, 2000 -.Dt PTHREAD_MUTEXATTR 3 -.Os -.Sh NAME -.Nm pthread_mutexattr_init , -.Nm pthread_mutexattr_destroy , -.Nm pthread_mutexattr_setprioceiling , -.Nm pthread_mutexattr_getprioceiling , -.Nm pthread_mutexattr_setprotocol , -.Nm pthread_mutexattr_getprotocol , -.Nm pthread_mutexattr_settype , -.Nm pthread_mutexattr_gettype -.Nd mutex attribute operations -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_mutexattr_init "pthread_mutexattr_t *attr" -.Ft int -.Fn pthread_mutexattr_destroy "pthread_mutexattr_t *attr" -.Ft int -.Fn pthread_mutexattr_setprioceiling "pthread_mutexattr_t *attr" "int prioceiling" -.Ft int -.Fn pthread_mutexattr_getprioceiling "pthread_mutexattr_t *attr" "int *prioceiling" -.Ft int -.Fn pthread_mutexattr_setprotocol "pthread_mutexattr_t *attr" "int protocol" -.Ft int -.Fn pthread_mutexattr_getprotocol "pthread_mutexattr_t *attr" "int *protocol" -.Ft int -.Fn pthread_mutexattr_settype "pthread_mutexattr_t *attr" "int type" -.Ft int -.Fn pthread_mutexattr_gettype "pthread_mutexattr_t *attr" "int *type" -.Sh DESCRIPTION -Mutex attributes are used to specify parameters to -.Fn pthread_mutex_init . -One attribute object can be used in multiple calls to -.Fn pthread_mutex_init , -with or without modifications between calls. -.Pp -The -.Fn pthread_mutexattr_init -function initializes -.Fa attr -with all the default mutex attributes. -.Pp -The -.Fn pthread_mutexattr_destroy -function destroys -.Fa attr . -.Pp -The -.Fn pthread_mutexattr_set* -functions set the attribute that corresponds to each function name. -.Pp -The -.Fn pthread_mutexattr_get* -functions copy the value of the attribute that corresponds to each function name -to the location pointed to by the second function parameter. -.Sh RETURN VALUES -If successful, these functions return 0. -Otherwise, an error number is returned to indicacte the error. -.Sh ERRORS -.Fn pthread_mutexattr_init -will fail if: -.Bl -tag -width Er -.It Bq Er ENOMEM -Out of memory. -.El -.Pp -.Fn pthread_mutexattr_destroy -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -Invalid value for -.Fa attr . -.El -.Pp -.Fn pthread_mutexattr_setprioceiling -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -Invalid value for -.Fa attr , -or invalid value for -.Fa prioceiling . -.El -.Pp -.Fn pthread_mutexattr_getprioceiling -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -Invalid value for -.Fa attr . -.El -.Pp -.Fn pthread_mutexattr_setprotocol -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -Invalid value for -.Fa attr , -or invalid value for -.Fa protocol . -.El -.Pp -.Fn pthread_mutexattr_getprotocol -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -Invalid value for -.Fa attr . -.El -.Pp -.Fn pthread_mutexattr_settype -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -Invalid value for -.Fa attr , -or invalid value for -.Fa type . -.El -.Pp -.Fn pthread_mutexattr_gettype -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -Invalid value for -.Fa attr . -.El -.Sh SEE ALSO -.Xr pthread_mutex_init 3 -.Sh STANDARDS -.Fn pthread_mutexattr_init -and -.Fn pthread_mutexattr_destroy -conform to -.St -p1003.1-96 -.Pp -.Fn pthread_mutexattr_setprioceiling , -.Fn pthread_mutexattr_getprioceiling , -.Fn pthread_mutexattr_setprotocol , -.Fn pthread_mutexattr_getprotocol , -.Fn pthread_mutexattr_settype , -and -.Fn pthread_mutexattr_gettype -conform to -.St -susv2 diff --git a/lib/libc_r/man/pthread_once.3 b/lib/libc_r/man/pthread_once.3 deleted file mode 100644 index 83e40014787..00000000000 --- a/lib/libc_r/man/pthread_once.3 +++ /dev/null @@ -1,106 +0,0 @@ -.\" $OpenBSD: pthread_once.3,v 1.10 2002/05/01 08:03:30 mpech Exp $ -.\" -.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by John Birrell. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_once.3,v 1.5 1999/08/28 00:03:09 peter Exp $ -.\" -.Dd April 4, 1996 -.Dt PTHREAD_ONCE 3 -.Os -.Sh NAME -.Nm pthread_once -.Nd dynamic package initialization -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Pp -.Ft pthread_once_t -.Fa once_control -\&= -.Dv PTHREAD_ONCE_INIT ; -.Pp -.Ft int -.Fn pthread_once "pthread_once_t *once_control" "void (*init_routine)(void)" -.Sh DESCRIPTION -The first call to -.Fn pthread_once -by any thread in a process, with a given -.Fa once_control , -will call the -.Fn init_routine -with no arguments. -Subsequent calls to -.Fn pthread_once -with the same -.Fa once_control -will not call the -.Fn init_routine . -On return from -.Fn pthread_once , -it is guaranteed that -.Fn init_routine -has completed. -The -.Fa once_control -parameter is used to determine whether the associated initialization -routine has been called. -.Pp -The function -.Fn pthread_once -is not a cancellation point. -However, if -.Fn init_routine -is a cancellation point and is cancelled, the effect on -.Fa once_control is as if -.Fn pthread_once -was never called. -.Pp -The constant -.Dv PTHREAD_ONCE_INIT -is defined by header -.Aq Pa pthread.h . -.Pp -The behavior of -.Fn pthread_once -is undefined if -.Fa once_control -has automatic storage duration or is not initialized by -.Dv PTHREAD_ONCE_INIT . -.Sh RETURN VALUES -If successful, the -.Fn pthread_once -function will return zero. -Otherwise an error number will be returned to indicate the error. -.Sh ERRORS -None. -.Sh STANDARDS -.Fn pthread_once -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_rwlock_destroy.3 b/lib/libc_r/man/pthread_rwlock_destroy.3 deleted file mode 100644 index 103d2efe5ff..00000000000 --- a/lib/libc_r/man/pthread_rwlock_destroy.3 +++ /dev/null @@ -1,83 +0,0 @@ -.\" $OpenBSD: pthread_rwlock_destroy.3,v 1.5 1999/11/24 05:35:32 d Exp $ -.\" Copyright (c) 1998 Alex Nash -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_rwlock_destroy.3,v 1.3 1999/08/28 00:03:09 peter Exp $ -.\" -.Dd August 4, 1998 -.Dt PTHREAD_RWLOCK_DESTROY 3 -.Os -.Sh NAME -.Nm pthread_rwlock_destroy -.Nd destroy a read/write lock -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_rwlock_destroy "pthread_rwlock_t *lock" -.Sh DESCRIPTION -The -.Fn pthread_rwlock_destroy -function is used to destroy a read/write lock previously created with -.Fn pthread_rwlock_init . -.Sh RETURN VALUES -If successful, the -.Fn pthread_rwlock_destroy -function will return zero. Otherwise an error number will be returned -to indicate the error. -.Sh SEE ALSO -.Xr pthread_rwlock_init 3 -.Sh STANDARDS -The -.Fn pthread_rwlock_destroy -function is expected to conform to -.St -susv2 . -.Sh ERRORS -The -.Fn pthread_rwlock_destroy -function will fail if: -.Bl -tag -width Er -.It Bq Er EPERM -The caller does not have the privilege to perform the operation. -.El -.Pp -The -.Fn pthread_rwlock_destroy -function may fail if: -.Bl -tag -width Er -.It Bq Er EBUSY -The system has detected an attempt to destroy the object referenced by -.Fa lock -while it is locked. -.It Bq Er EINVAL -The value specified by -.Fa lock -is invalid. -.El -.Sh HISTORY -The -.Fn pthread_rwlock_destroy -function first appeared in -.Fx 3.0 -and -.Ox 2.5 . diff --git a/lib/libc_r/man/pthread_rwlock_init.3 b/lib/libc_r/man/pthread_rwlock_init.3 deleted file mode 100644 index 87ca307fee6..00000000000 --- a/lib/libc_r/man/pthread_rwlock_init.3 +++ /dev/null @@ -1,102 +0,0 @@ -.\" $OpenBSD: pthread_rwlock_init.3,v 1.4 2000/04/12 21:48:02 aaron Exp $ -.\" Copyright (c) 1998 Alex Nash -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_rwlock_init.3,v 1.2 1999/08/28 00:03:09 peter Exp $ -.\" -.Dd August 4, 1998 -.Dt PTHREAD_RWLOCK_INIT 3 -.Os -.Sh NAME -.Nm pthread_rwlock_init -.Nd initialize a read/write lock -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_rwlock_init "pthread_rwlock_t *lock" "const pthread_rwlockattr_t *attr" -.Sh DESCRIPTION -The -.Fn pthread_rwlock_init -function is used to initialize a read/write lock, with attributes -specified by -.Fa attr . -If -.Fa attr -is NULL, the default read/write lock attributes are used. -.Pp -The results of calling -.Fn pthread_rwlock_init -with an already initialized lock are undefined. -.Sh RETURN VALUES -If successful, the -.Fn pthread_rwlock_init -function will return zero. Otherwise an error number will be returned -to indicate the error. -.Sh SEE ALSO -.Xr pthread_rwlock_destroy 3 , -.Xr pthread_rwlockattr_init 3 , -.Xr pthread_rwlockattr_setpshared 3 -.Sh STANDARDS -The -.Fn pthread_rwlock_init -function is expected to conform to -.St -susv2 . -.Sh ERRORS -The -.Fn pthread_rwlock_init -function will fail if: -.Bl -tag -width Er -.It Bq Er EAGAIN -The system lacked the necessary resources (other than memory) to -initialize the lock. -.It Bq Er ENOMEM -Insufficient memory exists to initialize the lock. -.It Bq Er EPERM -The caller does not have sufficient privilege to perform the -operation. -.El -.Pp -The -.Fn pthread_rwlock_init -function may fail if: -.Bl -tag -width Er -.It Bq Er EBUSY -The system has detected an attempt to re-initialize the object -referenced by -.Fa lock , -a previously initialized but not yet destroyed read/write lock. -.It Bq Er EINVAL -The value specified by -.Fa attr -is invalid. -.El -.Sh HISTORY -The -.Fn pthread_rwlock_init -function first appeared in -.Fx 3.0 -and -.Ox 2.5 . -.Sh BUGS -The PTHREAD_PROCESS_SHARED attribute is not supported. diff --git a/lib/libc_r/man/pthread_rwlock_rdlock.3 b/lib/libc_r/man/pthread_rwlock_rdlock.3 deleted file mode 100644 index 56188fb9b91..00000000000 --- a/lib/libc_r/man/pthread_rwlock_rdlock.3 +++ /dev/null @@ -1,125 +0,0 @@ -.\" $OpenBSD: pthread_rwlock_rdlock.3,v 1.5 2000/04/12 21:48:02 aaron Exp $ -.\" Copyright (c) 1998 Alex Nash -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_rwlock_rdlock.3,v 1.2 1999/08/28 00:03:09 peter Exp $ -.\" -.Dd August 4, 1998 -.Dt PTHREAD_RWLOCK_RDLOCK 3 -.Os -.Sh NAME -.Nm pthread_rwlock_rdlock , -.Nm pthread_rwlock_tryrdlock -.Nd acquire a read/write lock for reading -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_rwlock_rdlock "pthread_rwlock_t *lock" -.Ft int -.Fn pthread_rwlock_tryrdlock "pthread_rwlock_t *lock" -.Sh DESCRIPTION -The -.Fn pthread_rwlock_rdlock -function acquires a read lock on -.Fa lock -provided that -.Fa lock -is not presently held for writing and no writer threads are -presently blocked on the lock. If the read lock cannot be -immediately acquired, the calling thread blocks until it can -acquire the lock. -.Pp -The -.Fn pthread_rwlock_tryrdlock -function performs the same action, but does not block if the lock -cannot be immediately obtained (i.e., the lock is held for writing -or there are waiting writers). -.Pp -A thread may hold multiple concurrent read locks. If so, -.Fn pthread_rwlock_unlock -must be called once for each lock obtained. -.Pp -The results of acquiring a read lock while the calling thread holds -a write lock are undefined. -.Sh IMPLEMENTATION NOTES -To prevent writer starvation, writers are favored over readers. -.Sh RETURN VALUES -If successful, the -.Fn pthread_rwlock_rdlock -and -.Fn pthread_rwlock_tryrdlock -functions will return zero. Otherwise an error number will be returned -to indicate the error. -.Sh SEE ALSO -.Xr pthread_rwlock_init 3 , -.Xr pthread_rwlock_trywrlock 3 , -.Xr pthread_rwlock_unlock 3 , -.Xr pthread_rwlock_wrlock 3 -.Sh STANDARDS -The -.Fn pthread_rwlock_rdlock -and -.Fn pthread_rwlock_tryrdlock -functions are expected to conform to -.St -susv2 . -.Sh ERRORS -The -.Fn pthread_rwlock_tryrdlock -function will fail if: -.Bl -tag -width Er -.It Bq Er EBUSY -The lock could not be acquired because a writer holds the lock or -was blocked on it. -.El -.Pp -The -.Fn pthread_rwlock_rdlock -and -.Fn pthread_rwlock_tryrdlock -functions may fail if: -.Bl -tag -width Er -.It Bq Er EAGAIN -The lock could not be acquired because the maximum number of read locks -against -.Fa lock -has been exceeded. -.It Bq Er EDEADLK -The current thread already owns -.Fa lock -for writing. -.It Bq Er EINVAL -The value specified by -.Fa lock -is invalid. -.It Bq Er ENOMEM -Insufficient memory exists to initialize the lock (applies to -statically initialized locks only). -.El -.Sh HISTORY -The -.Fn pthread_rwlock_rdlock -function first appeared in -.Fx 3.0 -and -.Ox 2.5 . diff --git a/lib/libc_r/man/pthread_rwlock_unlock.3 b/lib/libc_r/man/pthread_rwlock_unlock.3 deleted file mode 100644 index 797df36091b..00000000000 --- a/lib/libc_r/man/pthread_rwlock_unlock.3 +++ /dev/null @@ -1,82 +0,0 @@ -.\" $OpenBSD: pthread_rwlock_unlock.3,v 1.4 2000/04/12 21:48:02 aaron Exp $ -.\" Copyright (c) 1998 Alex Nash -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_rwlock_unlock.3,v 1.2 1999/08/28 00:03:10 peter Exp $ -.\" -.Dd August 4, 1998 -.Dt PTHREAD_RWLOCK_UNLOCK 3 -.Os -.Sh NAME -.Nm pthread_rwlock_unlock -.Nd release a read/write lock -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_rwlock_unlock "pthread_rwlock_t *lock" -.Sh DESCRIPTION -The -.Fn pthread_rwlock_unlock -function is used to release the read/write lock previously obtained by -.Fn pthread_rwlock_rdlock , -.Fn pthread_rwlock_wrlock , -.Fn pthread_rwlock_tryrdlock , -or -.Fn pthread_rwlock_trywrlock . -.Sh RETURN VALUES -If successful, the -.Fn pthread_rwlock_unlock -function will return zero. Otherwise an error number will be returned -to indicate the error. -.Pp -The results are undefined if -.Fa lock -is not held by the calling thread. -.Sh SEE ALSO -.Xr pthread_rwlock_rdlock 3 , -.Xr pthread_rwlock_wrlock 3 -.Sh STANDARDS -The -.Fn pthread_rwlock_unlock -function is expected to conform to -.St -susv2 . -.Sh ERRORS -The -.Fn pthread_rwlock_unlock -function may fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa lock -is invalid. -.It Bq Er EPERM -The current thread does not own the read/write lock. -.El -.Sh HISTORY -The -.Fn pthread_rwlock_unlock -function first appeared in -.Fx 3.0 -and -.Ox 2.5 . diff --git a/lib/libc_r/man/pthread_rwlock_wrlock.3 b/lib/libc_r/man/pthread_rwlock_wrlock.3 deleted file mode 100644 index 31ce3902bc9..00000000000 --- a/lib/libc_r/man/pthread_rwlock_wrlock.3 +++ /dev/null @@ -1,105 +0,0 @@ -.\" $OpenBSD: pthread_rwlock_wrlock.3,v 1.4 2000/04/12 21:48:02 aaron Exp $ -.\" Copyright (c) 1998 Alex Nash -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_rwlock_wrlock.3,v 1.2 1999/08/28 00:03:10 peter Exp $ -.\" -.Dd August 4, 1998 -.Dt PTHREAD_RWLOCK_WRLOCK 3 -.Os -.Sh NAME -.Nm pthread_rwlock_wrlock , -.Nm pthread_rwlock_trywrlock -.Nd acquire a read/write lock for writing -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_rwlock_wrlock "pthread_rwlock_t *lock" -.Ft int -.Fn pthread_rwlock_trywrlock "pthread_rwlock_t *lock" -.Sh DESCRIPTION -The -.Fn pthread_rwlock_wrlock -function blocks until a write lock can be acquired against -.Fa lock . -The -.Fn pthread_rwlock_trywrlock -function performs the same action, but does not block if the lock -cannot be immediately obtained. -.Pp -The results are undefined if the calling thread already holds the -lock at the time the call is made. -.Sh IMPLEMENTATION NOTES -To prevent writer starvation, writers are favored over readers. -.Sh RETURN VALUES -If successful, the -.Fn pthread_rwlock_wrlock -and -.Fn pthread_rwlock_trywrlock -functions will return zero. Otherwise an error number will be returned -to indicate the error. -.Sh SEE ALSO -.Xr pthread_rwlock_trywrlock 3 , -.Xr pthread_rwlock_unlock 3 , -.Xr pthread_rwlock_wrlock 3 -.Sh STANDARDS -The -.Fn pthread_rwlock_wrlock -and -.Fn pthread_rwlock_trywrlock -functions are expected to conform to -.St -susv2 . -.Sh ERRORS -The -.Fn pthread_rwlock_trywrlock -function will fail if: -.Bl -tag -width Er -.It Bq Er EBUSY -The calling thread is not able to acquire the lock without blocking. -.El -.Pp -The -.Fn pthread_rwlock_wrlock -and -.Fn pthread_rwlock_trywrlock -functions may fail if: -.Bl -tag -width Er -.It Bq Er EDEADLK -The calling thread already owns the read/write lock (for reading -or writing). -.It Bq Er EINVAL -The value specified by -.Fa lock -is invalid. -.It Bq Er ENOMEM -Insufficient memory exists to initialize the lock (applies to -statically initialized locks only). -.El -.Sh HISTORY -The -.Fn pthread_rwlock_wrlock -function first appeared in -.Fx 3.0 -and -.Ox 2.5 . diff --git a/lib/libc_r/man/pthread_rwlockattr_destroy.3 b/lib/libc_r/man/pthread_rwlockattr_destroy.3 deleted file mode 100644 index 34ef04ad608..00000000000 --- a/lib/libc_r/man/pthread_rwlockattr_destroy.3 +++ /dev/null @@ -1,71 +0,0 @@ -.\" $OpenBSD: pthread_rwlockattr_destroy.3,v 1.7 2002/05/01 08:03:30 mpech Exp $ -.\" Copyright (c) 1998 Alex Nash -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_rwlockattr_destroy.3,v 1.3 1999/08/28 00:03:10 peter Exp $ -.\" -.Dd August 4, 1998 -.Dt PTHREAD_RWLOCKATTR_DESTROY 3 -.Os -.Sh NAME -.Nm pthread_rwlockattr_destroy -.Nd destroy a read/write lock -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_rwlockattr_destroy "pthread_rwlockattr_t *attr" -.Sh DESCRIPTION -The -.Fn pthread_rwlockattr_destroy -function is used to destroy a read/write lock attribute object -previously created with -.Fn pthread_rwlockattr_init . -.Sh RETURN VALUES -If successful, the -.Fn pthread_rwlockattr_destroy -function will return zero. -Otherwise an error number will be returned to indicate the error. -.Sh SEE ALSO -.Xr pthread_rwlockattr_init 3 -.Sh STANDARDS -The -.Fn pthread_rwlockattr_destroy -function is expected to conform to -.St -susv2 . -.Sh ERRORS -.Fn pthread_rwlockattr_destroy -may fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa attr -is invalid. -.El -.Sh HISTORY -The -.Fn pthread_rwlockattr_destroy -function first appeared in -.Fx 3.0 -and -.Ox 2.5 . diff --git a/lib/libc_r/man/pthread_rwlockattr_getpshared.3 b/lib/libc_r/man/pthread_rwlockattr_getpshared.3 deleted file mode 100644 index f5cb3b83e5a..00000000000 --- a/lib/libc_r/man/pthread_rwlockattr_getpshared.3 +++ /dev/null @@ -1,84 +0,0 @@ -.\" $OpenBSD: pthread_rwlockattr_getpshared.3,v 1.7 2002/05/01 08:03:30 mpech Exp $ -.\" Copyright (c) 1998 Alex Nash -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_rwlockattr_getpshared.3,v 1.4 1999/08/28 00:03:10 peter Exp $ -.\" -.Dd March 22, 1999 -.Dt PTHREAD_RWLOCKATTR_GETPSHARED 3 -.Os -.Sh NAME -.Nm pthread_rwlockattr_getpshared -.Nd get the process shared attribute -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_rwlockattr_getpshared "const pthread_rwlockattr_t *attr" "int *pshared" -.Sh DESCRIPTION -The -.Fn pthread_rwlockattr_getpshared -function is used to get the process shared setting of a read/write -lock attribute object. -The setting is returned via -.Fa pshared , -and may be one of two values: -.Bl -hang -offset flag -width 123456789012345678901234 -.It Ar PTHREAD_PROCESS_SHARED -Any thread of any process that has access to the memory where the -read/write lock resides can manipulate the lock. -.It Ar PTHREAD_PROCESS_PRIVATE -Only threads created within the same process as the thread that -initialized the read/write lock can manipulate the lock. -This is the default value. -.El -.Sh RETURN VALUES -If successful, the -.Fn pthread_rwlockattr_getpshared -function will return zero. -Otherwise an error number will be returned to indicate the error. -.Sh SEE ALSO -.Xr pthread_rwlock_init 3 , -.Xr pthread_rwlockattr_init 3 , -.Xr pthread_rwlockattr_setpshared 3 -.Sh STANDARDS -The -.Fn pthread_rwlockattr_getpshared -function is expected to conform to -.St -susv2 . -.Sh ERRORS -.Fn pthread_rwlockattr_getpshared -may fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa attr -is invalid. -.El -.Sh HISTORY -The -.Fn pthread_rwlockattr_getpshared -function first appeared in -.Fx 3.0 -and -.Ox 2.5 . diff --git a/lib/libc_r/man/pthread_rwlockattr_init.3 b/lib/libc_r/man/pthread_rwlockattr_init.3 deleted file mode 100644 index 14a2fd8dbee..00000000000 --- a/lib/libc_r/man/pthread_rwlockattr_init.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" $OpenBSD: pthread_rwlockattr_init.3,v 1.6 2002/05/01 08:03:30 mpech Exp $ -.\" Copyright (c) 1998 Alex Nash -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_rwlockattr_init.3,v 1.3 1999/08/28 00:03:10 peter Exp $ -.\" -.Dd August 4, 1998 -.Dt PTHREAD_RWLOCKATTR_INIT 3 -.Os -.Sh NAME -.Nm pthread_rwlockattr_init -.Nd initialize a read/write lock -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_rwlockattr_init "pthread_rwlockattr_t *attr" -.Sh DESCRIPTION -The -.Fn pthread_rwlockattr_init -function is used to initialize a read/write lock attributes object. -.Sh RETURN VALUES -If successful, the -.Fn pthread_rwlockattr_init -function will return zero. -Otherwise an error number will be returned to indicate the error. -.Sh SEE ALSO -.Xr pthread_rwlock_init 3 , -.Xr pthread_rwlockattr_destroy 3 , -.Xr pthread_rwlockattr_getpshared 3 , -.Xr pthread_rwlockattr_setpshared 3 -.Sh STANDARDS -The -.Fn pthread_rwlockattr_init -function is expected to conform to -.St -susv2 . -.Sh ERRORS -.Fn pthread_rwlockattr_init -will fail if: -.Bl -tag -width Er -.It Bq Er ENOMEM -Insufficient memory exists to initialize the attribute object. -.El -.Sh HISTORY -The -.Fn pthread_rwlockattr_init -function first appeared in -.Fx 3.0 -and -.Ox 2.5 . diff --git a/lib/libc_r/man/pthread_rwlockattr_setpshared.3 b/lib/libc_r/man/pthread_rwlockattr_setpshared.3 deleted file mode 100644 index 292940f15e4..00000000000 --- a/lib/libc_r/man/pthread_rwlockattr_setpshared.3 +++ /dev/null @@ -1,89 +0,0 @@ -.\" $OpenBSD: pthread_rwlockattr_setpshared.3,v 1.6 2002/05/01 08:03:30 mpech Exp $ -.\" Copyright (c) 1998 Alex Nash -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_rwlockattr_setpshared.3,v 1.2 1999/08/28 00:03:11 peter Exp $ -.\" -.Dd August 4, 1998 -.Dt PTHREAD_RWLOCKATTR_SETPSHARED 3 -.Os -.Sh NAME -.Nm pthread_rwlockattr_setpshared -.Nd set the process shared attribute -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_rwlockattr_setpshared "pthread_rwlockattr_t *attr" "int pshared" -.Sh DESCRIPTION -The -.Fn pthread_rwlockattr_setpshared -function sets the process shared attribute of -.Fa attr -to the value referenced by -.Fa pshared . -.Fa pshared -may be one of two values: -.Bl -hang -offset flag -width 123456789012345678901234 -.It Ar PTHREAD_PROCESS_SHARED -Any thread of any process that has access to the memory where the -read/write lock resides can manipulate the lock. -.It Ar PTHREAD_PROCESS_PRIVATE -Only threads created within the same process as the thread that -initialized the read/write lock can manipulate the lock. -This is the default value. -.El -.Sh RETURN VALUES -If successful, the -.Fn pthread_rwlockattr_setpshared -function will return zero. -Otherwise an error number will be returned to indicate the error. -.Sh SEE ALSO -.Xr pthread_rwlock_init 3 , -.Xr pthread_rwlockattr_init 3 , -.Xr pthread_rwlockattr_setpshared 3 -.Sh STANDARDS -The -.Fn pthread_rwlockattr_setpshared -function is expected to conform to -.St -susv2 . -.Sh ERRORS -.Fn pthread_rwlockattr_setpshared -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa attr -or -.Fa pshared -is invalid. -.El -.Sh HISTORY -The -.Fn pthread_rwlockattr_setpshared -function first appeared in -.Fx 3.0 -and -.Ox 2.5 . -.Sh BUGS -The PTHREAD_PROCESS_SHARED attribute is not supported. diff --git a/lib/libc_r/man/pthread_schedparam.3 b/lib/libc_r/man/pthread_schedparam.3 deleted file mode 100644 index ba98179720f..00000000000 --- a/lib/libc_r/man/pthread_schedparam.3 +++ /dev/null @@ -1,89 +0,0 @@ -.\" $OpenBSD: pthread_schedparam.3,v 1.1 2001/08/11 16:15:55 fgsch Exp $ -.\" Copyright (C) 2000 Jason Evans <jasone@freebsd.org>. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice(s), this list of conditions and the following disclaimer as -.\" the first lines of this file unmodified other than the possible -.\" addition of one or more copyright notices. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice(s), this list of conditions and the following disclaimer in -.\" the documentation and/or other materials provided with the -.\" distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD: src/lib/libc_r/man/pthread_schedparam.3,v 1.4 2001/07/15 07:53:27 dd Exp $ -.Dd May 1, 2000 -.Dt PTHREAD_SCHEDPARAM 3 -.Os -.Sh NAME -.Nm pthread_setschedparam , -.Nm pthread_getschedparam -.Nd thread scheduling parameter manipulation -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_setschedparam "pthread_t thread" "int policy" "const struct sched_param *param" -.Ft int -.Fn pthread_getschedparam "pthread_t thread" "int *policy" "struct sched_param *param" -.Sh DESCRIPTION -The -.Fn pthread_setschedparam -and -.Fn pthread_getschedparam -functions set and get the scheduling parameters of individual threads. -The scheduling policy for a thread can either be -.Dv SCHED_FIFO -(first in, first out) or -.Dv SCHED_RR -(round-robin). -The thread priority (accessed via -.Va param->sched_priority ) -must be at least -.Dv PTHREAD_MIN_PRIORITY -and no more than -.Dv PTHREAD_MAX_PRIORITY . -.Sh RETURN VALUES -If successful, these functions return 0. -Otherwise, an error number is returned to indicate the error. -.Sh ERRORS -.Fn pthread_setschedparam -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -Invalid value for -.Va policy . -.It Bq Er ENOTSUP -Invalid value for scheduling parameters. -.It Bq Er ESRCH -Non-existent thread -.Va thread . -.El -.Pp -.Fn pthread_getschedparam -will fail if: -.Bl -tag -width Er -.It Bq Er ESRCH -Non-existent thread -.Va thread . -.El -.Sh STANDARDS -.Fn pthread_setschedparam -and -.Fn pthread_getschedparam -conform to -.St -susv2 diff --git a/lib/libc_r/man/pthread_self.3 b/lib/libc_r/man/pthread_self.3 deleted file mode 100644 index 03be4482f5c..00000000000 --- a/lib/libc_r/man/pthread_self.3 +++ /dev/null @@ -1,61 +0,0 @@ -.\" $OpenBSD: pthread_self.3,v 1.6 2002/02/21 20:12:19 fgsch Exp $ -.\" -.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by John Birrell. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_self.3,v 1.4 1999/08/28 00:03:11 peter Exp $ -.\" -.Dd April 4, 1996 -.Dt PTHREAD_SELF 3 -.Os -.Sh NAME -.Nm pthread_self -.Nd get the calling thread's ID -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft pthread_t -.Fn pthread_self "void" -.Sh DESCRIPTION -The -.Fn pthread_self -function returns the thread ID of the calling thread. -.Sh RETURN VALUES -The -.Fn pthread_self -function returns the thread ID of the calling thread. -.Sh ERRORS -None. -.Sh SEE ALSO -.Xr pthread_create 3 , -.Xr pthread_equal 3 -.Sh STANDARDS -.Fn pthread_self -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_set_name_np.3 b/lib/libc_r/man/pthread_set_name_np.3 deleted file mode 100644 index 2de216bb1cf..00000000000 --- a/lib/libc_r/man/pthread_set_name_np.3 +++ /dev/null @@ -1,35 +0,0 @@ -.\" $OpenBSD: pthread_set_name_np.3,v 1.3 2000/04/15 02:15:26 aaron Exp $ -.\" David Leonard <d@openbsd.org>, 1999. Public domain. -.Dd December 19, 1999 -.Dt PTHREAD_SET_NAME_NP 3 -.Os -.Sh NAME -.Nm pthread_set_name_np -.Nd set the name of a thread -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Fd #include <pthread_np.h> -.Ft void -.Fn pthread_set_name_np "pthread_t thread" "char *name" -.Sh DESCRIPTION -The -.Fn pthread_set_name_np -function associates -.Fa name -with -.Fa thread . -This can be useful for debugging, as the name is displayed in -the thread status as displayed when the process receives the -.Dv SIGINFO -signal. -.Pp -The string pointed to by -.Fa name -is copied, and so need not be valid for the life of the thread. -.Sh SEE ALSO -.Xr pthreads 3 -.Sh STANDARDS -The -.Fn pthread_set_name_np -function is non-portable and may not be supported with the above -semantics on other POSIX systems. diff --git a/lib/libc_r/man/pthread_setspecific.3 b/lib/libc_r/man/pthread_setspecific.3 deleted file mode 100644 index 977bce59b6f..00000000000 --- a/lib/libc_r/man/pthread_setspecific.3 +++ /dev/null @@ -1,93 +0,0 @@ -.\" $OpenBSD: pthread_setspecific.3,v 1.10 2002/05/01 08:03:30 mpech Exp $ -.\" -.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by John Birrell. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD: pthread_setspecific.3,v 1.5 1999/08/28 00:03:11 peter Exp $ -.\" -.Dd April 4, 1996 -.Dt PTHREAD_SETSPECIFIC 3 -.Os -.Sh NAME -.Nm pthread_setspecific -.Nd set a thread-specific data value -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_setspecific "pthread_key_t key" "const void *value" -.Sh DESCRIPTION -The -.Fn pthread_setspecific -function associates a thread-specific value with a -.Fa key -obtained via a previous call to -.Fn pthread_key_create . -Different threads may bind different values to the same key. These values are -typically pointers to blocks of dynamically allocated memory that have been -reserved for use by the calling thread. -.Pp -The effect of calling -.Fn pthread_setspecific -with a key value not obtained from -.Fn pthread_key_create -or after -.Fa key -has been deleted with -.Fn pthread_key_delete -is undefined. -.Pp -.Fn pthread_setspecific -may be called from a thread-specific data destructor function; however, this -may result in lost storage or infinite loops. -.Sh RETURN VALUES -If successful, the -.Fn pthread_setspecific -function will return zero. -Otherwise an error number will be returned to indicate the error. -.Sh ERRORS -.Fn pthread_setspecific -will fail if: -.Bl -tag -width Er -.It Bq Er ENOMEM -Insufficient memory exists to associate the value with the -.Fa key . -.It Bq Er EINVAL -The -.Fa key -value is invalid. -.El -.Sh SEE ALSO -.Xr pthread_getspecific 3 , -.Xr pthread_key_create 3 , -.Xr pthread_key_delete 3 -.Sh STANDARDS -.Fn pthread_setspecific -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_sigmask.3 b/lib/libc_r/man/pthread_sigmask.3 deleted file mode 100644 index e1bd704e52f..00000000000 --- a/lib/libc_r/man/pthread_sigmask.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" $OpenBSD: pthread_sigmask.3,v 1.5 2002/11/09 20:34:01 fgsch Exp $ -.\" -.Dd March 21, 1999 -.Dt PTHREAD_SIGMASK 3 -.Os -.Sh NAME -.Nm pthread_sigmask -.Nd examine and/or change a thread's signal mask -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Fd #include <signal.h> -.Ft int -.Fn pthread_sigmask "int how" "const sigset_t *set" "sigset_t *oset" -.Sh DESCRIPTION -The -.Fn pthread_sigmask -function examines and/or changes the calling thread's signal mask. -.Pp -If -.Fa set -is not -.Dv NULL , -it specifies a set of signals to be modified, and -.Fa how -specifies what to set the signal mask to: -.Bl -tag -width SIG_UNBLOCK -.It Dv SIG_BLOCK -Union of the current mask and -.Fa set . -.It Dv SIG_UNBLOCK -Intersection of the current mask and the complement of -.Fa set . -.It Dv SIG_SETMASK -.Fa set . -.El -.Pp -If -.Fa oset -is not NULL, the previous signal mask is stored in the location pointed to by -.Fa oset . -.Pp -.Dv SIGKILL -and -.Dv SIGSTOP -cannot be blocked, and will be silently ignored if included in the signal mask. -.Sh RETURN VALUES -If successful, -.Fn pthread_sigmask -returns 0. -Otherwise, an error is returned. -.Sh ERRORS -.Fn pthread_sigmask -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -.Fa how -is not one of the defined values. -.El -.Sh SEE ALSO -.Xr sigaction 2 , -.Xr sigpending 2 , -.Xr sigprocmask 2 , -.Xr sigsuspend 2 , -.Xr sigsetops 3 , -.Xr pthreads 3 -.Sh STANDARDS -.Fn pthread_sigmask -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/pthread_single_np.3 b/lib/libc_r/man/pthread_single_np.3 deleted file mode 100644 index 80f6ff8b4c0..00000000000 --- a/lib/libc_r/man/pthread_single_np.3 +++ /dev/null @@ -1,41 +0,0 @@ -.\" $OpenBSD: pthread_single_np.3,v 1.3 1999/07/09 13:35:25 aaron Exp $ -.\" David Leonard <d@openbsd.org>, 1999. Public domain. -.Dd March 21, 1999 -.Dt PTHREAD_SINGLE_NP 3 -.Os -.Sh NAME -.Nm pthread_single_np , -.Nm pthread_multi_np -.Nd switch thread scheduling mode -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Fd #include <pthread_np.h> -.Ft int -.Fn pthread_single_np void -.Ft int -.Fn pthread_multi_np void -.Sh DESCRIPTION -The -.Fn pthread_single_np -function causes the process to -enter single-threaded (non-POSIX) scheduling mode. -.Pp -The -.Fn pthread_multi_np -function causes the process to -return to multi-threaded scheduling mode. -.Sh RETURN VALUES -The -.Fn pthread_single_np -and -.Fn pthread_multi_np -functions return zero on success, or an error number on failure. -.Sh SEE ALSO -.Xr pthreads 3 -.Sh STANDARDS -The -.Fn pthread_single_np -and -.Fn pthread_multi_np -functions are non-portable and may not be supported with the above -semantics on other POSIX systems. diff --git a/lib/libc_r/man/pthread_suspend_np.3 b/lib/libc_r/man/pthread_suspend_np.3 deleted file mode 100644 index a43b259e584..00000000000 --- a/lib/libc_r/man/pthread_suspend_np.3 +++ /dev/null @@ -1,52 +0,0 @@ -.\" $OpenBSD: pthread_suspend_np.3,v 1.2 1999/07/07 10:50:05 aaron Exp $ -.\" David Leonard <d@openbsd.org>, 1999. Public domain. -.Dd March 21, 1999 -.Dt PTHREAD_SUSPEND_NP 3 -.Os -.Sh NAME -.Nm pthread_suspend_np , -.Nm pthread_resume_np -.Nd suspend and resume a thread -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Fd #include <pthread_np.h> -.Ft int -.Fn pthread_suspend_np "pthread_t thread" -.Ft int -.Fn pthread_resume_np "pthread_t thread" -.Sh DESCRIPTION -The -.Fn pthread_suspend_np -function interrupts the given thread and places it in a suspended state. -.Pp -The -.Fn pthread_resume_np -function resumes a thread suspended with -.Fn pthread_suspend_np . -It has no effect on threads that have not been suspended. -.Pp -Suspending and resuming a thread has an effect similar to that of -receiving a signal, -namely that resumed system calls will return an error value of -.Er EINTR . -.Sh RETURN VALUES -The -.Fn pthread_suspend_np -and -.Fn pthread_resume_np -functions fail if: -.Bl -tag -width Er -.It Bq Er ESRCH -No thread could be found corresponding to that specified by the given -thread ID. -.El -.Sh SEE ALSO -.Xr pthread_cancel 3 , -.Xr pthreads 3 -.Sh STANDARDS -The -.Fn pthread_suspend_np -and -.Fn pthread_resume_np -functions are non-portable and may not be supported with the above -semantics on other POSIX systems. diff --git a/lib/libc_r/man/pthread_testcancel.3 b/lib/libc_r/man/pthread_testcancel.3 deleted file mode 100644 index cd0fcd6933e..00000000000 --- a/lib/libc_r/man/pthread_testcancel.3 +++ /dev/null @@ -1,196 +0,0 @@ -.\" $OpenBSD: pthread_testcancel.3,v 1.9 2002/05/01 08:03:30 mpech Exp $ -.\" -.Dd January 17, 1999 -.Dt PTHREAD_TESTCANCEL 3 -.Os -.Sh NAME -.Nm pthread_setcancelstate , -.Nm pthread_setcanceltype , -.Nm pthread_testcancel -.Nd set cancelability state -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_setcancelstate "int state" "int *oldstate" -.Ft int -.Fn pthread_setcanceltype "int type" "int *oldtype" -.Ft void -.Fn pthread_testcancel "void" -.Sh DESCRIPTION -The -.Fn pthread_setcancelstate -function atomically both sets the calling thread's cancelability state -to the indicated -.Fa state -and, if -.Fa oldstate -is not -.Dv NULL , -returns the previous cancelability state at the location referenced by -.Fa oldstate . -Legal values for -.Fa state -are -.Dv PTHREAD_CANCEL_ENABLE -and -.Dv PTHREAD_CANCEL_DISABLE . -.Pp -The -.Fn pthread_setcanceltype -function atomically both sets the calling thread's cancelability type -to the indicated -.Fa type -and, if -.Fa oldtype -is not -.Dv NULL , -returns the previous cancelability type at the location referenced by -.Fa oldtype . -Legal values for -.Fa type -are -.Dv PTHREAD_CANCEL_DEFERRED -and -.Dv PTHREAD_CANCEL_ASYNCHRONOUS . -.Pp -The cancelability state and type of any newly created threads, including the -thread in which -.Fn main -was first invoked, are -.Dv PTHREAD_CANCEL_ENABLE -and -.Dv PTHREAD_CANCEL_DEFERRED -respectively. -.Pp -The -.Fn pthread_testcancel -function creates a cancellation point in the calling thread. -The -.Fn pthread_testcancel -function has no effect if cancelability is disabled. -.Ss Cancelability States -The cancelability state of a thread determines the action taken upon -receipt of a cancellation request. -The thread may control cancellation in a number of ways. -.Pp -Each thread maintains its own -.Dq cancelability state -which may be encoded in two bits: -.Bl -hang -.It Em Cancelability Enable -When cancelability is -.Dv PTHREAD_CANCEL_DISABLE , -cancellation requests against the target thread are held pending. -.It Em Cancelability Type -When cancelability is enabled and the cancelability type is -.Dv PTHREAD_CANCEL_ASYNCHRONOUS , -new or pending cancellation requests may be acted upon at any time. -When cancelability is enabled and the cancelability type is -.Dv PTHREAD_CANCEL_DEFERRED , -cancellation requests are held pending until a cancellation point (see -below) is reached. -If cancelability is disabled, the setting of the -cancelability type has no immediate effect as all cancellation requests -are held pending; however, once cancelability is enabled again the new -type will be in effect. -.El -.Ss Cancellation Points -Cancellation points will occur when a thread is executing the following -functions: -.Fn close , -.Fn creat , -.Fn fcntl , -.Fn fsync , -.Fn msync , -.Fn nanosleep , -.Fn open , -.Fn pause , -.Fn pthread_cond_timedwait , -.Fn pthread_cond_wait , -.Fn pthread_join , -.Fn pthread_testcancel , -.Fn read , -.Fn sigwaitinfo , -.Fn sigsuspend , -.Fn sigwait , -.Fn sleep , -.Fn system , -.Fn tcdrain , -.Fn wait , -.Fn waitpid , -.Fn write . -.Sh RETURN VALUES -If successful, the -.Fn pthread_setcancelstate -and -.Fn pthread_setcanceltype -functions will return zero. -Otherwise, an error number shall be returned to indicate the error. -.Pp -The -.Fn pthread_setcancelstate -and -.Fn pthread_setcanceltype -functions are used to control the points at which a thread may be -asynchronously cancelled. -For cancellation control to be usable in modular -fashion, some rules must be followed. -.Pp -For purposes of this discussion, consider an object to be a generalization -of a procedure. It is a set of procedures and global variables written as -a unit and called by clients not known by the object. -Objects may depend on other objects. -.Pp -First, cancelability should only be disabled on entry to an object, never -explicitly enabled. -On exit from an object, the cancelability state should -always be restored to its value on entry to the object. -.Pp -This follows from a modularity argument: if the client of an object (or the -client of an object that uses that object) has disabled cancelability, it is -because the client doesn't want to have to worry about how to clean up if the -thread is cancelled while executing some sequence of actions. -If an object -is called in such a state and it enables cancelability and a cancellation -request is pending for that thread, then the thread will be cancelled, -contrary to the wish of the client that disabled. -.Pp -Second, the cancelability type may be explicitly set to either -.Em deferred -or -.Em asynchronous -upon entry to an object. -But as with the cancelability state, on exit from -an object that cancelability type should always be restored to its value on -entry to the object. -.Pp -Finally, only functions that are cancel-safe may be called from a thread that -is asynchronously cancelable. -.Sh ERRORS -The function -.Fn pthread_setcancelstate -may fail with: -.Bl -tag -width Er -.It Bq Er EINVAL -The specified state is not -.Dv PTHREAD_CANCEL_ENABLE -or -.Dv PTHREAD_CANCEL_DISABLE . -.El -.Pp -The function -.Fn pthread_setcanceltype -may fail with: -.Bl -tag -width Er -.It Bq Er EINVAL -The specified state is not -.Dv PTHREAD_CANCEL_DEFERRED -or -.Dv PTHREAD_CANCEL_ASYNCHRONOUS . -.El -.Sh SEE ALSO -.Xr pthread_cancel 3 -.Sh STANDARDS -.Fn pthread_testcancel -conforms to -.St -p1003.1-96 diff --git a/lib/libc_r/man/pthreads.3 b/lib/libc_r/man/pthreads.3 deleted file mode 100644 index daa8cd929a8..00000000000 --- a/lib/libc_r/man/pthreads.3 +++ /dev/null @@ -1,257 +0,0 @@ -.\" $OpenBSD: pthreads.3,v 1.18 2002/05/01 08:03:30 mpech Exp $ -.\" David Leonard <d@openbsd.org>, 1998. Public domain. -.Dd August 17, 1998 -.Dt PTHREADS 3 -.Os -.Sh NAME -.Nm pthreads -.Nd POSIX 1003.1c thread interface -.Sh DESCRIPTION -A thread is a flow of control within a process. -Each thread represents a minimal amount of state; -normally just the cpu state and a signal mask. -All other process state (such as memory, file descriptors) -is shared among all of the threads in the process. -.Pp -In -.Ox , -threads are implemented in a user-level library. -A program using these routines must be linked with the -.Fl pthread -option. -.Pp -The -.Dv SIGINFO -signal can be sent to a threaded process to have the library show the state of -all of its threads. -The information is sent to the process' -controlling tty and describes each thread's -ID, -state (see -.Sx Thread states ) , -current priority, -flags (see -.Sx Thread flags ) , -signal mask, and name (as set by -.Xr pthread_set_name_np 3 ) . -If the environment variable -.Ev PTHREAD_DEBUG -is defined additional information is displayed. -.Ss Thread states -Threads can be in one of these states: -.Bl -tag -offset indent -width Dv -compact -.It cond_wait -Executing -.Xr pthread_cond_wait 3 -or -.Xr pthread_cond_timedwait 3 . -.It dead -Waiting for resource deallocation by the thread garbage collector. -.It deadlock -Waiting for a resource held by the thread itself. -.It fdlr_wait -File descriptor read lock wait. -.It fdlw_wait -File descriptor write lock wait. -.It fdr_wait -Executing one of -.Xr accept 2 , -.Xr read 2 , -.Xr readv 2 , -.Xr recvfrom 2 , -.Xr recvmsg 2 . -.It fdw_wait -Executing one of -.Xr connect 2 , -.Xr sendmsg 2 , -.Xr sendto 2 , -.Xr write 2 , -.Xr writev 2 . -.It file_wait -Executing -.Xr flockfile 3 -or similar. -.It join -Executing -.Xr pthread_join 3 . -.It mutex_wait -Executing -.Xr pthread_mutex_lock 3 . -.It poll_wait -Executing -.Xr poll 2 . -.It running -Scheduled for, or engaged in, program execution. -.It select_wait -Executing -.Xr select 2 . -.It sigsuspend -Executing -.Xr sigsuspend 2 . -.It sigwait -Executing -.Xr sigwait 3 . -.It sleep_wait -Executing -.Xr sleep 3 -or -.Xr nanosleep 2 . -.It spinblock -Waiting for a machine-level atomic lock. -.It suspended -Suspended with -.Xr pthread_suspend_np 3 . -.It wait_wait -Executing -.Xr wait4 2 -or similar. -.El -.Ss Thread flags -The first three flags are one of: -.Bl -tag -offset indent -width 3en -compact -.It "p" -Private, system thread (e.g., the garbage collector). -.It "E, C, or c" -Thread is exiting (E), has a cancellation pending (C) (see -.Xr pthread_cancel 3 ) , -or is at a cancellation point (c). -.It "t" -Thread is being traced. -.El -The next 7 flags refer to thread attributes: -.Bl -tag -offset indent -width 3en -compact -.It "C" -Thread is in the -.Dv CONDQ . -.It "R" -Thread is in the -.Dv WORKQ . -.It "W" -Thread is in the -.Dv WAITQ . -.It "P" -Thread is in the -.Dv PRIOQ . -.It "d" -Thread has been detached (see -.Xr pthread_detach 3 ) . -.It "i" -Thread inherits scheduler properties. -.It "f" -Thread will save floating point context. -.El -.Ss Scheduling algorithm -The scheduling algorithm used by the user-level thread library is -roughly as follows: -.Bl -enum -compact -.It -Threads each have a time slice credit which is debited -by the actual time the thread spends in running. -Freshly scheduled threads are given a time slice credit of 100000 usec. -.It -Give an incremental priority update to run-enabled threads that -have not run since the last time that an incremental priority update -was given to them. -.It -Choose the next run-enabled thread with the highest priority, -that became inactive least recently, and has -the largest remaining time slice. -.El -.Pp -When all threads are blocked, the process also blocks. -When there are no threads remaining, -the process terminates with an exit code of zero. -.Ss Thread stacks -Each thread has (or should have) a different stack, whether it be provided by a -user attribute, or provided automatically by the system. -If a thread overflows its stack, unpredictable results may occur. -System-allocated stacks (including that of the initial thread) -are typically allocated in such a way that a -.Dv SIGSEGV -signal is delivered to the process when a stack overflows. -.Pp -Signals handlers are normally run on the stack of the currently executing -thread. -Hence, if you want to handle the -.Dv SIGSEGV -signal, you should make use of -.Xr sigaltstack 2 -or -.Xr sigprocmask 2 . -.Sh ENVIRONMENT -.Bl -tag -width "PTHREAD_DEBUG" -.It Ev PTHREAD_DEBUG -Enables verbose -.Dv SIGINFO -signal output. -.It Ev LIBC_R_DEBUG -Display thread status every time the garbage collection thread runs, -approximately once every 10 seconds. -The status display verbosity is controled by the -.Ev PTHREAD_DEBUG -environment variable. -.El -.Sh SEE ALSO -.Xr pthread_cleanup_pop 3 , -.Xr pthread_cleanup_push 3 , -.Xr pthread_cond_broadcast 3 , -.Xr pthread_cond_destroy 3 , -.Xr pthread_cond_init 3 , -.Xr pthread_cond_signal 3 , -.Xr pthread_cond_timedwait 3 , -.Xr pthread_cond_wait 3 , -.Xr pthread_create 3 , -.Xr pthread_detach 3 , -.Xr pthread_equal 3 , -.Xr pthread_exit 3 , -.Xr pthread_getspecific 3 , -.Xr pthread_join 3 , -.Xr pthread_key_create 3 , -.Xr pthread_key_delete 3 , -.Xr pthread_kill 3 , -.Xr pthread_mutex_destroy 3 , -.Xr pthread_mutex_init 3 , -.Xr pthread_mutex_lock 3 , -.Xr pthread_mutex_trylock 3 , -.Xr pthread_mutex_unlock 3 , -.Xr pthread_once 3 , -.Xr pthread_rwlock_destroy 3 , -.Xr pthread_rwlock_init 3 , -.Xr pthread_rwlock_rdlock 3 , -.Xr pthread_rwlock_unlock 3 , -.Xr pthread_rwlock_wrlock 3 , -.Xr pthread_rwlockattr_destroy 3 , -.Xr pthread_rwlockattr_getpshared 3 , -.Xr pthread_rwlockattr_init 3 , -.Xr pthread_rwlockattr_setpshared 3 , -.Xr pthread_self 3 , -.Xr pthread_setspecific 3 -.Sh STANDARDS -The user-level thread library provides functions that -conform to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. -.Sh AUTHORS -John Birrell -.Pa ( jb@freebsd.org ) -wrote the majority of the user level thread library. -.\" David Leonard did a fair bit too, but is far too modest. -.Sh BUGS -The library contains a scheduler that uses the -process virtual interval timer to pre-empt running threads. -This means that using -.Xr setitimer 2 -to alter the process virtual timer will have undefined effects. -The -.Dv SIGVTALRM -will never be delivered to threads in a process. -.Pp -Some pthread functions fail to work correctly when linked using the -.Fl g -option to -.Xr cc 1 -or -.Xr gcc 1 . -The problems do not occur when linked using the -.Fl ggdb -option. diff --git a/lib/libc_r/man/putc_unlocked.3 b/lib/libc_r/man/putc_unlocked.3 deleted file mode 100644 index afae2b033a2..00000000000 --- a/lib/libc_r/man/putc_unlocked.3 +++ /dev/null @@ -1,47 +0,0 @@ -.\" $OpenBSD: putc_unlocked.3,v 1.2 1999/07/07 10:50:05 aaron Exp $ -.\" David Leonard <d@openbsd.org>, 1998. Public domain. -.Dd March 20, 1999 -.Dt PUTC_UNLOCKED 3 -.Os -.Sh NAME -.Nm putc_unlocked , -.Nm putchar_unlocked -.Nd put next character from stream, efficiently -.Sh SYNOPSIS -.Fd #include <stdio.h> -.Ft int -.Fn putc_unlocked "int c" "FILE *stream" -.Ft int -.Fn putchar_unlocked "int c" -.Sh DESCRIPTION -The -.Fn putc_unlocked -and -.Fn putchar_unlocked -functions are equivalent to their locked counterparts, -.Xr putc 3 -and -.Xr putchar 3 . -However, -.Fn putc_unlocked -and -.Fn putchar_unlocked -assume that the relevant stream has either been previous locked -with -.Xr flockfile 3 , -or that it will not be accessed by any other thread. -.Sh RETURN VALUES -The return values are as described for -.Xr putc 3 -and -.Xr putchar 3 . -.Sh SEE ALSO -.Xr putc 3 , -.Xr putchar 3 -.Sh STANDARDS -.Fn putc_unlocked -and -.Fn putchar_unlocked -conform to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libc_r/man/sem_destroy.3 b/lib/libc_r/man/sem_destroy.3 deleted file mode 100644 index 692ed5a23b8..00000000000 --- a/lib/libc_r/man/sem_destroy.3 +++ /dev/null @@ -1,81 +0,0 @@ -.\" $OpenBSD: sem_destroy.3,v 1.2 2002/02/20 05:29:37 fgsch Exp $ -.\" -.\" Copyright (C) 2000 Jason Evans <jasone@FreeBSD.org>. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice(s), this list of conditions and the following disclaimer as -.\" the first lines of this file unmodified other than the possible -.\" addition of one or more copyright notices. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice(s), this list of conditions and the following disclaimer in -.\" the documentation and/or other materials provided with the -.\" distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD: src/lib/libc_r/man/sem_destroy.3,v 1.9 2001/10/01 16:09:09 ru Exp $ -.Dd February 15, 2000 -.Dt SEM_DESTROY 3 -.Os -.Sh NAME -.Nm sem_destroy -.Nd destroy an unnamed semaphore -.Sh SYNOPSIS -.Fd #include <semaphore.h> -.Ft int -.Fn sem_destroy "sem_t *sem" -.Sh DESCRIPTION -The -.Fn sem_destroy -function destroys the unnamed semaphore pointed to by -.Fa sem . -After a successful call to -.Fn sem_destroy , -.Fa sem -is unuseable until re-initialized by another call to -.Fn sem_init . -.Sh RETURN VALUES -.Rv -std sem_destroy -.Sh ERRORS -.Fn sem_destroy -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -.Fa sem -points to an invalid semaphore. -.It Bq Er EBUSY -There are currently threads blocked on the semaphore that -.Fa sem -points to. -.El -.Sh SEE ALSO -.Xr sem_init 3 -.Sh STANDARDS -.Fn sem_destroy -conforms to -.St -p1003.1-96 . -.Pp -POSIX does not define the behavior of -.Fn sem_destroy -if called while there are threads blocked on -.Fa sem , -but this implementation is guaranteed to return -1 and set -.Va errno -to -.Er EBUSY -if there are threads blocked on -.Fa sem . diff --git a/lib/libc_r/man/sem_getvalue.3 b/lib/libc_r/man/sem_getvalue.3 deleted file mode 100644 index 25a109102d3..00000000000 --- a/lib/libc_r/man/sem_getvalue.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" $OpenBSD: sem_getvalue.3,v 1.3 2002/05/01 08:03:30 mpech Exp $ -.\" -.\" Copyright (C) 2000 Jason Evans <jasone@FreeBSD.org>. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice(s), this list of conditions and the following disclaimer as -.\" the first lines of this file unmodified other than the possible -.\" addition of one or more copyright notices. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice(s), this list of conditions and the following disclaimer in -.\" the documentation and/or other materials provided with the -.\" distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD: src/lib/libc_r/man/sem_getvalue.3,v 1.9 2001/10/01 16:09:09 ru Exp $ -.Dd February 15, 2000 -.Dt SEM_GETVALUE 3 -.Os -.Sh NAME -.Nm sem_getvalue -.Nd get the value of a semaphore -.Sh SYNOPSIS -.Fd #include <semaphore.h> -.Ft int -.Fn sem_getvalue "sem_t *sem" "int *sval" -.Sh DESCRIPTION -The -.Fn sem_getvalue -function sets the variable pointed to by -.Fa sval -to the current value of the semaphore pointed to by -.Fa sem , -as of the time that the call to -.Fn sem_getvalue -is actually run. -.Sh RETURN VALUES -.Rv -std sem_getvalue -.Sh ERRORS -.Fn sem_getvalue -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -.Fa sem -points to an invalid semaphore. -.El -.Sh SEE ALSO -.Xr sem_post 3 , -.Xr sem_trywait 3 , -.Xr sem_wait 3 -.Sh STANDARDS -.Fn sem_getvalue -conforms to -.St -p1003.1-96 . -.Pp -The value of the semaphore is never negative, even if there are threads blocked -on the semaphore. -POSIX is somewhat ambiguous in its wording with regard to -what the value of the semaphore should be if there are blocked waiting threads, -but this behavior is conformant, given the wording of the specification. diff --git a/lib/libc_r/man/sem_init.3 b/lib/libc_r/man/sem_init.3 deleted file mode 100644 index 4e301c0b2e6..00000000000 --- a/lib/libc_r/man/sem_init.3 +++ /dev/null @@ -1,98 +0,0 @@ -.\" $OpenBSD: sem_init.3,v 1.2 2002/02/20 05:29:37 fgsch Exp $ -.\" -.\" Copyright (C) 2000 Jason Evans <jasone@FreeBSD.org>. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice(s), this list of conditions and the following disclaimer as -.\" the first lines of this file unmodified other than the possible -.\" addition of one or more copyright notices. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice(s), this list of conditions and the following disclaimer in -.\" the documentation and/or other materials provided with the -.\" distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD: src/lib/libc_r/man/sem_init.3,v 1.11 2001/10/01 16:09:09 ru Exp $ -.Dd February 15, 2000 -.Dt SEM_INIT 3 -.Os -.Sh NAME -.Nm sem_init -.Nd initialize an unnamed semaphore -.Sh SYNOPSIS -.Fd #include <semaphore.h> -.Ft int -.Fn sem_init "sem_t *sem" "int pshared" "unsigned int value" -.Sh DESCRIPTION -The -.Fn sem_init -function initializes the unnamed semaphore pointed to by -.Fa sem -to have the value -.Fa value . -A non-zero value for -.Fa pshared -specifies a shared semaphore that can be used by multiple processes, which this -implementation is not capable of. -.Pp -Following a successful call to -.Fn sem_init , -.Fa sem -can be used as an argument in subsequent calls to -.Fa sem_wait , -.Fa sem_trywait , -.Fa sem_post , -and -.Fa sem_destroy . -.Fa sem -is no longer valid after a successful call to -.Fa sem_destroy . -.Sh RETURN VALUES -.Rv -std sem_init -.Sh ERRORS -.Fn sem_init -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -.Fa value -exceeds SEM_VALUE_MAX. -.It Bq Er ENOSPC -Memory allocation error. -.It Bq Er EPERM -Unable to initialize a shared semaphore. -.El -.Sh SEE ALSO -.Xr sem_destroy 3 , -.Xr sem_post 3 , -.Xr sem_trywait 3 , -.Xr sem_wait 3 -.Sh STANDARDS -.Fn sem_init -conforms to -.St -p1003.1-96 . -.Pp -This implementation does not support shared semaphores, and reports this fact -by setting -.Va errno -to -.Er EPERM . -This is perhaps a stretch of the intention of POSIX, but is -compliant, with the caveat that -.Fn sem_init -always reports a permissions error when an attempt to create a shared semaphore -is made. diff --git a/lib/libc_r/man/sem_open.3 b/lib/libc_r/man/sem_open.3 deleted file mode 100644 index 07c40f6fc1d..00000000000 --- a/lib/libc_r/man/sem_open.3 +++ /dev/null @@ -1,81 +0,0 @@ -.\" $OpenBSD: sem_open.3,v 1.2 2002/02/20 05:29:37 fgsch Exp $ -.\" -.\" Copyright (C) 2000 Jason Evans <jasone@FreeBSD.org>. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice(s), this list of conditions and the following disclaimer as -.\" the first lines of this file unmodified other than the possible -.\" addition of one or more copyright notices. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice(s), this list of conditions and the following disclaimer in -.\" the documentation and/or other materials provided with the -.\" distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD: src/lib/libc_r/man/sem_open.3,v 1.7 2001/10/01 16:09:09 ru Exp $ -.Dd February 15, 2000 -.Dt SEM_OPEN 3 -.Os -.Sh NAME -.Nm sem_open , -.Nm sem_close , -.Nm sem_unlink -.Nd named semaphore operations -.Sh SYNOPSIS -.Fd #include <semaphore.h> -.Ft sem_t * -.Fn sem_open "const char *name" "int oflag" "..." -.Ft int -.Fn sem_close "sem_t *sem" -.Ft int -.Fn sem_unlink "const char *name" -.Sh DESCRIPTION -The -.Fn sem_open , -.Fn sem_close , -and -.Fn sem_unlink -functions are not supported by this implementation. -.Sh RETURN VALUES -.Fn sem_open -returns SEM_FAILED and sets -.Va errno -to indicate an error. -.Fn sem_close -and -.Fn sem_unlink -return -1 and set -.Va errno -to indicate an error. -.Sh ERRORS -.Fn sem_open , -.Fn sem_close , -and -.Fn sem_unlink -will fail: -.Bl -tag -width Er -.It Bq Er ENOSYS -Function not supported by this implementation. -.El -.Sh STANDARDS -.Fn sem_open , -.Fn sem_close , -and -.Fn sem_unlink -conform to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/sem_post.3 b/lib/libc_r/man/sem_post.3 deleted file mode 100644 index ddba637243a..00000000000 --- a/lib/libc_r/man/sem_post.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" $OpenBSD: sem_post.3,v 1.2 2002/02/20 05:29:37 fgsch Exp $ -.\" -.\" Copyright (C) 2000 Jason Evans <jasone@FreeBSD.org>. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice(s), this list of conditions and the following disclaimer as -.\" the first lines of this file unmodified other than the possible -.\" addition of one or more copyright notices. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice(s), this list of conditions and the following disclaimer in -.\" the documentation and/or other materials provided with the -.\" distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD: src/lib/libc_r/man/sem_post.3,v 1.10 2001/10/01 16:09:09 ru Exp $ -.Dd February 15, 2000 -.Dt SEM_POST 3 -.Os -.Sh NAME -.Nm sem_post -.Nd increment (unlock) a semaphore -.Sh SYNOPSIS -.Fd #include <semaphore.h> -.Ft int -.Fn sem_post "sem_t *sem" -.Sh DESCRIPTION -The -.Fn sem_post -function increments (unlocks) the semaphore pointed to by -.Fa sem . -If there are threads blocked on the semaphore when -.Fn sem_post -is called, then the highest priority thread that has been blocked the longest on -the semaphore will be allowed to return from -.Fn sem_wait . -.Pp -.Fn sem_post -is signal-reentrant and may be called within signal handlers. -.Sh RETURN VALUES -.Rv -std sem_post -.Sh ERRORS -.Fn sem_post -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -.Fa sem -points to an invalid semaphore. -.El -.Sh SEE ALSO -.Xr sem_trywait 3 , -.Xr sem_wait 3 -.Sh STANDARDS -.Fn sem_post -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/sem_wait.3 b/lib/libc_r/man/sem_wait.3 deleted file mode 100644 index 00d5a2fe4f3..00000000000 --- a/lib/libc_r/man/sem_wait.3 +++ /dev/null @@ -1,87 +0,0 @@ -.\" $OpenBSD: sem_wait.3,v 1.4 2002/05/01 08:03:30 mpech Exp $ -.\" -.\" Copyright (C) 2000 Jason Evans <jasone@FreeBSD.org>. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice(s), this list of conditions and the following disclaimer as -.\" the first lines of this file unmodified other than the possible -.\" addition of one or more copyright notices. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice(s), this list of conditions and the following disclaimer in -.\" the documentation and/or other materials provided with the -.\" distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD: src/lib/libc_r/man/sem_wait.3,v 1.8 2001/10/01 16:09:09 ru Exp $ -.Dd February 15, 2000 -.Dt SEM_WAIT 3 -.Os -.Sh NAME -.Nm sem_wait , -.Nm sem_trywait -.Nd decrement (lock) a semaphore -.Sh SYNOPSIS -.Fd #include <semaphore.h> -.Ft int -.Fn sem_wait "sem_t *sem" -.Ft int -.Fn sem_trywait "sem_t *sem" -.Sh DESCRIPTION -The -.Fn sem_wait -function decrements (locks) the semaphore pointed to by -.Fa sem , -but blocks if the value of -.Fa sem -is zero, until the value is non-zero and the value can be decremented. -.Pp -The -.Fn sem_trywait -function decrements (locks) the semaphore pointed to by -.Fa sem -only if the value is non-zero. -Otherwise, the semaphore is not decremented and -an error is returned. -.Sh RETURN VALUES -.Rv -std sem_wait -.Sh ERRORS -.Fn sem_wait -and -.Fn sem_trywait -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -.Fa sem -points to an invalid semaphore. -.El -.Pp -Additionally, -.Fn sem_trywait -will fail if: -.Bl -tag -width Er -.It Bq Er EAGAIN -The semaphore value was zero, and thus could not be decremented. -.El -.Sh SEE ALSO -.Xr sem_post 3 -.Sh STANDARDS -.Fn sem_wait -and -.Fn sem_trywait -conform to -.St -p1003.1-96 . diff --git a/lib/libc_r/man/sigwait.3 b/lib/libc_r/man/sigwait.3 deleted file mode 100644 index 56f7576c4a2..00000000000 --- a/lib/libc_r/man/sigwait.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" $OpenBSD: sigwait.3,v 1.11 2002/04/30 16:31:42 mpech Exp $ -.\" -.\" David Leonard <d@openbsd.org>, 1998. Public domain. -.Dd August 20, 1998 -.Dt SIGWAIT 3 -.Os -.Sh NAME -.Nm sigwait -.Nd synchronously accept a signal -.Sh SYNOPSIS -.Fd #include <signal.h> -.Ft int -.Fn sigwait "const sigset_t *set" "int *sig" -.Sh DESCRIPTION -The -.Fn sigwait -function selects a pending signal from -.Fa set , -atomically clears it from the system's set of pending signals, and returns -that signal number in the location referenced by -.Fa sig . -If prior to the call to -.Fn sigwait -there are multiple pending instances of a single signal number, -it is undefined whether upon successful return there are any remaining pending -signals for that signal number. -If no signal in -.Fa set -is pending at the time of the call, -the thread shall be suspended until one or more becomes pending. -The signals defined by -.Fa set -should have been blocked at the time of the call to -.Fn sigwait ; -otherwise the behaviour is undefined. -The effect of -.Fn sigwait -on the signal actions for the signals in -.Fa set -is unspecified. -.Pp -If more than one thread is using -.Fn sigwait -to wait for the same signal, -no more than one of these threads shall return from -.Fn sigwait -with the signal number. -Which thread returns from -.Fn sigwait -if more than a single thread is waiting is unspecified. -.Sh RETURN VALUES -Upon successful completion, -.Fn sigwait -stores the signal number of the received signal at the location referenced by -.Fa sig -and returns zero. -.Sh ERRORS -On error, -.Fn sigwait -returns one of these error values: -.Bl -tag -width Er -.It Bq Er EINVAL -The -.Fa set -argument contains an invalid or unsupported signal number -.El -.Sh SEE ALSO -.Xr sigaction 2 , -.Xr sigpending 2 , -.Xr sigsuspend 2 , -.Xr pause 3 , -.Xr pthread_sigmask 3 , -.Xr pthreads 3 -.Sh STANDARDS -.Fn sigwait -conforms to -.St -p1003.1-96 . diff --git a/lib/libc_r/shlib_version b/lib/libc_r/shlib_version deleted file mode 100644 index 5b844bbf422..00000000000 --- a/lib/libc_r/shlib_version +++ /dev/null @@ -1,2 +0,0 @@ -major=7 -minor=0 diff --git a/lib/libc_r/sys/Makefile.inc b/lib/libc_r/sys/Makefile.inc deleted file mode 100644 index aff80e5ba05..00000000000 --- a/lib/libc_r/sys/Makefile.inc +++ /dev/null @@ -1,43 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.9 2002/01/17 04:47:14 fgsch Exp $ - -.PATH: ${LIBC_RSRCDIR}/sys ${LIBC_RSRCDIR}/arch/${MACHINE_ARCH} - -SRCS+= uthread_error.c -SRCS+= _atomic_lock.c slow_atomic_lock.c - -.if exists(${LIBC_RSRCDIR}/arch/${MACHINE_ARCH}/uthread_machdep_asm.S) -SRCS+= uthread_machdep_asm.S -.endif -.if exists(${LIBC_RSRCDIR}/arch/${MACHINE_ARCH}/uthread_machdep.c) -SRCS+= uthread_machdep.c -.endif - -.if (${LIB} == "c_r") && (${ELF_TOOLCHAIN} == "no") - -# -# All syscalls are renamed as _thread_sys_{syscall}. -# This is a list of syscalls that are renamed as _thread_sys_{syscall} -# so that libc_r can provide replacement functions. -# -HIDDEN_SYSCALLS= accept.o bind.o close.o connect.o dup.o dup2.o \ - execve.o fchflags.o fchmod.o fchown.o fcntl.o \ - flock.o fpathconf.o fstat.o fstatfs.o fsync.o getdirentries.o \ - getlogin.o getpeername.o getsockname.o getsockopt.o ioctl.o kevent.o \ - listen.o msync.o nanosleep.o open.o pipe.o poll.o read.o readv.o \ - recvfrom.o recvmsg.o sched_yield.o select.o sendmsg.o sendto.o \ - setsockopt.o shutdown.o sigaction.o sigaltstack.o \ - sigprocmask.o sigsuspend.o \ - socket.o socketpair.o wait4.o write.o writev.o \ - _exit.o - -SRCS+= _sys_aliases.c -CLEANFILES += _sys_aliases.c - -_sys_aliases.c: ${LIBC_RSRCDIR}/Makefile ${LIBCSRCDIR}/sys/Makefile.inc - echo '#include <sys/cdefs.h>' > ${.TARGET} - for fn in ${ASM:R} ${PSEUDO:R} ""; do \ - case $$fn in ${HIDDEN_SYSCALLS:.o=|}"") : stays hidden ;; \ - *) echo "__indr_reference(_thread_sys_$$fn,$$fn);";; \ - esac; \ - done >> ${.TARGET} -.endif diff --git a/lib/libc_r/sys/slow_atomic_lock.c b/lib/libc_r/sys/slow_atomic_lock.c deleted file mode 100644 index 22889ea8691..00000000000 --- a/lib/libc_r/sys/slow_atomic_lock.c +++ /dev/null @@ -1,41 +0,0 @@ -/* $OpenBSD: slow_atomic_lock.c,v 1.3 1998/12/21 07:38:43 d Exp $ */ - -#include <pthread.h> -#include "pthread_private.h" -#include "spinlock.h" -#include <signal.h> - -/* - * uthread atomic lock: - * attempt to acquire a lock (by giving it a non-zero value). - * Return zero on success, or the lock's value on failure - * This uses signal masking to make sure that no other thread - * can modify the lock while processing, hence it is very slow. - */ -int -_thread_slow_atomic_lock(volatile _spinlock_lock_t *lock) -{ - _spinlock_lock_t old; - sigset_t oldset, newset = (sigset_t)~0; - - /* block signals - incurs a context switch */ - if (_thread_sys_sigprocmask(SIG_SETMASK, &newset, &oldset) < 0) - PANIC("_atomic_lock block"); - - old = *lock; - if (old == _SPINLOCK_UNLOCKED) - *lock = _SPINLOCK_LOCKED; - - /* restore signal mask to what it was */ - if (_thread_sys_sigprocmask(SIG_SETMASK, &oldset, NULL) < 0) - PANIC("_atomic_lock restore"); - - return (old != _SPINLOCK_UNLOCKED); -} - -int -_thread_slow_atomic_is_locked(volatile _spinlock_lock_t *lock) -{ - - return (*lock != _SPINLOCK_UNLOCKED); -} diff --git a/lib/libc_r/sys/uthread_error.c b/lib/libc_r/sys/uthread_error.c deleted file mode 100644 index 08740ed92ff..00000000000 --- a/lib/libc_r/sys/uthread_error.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: uthread_error.c,v 1.2 1999/11/25 07:01:30 d Exp $ */ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * Copyright (c) 1994 by Chris Provenzano, proven@mit.edu - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell - * and Chris Provenzano. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_error.c,v 1.2 1999/08/05 12:14:13 deischen Exp $ - */ -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -extern int errno; - -int * __error() -{ - int *p_errno; - if (_thread_run == _thread_initial) { - p_errno = &errno; - } else { - p_errno = &_thread_run->error; - } - return(p_errno); -} -#endif diff --git a/lib/libc_r/thread/Makefile.inc b/lib/libc_r/thread/Makefile.inc deleted file mode 100644 index 7d9e4a17fa7..00000000000 --- a/lib/libc_r/thread/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.4 2002/11/05 22:19:55 marc Exp $ - -.PATH: ${LIBC_RSRCDIR}/thread - -SRCS+= thread_storage.c thread_malloc_lock.c diff --git a/lib/libc_r/thread/thread_malloc_lock.c b/lib/libc_r/thread/thread_malloc_lock.c deleted file mode 100644 index 8755b1dad27..00000000000 --- a/lib/libc_r/thread/thread_malloc_lock.c +++ /dev/null @@ -1,24 +0,0 @@ -/* $OpenBSD: thread_malloc_lock.c,v 1.4 2002/11/05 22:19:55 marc Exp $ */ -/* Public Domain <marc@snafu.org> */ - -#include <pthread.h> -#include "pthread_private.h" - -static spinlock_t malloc_lock = _SPINLOCK_INITIALIZER; - -void -_thread_malloc_lock() -{ - _SPINLOCK(&malloc_lock); -} - -void -_thread_malloc_unlock() -{ - _SPINUNLOCK(&malloc_lock); -} - -void -_thread_malloc_init() -{ -} diff --git a/lib/libc_r/thread/thread_storage.c b/lib/libc_r/thread/thread_storage.c deleted file mode 100644 index 61609f9c277..00000000000 --- a/lib/libc_r/thread/thread_storage.c +++ /dev/null @@ -1,82 +0,0 @@ -/* $OpenBSD: thread_storage.c,v 1.6 2002/11/05 22:19:55 marc Exp $ */ -/* Public Domain */ - -/* - * libpthread's stronger functions - */ - -#include <stdlib.h> -#include <pthread.h> -#include <string.h> -#include "pthread_private.h" - -void -_libc_private_storage_lock(mutex) - pthread_mutex_t *mutex; -{ - if (__isthreaded && pthread_mutex_lock(mutex) != 0) - PANIC("_libc_private_storage_lock"); -} - -void -_libc_private_storage_unlock(mutex) - pthread_mutex_t *mutex; -{ - if (__isthreaded && pthread_mutex_unlock(mutex) != 0) - PANIC("_libc_private_storage_unlock"); -} - -void * -_libc_private_storage(volkey, init, initsz, error) - volatile struct _thread_private_key_struct * volkey; - void * init; - size_t initsz; - void * error; -{ - void *result; - void (*cleanfn)(void *); - struct _thread_private_key_struct * key; - - /* Use static storage while not threaded: */ - if (!__isthreaded) - return init; - - key = (struct _thread_private_key_struct *)volkey; /* for gcc */ - - /* Create the key once: */ - if (volkey->once.state == PTHREAD_NEEDS_INIT) { - if (pthread_mutex_lock(&key->once.mutex) != 0) - return error; - if (volkey->once.state == PTHREAD_NEEDS_INIT) { - if (key->cleanfn == NULL) - cleanfn = free; - else - cleanfn = key->cleanfn; - if (pthread_key_create(&key->key, cleanfn) != 0) { - pthread_mutex_unlock(&key->once.mutex); - return error; - } - key->once.state = PTHREAD_DONE_INIT; - } - pthread_mutex_unlock(&key->once.mutex); - } - - /* XXX signals may cause re-entrancy here? */ - - /* Acquire this key's thread-specific storage: */ - result = pthread_getspecific(key->key); - - /* Allocate and initialise storage if unallocated: */ - if (result == NULL) { - result = malloc(initsz); - if (result == NULL) - return error; - if (pthread_setspecific(key->key, result) != 0) { - free(result); - return error; - } - memcpy(result, init, initsz); - } - - return result; -} diff --git a/lib/libc_r/uthread/Makefile.inc b/lib/libc_r/uthread/Makefile.inc deleted file mode 100644 index b9a005b26fe..00000000000 --- a/lib/libc_r/uthread/Makefile.inc +++ /dev/null @@ -1,126 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.13 2002/01/18 22:07:27 fgsch Exp $ -# $FreeBSD: Makefile.inc,v 1.19 1999/08/28 00:03:19 peter Exp $ - -# uthread sources -.PATH: ${LIBC_RSRCDIR}/uthread - -CFLAGS += -I${LIBC_RSRCDIR}/arch/${MACHINE_ARCH} - -SRCS+= \ - uthread_accept.c \ - uthread_attr_destroy.c \ - uthread_attr_init.c \ - uthread_attr_getdetachstate.c \ - uthread_attr_getinheritsched.c \ - uthread_attr_getschedparam.c \ - uthread_attr_getschedpolicy.c \ - uthread_attr_getscope.c \ - uthread_attr_getstackaddr.c \ - uthread_attr_getstacksize.c \ - uthread_attr_setcreatesuspend_np.c \ - uthread_attr_setdetachstate.c \ - uthread_attr_setinheritsched.c \ - uthread_attr_setschedparam.c \ - uthread_attr_setschedpolicy.c \ - uthread_attr_setscope.c \ - uthread_attr_setstackaddr.c \ - uthread_attr_setstacksize.c \ - uthread_autoinit.c \ - uthread_bind.c \ - uthread_cancel.c \ - uthread_clean.c \ - uthread_close.c \ - uthread_cond.c \ - uthread_condattr_destroy.c \ - uthread_condattr_init.c \ - uthread_connect.c \ - uthread_create.c \ - uthread_detach.c \ - uthread_dup.c \ - uthread_dup2.c \ - uthread_equal.c \ - uthread_execve.c \ - uthread_exit.c \ - uthread_fchflags.c \ - uthread_fchmod.c \ - uthread_fchown.c \ - uthread_fcntl.c \ - uthread_fd.c \ - uthread_file.c \ - uthread_find_thread.c \ - uthread_flock.c \ - uthread_fork.c \ - uthread_fpathconf.c \ - uthread_fstat.c \ - uthread_fstatfs.c \ - uthread_fsync.c \ - uthread_gc.c \ - uthread_getdirentries.c \ - uthread_getpeername.c \ - uthread_getprio.c \ - uthread_getschedparam.c \ - uthread_getsockname.c \ - uthread_getsockopt.c \ - uthread_info_openbsd.c \ - uthread_init.c \ - uthread_ioctl.c \ - uthread_join.c \ - uthread_kern.c \ - uthread_kevent.c \ - uthread_kill.c \ - uthread_listen.c \ - uthread_main_np.c \ - uthread_mattr_init.c \ - uthread_mattr_kind_np.c \ - uthread_msync.c \ - uthread_multi_np.c \ - uthread_mutex.c \ - uthread_mutex_prioceiling.c \ - uthread_mutex_protocol.c \ - uthread_mutexattr_destroy.c \ - uthread_nanosleep.c \ - uthread_once.c \ - uthread_open.c \ - uthread_pipe.c \ - uthread_poll.c \ - uthread_priority_queue.c \ - uthread_read.c \ - uthread_readv.c \ - uthread_recvfrom.c \ - uthread_recvmsg.c \ - uthread_resume_np.c \ - uthread_rwlock.c \ - uthread_rwlockattr.c \ - uthread_select.c \ - uthread_self.c \ - uthread_sem.c \ - uthread_sendmsg.c \ - uthread_sendto.c \ - uthread_seterrno.c \ - uthread_setprio.c \ - uthread_setschedparam.c \ - uthread_setsockopt.c \ - uthread_shutdown.c \ - uthread_sig.c \ - uthread_sigaction.c \ - uthread_sigaltstack.c \ - uthread_sigblock.c \ - uthread_sigmask.c \ - uthread_sigpending.c \ - uthread_sigprocmask.c \ - uthread_sigsetmask.c \ - uthread_sigsuspend.c \ - uthread_sigwait.c \ - uthread_single_np.c \ - uthread_socket.c \ - uthread_socketpair.c \ - uthread_spec.c \ - uthread_spinlock.c \ - uthread_stack.c \ - uthread_suspend_np.c \ - uthread_switch_np.c \ - uthread_vfork.c \ - uthread_wait4.c \ - uthread_write.c \ - uthread_writev.c \ - uthread_yield.c diff --git a/lib/libc_r/uthread/pthread_private.h b/lib/libc_r/uthread/pthread_private.h deleted file mode 100644 index 83389b6008b..00000000000 --- a/lib/libc_r/uthread/pthread_private.h +++ /dev/null @@ -1,1322 +0,0 @@ -/* $OpenBSD: pthread_private.h,v 1.40 2002/12/11 23:21:19 marc Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * Private thread definitions for the uthread kernel. - * - * $FreeBSD: pthread_private.h,v 1.27 1999/09/29 15:18:38 marcel Exp $ - */ - -#ifndef _PTHREAD_PRIVATE_H -#define _PTHREAD_PRIVATE_H - -/* - * Evaluate the storage class specifier. - */ -#ifdef GLOBAL_PTHREAD_PRIVATE -#define SCLASS -#else -#define SCLASS extern -#endif - -/* - * Include files. - */ -#include <signal.h> -#include <stdio.h> -#include <sys/queue.h> -#include <sys/types.h> -#include <sys/time.h> -#include <sched.h> -#include <spinlock.h> -#include <pthread_np.h> -#include "thread_private.h" -#include "uthread_machdep.h" - -/* - * Workaround until we have ENOTSUP in errno.h - */ -#define ENOTSUP EOPNOTSUPP - -/* - * Kernel fatal error handler macro. - */ -#define PANIC(string) _thread_exit(__FILE__,__LINE__,string) - -/* Output debug messages like this: */ -#define stdout_debug(_x) _thread_sys_write(1,_x,strlen(_x)); -#define stderr_debug(_x) _thread_sys_write(2,_x,strlen(_x)); - - -/* - * Priority queue manipulation macros (using pqe link): - */ -#define PTHREAD_PRIOQ_INSERT_HEAD(thrd) _pq_insert_head(&_readyq,thrd) -#define PTHREAD_PRIOQ_INSERT_TAIL(thrd) _pq_insert_tail(&_readyq,thrd) -#define PTHREAD_PRIOQ_REMOVE(thrd) _pq_remove(&_readyq,thrd) -#define PTHREAD_PRIOQ_FIRST() _pq_first(&_readyq) - -/* - * Waiting queue manipulation macros (using pqe link): - */ -#define PTHREAD_WAITQ_REMOVE(thrd) _waitq_remove(thrd) -#define PTHREAD_WAITQ_INSERT(thrd) _waitq_insert(thrd) - -#if defined(_PTHREADS_INVARIANTS) -#define PTHREAD_WAITQ_CLEARACTIVE() _waitq_clearactive() -#define PTHREAD_WAITQ_SETACTIVE() _waitq_setactive() -#else -#define PTHREAD_WAITQ_CLEARACTIVE() -#define PTHREAD_WAITQ_SETACTIVE() -#endif - -/* - * Work queue manipulation macros (using qe link): - */ -#define PTHREAD_WORKQ_INSERT(thrd) do { \ - TAILQ_INSERT_TAIL(&_workq,thrd,qe); \ - (thrd)->flags |= PTHREAD_FLAGS_IN_WORKQ; \ -} while (0) -#define PTHREAD_WORKQ_REMOVE(thrd) do { \ - TAILQ_REMOVE(&_workq,thrd,qe); \ - (thrd)->flags &= ~PTHREAD_FLAGS_IN_WORKQ; \ -} while (0) - - -/* - * State change macro without scheduling queue change: - */ -#define PTHREAD_SET_STATE(thrd, newstate) do { \ - (thrd)->state = newstate; \ - (thrd)->fname = __FILE__; \ - (thrd)->lineno = __LINE__; \ -} while (0) - -/* - * State change macro with scheduling queue change - This must be - * called with preemption deferred (see thread_kern_sched_[un]defer). - */ -#if defined(_PTHREADS_INVARIANTS) -#include <assert.h> -#define PTHREAD_ASSERT(cond, msg) do { \ - if (!(cond)) \ - PANIC(msg); \ -} while (0) -#define PTHREAD_ASSERT_NOT_IN_SYNCQ(thrd) \ - PTHREAD_ASSERT((((thrd)->flags & PTHREAD_FLAGS_IN_SYNCQ) == 0), \ - "Illegal call from signal handler"); -#define PTHREAD_NEW_STATE(thrd, newstate) do { \ - if (_thread_kern_new_state != 0) \ - PANIC("Recursive PTHREAD_NEW_STATE"); \ - _thread_kern_new_state = 1; \ - if ((thrd)->state != newstate) { \ - if ((thrd)->state == PS_RUNNING) { \ - PTHREAD_PRIOQ_REMOVE(thrd); \ - PTHREAD_WAITQ_INSERT(thrd); \ - } else if (newstate == PS_RUNNING) { \ - PTHREAD_WAITQ_REMOVE(thrd); \ - PTHREAD_PRIOQ_INSERT_TAIL(thrd); \ - } \ - } \ - _thread_kern_new_state = 0; \ - PTHREAD_SET_STATE(thrd, newstate); \ -} while (0) -#else -#define PTHREAD_ASSERT(cond, msg) -#define PTHREAD_ASSERT_NOT_IN_SYNCQ(thrd) -#define PTHREAD_NEW_STATE(thrd, newstate) do { \ - if ((thrd)->state != newstate) { \ - if ((thrd)->state == PS_RUNNING) { \ - PTHREAD_PRIOQ_REMOVE(thrd); \ - PTHREAD_WAITQ_INSERT(thrd); \ - } else if (newstate == PS_RUNNING) { \ - PTHREAD_WAITQ_REMOVE(thrd); \ - PTHREAD_PRIOQ_INSERT_TAIL(thrd); \ - } \ - } \ - PTHREAD_SET_STATE(thrd, newstate); \ -} while (0) -#endif - -/* - * Define the signals to be used for scheduling. - */ -#if defined(_PTHREADS_COMPAT_SCHED) -#define _ITIMER_SCHED_TIMER ITIMER_VIRTUAL -#define _SCHED_SIGNAL SIGVTALRM -#else -#define _ITIMER_SCHED_TIMER ITIMER_PROF -#define _SCHED_SIGNAL SIGPROF -#endif - -/* Lists with volatile elements */ -#define V_TAILQ_HEAD(name, type) \ -volatile struct name { \ - struct type * tqh_first; \ - struct type * volatile * tqh_last; \ -} - -#define V_TAILQ_ENTRY(type) \ -volatile struct { \ - struct type * tqe_next; \ - struct type * volatile * tqe_prev; \ -} - -/* List of all threads: */ -typedef V_TAILQ_HEAD(, pthread) _thread_list_t; - -/* - * Priority queues. - * - * XXX It'd be nice if these were contained in uthread_priority_queue.[ch]. - */ -typedef struct pq_list { - _thread_list_t pl_head; /* list of threads at this priority */ - TAILQ_ENTRY(pq_list) pl_link; /* link for queue of priority lists */ - int pl_prio; /* the priority of this list */ - int pl_queued; /* is this in the priority queue */ -} pq_list_t; - -typedef struct pq_queue { - TAILQ_HEAD(, pq_list) pq_queue; /* queue of priority lists */ - pq_list_t *pq_lists; /* array of all priority lists */ - int pq_size; /* number of priority lists */ -} pq_queue_t; - - -/* - * TailQ initialization values. - */ -#define TAILQ_INITIALIZER { NULL, NULL } - -/* - * Mutex definitions. - */ -union pthread_mutex_data { - void *m_ptr; - int m_count; -}; - -struct pthread_mutex { - enum pthread_mutextype m_type; - int m_protocol; - V_TAILQ_HEAD(mutex_head, pthread) m_queue; - struct pthread *m_owner; - union pthread_mutex_data m_data; - long m_flags; - int m_refcount; - - /* - * Used for priority inheritence and protection. - * - * m_prio - For priority inheritence, the highest active - * priority (threads locking the mutex inherit - * this priority). For priority protection, the - * ceiling priority of this mutex. - * m_saved_prio - mutex owners inherited priority before - * taking the mutex, restored when the owner - * unlocks the mutex. - */ - int m_prio; - int m_saved_prio; - - /* - * Link for list of all mutexes a thread currently owns. - */ - V_TAILQ_ENTRY(pthread_mutex volatile) m_qe; - - /* - * Lock for accesses to this structure. - */ - spinlock_t lock; -}; - -/* - * Flags for mutexes. - */ -#define MUTEX_FLAGS_PRIVATE 0x01 -#define MUTEX_FLAGS_INITED 0x02 -#define MUTEX_FLAGS_BUSY 0x04 - -/* - * Static mutex initialization values. - */ -#define PTHREAD_MUTEX_STATIC_INITIALIZER \ - { PTHREAD_MUTEX_DEFAULT, PTHREAD_PRIO_NONE, TAILQ_INITIALIZER, \ - NULL, { NULL }, MUTEX_FLAGS_PRIVATE, 0, 0, 0, TAILQ_INITIALIZER, \ - _SPINLOCK_INITIALIZER } - -struct pthread_mutex_attr { - enum pthread_mutextype m_type; - int m_protocol; - int m_ceiling; - long m_flags; -}; - -#define PTHREAD_MUTEXATTR_STATIC_INITIALIZER \ - { PTHREAD_MUTEX_DEFAULT, PTHREAD_PRIO_NONE, 0, MUTEX_FLAGS_PRIVATE } - -/* - * Condition variable definitions. - */ -enum pthread_cond_type { - COND_TYPE_FAST, - COND_TYPE_MAX -}; - -struct pthread_cond { - enum pthread_cond_type c_type; - V_TAILQ_HEAD(cond_head, pthread) c_queue; - pthread_mutex_t c_mutex; - long c_flags; - int c_seqno; - - /* - * Lock for accesses to this structure. - */ - spinlock_t lock; -}; - -struct pthread_cond_attr { - enum pthread_cond_type c_type; - long c_flags; -}; - -/* - * Flags for condition variables. - */ -#define COND_FLAGS_PRIVATE 0x01 -#define COND_FLAGS_INITED 0x02 -#define COND_FLAGS_BUSY 0x04 - -/* - * Static cond initialization values. - */ -#define PTHREAD_COND_STATIC_INITIALIZER \ - { COND_TYPE_FAST, TAILQ_INITIALIZER, NULL, NULL, \ - 0, 0, _SPINLOCK_INITIALIZER } - -/* - * Semaphore definitions. - */ -struct sem { -#define SEM_MAGIC ((u_int32_t) 0x09fa4012) - u_int32_t magic; - pthread_mutex_t lock; - pthread_cond_t gtzero; - u_int32_t count; - u_int32_t nwaiters; -}; - -/* - * Cleanup definitions. - */ -struct pthread_cleanup { - struct pthread_cleanup *next; - void (*routine) (); - void *routine_arg; -}; - -struct pthread_attr { - int sched_policy; - int sched_inherit; - int sched_interval; - int prio; - int suspend; - int flags; - void *arg_attr; - void (*cleanup_attr) (); - void *stackaddr_attr; - size_t stacksize_attr; - size_t guardsize_attr; -}; - -/* - * Thread creation state attributes. - */ -#define PTHREAD_CREATE_RUNNING 0 -#define PTHREAD_CREATE_SUSPENDED 1 - -/* - * Additional state for a thread suspended with pthread_suspend_np(). - */ -enum pthread_susp { - SUSP_NO, /* Not suspended. */ - SUSP_YES, /* Suspended. */ - SUSP_JOIN, /* Suspended, joining. */ - SUSP_NOWAIT, /* Suspended, was in a mutex or condition queue. */ - SUSP_MUTEX_WAIT,/* Suspended, still in a mutex queue. */ - SUSP_COND_WAIT /* Suspended, still in a condition queue. */ -}; - -/* - * Miscellaneous definitions. - */ -#define PTHREAD_STACK_DEFAULT 65536 -/* - * Maximum size of initial thread's stack. This perhaps deserves to be larger - * than the stacks of other threads, since many applications are likely to run - * almost entirely on this stack. - */ -#define PTHREAD_STACK_INITIAL 0x100000 - -/* Address immediately beyond the beginning of the initial thread stack. */ -#define _POSIX_THREAD_ATTR_STACKSIZE - -/* - * Define the different priority ranges. All applications have thread - * priorities constrained within 0-31. The threads library raises the - * priority when delivering signals in order to ensure that signal - * delivery happens (from the POSIX spec) "as soon as possible". - * In the future, the threads library will also be able to map specific - * threads into real-time (cooperating) processes or kernel threads. - * The RT and SIGNAL priorities will be used internally and added to - * thread base priorities so that the scheduling queue can handle both - * normal and RT priority threads with and without signal handling. - * - * The approach taken is that, within each class, signal delivery - * always has priority over thread execution. - */ -#define PTHREAD_DEFAULT_PRIORITY 15 -#define PTHREAD_MIN_PRIORITY 0 -#define PTHREAD_MAX_PRIORITY 31 /* 0x1F */ -#define PTHREAD_SIGNAL_PRIORITY 32 /* 0x20 */ -#define PTHREAD_RT_PRIORITY 64 /* 0x40 */ -#define PTHREAD_FIRST_PRIORITY PTHREAD_MIN_PRIORITY -#define PTHREAD_LAST_PRIORITY \ - (PTHREAD_MAX_PRIORITY + PTHREAD_SIGNAL_PRIORITY + PTHREAD_RT_PRIORITY) -#define PTHREAD_BASE_PRIORITY(prio) ((prio) & PTHREAD_MAX_PRIORITY) - -/* - * Clock resolution in microseconds. - */ -#define CLOCK_RES_USEC 10000 -#define CLOCK_RES_USEC_MIN 1000 - -/* - * Time slice period in microseconds. - */ -#define TIMESLICE_USEC 20000 - -/* - * Define a thread-safe macro to get the current time of day - * which is updated at regular intervals by the scheduling signal - * handler. - */ -#define GET_CURRENT_TOD(tv) \ - do { \ - tv.tv_sec = _sched_tod.tv_sec; \ - tv.tv_usec = _sched_tod.tv_usec; \ - } while (tv.tv_sec != _sched_tod.tv_sec) - - -struct pthread_key { - spinlock_t lock; - volatile int allocated; - volatile int count; - void (*destructor) (); -}; - -struct pthread_rwlockattr { - int pshared; -}; - -struct pthread_rwlock { - pthread_mutex_t lock; /* monitor lock */ - int state; /* 0 = idle >0 = # of readers -1 = writer */ - pthread_cond_t read_signal; - pthread_cond_t write_signal; - int blocked_writers; -}; - -/* - * Thread states. - */ -enum pthread_state { - PS_RUNNING, - PS_SIGTHREAD, - PS_MUTEX_WAIT, - PS_COND_WAIT, - PS_FDLR_WAIT, - PS_FDLW_WAIT, - PS_FDR_WAIT, - PS_FDW_WAIT, - PS_FILE_WAIT, - PS_POLL_WAIT, - PS_SELECT_WAIT, - PS_SLEEP_WAIT, - PS_WAIT_WAIT, - PS_SIGSUSPEND, - PS_SIGWAIT, - PS_SPINBLOCK, - PS_JOIN, - PS_SUSPENDED, - PS_DEAD, - PS_DEADLOCK, - PS_STATE_MAX -}; - - -/* - * File descriptor locking definitions are defined in "thread_private.h" - */ - -/* - * File descriptor table structure. - */ -struct fd_table_entry { - /* - * Lock for accesses to this file descriptor table - * entry. This is passed to _spinlock() to provide atomic - * access to this structure. It does *not* represent the - * state of the lock on the file descriptor. - */ - spinlock_t lock; - _thread_list_t r_queue; /* Read queue. */ - _thread_list_t w_queue; /* Write queue. */ - struct pthread *r_owner; /* Ptr to thread owning read lock. */ - struct pthread *w_owner; /* Ptr to thread owning write lock. */ - const char *r_fname; /* Ptr to read lock source file name */ - int r_lineno; /* Read lock source line number. */ - const char *w_fname; /* Ptr to write lock source file name */ - int w_lineno; /* Write lock source line number. */ - int r_lockcount; /* Count for FILE read locks. */ - int w_lockcount; /* Count for FILE write locks. */ - int flags; /* Flags used in open. */ -}; - -struct pthread_poll_data { - int nfds; - struct pollfd *fds; -}; - -union pthread_wait_data { - pthread_mutex_t mutex; - pthread_cond_t cond; - const sigset_t *sigwait; /* Waiting on a signal in sigwait */ - struct { - short fd; /* Used when thread waiting on fd */ - short branch; /* Line number, for debugging. */ - char *fname; /* Source file name for debugging.*/ - } fd; - FILE *fp; - struct pthread_poll_data *poll_data; - spinlock_t *spinlock; - struct pthread *thread; -}; - -/* Spare thread stack. */ -struct stack { - SLIST_ENTRY(stack) qe; /* Queue entry for this stack. */ - void *base; /* Bottom of useful stack */ - size_t size; /* Size of useful stack */ - void *redzone; /* Red zone location */ - void *storage; /* allocated storage */ -}; - -/* - * Define a continuation routine that can be used to perform a - * transfer of control: - */ -typedef void (*thread_continuation_t) (void *); - -typedef V_TAILQ_ENTRY(pthread) pthread_entry_t; - -struct join_status { - struct pthread *thread; - void *ret; - int error; -}; - -/* - * Thread structure. - */ -struct pthread { - /* - * Magic value to help recognize a valid thread structure - * from an invalid one: - */ -#define PTHREAD_MAGIC ((u_int32_t) 0xd09ba115) - u_int32_t magic; - char *name; - - /* - * Lock for accesses to this thread structure. - */ - spinlock_t lock; - - /* Queue entry for list of all threads: */ - pthread_entry_t tle; - - /* Queue entry for list of dead threads: */ - pthread_entry_t dle; - - /* - * Thread start routine, argument, stack pointer and thread - * attributes. - */ - void *(*start_routine)(void *); - void *arg; - struct stack *stack; - struct pthread_attr attr; - - /* - * Saved signal context used in call to sigreturn by - * _thread_kern_sched if sig_saved is TRUE. - */ - struct sigcontext saved_sigcontext; - - /* - * Machine-dependent context, valid if sig_saved is FALSE. - */ - struct _machdep_state _machdep; - - /* - * TRUE if the last state saved was a signal context. FALSE if the - * last state saved was a jump buffer. - */ - int sig_saved; - - /* - * Cancelability flags - the lower 2 bits are used by cancel - * definitions in pthread.h - */ -#define PTHREAD_AT_CANCEL_POINT 0x0004 -#define PTHREAD_CANCELLING 0x0008 -#define PTHREAD_CANCEL_NEEDED 0x0010 - int cancelflags; - - enum pthread_susp suspended; - - thread_continuation_t continuation; - - /* - * Current signal mask and pending signals. - */ - sigset_t sigmask; - sigset_t sigpend; - int sigmask_seqno; - int check_pending; - - /* Thread state: */ - enum pthread_state state; - - /* Scheduling clock when this thread was last made active. */ - long last_active; - - /* Scheduling clock when this thread was last made inactive. */ - long last_inactive; - - /* - * Number of microseconds accumulated by this thread when - * time slicing is active. - */ - long slice_usec; - - /* - * Time to wake up thread. This is used for sleeping threads and - * for any operation which may time out (such as select). - */ - struct timespec wakeup_time; - - /* TRUE if operation has timed out. */ - int timeout; - - /* - * Error variable used instead of errno. The function __error() - * returns a pointer to this. - */ - int error; - - /* - * The joiner is the thread that is joining to this thread. The - * join status keeps track of a join operation to another thread. - */ - struct pthread *joiner; - struct join_status join_status; - - /* - * The current thread can belong to only one scheduling queue at - * a time (ready or waiting queue). It can also belong to: - * - * o A queue of threads waiting for a mutex - * o A queue of threads waiting for a condition variable - * o A queue of threads waiting for a file descriptor lock - * o A queue of threads needing work done by the kernel thread - * (waiting for a spinlock or file I/O) - * - * A thread can also be joining a thread (the joiner field above). - * - * It must not be possible for a thread to belong to any of the - * above queues while it is handling a signal. Signal handlers - * may longjmp back to previous stack frames circumventing normal - * control flow. This could corrupt queue integrity if the thread - * retains membership in the queue. Therefore, if a thread is a - * member of one of these queues when a signal handler is invoked, - * it must remove itself from the queue before calling the signal - * handler and reinsert itself after normal return of the handler. - * - * Use pqe for the scheduling queue link (both ready and waiting), - * sqe for synchronization (mutex and condition variable) queue - * links, and qe for all other links. - */ - - pthread_entry_t pqe; /* priority queue link */ - pthread_entry_t sqe; /* synchronization queue link */ - pthread_entry_t qe; /* all other queues link */ - - /* Wait data. */ - union pthread_wait_data data; - - /* - * Allocated for converting select into poll. - */ - struct pthread_poll_data poll_data; - - /* - * Set to TRUE if a blocking operation was - * interrupted by a signal: - */ - int interrupted; - - /* Signal number when in state PS_SIGWAIT: */ - int signo; - - /* - * Set to non-zero when this thread has deferred signals. - * We allow for recursive deferral. - */ - int sig_defer_count; - - /* - * Set to TRUE if this thread should yield after undeferring - * signals. - */ - int yield_on_sig_undefer; - - /* Miscellaneous flags; only set with signals deferred. */ - int flags; -#define PTHREAD_FLAGS_PRIVATE 0x0001 -#define PTHREAD_EXITING 0x0002 -#define PTHREAD_FLAGS_IN_WAITQ 0x0004 /* in waiting queue using pqe link */ -#define PTHREAD_FLAGS_IN_PRIOQ 0x0008 /* in priority queue using pqe link */ -#define PTHREAD_FLAGS_IN_WORKQ 0x0010 /* in work queue using qe link */ -#define PTHREAD_FLAGS_IN_FILEQ 0x0020 /* in file lock queue using qe link */ -#define PTHREAD_FLAGS_IN_FDQ 0x0040 /* in fd lock queue using qe link */ -#define PTHREAD_FLAGS_IN_CONDQ 0x0080 /* in condition queue using sqe link */ -#define PTHREAD_FLAGS_IN_MUTEXQ 0x0100 /* in mutex queue using sqe link */ -#define PTHREAD_FLAGS_TRACE 0x0200 /* for debugging purposes */ -#define PTHREAD_FLAGS_IN_SYNCQ \ - (PTHREAD_FLAGS_IN_CONDQ | PTHREAD_FLAGS_IN_MUTEXQ) - - /* - * Base priority is the user setable and retrievable priority - * of the thread. It is only affected by explicit calls to - * set thread priority and upon thread creation via a thread - * attribute or default priority. - */ - char base_priority; - - /* - * Inherited priority is the priority a thread inherits by - * taking a priority inheritence or protection mutex. It - * is not affected by base priority changes. Inherited - * priority defaults to and remains 0 until a mutex is taken - * that is being waited on by any other thread whose priority - * is non-zero. - */ - char inherited_priority; - - /* - * Active priority is always the maximum of the threads base - * priority and inherited priority. When there is a change - * in either the base or inherited priority, the active - * priority must be recalculated. - */ - char active_priority; - - /* Number of priority ceiling or protection mutexes owned. */ - int priority_mutex_count; - - /* - * Queue of currently owned mutexes. - */ - V_TAILQ_HEAD(, pthread_mutex volatile) mutexq; - - void *ret; - const void **specific_data; - int specific_data_count; - - /* Cleanup handlers Link List */ - struct pthread_cleanup *cleanup; - char *fname; /* Ptr to source file name */ - int lineno; /* Source line number. */ -}; - -/* - * Flags and prototypes for the machine dependent layer - */ -void _thread_machdep_switch(struct _machdep_state *newstate, - struct _machdep_state *savestate); -void _thread_machdep_init(struct _machdep_state *state, void *stackbase, - int stacksize, void (*entry)(void)); -void _thread_machdep_save_float_state(struct _machdep_state* statep); -void _thread_machdep_restore_float_state(struct _machdep_state* statep); - -/* - * Global variables for the uthread kernel. - */ - -/* Kernel thread structure used when there are no running threads: */ -SCLASS struct pthread _thread_kern_thread; - -/* Ptr to the thread structure for the running thread: */ -SCLASS struct pthread * volatile _thread_run -#ifdef GLOBAL_PTHREAD_PRIVATE -= &_thread_kern_thread; -#else -; -#endif - -/* Ptr to the thread structure for the last user thread to run: */ -SCLASS struct pthread * volatile _last_user_thread -#ifdef GLOBAL_PTHREAD_PRIVATE -= &_thread_kern_thread; -#else -; -#endif - -/* - * Ptr to the thread running in single-threaded mode or NULL if - * running multi-threaded (default POSIX behaviour). - */ -SCLASS struct pthread * volatile _thread_single -#ifdef GLOBAL_PTHREAD_PRIVATE -= NULL; -#else -; -#endif - -SCLASS _thread_list_t _thread_list -#ifdef GLOBAL_PTHREAD_PRIVATE -= TAILQ_HEAD_INITIALIZER(_thread_list); -#else -; -#endif - -/* - * Array of kernel pipe file descriptors that are used to ensure that - * no signals are missed in calls to _select. - */ -SCLASS int _thread_kern_pipe[2] -#ifdef GLOBAL_PTHREAD_PRIVATE -= { - -1, - -1 -}; -#else -; -#endif -SCLASS int volatile _queue_signals -#ifdef GLOBAL_PTHREAD_PRIVATE -= 0; -#else -; -#endif -SCLASS int volatile _thread_kern_in_sched -#ifdef GLOBAL_PTHREAD_PRIVATE -= 0; -#else -; -#endif - -SCLASS int _sig_in_handler -#ifdef GLOBAL_PTHREAD_PRIVATE -= 0; -#else -; -#endif - -/* Time of day at last scheduling timer signal: */ -SCLASS struct timeval volatile _sched_tod -#ifdef GLOBAL_PTHREAD_PRIVATE -= { 0, 0 }; -#else -; -#endif - -/* - * Current scheduling timer ticks; used as resource usage. - */ -SCLASS unsigned int volatile _sched_ticks -#ifdef GLOBAL_PTHREAD_PRIVATE -= 0; -#else -; -#endif - -/* Dead threads: */ -SCLASS _thread_list_t _dead_list -#ifdef GLOBAL_PTHREAD_PRIVATE -= TAILQ_HEAD_INITIALIZER(_dead_list); -#else -; -#endif - -/* Initial thread: */ -SCLASS struct pthread *_thread_initial -#ifdef GLOBAL_PTHREAD_PRIVATE -= NULL; -#else -; -#endif - -/* Default thread attributes: */ -SCLASS struct pthread_attr pthread_attr_default -#ifdef GLOBAL_PTHREAD_PRIVATE -= { SCHED_RR, 0, TIMESLICE_USEC, PTHREAD_DEFAULT_PRIORITY, - PTHREAD_CREATE_RUNNING, PTHREAD_CREATE_JOINABLE, NULL, NULL, NULL, - PTHREAD_STACK_DEFAULT }; -#else -; -#endif - -/* Default mutex attributes: */ -SCLASS struct pthread_mutex_attr pthread_mutexattr_default -#ifdef GLOBAL_PTHREAD_PRIVATE -= { PTHREAD_MUTEX_DEFAULT, PTHREAD_PRIO_NONE, 0, 0 }; -#else -; -#endif - -/* Default condition variable attributes: */ -SCLASS struct pthread_cond_attr pthread_condattr_default -#ifdef GLOBAL_PTHREAD_PRIVATE -= { COND_TYPE_FAST, 0 }; -#else -; -#endif - -/* File table information: */ -SCLASS struct fd_table_entry **_thread_fd_table -#ifdef GLOBAL_PTHREAD_PRIVATE -= NULL; -#else -; -#endif - -/* Table for polling file descriptors: */ -SCLASS struct pollfd *_thread_pfd_table -#ifdef GLOBAL_PTHREAD_PRIVATE -= NULL; -#else -; -#endif - -SCLASS const int dtablecount -#ifdef GLOBAL_PTHREAD_PRIVATE -= 4096/sizeof(struct fd_table_entry); -#else -; -#endif -SCLASS int _thread_dtablesize /* Descriptor table size. */ -#ifdef GLOBAL_PTHREAD_PRIVATE -= 0; -#else -; -#endif - -SCLASS int _clock_res_usec /* Clock resolution in usec. */ -#ifdef GLOBAL_PTHREAD_PRIVATE -= CLOCK_RES_USEC; -#else -; -#endif - -/* Garbage collector mutex and condition variable. */ -SCLASS pthread_mutex_t _gc_mutex -#ifdef GLOBAL_PTHREAD_PRIVATE -= NULL -#endif -; -SCLASS pthread_cond_t _gc_cond -#ifdef GLOBAL_PTHREAD_PRIVATE -= NULL -#endif -; - -/* - * Array of signal actions for this process. - */ -SCLASS struct sigaction _thread_sigact[NSIG]; - -/* - * Array of counts of dummy handlers for SIG_DFL signals. This is used to - * assure that there is always a dummy signal handler installed while there is a - * thread sigwait()ing on the corresponding signal. - */ -SCLASS int _thread_dfl_count[NSIG]; - -/* - * Pending signals and mask for this process: - */ -SCLASS sigset_t _process_sigpending; -SCLASS sigset_t _process_sigmask -#ifdef GLOBAL_PTHREAD_PRIVATE -= 0 -#endif -; - -/* - * Scheduling queues: - */ -SCLASS pq_queue_t _readyq; -SCLASS _thread_list_t _waitingq; - -/* - * Work queue: - */ -SCLASS _thread_list_t _workq; - -/* Tracks the number of threads blocked while waiting for a spinlock. */ -SCLASS volatile int _spinblock_count -#ifdef GLOBAL_PTHREAD_PRIVATE -= 0 -#endif -; - -/* Used to maintain pending and active signals: */ -struct sigstatus { - int pending; /* Is this a pending signal? */ - int blocked; /* - * A handler is currently active for - * this signal; ignore subsequent - * signals until the handler is done. - */ - int signo; /* arg 1 to signal handler */ - siginfo_t siginfo; /* arg 2 to signal handler */ - struct sigcontext uc; /* arg 3 to signal handler */ -}; - -SCLASS struct sigstatus _thread_sigq[NSIG]; - -/* Indicates that the signal queue needs to be checked. */ -SCLASS volatile int _sigq_check_reqd -#ifdef GLOBAL_PTHREAD_PRIVATE -= 0 -#endif -; - -/* The signal stack. */ -SCLASS struct sigaltstack _thread_sigstack; - -/* Thread switch hook. */ -SCLASS pthread_switch_routine_t _sched_switch_hook -#ifdef GLOBAL_PTHREAD_PRIVATE -= NULL -#endif -; - -/* - * Spare stack queue. Stacks of default size are cached in order to reduce - * thread creation time. Spare stacks are used in LIFO order to increase cache - * locality. - */ -typedef SLIST_HEAD(, stack) _stack_list_t; -extern _stack_list_t _stackq; - -/* Used for _PTHREADS_INVARIANTS checking. */ -SCLASS int _thread_kern_new_state -#ifdef GLOBAL_PTHREAD_PRIVATE -= 0; -#else -; -#endif - -/* Undefine the storage class specifier: */ -#undef SCLASS - -/* - * Function prototype definitions. - */ -__BEGIN_DECLS -int _find_thread(pthread_t); -struct pthread *_get_curthread(void); -void _set_curthread(struct pthread *); -int _thread_create(pthread_t *, const pthread_attr_t *, - void *(*start_routine)(void *), void *,pthread_t); -void _dispatch_signals(pthread_t, struct sigcontext *); -void _thread_signal(pthread_t, int); -int _mutex_cv_lock(pthread_mutex_t *); -int _mutex_cv_unlock(pthread_mutex_t *); -int _mutex_reinit(pthread_mutex_t *); -void _mutex_notify_priochange(struct pthread *); -int _cond_reinit(pthread_cond_t *); -int _pq_alloc(struct pq_queue *, int, int); -int _pq_init(struct pq_queue *); -void _pq_remove(struct pq_queue *pq, struct pthread *); -void _pq_insert_head(struct pq_queue *pq, struct pthread *); -void _pq_insert_tail(struct pq_queue *pq, struct pthread *); -struct pthread *_pq_first(struct pq_queue *pq); -void _waitq_insert(pthread_t pthread); -void _waitq_remove(pthread_t pthread); -#if defined(_PTHREADS_INVARIANTS) -void _waitq_setactive(void); -void _waitq_clearactive(void); -#endif -__dead void _thread_exit(const char *, int, const char *) __attribute__((__noreturn__)); -void *_thread_cleanup(pthread_t); -void _thread_cleanupspecific(void); -void _thread_dump_data(const void *, int); -void _thread_dump_info(void); -void _thread_init(void); -void _thread_kern_sched(struct sigcontext *); -void _thread_kern_sched_sig(void); -void _thread_kern_sched_state(enum pthread_state,char *fname,int lineno); -void _thread_kern_sched_state_unlock(enum pthread_state state, - spinlock_t *lock, char *fname, int lineno); -void _thread_kern_set_timeout(const struct timespec *); -void _thread_kern_sig_defer(void); -void _thread_kern_sig_undefer(void); -void _thread_sig_handler(int, siginfo_t *, struct sigcontext *); -void _thread_sig_handle(int, struct sigcontext *); -void _thread_sig_init(void); -void _thread_sig_process(int, struct sigcontext *); -void _thread_start(void); -void _thread_start_sig_handler(void); -void _thread_seterrno(pthread_t,int); -int _thread_fd_table_init(int fd); -pthread_addr_t _thread_gc(pthread_addr_t); -void _thread_enter_cancellation_point(void); -void _thread_leave_cancellation_point(void); -void _thread_cancellation_point(void); -int _thread_slow_atomic_lock(volatile _spinlock_lock_t *); -int _thread_slow_atomic_is_locked(volatile _spinlock_lock_t *); -struct stack * _thread_stack_alloc(void *, size_t); -void _thread_stack_free(struct stack *); - - -/* #include <signal.h> */ -#ifdef _USER_SIGNAL_H -int _thread_sys_kill(pid_t, int); -int _thread_sys_sigaction(int, const struct sigaction *, struct sigaction *); -int _thread_sys_sigpending(sigset_t *); -int _thread_sys_sigprocmask(int, const sigset_t *, sigset_t *); -int _thread_sys_sigsuspend(const sigset_t *); -int _thread_sys_siginterrupt(int, int); -int _thread_sys_sigpause(int); -int _thread_sys_sigreturn(struct sigcontext *); -int _thread_sys_sigaltstack(const struct sigaltstack *, struct sigaltstack *); -int _thread_sys_sigvec(int, struct sigvec *, struct sigvec *); -void _thread_sys_psignal(unsigned int, const char *); -void (*_thread_sys_signal(int, void (*)(int)))(int); -#endif - -/* #include <sys/stat.h> */ -#ifdef _SYS_STAT_H_ -int _thread_sys_fchmod(int, mode_t); -int _thread_sys_fstat(int, struct stat *); -int _thread_sys_fchflags(int, unsigned int); -#endif - -/* #include <sys/mount.h> */ -#ifdef _SYS_MOUNT_H_ -int _thread_sys_fstatfs(int, struct statfs *); -#endif -int _thread_sys_pipe(int *); - -/* #include <sys/socket.h> */ -#ifdef _SYS_SOCKET_H_ -int _thread_sys_accept(int, struct sockaddr *, socklen_t *); -int _thread_sys_bind(int, const struct sockaddr *, socklen_t); -int _thread_sys_connect(int, const struct sockaddr *, socklen_t); -int _thread_sys_getpeername(int, struct sockaddr *, socklen_t *); -int _thread_sys_getsockname(int, struct sockaddr *, socklen_t *); -int _thread_sys_getsockopt(int, int, int, void *, socklen_t *); -int _thread_sys_listen(int, int); -int _thread_sys_setsockopt(int, int, int, const void *, socklen_t); -int _thread_sys_shutdown(int, int); -int _thread_sys_socket(int, int, int); -int _thread_sys_socketpair(int, int, int, int *); -ssize_t _thread_sys_recv(int, void *, size_t, int); -ssize_t _thread_sys_recvfrom(int, void *, size_t, int, struct sockaddr *, socklen_t *); -ssize_t _thread_sys_recvmsg(int, struct msghdr *, int); -ssize_t _thread_sys_send(int, const void *, size_t, int); -ssize_t _thread_sys_sendmsg(int, const struct msghdr *, int); -ssize_t _thread_sys_sendto(int, const void *,size_t, int, const struct sockaddr *, socklen_t); -#endif - -/* #include <stdio.h> */ -#ifdef _STDIO_H_ -FILE *_thread_sys_fdopen(int, const char *); -FILE *_thread_sys_fopen(const char *, const char *); -FILE *_thread_sys_freopen(const char *, const char *, FILE *); -FILE *_thread_sys_popen(const char *, const char *); -FILE *_thread_sys_tmpfile(void); -char *_thread_sys_ctermid(char *); -char *_thread_sys_cuserid(char *); -char *_thread_sys_fgetln(FILE *, size_t *); -char *_thread_sys_fgets(char *, int, FILE *); -char *_thread_sys_gets(char *); -char *_thread_sys_tempnam(const char *, const char *); -char *_thread_sys_tmpnam(char *); -int _thread_sys_fclose(FILE *); -int _thread_sys_feof(FILE *); -int _thread_sys_ferror(FILE *); -int _thread_sys_fflush(FILE *); -int _thread_sys_fgetc(FILE *); -int _thread_sys_fgetpos(FILE *, fpos_t *); -int _thread_sys_fileno(FILE *); -int _thread_sys_fprintf(FILE *, const char *, ...); -int _thread_sys_fpurge(FILE *); -int _thread_sys_fputc(int, FILE *); -int _thread_sys_fputs(const char *, FILE *); -int _thread_sys_fscanf(FILE *, const char *, ...); -int _thread_sys_fseek(FILE *, long, int); -int _thread_sys_fsetpos(FILE *, const fpos_t *); -int _thread_sys_getc(FILE *); -int _thread_sys_getchar(void); -int _thread_sys_getw(FILE *); -int _thread_sys_pclose(FILE *); -int _thread_sys_printf(const char *, ...); -int _thread_sys_putc(int, FILE *); -int _thread_sys_putchar(int); -int _thread_sys_puts(const char *); -int _thread_sys_putw(int, FILE *); -int _thread_sys_remove(const char *); -int _thread_sys_rename (const char *, const char *); -int _thread_sys_scanf(const char *, ...); -int _thread_sys_setlinebuf(FILE *); -int _thread_sys_setvbuf(FILE *, char *, int, size_t); -int _thread_sys_snprintf(char *, size_t, const char *, ...); -int _thread_sys_sprintf(char *, const char *, ...); -int _thread_sys_sscanf(const char *, const char *, ...); -int _thread_sys_ungetc(int, FILE *); -int _thread_sys_vfprintf(FILE *, const char *, _BSD_VA_LIST_); -int _thread_sys_vprintf(const char *, _BSD_VA_LIST_); -int _thread_sys_vscanf(const char *, _BSD_VA_LIST_); -int _thread_sys_vsnprintf(char *, size_t, const char *, _BSD_VA_LIST_); -int _thread_sys_vsprintf(char *, const char *, _BSD_VA_LIST_); -int _thread_sys_vsscanf(const char *, const char *, _BSD_VA_LIST_); -long _thread_sys_ftell(FILE *); -size_t _thread_sys_fread(void *, size_t, size_t, FILE *); -size_t _thread_sys_fwrite(const void *, size_t, size_t, FILE *); -void _thread_sys_clearerr(FILE *); -void _thread_sys_perror(const char *); -void _thread_sys_rewind(FILE *); -void _thread_sys_setbuf(FILE *, char *); -void _thread_sys_setbuffer(FILE *, char *, int); -#endif - -/* #include <unistd.h> */ -#ifdef _UNISTD_H_ -char *_thread_sys_ttyname(int); -int _thread_sys_close(int); -int _thread_sys_dup(int); -int _thread_sys_dup2(int, int); -int _thread_sys_exect(const char *, char * const *, char * const *); -int _thread_sys_execve(const char *, char * const *, char * const *); -int _thread_sys_fchdir(int); -int _thread_sys_fchown(int, uid_t, gid_t); -int _thread_sys_fsync(int); -int _thread_sys_ftruncate(int, off_t); -long _thread_sys_fpathconf(int, int); -pid_t _thread_sys_getpid(void); -int _thread_sys_pause(void); -int _thread_sys_pipe(int *); -int _thread_sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); -off_t _thread_sys_lseek(int, off_t, int); -pid_t _thread_sys_fork(void); -pid_t _thread_sys_tcgetpgrp(int); -ssize_t _thread_sys_read(int, void *, size_t); -ssize_t _thread_sys_write(int, const void *, size_t); -__dead void _thread_sys__exit(int) __attribute__((__noreturn__)); -#endif - -/* #include <fcntl.h> */ -#ifdef _SYS_FCNTL_H_ -int _thread_sys_creat(const char *, mode_t); -int _thread_sys_fcntl(int, int, ...); -int _thread_sys_flock(int, int); -int _thread_sys_open(const char *, int, ...); -#endif - -/* #include <sys/ioctl.h> */ -#ifdef _SYS_IOCTL_H_ -int _thread_sys_ioctl(int, unsigned long, ...); -#endif - -/* #include <dirent.h> */ -#ifdef _DIRENT_H_ -DIR *___thread_sys_opendir2(const char *, int); -DIR *_thread_sys_opendir(const char *); -int _thread_sys_alphasort(const void *, const void *); -int _thread_sys_scandir(const char *, struct dirent ***, - int (*)(struct dirent *), int (*)(const void *, const void *)); -int _thread_sys_closedir(DIR *); -int _thread_sys_getdirentries(int, char *, int, long *); -long _thread_sys_telldir(const DIR *); -struct dirent *_thread_sys_readdir(DIR *); -void _thread_sys_rewinddir(DIR *); -void _thread_sys_seekdir(DIR *, long); -#endif - -/* #include <sys/uio.h> */ -#ifdef _SYS_UIO_H_ -ssize_t _thread_sys_readv(int, const struct iovec *, int); -ssize_t _thread_sys_writev(int, const struct iovec *, int); -#endif - -/* #include <sys/wait.h> */ -#ifdef _SYS_WAIT_H_ -pid_t _thread_sys_wait(int *); -pid_t _thread_sys_waitpid(pid_t, int *, int); -pid_t _thread_sys_wait3(int *, int, struct rusage *); -pid_t _thread_sys_wait4(pid_t, int *, int, struct rusage *); -#endif - -/* #include <poll.h> */ -#ifdef _SYS_POLL_H_ -int _thread_sys_poll(struct pollfd *, unsigned, int); -#endif - -/* #include <sys/event.h> */ -#ifdef _SYS_EVENT_H_ -int _thread_sys_kevent(int, const struct kevent *, int, struct kevent *, - int, const struct timespec *); -#endif - -/* #include <sys/mman.h> */ -int _thread_sys_msync(void *, size_t, int); - -__END_DECLS - -#endif /* !_PTHREAD_PRIVATE_H */ diff --git a/lib/libc_r/uthread/uthread_accept.c b/lib/libc_r/uthread/uthread_accept.c deleted file mode 100644 index a3f424084fc..00000000000 --- a/lib/libc_r/uthread/uthread_accept.c +++ /dev/null @@ -1,107 +0,0 @@ -/* $OpenBSD: uthread_accept.c,v 1.7 2002/11/12 20:12:45 marc Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_accept.c,v 1.9 1999/08/28 00:03:20 peter Exp $ - */ -#include <errno.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <fcntl.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -accept(int fd, struct sockaddr * name, socklen_t *namelen) -{ - struct pthread *curthread = _get_curthread(); - int ret; - - /* Lock the file descriptor: */ - if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { - /* Enter a loop to wait for a connection request: */ - while ((ret = _thread_sys_accept(fd, name, namelen)) < 0) { - /* Check if the socket is to block: */ - if ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0 && - (errno == EWOULDBLOCK || errno == EAGAIN)) { - /* Save the socket file descriptor: */ - curthread->data.fd.fd = fd; - curthread->data.fd.fname = __FILE__; - curthread->data.fd.branch = __LINE__; - - /* Set the timeout: */ - _thread_kern_set_timeout(NULL); - curthread->interrupted = 0; - - /* Schedule the next thread: */ - _thread_kern_sched_state(PS_FDR_WAIT, __FILE__, - __LINE__); - - /* Check if the wait was interrupted: */ - if (curthread->interrupted) { - /* Return an error status: */ - errno = EINTR; - ret = -1; - break; - } - } else { - /* - * Another error has occurred, so exit the - * loop here: - */ - break; - } - } - - /* - * If no errors initialize the file descriptor table - * for the new socket. Turn on blocking mode in the - * child if it is on in the parent. This is done - * as _thread_fd_table_init *may* have turned the flag on. - */ - if (ret != -1) { - if (_thread_fd_table_init(ret) != 0) { - /* Quietly close the socket: */ - _thread_sys_close(ret); - ret = -1; - } else if ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0) - _thread_fd_table[ret]->flags &= ~O_NONBLOCK; - } - - /* Unlock the file descriptor: */ - _FD_UNLOCK(fd, FD_RDWR); - } - /* Return the socket file descriptor or -1 on error: */ - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_attr_destroy.c b/lib/libc_r/uthread/uthread_attr_destroy.c deleted file mode 100644 index a71b00eea6e..00000000000 --- a/lib/libc_r/uthread/uthread_attr_destroy.c +++ /dev/null @@ -1,63 +0,0 @@ -/* $OpenBSD: uthread_attr_destroy.c,v 1.4 2002/11/07 02:56:20 marc Exp $ */ -/* - * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_attr_destroy.c,v 1.4 1999/08/28 00:03:20 peter Exp $ - */ -#include <stdlib.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_attr_destroy(pthread_attr_t *attr) -{ - int ret; - - /* Check for invalid arguments: */ - if (attr == NULL || *attr == NULL) - /* Invalid argument: */ - ret = EINVAL; - else { - /* Free the memory allocated to the attribute object: */ - free(*attr); - - /* - * Leave the attribute pointer NULL now that the memory - * has been freed: - */ - *attr = NULL; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_attr_getdetachstate.c b/lib/libc_r/uthread/uthread_attr_getdetachstate.c deleted file mode 100644 index 915caddf33e..00000000000 --- a/lib/libc_r/uthread/uthread_attr_getdetachstate.c +++ /dev/null @@ -1,60 +0,0 @@ -/* $OpenBSD: uthread_attr_getdetachstate.c,v 1.4 2002/01/10 00:45:30 fgsch Exp $ */ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_attr_getdetachstate.c,v 1.3 1999/08/28 00:03:20 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate) -{ - int ret; - - /* Check for invalid arguments: */ - if (attr == NULL || *attr == NULL || detachstate == NULL) - ret = EINVAL; - else { - /* Check if the detached flag is set: */ - if ((*attr)->flags & PTHREAD_DETACHED) - /* Return detached: */ - *detachstate = PTHREAD_CREATE_DETACHED; - else - /* Return joinable: */ - *detachstate = PTHREAD_CREATE_JOINABLE; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_attr_getinheritsched.c b/lib/libc_r/uthread/uthread_attr_getinheritsched.c deleted file mode 100644 index da160586615..00000000000 --- a/lib/libc_r/uthread/uthread_attr_getinheritsched.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: uthread_attr_getinheritsched.c,v 1.2 1999/11/25 07:01:30 d Exp $ */ -/* - * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Daniel Eischen. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_attr_getinheritsched.c,v 1.3 1999/08/28 00:03:21 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_attr_getinheritsched(const pthread_attr_t *attr, int *sched_inherit) -{ - int ret = 0; - - if ((attr == NULL) || (*attr == NULL)) - ret = EINVAL; - else - *sched_inherit = (*attr)->sched_inherit; - - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_attr_getschedparam.c b/lib/libc_r/uthread/uthread_attr_getschedparam.c deleted file mode 100644 index 321d2b646b1..00000000000 --- a/lib/libc_r/uthread/uthread_attr_getschedparam.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: uthread_attr_getschedparam.c,v 1.2 1999/11/25 07:01:31 d Exp $ */ -/* - * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Daniel Eischen. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_attr_getschedparam.c,v 1.3 1999/08/28 00:03:21 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param) -{ - int ret = 0; - - if ((attr == NULL) || (*attr == NULL) || (param == NULL)) - ret = EINVAL; - else - param->sched_priority = (*attr)->prio; - - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_attr_getschedpolicy.c b/lib/libc_r/uthread/uthread_attr_getschedpolicy.c deleted file mode 100644 index 5be8dcba3bf..00000000000 --- a/lib/libc_r/uthread/uthread_attr_getschedpolicy.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: uthread_attr_getschedpolicy.c,v 1.2 1999/11/25 07:01:31 d Exp $ */ -/* - * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Daniel Eischen. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_attr_getschedpolicy.c,v 1.3 1999/08/28 00:03:21 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy) -{ - int ret = 0; - - if ((attr == NULL) || (*attr == NULL) || (policy == NULL)) - ret = EINVAL; - else - *policy = (*attr)->sched_policy; - - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_attr_getscope.c b/lib/libc_r/uthread/uthread_attr_getscope.c deleted file mode 100644 index 68bfb0d6654..00000000000 --- a/lib/libc_r/uthread/uthread_attr_getscope.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $OpenBSD: uthread_attr_getscope.c,v 1.2 1999/11/25 07:01:31 d Exp $ */ -/* - * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Daniel Eischen. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_attr_getscope.c,v 1.3 1999/08/28 00:03:22 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_attr_getscope(const pthread_attr_t *attr, int *contentionscope) -{ - int ret = 0; - - if ((attr == NULL) || (*attr == NULL) || (contentionscope == NULL)) - /* Return an invalid argument: */ - ret = EINVAL; - - else - *contentionscope = (*attr)->flags & PTHREAD_SCOPE_SYSTEM ? - PTHREAD_SCOPE_SYSTEM : PTHREAD_SCOPE_PROCESS; - - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_attr_getstackaddr.c b/lib/libc_r/uthread/uthread_attr_getstackaddr.c deleted file mode 100644 index b2a330f5a64..00000000000 --- a/lib/libc_r/uthread/uthread_attr_getstackaddr.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $OpenBSD: uthread_attr_getstackaddr.c,v 1.4 2002/11/07 02:56:20 marc Exp $ */ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_attr_getstackaddr.c,v 1.3 1999/08/28 00:03:22 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_attr_getstackaddr(pthread_attr_t *attr, void **stackaddr) -{ - int ret; - - /* Check for invalid arguments: */ - if (attr == NULL || *attr == NULL || stackaddr == NULL) - ret = EINVAL; - else { - /* Return the stack address: */ - *stackaddr = (*attr)->stackaddr_attr; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_attr_getstacksize.c b/lib/libc_r/uthread/uthread_attr_getstacksize.c deleted file mode 100644 index f58a0bf5d15..00000000000 --- a/lib/libc_r/uthread/uthread_attr_getstacksize.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $OpenBSD: uthread_attr_getstacksize.c,v 1.4 2002/11/07 02:56:20 marc Exp $ */ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_attr_getstacksize.c,v 1.3 1999/08/28 00:03:22 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_attr_getstacksize(pthread_attr_t *attr, size_t *stacksize) -{ - int ret; - - /* Check for invalid arguments: */ - if (attr == NULL || *attr == NULL || stacksize == NULL) - ret = EINVAL; - else { - /* Return the stack size: */ - *stacksize = (*attr)->stacksize_attr; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_attr_init.c b/lib/libc_r/uthread/uthread_attr_init.c deleted file mode 100644 index c7b811e3505..00000000000 --- a/lib/libc_r/uthread/uthread_attr_init.c +++ /dev/null @@ -1,62 +0,0 @@ -/* $OpenBSD: uthread_attr_init.c,v 1.4 2002/11/07 02:56:20 marc Exp $ */ -/* - * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_attr_init.c,v 1.4 1999/08/28 00:03:23 peter Exp $ - */ -#include <string.h> -#include <stdlib.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_attr_init(pthread_attr_t *attr) -{ - int ret; - pthread_attr_t pattr; - - /* Allocate memory for the attribute object: */ - if ((pattr = (pthread_attr_t) malloc(sizeof(struct pthread_attr))) == NULL) - /* Insufficient memory: */ - ret = ENOMEM; - else { - /* Initialise the attribute object with the defaults: */ - memcpy(pattr, &pthread_attr_default, sizeof(struct pthread_attr)); - - /* Return a pointer to the attribute object: */ - *attr = pattr; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_attr_setcreatesuspend_np.c b/lib/libc_r/uthread/uthread_attr_setcreatesuspend_np.c deleted file mode 100644 index e1d7d51bfaa..00000000000 --- a/lib/libc_r/uthread/uthread_attr_setcreatesuspend_np.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: uthread_attr_setcreatesuspend_np.c,v 1.4 2001/08/10 14:37:20 fgsch Exp $ */ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_attr_setcreatesuspend_np.c,v 1.3 1999/08/28 00:03:24 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_attr_setcreatesuspend_np(pthread_attr_t *attr) -{ - int ret; - if (attr == NULL || *attr == NULL) { - ret = EINVAL; - } else { - (*attr)->suspend = PTHREAD_CREATE_SUSPENDED; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_attr_setdetachstate.c b/lib/libc_r/uthread/uthread_attr_setdetachstate.c deleted file mode 100644 index f0801e5823d..00000000000 --- a/lib/libc_r/uthread/uthread_attr_setdetachstate.c +++ /dev/null @@ -1,62 +0,0 @@ -/* $OpenBSD: uthread_attr_setdetachstate.c,v 1.4 2002/11/07 02:56:20 marc Exp $ */ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_attr_setdetachstate.c,v 1.3 1999/08/28 00:03:24 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate) -{ - int ret; - - /* Check for invalid arguments: */ - if (attr == NULL || *attr == NULL || - (detachstate != PTHREAD_CREATE_DETACHED && - detachstate != PTHREAD_CREATE_JOINABLE)) - ret = EINVAL; - else { - /* Check if detached state: */ - if (detachstate == PTHREAD_CREATE_DETACHED) - /* Set the detached flag: */ - (*attr)->flags |= PTHREAD_DETACHED; - else - /* Reset the detached flag: */ - (*attr)->flags &= ~PTHREAD_DETACHED; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_attr_setinheritsched.c b/lib/libc_r/uthread/uthread_attr_setinheritsched.c deleted file mode 100644 index 61e0f2f6144..00000000000 --- a/lib/libc_r/uthread/uthread_attr_setinheritsched.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: uthread_attr_setinheritsched.c,v 1.2 1999/11/25 07:01:31 d Exp $ */ -/* - * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Daniel Eischen. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_attr_setinheritsched.c,v 1.3 1999/08/28 00:03:24 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_attr_setinheritsched(pthread_attr_t *attr, int sched_inherit) -{ - int ret = 0; - - if ((attr == NULL) || (*attr == NULL)) - ret = EINVAL; - else - (*attr)->sched_inherit = sched_inherit; - - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_attr_setprio.c b/lib/libc_r/uthread/uthread_attr_setprio.c deleted file mode 100644 index ffe74d8a102..00000000000 --- a/lib/libc_r/uthread/uthread_attr_setprio.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: uthread_attr_setprio.c,v 1.5 2002/11/07 02:56:20 marc Exp $ */ -/* - * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_attr_setprio.c,v 1.3 1999/08/28 00:03:24 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_attr_setprio(pthread_attr_t *attr, int priority) -{ - int ret; - if (attr == NULL || *attr == NULL) { - ret = EINVAL; - } else { - (*attr)->prio = priority; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_attr_setschedparam.c b/lib/libc_r/uthread/uthread_attr_setschedparam.c deleted file mode 100644 index d1071fa4314..00000000000 --- a/lib/libc_r/uthread/uthread_attr_setschedparam.c +++ /dev/null @@ -1,58 +0,0 @@ -/* $OpenBSD: uthread_attr_setschedparam.c,v 1.4 2002/01/19 23:49:32 fgsch Exp $ */ -/* - * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Daniel Eischen. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_attr_setschedparam.c,v 1.3 1999/08/28 00:03:25 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param) -{ - int ret = 0; - - if ((attr == NULL) || (*attr == NULL)) - ret = EINVAL; - else if (param == NULL) { - ret = ENOTSUP; - } else if ((param->sched_priority < PTHREAD_MIN_PRIORITY) || - (param->sched_priority > PTHREAD_MAX_PRIORITY)) { - /* Return an unsupported value error. */ - ret = ENOTSUP; - } else - (*attr)->prio = param->sched_priority; - - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_attr_setschedpolicy.c b/lib/libc_r/uthread/uthread_attr_setschedpolicy.c deleted file mode 100644 index 59e4ed926d0..00000000000 --- a/lib/libc_r/uthread/uthread_attr_setschedpolicy.c +++ /dev/null @@ -1,54 +0,0 @@ -/* $OpenBSD: uthread_attr_setschedpolicy.c,v 1.4 2002/01/19 23:49:32 fgsch Exp $ */ -/* - * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Daniel Eischen. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_attr_setschedpolicy.c,v 1.3 1999/08/28 00:03:25 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy) -{ - int ret = 0; - - if ((attr == NULL) || (*attr == NULL)) - ret = EINVAL; - else if ((policy < SCHED_FIFO) || (policy > SCHED_RR)) { - ret = ENOTSUP; - } else - (*attr)->sched_policy = policy; - - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_attr_setscope.c b/lib/libc_r/uthread/uthread_attr_setscope.c deleted file mode 100644 index 2b8f4122034..00000000000 --- a/lib/libc_r/uthread/uthread_attr_setscope.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $OpenBSD: uthread_attr_setscope.c,v 1.4 2002/02/19 01:13:08 fgsch Exp $ */ -/* - * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Daniel Eischen. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_attr_setscope.c,v 1.3 1999/08/28 00:03:25 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_attr_setscope(pthread_attr_t *attr, int contentionscope) -{ - int ret = 0; - - if ((attr == NULL) || (*attr == NULL)) { - /* Return an invalid argument: */ - ret = EINVAL; - } else if ((contentionscope != PTHREAD_SCOPE_PROCESS) || - (contentionscope == PTHREAD_SCOPE_SYSTEM)) { - /* We don't support PTHREAD_SCOPE_SYSTEM. */ - ret = ENOTSUP; - } else - (*attr)->flags |= contentionscope; - - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_attr_setstackaddr.c b/lib/libc_r/uthread/uthread_attr_setstackaddr.c deleted file mode 100644 index a2f07bab9a3..00000000000 --- a/lib/libc_r/uthread/uthread_attr_setstackaddr.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $OpenBSD: uthread_attr_setstackaddr.c,v 1.4 2002/11/07 02:56:20 marc Exp $ */ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_attr_setstackaddr.c,v 1.3 1999/08/28 00:03:25 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr) -{ - int ret; - - /* Check for invalid arguments: */ - if (attr == NULL || *attr == NULL || stackaddr == NULL) - ret = EINVAL; - else { - /* Save the stack address: */ - (*attr)->stackaddr_attr = stackaddr; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_attr_setstacksize.c b/lib/libc_r/uthread/uthread_attr_setstacksize.c deleted file mode 100644 index 5c1e489cf97..00000000000 --- a/lib/libc_r/uthread/uthread_attr_setstacksize.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $OpenBSD: uthread_attr_setstacksize.c,v 1.4 2002/11/07 02:56:20 marc Exp $ */ -/* - * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_attr_setstacksize.c,v 1.4 1999/08/28 00:03:26 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize) -{ - int ret; - - /* Check for invalid arguments: */ - if (attr == NULL || *attr == NULL || stacksize < PTHREAD_STACK_MIN) - ret = EINVAL; - else { - /* Save the stack size: */ - (*attr)->stacksize_attr = stacksize; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_autoinit.c b/lib/libc_r/uthread/uthread_autoinit.c deleted file mode 100644 index 5753d434c7f..00000000000 --- a/lib/libc_r/uthread/uthread_autoinit.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * David Leonard, 1998. Public Domain. <david.leonard@csee.uq.edu.au> - * - * $OpenBSD: uthread_autoinit.c,v 1.10 2002/02/16 21:27:25 millert Exp $ - */ - -#include <stdio.h> -#include <pthread.h> -#include "pthread_private.h" - -__BEGIN_DECLS -extern void _thread_init(void); -__END_DECLS - -#ifdef DEBUG -#define init_debug(m) stderr_debug( "[init method: " m "]\n") -#else -#define init_debug(m) /* nothing */ -#endif - -/* - * Use C++'s static instance constructor to initialise threads. - */ -#ifdef __cplusplus -class Init { -public: - Init() { - init_debug("C++"); - _thread_init(); - } -}; -Init _thread_initialiser; -#endif /* C++ */ - -/* - * The a.out ld.so dynamic linker calls the function - * at symbol ".init" if it exists, just after linkage. - */ -extern void _thread_dot_init(void) asm(".init"); -void -_thread_dot_init() -{ - init_debug("a.out .init"); - _thread_init(); -} - -/* - * A GNU C installation may know how to automatically run - * constructors for other architectures. (It doesn't matter if - * we initialise multiple times.) This construct places - * the function in the __CTOR_LIST__ entry in the object, and later - * the collect2 stage of linkage will inform __main (from libgcc.a) - * to call it. - */ -#if defined(__GNUC__) /* && defined(notyet) */ /* internal compiler error??? */ -void _thread_init_constructor(void) __attribute__((constructor)); -void -_thread_init_constructor() -{ - init_debug("GNU constructor"); - _thread_init(); -} -#endif /* GNU C */ - -/* - * Dummy symbol referenced by uthread_init.o so this compilation unit - * is always loaded from archives. - */ -int _thread_autoinit_dummy_decl = 0; - diff --git a/lib/libc_r/uthread/uthread_bind.c b/lib/libc_r/uthread/uthread_bind.c deleted file mode 100644 index fca26b55558..00000000000 --- a/lib/libc_r/uthread/uthread_bind.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: uthread_bind.c,v 1.4 1999/11/25 07:01:32 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_bind.c,v 1.5 1999/08/28 00:03:26 peter Exp $ - */ -#include <sys/types.h> -#include <sys/socket.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -bind(int fd, const struct sockaddr * name, socklen_t namelen) -{ - int ret; - - if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { - ret = _thread_sys_bind(fd, name, namelen); - _FD_UNLOCK(fd, FD_RDWR); - } - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_cancel.c b/lib/libc_r/uthread/uthread_cancel.c deleted file mode 100644 index b08702ce857..00000000000 --- a/lib/libc_r/uthread/uthread_cancel.c +++ /dev/null @@ -1,245 +0,0 @@ -/* $OpenBSD: uthread_cancel.c,v 1.13 2002/05/07 05:13:17 pvalchev Exp $ */ -/* - * David Leonard <d@openbsd.org>, 1999. Public domain. - */ -#include <sys/errno.h> -#include <pthread.h> -#include "pthread_private.h" - -static void finish_cancellation(void *arg); - -int -pthread_cancel(pthread_t pthread) -{ - int ret; - - if ((ret = _find_thread(pthread)) != 0) { - /* NOTHING */ - } else if (pthread->state == PS_DEAD || pthread->state == PS_DEADLOCK - || (pthread->flags & PTHREAD_EXITING) != 0) { - ret = 0; - } else { - /* Protect the scheduling queues: */ - _thread_kern_sig_defer(); - - if (((pthread->cancelflags & PTHREAD_CANCEL_DISABLE) != 0) || - (((pthread->cancelflags & PTHREAD_CANCEL_ASYNCHRONOUS) == 0) && - ((pthread->cancelflags & PTHREAD_AT_CANCEL_POINT) == 0))) - /* Just mark it for cancellation: */ - pthread->cancelflags |= PTHREAD_CANCELLING; - else { - /* - * Check if we need to kick it back into the - * run queue: - */ - switch (pthread->state) { - case PS_RUNNING: - /* No need to resume: */ - pthread->cancelflags |= PTHREAD_CANCELLING; - break; - - case PS_SPINBLOCK: - case PS_FDR_WAIT: - case PS_FDW_WAIT: - case PS_POLL_WAIT: - case PS_SELECT_WAIT: - /* Remove these threads from the work queue: */ - if ((pthread->flags & PTHREAD_FLAGS_IN_WORKQ) - != 0) - PTHREAD_WORKQ_REMOVE(pthread); - /* Fall through: */ - case PS_SIGTHREAD: - case PS_SLEEP_WAIT: - case PS_WAIT_WAIT: - case PS_SIGSUSPEND: - case PS_SIGWAIT: - /* Interrupt and resume: */ - pthread->interrupted = 1; - pthread->cancelflags |= PTHREAD_CANCELLING; - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - break; - - case PS_JOIN: - /* - * Disconnect the thread from the joinee: - */ - if (pthread->join_status.thread != NULL) { - pthread->join_status.thread->joiner - = NULL; - pthread->join_status.thread = NULL; - } - pthread->cancelflags |= PTHREAD_CANCELLING; - PTHREAD_NEW_STATE(pthread, PS_RUNNING); - break; - - case PS_SUSPENDED: - if (pthread->suspended == SUSP_NO || - pthread->suspended == SUSP_YES || - pthread->suspended == SUSP_JOIN || - pthread->suspended == SUSP_NOWAIT) { - /* - * This thread isn't in any scheduling - * queues; just change it's state: - */ - pthread->cancelflags |= - PTHREAD_CANCELLING; - PTHREAD_SET_STATE(pthread, PS_RUNNING); - break; - } - /* FALLTHROUGH */ - case PS_MUTEX_WAIT: - case PS_COND_WAIT: - case PS_FDLR_WAIT: - case PS_FDLW_WAIT: - case PS_FILE_WAIT: - /* - * Threads in these states may be in queues. - * In order to preserve queue integrity, the - * cancelled thread must remove itself from the - * queue. Mark the thread as interrupted and - * needing cancellation, and set the state to - * running. When the thread resumes, it will - * remove itself from the queue and call the - * cancellation completion routine. - */ - pthread->interrupted = 1; - pthread->cancelflags |= PTHREAD_CANCEL_NEEDED; - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - pthread->continuation = finish_cancellation; - break; - - case PS_DEAD: - case PS_DEADLOCK: - case PS_STATE_MAX: - /* Ignore - only here to silence -Wall: */ - break; - } - } - - /* Unprotect the scheduling queues: */ - _thread_kern_sig_undefer(); - - ret = 0; - } - return (ret); -} - -int -pthread_setcancelstate(int state, int *oldstate) -{ - struct pthread *curthread = _get_curthread(); - int ostate; - int ret; - - ostate = curthread->cancelflags & PTHREAD_CANCEL_DISABLE; - - switch (state) { - case PTHREAD_CANCEL_ENABLE: - if (oldstate != NULL) - *oldstate = ostate; - curthread->cancelflags &= ~PTHREAD_CANCEL_DISABLE; - if ((curthread->cancelflags & PTHREAD_CANCEL_ASYNCHRONOUS) != 0) - pthread_testcancel(); - ret = 0; - break; - case PTHREAD_CANCEL_DISABLE: - if (oldstate != NULL) - *oldstate = ostate; - curthread->cancelflags |= PTHREAD_CANCEL_DISABLE; - ret = 0; - break; - default: - ret = EINVAL; - } - - return (ret); -} - - -int -pthread_setcanceltype(int type, int *oldtype) -{ - struct pthread *curthread = _get_curthread(); - int otype; - int ret; - - otype = curthread->cancelflags & PTHREAD_CANCEL_ASYNCHRONOUS; - switch (type) { - case PTHREAD_CANCEL_ASYNCHRONOUS: - if (oldtype != NULL) - *oldtype = otype; - curthread->cancelflags |= PTHREAD_CANCEL_ASYNCHRONOUS; - pthread_testcancel(); - ret = 0; - break; - case PTHREAD_CANCEL_DEFERRED: - if (oldtype != NULL) - *oldtype = otype; - curthread->cancelflags &= ~PTHREAD_CANCEL_ASYNCHRONOUS; - ret = 0; - break; - default: - ret = EINVAL; - } - - return (ret); -} - -void -pthread_testcancel(void) -{ - struct pthread *curthread = _get_curthread(); - - if (((curthread->cancelflags & PTHREAD_CANCEL_DISABLE) == 0) && - ((curthread->cancelflags & PTHREAD_CANCELLING) != 0) && - ((curthread->flags & PTHREAD_EXITING) == 0)) { - /* - * It is possible for this thread to be swapped out - * while performing cancellation; do not allow it - * to be cancelled again. - */ - curthread->cancelflags &= ~PTHREAD_CANCELLING; -#ifdef notyet - _thread_exit_cleanup(); -#endif - pthread_exit(PTHREAD_CANCELED); - PANIC("cancel"); - } -} - -void -_thread_enter_cancellation_point(void) -{ - struct pthread *curthread = _get_curthread(); - - /* Look for a cancellation before we block: */ - pthread_testcancel(); - curthread->cancelflags |= PTHREAD_AT_CANCEL_POINT; -} - -void -_thread_leave_cancellation_point(void) -{ - struct pthread *curthread = _get_curthread(); - - curthread->cancelflags &= ~PTHREAD_AT_CANCEL_POINT; - /* Look for a cancellation after we unblock: */ - pthread_testcancel(); -} - -static void -finish_cancellation(void *arg) -{ - struct pthread *curthread = _get_curthread(); - - curthread->continuation = NULL; - curthread->interrupted = 0; - - if ((curthread->cancelflags & PTHREAD_CANCEL_NEEDED) != 0) { - curthread->cancelflags &= ~PTHREAD_CANCEL_NEEDED; -#ifdef notyet - _thread_exit_cleanup(); -#endif - pthread_exit(PTHREAD_CANCELED); - } -} diff --git a/lib/libc_r/uthread/uthread_clean.c b/lib/libc_r/uthread/uthread_clean.c deleted file mode 100644 index ed6df7d70b6..00000000000 --- a/lib/libc_r/uthread/uthread_clean.c +++ /dev/null @@ -1,72 +0,0 @@ -/* $OpenBSD: uthread_clean.c,v 1.4 2001/08/21 19:24:53 fgsch Exp $ */ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_clean.c,v 1.4 1999/08/28 00:03:26 peter Exp $ - */ -#include <signal.h> -#include <errno.h> -#include <stdlib.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -void -pthread_cleanup_push(void (*routine) (void *), void *routine_arg) -{ - struct pthread *curthread = _get_curthread(); - struct pthread_cleanup *new; - - if ((new = (struct pthread_cleanup *) malloc(sizeof(struct pthread_cleanup))) != NULL) { - new->routine = routine; - new->routine_arg = routine_arg; - new->next = curthread->cleanup; - - curthread->cleanup = new; - } -} - -void -pthread_cleanup_pop(int execute) -{ - struct pthread *curthread = _get_curthread(); - struct pthread_cleanup *old; - - if ((old = curthread->cleanup) != NULL) { - curthread->cleanup = old->next; - if (execute) { - old->routine(old->routine_arg); - } - free(old); - } -} - -#endif diff --git a/lib/libc_r/uthread/uthread_close.c b/lib/libc_r/uthread/uthread_close.c deleted file mode 100644 index 87b86611469..00000000000 --- a/lib/libc_r/uthread/uthread_close.c +++ /dev/null @@ -1,116 +0,0 @@ -/* $OpenBSD: uthread_close.c,v 1.8 2000/10/04 05:52:34 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_close.c,v 1.7 1999/08/28 00:03:26 peter Exp $ - */ -#include <errno.h> -#include <stdlib.h> -#include <unistd.h> -#include <fcntl.h> -#include <sys/stat.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -close(int fd) -{ - int flags; - int ret; - struct stat sb; - struct fd_table_entry *entry; - - /* This is a cancelation point: */ - _thread_enter_cancellation_point(); - - if ((fd == _thread_kern_pipe[0]) || (fd == _thread_kern_pipe[1])) { - /* - * Don't allow silly programs to close the kernel pipe. - */ - errno = EBADF; - ret = -1; - } - /* - * Lock the file descriptor while the file is closed and get - * the file descriptor status: - */ - else if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { - /* - * Check if the file should be left as blocking. - * - * This is so that the file descriptors shared with a parent - * process aren't left set to non-blocking if the child - * closes them prior to exit. An example where this causes - * problems with /bin/sh is when a child closes stdin. - * - * Setting a file as blocking causes problems if a threaded - * parent accesses the file descriptor before the child exits. - * Once the threaded parent receives a SIGCHLD then it resets - * all of its files to non-blocking, and so it is then safe - * to access them. - * - * Pipes are not set to blocking when they are closed, as - * the parent and child will normally close the file - * descriptor of the end of the pipe that they are not - * using, which would then cause any reads to block - * indefinitely. - * - * Files that we cannot fstat are probably not regular - * so we don't bother with them. - */ - - if ((_thread_sys_fstat(fd, &sb) == 0) && - ((S_ISREG(sb.st_mode) || S_ISCHR(sb.st_mode)) && - (_thread_fd_table[fd]->flags & O_NONBLOCK) == 0)) - { - /* Get the current flags: */ - flags = _thread_sys_fcntl(fd, F_GETFL, NULL); - /* Clear the nonblocking file descriptor flag: */ - _thread_sys_fcntl(fd, F_SETFL, flags & ~O_NONBLOCK); - } - - /* XXX: Assumes well behaved threads. */ - /* XXX: Defer real close to avoid race condition */ - entry = _thread_fd_table[fd]; - _thread_fd_table[fd] = NULL; - free(entry); - - /* Close the file descriptor: */ - ret = _thread_sys_close(fd); - } - - /* No longer in a cancellation point: */ - _thread_leave_cancellation_point(); - - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_cond.c b/lib/libc_r/uthread/uthread_cond.c deleted file mode 100644 index dc46e26127d..00000000000 --- a/lib/libc_r/uthread/uthread_cond.c +++ /dev/null @@ -1,709 +0,0 @@ -/* $OpenBSD: uthread_cond.c,v 1.13 2002/06/04 00:09:07 deraadt Exp $ */ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_cond.c,v 1.18 1999/08/30 00:02:07 deischen Exp $ - */ -#include <stdlib.h> -#include <errno.h> -#include <string.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* - * Prototypes - */ -static inline pthread_t cond_queue_deq(pthread_cond_t); -static inline void cond_queue_remove(pthread_cond_t, pthread_t); -static inline void cond_queue_enq(pthread_cond_t, pthread_t); - -/* Reinitialize a condition variable to defaults. */ -int -_cond_reinit(pthread_cond_t *cond) -{ - int ret = 0; - - if (cond == NULL) - ret = EINVAL; - else if (*cond == NULL) - ret = pthread_cond_init(cond, NULL); - else { - /* - * Initialize the condition variable structure: - */ - TAILQ_INIT(&(*cond)->c_queue); - (*cond)->c_flags = COND_FLAGS_INITED; - (*cond)->c_type = COND_TYPE_FAST; - (*cond)->c_mutex = NULL; - (*cond)->c_seqno = 0; - _SPINLOCK_INIT(&(*cond)->lock); - } - return (ret); -} - -int -pthread_cond_init(pthread_cond_t * cond, const pthread_condattr_t * cond_attr) -{ - enum pthread_cond_type type; - pthread_cond_t pcond; - int rval = 0; - - if (cond == NULL) - rval = EINVAL; - else { - /* - * Check if a pointer to a condition variable attribute - * structure was passed by the caller: - */ - if (cond_attr != NULL && *cond_attr != NULL) { - /* Default to a fast condition variable: */ - type = (*cond_attr)->c_type; - } else { - /* Default to a fast condition variable: */ - type = COND_TYPE_FAST; - } - - /* Process according to condition variable type: */ - switch (type) { - /* Fast condition variable: */ - case COND_TYPE_FAST: - /* Nothing to do here. */ - break; - - /* Trap invalid condition variable types: */ - default: - /* Return an invalid argument error: */ - rval = EINVAL; - break; - } - - /* Check for no errors: */ - if (rval == 0) { - if ((pcond = (pthread_cond_t) - malloc(sizeof(struct pthread_cond))) == NULL) { - rval = ENOMEM; - } else { - /* - * Initialise the condition variable - * structure: - */ - TAILQ_INIT(&pcond->c_queue); - pcond->c_flags |= COND_FLAGS_INITED; - pcond->c_type = type; - pcond->c_mutex = NULL; - pcond->c_seqno = 0; - _SPINLOCK_INIT(&pcond->lock); - *cond = pcond; - } - } - } - /* Return the completion status: */ - return (rval); -} - -int -pthread_cond_destroy(pthread_cond_t * cond) -{ - int rval = 0; - - if (cond == NULL || *cond == NULL) - rval = EINVAL; - else { - /* Lock the condition variable structure: */ - _SPINLOCK(&(*cond)->lock); - - /* - * Free the memory allocated for the condition - * variable structure: - */ - free(*cond); - - /* - * NULL the caller's pointer now that the condition - * variable has been destroyed: - */ - *cond = NULL; - } - /* Return the completion status: */ - return (rval); -} - -int -pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex) -{ - struct pthread *curthread = _get_curthread(); - int rval = 0; - int done = 0; - int interrupted = 0; - int seqno; - - _thread_enter_cancellation_point(); - - if (cond == NULL) { - _thread_leave_cancellation_point(); - return (EINVAL); - } - - /* - * If the condition variable is statically initialized, - * perform the dynamic initialization: - */ - if (*cond == NULL && - (rval = pthread_cond_init(cond, NULL)) != 0) { - _thread_leave_cancellation_point(); - return (rval); - } - - /* - * Enter a loop waiting for a condition signal or broadcast - * to wake up this thread. A loop is needed in case the waiting - * thread is interrupted by a signal to execute a signal handler. - * It is not (currently) possible to remain in the waiting queue - * while running a handler. Instead, the thread is interrupted - * and backed out of the waiting queue prior to executing the - * signal handler. - */ - do { - /* Lock the condition variable structure: */ - _SPINLOCK(&(*cond)->lock); - - /* - * If the condvar was statically allocated, properly - * initialize the tail queue. - */ - if (((*cond)->c_flags & COND_FLAGS_INITED) == 0) { - TAILQ_INIT(&(*cond)->c_queue); - (*cond)->c_flags |= COND_FLAGS_INITED; - } - - /* Process according to condition variable type: */ - switch ((*cond)->c_type) { - /* Fast condition variable: */ - case COND_TYPE_FAST: - if ((mutex == NULL) || (((*cond)->c_mutex != NULL) && - ((*cond)->c_mutex != *mutex))) { - /* Unlock the condition variable structure: */ - _SPINUNLOCK(&(*cond)->lock); - - /* Return invalid argument error: */ - rval = EINVAL; - } else { - /* Reset the timeout and interrupted flags: */ - curthread->timeout = 0; - curthread->interrupted = 0; - - /* - * Queue the running thread for the condition - * variable: - */ - cond_queue_enq(*cond, curthread); - - /* Remember the mutex and sequence number: */ - (*cond)->c_mutex = *mutex; - seqno = (*cond)->c_seqno; - - /* Wait forever: */ - curthread->wakeup_time.tv_sec = -1; - - /* Unlock the mutex: */ - if ((rval = _mutex_cv_unlock(mutex)) != 0) { - /* - * Cannot unlock the mutex, so remove - * the running thread from the condition - * variable queue: - */ - cond_queue_remove(*cond, curthread); - - /* Check for no more waiters: */ - if (TAILQ_FIRST(&(*cond)->c_queue) == - NULL) - (*cond)->c_mutex = NULL; - - /* Unlock the condition variable structure: */ - _SPINUNLOCK(&(*cond)->lock); - } else { - /* - * Schedule the next thread and unlock - * the condition variable structure: - */ - _thread_kern_sched_state_unlock(PS_COND_WAIT, - &(*cond)->lock, __FILE__, __LINE__); - - done = (seqno != (*cond)->c_seqno); - - interrupted = curthread->interrupted; - - /* - * Check if the wait was interrupted - * (canceled) or needs to be resumed - * after handling a signal. - */ - if (interrupted != 0) { - /* - * Lock the mutex and ignore any - * errors. Note that even - * though this thread may have - * been canceled, POSIX requires - * that the mutex be reacquired - * prior to cancellation. - */ - (void)_mutex_cv_lock(mutex); - } else { - /* - * Lock the condition variable - * while removing the thread. - */ - _SPINLOCK(&(*cond)->lock); - - cond_queue_remove(*cond, - curthread); - - /* Check for no more waiters: */ - if (TAILQ_FIRST(&(*cond)->c_queue) == NULL) - (*cond)->c_mutex = NULL; - - _SPINUNLOCK(&(*cond)->lock); - - /* Lock the mutex: */ - rval = _mutex_cv_lock(mutex); - } - } - } - break; - - /* Trap invalid condition variable types: */ - default: - /* Unlock the condition variable structure: */ - _SPINUNLOCK(&(*cond)->lock); - - /* Return an invalid argument error: */ - rval = EINVAL; - break; - } - - if ((interrupted != 0) && (curthread->continuation != NULL)) - curthread->continuation((void *) curthread); - } while ((done == 0) && (rval == 0)); - - _thread_leave_cancellation_point(); - - /* Return the completion status: */ - return (rval); -} - -int -pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex, - const struct timespec * abstime) -{ - struct pthread *curthread = _get_curthread(); - int rval = 0; - int done = 0; - int interrupted = 0; - int seqno; - - _thread_enter_cancellation_point(); - - if (cond == NULL || - abstime == NULL || abstime->tv_sec < 0 || abstime->tv_nsec < 0 || - abstime->tv_nsec >= 1000000000) { - _thread_leave_cancellation_point(); - return (EINVAL); - } - /* - * If the condition variable is statically initialized, perform dynamic - * initialization. - */ - if (*cond == NULL && (rval = pthread_cond_init(cond, NULL)) != 0) { - _thread_leave_cancellation_point(); - return (rval); - } - - /* - * Enter a loop waiting for a condition signal or broadcast - * to wake up this thread. A loop is needed in case the waiting - * thread is interrupted by a signal to execute a signal handler. - * It is not (currently) possible to remain in the waiting queue - * while running a handler. Instead, the thread is interrupted - * and backed out of the waiting queue prior to executing the - * signal handler. - */ - do { - /* Lock the condition variable structure: */ - _SPINLOCK(&(*cond)->lock); - - /* - * If the condvar was statically allocated, properly - * initialize the tail queue. - */ - if (((*cond)->c_flags & COND_FLAGS_INITED) == 0) { - TAILQ_INIT(&(*cond)->c_queue); - (*cond)->c_flags |= COND_FLAGS_INITED; - } - - /* Process according to condition variable type: */ - switch ((*cond)->c_type) { - /* Fast condition variable: */ - case COND_TYPE_FAST: - if ((mutex == NULL) || (((*cond)->c_mutex != NULL) && - ((*cond)->c_mutex != *mutex))) { - /* Return invalid argument error: */ - rval = EINVAL; - - /* Unlock the condition variable structure: */ - _SPINUNLOCK(&(*cond)->lock); - } else { - /* Set the wakeup time: */ - curthread->wakeup_time.tv_sec = - abstime->tv_sec; - curthread->wakeup_time.tv_nsec = - abstime->tv_nsec; - - /* Reset the timeout and interrupted flags: */ - curthread->timeout = 0; - curthread->interrupted = 0; - - /* - * Queue the running thread for the condition - * variable: - */ - cond_queue_enq(*cond, curthread); - - /* Remember the mutex and sequence number: */ - (*cond)->c_mutex = *mutex; - seqno = (*cond)->c_seqno; - - /* Unlock the mutex: */ - if ((rval = _mutex_cv_unlock(mutex)) != 0) { - /* - * Cannot unlock the mutex, so remove - * the running thread from the condition - * variable queue: - */ - cond_queue_remove(*cond, curthread); - - /* Check for no more waiters: */ - if (TAILQ_FIRST(&(*cond)->c_queue) == NULL) - (*cond)->c_mutex = NULL; - - /* Unlock the condition variable structure: */ - _SPINUNLOCK(&(*cond)->lock); - } else { - /* - * Schedule the next thread and unlock - * the condition variable structure: - */ - _thread_kern_sched_state_unlock(PS_COND_WAIT, - &(*cond)->lock, __FILE__, __LINE__); - - done = (seqno != (*cond)->c_seqno); - - interrupted = curthread->interrupted; - - /* - * Check if the wait was interrupted - * (canceled) or needs to be resumed - * after handling a signal. - */ - if (interrupted != 0) { - /* - * Lock the mutex and ignore any - * errors. Note that even - * though this thread may have - * been canceled, POSIX requires - * that the mutex be reacquired - * prior to cancellation. - */ - (void)_mutex_cv_lock(mutex); - } else { - /* - * Lock the condition variable - * while removing the thread. - */ - _SPINLOCK(&(*cond)->lock); - - cond_queue_remove(*cond, - curthread); - - /* Check for no more waiters: */ - if (TAILQ_FIRST(&(*cond)->c_queue) == NULL) - (*cond)->c_mutex = NULL; - - _SPINUNLOCK(&(*cond)->lock); - - /* Lock the mutex: */ - rval = _mutex_cv_lock(mutex); - - /* - * Return ETIMEDOUT if the wait - * timed out and there wasn't an - * error locking the mutex: - */ - if ((curthread->timeout != 0) - && rval == 0) - rval = ETIMEDOUT; - - } - } - } - break; - - /* Trap invalid condition variable types: */ - default: - /* Unlock the condition variable structure: */ - _SPINUNLOCK(&(*cond)->lock); - - /* Return an invalid argument error: */ - rval = EINVAL; - break; - } - - if ((interrupted != 0) && (curthread->continuation != NULL)) - curthread->continuation((void *) curthread); - } while ((done == 0) && (rval == 0)); - - _thread_leave_cancellation_point(); - - /* Return the completion status: */ - return (rval); -} - -int -pthread_cond_signal(pthread_cond_t * cond) -{ - int rval = 0; - pthread_t pthread; - - if (cond == NULL) - rval = EINVAL; - /* - * If the condition variable is statically initialized, perform dynamic - * initialization. - */ - else if (*cond != NULL || (rval = pthread_cond_init(cond, NULL)) == 0) { - /* - * Defer signals to protect the scheduling queues - * from access by the signal handler: - */ - _thread_kern_sig_defer(); - - /* Lock the condition variable structure: */ - _SPINLOCK(&(*cond)->lock); - - /* Process according to condition variable type: */ - switch ((*cond)->c_type) { - /* Fast condition variable: */ - case COND_TYPE_FAST: - /* Increment the sequence number: */ - (*cond)->c_seqno++; - - if ((pthread = cond_queue_deq(*cond)) != NULL) { - /* - * Unless the thread is currently suspended, - * allow it to run. If the thread is suspended, - * make a note that the thread isn't in a wait - * queue any more. - */ - if (pthread->state != PS_SUSPENDED) - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - else - pthread->suspended = SUSP_NOWAIT; - } - - /* Check for no more waiters: */ - if (TAILQ_FIRST(&(*cond)->c_queue) == NULL) - (*cond)->c_mutex = NULL; - break; - - /* Trap invalid condition variable types: */ - default: - /* Return an invalid argument error: */ - rval = EINVAL; - break; - } - - /* Unlock the condition variable structure: */ - _SPINUNLOCK(&(*cond)->lock); - - /* - * Undefer and handle pending signals, yielding if - * necessary: - */ - _thread_kern_sig_undefer(); - } - - /* Return the completion status: */ - return (rval); -} - -int -pthread_cond_broadcast(pthread_cond_t * cond) -{ - int rval = 0; - pthread_t pthread; - - if (cond == NULL) - rval = EINVAL; - /* - * If the condition variable is statically initialized, perform dynamic - * initialization. - */ - else if (*cond != NULL || (rval = pthread_cond_init(cond, NULL)) == 0) { - /* - * Defer signals to protect the scheduling queues - * from access by the signal handler: - */ - _thread_kern_sig_defer(); - - /* Lock the condition variable structure: */ - _SPINLOCK(&(*cond)->lock); - - /* Process according to condition variable type: */ - switch ((*cond)->c_type) { - /* Fast condition variable: */ - case COND_TYPE_FAST: - /* Increment the sequence number: */ - (*cond)->c_seqno++; - - /* - * Enter a loop to bring all threads off the - * condition queue: - */ - while ((pthread = cond_queue_deq(*cond)) != NULL) { - /* - * Unless the thread is currently suspended, - * allow it to run. If the thread is suspended, - * make a note that the thread isn't in a wait - * queue any more. - */ - if (pthread->state != PS_SUSPENDED) - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - else - pthread->suspended = SUSP_NOWAIT; - } - - /* There are no more waiting threads: */ - (*cond)->c_mutex = NULL; - break; - - /* Trap invalid condition variable types: */ - default: - /* Return an invalid argument error: */ - rval = EINVAL; - break; - } - - /* Unlock the condition variable structure: */ - _SPINUNLOCK(&(*cond)->lock); - - /* - * Undefer and handle pending signals, yielding if - * necessary: - */ - _thread_kern_sig_undefer(); - } - - /* Return the completion status: */ - return (rval); -} - -/* - * Dequeue a waiting thread from the head of a condition queue in - * descending priority order. - */ -static inline pthread_t -cond_queue_deq(pthread_cond_t cond) -{ - pthread_t pthread; - - while ((pthread = TAILQ_FIRST(&cond->c_queue)) != NULL) { - TAILQ_REMOVE(&cond->c_queue, pthread, sqe); - pthread->flags &= ~PTHREAD_FLAGS_IN_CONDQ; - if ((pthread->timeout == 0) && (pthread->interrupted == 0)) - /* - * Only exit the loop when we find a thread - * that hasn't timed out or been canceled; - * those threads are already running and don't - * need their run state changed. - */ - break; - } - - return(pthread); -} - -/* - * Remove a waiting thread from a condition queue in descending priority - * order. - */ -static inline void -cond_queue_remove(pthread_cond_t cond, pthread_t pthread) -{ - /* - * Because pthread_cond_timedwait() can timeout as well - * as be signaled by another thread, it is necessary to - * guard against removing the thread from the queue if - * it isn't in the queue. - */ - if (pthread->flags & PTHREAD_FLAGS_IN_CONDQ) { - TAILQ_REMOVE(&cond->c_queue, pthread, sqe); - pthread->flags &= ~PTHREAD_FLAGS_IN_CONDQ; - } -} - -/* - * Enqueue a waiting thread to a condition queue in descending priority - * order. - */ -static inline void -cond_queue_enq(pthread_cond_t cond, pthread_t pthread) -{ - pthread_t tid = TAILQ_LAST(&cond->c_queue, cond_head); - - PTHREAD_ASSERT_NOT_IN_SYNCQ(pthread); - - /* - * For the common case of all threads having equal priority, - * we perform a quick check against the priority of the thread - * at the tail of the queue. - */ - if ((tid == NULL) || (pthread->active_priority <= tid->active_priority)) - TAILQ_INSERT_TAIL(&cond->c_queue, pthread, sqe); - else { - tid = TAILQ_FIRST(&cond->c_queue); - while (pthread->active_priority <= tid->active_priority) - tid = TAILQ_NEXT(tid, sqe); - TAILQ_INSERT_BEFORE(tid, pthread, sqe); - } - pthread->flags |= PTHREAD_FLAGS_IN_CONDQ; - pthread->data.cond = cond; -} -#endif diff --git a/lib/libc_r/uthread/uthread_condattr_destroy.c b/lib/libc_r/uthread/uthread_condattr_destroy.c deleted file mode 100644 index 08769b87dd3..00000000000 --- a/lib/libc_r/uthread/uthread_condattr_destroy.c +++ /dev/null @@ -1,54 +0,0 @@ -/* $OpenBSD: uthread_condattr_destroy.c,v 1.4 2002/11/07 02:56:20 marc Exp $ */ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_condattr_destroy.c,v 1.4 1999/08/28 00:03:27 peter Exp $ - */ -#include <stdlib.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_condattr_destroy(pthread_condattr_t *attr) -{ - int ret; - if (attr == NULL || *attr == NULL) { - ret = EINVAL; - } else { - free(*attr); - *attr = NULL; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_condattr_init.c b/lib/libc_r/uthread/uthread_condattr_init.c deleted file mode 100644 index 298989ccef4..00000000000 --- a/lib/libc_r/uthread/uthread_condattr_init.c +++ /dev/null @@ -1,59 +0,0 @@ -/* $OpenBSD: uthread_condattr_init.c,v 1.3 1999/11/25 07:01:33 d Exp $ */ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_condattr_init.c,v 1.4 1999/08/28 00:03:27 peter Exp $ - */ -#include <string.h> -#include <stdlib.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_condattr_init(pthread_condattr_t *attr) -{ - int ret; - pthread_condattr_t pattr; - - if ((pattr = (pthread_condattr_t) - malloc(sizeof(struct pthread_cond_attr))) == NULL) { - ret = ENOMEM; - } else { - memcpy(pattr, &pthread_condattr_default, - sizeof(struct pthread_cond_attr)); - *attr = pattr; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_connect.c b/lib/libc_r/uthread/uthread_connect.c deleted file mode 100644 index ad0a6ea8921..00000000000 --- a/lib/libc_r/uthread/uthread_connect.c +++ /dev/null @@ -1,80 +0,0 @@ -/* $OpenBSD: uthread_connect.c,v 1.4 2001/08/21 19:24:53 fgsch Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_connect.c,v 1.6 1999/08/28 00:03:28 peter Exp $ - */ -#include <errno.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <fcntl.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -connect(int fd, const struct sockaddr * name, socklen_t namelen) -{ - struct pthread *curthread = _get_curthread(); - struct sockaddr tmpname; - int errnolen, ret, tmpnamelen; - - if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { - if ((ret = _thread_sys_connect(fd, name, namelen)) < 0) { - if (!(_thread_fd_table[fd]->flags & O_NONBLOCK) && - ((errno == EWOULDBLOCK) || (errno == EINPROGRESS) || - (errno == EALREADY) || (errno == EAGAIN))) { - curthread->data.fd.fd = fd; - - /* Set the timeout: */ - _thread_kern_set_timeout(NULL); - _thread_kern_sched_state(PS_FDW_WAIT, __FILE__, __LINE__); - - tmpnamelen = sizeof(tmpname); - /* 0 now lets see if it really worked */ - if (((ret = _thread_sys_getpeername(fd, &tmpname, &tmpnamelen)) < 0) && (errno == ENOTCONN)) { - - /* - * Get the error, this function - * should not fail - */ - errnolen = sizeof(errno); - _thread_sys_getsockopt(fd, SOL_SOCKET, SO_ERROR, &errno, &errnolen); - } - } else { - ret = -1; - } - } - _FD_UNLOCK(fd, FD_RDWR); - } - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_create.c b/lib/libc_r/uthread/uthread_create.c deleted file mode 100644 index c61c1b9d515..00000000000 --- a/lib/libc_r/uthread/uthread_create.c +++ /dev/null @@ -1,242 +0,0 @@ -/* $OpenBSD: uthread_create.c,v 1.18 2001/12/31 18:23:15 fgsch Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_create.c,v 1.19 1999/08/28 00:03:28 peter Exp $ - */ -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <fcntl.h> -#include <unistd.h> -#include <sys/time.h> -#include <sys/types.h> -#include <sys/mman.h> -#ifdef _THREAD_SAFE -#include <machine/reg.h> -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_create(pthread_t * thread, const pthread_attr_t * attr, - void *(*start_routine) (void *), void *arg) -{ - struct pthread *curthread = _get_curthread(); - struct itimerval itimer; - int f_gc = 0; - int ret = 0; - pthread_t gc_thread; - pthread_t new_thread; - pthread_attr_t pattr; - struct stack *stack; - - /* - * Locking functions in libc are required when there are - * threads other than the initial thread. - */ - __isthreaded = 1; - - /* Allocate memory for the thread structure: */ - if ((new_thread = (pthread_t) malloc(sizeof(struct pthread))) == NULL) { - /* Insufficient memory to create a thread: */ - ret = EAGAIN; - } else { - /* Check if default thread attributes are required: */ - if (attr == NULL || *attr == NULL) { - /* Use the default thread attributes: */ - pattr = &pthread_attr_default; - } else { - pattr = *attr; - } - /* Check if a stack was specified in the thread attributes: */ - if ((stack = pattr->stackaddr_attr) != NULL) { - } - /* Allocate a stack: */ - else { - stack = _thread_stack_alloc(pattr->stackaddr_attr, - pattr->stacksize_attr); - if (stack == NULL) { - ret = EAGAIN; - free(new_thread); - } - } - - /* Check for errors: */ - if (ret != 0) { - } else { - /* Initialise the thread structure: */ - memset(new_thread, 0, sizeof(struct pthread)); - _SPINLOCK_INIT(&new_thread->lock); - new_thread->slice_usec = -1; - new_thread->sig_saved = 0; - new_thread->stack = stack; - new_thread->start_routine = start_routine; - new_thread->arg = arg; - - new_thread->cancelflags = PTHREAD_CANCEL_ENABLE | - PTHREAD_CANCEL_DEFERRED; - - /* - * Write a magic value to the thread structure - * to help identify valid ones: - */ - new_thread->magic = PTHREAD_MAGIC; - - /* Initialise the thread for signals: */ - new_thread->sigmask = curthread->sigmask; - new_thread->sigmask_seqno = 0; - - /* - * Set up new stack frame so that it 'returns' to - * the beginning of _thread_start() after it is - * switched to: - */ - _thread_machdep_init(&new_thread->_machdep, - stack->base, stack->size, _thread_start); - - /* Copy the thread attributes: */ - memcpy(&new_thread->attr, pattr, sizeof(struct pthread_attr)); - - /* - * Check if this thread is to inherit the scheduling - * attributes from its parent: - */ - if (new_thread->attr.flags & PTHREAD_INHERIT_SCHED) { - /* Copy the scheduling attributes: */ - new_thread->base_priority = - curthread->base_priority & - ~PTHREAD_SIGNAL_PRIORITY; - new_thread->attr.prio = - curthread->base_priority & - ~PTHREAD_SIGNAL_PRIORITY; - new_thread->attr.sched_policy = - curthread->attr.sched_policy; - } else { - /* - * Use just the thread priority, leaving the - * other scheduling attributes as their - * default values: - */ - new_thread->base_priority = - new_thread->attr.prio; - } - new_thread->active_priority = new_thread->base_priority; - new_thread->inherited_priority = 0; - - /* Initialize joiner to NULL (no joiner): */ - new_thread->joiner = NULL; - - /* Initialize the mutex queue: */ - TAILQ_INIT(&new_thread->mutexq); - - /* Initialise hooks in the thread structure: */ - new_thread->specific_data = NULL; - new_thread->cleanup = NULL; - new_thread->flags = 0; - new_thread->poll_data.nfds = 0; - new_thread->poll_data.fds = NULL; - new_thread->continuation = NULL; - - /* - * Defer signals to protect the scheduling queues - * from access by the signal handler: - */ - _thread_kern_sig_defer(); - - /* - * Check if the garbage collector thread - * needs to be started. - */ - f_gc = (TAILQ_FIRST(&_thread_list) == _thread_initial); - - /* Add the thread to the linked list of all threads: */ - TAILQ_INSERT_HEAD(&_thread_list, new_thread, tle); - - if (pattr->suspend == PTHREAD_CREATE_SUSPENDED) - new_thread->state = PS_SUSPENDED; - else { - new_thread->state = PS_RUNNING; - PTHREAD_PRIOQ_INSERT_TAIL(new_thread); - } - - /* - * Undefer and handle pending signals, yielding - * if necessary. - */ - _thread_kern_sig_undefer(); - - /* Return a pointer to the thread structure: */ - if (thread != NULL) - (*thread) = new_thread; - - if (f_gc != 0) { - /* Install the scheduling timer: */ - itimer.it_interval.tv_sec = 0; - itimer.it_interval.tv_usec = _clock_res_usec; - itimer.it_value = itimer.it_interval; - if (setitimer(_ITIMER_SCHED_TIMER, &itimer, - NULL) != 0) - PANIC("Cannot set interval timer"); - } - - /* Schedule the new user thread: */ - _thread_kern_sched(NULL); - - /* - * Start a garbage collector thread - * if necessary. - */ - if (f_gc && pthread_create(&gc_thread,NULL, - _thread_gc,NULL) != 0) - PANIC("Can't create gc thread"); - - } - } - - /* Return the status: */ - return (ret); -} - -void -_thread_start(void) -{ - struct pthread *curthread = _get_curthread(); - - /* We just left the scheduler via longjmp: */ - _thread_kern_in_sched = 0; - - /* Run the current thread's start routine with argument: */ - pthread_exit(curthread->start_routine(curthread->arg)); - - /* This point should never be reached. */ - PANIC("Thread has resumed after exit"); -} -#endif diff --git a/lib/libc_r/uthread/uthread_detach.c b/lib/libc_r/uthread/uthread_detach.c deleted file mode 100644 index 92d41efedc4..00000000000 --- a/lib/libc_r/uthread/uthread_detach.c +++ /dev/null @@ -1,91 +0,0 @@ -/* $OpenBSD: uthread_detach.c,v 1.8 2002/03/07 22:36:03 fgsch Exp $ */ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_detach.c,v 1.10 1999/08/28 00:03:28 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_detach(pthread_t pthread) -{ - int rval = 0; - - /* Check for invalid calling parameters: */ - if (pthread == NULL || pthread->magic != PTHREAD_MAGIC) - /* Return an invalid argument error: */ - rval = EINVAL; - - /* Check if the thread has not been detached: */ - else if ((pthread->attr.flags & PTHREAD_DETACHED) == 0) { - /* Flag the thread as detached: */ - pthread->attr.flags |= PTHREAD_DETACHED; - - /* - * Defer signals to protect the scheduling queues from - * access by the signal handler: - */ - _thread_kern_sig_defer(); - - /* Check if there is a joiner: */ - if (pthread->joiner != NULL) { - struct pthread *joiner = pthread->joiner; - - /* Make the thread runnable: */ - PTHREAD_NEW_STATE(joiner, PS_RUNNING); - - /* Set the return value for the woken thread: */ - joiner->join_status.error = ESRCH; - joiner->join_status.ret = NULL; - joiner->join_status.thread = NULL; - - /* - * Disconnect the joiner from the thread being detached: - */ - pthread->joiner = NULL; - } - - /* - * Undefer and handle pending signals, yielding if a - * scheduling signal occurred while in the critical region. - */ - _thread_kern_sig_undefer(); - } else - /* Return an error: */ - rval = EINVAL; - - /* Return the completion status: */ - return (rval); -} -#endif diff --git a/lib/libc_r/uthread/uthread_dup.c b/lib/libc_r/uthread/uthread_dup.c deleted file mode 100644 index 8aba9a1dba6..00000000000 --- a/lib/libc_r/uthread/uthread_dup.c +++ /dev/null @@ -1,71 +0,0 @@ -/* $OpenBSD: uthread_dup.c,v 1.3 1999/11/25 07:01:33 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_dup.c,v 1.5 1999/08/28 00:03:29 peter Exp $ - */ -#include <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -dup(int fd) -{ - int ret; - - /* Lock the file descriptor: */ - if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { - /* Perform the 'dup' syscall: */ - if ((ret = _thread_sys_dup(fd)) < 0) { - } - /* Initialise the file descriptor table entry: */ - else if (_thread_fd_table_init(ret) != 0) { - /* Quietly close the file: */ - _thread_sys_close(ret); - - /* Reset the file descriptor: */ - ret = -1; - } else { - /* - * Save the file open flags so that they can be - * checked later: - */ - _thread_fd_table[ret]->flags = _thread_fd_table[fd]->flags; - } - - /* Unlock the file descriptor: */ - _FD_UNLOCK(fd, FD_RDWR); - } - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_dup2.c b/lib/libc_r/uthread/uthread_dup2.c deleted file mode 100644 index 5809c4c66b7..00000000000 --- a/lib/libc_r/uthread/uthread_dup2.c +++ /dev/null @@ -1,88 +0,0 @@ -/* $OpenBSD: uthread_dup2.c,v 1.5 2002/02/19 01:10:24 fgsch Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_dup2.c,v 1.6 1999/08/28 00:03:29 peter Exp $ - */ -#include <errno.h> -#include <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -dup2(int fd, int newfd) -{ - int ret; - int newfd_opened; - - /* Check if the file descriptor is out of range: */ - if (newfd < 0 || newfd >= _thread_dtablesize || - newfd == _thread_kern_pipe[0] || newfd == _thread_kern_pipe[1]) { - /* Return a bad file descriptor error: */ - errno = EBADF; - ret = -1; - } - - /* Lock the file descriptor: */ - else if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { - /* Lock the file descriptor: */ - if (!(newfd_opened = (_thread_fd_table[newfd] != NULL)) || - (ret = _FD_LOCK(newfd, FD_RDWR, NULL)) == 0) { - /* Perform the 'dup2' syscall: */ - if ((ret = _thread_sys_dup2(fd, newfd)) < 0) { - } - /* Initialise the file descriptor table entry: */ - else if (_thread_fd_table_init(ret) != 0) { - /* Quietly close the file: */ - _thread_sys_close(ret); - - /* Reset the file descriptor: */ - ret = -1; - } else { - /* - * Save the file open flags so that they can - * be checked later: - */ - _thread_fd_table[ret]->flags = _thread_fd_table[fd]->flags; - } - - /* Unlock the file descriptor: */ - if (newfd_opened) - _FD_UNLOCK(newfd, FD_RDWR); - } - /* Unlock the file descriptor: */ - _FD_UNLOCK(fd, FD_RDWR); - } - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_equal.c b/lib/libc_r/uthread/uthread_equal.c deleted file mode 100644 index 54da618366f..00000000000 --- a/lib/libc_r/uthread/uthread_equal.c +++ /dev/null @@ -1,45 +0,0 @@ -/* $OpenBSD: uthread_equal.c,v 1.3 1999/11/25 07:01:33 d Exp $ */ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_equal.c,v 1.3 1999/08/28 00:03:29 peter Exp $ - */ -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_equal(pthread_t t1, pthread_t t2) -{ - /* Compare the two thread pointers: */ - return (t1 == t2); -} -#endif diff --git a/lib/libc_r/uthread/uthread_execve.c b/lib/libc_r/uthread/uthread_execve.c deleted file mode 100644 index d6b9c8116b5..00000000000 --- a/lib/libc_r/uthread/uthread_execve.c +++ /dev/null @@ -1,115 +0,0 @@ -/* $OpenBSD: uthread_execve.c,v 1.6 2001/08/21 19:24:53 fgsch Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_execve.c,v 1.8 1999/08/28 00:03:30 peter Exp $ - */ -#include <errno.h> -#include <fcntl.h> -#include <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -execve(const char *name, char *const * argv, char *const * envp) -{ - struct pthread *curthread = _get_curthread(); - int flags; - int i; - int ret; - struct sigaction act; - struct sigaction oact; - struct itimerval itimer; - - /* Disable the interval timer: */ - itimer.it_interval.tv_sec = 0; - itimer.it_interval.tv_usec = 0; - itimer.it_value.tv_sec = 0; - itimer.it_value.tv_usec = 0; - setitimer(_ITIMER_SCHED_TIMER, &itimer, NULL); - - /* Close the pthread kernel pipe: */ - _thread_sys_close(_thread_kern_pipe[0]); - _thread_sys_close(_thread_kern_pipe[1]); - - /* - * Enter a loop to set all file descriptors to blocking - * if they were not created as non-blocking: - */ - for (i = 0; i < _thread_dtablesize; i++) { - /* Check if this file descriptor is in use: */ - if (_thread_fd_table[i] != NULL && - !(_thread_fd_table[i]->flags & O_NONBLOCK)) { - /* Get the current flags: */ - flags = _thread_sys_fcntl(i, F_GETFL, NULL); - /* Clear the nonblocking file descriptor flag: */ - _thread_sys_fcntl(i, F_SETFL, flags & ~O_NONBLOCK); - } - } - - /* Enter a loop to adopt the signal actions for the running thread: */ - for (i = 1; i < NSIG; i++) { - /* Check for signals which cannot be caught: */ - if (i == SIGKILL || i == SIGSTOP) { - /* Don't do anything with these signals. */ - } else { - /* Check if ignoring this signal: */ - if (_thread_sigact[i - 1].sa_handler == SIG_IGN) { - /* Continue to ignore this signal: */ - act.sa_handler = SIG_IGN; - } else { - /* Use the default handler for this signal: */ - act.sa_handler = SIG_DFL; - } - - /* Copy the mask and flags for this signal: */ - act.sa_mask = _thread_sigact[i - 1].sa_mask; - act.sa_flags = _thread_sigact[i - 1].sa_flags; - - /* Ensure the scheduling signal is masked: */ - sigaddset(&act.sa_mask, _SCHED_SIGNAL); - - /* Change the signal action for the process: */ - _thread_sys_sigaction(i, &act, &oact); - } - } - - /* Set the signal mask: */ - _thread_sys_sigprocmask(SIG_SETMASK, &curthread->sigmask, NULL); - - /* Execute the process: */ - ret = _thread_sys_execve(name, argv, envp); - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_exit.c b/lib/libc_r/uthread/uthread_exit.c deleted file mode 100644 index 91f41343583..00000000000 --- a/lib/libc_r/uthread/uthread_exit.c +++ /dev/null @@ -1,245 +0,0 @@ -/* $OpenBSD: uthread_exit.c,v 1.17 2002/11/07 02:56:20 marc Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_exit.c,v 1.12 1999/08/30 15:45:42 dt Exp $ - */ -#include <errno.h> -#include <unistd.h> -#include <fcntl.h> -#include <string.h> -#include <signal.h> -#include <sys/types.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -void -_exit(int status) -{ - int flags; - int i; - struct itimerval itimer; - - /* Disable the interval timer: */ - itimer.it_interval.tv_sec = 0; - itimer.it_interval.tv_usec = 0; - itimer.it_value.tv_sec = 0; - itimer.it_value.tv_usec = 0; - setitimer(_ITIMER_SCHED_TIMER, &itimer, NULL); - - /* Close the pthread kernel pipe: */ - _thread_sys_close(_thread_kern_pipe[0]); - _thread_sys_close(_thread_kern_pipe[1]); - - /* - * Enter a loop to set all file descriptors to blocking - * if they were not created as non-blocking: - */ - for (i = 0; i < _thread_dtablesize; i++) { - /* Check if this file descriptor is in use: */ - if (_thread_fd_table[i] != NULL && - !(_thread_fd_table[i]->flags & O_NONBLOCK)) { - /* Get the current flags: */ - flags = _thread_sys_fcntl(i, F_GETFL, NULL); - /* Clear the nonblocking file descriptor flag: */ - _thread_sys_fcntl(i, F_SETFL, flags & ~O_NONBLOCK); - } - } - - /* Call the _exit syscall: */ - _thread_sys__exit(status); -} - -static void -numlcat(char *s, int l, size_t sz) -{ - char digit[2]; - - /* Inefficient. */ - if (l < 0) { - l = -l; - strlcat(s, "-", sz); - } - if (l >= 10) - numlcat(s, l / 10, sz); - digit[0] = "0123456789"[l % 10]; - digit[1] = '\0'; - strlcat(s, digit, sz); -} - -void -_thread_exit(const char *fname, int lineno, const char *string) -{ - char s[256]; - - /* Prepare an error message string: */ - s[0] = '\0'; - strlcat(s, "pid ", sizeof s); - numlcat(s, (int)_thread_sys_getpid(), sizeof s); - strlcat(s, ": Fatal error '", sizeof s); - strlcat(s, string, sizeof s); - strlcat(s, "' at line ", sizeof s); - numlcat(s, lineno, sizeof s); - strlcat(s, " in file ", sizeof s); - strlcat(s, fname, sizeof s); - strlcat(s, " (errno = ", sizeof s); - numlcat(s, errno, sizeof s); - strlcat(s, ")\n", sizeof s); - - /* Write the string to the standard error file descriptor: */ - _thread_sys_write(2, s, strlen(s)); - - /* Force this process to exit: */ - /* XXX - Do we want abort to be conditional on _PTHREADS_INVARIANTS? */ -#if defined(_PTHREADS_INVARIANTS) - { - struct sigaction sa; - sigset_t s; - - /* Ignore everything except ABORT */ - sigfillset(&s); - sigdelset(&s, SIGABRT); - _thread_sys_sigprocmask(SIG_SETMASK, &s, NULL); - - /* Set the abort handler to default (dump core) */ - sa.sa_handler = SIG_DFL; - sigemptyset(&sa.sa_mask); - sa.sa_flags = SA_SIGINFO; - (void)_thread_sys_sigaction(SIGABRT, &sa, NULL); - (void)_thread_sys_kill(_thread_sys_getpid(), SIGABRT); - for (;;) ; - } -#else - _exit(1); -#endif -} - -void -pthread_exit(void *status) -{ - struct pthread *curthread = _get_curthread(); - pthread_t pthread; - - /* Check if this thread is already in the process of exiting: */ - if ((curthread->flags & PTHREAD_EXITING) != 0) { - PANIC("Thread has called pthread_exit() from a destructor. POSIX 1003.1 1996 s16.2.5.2 does not allow this!"); - } - - /* Flag this thread as exiting: */ - curthread->flags |= PTHREAD_EXITING; - - /* Save the return value: */ - curthread->ret = status; - - while (curthread->cleanup != NULL) { - pthread_cleanup_pop(1); - } - if (curthread->attr.cleanup_attr != NULL) { - curthread->attr.cleanup_attr(curthread->attr.arg_attr); - } - /* Check if there is thread specific data: */ - if (curthread->specific_data != NULL) { - /* Run the thread-specific data destructors: */ - _thread_cleanupspecific(); - } - - /* - * Lock the garbage collector mutex to ensure that the garbage - * collector is not using the dead thread list. - */ - if (pthread_mutex_lock(&_gc_mutex) != 0) - PANIC("Cannot lock gc mutex"); - - /* Add this thread to the list of dead threads. */ - TAILQ_INSERT_HEAD(&_dead_list, curthread, dle); - - /* - * Signal the garbage collector thread that there is something - * to clean up. - */ - if (pthread_cond_signal(&_gc_cond) != 0) - PANIC("Cannot signal gc cond"); - - /* - * Avoid a race condition where a scheduling signal can occur - * causing the garbage collector thread to run. If this happens, - * the current thread can be cleaned out from under us. - */ - _thread_kern_sig_defer(); - - /* Unlock the garbage collector mutex: */ - if (pthread_mutex_unlock(&_gc_mutex) != 0) - PANIC("Cannot unlock gc mutex"); - - /* Check if there is a thread joining this one: */ - if (curthread->joiner != NULL) { - pthread = curthread->joiner; - curthread->joiner = NULL; - - switch (pthread->suspended) { - case SUSP_JOIN: - /* - * The joining thread is suspended. Change the - * suspension state to make the thread runnable when it - * is resumed: - */ - pthread->suspended = SUSP_NO; - break; - case SUSP_NO: - /* Make the joining thread runnable: */ - PTHREAD_NEW_STATE(pthread, PS_RUNNING); - break; - default: - PANIC("Unreachable code reached"); - } - - /* Set the return value for the joining thread: */ - pthread->join_status.ret = curthread->ret; - pthread->join_status.error = 0; - pthread->join_status.thread = NULL; - - /* Make this thread collectable by the garbage collector. */ - PTHREAD_ASSERT(((curthread->attr.flags & PTHREAD_DETACHED) == - 0), "Cannot join a detached thread"); - curthread->attr.flags |= PTHREAD_DETACHED; - } - - /* Remove this thread from the thread list: */ - TAILQ_REMOVE(&_thread_list, curthread, tle); - - /* This thread will never be re-scheduled. */ - _thread_kern_sched_state(PS_DEAD, __FILE__, __LINE__); - - /* This point should not be reached. */ - PANIC("Dead thread has resumed"); -} -#endif diff --git a/lib/libc_r/uthread/uthread_fchflags.c b/lib/libc_r/uthread/uthread_fchflags.c deleted file mode 100644 index da333f4b14f..00000000000 --- a/lib/libc_r/uthread/uthread_fchflags.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - * David Leonard <d@openbsd.org>, 1999. Public Domain. - * - * $OpenBSD: uthread_fchflags.c,v 1.1 1999/01/08 05:42:18 d Exp $ - */ - -#include <sys/stat.h> -#include <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -fchflags(int fd, unsigned int flags) -{ - int ret; - - if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) { - ret = _thread_sys_fchflags(fd, flags); - _FD_UNLOCK(fd, FD_WRITE); - } - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_fchmod.c b/lib/libc_r/uthread/uthread_fchmod.c deleted file mode 100644 index 652f45c0fd7..00000000000 --- a/lib/libc_r/uthread/uthread_fchmod.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: uthread_fchmod.c,v 1.3 1999/11/25 07:01:34 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_fchmod.c,v 1.5 1999/08/28 00:03:30 peter Exp $ - */ -#include <sys/types.h> -#include <sys/stat.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -fchmod(int fd, mode_t mode) -{ - int ret; - - if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) { - ret = _thread_sys_fchmod(fd, mode); - _FD_UNLOCK(fd, FD_WRITE); - } - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_fchown.c b/lib/libc_r/uthread/uthread_fchown.c deleted file mode 100644 index ed136ad7ac5..00000000000 --- a/lib/libc_r/uthread/uthread_fchown.c +++ /dev/null @@ -1,53 +0,0 @@ -/* $OpenBSD: uthread_fchown.c,v 1.3 1999/11/25 07:01:34 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_fchown.c,v 1.5 1999/08/28 00:03:31 peter Exp $ - */ -#include <sys/types.h> -#include <unistd.h> -#include <dirent.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -fchown(int fd, uid_t owner, gid_t group) -{ - int ret; - - if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) { - ret = _thread_sys_fchown(fd, owner, group); - _FD_UNLOCK(fd, FD_WRITE); - } - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_fcntl.c b/lib/libc_r/uthread/uthread_fcntl.c deleted file mode 100644 index 7070a564838..00000000000 --- a/lib/libc_r/uthread/uthread_fcntl.c +++ /dev/null @@ -1,149 +0,0 @@ -/* $OpenBSD: uthread_fcntl.c,v 1.6 1999/11/25 07:01:34 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_fcntl.c,v 1.8 1999/08/28 00:03:31 peter Exp $ - */ -#include <stdarg.h> -#include <unistd.h> -#include <fcntl.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -fcntl(int fd, int cmd,...) -{ - int flags = 0; - int nonblock; - int oldfd; - int ret; - va_list ap; - - /* This is a cancellation point: */ - _thread_enter_cancellation_point(); - - /* Lock the file descriptor: */ - if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { - /* Initialise the variable argument list: */ - va_start(ap, cmd); - - /* Process according to file control command type: */ - switch (cmd) { - /* Duplicate a file descriptor: */ - case F_DUPFD: - /* - * Get the file descriptor that the caller wants to - * use: - */ - oldfd = va_arg(ap, int); - - /* Initialise the file descriptor table entry: */ - if ((ret = _thread_sys_fcntl(fd, cmd, oldfd)) < 0) { - } - /* Initialise the file descriptor table entry: */ - else if (_thread_fd_table_init(ret) != 0) { - /* Quietly close the file: */ - _thread_sys_close(ret); - - /* Reset the file descriptor: */ - ret = -1; - } else { - /* - * Save the file open flags so that they can - * be checked later: - */ - _thread_fd_table[ret]->flags = _thread_fd_table[fd]->flags; - } - break; - case F_SETFD: - flags = va_arg(ap, int); - ret = _thread_sys_fcntl(fd, cmd, flags); - break; - case F_GETFD: - ret = _thread_sys_fcntl(fd, cmd, 0); - break; - case F_GETFL: - ret = _thread_fd_table[fd]->flags; - break; - case F_SETFL: - /* - * Get the file descriptor flags passed by the - * caller: - */ - flags = va_arg(ap, int); - - /* - * Check if the user wants a non-blocking file - * descriptor: - */ - nonblock = flags & O_NONBLOCK; - - /* Set the file descriptor flags: */ - if ((ret = _thread_sys_fcntl(fd, cmd, flags | O_NONBLOCK)) != 0) { - - /* Get the flags so that we behave like the kernel: */ - } else if ((flags = _thread_sys_fcntl(fd, - F_GETFL, 0)) == -1) { - /* Error getting flags: */ - ret = -1; - - /* - * Check if the file descriptor is non-blocking - * with respect to the user: - */ - } else if (nonblock) - /* A non-blocking descriptor: */ - _thread_fd_table[fd]->flags = flags | O_NONBLOCK; - else - /* Save the flags: */ - _thread_fd_table[fd]->flags = flags & ~O_NONBLOCK; - break; - default: - /* Might want to make va_arg use a union */ - ret = _thread_sys_fcntl(fd, cmd, va_arg(ap, void *)); - break; - } - - /* Free variable arguments: */ - va_end(ap); - - /* Unlock the file descriptor: */ - _FD_UNLOCK(fd, FD_RDWR); - } - - /* No longer in a cancellation point: */ - _thread_leave_cancellation_point(); - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_fd.c b/lib/libc_r/uthread/uthread_fd.c deleted file mode 100644 index 5a998fbba7e..00000000000 --- a/lib/libc_r/uthread/uthread_fd.c +++ /dev/null @@ -1,504 +0,0 @@ -/* $OpenBSD: uthread_fd.c,v 1.16 2003/01/19 21:22:31 marc Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_fd.c,v 1.13 1999/08/28 00:03:31 peter Exp $ - * - */ -#include <errno.h> -#include <fcntl.h> -#include <stdlib.h> -#include <string.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* Static variables: */ -static spinlock_t fd_table_lock = _SPINLOCK_INITIALIZER; - -/* - * Initialize the fd_table entry for the given fd. - * - * This function *must* return -1 and set the thread specific errno - * as a system call. This is because the error return from this - * function is propagated directly back from thread-wrapped system - * calls. - */ -int -_thread_fd_table_init(int fd) -{ - int ret = 0; - struct fd_table_entry *entry; - int saved_errno; - - if (fd < 0 || fd >= _thread_dtablesize) { - /* - * file descriptor is out of range, Return a bad file - * descriptor error: - */ - errno = EBADF; - ret = -1; - } else if (_thread_fd_table[fd] == NULL) { - /* First time for this fd, build an entry */ - entry = (struct fd_table_entry *) - malloc(sizeof(struct fd_table_entry)); - if (entry == NULL) { - errno = ENOMEM; - ret = -1; - } else { - /* Initialise the file locks: */ - _SPINLOCK_INIT(&entry->lock); - entry->r_owner = NULL; - entry->w_owner = NULL; - entry->r_fname = NULL; - entry->w_fname = NULL; - entry->r_lineno = 0; - entry->w_lineno = 0; - entry->r_lockcount = 0; - entry->w_lockcount = 0; - - /* Initialise the read/write queues: */ - TAILQ_INIT(&entry->r_queue); - TAILQ_INIT(&entry->w_queue); - - /* Get the flags for the file: */ - entry->flags = _thread_sys_fcntl(fd, F_GETFL, 0); - if (entry->flags == -1) - /* use the errno fcntl returned */ - ret = -1; - else { - /* - * Make the file descriptor non-blocking. - * This might fail if the device driver does - * not support non-blocking calls, or if the - * driver is naturally non-blocking. - */ - saved_errno = errno; - _thread_sys_fcntl(fd, F_SETFL, - entry->flags | O_NONBLOCK); - errno = saved_errno; - - /* Lock the file descriptor table: */ - _SPINLOCK(&fd_table_lock); - - /* - * Check if another thread allocated the - * file descriptor entry while this thread - * was doing the same thing. The table wasn't - * kept locked during this operation because - * it has the potential to recurse. - */ - if (_thread_fd_table[fd] == NULL) { - /* This thread wins: */ - _thread_fd_table[fd] = entry; - entry = NULL; - } - - /* Unlock the file descriptor table: */ - _SPINUNLOCK(&fd_table_lock); - } - - /* - * If there was an error in getting the flags for - * the file or if another thread initialized the - * table entry throw this entry away. - */ - if (entry != NULL) - free(entry); - } - } - - /* Return the completion status: */ - return (ret); -} - -/* - * Unlock the fd table entry for a given thread, fd, and lock type. - */ -void -_thread_fd_unlock_thread(struct pthread *thread, int fd, int lock_type, - const char *fname, int lineno) -{ - struct fd_table_entry *entry; - int ret; - - /* - * Check that the file descriptor table is initialised for this - * entry: - */ - ret = _thread_fd_table_init(fd); - if (ret == 0) { - entry = _thread_fd_table[fd]; - - /* - * Defer signals to protect the scheduling queues from - * access by the signal handler: - */ - _thread_kern_sig_defer(); - - /* - * Lock the file descriptor table entry to prevent - * other threads for clashing with the current - * thread's accesses: - */ - if (fname) - _spinlock_debug(&entry->lock, (char *)fname, lineno); - else - _SPINLOCK(&entry->lock); - - /* Check if the running thread owns the read lock: */ - if (entry->r_owner == thread && - (lock_type == FD_READ || lock_type == FD_RDWR)) { - /* - * Decrement the read lock count for the - * running thread: - */ - entry->r_lockcount--; - if (entry->r_lockcount == 0) { - /* - * no read locks, dequeue any threads - * waiting for a read lock - */ - entry->r_owner = TAILQ_FIRST(&entry->r_queue); - if (entry->r_owner != NULL) { - TAILQ_REMOVE(&entry->r_queue, - entry->r_owner, qe); - - /* - * Set the state of the new owner of - * the thread to running: - */ - PTHREAD_NEW_STATE(entry->r_owner, - PS_RUNNING); - - /* - * Reset the number of read locks. - * This will be incremented by the new - * owner of the lock when it sees that - *it has the lock. - */ - entry->r_lockcount = 0; - } - } - - } - /* Check if the running thread owns the write lock: */ - if (entry->w_owner == thread && - (lock_type == FD_WRITE || lock_type == FD_RDWR)) { - /* - * Decrement the write lock count for the - * running thread: - */ - entry->w_lockcount--; - if (entry->w_lockcount == 0) { - /* - * no write locks, dequeue any threads - * waiting on a write lock. - */ - entry->w_owner = TAILQ_FIRST(&entry->w_queue); - if (entry->w_owner != NULL) { - /* Remove this thread from the queue: */ - TAILQ_REMOVE(&entry->w_queue, - entry->w_owner, qe); - - /* - * Set the state of the new owner of - * the thread to running: - */ - PTHREAD_NEW_STATE(entry->w_owner, - PS_RUNNING); - - /* - * Reset the number of write locks. - * This will be incremented by the - * new owner of the lock when it - * sees that it has the lock. - */ - entry->w_lockcount = 0; - } - } - } - - /* Unlock the file descriptor table entry: */ - _SPINUNLOCK(&entry->lock); - - /* - * Undefer and handle pending signals, yielding if - * necessary: - */ - _thread_kern_sig_undefer(); - } - - /* Nothing to return. */ - return; -} - -/* - * Unlock an fd table entry for the given fd and lock type. Save - * fname and lineno (debug variables). - */ -void -_thread_fd_unlock(int fd, int lock_type, const char *fname, int lineno) -{ - struct pthread *curthread = _get_curthread(); - _thread_fd_unlock_thread(curthread, fd, lock_type, fname, lineno); -} - -/* - * Unlock all fd table entries owned by the given thread - */ -void -_thread_fd_unlock_owned(pthread_t pthread) -{ - struct fd_table_entry *entry; - int do_unlock; - int fd; - - for (fd = 0; fd < _thread_dtablesize; fd++) { - entry = _thread_fd_table[fd]; - if (entry) { - _SPINLOCK(&entry->lock); - do_unlock = 0; - /* force an unlock regardless of the recursion level */ - if (entry->r_owner == pthread) { - entry->r_lockcount = 1; - do_unlock++; - } - if (entry->w_owner == pthread) { - entry->w_lockcount = 1; - do_unlock++; - } - _SPINUNLOCK(&entry->lock); - if (do_unlock) - _thread_fd_unlock_thread(pthread, fd, FD_RDWR, - __FILE__, __LINE__); - } - } -} - -/* - * Lock an fd table entry for the given fd and lock type. Save - * fname and lineno (debug variables). The debug variables may be - * null when called by the non-debug version of the function. - */ -int -_thread_fd_lock(int fd, int lock_type, struct timespec * timeout, - const char *fname, int lineno) -{ - struct pthread *curthread = _get_curthread(); - struct fd_table_entry *entry; - int ret; - - /* - * Check that the file descriptor table is initialised for this - * entry: - */ - ret = _thread_fd_table_init(fd); - if (ret == 0) { - entry = _thread_fd_table[fd]; - - /* - * Lock the file descriptor table entry to prevent - * other threads for clashing with the current - * thread's accesses: - */ - if (fname) - _spinlock_debug(&entry->lock, (char *)fname, lineno); - else - _SPINLOCK(&entry->lock); - - /* Handle read locks */ - if (lock_type == FD_READ || lock_type == FD_RDWR) { - /* - * Enter a loop to wait for the file descriptor to be - * locked for read for the current thread: - */ - while (entry->r_owner != curthread) { - /* - * Check if the file descriptor is locked by - * another thread: - */ - if (entry->r_owner != NULL) { - /* - * Another thread has locked the file - * descriptor for read, so join the - * queue of threads waiting for a - * read lock on this file descriptor: - */ - TAILQ_INSERT_TAIL(&entry->r_queue, - curthread, qe); - - /* - * Save the file descriptor details - * in the thread structure for the - * running thread: - */ - curthread->data.fd.fd = fd; - curthread->data.fd.branch = lineno; - curthread->data.fd.fname = - (char *)fname; - - /* Set the timeout: */ - _thread_kern_set_timeout(timeout); - - /* - * Unlock the file descriptor - * table entry: - */ - _SPINUNLOCK(&entry->lock); - - /* - * Schedule this thread to wait on - * the read lock. It will only be - * woken when it becomes the next in - * the queue and is granted access - * to the lock by the thread that is - * unlocking the file descriptor. - */ - _thread_kern_sched_state(PS_FDLR_WAIT, - __FILE__, - __LINE__); - - /* - * Lock the file descriptor - * table entry again: - */ - _SPINLOCK(&entry->lock); - - } else { - /* - * The running thread now owns the - * read lock on this file descriptor: - */ - entry->r_owner = curthread; - - /* - * Reset the number of read locks for - * this file descriptor: - */ - entry->r_lockcount = 0; - entry->r_fname = fname; - entry->r_lineno = lineno; - } - } - - /* Increment the read lock count: */ - entry->r_lockcount++; - } - - /* Handle write locks */ - if (lock_type == FD_WRITE || lock_type == FD_RDWR) { - /* - * Enter a loop to wait for the file descriptor to be - * locked for write for the current thread: - */ - while (entry->w_owner != curthread) { - /* - * Check if the file descriptor is locked by - * another thread: - */ - if (entry->w_owner != NULL) { - /* - * Another thread has locked the file - * descriptor for write, so join the - * queue of threads waiting for a - * write lock on this file - * descriptor: - */ - TAILQ_INSERT_TAIL(&entry->w_queue, - curthread, qe); - - /* - * Save the file descriptor details - * in the thread structure for the - * running thread: - */ - curthread->data.fd.fd = fd; - curthread->data.fd.branch = lineno; - curthread->data.fd.fname = - (char *)fname; - - /* Set the timeout: */ - _thread_kern_set_timeout(timeout); - - /* - * Unlock the file descriptor - * table entry: - */ - _SPINUNLOCK(&entry->lock); - - /* - * Schedule this thread to wait on - * the write lock. It will only be - * woken when it becomes the next in - * the queue and is granted access to - * the lock by the thread that is - * unlocking the file descriptor. - */ - _thread_kern_sched_state(PS_FDLW_WAIT, - __FILE__, - __LINE__); - - /* - * Lock the file descriptor - * table entry again: - */ - _SPINLOCK(&entry->lock); - } else { - /* - * The running thread now owns the - * write lock on this file descriptor: - */ - entry->w_owner = curthread; - - /* - * Reset the number of write locks - * for this file descriptor: - */ - entry->w_lockcount = 0; - entry->w_fname = fname; - entry->w_lineno = lineno; - } - } - - /* Increment the write lock count: */ - entry->w_lockcount++; - } - - /* Unlock the file descriptor table entry: */ - _SPINUNLOCK(&entry->lock); - } - - /* Return the completion status: */ - return (ret); -} - -#endif diff --git a/lib/libc_r/uthread/uthread_file.c b/lib/libc_r/uthread/uthread_file.c deleted file mode 100644 index 73f8cda30f5..00000000000 --- a/lib/libc_r/uthread/uthread_file.c +++ /dev/null @@ -1,368 +0,0 @@ -/* $OpenBSD: uthread_file.c,v 1.9 2002/11/07 03:51:21 marc Exp $ */ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_file.c,v 1.9 1999/08/28 00:03:32 peter Exp $ - * - * POSIX stdio FILE locking functions. These assume that the locking - * is only required at FILE structure level, not at file descriptor - * level too. - * - */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/queue.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* - * The FILE lock structure. The FILE *fp is locked if the owner is - * not NULL. If not locked, the file lock structure can be - * reassigned to a different file by setting fp. - */ -struct file_lock { - LIST_ENTRY(file_lock) entry; /* Entry if file list. */ - V_TAILQ_HEAD(lock_head, pthread) - l_head; /* Head of queue for threads */ - /* waiting on this lock. */ - FILE *fp; /* The target file. */ - pthread_t owner; /* Thread that owns lock. */ - int count; /* Lock count for owner. */ -}; - -/* - * The number of file lock lists into which the file pointer is - * hashed. Ideally, the FILE structure size would have been increased, - * but this causes incompatibility, so separate data structures are - * required. - */ -#define NUM_HEADS 128 - -/* - * This macro casts a file pointer to a long integer and right - * shifts this by the number of bytes in a pointer. The shifted - * value is then remaindered using the maximum number of hash - * entries to produce and index into the array of static lock - * structures. If there is a collision, a linear search of the - * dynamic list of locks linked to each static lock is perfomed. - */ -#define file_idx(_p) ((((u_long) _p) >> sizeof(void *)) % NUM_HEADS) - -/* - * Global array of file locks. The first lock for each hash bucket is - * allocated statically in the hope that there won't be too many - * collisions that require a malloc and an element added to the list. - */ -struct static_file_lock { - LIST_HEAD(file_list_head, file_lock) head; - struct file_lock fl; -} flh[NUM_HEADS]; - -/* Set to non-zero when initialisation is complete: */ -static int init_done = 0; - -/* Lock for accesses to the hash table: */ -static spinlock_t hash_lock = _SPINLOCK_INITIALIZER; - -/* - * Find a lock structure for a FILE, return NULL if the file is - * not locked: - */ -static -struct file_lock * -find_lock(int idx, FILE *fp) -{ - struct file_lock *p; - - /* Check if the file is locked using the static structure: */ - if (flh[idx].fl.fp == fp && flh[idx].fl.owner != NULL) - /* Return a pointer to the static lock: */ - p = &flh[idx].fl; - else { - /* Point to the first dynamic lock: */ - p = flh[idx].head.lh_first; - - /* - * Loop through the dynamic locks looking for the - * target file: - */ - while (p != NULL && (p->fp != fp || p->owner == NULL)) - /* Not this file, try the next: */ - p = p->entry.le_next; - } - return(p); -} - -/* - * Lock a file, assuming that there is no lock structure currently - * assigned to it. - */ -static -struct file_lock * -do_lock(int idx, FILE *fp) -{ - struct file_lock *p; - - /* Check if the static structure is not being used: */ - if (flh[idx].fl.owner == NULL) { - /* Return a pointer to the static lock: */ - p = &flh[idx].fl; - } - else { - /* Point to the first dynamic lock: */ - p = flh[idx].head.lh_first; - - /* - * Loop through the dynamic locks looking for a - * lock structure that is not being used: - */ - while (p != NULL && p->owner != NULL) - /* This one is used, try the next: */ - p = p->entry.le_next; - } - - /* - * If an existing lock structure has not been found, - * allocate memory for a new one: - */ - if (p == NULL && (p = (struct file_lock *) - malloc(sizeof(struct file_lock))) != NULL) { - /* Add the new element to the list: */ - LIST_INSERT_HEAD(&flh[idx].head, p, entry); - } - - /* Check if there is a lock structure to acquire: */ - if (p != NULL) { - /* Acquire the lock for the running thread: */ - p->fp = fp; - p->owner = _thread_run; - p->count = 1; - TAILQ_INIT(&p->l_head); - } - return(p); -} - -void -_flockfile_debug(FILE * fp, char *fname, int lineno) -{ - int idx = file_idx(fp); - struct file_lock *p; - - /* Check if this is a real file: */ - if (fp->_file >= 0) { - /* Lock the hash table: */ - _SPINLOCK(&hash_lock); - - /* Check if the static array has not been initialised: */ - if (!init_done) { - /* Initialise the global array: */ - memset(flh,0,sizeof(flh)); - - /* Flag the initialisation as complete: */ - init_done = 1; - } - - /* Get a pointer to any existing lock for the file: */ - if ((p = find_lock(idx, fp)) == NULL) { - /* - * The file is not locked, so this thread can - * grab the lock: - */ - p = do_lock(idx, fp); - - /* Unlock the hash table: */ - _SPINUNLOCK(&hash_lock); - - /* - * The file is already locked, so check if the - * running thread is the owner: - */ - } else if (p->owner == _thread_run) { - /* - * The running thread is already the - * owner, so increment the count of - * the number of times it has locked - * the file: - */ - p->count++; - - /* Unlock the hash table: */ - _SPINUNLOCK(&hash_lock); - } else { - /* - * The file is locked for another thread. - * Append this thread to the queue of - * threads waiting on the lock. - */ - TAILQ_INSERT_TAIL(&p->l_head,_thread_run,qe); - - /* Unlock the hash table: */ - _SPINUNLOCK(&hash_lock); - - /* Wait on the FILE lock: */ - _thread_kern_sched_state(PS_FILE_WAIT, fname, lineno); - } - } - return; -} - -void -flockfile(FILE * fp) -{ - _flockfile_debug(fp, "?", 1); - return; -} - -int -ftrylockfile(FILE * fp) -{ - int ret = -1; - int idx = file_idx(fp); - struct file_lock *p; - - /* Check if this is a real file: */ - if (fp->_file >= 0) { - /* Lock the hash table: */ - _SPINLOCK(&hash_lock); - - /* Get a pointer to any existing lock for the file: */ - if ((p = find_lock(idx, fp)) == NULL) { - /* - * The file is not locked, so this thread can - * grab the lock: - */ - p = do_lock(idx, fp); - - /* - * The file is already locked, so check if the - * running thread is the owner: - */ - } else if (p->owner == _thread_run) { - /* - * The running thread is already the - * owner, so increment the count of - * the number of times it has locked - * the file: - */ - p->count++; - } else { - /* - * The file is locked for another thread, - * so this try fails. - */ - p = NULL; - } - - /* Check if the lock was obtained: */ - if (p != NULL) - /* Return success: */ - ret = 0; - - /* Unlock the hash table: */ - _SPINUNLOCK(&hash_lock); - - } - return (ret); -} - -void -funlockfile(FILE * fp) -{ - int idx = file_idx(fp); - struct file_lock *p; - - /* Check if this is a real file: */ - if (fp->_file >= 0) { - /* - * Defer signals to protect the scheduling queues from - * access by the signal handler: - */ - _thread_kern_sig_defer(); - - /* Lock the hash table: */ - _SPINLOCK(&hash_lock); - - /* - * Get a pointer to the lock for the file and check that - * the running thread is the one with the lock: - */ - if ((p = find_lock(idx, fp)) != NULL && - p->owner == _thread_run) { - /* - * Check if this thread has locked the FILE - * more than once: - */ - if (p->count > 1) - /* - * Decrement the count of the number of - * times the running thread has locked this - * file: - */ - p->count--; - else { - /* - * The running thread will release the - * lock now: - */ - p->count = 0; - - /* Get the new owner of the lock: */ - if ((p->owner = TAILQ_FIRST(&p->l_head)) != NULL) { - /* Pop the thread off the queue: */ - TAILQ_REMOVE(&p->l_head,p->owner,qe); - - /* - * This is the first lock for the new - * owner: - */ - p->count = 1; - - /* Allow the new owner to run: */ - PTHREAD_NEW_STATE(p->owner,PS_RUNNING); - } - } - } - - /* Unlock the hash table: */ - _SPINUNLOCK(&hash_lock); - - /* - * Undefer and handle pending signals, yielding if - * necessary: - */ - _thread_kern_sig_undefer(); - } - return; -} - -#endif diff --git a/lib/libc_r/uthread/uthread_find_thread.c b/lib/libc_r/uthread/uthread_find_thread.c deleted file mode 100644 index c531643e325..00000000000 --- a/lib/libc_r/uthread/uthread_find_thread.c +++ /dev/null @@ -1,69 +0,0 @@ -/* $OpenBSD: uthread_find_thread.c,v 1.5 2001/12/11 00:19:47 fgsch Exp $ */ -/* - * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_find_thread.c,v 1.5 1999/08/28 00:03:32 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* Find a thread in the linked list of active threads: */ -int -_find_thread(pthread_t pthread) -{ - pthread_t pthread1; - - /* Check if the caller has specified an invalid thread: */ - if (pthread == NULL || pthread->magic != PTHREAD_MAGIC) - /* Invalid thread: */ - return(EINVAL); - - /* - * Defer signals to protect the thread list from access - * by the signal handler: - */ - _thread_kern_sig_defer(); - - /* Search for the specified thread: */ - TAILQ_FOREACH(pthread1, &_thread_list, tle) { - if (pthread == pthread1) - break; - } - - /* Undefer and handle pending signals, yielding if necessary: */ - _thread_kern_sig_undefer(); - - /* Return zero if the thread exists: */ - return ((pthread1 != NULL) ? 0:ESRCH); -} -#endif diff --git a/lib/libc_r/uthread/uthread_flock.c b/lib/libc_r/uthread/uthread_flock.c deleted file mode 100644 index fed679bd80b..00000000000 --- a/lib/libc_r/uthread/uthread_flock.c +++ /dev/null @@ -1,51 +0,0 @@ -/* $OpenBSD: uthread_flock.c,v 1.3 1999/11/25 07:01:35 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_flock.c,v 1.5 1999/08/28 00:03:32 peter Exp $ - */ -#include <sys/file.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -flock(int fd, int operation) -{ - int ret; - - if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { - ret = _thread_sys_flock(fd, operation); - _FD_UNLOCK(fd, FD_RDWR); - } - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_fork.c b/lib/libc_r/uthread/uthread_fork.c deleted file mode 100644 index 0271e822526..00000000000 --- a/lib/libc_r/uthread/uthread_fork.c +++ /dev/null @@ -1,191 +0,0 @@ -/* $OpenBSD: uthread_fork.c,v 1.10 2001/08/21 19:24:53 fgsch Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_fork.c,v 1.14 1999/09/29 15:18:38 marcel Exp $ - */ -#include <errno.h> -#include <string.h> -#include <unistd.h> -#include <fcntl.h> -#include <stdlib.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -pid_t -fork(void) -{ - struct pthread *curthread = _get_curthread(); - int i, flags; - pid_t ret; - pthread_t pthread; - - /* - * Defer signals to protect the scheduling queues from access - * by the signal handler: - */ - _thread_kern_sig_defer(); - - /* Fork a new process: */ - if ((ret = _thread_sys_fork()) != 0) { - /* Parent process or error. Nothing to do here. */ - } else { - /* Close the pthread kernel pipe: */ - _thread_sys_close(_thread_kern_pipe[0]); - _thread_sys_close(_thread_kern_pipe[1]); - - /* Reset signals pending for the running thread: */ - sigemptyset(&curthread->sigpend); - - /* - * Create a pipe that is written to by the signal handler to - * prevent signals being missed in calls to - * _thread_sys_select: - */ - if (_thread_sys_pipe(_thread_kern_pipe) != 0) { - /* Cannot create pipe, so abort: */ - PANIC("Cannot create pthread kernel pipe for forked process"); - } - /* Get the flags for the read pipe: */ - else if ((flags = _thread_sys_fcntl(_thread_kern_pipe[0], F_GETFL, NULL)) == -1) { - /* Abort this application: */ - abort(); - } - /* Make the read pipe non-blocking: */ - else if (_thread_sys_fcntl(_thread_kern_pipe[0], F_SETFL, flags | O_NONBLOCK) == -1) { - /* Abort this application: */ - abort(); - } - /* Get the flags for the write pipe: */ - else if ((flags = _thread_sys_fcntl(_thread_kern_pipe[1], F_GETFL, NULL)) == -1) { - /* Abort this application: */ - abort(); - } - /* Make the write pipe non-blocking: */ - else if (_thread_sys_fcntl(_thread_kern_pipe[1], F_SETFL, flags | O_NONBLOCK) == -1) { - /* Abort this application: */ - abort(); - } - /* Reinitialize the GC mutex: */ - else if (_mutex_reinit(&_gc_mutex) != 0) { - /* Abort this application: */ - PANIC("Cannot initialize GC mutex for forked process"); - } - /* Reinitialize the GC condition variable: */ - else if (_cond_reinit(&_gc_cond) != 0) { - /* Abort this application: */ - PANIC("Cannot initialize GC condvar for forked process"); - } - /* Initialize the ready queue: */ - else if (_pq_init(&_readyq) != 0) { - /* Abort this application: */ - PANIC("Cannot initialize priority ready queue."); - } else { - /* - * Enter a loop to remove all threads other than - * the running thread from the thread list: - */ - while ((pthread = TAILQ_FIRST(&_thread_list)) != NULL) { - TAILQ_REMOVE(&_thread_list, pthread, tle); - - /* Make sure this isn't the running thread: */ - if (pthread != curthread) { - /* XXX should let gc do all this. */ - if(pthread->stack != NULL) - _thread_stack_free(pthread->stack); - - if (pthread->specific_data != NULL) - free(pthread->specific_data); - - if (pthread->poll_data.fds != NULL) - free(pthread->poll_data.fds); - - free(pthread); - } - } - - /* Restore the running thread */ - TAILQ_INSERT_HEAD(&_thread_list, curthread, tle); - - /* Re-init the dead thread list: */ - TAILQ_INIT(&_dead_list); - - /* Re-init the waiting and work queues. */ - TAILQ_INIT(&_waitingq); - TAILQ_INIT(&_workq); - - /* Re-init the threads mutex queue: */ - TAILQ_INIT(&curthread->mutexq); - - /* No spinlocks yet: */ - _spinblock_count = 0; - - /* Don't queue signals yet: */ - _queue_signals = 0; - - /* Initialize signal handling: */ - _thread_sig_init(); - - /* Initialize the scheduling switch hook routine: */ - _sched_switch_hook = NULL; - - /* Clear out any locks in the file descriptor table: */ - for (i = 0; i < _thread_dtablesize; i++) { - if (_thread_fd_table[i] != NULL) { - /* Initialise the file locks: */ - _SPINLOCK_INIT(&_thread_fd_table[i]->lock); - _thread_fd_table[i]->r_owner = NULL; - _thread_fd_table[i]->w_owner = NULL; - _thread_fd_table[i]->r_fname = NULL; - _thread_fd_table[i]->w_fname = NULL; - _thread_fd_table[i]->r_lineno = 0;; - _thread_fd_table[i]->w_lineno = 0;; - _thread_fd_table[i]->r_lockcount = 0;; - _thread_fd_table[i]->w_lockcount = 0;; - - /* Initialise the read/write queues: */ - TAILQ_INIT(&_thread_fd_table[i]->r_queue); - TAILQ_INIT(&_thread_fd_table[i]->w_queue); - } - } - } - } - - /* - * Undefer and handle pending signals, yielding if necessary: - */ - _thread_kern_sig_undefer(); - - /* Return the process ID: */ - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_fpathconf.c b/lib/libc_r/uthread/uthread_fpathconf.c deleted file mode 100644 index 5c49b2b2063..00000000000 --- a/lib/libc_r/uthread/uthread_fpathconf.c +++ /dev/null @@ -1,23 +0,0 @@ -/* - * David Leonard <d@openbsd.org>, 1999. Public Domain. - * - * $OpenBSD: uthread_fpathconf.c,v 1.2 2002/01/02 16:19:35 fgsch Exp $ - */ - -#include <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -long -fpathconf(int fd, int name) -{ - long ret; - - if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) { - ret = _thread_sys_fpathconf(fd, name); - _FD_UNLOCK(fd, FD_READ); - } - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_fstat.c b/lib/libc_r/uthread/uthread_fstat.c deleted file mode 100644 index 29b65b5aac6..00000000000 --- a/lib/libc_r/uthread/uthread_fstat.c +++ /dev/null @@ -1,59 +0,0 @@ -/* $OpenBSD: uthread_fstat.c,v 1.3 1999/11/25 07:01:35 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_fstat.c,v 1.5 1999/08/28 00:03:33 peter Exp $ - */ -#include <signal.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/param.h> -#include <sys/mount.h> -#include <sys/stat.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -fstat(int fd, struct stat * buf) -{ - int ret; - - /* Lock the file descriptor for read: */ - if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) { - /* Get the file status: */ - ret = _thread_sys_fstat(fd, buf); - /* Unlock the file descriptor: */ - _FD_UNLOCK(fd, FD_READ); - } - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_fstatfs.c b/lib/libc_r/uthread/uthread_fstatfs.c deleted file mode 100644 index ba809a5bef4..00000000000 --- a/lib/libc_r/uthread/uthread_fstatfs.c +++ /dev/null @@ -1,59 +0,0 @@ -/* $OpenBSD: uthread_fstatfs.c,v 1.3 1999/11/25 07:01:35 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_fstatfs.c,v 1.5 1999/08/28 00:03:33 peter Exp $ - */ -#include <signal.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/param.h> -#include <sys/mount.h> -#include <sys/stat.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -fstatfs(int fd, struct statfs * buf) -{ - int ret; - - /* Lock the file descriptor for read: */ - if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) { - /* Get the file system status: */ - ret = _thread_sys_fstatfs(fd, buf); - /* Unlock the file descriptor: */ - _FD_UNLOCK(fd, FD_READ); - } - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_fsync.c b/lib/libc_r/uthread/uthread_fsync.c deleted file mode 100644 index cc5cb5046e1..00000000000 --- a/lib/libc_r/uthread/uthread_fsync.c +++ /dev/null @@ -1,58 +0,0 @@ -/* $OpenBSD: uthread_fsync.c,v 1.5 1999/11/25 07:01:35 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_fsync.c,v 1.5 1999/08/28 00:03:33 peter Exp $ - */ -#include <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -fsync(int fd) -{ - int ret; - - /* This is a cancellation point: */ - _thread_enter_cancellation_point(); - - if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { - ret = _thread_sys_fsync(fd); - _FD_UNLOCK(fd, FD_RDWR); - } - - /* No longer in a cancellation point: */ - _thread_leave_cancellation_point(); - - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_gc.c b/lib/libc_r/uthread/uthread_gc.c deleted file mode 100644 index 956633e7fe4..00000000000 --- a/lib/libc_r/uthread/uthread_gc.c +++ /dev/null @@ -1,214 +0,0 @@ -/* $OpenBSD: uthread_gc.c,v 1.11 2001/12/11 00:19:47 fgsch Exp $ */ -/* - * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_gc.c,v 1.10 1999/08/28 00:03:34 peter Exp $ - * - * Garbage collector thread. Frees memory allocated for dead threads. - * - */ -#include <errno.h> -#include <stdlib.h> -#include <time.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/types.h> -#include <sys/mman.h> -#include <pthread.h> -#include "pthread_private.h" - -pthread_addr_t -_thread_gc(pthread_addr_t arg) -{ - struct pthread *curthread = _get_curthread(); - int f_debug; - int f_done = 0; - int ret; - sigset_t mask; - pthread_t pthread; - pthread_t pthread_cln; - struct timespec abstime; - void *p_stack; - - /* Block all signals */ - sigfillset(&mask); - pthread_sigmask(SIG_BLOCK, &mask, NULL); - - /* Mark this thread as a library thread (not a user thread). */ - curthread->flags |= PTHREAD_FLAGS_PRIVATE; - - /* Set a debug flag based on an environment variable. */ - f_debug = (getenv("LIBC_R_DEBUG") != NULL); - - /* Set the name of this thread. */ - pthread_set_name_np(curthread,"GC"); - - while (!f_done) { - /* Check if debugging this application. */ - if (f_debug) - /* Dump thread info to file. */ - _thread_dump_info(); - - /* - * Defer signals to protect the scheduling queues from - * access by the signal handler: - */ - _thread_kern_sig_defer(); - - /* Check if this is the last running thread: */ - if (TAILQ_FIRST(&_thread_list) == curthread && - TAILQ_NEXT(curthread, tle) == NULL) - /* - * This is the last thread, so it can exit - * now. - */ - f_done = 1; - - /* - * Undefer and handle pending signals, yielding if - * necessary: - */ - _thread_kern_sig_undefer(); - - /* No stack of thread structure to free yet: */ - p_stack = NULL; - pthread_cln = NULL; - - /* - * Lock the garbage collector mutex which ensures that - * this thread sees another thread exit: - */ - if (pthread_mutex_lock(&_gc_mutex) != 0) - PANIC("Cannot lock gc mutex"); - - /* - * Enter a loop to search for the first dead thread that - * has memory to free. - */ - for (pthread = TAILQ_FIRST(&_dead_list); - p_stack == NULL && pthread_cln == NULL && pthread != NULL; - pthread = TAILQ_NEXT(pthread, dle)) { - /* Check if the initial thread: */ - if (pthread == _thread_initial) { - /* Don't destroy the initial thread. */ - } - /* - * Check if this thread has detached: - */ - else if ((pthread->attr.flags & - PTHREAD_DETACHED) != 0) { - /* Remove this thread from the dead list: */ - TAILQ_REMOVE(&_dead_list, pthread, dle); - - /* - * Point to the stack structure that must - * be freed outside the locks: - */ - if (pthread->stack != NULL) - p_stack = pthread->stack; - - /* - * Point to the thread structure that must - * be freed outside the locks: - */ - pthread_cln = pthread; - - } else { - /* - * This thread has not detached, so do - * not destroy it. - * - * But we can destroy its stack. - */ - if (pthread->stack != NULL) { - p_stack = pthread->stack; - pthread->stack = NULL; - } - } - } - - /* - * Check if this is not the last thread and there is no - * memory to free this time around. - */ - if (!f_done && p_stack == NULL && pthread_cln == NULL) { - /* Get the current time. */ - if (clock_gettime(CLOCK_REALTIME,&abstime) != 0) - PANIC("gc cannot get time"); - - /* - * Do a backup poll in 10 seconds if no threads - * die before then. - */ - abstime.tv_sec += 10; - - /* - * Wait for a signal from a dying thread or a - * timeout (for a backup poll). - */ - if ((ret = pthread_cond_timedwait(&_gc_cond, - &_gc_mutex, &abstime)) != 0 && ret != ETIMEDOUT) - PANIC("gc cannot wait for a signal"); - } - - /* Unlock the garbage collector mutex: */ - if (pthread_mutex_unlock(&_gc_mutex) != 0) - PANIC("Cannot unlock gc mutex"); - - /* - * If there is memory to free, do it now. The call to - * free() might block, so this must be done outside the - * locks. - */ - if (p_stack != NULL) - /* Free the stack storage. */ - _thread_stack_free(p_stack); - - if (pthread_cln != NULL) { - if (pthread_cln->name != NULL) { - /* Free the thread name string. */ - free(pthread_cln->name); - } - /* - * Free the memory allocated for the thread - * structure. - */ - if (pthread_cln->poll_data.fds != NULL) - free(pthread_cln->poll_data.fds); - - if (pthread_cln->specific_data != NULL) - free(pthread_cln->specific_data); - - free(pthread_cln); - } - } - return (NULL); -} diff --git a/lib/libc_r/uthread/uthread_getdirentries.c b/lib/libc_r/uthread/uthread_getdirentries.c deleted file mode 100644 index 1dd8d30e651..00000000000 --- a/lib/libc_r/uthread/uthread_getdirentries.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: uthread_getdirentries.c,v 1.3 1999/11/25 07:01:36 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_getdirentries.c,v 1.5 1999/08/28 00:03:34 peter Exp $ - */ -#include <sys/types.h> -#include <dirent.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -getdirentries(int fd, char *buf, int nbytes, long *basep) -{ - int ret; - - if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { - ret = _thread_sys_getdirentries(fd, buf, nbytes, basep); - _FD_UNLOCK(fd, FD_RDWR); - } - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_getpeername.c b/lib/libc_r/uthread/uthread_getpeername.c deleted file mode 100644 index 378f23f7416..00000000000 --- a/lib/libc_r/uthread/uthread_getpeername.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: uthread_getpeername.c,v 1.4 1999/11/25 07:01:36 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_getpeername.c,v 1.5 1999/08/28 00:03:34 peter Exp $ - */ -#include <sys/types.h> -#include <sys/socket.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -getpeername(int fd, struct sockaddr * peer, socklen_t *paddrlen) -{ - int ret; - - if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) { - ret = _thread_sys_getpeername(fd, peer, paddrlen); - _FD_UNLOCK(fd, FD_READ); - } - return ret; -} -#endif diff --git a/lib/libc_r/uthread/uthread_getprio.c b/lib/libc_r/uthread/uthread_getprio.c deleted file mode 100644 index 725fb0bde54..00000000000 --- a/lib/libc_r/uthread/uthread_getprio.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $OpenBSD: uthread_getprio.c,v 1.4 1999/11/25 07:01:36 d Exp $ */ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_getprio.c,v 1.6 1999/08/28 00:03:35 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_getprio(pthread_t pthread) -{ - int policy, ret; - struct sched_param param; - - if ((ret = pthread_getschedparam(pthread, &policy, ¶m)) == 0) - ret = param.sched_priority; - else { - /* Invalid thread: */ - errno = ret; - ret = -1; - } - - /* Return the thread priority or an error status: */ - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_getschedparam.c b/lib/libc_r/uthread/uthread_getschedparam.c deleted file mode 100644 index a7f1bf030c6..00000000000 --- a/lib/libc_r/uthread/uthread_getschedparam.c +++ /dev/null @@ -1,59 +0,0 @@ -/* $OpenBSD: uthread_getschedparam.c,v 1.3 2002/01/19 23:42:40 fgsch Exp $ */ -/* - * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Daniel Eischen. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_getschedparam.c,v 1.3 1999/08/28 00:03:35 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_getschedparam(pthread_t pthread, int *policy, struct sched_param *param) -{ - int ret; - - if ((param == NULL) || (policy == NULL)) - /* Return an invalid argument error: */ - ret = EINVAL; - - /* Find the thread in the list of active threads: */ - else if ((ret = _find_thread(pthread)) == 0) { - /* Return the threads base priority and scheduling policy: */ - param->sched_priority = - PTHREAD_BASE_PRIORITY(pthread->base_priority); - *policy = pthread->attr.sched_policy; - } - - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_getsockname.c b/lib/libc_r/uthread/uthread_getsockname.c deleted file mode 100644 index 683cc910f15..00000000000 --- a/lib/libc_r/uthread/uthread_getsockname.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: uthread_getsockname.c,v 1.4 1999/11/25 07:01:36 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_getsockname.c,v 1.5 1999/08/28 00:03:36 peter Exp $ - */ -#include <sys/types.h> -#include <sys/socket.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -getsockname(int s, struct sockaddr * name, socklen_t *namelen) -{ - int ret; - - if ((ret = _FD_LOCK(s, FD_READ, NULL)) == 0) { - ret = _thread_sys_getsockname(s, name, namelen); - _FD_UNLOCK(s, FD_READ); - } - return ret; -} -#endif diff --git a/lib/libc_r/uthread/uthread_getsockopt.c b/lib/libc_r/uthread/uthread_getsockopt.c deleted file mode 100644 index f73b54780ea..00000000000 --- a/lib/libc_r/uthread/uthread_getsockopt.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: uthread_getsockopt.c,v 1.4 1999/11/25 07:01:36 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_getsockopt.c,v 1.5 1999/08/28 00:03:36 peter Exp $ - */ -#include <sys/types.h> -#include <sys/socket.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -getsockopt(int fd, int level, int optname, void *optval, socklen_t *optlen) -{ - int ret; - - if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { - ret = _thread_sys_getsockopt(fd, level, optname, optval, optlen); - _FD_UNLOCK(fd, FD_RDWR); - } - return ret; -} -#endif diff --git a/lib/libc_r/uthread/uthread_info.c b/lib/libc_r/uthread/uthread_info.c deleted file mode 100644 index b528f9bd64e..00000000000 --- a/lib/libc_r/uthread/uthread_info.c +++ /dev/null @@ -1,317 +0,0 @@ -/* $OpenBSD: uthread_info.c,v 1.11 2002/10/21 23:10:29 marc Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_info.c,v 1.14 1999/09/29 15:18:38 marcel Exp $ - */ -#include <stdio.h> -#include <fcntl.h> -#include <string.h> -#include <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include <errno.h> -#include "pthread_private.h" - -struct s_thread_info { - enum pthread_state state; - char *name; -}; - -/* Static variables: */ -static const struct s_thread_info thread_info[] = { - {PS_RUNNING , "Running"}, - {PS_SIGTHREAD , "Waiting on signal thread"}, - {PS_MUTEX_WAIT , "Waiting on a mutex"}, - {PS_COND_WAIT , "Waiting on a condition variable"}, - {PS_FDLR_WAIT , "Waiting for a file read lock"}, - {PS_FDLW_WAIT , "Waiting for a file write lock"}, - {PS_FDR_WAIT , "Waiting for read"}, - {PS_FDW_WAIT , "Waiting for write"}, - {PS_FILE_WAIT , "Waiting for FILE lock"}, - {PS_POLL_WAIT , "Waiting on poll"}, - {PS_SELECT_WAIT , "Waiting on select"}, - {PS_SLEEP_WAIT , "Sleeping"}, - {PS_WAIT_WAIT , "Waiting process"}, - {PS_SIGSUSPEND , "Suspended, waiting for a signal"}, - {PS_SIGWAIT , "Waiting for a signal"}, - {PS_SPINBLOCK , "Waiting for a spinlock"}, - {PS_JOIN , "Waiting to join"}, - {PS_SUSPENDED , "Suspended"}, - {PS_DEAD , "Dead"}, - {PS_DEADLOCK , "Deadlocked"}, - {PS_STATE_MAX , "Not a real state!"} -}; - -void -_thread_dump_info(void) -{ - struct pthread *curthread = _get_curthread(); - char s[512]; - int fd; - int i; - int j; - pthread_t pthread; - char tmpfile[128]; - pq_list_t *pq_list; - - for (i = 0; i < 100000; i++) { - snprintf(tmpfile, sizeof(tmpfile), "/tmp/uthread.dump.%u.%i", - getpid(), i); - /* Open the dump file for append and create it if necessary: */ - if ((fd = _thread_sys_open(tmpfile, O_RDWR | O_CREAT | O_EXCL, - 0666)) < 0) { - /* Can't open the dump file. */ - if (errno == EEXIST) - continue; - /* - * We only need to continue in case of - * EEXIT error. Most other error - * codes means that we will fail all - * the times. - */ - return; - } else { - break; - } - } - if (i==100000) { - /* all 100000 possibilities are in use :( */ - return; - } else { - /* Output a header for active threads: */ - strcpy(s, "\n\n=============\nACTIVE THREADS\n\n"); - _thread_sys_write(fd, s, strlen(s)); - - /* Enter a loop to report each thread in the global list: */ - TAILQ_FOREACH(pthread, &_thread_list, tle) { - /* Find the state: */ - for (j = 0; j < (sizeof(thread_info) / - sizeof(struct s_thread_info)) - 1; j++) - if (thread_info[j].state == pthread->state) - break; - /* Output a record for the current thread: */ - snprintf(s, sizeof(s), - "--------------------\nThread %p (%s) prio %3d state %s [%s:%d]\n", - pthread, (pthread->name == NULL) ? - "":pthread->name, pthread->base_priority, - thread_info[j].name, - pthread->fname,pthread->lineno); - _thread_sys_write(fd, s, strlen(s)); - - /* Check if this is the running thread: */ - if (pthread == curthread) { - /* Output a record for the running thread: */ - strcpy(s, "This is the running thread\n"); - _thread_sys_write(fd, s, strlen(s)); - } - /* Check if this is the initial thread: */ - if (pthread == _thread_initial) { - /* Output a record for the initial thread: */ - strcpy(s, "This is the initial thread\n"); - _thread_sys_write(fd, s, strlen(s)); - } - /* Process according to thread state: */ - switch (pthread->state) { - /* File descriptor read lock wait: */ - case PS_FDLR_WAIT: - case PS_FDLW_WAIT: - case PS_FDR_WAIT: - case PS_FDW_WAIT: - /* Write the lock details: */ - snprintf(s, sizeof(s), "fd %d[%s:%d]", - pthread->data.fd.fd, - pthread->data.fd.fname, - pthread->data.fd.branch); - _thread_sys_write(fd, s, strlen(s)); - if (_thread_fd_table[pthread->data.fd.fd]) - snprintf(s, sizeof(s), "owner %pr/%pw\n", - _thread_fd_table[pthread->data.fd.fd]->r_owner, - _thread_fd_table[pthread->data.fd.fd]->w_owner); - else - snprintf(s, sizeof(s), "owner [unknown]\n"); - - _thread_sys_write(fd, s, strlen(s)); - break; - case PS_SIGWAIT: - snprintf(s, sizeof(s), "sigmask (hi)"); - _thread_sys_write(fd, s, strlen(s)); - for (i = _SIG_WORDS - 1; i >= 0; i--) { - snprintf(s, sizeof(s), "%08x\n", - pthread->sigmask.__bits[i]); - _thread_sys_write(fd, s, strlen(s)); - } - snprintf(s, sizeof(s), "(lo)\n"); - _thread_sys_write(fd, s, strlen(s)); - break; - - /* - * Trap other states that are not explicitly - * coded to dump information: - */ - default: - /* Nothing to do here. */ - break; - } - } - - /* Output a header for ready threads: */ - strcpy(s, "\n\n=============\nREADY THREADS\n\n"); - _thread_sys_write(fd, s, strlen(s)); - - /* Enter a loop to report each thread in the ready queue: */ - TAILQ_FOREACH (pq_list, &_readyq.pq_queue, pl_link) { - TAILQ_FOREACH(pthread, &pq_list->pl_head, pqe) { - /* Find the state: */ - for (j = 0; j < (sizeof(thread_info) / - sizeof(struct s_thread_info)) - 1; j++) - if (thread_info[j].state == pthread->state) - break; - /* Output a record for the current thread: */ - snprintf(s, sizeof(s), - "--------------------\nThread %p (%s) prio %3d state %s [%s:%d]\n", - pthread, (pthread->name == NULL) ? - "":pthread->name, pthread->base_priority, - thread_info[j].name, - pthread->fname,pthread->lineno); - _thread_sys_write(fd, s, strlen(s)); - } - } - - /* Output a header for waiting threads: */ - strcpy(s, "\n\n=============\nWAITING THREADS\n\n"); - _thread_sys_write(fd, s, strlen(s)); - - /* Enter a loop to report each thread in the waiting queue: */ - TAILQ_FOREACH (pthread, &_waitingq, pqe) { - /* Find the state: */ - for (j = 0; j < (sizeof(thread_info) / - sizeof(struct s_thread_info)) - 1; j++) - if (thread_info[j].state == pthread->state) - break; - /* Output a record for the current thread: */ - snprintf(s, sizeof(s), - "--------------------\nThread %p (%s) prio %3d state %s [%s:%d]\n", - pthread, (pthread->name == NULL) ? - "":pthread->name, pthread->base_priority, - thread_info[j].name, - pthread->fname,pthread->lineno); - _thread_sys_write(fd, s, strlen(s)); - } - - /* Output a header for threads in the work queue: */ - strcpy(s, "\n\n=============\nTHREADS IN WORKQ\n\n"); - _thread_sys_write(fd, s, strlen(s)); - - /* Enter a loop to report each thread in the waiting queue: */ - TAILQ_FOREACH (pthread, &_workq, qe) { - /* Find the state: */ - for (j = 0; j < (sizeof(thread_info) / - sizeof(struct s_thread_info)) - 1; j++) - if (thread_info[j].state == pthread->state) - break; - /* Output a record for the current thread: */ - snprintf(s, sizeof(s), - "--------------------\nThread %p (%s) prio %3d state %s [%s:%d]\n", - pthread, (pthread->name == NULL) ? - "":pthread->name, pthread->base_priority, - thread_info[j].name, - pthread->fname,pthread->lineno); - _thread_sys_write(fd, s, strlen(s)); - } - - /* Check if there are no dead threads: */ - if (TAILQ_FIRST(&_dead_list) == NULL) { - /* Output a record: */ - strcpy(s, "\n\nTHERE ARE NO DEAD THREADS\n"); - _thread_sys_write(fd, s, strlen(s)); - } else { - /* Output a header for dead threads: */ - strcpy(s, "\n\nDEAD THREADS\n\n"); - _thread_sys_write(fd, s, strlen(s)); - - /* - * Enter a loop to report each thread in the global - * dead thread list: - */ - TAILQ_FOREACH(pthread, &_dead_list, dle) { - /* Output a record for the current thread: */ - snprintf(s, sizeof(s), - "Thread %p prio %3d [%s:%d]\n", - pthread, pthread->base_priority, - pthread->fname,pthread->lineno); - _thread_sys_write(fd, s, strlen(s)); - } - } - - /* Output a header for file descriptors: */ - snprintf(s, sizeof(s), "\n\n=============\nFILE DESCRIPTOR TABLE (table size %d)\n\n",_thread_dtablesize); - _thread_sys_write(fd, s, strlen(s)); - - /* Enter a loop to report file descriptor lock usage: */ - for (i = 0; i < _thread_dtablesize; i++) { - /* - * Check if memory is allocated for this file - * descriptor: - */ - if (_thread_fd_table[i] != NULL) { - /* Report the file descriptor lock status: */ - snprintf(s, sizeof(s), - "fd[%3d] read owner %p count %d [%s:%d]\n write owner %p count %d [%s:%d]\n", - i, - _thread_fd_table[i]->r_owner, - _thread_fd_table[i]->r_lockcount, - _thread_fd_table[i]->r_fname, - _thread_fd_table[i]->r_lineno, - _thread_fd_table[i]->w_owner, - _thread_fd_table[i]->w_lockcount, - _thread_fd_table[i]->w_fname, - _thread_fd_table[i]->w_lineno); - _thread_sys_write(fd, s, strlen(s)); - } - } - - /* Close the dump file: */ - _thread_sys_close(fd); - } - return; -} - -/* Set the thread name for debug: */ -void -pthread_set_name_np(pthread_t thread, char *name) -{ - /* Check if the caller has specified a valid thread: */ - if (thread != NULL && thread->magic == PTHREAD_MAGIC) - thread->name = strdup(name); - return; -} -#endif diff --git a/lib/libc_r/uthread/uthread_info_openbsd.c b/lib/libc_r/uthread/uthread_info_openbsd.c deleted file mode 100644 index 0b7881d6477..00000000000 --- a/lib/libc_r/uthread/uthread_info_openbsd.c +++ /dev/null @@ -1,476 +0,0 @@ -/* $OpenBSD: uthread_info_openbsd.c,v 1.7 2002/12/11 23:21:19 marc Exp $ */ - -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ -#include <stdio.h> -#include <fcntl.h> -#include <string.h> -#include <unistd.h> -#include <stdlib.h> -#include <stddef.h> -#include <paths.h> -#include <sys/poll.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int _thread_dump_verbose = 0; - -struct s_thread_info { - enum pthread_state state; - char *name; -}; - -/* Static variables: */ -static const struct s_thread_info thread_info[] = { - {PS_RUNNING , "running"}, - {PS_SIGTHREAD , "sigthread"}, - {PS_MUTEX_WAIT , "mutex_wait"}, - {PS_COND_WAIT , "cond_wait"}, - {PS_FDLR_WAIT , "fdlr_wait"}, - {PS_FDLW_WAIT , "fdlw_wait"}, - {PS_FDR_WAIT , "fdr_wait"}, - {PS_FDW_WAIT , "fdw_wait"}, - {PS_FILE_WAIT , "file_wait"}, - {PS_POLL_WAIT , "poll_wait"}, - {PS_SELECT_WAIT , "select_wait"}, - {PS_SLEEP_WAIT , "sleep_wait"}, - {PS_WAIT_WAIT , "wait_wait"}, - {PS_SIGSUSPEND , "sigsuspend"}, - {PS_SIGWAIT , "sigwait"}, - {PS_SPINBLOCK , "spinblock"}, - {PS_JOIN , "join"}, - {PS_SUSPENDED , "suspended"}, - {PS_DEAD , "dead"}, - {PS_DEADLOCK , "deadlock"}, - {(enum pthread_state)0, "<invalid>"}, -}; - -#define writestring(fd, s) _thread_sys_write(fd, s, (sizeof s) - 1) - -const static char info_lead[] = " -"; - -/* Determine a filename for display purposes: */ -static const char * -truncname(const char *name, int maxlen) -{ - int len; - - if (name == NULL) - name = "(null)"; - len = strlen(name); - if (len > maxlen) - return name + len - maxlen; - else - return name; -} - -static void -_thread_dump_entry(pthread, fd, verbose) - pthread_t pthread; - int fd; - int verbose; -{ - const char *state; - char s[512]; - char location[30]; - int j; - - /* Find last known file:line checkpoint: */ - if (pthread->fname && pthread->state != PS_RUNNING) - snprintf(location, sizeof location, "%s:%d", - truncname(pthread->fname, 21), pthread->lineno); - else - location[0] = '\0'; - - /* Find the state: */ - for (j = 0; j < (sizeof(thread_info) / - sizeof(struct s_thread_info)) - 1; j++) - if (thread_info[j].state == pthread->state) - break; - state = thread_info[j].name; - - /* Output a record for the current thread: */ - s[0] = 0; - snprintf(s, sizeof(s), - " %8p%c%-11s %2d %c%c%c%c%c%c%c%c%c%c %04x %-8.8s %s\n", - (void *)pthread, - (pthread == _thread_run) ? '*' : ' ', - state, - pthread->active_priority, - (pthread->flags & PTHREAD_FLAGS_PRIVATE) ? 'p' : '-', - (pthread->flags & PTHREAD_EXITING) ? 'E' : - (pthread->cancelflags & PTHREAD_AT_CANCEL_POINT) ? 'c' : '-', - (pthread->flags & PTHREAD_FLAGS_TRACE) ? 't' : '-', - (pthread->flags & PTHREAD_FLAGS_IN_CONDQ) ? 'C' : '-', - (pthread->flags & PTHREAD_FLAGS_IN_WORKQ) ? 'R' : '-', - (pthread->flags & PTHREAD_FLAGS_IN_WAITQ) ? 'W' : '-', - (pthread->flags & PTHREAD_FLAGS_IN_PRIOQ) ? 'P' : '-', - (pthread->attr.flags & PTHREAD_DETACHED) ? 'd' : '-', - (pthread->attr.flags & PTHREAD_INHERIT_SCHED) ? 'i' : '-', - (pthread->attr.flags & PTHREAD_NOFLOAT) ? '-' : 'f', - ((unsigned int)pthread->sigmask & 0xffff), - (pthread->name == NULL) ? "" : pthread->name, - (verbose) ? location : "" - ); - _thread_sys_write(fd, s, strlen(s)); - - if (!verbose) - return; - - /* Show the scheduler wake and time slice properties */ - snprintf(s, sizeof(s), "%s sched wake ", info_lead); - _thread_sys_write(fd, s, strlen(s)); - if (pthread->wakeup_time.tv_sec == -1) - writestring(fd, "- slice "); - else { - struct timeval now; - struct timespec nows, delta; - - gettimeofday(&now, NULL); - TIMEVAL_TO_TIMESPEC(&now, &nows); - timespecsub(&pthread->wakeup_time, &nows, &delta); - snprintf(s, sizeof s, "%d.%09ld slice ", - delta.tv_sec, delta.tv_nsec); - _thread_sys_write(fd, s, strlen(s)); - } - if (pthread->slice_usec == -1) - writestring(fd, "-\n"); - else { - snprintf(s, sizeof s, "%ld.%06ld\n", - pthread->slice_usec / 1000000, - pthread->slice_usec % 1000000); - _thread_sys_write(fd, s, strlen(s)); - } - - /* Process according to thread state: */ - switch (pthread->state) { - /* File descriptor read lock wait: */ - case PS_FDLR_WAIT: - case PS_FDLW_WAIT: - case PS_FDR_WAIT: - case PS_FDW_WAIT: - /* Write the lock details: */ - snprintf(s, sizeof(s), "%s fd %d [%s:%d]\n", - info_lead, - pthread->data.fd.fd, - truncname(pthread->data.fd.fname, 32), - pthread->data.fd.branch); - _thread_sys_write(fd, s, strlen(s)); - s[0] = 0; - if (_thread_fd_table[pthread->data.fd.fd]) - snprintf(s, sizeof(s), "%s owner %pr/%pw\n", - info_lead, - _thread_fd_table[pthread->data.fd.fd]->r_owner, - _thread_fd_table[pthread->data.fd.fd]->w_owner); - else - snprintf(s, sizeof(s), "%s owner [unknown]\n", info_lead); - _thread_sys_write(fd, s, strlen(s)); - break; - case PS_SIGWAIT: - snprintf(s, sizeof(s), "%s sigmask 0x%08lx\n", - info_lead, - (unsigned long)pthread->sigmask); - _thread_sys_write(fd, s, strlen(s)); - break; - case PS_MUTEX_WAIT: - snprintf(s, sizeof(s), - "%s mutex %p\n", - info_lead, - pthread->data.mutex); - _thread_sys_write(fd, s, strlen(s)); - if (pthread->data.mutex) { - snprintf(s, sizeof(s), - "%s owner %p\n", - info_lead, - pthread->data.mutex->m_owner); - _thread_sys_write(fd, s, strlen(s)); - } - break; - case PS_COND_WAIT: - snprintf(s, sizeof(s), - "%s cond %p\n", - info_lead, - pthread->data.cond); - _thread_sys_write(fd, s, strlen(s)); - break; -#ifdef notyet - case PS_JOIN: - { - struct pthread *t, * volatile *last; - pthread_entry_t *e; - - /* Find the end of the list: */ - for (e = &pthread->qe; e->tqe_next != NULL; - e = &e->tqe_next->qe) - ; - last = &e->tqe_next; - /* Walk backwards to the head: */ - for (e = &pthread->qe; - ((_thread_list_t *)e)->tqh_last != last; - e = (pthread_entry_t *)e->tqe_prev) - ; - /* Convert the head address into a thread address: */ - t = (pthread_t)((caddr_t)e - - offsetof(struct pthread, join_queue)); - snprintf(s, sizeof(s), - "%s thread %p\n", info_lead, t); - _thread_sys_write(fd, s, strlen(s)); - } - break; -#endif - case PS_SLEEP_WAIT: - { - struct timeval tv; - struct timespec current_time; - struct timespec remaining_time; - double remain; - - gettimeofday(&tv, NULL); - TIMEVAL_TO_TIMESPEC(&tv, ¤t_time); - timespecsub(&pthread->wakeup_time, - ¤t_time, &remaining_time); - remain = remaining_time.tv_sec - + (double)remaining_time.tv_nsec / 1e9; - snprintf(s, sizeof(s), - "%s wake in %f sec\n", - info_lead, remain); - _thread_sys_write(fd, s, strlen(s)); - } - break; - case PS_SELECT_WAIT: - case PS_POLL_WAIT: - { - int i; - - for (i = 0; i < pthread->data.poll_data->nfds; i++) - snprintf(s, sizeof(s), "%s%d:%s%s", - i ? " " : "", - pthread->data.poll_data->fds[i].fd, - pthread->data.poll_data->fds[i].events & - POLLIN ? "r" : "", - pthread->data.poll_data->fds[i].events & - POLLOUT ? "w" : "" - ); - snprintf(s, sizeof(s), "\n"); - } - break; - default: - /* Nothing to do here. */ - break; - } -} - -void -_thread_dump_info(void) -{ - char s[512]; - int fd; - int i; - pthread_t pthread; - pq_list_t * pq_list; - int verbose; - - verbose = _thread_dump_verbose; - if (getenv("PTHREAD_DEBUG") != NULL) - verbose = 1; - - /* Open the controlling tty: */ - fd = _thread_sys_open(_PATH_TTY, O_WRONLY | O_APPEND); - if (fd < 0) - return; - - if (!verbose) { - /* Display only a very brief list of threads */ - TAILQ_FOREACH(pthread, &_thread_list, tle) - if ((pthread->flags & PTHREAD_FLAGS_PRIVATE) == 0) - _thread_dump_entry(pthread, fd, 0); - return; - } - - /* Display a list of active threads: */ - snprintf(s, sizeof s, " %8s%c%-11s %2s %-10s %4s %-8s %s\n", - "id", ' ', "state", "pr", "flags", "mask", "name", "location"); - _thread_sys_write(fd, s, strlen(s)); - - writestring(fd, "active:\n"); - - TAILQ_FOREACH(pthread, &_thread_list, tle) - _thread_dump_entry(pthread, fd, 1); - - writestring(fd, "ready:\n"); - TAILQ_FOREACH (pq_list, &_readyq.pq_queue, pl_link) - TAILQ_FOREACH(pthread, &pq_list->pl_head, pqe) - _thread_dump_entry(pthread, fd, 0); - - writestring(fd, "waiting:\n"); - TAILQ_FOREACH (pthread, &_waitingq, pqe) - _thread_dump_entry(pthread, fd, 0); - - writestring(fd, "workq:\n"); - TAILQ_FOREACH (pthread, &_workq, qe) - _thread_dump_entry(pthread, fd, 0); - - writestring(fd, "dead:\n"); - TAILQ_FOREACH(pthread, &_dead_list, dle) - _thread_dump_entry(pthread, fd, 1); - - /* Output a header for file descriptors: */ - snprintf(s, sizeof(s), "file descriptor table, size %d:\n", - _thread_dtablesize); - _thread_sys_write(fd, s, strlen(s)); - - snprintf(s, sizeof s, - " %3s %8s %4s %21s %8s %4s %21s\n", - "fd", "rdowner", "rcnt", "rdcode", - "wrowner", "wcnt", "wrcode"); - _thread_sys_write(fd, s, strlen(s)); - - /* Enter a loop to report file descriptor lock usage: */ - for (i = 0; i < _thread_dtablesize; i++) { - /* - * Check if memory is allocated for this file - * descriptor: - */ - char rcode[22], wcode[22]; - - if (_thread_fd_table[i] != NULL) { - - /* Find the reader's last file:line: */ - if (_thread_fd_table[i]->r_owner) - snprintf(rcode, sizeof rcode, "%s:%d", - truncname(_thread_fd_table[i]->r_fname, 16), - _thread_fd_table[i]->r_lineno); - else - rcode[0] = '\0'; - - /* Find the writer's last file:line: */ - if (_thread_fd_table[i]->w_owner) - snprintf(wcode, sizeof wcode, "%s:%d", - truncname(_thread_fd_table[i]->w_fname, 16), - _thread_fd_table[i]->w_lineno); - else - wcode[0] = '\0'; - - /* Report the file descriptor lock status: */ - snprintf(s, sizeof(s), - " %3d %8p %4d %21s %8p %4d %21s\n", - i, - _thread_fd_table[i]->r_owner, - _thread_fd_table[i]->r_lockcount, - rcode, - _thread_fd_table[i]->w_owner, - _thread_fd_table[i]->w_lockcount, - wcode - ); - _thread_sys_write(fd, s, strlen(s)); - } - } - - /* Close the dump file: */ - _thread_sys_close(fd); - return; -} - -/* - * Generic "dump some data to /dev/tty in hex format" function - * output format is: - * 0 22 48 - * 0x0123456789abcdef: 00 11 22 33 44 55 66 77 01234567 - */ -#define DUMP_BUFLEN 84 -#define DUMP_HEX_OFF 22 -#define DUMP_ASCII_OFF 48 - -void -_thread_dump_data(const void *addr, int len) -{ - int fd = -1; - unsigned char data[ DUMP_BUFLEN ]; - - if (getenv("PTHREAD_DEBUG") != NULL) - fd = _thread_sys_open(_PATH_TTY, O_WRONLY | O_APPEND); - if (fd != -1) { - memset(data, ' ', DUMP_BUFLEN); - while (len) { - const unsigned char *d; - unsigned char *h; - unsigned char *a; - int count; - - d = addr; - h = &data[DUMP_HEX_OFF]; - a = &data[DUMP_ASCII_OFF]; - - if (len > 8) { - count = 8; - len -= 8; - } else { - count = len; - len = 0; - memset(data, ' ', DUMP_BUFLEN); - } - addr += 8; - - sprintf( data, "%18p: ", d ); - while (count--) { - if (isprint(*d)) - *a++ = *d; - else - *a++ = '.'; - *h++ = "0123456789abcdef"[(*d >> 4) & 0xf]; - *h++ = "0123456789abcdef"[*d++ & 0xf]; - *h++ = ' '; - } - *a++ = '\n'; - *a = 0; - _thread_sys_write(fd, data, a - data); - } - writestring(fd, "\n"); - _thread_sys_close(fd); - } -} - -/* Set the thread name for debug: */ -void -pthread_set_name_np(pthread_t thread, char *name) -{ - /* Check if the caller has specified a valid thread: */ - if (thread != NULL && thread->magic == PTHREAD_MAGIC) { - if (thread->name != NULL) - free(thread->name); - thread->name = strdup(name); - } - return; -} -#endif diff --git a/lib/libc_r/uthread/uthread_init.c b/lib/libc_r/uthread/uthread_init.c deleted file mode 100644 index b2414f7cc25..00000000000 --- a/lib/libc_r/uthread/uthread_init.c +++ /dev/null @@ -1,409 +0,0 @@ -/* $OpenBSD: uthread_init.c,v 1.25 2002/11/08 07:53:03 marc Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_init.c,v 1.18 1999/08/28 00:03:36 peter Exp $ - */ - -/* Allocate space for global thread variables here: */ -#define GLOBAL_PTHREAD_PRIVATE - -#include <sys/types.h> -#include <sys/param.h> - -#include <sys/ioctl.h> -#include <sys/mman.h> -#include <sys/mount.h> -#include <sys/socket.h> -#include <sys/stat.h> -#include <sys/sysctl.h> -#include <sys/time.h> -#include <sys/ttycom.h> -#include <sys/user.h> -#include <sys/wait.h> - -#include <dirent.h> -#include <errno.h> -#include <fcntl.h> -#include <paths.h> -#include <poll.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#ifdef _THREAD_SAFE -#include <machine/reg.h> -#include <pthread.h> -#include "pthread_private.h" - -/* Global thread variables. */ -_stack_list_t _stackq; - -extern int _thread_autoinit_dummy_decl; - -/* - * All weak references used within libc that are redefined in libc_r - * or libpthread MUST be in this table. This is necessary to force the - * proper version to be used when linking -static. - */ -static void *references[] = { - &_exit, - &accept, - &bind, - &close, - &connect, - &dup, - &dup2, - &execve, - &fchflags, - &fchmod, - &fchown, - &fcntl, - &flock, - &fork, - &fpathconf, - &fstat, - &fstatfs, - &fsync, - &getdirentries, - &getpeername, - &getsockname, - &getsockopt, - &ioctl, - &kevent, - &listen, - &msync, - &nanosleep, - &open, - &pipe, - &poll, - &read, - &readv, - &recvfrom, - &recvmsg, - &select, - &sendmsg, - &sendto, - &setsockopt, - &shutdown, - &sigaction, - &sigaltstack, - &sigpending, - &sigprocmask, - &sigsuspend, - &socket, - &socketpair, - &vfork, - &wait4, - &write, - &writev, - /* libc thread-safe helper functions */ - &_thread_fd_lock, - &_thread_fd_unlock, - &_thread_malloc_init, - &_thread_malloc_lock, - &_thread_malloc_unlock, - &_libc_private_storage, - &_libc_private_storage_lock, - &_libc_private_storage_unlock, - &flockfile, - &_flockfile_debug, - &ftrylockfile, - &funlockfile -}; - -/* - * Threaded process initialization - */ -void -_thread_init(void) -{ - int fd; - int flags; - int i; - size_t len; - int mib[2]; - struct clockinfo clockinfo; - struct sigaction act; - - /* Check if this function has already been called: */ - if (_thread_initial) - /* Only initialise the threaded application once. */ - return; - - if (references[0] == NULL) - PANIC("Failed loading mandatory references in _thread_init"); - - /* - * Check for the special case of this process running as - * or in place of init as pid = 1: - */ - if (getpid() == 1) { - /* - * Setup a new session for this process which is - * assumed to be running as root. - */ - if (setsid() == -1) - PANIC("Can't set session ID"); - if (revoke(_PATH_CONSOLE) != 0) - PANIC("Can't revoke console"); - if ((fd = _thread_sys_open(_PATH_CONSOLE, O_RDWR)) < 0) - PANIC("Can't open console"); - if (setlogin("root") == -1) - PANIC("Can't set login to root"); - if (_thread_sys_ioctl(fd,TIOCSCTTY, (char *) NULL) == -1) - PANIC("Can't set controlling terminal"); - if (_thread_sys_dup2(fd,0) == -1 || - _thread_sys_dup2(fd,1) == -1 || - _thread_sys_dup2(fd,2) == -1) - PANIC("Can't dup2"); - } - - /* - * Create a pipe that is written to by the signal handler to prevent - * signals being missed in calls to _select: - */ - if (_thread_sys_pipe(_thread_kern_pipe) != 0) { - /* Cannot create pipe, so abort: */ - PANIC("Cannot create kernel pipe"); - } - /* Get the flags for the read pipe: */ - else if ((flags = _thread_sys_fcntl(_thread_kern_pipe[0], F_GETFL, NULL)) == -1) { - /* Abort this application: */ - PANIC("Cannot get kernel read pipe flags"); - } - /* Make the read pipe non-blocking: */ - else if (_thread_sys_fcntl(_thread_kern_pipe[0], F_SETFL, flags | O_NONBLOCK) == -1) { - /* Abort this application: */ - PANIC("Cannot make kernel read pipe non-blocking"); - } - /* Get the flags for the write pipe: */ - else if ((flags = _thread_sys_fcntl(_thread_kern_pipe[1], F_GETFL, NULL)) == -1) { - /* Abort this application: */ - PANIC("Cannot get kernel write pipe flags"); - } - /* Make the write pipe non-blocking: */ - else if (_thread_sys_fcntl(_thread_kern_pipe[1], F_SETFL, flags | O_NONBLOCK) == -1) { - /* Abort this application: */ - PANIC("Cannot get kernel write pipe flags"); - } - /* Allocate and initialize the ready queue: */ - else if (_pq_alloc(&_readyq, PTHREAD_MIN_PRIORITY, PTHREAD_LAST_PRIORITY) != 0) { - /* Abort this application: */ - PANIC("Cannot allocate priority ready queue."); - } - /* Allocate memory for the thread structure of the initial thread: */ - else if ((_thread_initial = (pthread_t) malloc(sizeof(struct pthread))) == NULL) { - /* - * Insufficient memory to initialise this application, so - * abort: - */ - PANIC("Cannot allocate memory for initial thread"); - } else { - /* Zero the global kernel thread structure: */ - memset(&_thread_kern_thread, 0, sizeof(struct pthread)); - _thread_kern_thread.flags = PTHREAD_FLAGS_PRIVATE; - memset(_thread_initial, 0, sizeof(struct pthread)); - - /* Initialize the waiting and work queues: */ - TAILQ_INIT(&_waitingq); - TAILQ_INIT(&_workq); - - /* Initialize the scheduling switch hook routine: */ - _sched_switch_hook = NULL; - - /* Initialize the thread stack cache: */ - SLIST_INIT(&_stackq); - - /* - * Write a magic value to the thread structure - * to help identify valid ones: - */ - _thread_initial->magic = PTHREAD_MAGIC; - - /* Set the initial cancel state */ - _thread_initial->cancelflags = PTHREAD_CANCEL_ENABLE | - PTHREAD_CANCEL_DEFERRED; - - /* Default the priority of the initial thread: */ - _thread_initial->base_priority = PTHREAD_DEFAULT_PRIORITY; - _thread_initial->active_priority = PTHREAD_DEFAULT_PRIORITY; - _thread_initial->inherited_priority = 0; - - /* Initialise the state of the initial thread: */ - _thread_initial->state = PS_RUNNING; - - /* Initialize joiner to NULL (no joiner): */ - _thread_initial->joiner = NULL; - - /* Initialize the owned mutex queue and count: */ - TAILQ_INIT(&(_thread_initial->mutexq)); - _thread_initial->priority_mutex_count = 0; - - /* Initialize the global scheduling time: */ - _sched_ticks = 0; - gettimeofday((struct timeval *) &_sched_tod, NULL); - - /* Initialize last active: */ - _thread_initial->last_active = (long) _sched_ticks; - - /* Give it a useful name */ - pthread_set_name_np(_thread_initial, "main"); - - /* Initialise the rest of the fields: */ - _thread_initial->poll_data.nfds = 0; - _thread_initial->poll_data.fds = NULL; - _thread_initial->sig_defer_count = 0; - _thread_initial->slice_usec = -1; - _thread_initial->sig_saved = 0; - _thread_initial->yield_on_sig_undefer = 0; - _thread_initial->specific_data = NULL; - _thread_initial->cleanup = NULL; - _thread_initial->flags = 0; - _thread_initial->error = 0; - _SPINLOCK_INIT(&_thread_initial->lock); - TAILQ_INIT(&_thread_list); - TAILQ_INSERT_HEAD(&_thread_list, _thread_initial, tle); - _set_curthread(_thread_initial); - - /* Initialise the global signal action structure: */ - sigfillset(&act.sa_mask); - act.sa_handler = (void (*) ()) _thread_sig_handler; - act.sa_flags = SA_SIGINFO; - - /* Clear pending signals for the process: */ - sigemptyset(&_process_sigpending); - - /* Initialize signal handling: */ - _thread_sig_init(); - - /* Enter a loop to get the existing signal status: */ - for (i = 1; i < NSIG; i++) { - /* Check for signals which cannot be trapped: */ - if (i == SIGKILL || i == SIGSTOP) { - } - - /* Get the signal handler details: */ - else if (_thread_sys_sigaction(i, NULL, - &_thread_sigact[i - 1]) != 0) { - /* - * Abort this process if signal - * initialisation fails: - */ - PANIC("Cannot read signal handler info"); - } - - /* Initialize the SIG_DFL dummy handler count. */ - _thread_dfl_count[i] = 0; - } - - /* - * Install the signal handler for the most important - * signals that the user-thread kernel needs. Actually - * SIGINFO isn't really needed, but it is nice to have. - */ - if (_thread_sys_sigaction(_SCHED_SIGNAL, &act, NULL) != 0 || - _thread_sys_sigaction(SIGINFO, &act, NULL) != 0 || - _thread_sys_sigaction(SIGCHLD, &act, NULL) != 0) { - /* - * Abort this process if signal initialization fails: - */ - PANIC("Cannot initialize signal handler"); - } - _thread_sigact[_SCHED_SIGNAL - 1].sa_flags = SA_SIGINFO; - _thread_sigact[SIGINFO - 1].sa_flags = SA_SIGINFO; - _thread_sigact[SIGCHLD - 1].sa_flags = SA_SIGINFO; - - /* Get the process signal mask: */ - _thread_sys_sigprocmask(SIG_SETMASK, NULL, &_process_sigmask); - - /* Get the kernel clockrate: */ - mib[0] = CTL_KERN; - mib[1] = KERN_CLOCKRATE; - len = sizeof (struct clockinfo); - if (sysctl(mib, 2, &clockinfo, &len, NULL, 0) == 0) - _clock_res_usec = clockinfo.tick > CLOCK_RES_USEC_MIN ? - clockinfo.tick : CLOCK_RES_USEC_MIN; - - /* Get the table size: */ - if ((_thread_dtablesize = getdtablesize()) < 0) { - /* - * Cannot get the system defined table size, so abort - * this process. - */ - PANIC("Cannot get dtablesize"); - } - /* Allocate memory for the file descriptor table: */ - if ((_thread_fd_table = (struct fd_table_entry **) malloc(sizeof(struct fd_table_entry *) * _thread_dtablesize)) == NULL) { - /* Avoid accesses to file descriptor table on exit: */ - _thread_dtablesize = 0; - - /* - * Cannot allocate memory for the file descriptor - * table, so abort this process. - */ - PANIC("Cannot allocate memory for file descriptor table"); - } - /* Allocate memory for the pollfd table: */ - if ((_thread_pfd_table = (struct pollfd *) malloc(sizeof(struct pollfd) * _thread_dtablesize)) == NULL) { - /* - * Cannot allocate memory for the file descriptor - * table, so abort this process. - */ - PANIC("Cannot allocate memory for pollfd table"); - } else { - /* - * Enter a loop to initialise the file descriptor - * table: - */ - for (i = 0; i < _thread_dtablesize; i++) { - /* Initialise the file descriptor table: */ - _thread_fd_table[i] = NULL; - } - - /* Initialize stdio file descriptor table entries: */ - for (i = 0; i < 3; i++) { - if ((_thread_fd_table_init(i) != 0) && - (errno != EBADF)) - PANIC("Cannot initialize stdio file " - "descriptor table entry"); - } - } - } - - /* Initialise the garbage collector mutex and condition variable. */ - if (pthread_mutex_init(&_gc_mutex,NULL) != 0 || - pthread_cond_init(&_gc_cond,NULL) != 0) - PANIC("Failed to initialise garbage collector mutex or condvar"); - - _thread_autoinit_dummy_decl = 0; -} -#endif diff --git a/lib/libc_r/uthread/uthread_ioctl.c b/lib/libc_r/uthread/uthread_ioctl.c deleted file mode 100644 index d7daa17196b..00000000000 --- a/lib/libc_r/uthread/uthread_ioctl.c +++ /dev/null @@ -1,80 +0,0 @@ -/* $OpenBSD: uthread_ioctl.c,v 1.3 1999/11/25 07:01:37 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_ioctl.c,v 1.6 1999/08/28 00:03:37 peter Exp $ - */ -#include <stdarg.h> -#include <sys/ioctl.h> -#ifdef _THREAD_SAFE -#include <sys/fcntl.h> /* O_NONBLOCK*/ -#include <pthread.h> -#include "pthread_private.h" - -int -ioctl(int fd, unsigned long request,...) -{ - int ret; - int *op; - va_list ap; - - /* Lock the file descriptor: */ - if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { - /* Initialise the variable argument list: */ - va_start(ap, request); - - switch( request) { - case FIONBIO: - /* - * descriptors must be non-blocking; we are only - * twiddling the flag based on the request - */ - op = va_arg(ap, int *); - _thread_fd_table[fd]->flags &= ~O_NONBLOCK; - _thread_fd_table[fd]->flags |= ((*op) ? O_NONBLOCK : 0); - ret = 0; - break; - default: - ret = _thread_sys_ioctl(fd, request, va_arg(ap, char *)); - break; - } - - /* Free variable arguments: */ - va_end(ap); - - /* Unlock the file descriptor: */ - _FD_UNLOCK(fd, FD_RDWR); - } - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_join.c b/lib/libc_r/uthread/uthread_join.c deleted file mode 100644 index 92fc58cdf12..00000000000 --- a/lib/libc_r/uthread/uthread_join.c +++ /dev/null @@ -1,163 +0,0 @@ -/* $OpenBSD: uthread_join.c,v 1.10 2002/01/19 23:49:32 fgsch Exp $ */ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_join.c,v 1.9 1999/08/28 00:03:37 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_join(pthread_t pthread, void **thread_return) -{ - struct pthread *curthread = _get_curthread(); - int ret = 0; - pthread_t thread; - - _thread_enter_cancellation_point(); - - /* Check if the caller has specified an invalid thread: */ - if (pthread == NULL || pthread->magic != PTHREAD_MAGIC) { - /* Invalid thread: */ - _thread_leave_cancellation_point(); - return (EINVAL); - } - - /* Check if the caller has specified itself: */ - if (pthread == curthread) { - /* Avoid a deadlock condition: */ - _thread_leave_cancellation_point(); - return (EDEADLK); - } - - /* - * Lock the garbage collector mutex to ensure that the garbage - * collector is not using the dead thread list. - */ - if (pthread_mutex_lock(&_gc_mutex) != 0) - PANIC("Cannot lock gc mutex"); - - /* - * Defer signals to protect the thread list from access - * by the signal handler: - */ - _thread_kern_sig_defer(); - - /* - * Unlock the garbage collector mutex, now that the garbage collector - * can't be run: - */ - if (pthread_mutex_unlock(&_gc_mutex) != 0) - PANIC("Cannot unlock gc mutex"); - - /* - * Search for the specified thread in the list of active threads. This - * is done manually here rather than calling _find_thread() because - * the searches in _thread_list and _dead_list (as well as setting up - * join/detach state) have to be done atomically. - */ - TAILQ_FOREACH(thread, &_thread_list, tle) { - if (thread == pthread) - break; - } - if (thread == NULL) { - /* - * Search for the specified thread in the list of dead threads: - */ - TAILQ_FOREACH(thread, &_dead_list, dle) { - if (thread == pthread) - break; - } - } - - /* Check if the thread was not found or has been detached: */ - if (thread == NULL || - ((pthread->attr.flags & PTHREAD_DETACHED) != 0)) { - /* Undefer and handle pending signals, yielding if necessary: */ - _thread_kern_sig_undefer(); - - /* Return an error: */ - ret = ESRCH; - - } else if (pthread->joiner != NULL) { - /* Undefer and handle pending signals, yielding if necessary: */ - _thread_kern_sig_undefer(); - - /* Multiple joiners are not supported. */ - ret = ENOTSUP; - - /* Check if the thread is not dead: */ - } else if (pthread->state != PS_DEAD) { - /* Set the running thread to be the joiner: */ - pthread->joiner = curthread; - - /* Keep track of which thread we're joining to: */ - curthread->join_status.thread = pthread; - - while (curthread->join_status.thread == pthread) { - /* Schedule the next thread: */ - _thread_kern_sched_state(PS_JOIN, __FILE__, __LINE__); - } - - /* - * The thread return value and error are set by the thread we're - * joining to when it exits or detaches: - */ - ret = curthread->join_status.error; - if ((ret == 0) && (thread_return != NULL)) - *thread_return = curthread->join_status.ret; - } else { - /* - * The thread exited (is dead) without being detached, and no - * thread has joined it. - */ - - /* Check if the return value is required: */ - if (thread_return != NULL) { - /* Return the thread's return value: */ - *thread_return = pthread->ret; - } - - /* Make the thread collectable by the garbage collector. */ - pthread->attr.flags |= PTHREAD_DETACHED; - - /* Undefer and handle pending signals, yielding if necessary: */ - _thread_kern_sig_undefer(); - } - - _thread_leave_cancellation_point(); - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_kern.c b/lib/libc_r/uthread/uthread_kern.c deleted file mode 100644 index cf1a6dcf6ac..00000000000 --- a/lib/libc_r/uthread/uthread_kern.c +++ /dev/null @@ -1,1141 +0,0 @@ -/* $OpenBSD: uthread_kern.c,v 1.23 2002/11/04 21:28:49 marc Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_kern.c,v 1.23 1999/09/29 15:18:39 marcel Exp $ - * - */ -#include <errno.h> -#include <poll.h> -#include <stdlib.h> -#include <stdarg.h> -#include <string.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/time.h> -#include <sys/socket.h> -#include <sys/uio.h> -#include <sys/syscall.h> -#include <fcntl.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -#if defined(PTHREAD_TRACE_KERN) -#define PTHREAD_TRACE(x) _thread_sys_write(-1, (void*) x, 0) -#else -#define PTHREAD_TRACE(x) -#endif - -/* - * local functions. Do NOT make these static... we want so see them in - * crash dumps. - */ -void _thread_kern_poll(int); -void _dequeue_signals(void); -inline void _thread_run_switch_hook(pthread_t, pthread_t); - -/* Static variables: */ -static int last_tick = 0; - -void -_thread_kern_sched_sig(void) -{ - struct pthread *curthread = _get_curthread(); - - PTHREAD_TRACE(1); - curthread->check_pending = 1; - _thread_kern_sched(NULL); -} - -void -_thread_kern_sched(struct sigcontext * scp) -{ - struct timespec ts; - struct timeval tv; - struct pthread *curthread = _get_curthread(); - pthread_t pthread, pthread_h; - unsigned int current_tick; - int add_to_prioq; - pthread_t old_thread_run; - - PTHREAD_TRACE(2); - - /* - * Flag the pthread kernel as executing scheduler code - * to avoid a scheduler signal from interrupting this - * execution and calling the scheduler again. - */ - _thread_kern_in_sched = 1; - - /* Check if this function was called from the signal handler: */ - if (scp != NULL) { - /* - * The signal handler should have saved the state of - * the current thread. Restore the process signal - * mask. - */ - if (_thread_sys_sigprocmask(SIG_SETMASK, - &_process_sigmask, NULL) != 0) - PANIC("Unable to restore process mask after signal"); - - /* - * Copy the signal context to the current thread's jump - * buffer: - */ - memcpy(&curthread->saved_sigcontext, scp, - sizeof(curthread->saved_sigcontext)); - - /* - * Save floating point state. - */ - _thread_machdep_save_float_state(&curthread->_machdep); - - /* Flag the signal context as the last state saved: */ - curthread->sig_saved = 1; - } else - /* Flag the jump buffer was the last state saved: */ - curthread->sig_saved = 0; - - /* If the currently running thread is a user thread, save it: */ - if ((curthread->flags & PTHREAD_FLAGS_PRIVATE) == 0) - _last_user_thread = curthread; - - /* Save errno. */ - curthread->error = errno; - - /* Save the current thread to switch from */ - old_thread_run = curthread; - - /* - * Enter a scheduling loop that finds the next thread that is - * ready to run. This loop completes when there are no more threads - * in the global list or when a thread has its state restored by - * either a sigreturn (if the state was saved as a sigcontext) or a - * switch. - */ - while (!(TAILQ_EMPTY(&_thread_list))) { - /* Get the current time of day: */ - GET_CURRENT_TOD(tv); - TIMEVAL_TO_TIMESPEC(&tv, &ts); - current_tick = _sched_ticks; - - /* - * Protect the scheduling queues from access by the signal - * handler. - */ - _queue_signals = 1; - add_to_prioq = 0; - - if (curthread != &_thread_kern_thread) { - /* - * This thread no longer needs to yield the CPU. - */ - curthread->yield_on_sig_undefer = 0; - - if (curthread->state != PS_RUNNING) { - /* - * Save the current time as the time that the - * thread became inactive: - */ - curthread->last_inactive = (long)current_tick; - if (curthread->last_inactive < - curthread->last_active) { - /* Account for a rollover: */ - curthread->last_inactive =+ - UINT_MAX + 1; - } - } - - /* - * Place the currently running thread into the - * appropriate queue(s). - */ - switch (curthread->state) { - case PS_DEAD: - case PS_STATE_MAX: /* to silence -Wall */ - case PS_SUSPENDED: - /* - * Dead and suspended threads are not placed - * in any queue: - */ - break; - - case PS_RUNNING: - /* - * Runnable threads can't be placed in the - * priority queue until after waiting threads - * are polled (to preserve round-robin - * scheduling). - */ - add_to_prioq = 1; - break; - - /* - * States which do not depend on file descriptor I/O - * operations or timeouts: - */ - case PS_DEADLOCK: - case PS_FDLR_WAIT: - case PS_FDLW_WAIT: - case PS_FILE_WAIT: - case PS_JOIN: - case PS_MUTEX_WAIT: - case PS_SIGSUSPEND: - case PS_SIGTHREAD: - case PS_SIGWAIT: - case PS_WAIT_WAIT: - /* No timeouts for these states: */ - curthread->wakeup_time.tv_sec = -1; - curthread->wakeup_time.tv_nsec = -1; - - /* Restart the time slice: */ - curthread->slice_usec = -1; - - /* Insert into the waiting queue: */ - PTHREAD_WAITQ_INSERT(curthread); - break; - - /* States which can timeout: */ - case PS_COND_WAIT: - case PS_SLEEP_WAIT: - /* Restart the time slice: */ - curthread->slice_usec = -1; - - /* Insert into the waiting queue: */ - PTHREAD_WAITQ_INSERT(curthread); - break; - - /* States that require periodic work: */ - case PS_SPINBLOCK: - /* No timeouts for this state: */ - curthread->wakeup_time.tv_sec = -1; - curthread->wakeup_time.tv_nsec = -1; - - /* Increment spinblock count: */ - _spinblock_count++; - - /* FALLTHROUGH */ - case PS_FDR_WAIT: - case PS_FDW_WAIT: - case PS_POLL_WAIT: - case PS_SELECT_WAIT: - /* Restart the time slice: */ - curthread->slice_usec = -1; - - /* Insert into the waiting queue: */ - PTHREAD_WAITQ_INSERT(curthread); - - /* Insert into the work queue: */ - PTHREAD_WORKQ_INSERT(curthread); - break; - } - - /* - * Are there pending signals for this thread? - * - * This check has to be performed after the thread - * has been placed in the queue(s) appropriate for - * its state. The process of adding pending signals - * can change a threads state, which in turn will - * attempt to add or remove the thread from any - * scheduling queue to which it belongs. - */ -#ifdef notyet - if (curthread->check_pending != 0) { - curthread->check_pending = 0; - _thread_sig_check_pending(curthread); - } -#endif - } - - /* - * Avoid polling file descriptors if there are none - * waiting: - */ - if (TAILQ_EMPTY(&_workq) != 0) { - } - /* - * Poll file descriptors only if a new scheduling signal - * has occurred or if we have no more runnable threads. - */ - else if (((current_tick = _sched_ticks) != last_tick) || - ((curthread->state != PS_RUNNING) && - (PTHREAD_PRIOQ_FIRST() == NULL))) { - /* Unprotect the scheduling queues: */ - _queue_signals = 0; - - /* - * Poll file descriptors to update the state of threads - * waiting on file I/O where data may be available: - */ - _thread_kern_poll(0); - - /* Protect the scheduling queues: */ - _queue_signals = 1; - } - last_tick = current_tick; - - /* - * Wake up threads that have timedout. This has to be - * done after polling in case a thread does a poll or - * select with zero time. - */ - PTHREAD_WAITQ_SETACTIVE(); - while (((pthread = TAILQ_FIRST(&_waitingq)) != NULL) && - (pthread->wakeup_time.tv_sec != -1) && - (((pthread->wakeup_time.tv_sec == 0) && - (pthread->wakeup_time.tv_nsec == 0)) || - (pthread->wakeup_time.tv_sec < ts.tv_sec) || - ((pthread->wakeup_time.tv_sec == ts.tv_sec) && - (pthread->wakeup_time.tv_nsec <= ts.tv_nsec)))) { - switch (pthread->state) { - case PS_POLL_WAIT: - case PS_SELECT_WAIT: - /* Return zero file descriptors ready: */ - pthread->data.poll_data->nfds = 0; - /* fall through */ - default: - /* - * Remove this thread from the waiting queue - * (and work queue if necessary) and place it - * in the ready queue. - */ - PTHREAD_WAITQ_CLEARACTIVE(); - if (pthread->flags & PTHREAD_FLAGS_IN_WORKQ) - PTHREAD_WORKQ_REMOVE(pthread); - PTHREAD_NEW_STATE(pthread, PS_RUNNING); - PTHREAD_WAITQ_SETACTIVE(); - break; - } - /* - * Flag the timeout in the thread structure: - */ - pthread->timeout = 1; - } - PTHREAD_WAITQ_CLEARACTIVE(); - - /* - * Check to see if the current thread needs to be added - * to the priority queue: - */ - if (add_to_prioq != 0) { - /* - * Save the current time as the time that the - * thread became inactive: - */ - current_tick = _sched_ticks; - curthread->last_inactive = (long)current_tick; - if (curthread->last_inactive < - curthread->last_active) { - /* Account for a rollover: */ - curthread->last_inactive =+ UINT_MAX + 1; - } - - if ((curthread->slice_usec != -1) && - (curthread->attr.sched_policy != SCHED_FIFO)) { - /* - * Accumulate the number of microseconds for - * which the current thread has run: - */ - curthread->slice_usec += - (curthread->last_inactive - - curthread->last_active) * - (long)_clock_res_usec; - /* Check for time quantum exceeded: */ - if (curthread->slice_usec > TIMESLICE_USEC) - curthread->slice_usec = -1; - } - - if (curthread->slice_usec == -1) { - /* - * The thread exceeded its time - * quantum or it yielded the CPU; - * place it at the tail of the - * queue for its priority. - */ - PTHREAD_PRIOQ_INSERT_TAIL(curthread); - } else { - /* - * The thread hasn't exceeded its - * interval. Place it at the head - * of the queue for its priority. - */ - PTHREAD_PRIOQ_INSERT_HEAD(curthread); - } - } - - /* - * Get the highest priority thread in the ready queue. - */ - pthread_h = PTHREAD_PRIOQ_FIRST(); - - /* Check if there are no threads ready to run: */ - if (pthread_h == NULL) { - /* - * Lock the pthread kernel by changing the pointer to - * the running thread to point to the global kernel - * thread structure: - */ - _set_curthread(&_thread_kern_thread); - curthread = &_thread_kern_thread; - - /* Unprotect the scheduling queues: */ - _queue_signals = 0; - - /* - * There are no threads ready to run, so wait until - * something happens that changes this condition: - */ - _thread_kern_poll(1); - - /* - * This process' usage will likely be very small - * while waiting in a poll. Since the scheduling - * clock is based on the profiling timer, it is - * unlikely that the profiling timer will fire - * and update the time of day. To account for this, - * get the time of day after polling with a timeout. - */ - gettimeofday((struct timeval *) &_sched_tod, NULL); - - /* Check once more for a runnable thread: */ - _queue_signals = 1; - pthread_h = PTHREAD_PRIOQ_FIRST(); - _queue_signals = 0; - } - - if (pthread_h != NULL) { - /* Remove the thread from the ready queue: */ - PTHREAD_PRIOQ_REMOVE(pthread_h); - - /* Unprotect the scheduling queues: */ - _queue_signals = 0; - - /* - * Check for signals queued while the scheduling - * queues were protected: - */ - while (_sigq_check_reqd != 0) { - /* Clear before handling queued signals: */ - _sigq_check_reqd = 0; - - /* Protect the scheduling queues again: */ - _queue_signals = 1; - - _dequeue_signals(); - - /* - * Check for a higher priority thread that - * became runnable due to signal handling. - */ - if (((pthread = PTHREAD_PRIOQ_FIRST()) != NULL) && - (pthread->active_priority > pthread_h->active_priority)) { - /* Remove the thread from the ready queue: */ - PTHREAD_PRIOQ_REMOVE(pthread); - - /* - * Insert the lower priority thread - * at the head of its priority list: - */ - PTHREAD_PRIOQ_INSERT_HEAD(pthread_h); - - /* There's a new thread in town: */ - pthread_h = pthread; - } - - /* Unprotect the scheduling queues: */ - _queue_signals = 0; - } - - /* Make the selected thread the current thread: */ - _set_curthread(pthread_h); - curthread = pthread_h; - - /* - * Save the current time as the time that the thread - * became active: - */ - current_tick = _sched_ticks; - curthread->last_active = (long) current_tick; - - /* - * Check if this thread is running for the first time - * or running again after using its full time slice - * allocation: - */ - if (curthread->slice_usec == -1) { - /* Reset the accumulated time slice period: */ - curthread->slice_usec = 0; - } - - /* Restore errno. */ - errno = curthread->error; - - /* - * Restore the new thread, saving current. - */ - _thread_machdep_switch(&curthread->_machdep, - &old_thread_run->_machdep); - - /* Check if a signal context was saved: */ - if (curthread->sig_saved == 1) { - /* - * Restore floating point state. - */ - _thread_machdep_restore_float_state(&curthread->_machdep); - - /* - * Do a sigreturn to restart the thread that - * was interrupted by a signal: - */ - _thread_kern_in_sched = 0; - - /* - * If we had a context switch, run any - * installed switch hooks. - */ - if ((_sched_switch_hook != NULL) && - (_last_user_thread != curthread)) { - _thread_run_switch_hook(_last_user_thread, - curthread); - } - - if (((curthread->cancelflags & - PTHREAD_AT_CANCEL_POINT) == 0) && - ((curthread->cancelflags & - PTHREAD_CANCEL_ASYNCHRONOUS) != 0)) - pthread_testcancel(); - - /* return to signal handler. This code - should be: - _thread_sys_sigreturn(&curthread->saved_sigcontext); - but that doesn't currently work on the - sparc */ - return; - } else { - /* - * This is the normal way out of the scheduler. - */ - _thread_kern_in_sched = 0; - - if (_sched_switch_hook != NULL) { - /* Run the installed switch hook: */ - _thread_run_switch_hook(_last_user_thread, - curthread); - } - - if (((curthread->cancelflags & - PTHREAD_AT_CANCEL_POINT) == 0) && - ((curthread->cancelflags & - PTHREAD_CANCEL_ASYNCHRONOUS) != 0)) - pthread_testcancel(); - return; - } - - /* This point should not be reached. */ - PANIC("Thread has returned from sigreturn or switch"); - } - } - - /* There are no more threads, so exit this process: */ - exit(0); -} - -void -_thread_kern_sched_state(enum pthread_state state, char *fname, int lineno) -{ - struct pthread *curthread = _get_curthread(); - - PTHREAD_TRACE(3); - /* - * Flag the pthread kernel as executing scheduler code - * to avoid a scheduler signal from interrupting this - * execution and calling the scheduler again. - */ - _thread_kern_in_sched = 1; - - /* - * Prevent the signal handler from fiddling with this thread - * before its state is set and is placed into the proper queue. - */ - _queue_signals = 1; - - /* Change the state of the current thread: */ - curthread->state = state; - curthread->fname = fname; - curthread->lineno = lineno; - - /* Schedule the next thread that is ready: */ - _thread_kern_sched(NULL); -} - -void -_thread_kern_sched_state_unlock(enum pthread_state state, - spinlock_t *lock, char *fname, int lineno) -{ - struct pthread *curthread = _get_curthread(); - - PTHREAD_TRACE(4); - - /* - * Flag the pthread kernel as executing scheduler code - * to avoid a scheduler signal from interrupting this - * execution and calling the scheduler again. - */ - _thread_kern_in_sched = 1; - - /* - * Prevent the signal handler from fiddling with this thread - * before its state is set and it is placed into the proper - * queue(s). - */ - _queue_signals = 1; - - /* Change the state of the current thread: */ - curthread->state = state; - curthread->fname = fname; - curthread->lineno = lineno; - - _SPINUNLOCK(lock); - - /* Schedule the next thread that is ready: */ - _thread_kern_sched(NULL); -} - -void -_thread_kern_poll(int wait_reqd) -{ - int count = 0; - int i, found; - int kern_pipe_added = 0; - int nfds = 0; - int timeout_ms = 0; - struct pthread *pthread; - struct timespec ts; - struct timeval tv; - - PTHREAD_TRACE(5); - - /* Check if the caller wants to wait: */ - if (wait_reqd == 0) { - timeout_ms = 0; - } - else { - /* Get the current time of day: */ - GET_CURRENT_TOD(tv); - TIMEVAL_TO_TIMESPEC(&tv, &ts); - - _queue_signals = 1; - pthread = TAILQ_FIRST(&_waitingq); - _queue_signals = 0; - - if ((pthread == NULL) || (pthread->wakeup_time.tv_sec == -1)) { - /* - * Either there are no threads in the waiting queue, - * or there are no threads that can timeout. - */ - timeout_ms = INFTIM; - } - else if (pthread->wakeup_time.tv_sec - ts.tv_sec > 60000) - /* Limit maximum timeout to prevent rollover. */ - timeout_ms = 60000; - else { - /* - * Calculate the time left for the next thread to - * timeout: - */ - timeout_ms = ((pthread->wakeup_time.tv_sec - ts.tv_sec) * - 1000) + ((pthread->wakeup_time.tv_nsec - ts.tv_nsec) / - 1000000); - /* - * Don't allow negative timeouts: - */ - if (timeout_ms < 0) - timeout_ms = 0; - } - } - - /* Protect the scheduling queues: */ - _queue_signals = 1; - - /* - * Check to see if the signal queue needs to be walked to look - * for threads awoken by a signal while in the scheduler. - */ - if (_sigq_check_reqd != 0) { - /* Reset flag before handling queued signals: */ - _sigq_check_reqd = 0; - _dequeue_signals(); - } - - /* - * Check for a thread that became runnable due to a signal: - */ - if (PTHREAD_PRIOQ_FIRST() != NULL) { - /* - * Since there is at least one runnable thread, - * disable the wait. - */ - timeout_ms = 0; - } - - /* - * Form the poll table: - */ - nfds = 0; - if (timeout_ms != 0) { - /* Add the kernel pipe to the poll table: */ - _thread_pfd_table[nfds].fd = _thread_kern_pipe[0]; - _thread_pfd_table[nfds].events = POLLRDNORM; - _thread_pfd_table[nfds].revents = 0; - nfds++; - kern_pipe_added = 1; - } - - PTHREAD_WAITQ_SETACTIVE(); - TAILQ_FOREACH(pthread, &_workq, qe) { - switch (pthread->state) { - case PS_SPINBLOCK: - /* - * If the lock is available, let the thread run. - */ - if (pthread->data.spinlock->access_lock == - _SPINLOCK_UNLOCKED) { - PTHREAD_WAITQ_CLEARACTIVE(); - PTHREAD_WORKQ_REMOVE(pthread); - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - PTHREAD_WAITQ_SETACTIVE(); - /* One less thread in a spinblock state: */ - _spinblock_count--; - /* - * Since there is at least one runnable - * thread, disable the wait. - */ - timeout_ms = 0; - } - break; - - /* File descriptor read wait: */ - case PS_FDR_WAIT: - /* Limit number of polled files to table size: */ - if (nfds < _thread_dtablesize) { - _thread_pfd_table[nfds].events = POLLRDNORM; - _thread_pfd_table[nfds].fd = pthread->data.fd.fd; - nfds++; - } - break; - - /* File descriptor write wait: */ - case PS_FDW_WAIT: - /* Limit number of polled files to table size: */ - if (nfds < _thread_dtablesize) { - _thread_pfd_table[nfds].events = POLLWRNORM; - _thread_pfd_table[nfds].fd = pthread->data.fd.fd; - nfds++; - } - break; - - /* File descriptor poll or select wait: */ - case PS_POLL_WAIT: - case PS_SELECT_WAIT: - /* Limit number of polled files to table size: */ - if (pthread->data.poll_data->nfds + nfds < - _thread_dtablesize) { - for (i = 0; i < pthread->data.poll_data->nfds; i++) { - _thread_pfd_table[nfds + i].fd = - pthread->data.poll_data->fds[i].fd; - _thread_pfd_table[nfds + i].events = - pthread->data.poll_data->fds[i].events; - } - nfds += pthread->data.poll_data->nfds; - } - break; - - /* Other states do not depend on file I/O. */ - default: - break; - } - } - PTHREAD_WAITQ_CLEARACTIVE(); - - /* - * Wait for a file descriptor to be ready for read, write, or - * an exception, or a timeout to occur: - */ - count = _thread_sys_poll(_thread_pfd_table, nfds, timeout_ms); - - if (kern_pipe_added != 0) - /* - * Remove the pthread kernel pipe file descriptor - * from the pollfd table: - */ - nfds = 1; - else - nfds = 0; - - /* - * Check if it is possible that there are bytes in the kernel - * read pipe waiting to be read: - */ - if (count < 0 || ((kern_pipe_added != 0) && - (_thread_pfd_table[0].revents & POLLRDNORM))) { - /* - * If the kernel read pipe was included in the - * count: - */ - if (count > 0) { - /* Decrement the count of file descriptors: */ - count--; - } - - if (_sigq_check_reqd != 0) { - /* Reset flag before handling signals: */ - _sigq_check_reqd = 0; - _dequeue_signals(); - } - } - - /* - * Check if any file descriptors are ready: - */ - if (count > 0) { - /* - * Enter a loop to look for threads waiting on file - * descriptors that are flagged as available by the - * _poll syscall: - */ - PTHREAD_WAITQ_SETACTIVE(); - TAILQ_FOREACH(pthread, &_workq, qe) { - switch (pthread->state) { - case PS_SPINBLOCK: - /* - * If the lock is available, let the thread run. - */ - if (pthread->data.spinlock->access_lock == - _SPINLOCK_UNLOCKED) { - PTHREAD_WAITQ_CLEARACTIVE(); - PTHREAD_WORKQ_REMOVE(pthread); - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - PTHREAD_WAITQ_SETACTIVE(); - - /* - * One less thread in a spinblock state: - */ - _spinblock_count--; - } - break; - - /* File descriptor read wait: */ - case PS_FDR_WAIT: - if ((nfds < _thread_dtablesize) && - (_thread_pfd_table[nfds].revents & POLLRDNORM)) { - PTHREAD_WAITQ_CLEARACTIVE(); - PTHREAD_WORKQ_REMOVE(pthread); - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - PTHREAD_WAITQ_SETACTIVE(); - } - nfds++; - break; - - /* File descriptor write wait: */ - case PS_FDW_WAIT: - if ((nfds < _thread_dtablesize) && - (_thread_pfd_table[nfds].revents & POLLWRNORM)) { - PTHREAD_WAITQ_CLEARACTIVE(); - PTHREAD_WORKQ_REMOVE(pthread); - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - PTHREAD_WAITQ_SETACTIVE(); - } - nfds++; - break; - - /* File descriptor poll or select wait: */ - case PS_POLL_WAIT: - case PS_SELECT_WAIT: - if (pthread->data.poll_data->nfds + nfds < - _thread_dtablesize) { - /* - * Enter a loop looking for I/O - * readiness: - */ - found = 0; - for (i = 0; i < pthread->data.poll_data->nfds; i++) { - if (_thread_pfd_table[nfds + i].revents != 0) { - pthread->data.poll_data->fds[i].revents = - _thread_pfd_table[nfds + i].revents; - found++; - } - } - - /* Increment before destroying: */ - nfds += pthread->data.poll_data->nfds; - - if (found != 0) { - pthread->data.poll_data->nfds = found; - PTHREAD_WAITQ_CLEARACTIVE(); - PTHREAD_WORKQ_REMOVE(pthread); - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - PTHREAD_WAITQ_SETACTIVE(); - } - } - else - nfds += pthread->data.poll_data->nfds; - break; - - /* Other states do not depend on file I/O. */ - default: - break; - } - } - PTHREAD_WAITQ_CLEARACTIVE(); - } - else if (_spinblock_count != 0) { - /* - * Enter a loop to look for threads waiting on a spinlock - * that is now available. - */ - PTHREAD_WAITQ_SETACTIVE(); - TAILQ_FOREACH(pthread, &_workq, qe) { - if (pthread->state == PS_SPINBLOCK) { - /* - * If the lock is available, let the thread run. - */ - if (pthread->data.spinlock->access_lock == - _SPINLOCK_UNLOCKED) { - PTHREAD_WAITQ_CLEARACTIVE(); - PTHREAD_WORKQ_REMOVE(pthread); - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - PTHREAD_WAITQ_SETACTIVE(); - - /* - * One less thread in a spinblock state: - */ - _spinblock_count--; - } - } - } - PTHREAD_WAITQ_CLEARACTIVE(); - } - - /* Unprotect the scheduling queues: */ - _queue_signals = 0; - - while (_sigq_check_reqd != 0) { - /* Handle queued signals: */ - _sigq_check_reqd = 0; - - /* Protect the scheduling queues: */ - _queue_signals = 1; - _dequeue_signals(); - _queue_signals = 0; - } -} - -void -_thread_kern_set_timeout(const struct timespec * timeout) -{ - struct pthread *curthread = _get_curthread(); - struct timespec current_time; - struct timeval tv; - - PTHREAD_TRACE(6); - - /* Reset the timeout flag for the running thread: */ - curthread->timeout = 0; - - /* Check if the thread is to wait forever: */ - if (timeout == NULL) { - /* - * Set the wakeup time to something that can be recognised as - * different to an actual time of day: - */ - curthread->wakeup_time.tv_sec = -1; - curthread->wakeup_time.tv_nsec = -1; - } - /* Check if no waiting is required: */ - else if (timeout->tv_sec == 0 && timeout->tv_nsec == 0) { - /* Set the wake up time to 'immediately': */ - curthread->wakeup_time.tv_sec = 0; - curthread->wakeup_time.tv_nsec = 0; - } else { - /* Get the current time: */ - GET_CURRENT_TOD(tv); - TIMEVAL_TO_TIMESPEC(&tv, ¤t_time); - - /* Calculate the time for the current thread to wake up: */ - curthread->wakeup_time.tv_sec = current_time.tv_sec + timeout->tv_sec; - curthread->wakeup_time.tv_nsec = current_time.tv_nsec + timeout->tv_nsec; - - /* Check if the nanosecond field needs to wrap: */ - if (curthread->wakeup_time.tv_nsec >= 1000000000) { - /* Wrap the nanosecond field: */ - curthread->wakeup_time.tv_sec += 1; - curthread->wakeup_time.tv_nsec -= 1000000000; - } - } -} - -void -_thread_kern_sig_defer(void) -{ - struct pthread *curthread = _get_curthread(); - - PTHREAD_TRACE(7); - - /* Allow signal deferral to be recursive. */ - curthread->sig_defer_count++; -} - -void -_thread_kern_sig_undefer(void) -{ - struct pthread *curthread = _get_curthread(); - - PTHREAD_TRACE(8); - - /* - * Perform checks to yield only if we are about to undefer - * signals. - */ - if (curthread->sig_defer_count > 1) { - /* Decrement the signal deferral count. */ - curthread->sig_defer_count--; - } - else if (curthread->sig_defer_count == 1) { - /* Reenable signals: */ - curthread->sig_defer_count = 0; - - /* - * Check if there are queued signals: - */ - if (_sigq_check_reqd != 0) - _thread_kern_sched(NULL); - - /* - * Check for asynchronous cancellation before delivering any - * pending signals: - */ - if (((curthread->cancelflags & PTHREAD_AT_CANCEL_POINT) == 0) && - ((curthread->cancelflags & PTHREAD_CANCEL_ASYNCHRONOUS) != 0)) - pthread_testcancel(); - - /* - * If there are pending signals or this thread has - * to yield the CPU, call the kernel scheduler: - * - * XXX - Come back and revisit the pending signal problem - */ - if ((curthread->yield_on_sig_undefer != 0) || - curthread->sigpend != 0) { - curthread->yield_on_sig_undefer = 0; - _thread_kern_sched(NULL); - } - } -} - -void -_dequeue_signals(void) -{ - char bufr[128]; - int i, num; - - PTHREAD_TRACE(9); - - /* - * Enter a loop to read and handle queued signals from the - * pthread kernel pipe: - */ - while (((num = _thread_sys_read(_thread_kern_pipe[0], bufr, - sizeof(bufr))) > 0) || (num == -1 && errno == EINTR)) { - /* - * The buffer read contains one byte per signal and - * each byte is the signal number. - */ - for (i = 0; i < num; i++) { - if ((int) bufr[i] == _SCHED_SIGNAL) { - /* - * Scheduling signals shouldn't ever be - * queued; just ignore it for now. - */ - } - else { - /* Handle this signal: */ - _thread_sig_process((int) bufr[i], NULL); - } - } - } - if ((num < 0) && (errno != EAGAIN)) { - /* - * The only error we should expect is if there is - * no data to read. - */ - PANIC("Unable to read from thread kernel pipe"); - } -} - -inline void -_thread_run_switch_hook(pthread_t thread_out, pthread_t thread_in) -{ - pthread_t tid_out = thread_out; - pthread_t tid_in = thread_in; - - PTHREAD_TRACE(10); - - if ((tid_out != NULL) && - (tid_out->flags & PTHREAD_FLAGS_PRIVATE) != 0) - tid_out = NULL; - if ((tid_in != NULL) && - (tid_in->flags & PTHREAD_FLAGS_PRIVATE) != 0) - tid_in = NULL; - - if ((_sched_switch_hook != NULL) && (tid_out != tid_in)) { - /* Run the scheduler switch hook: */ - _sched_switch_hook(tid_out, tid_in); - } -} - -struct pthread * -_get_curthread(void) -{ - if (_thread_initial == NULL) - _thread_init(); - - return (_thread_run); -} - -void -_set_curthread(struct pthread *newthread) -{ - _thread_run = newthread; -} -#endif diff --git a/lib/libc_r/uthread/uthread_kevent.c b/lib/libc_r/uthread/uthread_kevent.c deleted file mode 100644 index fdbd61169b4..00000000000 --- a/lib/libc_r/uthread/uthread_kevent.c +++ /dev/null @@ -1,79 +0,0 @@ -/* $OpenBSD: uthread_kevent.c,v 1.3 2001/12/08 17:08:07 fgsch Exp $ */ - -/*- - * Copyright (c) 2000 Jonathan Lemon <jlemon@flugsvamp.com> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_kevent.c,v 1.5 2001/04/10 04:19:20 deischen Exp $ - */ - -#include <unistd.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/time.h> -#include <sys/event.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -kevent(int kq, const struct kevent *changelist, int nchanges, - struct kevent *eventlist, int nevents, const struct timespec *timeout) -{ - struct pthread *curthread = _get_curthread(); - struct timespec nullts = { 0, 0 }; - int rc; - - /* Set the wake up time */ - _thread_kern_set_timeout(timeout); - - rc = _thread_sys_kevent(kq, changelist, nchanges, - eventlist, nevents, &nullts); - if (rc == 0 && eventlist != NULL && nevents > 0 && (timeout == NULL || - timeout->tv_sec != 0 || timeout->tv_nsec != 0)) { - /* Save the socket file descriptor: */ - curthread->data.fd.fd = kq; - curthread->data.fd.fname = __FILE__; - curthread->data.fd.branch = __LINE__; - - do { - /* Reset the interrupted and timeout flags: */ - curthread->interrupted = 0; - curthread->timeout = 0; - - _thread_kern_sched_state(PS_FDR_WAIT, - __FILE__, __LINE__); - - if (curthread->interrupted) { - errno = EINTR; - rc = -1; - break; - } - rc = _thread_sys_kevent(kq, NULL, 0, - eventlist, nevents, &nullts); - } while (rc == 0 && curthread->timeout == 0); - } - return (rc); -} -#endif diff --git a/lib/libc_r/uthread/uthread_kill.c b/lib/libc_r/uthread/uthread_kill.c deleted file mode 100644 index 59d78b80ebf..00000000000 --- a/lib/libc_r/uthread/uthread_kill.c +++ /dev/null @@ -1,170 +0,0 @@ -/* $OpenBSD: uthread_kill.c,v 1.8 2002/10/30 19:11:56 marc Exp $ */ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_kill.c,v 1.9 1999/08/28 00:03:38 peter Exp $ - */ -#include <errno.h> -#include <signal.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* - * XXX THIS IS WRONG! The signal has to either come through the OS to - * get the proper siginfo, context, etc., or we need to gen up a - * siginfo (assuming needed). Signal reset and other semantics - * also need to be obeyed. - */ -int -pthread_kill(pthread_t pthread, int sig) -{ - int ret; - - /* Check for invalid signal numbers: */ - if (sig < 0 || sig >= NSIG) - /* Invalid signal: */ - ret = EINVAL; - - /* - * Ensure the thread is in the list of active threads, and the - * signal is valid (signal 0 specifies error checking only) and - * not being ignored: - */ - else if (((ret = _find_thread(pthread)) == 0) && (sig > 0) && - (_thread_sigact[sig - 1].sa_handler != SIG_IGN)) { - /* - * Defer signals to protect the scheduling queues from - * access by the signal handler: - */ - _thread_kern_sig_defer(); - - switch (pthread->state) { - case PS_SIGSUSPEND: - /* - * Only wake up the thread if the signal is unblocked - * and there is a handler installed for the signal. - */ - if (!sigismember(&pthread->sigmask, sig) && - _thread_sigact[sig - 1].sa_handler != SIG_DFL) { - /* Change the state of the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - - /* Return the signal number: */ - pthread->signo = sig; - } - sigaddset(&pthread->sigpend,sig); - break; - - case PS_SIGWAIT: - /* Wake up the thread if the signal is blocked. */ - if (sigismember(pthread->data.sigwait, sig)) { - /* Change the state of the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - - /* Return the signal number: */ - pthread->signo = sig; - } else - sigaddset(&pthread->sigpend,sig); - break; - - case PS_FDR_WAIT: - case PS_FDW_WAIT: - case PS_POLL_WAIT: - case PS_SLEEP_WAIT: - case PS_SELECT_WAIT: - if (!sigismember(&pthread->sigmask, sig) && - (_thread_sigact[sig - 1].sa_handler != SIG_IGN)) { - /* Flag the operation as interrupted: */ - pthread->interrupted = 1; - - if (pthread->flags & PTHREAD_FLAGS_IN_WORKQ) - PTHREAD_WORKQ_REMOVE(pthread); - - /* Change the state of the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - - /* Return the signal number: */ - pthread->signo = sig; - } else { - sigaddset(&pthread->sigpend,sig); - } - break; - - default: - /* Increment the pending signal count: */ - sigaddset(&pthread->sigpend,sig); - break; - } - - - /* - * Check that a custom handler is installed - * and if the signal is not blocked: - */ - if (_thread_sigact[sig - 1].sa_handler != SIG_DFL && - _thread_sigact[sig - 1].sa_handler != SIG_IGN && - sigismember(&pthread->sigpend, sig) && - !sigismember(&pthread->sigmask, sig)) { - pthread_t pthread_saved = _thread_run; - - /* Current thread inside critical region? */ - if (_thread_run->sig_defer_count > 0) - pthread->sig_defer_count++; - - _thread_run = pthread; - - /* Clear the pending signal: */ - sigdelset(&pthread->sigpend, sig); - - /* - * Dispatch the signal via the custom signal - * handler: ;;; what about SA_SIGINFO??? - */ - (*(_thread_sigact[sig - 1].sa_handler))(sig); - - _thread_run = pthread_saved; - - if (_thread_run->sig_defer_count > 0) - pthread->sig_defer_count--; - } - - /* - * Undefer and handle pending signals, yielding if - * necessary: - */ - _thread_kern_sig_undefer(); - } - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_listen.c b/lib/libc_r/uthread/uthread_listen.c deleted file mode 100644 index 0f9b312b3bb..00000000000 --- a/lib/libc_r/uthread/uthread_listen.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: uthread_listen.c,v 1.3 1999/11/25 07:01:38 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_listen.c,v 1.5 1999/08/28 00:03:38 peter Exp $ - */ -#include <sys/types.h> -#include <sys/socket.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -listen(int fd, int backlog) -{ - int ret; - - if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { - ret = _thread_sys_listen(fd, backlog); - _FD_UNLOCK(fd, FD_RDWR); - } - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_main_np.c b/lib/libc_r/uthread/uthread_main_np.c deleted file mode 100644 index 84dd1674a18..00000000000 --- a/lib/libc_r/uthread/uthread_main_np.c +++ /dev/null @@ -1,48 +0,0 @@ -/* $OpenBSD: uthread_main_np.c,v 1.1 2001/08/17 22:12:31 pvalchev Exp $ */ -/* - * Copyright (c) 2001 Alfred Perlstein - * Author: Alfred Perlstein <alfred@FreeBSD.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_main_np.c,v 1.2 2001/04/03 22:25:39 iedowse Exp $ - */ - -#ifdef _THREAD_SAFE -#include <pthread.h> -#include <pthread_np.h> -#include "pthread_private.h" - -/* - * Provide the equivalent to Solaris thr_main() function - */ -int -pthread_main_np() -{ - - if (!_thread_initial) - return (-1); - else - return (pthread_equal(pthread_self(), _thread_initial) ? 1 : 0); -} -#endif diff --git a/lib/libc_r/uthread/uthread_mattr_init.c b/lib/libc_r/uthread/uthread_mattr_init.c deleted file mode 100644 index 172ddb45b35..00000000000 --- a/lib/libc_r/uthread/uthread_mattr_init.c +++ /dev/null @@ -1,59 +0,0 @@ -/* $OpenBSD: uthread_mattr_init.c,v 1.4 1999/11/25 07:01:38 d Exp $ */ -/* - * Copyright (c) 1996 Jeffrey Hsu <hsu@freebsd.org>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_mattr_init.c,v 1.5 1999/08/28 00:03:39 peter Exp $ - */ -#include <string.h> -#include <stdlib.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_mutexattr_init(pthread_mutexattr_t *attr) -{ - int ret; - pthread_mutexattr_t pattr; - - if ((pattr = (pthread_mutexattr_t) - malloc(sizeof(struct pthread_mutex_attr))) == NULL) { - ret = ENOMEM; - } else { - memcpy(pattr, &pthread_mutexattr_default, - sizeof(struct pthread_mutex_attr)); - *attr = pattr; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_mattr_kind_np.c b/lib/libc_r/uthread/uthread_mattr_kind_np.c deleted file mode 100644 index ddc9bee01fe..00000000000 --- a/lib/libc_r/uthread/uthread_mattr_kind_np.c +++ /dev/null @@ -1,92 +0,0 @@ -/* $OpenBSD: uthread_mattr_kind_np.c,v 1.7 2001/08/10 14:37:20 fgsch Exp $ */ -/* - * Copyright (c) 1996 Jeffrey Hsu <hsu@freebsd.org>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_mattr_kind_np.c,v 1.4 1999/08/28 00:03:39 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, int kind) -{ - int ret; - if (attr == NULL || *attr == NULL) { - ret = EINVAL; - } else { - (*attr)->m_type = kind; - ret = 0; - } - return(ret); -} - -int -pthread_mutexattr_getkind_np(pthread_mutexattr_t attr) -{ - int ret; - if (attr == NULL) { - ret = EINVAL; - } else { - ret = attr->m_type; - } - return(ret); -} - -int -pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) -{ - int ret; - if (attr == NULL || *attr == NULL || type >= MUTEX_TYPE_MAX) { - ret = EINVAL; - } else { - (*attr)->m_type = type; - ret = 0; - } - return(ret); -} - -int -pthread_mutexattr_gettype(pthread_mutexattr_t *attr, int *type) -{ - int ret; - - if (attr == NULL || *attr == NULL || (*attr)->m_type >= - MUTEX_TYPE_MAX) { - ret = EINVAL; - } else { - *type = (*attr)->m_type; - ret = 0; - } - return ret; -} -#endif diff --git a/lib/libc_r/uthread/uthread_msync.c b/lib/libc_r/uthread/uthread_msync.c deleted file mode 100644 index 3edde1a31d4..00000000000 --- a/lib/libc_r/uthread/uthread_msync.c +++ /dev/null @@ -1,31 +0,0 @@ -/* - * David Leonard <d@openbsd.org>, 1999. Public Domain. - * - * $OpenBSD: uthread_msync.c,v 1.3 1999/11/25 07:01:38 d Exp $ - */ - -#include <sys/types.h> -#include <sys/mman.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -msync(addr, len, flags) - void *addr; - size_t len; - int flags; -{ - int ret; - - /* This is a cancellation point: */ - _thread_enter_cancellation_point(); - - ret = _thread_sys_msync(addr, len, flags); - - /* No longer in a cancellation point: */ - _thread_leave_cancellation_point(); - - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_multi_np.c b/lib/libc_r/uthread/uthread_multi_np.c deleted file mode 100644 index 88c6cbbfddf..00000000000 --- a/lib/libc_r/uthread/uthread_multi_np.c +++ /dev/null @@ -1,46 +0,0 @@ -/* $OpenBSD: uthread_multi_np.c,v 1.3 1999/11/25 07:01:38 d Exp $ */ -/* - * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_multi_np.c,v 1.3 1999/08/28 00:03:40 peter Exp $ - */ -#include <string.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_multi_np() -{ - /* Return to multi-threaded scheduling mode: */ - _thread_single = NULL; - return(0); -} -#endif diff --git a/lib/libc_r/uthread/uthread_mutex.c b/lib/libc_r/uthread/uthread_mutex.c deleted file mode 100644 index 79bd3573379..00000000000 --- a/lib/libc_r/uthread/uthread_mutex.c +++ /dev/null @@ -1,1548 +0,0 @@ -/* $OpenBSD: uthread_mutex.c,v 1.15 2002/10/30 19:11:56 marc Exp $ */ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_mutex.c,v 1.16 1999/08/28 00:03:40 peter Exp $ - */ -#include <stdlib.h> -#include <errno.h> -#include <string.h> -#include <sys/param.h> -#include <sys/queue.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -#if defined(_PTHREADS_INVARIANTS) -#define _MUTEX_INIT_LINK(m) do { \ - (m)->m_qe.tqe_prev = NULL; \ - (m)->m_qe.tqe_next = NULL; \ -} while (0) -#define _MUTEX_ASSERT_IS_OWNED(m) do { \ - if ((m)->m_qe.tqe_prev == NULL) \ - PANIC("mutex is not on list"); \ -} while (0) -#define _MUTEX_ASSERT_NOT_OWNED(m) do { \ - if (((m)->m_qe.tqe_prev != NULL) || \ - ((m)->m_qe.tqe_next != NULL)) \ - PANIC("mutex is on list"); \ -} while (0) -#else -#define _MUTEX_INIT_LINK(m) -#define _MUTEX_ASSERT_IS_OWNED(m) -#define _MUTEX_ASSERT_NOT_OWNED(m) -#endif - -/* - * Prototypes - */ -static inline int mutex_self_trylock(pthread_mutex_t); -static inline int mutex_self_lock(pthread_mutex_t); -static inline int mutex_unlock_common(pthread_mutex_t *, int); -static void mutex_priority_adjust(pthread_mutex_t); -static void mutex_rescan_owned (pthread_t, pthread_mutex_t); -static inline pthread_t mutex_queue_deq(pthread_mutex_t); -static inline void mutex_queue_remove(pthread_mutex_t, pthread_t); -static inline void mutex_queue_enq(pthread_mutex_t, pthread_t); - - -static spinlock_t static_init_lock = _SPINLOCK_INITIALIZER; - -static struct pthread_mutex_attr static_mutex_attr = - PTHREAD_MUTEXATTR_STATIC_INITIALIZER; -static pthread_mutexattr_t static_mattr = &static_mutex_attr; - -/* Reinitialize a mutex to defaults. */ -int -_mutex_reinit(pthread_mutex_t * mutex) -{ - int ret = 0; - - if (mutex == NULL) - ret = EINVAL; - else if (*mutex == NULL) - ret = pthread_mutex_init(mutex, NULL); - else { - /* - * Initialize the mutex structure: - */ - (*mutex)->m_type = PTHREAD_MUTEX_DEFAULT; - (*mutex)->m_protocol = PTHREAD_PRIO_NONE; - TAILQ_INIT(&(*mutex)->m_queue); - (*mutex)->m_owner = NULL; - (*mutex)->m_data.m_count = 0; - (*mutex)->m_flags &= MUTEX_FLAGS_PRIVATE; - (*mutex)->m_flags |= MUTEX_FLAGS_INITED; - (*mutex)->m_refcount = 0; - (*mutex)->m_prio = 0; - (*mutex)->m_saved_prio = 0; - _MUTEX_INIT_LINK(*mutex); - _SPINLOCK_INIT(&(*mutex)->lock); - } - return (ret); -} - -int -pthread_mutex_init(pthread_mutex_t * mutex, - const pthread_mutexattr_t * mutex_attr) -{ - enum pthread_mutextype type; - int protocol; - int ceiling; - int flags; - pthread_mutex_t pmutex; - int ret = 0; - - if (mutex == NULL) - ret = EINVAL; - - /* Check if default mutex attributes: */ - else if (mutex_attr == NULL || *mutex_attr == NULL) { - /* Default to a (error checking) POSIX mutex: */ - type = PTHREAD_MUTEX_ERRORCHECK; - protocol = PTHREAD_PRIO_NONE; - ceiling = PTHREAD_MAX_PRIORITY; - flags = 0; - } - - /* Check mutex type: */ - else if (((*mutex_attr)->m_type < PTHREAD_MUTEX_ERRORCHECK) || - ((*mutex_attr)->m_type >= MUTEX_TYPE_MAX)) - /* Return an invalid argument error: */ - ret = EINVAL; - - /* Check mutex protocol: */ - else if (((*mutex_attr)->m_protocol < PTHREAD_PRIO_NONE) || - ((*mutex_attr)->m_protocol > PTHREAD_PRIO_PROTECT)) - /* Return an invalid argument error: */ - ret = EINVAL; - - else { - /* Use the requested mutex type and protocol: */ - type = (*mutex_attr)->m_type; - protocol = (*mutex_attr)->m_protocol; - ceiling = (*mutex_attr)->m_ceiling; - flags = (*mutex_attr)->m_flags; - } - - /* Check no errors so far: */ - if (ret == 0) { - if ((pmutex = (pthread_mutex_t) - malloc(sizeof(struct pthread_mutex))) == NULL) - ret = ENOMEM; - else { - /* Set the mutex flags: */ - pmutex->m_flags = flags; - - /* Process according to mutex type: */ - switch (type) { - /* case PTHREAD_MUTEX_DEFAULT: */ - case PTHREAD_MUTEX_ERRORCHECK: - case PTHREAD_MUTEX_NORMAL: - /* Nothing to do here. */ - break; - - /* Single UNIX Spec 2 recursive mutex: */ - case PTHREAD_MUTEX_RECURSIVE: - /* Reset the mutex count: */ - pmutex->m_data.m_count = 0; - break; - - /* Trap invalid mutex types: */ - default: - /* Return an invalid argument error: */ - ret = EINVAL; - break; - } - if (ret == 0) { - /* Initialise the rest of the mutex: */ - TAILQ_INIT(&pmutex->m_queue); - pmutex->m_flags |= MUTEX_FLAGS_INITED; - pmutex->m_owner = NULL; - pmutex->m_type = type; - pmutex->m_protocol = protocol; - pmutex->m_refcount = 0; - if (protocol == PTHREAD_PRIO_PROTECT) - pmutex->m_prio = ceiling; - else - pmutex->m_prio = 0; - pmutex->m_saved_prio = 0; - _MUTEX_INIT_LINK(pmutex); - _SPINLOCK_INIT(&pmutex->lock); - *mutex = pmutex; - } else { - free((void *)pmutex); - *mutex = NULL; - } - } - } - /* Return the completion status: */ - return(ret); -} - -int -pthread_mutex_destroy(pthread_mutex_t * mutex) -{ - int ret = 0; - - if (mutex == NULL || *mutex == NULL) - ret = EINVAL; - else { - /* Lock the mutex structure: */ - _SPINLOCK(&(*mutex)->lock); - - /* - * Check to see if this mutex is in use: - */ - if (((*mutex)->m_owner != NULL) || - (TAILQ_FIRST(&(*mutex)->m_queue) != NULL) || - ((*mutex)->m_refcount != 0)) { - ret = EBUSY; - - /* Unlock the mutex structure: */ - _SPINUNLOCK(&(*mutex)->lock); - } - else { - /* - * Free the memory allocated for the mutex - * structure: - */ - _MUTEX_ASSERT_NOT_OWNED(*mutex); - free((void *)*mutex); - - /* - * Leave the caller's pointer NULL now that - * the mutex has been destroyed: - */ - *mutex = NULL; - } - } - - /* Return the completion status: */ - return (ret); -} - -static int -init_static(pthread_mutex_t *mutex) -{ - int ret; - - _SPINLOCK(&static_init_lock); - - if (*mutex == NULL) - ret = pthread_mutex_init(mutex, NULL); - else - ret = 0; - - _SPINUNLOCK(&static_init_lock); - - return(ret); -} - -static int -init_static_private(pthread_mutex_t *mutex) -{ - int ret; - - _SPINLOCK(&static_init_lock); - - if (*mutex == NULL) - ret = pthread_mutex_init(mutex, &static_mattr); - else - ret = 0; - - _SPINUNLOCK(&static_init_lock); - - return(ret); -} - -static int -mutex_trylock_common(pthread_mutex_t *mutex) -{ - struct pthread *curthread = _get_curthread(); - int ret = 0; - - PTHREAD_ASSERT((mutex != NULL) && (*mutex != NULL), - "Uninitialized mutex in mutex_trylock_common"); - - /* - * Defer signals to protect the scheduling queues from - * access by the signal handler: - */ - _thread_kern_sig_defer(); - - /* Lock the mutex structure: */ - _SPINLOCK(&(*mutex)->lock); - - /* - * If the mutex was statically allocated, properly - * initialize the tail queue. - */ - if (((*mutex)->m_flags & MUTEX_FLAGS_INITED) == 0) { - TAILQ_INIT(&(*mutex)->m_queue); - _MUTEX_INIT_LINK(*mutex); - (*mutex)->m_flags |= MUTEX_FLAGS_INITED; - } - - /* Process according to mutex type: */ - switch ((*mutex)->m_protocol) { - /* Default POSIX mutex: */ - case PTHREAD_PRIO_NONE: - /* Check if this mutex is not locked: */ - if ((*mutex)->m_owner == NULL) { - /* Lock the mutex for the running thread: */ - (*mutex)->m_owner = curthread; - - /* Add to the list of owned mutexes: */ - _MUTEX_ASSERT_NOT_OWNED(*mutex); - TAILQ_INSERT_TAIL(&curthread->mutexq, - (*mutex), m_qe); - } else if ((*mutex)->m_owner == curthread) - ret = mutex_self_trylock(*mutex); - else - /* Return a busy error: */ - ret = EBUSY; - break; - - /* POSIX priority inheritence mutex: */ - case PTHREAD_PRIO_INHERIT: - /* Check if this mutex is not locked: */ - if ((*mutex)->m_owner == NULL) { - /* Lock the mutex for the running thread: */ - (*mutex)->m_owner = curthread; - - /* Track number of priority mutexes owned: */ - curthread->priority_mutex_count++; - - /* - * The mutex takes on the attributes of the - * running thread when there are no waiters. - */ - (*mutex)->m_prio = curthread->active_priority; - (*mutex)->m_saved_prio = - curthread->inherited_priority; - - /* Add to the list of owned mutexes: */ - _MUTEX_ASSERT_NOT_OWNED(*mutex); - TAILQ_INSERT_TAIL(&curthread->mutexq, - (*mutex), m_qe); - } else if ((*mutex)->m_owner == curthread) - ret = mutex_self_trylock(*mutex); - else - /* Return a busy error: */ - ret = EBUSY; - break; - - /* POSIX priority protection mutex: */ - case PTHREAD_PRIO_PROTECT: - /* Check for a priority ceiling violation: */ - if (curthread->active_priority > (*mutex)->m_prio) - ret = EINVAL; - - /* Check if this mutex is not locked: */ - else if ((*mutex)->m_owner == NULL) { - /* Lock the mutex for the running thread: */ - (*mutex)->m_owner = curthread; - - /* Track number of priority mutexes owned: */ - curthread->priority_mutex_count++; - - /* - * The running thread inherits the ceiling - * priority of the mutex and executes at that - * priority. - */ - curthread->active_priority = (*mutex)->m_prio; - (*mutex)->m_saved_prio = - curthread->inherited_priority; - curthread->inherited_priority = - (*mutex)->m_prio; - - /* Add to the list of owned mutexes: */ - _MUTEX_ASSERT_NOT_OWNED(*mutex); - TAILQ_INSERT_TAIL(&curthread->mutexq, - (*mutex), m_qe); - } else if ((*mutex)->m_owner == curthread) - ret = mutex_self_trylock(*mutex); - else - /* Return a busy error: */ - ret = EBUSY; - break; - - /* Trap invalid mutex types: */ - default: - /* Return an invalid argument error: */ - ret = EINVAL; - break; - } - - /* Unlock the mutex structure: */ - _SPINUNLOCK(&(*mutex)->lock); - - /* - * Undefer and handle pending signals, yielding if - * necessary: - */ - _thread_kern_sig_undefer(); - - /* Return the completion status: */ - return (ret); -} - -int -pthread_mutex_trylock(pthread_mutex_t *mutex) -{ - int ret = 0; - - if (mutex == NULL) - ret = EINVAL; - - /* - * If the mutex is statically initialized, perform the dynamic - * initialization: - */ - else if ((*mutex != NULL) || (ret = init_static(mutex)) == 0) - ret = mutex_trylock_common(mutex); - - return (ret); -} - -int -_pthread_mutex_trylock(pthread_mutex_t *mutex) -{ - int ret = 0; - - if (mutex == NULL) - ret = EINVAL; - - /* - * If the mutex is statically initialized, perform the dynamic - * initialization marking the mutex private (delete safe): - */ - else if ((*mutex != NULL) || (ret = init_static_private(mutex)) == 0) - ret = mutex_trylock_common(mutex); - - return (ret); -} - -static int -mutex_lock_common(pthread_mutex_t * mutex) -{ - struct pthread *curthread = _get_curthread(); - int ret = 0; - - PTHREAD_ASSERT((mutex != NULL) && (*mutex != NULL), - "Uninitialized mutex in mutex_lock_common"); - - /* Reset the interrupted flag: */ - curthread->interrupted = 0; - - /* - * Enter a loop waiting to become the mutex owner. We need a - * loop in case the waiting thread is interrupted by a signal - * to execute a signal handler. It is not (currently) possible - * to remain in the waiting queue while running a handler. - * Instead, the thread is interrupted and backed out of the - * waiting queue prior to executing the signal handler. - */ - do { - /* - * Defer signals to protect the scheduling queues from - * access by the signal handler: - */ - _thread_kern_sig_defer(); - - /* Lock the mutex structure: */ - _SPINLOCK(&(*mutex)->lock); - - /* - * If the mutex was statically allocated, properly - * initialize the tail queue. - */ - if (((*mutex)->m_flags & MUTEX_FLAGS_INITED) == 0) { - TAILQ_INIT(&(*mutex)->m_queue); - (*mutex)->m_flags |= MUTEX_FLAGS_INITED; - _MUTEX_INIT_LINK(*mutex); - } - - /* Process according to mutex type: */ - switch ((*mutex)->m_protocol) { - /* Default POSIX mutex: */ - case PTHREAD_PRIO_NONE: - if ((*mutex)->m_owner == NULL) { - /* Lock the mutex for this thread: */ - (*mutex)->m_owner = curthread; - - /* Add to the list of owned mutexes: */ - _MUTEX_ASSERT_NOT_OWNED(*mutex); - TAILQ_INSERT_TAIL(&curthread->mutexq, - (*mutex), m_qe); - - } else if ((*mutex)->m_owner == curthread) - ret = mutex_self_lock(*mutex); - else { - /* - * Join the queue of threads waiting to lock - * the mutex: - */ - mutex_queue_enq(*mutex, curthread); - - /* - * Keep a pointer to the mutex this thread - * is waiting on: - */ - curthread->data.mutex = *mutex; - - /* - * Unlock the mutex structure and schedule the - * next thread: - */ - _thread_kern_sched_state_unlock(PS_MUTEX_WAIT, - &(*mutex)->lock, __FILE__, __LINE__); - - /* Lock the mutex structure again: */ - _SPINLOCK(&(*mutex)->lock); - } - break; - - /* POSIX priority inheritence mutex: */ - case PTHREAD_PRIO_INHERIT: - /* Check if this mutex is not locked: */ - if ((*mutex)->m_owner == NULL) { - /* Lock the mutex for this thread: */ - (*mutex)->m_owner = curthread; - - /* Track number of priority mutexes owned: */ - curthread->priority_mutex_count++; - - /* - * The mutex takes on attributes of the - * running thread when there are no waiters. - */ - (*mutex)->m_prio = curthread->active_priority; - (*mutex)->m_saved_prio = - curthread->inherited_priority; - curthread->inherited_priority = - (*mutex)->m_prio; - - /* Add to the list of owned mutexes: */ - _MUTEX_ASSERT_NOT_OWNED(*mutex); - TAILQ_INSERT_TAIL(&curthread->mutexq, - (*mutex), m_qe); - - } else if ((*mutex)->m_owner == curthread) - ret = mutex_self_lock(*mutex); - else { - /* - * Join the queue of threads waiting to lock - * the mutex: - */ - mutex_queue_enq(*mutex, curthread); - - /* - * Keep a pointer to the mutex this thread - * is waiting on: - */ - curthread->data.mutex = *mutex; - - if (curthread->active_priority > - (*mutex)->m_prio) - /* Adjust priorities: */ - mutex_priority_adjust(*mutex); - - /* - * Unlock the mutex structure and schedule the - * next thread: - */ - _thread_kern_sched_state_unlock(PS_MUTEX_WAIT, - &(*mutex)->lock, __FILE__, __LINE__); - - /* Lock the mutex structure again: */ - _SPINLOCK(&(*mutex)->lock); - } - break; - - /* POSIX priority protection mutex: */ - case PTHREAD_PRIO_PROTECT: - /* Check for a priority ceiling violation: */ - if (curthread->active_priority > (*mutex)->m_prio) - ret = EINVAL; - - /* Check if this mutex is not locked: */ - else if ((*mutex)->m_owner == NULL) { - /* - * Lock the mutex for the running - * thread: - */ - (*mutex)->m_owner = curthread; - - /* Track number of priority mutexes owned: */ - curthread->priority_mutex_count++; - - /* - * The running thread inherits the ceiling - * priority of the mutex and executes at that - * priority: - */ - curthread->active_priority = (*mutex)->m_prio; - (*mutex)->m_saved_prio = - curthread->inherited_priority; - curthread->inherited_priority = - (*mutex)->m_prio; - - /* Add to the list of owned mutexes: */ - _MUTEX_ASSERT_NOT_OWNED(*mutex); - TAILQ_INSERT_TAIL(&curthread->mutexq, - (*mutex), m_qe); - } else if ((*mutex)->m_owner == curthread) - ret = mutex_self_lock(*mutex); - else { - /* - * Join the queue of threads waiting to lock - * the mutex: - */ - mutex_queue_enq(*mutex, curthread); - - /* - * Keep a pointer to the mutex this thread - * is waiting on: - */ - curthread->data.mutex = *mutex; - - /* Clear any previous error: */ - curthread->error = 0; - - /* - * Unlock the mutex structure and schedule the - * next thread: - */ - _thread_kern_sched_state_unlock(PS_MUTEX_WAIT, - &(*mutex)->lock, __FILE__, __LINE__); - - /* Lock the mutex structure again: */ - _SPINLOCK(&(*mutex)->lock); - - /* - * The threads priority may have changed while - * waiting for the mutex causing a ceiling - * violation. - */ - ret = curthread->error; - curthread->error = 0; - } - break; - - /* Trap invalid mutex types: */ - default: - /* Return an invalid argument error: */ - ret = EINVAL; - break; - } - - /* - * Check to see if this thread was interrupted and - * is still in the mutex queue of waiting threads: - */ - if (curthread->interrupted != 0) - mutex_queue_remove(*mutex, curthread); - - /* Unlock the mutex structure: */ - _SPINUNLOCK(&(*mutex)->lock); - - /* - * Undefer and handle pending signals, yielding if - * necessary: - */ - _thread_kern_sig_undefer(); - } while (((*mutex)->m_owner != curthread) && (ret == 0) && - (curthread->interrupted == 0)); - - if (curthread->interrupted != 0 && - curthread->continuation != NULL) - curthread->continuation((void *) curthread); - - /* Return the completion status: */ - return (ret); -} - -int -pthread_mutex_lock(pthread_mutex_t *mutex) -{ - int ret = 0; - - if (_thread_initial == NULL) - _thread_init(); - - if (mutex == NULL) - ret = EINVAL; - - /* - * If the mutex is statically initialized, perform the dynamic - * initialization: - */ - else if ((*mutex != NULL) || ((ret = init_static(mutex)) == 0)) - ret = mutex_lock_common(mutex); - - return (ret); -} - -int -pthread_mutex_unlock(pthread_mutex_t * mutex) -{ - return (mutex_unlock_common(mutex, /* add reference */ 0)); -} - -int -_mutex_cv_unlock(pthread_mutex_t * mutex) -{ - return (mutex_unlock_common(mutex, /* add reference */ 1)); -} - -int -_mutex_cv_lock(pthread_mutex_t * mutex) -{ - int ret; - if ((ret = pthread_mutex_lock(mutex)) == 0) - (*mutex)->m_refcount--; - return (ret); -} - -static inline int -mutex_self_trylock(pthread_mutex_t mutex) -{ - int ret = 0; - - switch (mutex->m_type) { - - /* case PTHREAD_MUTEX_DEFAULT: */ - case PTHREAD_MUTEX_ERRORCHECK: - case PTHREAD_MUTEX_NORMAL: - /* - * POSIX specifies that mutexes should return EDEADLK if a - * recursive lock is detected. - */ - ret = EBUSY; - break; - - case PTHREAD_MUTEX_RECURSIVE: - /* Increment the lock count: */ - mutex->m_data.m_count++; - break; - - default: - /* Trap invalid mutex types; */ - ret = EINVAL; - } - - return(ret); -} - -static inline int -mutex_self_lock(pthread_mutex_t mutex) -{ - int ret = 0; - - switch (mutex->m_type) { - /* case PTHREAD_MUTEX_DEFAULT: */ - case PTHREAD_MUTEX_ERRORCHECK: - /* - * POSIX specifies that mutexes should return EDEADLK if a - * recursive lock is detected. - */ - ret = EDEADLK; - break; - - case PTHREAD_MUTEX_NORMAL: - /* - * What SS2 define as a 'normal' mutex. Intentionally - * deadlock on attempts to get a lock you already own. - */ - _thread_kern_sched_state_unlock(PS_DEADLOCK, - &mutex->lock, __FILE__, __LINE__); - break; - - case PTHREAD_MUTEX_RECURSIVE: - /* Increment the lock count: */ - mutex->m_data.m_count++; - break; - - default: - /* Trap invalid mutex types; */ - ret = EINVAL; - } - - return(ret); -} - -static inline int -mutex_unlock_common(pthread_mutex_t * mutex, int add_reference) -{ - struct pthread *curthread = _get_curthread(); - int ret = 0; - - if (mutex == NULL || *mutex == NULL) { - ret = EINVAL; - } else { - /* - * Defer signals to protect the scheduling queues from - * access by the signal handler: - */ - _thread_kern_sig_defer(); - - /* Lock the mutex structure: */ - _SPINLOCK(&(*mutex)->lock); - - /* Process according to mutex type: */ - switch ((*mutex)->m_protocol) { - /* Default POSIX mutex: */ - case PTHREAD_PRIO_NONE: - /* - * Check if the running thread is not the owner of the - * mutex: - */ - if ((*mutex)->m_owner != curthread) { - /* - * Return an invalid argument error for no - * owner and a permission error otherwise: - */ - ret = (*mutex)->m_owner == NULL ? EINVAL : EPERM; - } - else if (((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE) && - ((*mutex)->m_data.m_count > 0)) { - /* Decrement the count: */ - (*mutex)->m_data.m_count--; - } else { - /* - * Clear the count in case this is recursive - * mutex. - */ - (*mutex)->m_data.m_count = 0; - - /* Remove the mutex from the threads queue. */ - _MUTEX_ASSERT_IS_OWNED(*mutex); - TAILQ_REMOVE(&(*mutex)->m_owner->mutexq, - (*mutex), m_qe); - _MUTEX_INIT_LINK(*mutex); - - /* - * Get the next thread from the queue of - * threads waiting on the mutex: - */ - if (((*mutex)->m_owner = - mutex_queue_deq(*mutex)) != NULL) { - /* - * Unless the new owner of the mutex is - * currently suspended, allow the owner - * to run. If the thread is suspended, - * make a note that the thread isn't in - * a wait queue any more. - */ - if (((*mutex)->m_owner->state != - PS_SUSPENDED)) { - PTHREAD_NEW_STATE((*mutex)->m_owner, - PS_RUNNING); - } else { - (*mutex)->m_owner->suspended = - SUSP_NOWAIT; - } - - /* - * Add the mutex to the threads list of - * owned mutexes: - */ - TAILQ_INSERT_TAIL(&(*mutex)->m_owner->mutexq, - (*mutex), m_qe); - - /* - * The owner is no longer waiting for - * this mutex: - */ - (*mutex)->m_owner->data.mutex = NULL; - } - } - break; - - /* POSIX priority inheritence mutex: */ - case PTHREAD_PRIO_INHERIT: - /* - * Check if the running thread is not the owner of the - * mutex: - */ - if ((*mutex)->m_owner != curthread) { - /* - * Return an invalid argument error for no - * owner and a permission error otherwise: - */ - ret = (*mutex)->m_owner == NULL ? EINVAL : EPERM; - } - else if (((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE) && - ((*mutex)->m_data.m_count > 0)) { - /* Decrement the count: */ - (*mutex)->m_data.m_count--; - } else { - /* - * Clear the count in case this is recursive - * mutex. - */ - (*mutex)->m_data.m_count = 0; - - /* - * Restore the threads inherited priority and - * recompute the active priority (being careful - * not to override changes in the threads base - * priority subsequent to locking the mutex). - */ - curthread->inherited_priority = - (*mutex)->m_saved_prio; - curthread->active_priority = - MAX(curthread->inherited_priority, - curthread->base_priority); - - /* - * This thread now owns one less priority mutex. - */ - curthread->priority_mutex_count--; - - /* Remove the mutex from the threads queue. */ - _MUTEX_ASSERT_IS_OWNED(*mutex); - TAILQ_REMOVE(&(*mutex)->m_owner->mutexq, - (*mutex), m_qe); - _MUTEX_INIT_LINK(*mutex); - - /* - * Get the next thread from the queue of threads - * waiting on the mutex: - */ - if (((*mutex)->m_owner = - mutex_queue_deq(*mutex)) == NULL) - /* This mutex has no priority. */ - (*mutex)->m_prio = 0; - else { - /* - * Track number of priority mutexes owned: - */ - (*mutex)->m_owner->priority_mutex_count++; - - /* - * Add the mutex to the threads list - * of owned mutexes: - */ - TAILQ_INSERT_TAIL(&(*mutex)->m_owner->mutexq, - (*mutex), m_qe); - - /* - * The owner is no longer waiting for - * this mutex: - */ - (*mutex)->m_owner->data.mutex = NULL; - - /* - * Set the priority of the mutex. Since - * our waiting threads are in descending - * priority order, the priority of the - * mutex becomes the active priority of - * the thread we just dequeued. - */ - (*mutex)->m_prio = - (*mutex)->m_owner->active_priority; - - /* - * Save the owning threads inherited - * priority: - */ - (*mutex)->m_saved_prio = - (*mutex)->m_owner->inherited_priority; - - /* - * The owning threads inherited priority - * now becomes his active priority (the - * priority of the mutex). - */ - (*mutex)->m_owner->inherited_priority = - (*mutex)->m_prio; - - /* - * Unless the new owner of the mutex is - * currently suspended, allow the owner - * to run. If the thread is suspended, - * make a note that the thread isn't in - * a wait queue any more. - */ - if (((*mutex)->m_owner->state != - PS_SUSPENDED)) { - PTHREAD_NEW_STATE((*mutex)->m_owner, - PS_RUNNING); - } else { - (*mutex)->m_owner->suspended = - SUSP_NOWAIT; - } - } - } - break; - - /* POSIX priority ceiling mutex: */ - case PTHREAD_PRIO_PROTECT: - /* - * Check if the running thread is not the owner of the - * mutex: - */ - if ((*mutex)->m_owner != curthread) { - /* - * Return an invalid argument error for no - * owner and a permission error otherwise: - */ - ret = (*mutex)->m_owner == NULL ? EINVAL : EPERM; - } - else if (((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE) && - ((*mutex)->m_data.m_count > 0)) { - /* Decrement the count: */ - (*mutex)->m_data.m_count--; - } else { - /* - * Clear the count in case this is recursive - * mutex. - */ - (*mutex)->m_data.m_count = 0; - - /* - * Restore the threads inherited priority and - * recompute the active priority (being careful - * not to override changes in the threads base - * priority subsequent to locking the mutex). - */ - curthread->inherited_priority = - (*mutex)->m_saved_prio; - curthread->active_priority = - MAX(curthread->inherited_priority, - curthread->base_priority); - - /* - * This thread now owns one less priority mutex. - */ - curthread->priority_mutex_count--; - - /* Remove the mutex from the threads queue. */ - _MUTEX_ASSERT_IS_OWNED(*mutex); - TAILQ_REMOVE(&(*mutex)->m_owner->mutexq, - (*mutex), m_qe); - _MUTEX_INIT_LINK(*mutex); - - /* - * Enter a loop to find a waiting thread whose - * active priority will not cause a ceiling - * violation: - */ - while ((((*mutex)->m_owner = - mutex_queue_deq(*mutex)) != NULL) && - ((*mutex)->m_owner->active_priority > - (*mutex)->m_prio)) { - /* - * Either the mutex ceiling priority - * been lowered and/or this threads - * priority has been raised subsequent - * to this thread being queued on the - * waiting list. - */ - (*mutex)->m_owner->error = EINVAL; - PTHREAD_NEW_STATE((*mutex)->m_owner, - PS_RUNNING); - /* - * The thread is no longer waiting for - * this mutex: - */ - (*mutex)->m_owner->data.mutex = NULL; - } - - /* Check for a new owner: */ - if ((*mutex)->m_owner != NULL) { - /* - * Track number of priority mutexes owned: - */ - (*mutex)->m_owner->priority_mutex_count++; - - /* - * Add the mutex to the threads list - * of owned mutexes: - */ - TAILQ_INSERT_TAIL(&(*mutex)->m_owner->mutexq, - (*mutex), m_qe); - - /* - * The owner is no longer waiting for - * this mutex: - */ - (*mutex)->m_owner->data.mutex = NULL; - - /* - * Save the owning threads inherited - * priority: - */ - (*mutex)->m_saved_prio = - (*mutex)->m_owner->inherited_priority; - - /* - * The owning thread inherits the - * ceiling priority of the mutex and - * executes at that priority: - */ - (*mutex)->m_owner->inherited_priority = - (*mutex)->m_prio; - (*mutex)->m_owner->active_priority = - (*mutex)->m_prio; - - /* - * Unless the new owner of the mutex is - * currently suspended, allow the owner - * to run. If the thread is suspended, - * make a note that the thread isn't in - * a wait queue any more. - */ - if (((*mutex)->m_owner->state != - PS_SUSPENDED)) { - PTHREAD_NEW_STATE((*mutex)->m_owner, - PS_RUNNING); - } else { - (*mutex)->m_owner->suspended = - SUSP_NOWAIT; - } - } - } - break; - - /* Trap invalid mutex types: */ - default: - /* Return an invalid argument error: */ - ret = EINVAL; - break; - } - - if ((ret == 0) && (add_reference != 0)) { - /* Increment the reference count: */ - (*mutex)->m_refcount++; - } - - /* Unlock the mutex structure: */ - _SPINUNLOCK(&(*mutex)->lock); - - /* - * Undefer and handle pending signals, yielding if - * necessary: - */ - _thread_kern_sig_undefer(); - } - - /* Return the completion status: */ - return (ret); -} - - -/* - * This function is called when a change in base priority occurs for - * a thread that is holding or waiting for a priority protection or - * inheritence mutex. A change in a threads base priority can effect - * changes to active priorities of other threads and to the ordering - * of mutex locking by waiting threads. - * - * This must be called while thread scheduling is deferred. - */ -void -_mutex_notify_priochange(pthread_t pthread) -{ - /* Adjust the priorites of any owned priority mutexes: */ - if (pthread->priority_mutex_count > 0) { - /* - * Rescan the mutexes owned by this thread and correct - * their priorities to account for this threads change - * in priority. This has the side effect of changing - * the threads active priority. - */ - mutex_rescan_owned(pthread, /* rescan all owned */ NULL); - } - - /* - * If this thread is waiting on a priority inheritence mutex, - * check for priority adjustments. A change in priority can - * also effect a ceiling violation(*) for a thread waiting on - * a priority protection mutex; we don't perform the check here - * as it is done in pthread_mutex_unlock. - * - * (*) It should be noted that a priority change to a thread - * _after_ taking and owning a priority ceiling mutex - * does not affect ownership of that mutex; the ceiling - * priority is only checked before mutex ownership occurs. - */ - if (pthread->state == PS_MUTEX_WAIT) { - /* Lock the mutex structure: */ - _SPINLOCK(&pthread->data.mutex->lock); - - /* - * Check to make sure this thread is still in the same state - * (the spinlock above can yield the CPU to another thread): - */ - if (pthread->state == PS_MUTEX_WAIT) { - /* - * Remove and reinsert this thread into the list of - * waiting threads to preserve decreasing priority - * order. - */ - mutex_queue_remove(pthread->data.mutex, pthread); - mutex_queue_enq(pthread->data.mutex, pthread); - - if (pthread->data.mutex->m_protocol == - PTHREAD_PRIO_INHERIT) { - /* Adjust priorities: */ - mutex_priority_adjust(pthread->data.mutex); - } - } - - /* Unlock the mutex structure: */ - _SPINUNLOCK(&pthread->data.mutex->lock); - } -} - -/* - * Called when a new thread is added to the mutex waiting queue or - * when a threads priority changes that is already in the mutex - * waiting queue. - */ -static void -mutex_priority_adjust(pthread_mutex_t mutex) -{ - pthread_t pthread_next, pthread = mutex->m_owner; - int temp_prio; - pthread_mutex_t m = mutex; - - /* - * Calculate the mutex priority as the maximum of the highest - * active priority of any waiting threads and the owning threads - * active priority(*). - * - * (*) Because the owning threads current active priority may - * reflect priority inherited from this mutex (and the mutex - * priority may have changed) we must recalculate the active - * priority based on the threads saved inherited priority - * and its base priority. - */ - pthread_next = TAILQ_FIRST(&m->m_queue); /* should never be NULL */ - temp_prio = MAX(pthread_next->active_priority, - MAX(m->m_saved_prio, pthread->base_priority)); - - /* See if this mutex really needs adjusting: */ - if (temp_prio == m->m_prio) - /* No need to propagate the priority: */ - return; - - /* Set new priority of the mutex: */ - m->m_prio = temp_prio; - - while (m != NULL) { - /* - * Save the threads priority before rescanning the - * owned mutexes: - */ - temp_prio = pthread->active_priority; - - /* - * Fix the priorities for all the mutexes this thread has - * locked since taking this mutex. This also has a - * potential side-effect of changing the threads priority. - */ - mutex_rescan_owned(pthread, m); - - /* - * If the thread is currently waiting on a mutex, check - * to see if the threads new priority has affected the - * priority of the mutex. - */ - if ((temp_prio != pthread->active_priority) && - (pthread->state == PS_MUTEX_WAIT) && - (pthread->data.mutex->m_protocol == PTHREAD_PRIO_INHERIT)) { - /* Grab the mutex this thread is waiting on: */ - m = pthread->data.mutex; - - /* - * The priority for this thread has changed. Remove - * and reinsert this thread into the list of waiting - * threads to preserve decreasing priority order. - */ - mutex_queue_remove(m, pthread); - mutex_queue_enq(m, pthread); - - /* Grab the waiting thread with highest priority: */ - pthread_next = TAILQ_FIRST(&m->m_queue); - - /* - * Calculate the mutex priority as the maximum of the - * highest active priority of any waiting threads and - * the owning threads active priority. - */ - temp_prio = MAX(pthread_next->active_priority, - MAX(m->m_saved_prio, m->m_owner->base_priority)); - - if (temp_prio != m->m_prio) { - /* - * The priority needs to be propagated to the - * mutex this thread is waiting on and up to - * the owner of that mutex. - */ - m->m_prio = temp_prio; - pthread = m->m_owner; - } - else - /* We're done: */ - m = NULL; - - } - else - /* We're done: */ - m = NULL; - } -} - -static void -mutex_rescan_owned(pthread_t pthread, pthread_mutex_t mutex) -{ - int active_prio, inherited_prio; - pthread_mutex_t m; - pthread_t pthread_next; - - /* - * Start walking the mutexes the thread has taken since - * taking this mutex. - */ - if (mutex == NULL) { - /* - * A null mutex means start at the beginning of the owned - * mutex list. - */ - m = TAILQ_FIRST(&pthread->mutexq); - - /* There is no inherited priority yet. */ - inherited_prio = 0; - } - else { - /* - * The caller wants to start after a specific mutex. It - * is assumed that this mutex is a priority inheritence - * mutex and that its priority has been correctly - * calculated. - */ - m = TAILQ_NEXT(mutex, m_qe); - - /* Start inheriting priority from the specified mutex. */ - inherited_prio = mutex->m_prio; - } - active_prio = MAX(inherited_prio, pthread->base_priority); - - while (m != NULL) { - /* - * We only want to deal with priority inheritence - * mutexes. This might be optimized by only placing - * priority inheritence mutexes into the owned mutex - * list, but it may prove to be useful having all - * owned mutexes in this list. Consider a thread - * exiting while holding mutexes... - */ - if (m->m_protocol == PTHREAD_PRIO_INHERIT) { - /* - * Fix the owners saved (inherited) priority to - * reflect the priority of the previous mutex. - */ - m->m_saved_prio = inherited_prio; - - if ((pthread_next = TAILQ_FIRST(&m->m_queue)) != NULL) - /* Recalculate the priority of the mutex: */ - m->m_prio = MAX(active_prio, - pthread_next->active_priority); - else - m->m_prio = active_prio; - - /* Recalculate new inherited and active priorities: */ - inherited_prio = m->m_prio; - active_prio = MAX(m->m_prio, pthread->base_priority); - } - - /* Advance to the next mutex owned by this thread: */ - m = TAILQ_NEXT(m, m_qe); - } - - /* - * Fix the threads inherited priority and recalculate its - * active priority. - */ - pthread->inherited_priority = inherited_prio; - active_prio = MAX(inherited_prio, pthread->base_priority); - - if (active_prio != pthread->active_priority) { - /* - * If this thread is in the priority queue, it must be - * removed and reinserted for its new priority. - */ - if (pthread->flags & PTHREAD_FLAGS_IN_PRIOQ) { - /* - * Remove the thread from the priority queue - * before changing its priority: - */ - PTHREAD_PRIOQ_REMOVE(pthread); - - /* - * POSIX states that if the priority is being - * lowered, the thread must be inserted at the - * head of the queue for its priority if it owns - * any priority protection or inheritence mutexes. - */ - if ((active_prio < pthread->active_priority) && - (pthread->priority_mutex_count > 0)) { - /* Set the new active priority. */ - pthread->active_priority = active_prio; - - PTHREAD_PRIOQ_INSERT_HEAD(pthread); - } - else { - /* Set the new active priority. */ - pthread->active_priority = active_prio; - - PTHREAD_PRIOQ_INSERT_TAIL(pthread); - } - } - else { - /* Set the new active priority. */ - pthread->active_priority = active_prio; - } - } -} - -void -_mutex_unlock_private(pthread_t pthread) -{ - struct pthread_mutex volatile *m, *m_next; - - for (m = TAILQ_FIRST(&pthread->mutexq); m != NULL; m = m_next) { - m_next = TAILQ_NEXT(m, m_qe); - if ((m->m_flags & MUTEX_FLAGS_PRIVATE) != 0) - pthread_mutex_unlock(&m); - } -} - -void -_mutex_lock_backout(pthread_t pthread) -{ - struct pthread_mutex volatile *mutex; - - /* - * Defer signals to protect the scheduling queues from - * access by the signal handler: - */ - _thread_kern_sig_defer(); - if ((pthread->flags & PTHREAD_FLAGS_IN_MUTEXQ) != 0) { - mutex = pthread->data.mutex; - - /* Lock the mutex structure: */ - _SPINLOCK(&mutex->lock); - - mutex_queue_remove(mutex, pthread); - - /* This thread is no longer waiting for the mutex: */ - pthread->data.mutex = NULL; - - /* Unlock the mutex structure: */ - _SPINUNLOCK(&mutex->lock); - - } - /* - * Undefer and handle pending signals, yielding if - * necessary: - */ - _thread_kern_sig_undefer(); -} - -/* - * Dequeue a waiting thread from the head of a mutex queue in descending - * priority order. - */ -static inline pthread_t -mutex_queue_deq(pthread_mutex_t mutex) -{ - pthread_t pthread; - - while ((pthread = TAILQ_FIRST(&mutex->m_queue)) != NULL) { - TAILQ_REMOVE(&mutex->m_queue, pthread, sqe); - pthread->flags &= ~PTHREAD_FLAGS_IN_MUTEXQ; - - /* - * Only exit the loop if the thread hasn't been - * cancelled. - */ - if (pthread->interrupted == 0) - break; - } - - return(pthread); -} - -/* - * Remove a waiting thread from a mutex queue in descending priority order. - */ -static inline void -mutex_queue_remove(pthread_mutex_t mutex, pthread_t pthread) -{ - if ((pthread->flags & PTHREAD_FLAGS_IN_MUTEXQ) != 0) { - TAILQ_REMOVE(&mutex->m_queue, pthread, sqe); - pthread->flags &= ~PTHREAD_FLAGS_IN_MUTEXQ; - } -} - -/* - * Enqueue a waiting thread to a queue in descending priority order. - */ -static inline void -mutex_queue_enq(pthread_mutex_t mutex, pthread_t pthread) -{ - pthread_t tid = TAILQ_LAST(&mutex->m_queue, mutex_head); - - PTHREAD_ASSERT_NOT_IN_SYNCQ(pthread); - /* - * For the common case of all threads having equal priority, - * we perform a quick check against the priority of the thread - * at the tail of the queue. - */ - if ((tid == NULL) || (pthread->active_priority <= tid->active_priority)) - TAILQ_INSERT_TAIL(&mutex->m_queue, pthread, sqe); - else { - tid = TAILQ_FIRST(&mutex->m_queue); - while (pthread->active_priority <= tid->active_priority) - tid = TAILQ_NEXT(tid, sqe); - TAILQ_INSERT_BEFORE(tid, pthread, sqe); - } - pthread->flags |= PTHREAD_FLAGS_IN_MUTEXQ; -} - -#endif diff --git a/lib/libc_r/uthread/uthread_mutex_prioceiling.c b/lib/libc_r/uthread/uthread_mutex_prioceiling.c deleted file mode 100644 index afcd9372d47..00000000000 --- a/lib/libc_r/uthread/uthread_mutex_prioceiling.c +++ /dev/null @@ -1,111 +0,0 @@ -/* $OpenBSD: uthread_mutex_prioceiling.c,v 1.2 1999/11/25 07:01:40 d Exp $ */ -/* - * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Daniel Eischen. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_mutex_prioceiling.c,v 1.3 1999/08/28 00:03:40 peter Exp $ - */ -#include <string.h> -#include <stdlib.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_mutexattr_getprioceiling(pthread_mutexattr_t *mattr, int *prioceiling) -{ - int ret = 0; - - if ((mattr == NULL) || (*mattr == NULL)) - ret = EINVAL; - else if ((*mattr)->m_protocol != PTHREAD_PRIO_PROTECT) - ret = EINVAL; - else - *prioceiling = (*mattr)->m_ceiling; - - return(ret); -} - -int -pthread_mutexattr_setprioceiling(pthread_mutexattr_t *mattr, int prioceiling) -{ - int ret = 0; - - if ((mattr == NULL) || (*mattr == NULL)) - ret = EINVAL; - else if ((*mattr)->m_protocol != PTHREAD_PRIO_PROTECT) - ret = EINVAL; - else - (*mattr)->m_ceiling = prioceiling; - - return(ret); -} - -int -pthread_mutex_getprioceiling(pthread_mutex_t *mutex, - int *prioceiling) -{ - int ret; - - if ((mutex == NULL) || (*mutex == NULL)) - ret = EINVAL; - else if ((*mutex)->m_protocol != PTHREAD_PRIO_PROTECT) - ret = EINVAL; - else - ret = (*mutex)->m_prio; - - return(ret); -} - -int -pthread_mutex_setprioceiling(pthread_mutex_t *mutex, - int prioceiling, int *old_ceiling) -{ - int ret = 0; - - if ((mutex == NULL) || (*mutex == NULL)) - ret = EINVAL; - else if ((*mutex)->m_protocol != PTHREAD_PRIO_PROTECT) - ret = EINVAL; - else { - /* Lock the mutex: */ - if ((ret = pthread_mutex_lock(mutex)) == 0) { - /* Return the old ceiling and set the new ceiling: */ - *old_ceiling = (*mutex)->m_prio; - (*mutex)->m_prio = prioceiling; - - /* Unlock the mutex: */ - ret = pthread_mutex_unlock(mutex); - } - } - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_mutex_protocol.c b/lib/libc_r/uthread/uthread_mutex_protocol.c deleted file mode 100644 index 6b075ee4f2b..00000000000 --- a/lib/libc_r/uthread/uthread_mutex_protocol.c +++ /dev/null @@ -1,70 +0,0 @@ -/* $OpenBSD: uthread_mutex_protocol.c,v 1.2 1999/11/25 07:01:40 d Exp $ */ -/* - * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Daniel Eischen. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_mutex_protocol.c,v 1.3 1999/08/28 00:03:41 peter Exp $ - */ -#include <string.h> -#include <stdlib.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_mutexattr_getprotocol(pthread_mutexattr_t *mattr, int *protocol) -{ - int ret = 0; - - if ((mattr == NULL) || (*mattr == NULL)) - ret = EINVAL; - else - *protocol = (*mattr)->m_protocol; - - return(ret); -} - -int -pthread_mutexattr_setprotocol(pthread_mutexattr_t *mattr, int protocol) -{ - int ret = 0; - - if ((mattr == NULL) || (*mattr == NULL) || - (protocol < PTHREAD_PRIO_NONE) || (protocol > PTHREAD_PRIO_PROTECT)) - ret = EINVAL; - else { - (*mattr)->m_protocol = protocol; - (*mattr)->m_ceiling = PTHREAD_MAX_PRIORITY; - } - return(ret); -} - -#endif diff --git a/lib/libc_r/uthread/uthread_mutexattr_destroy.c b/lib/libc_r/uthread/uthread_mutexattr_destroy.c deleted file mode 100644 index 39b7d66efd3..00000000000 --- a/lib/libc_r/uthread/uthread_mutexattr_destroy.c +++ /dev/null @@ -1,54 +0,0 @@ -/* $OpenBSD: uthread_mutexattr_destroy.c,v 1.4 2002/11/07 02:56:20 marc Exp $ */ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_mutexattr_destroy.c,v 1.4 1999/08/28 00:03:41 peter Exp $ - */ -#include <stdlib.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_mutexattr_destroy(pthread_mutexattr_t *attr) -{ - int ret; - if (attr == NULL || *attr == NULL) { - ret = EINVAL; - } else { - free(*attr); - *attr = NULL; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_nanosleep.c b/lib/libc_r/uthread/uthread_nanosleep.c deleted file mode 100644 index 26a26c1c678..00000000000 --- a/lib/libc_r/uthread/uthread_nanosleep.c +++ /dev/null @@ -1,138 +0,0 @@ -/* $OpenBSD: uthread_nanosleep.c,v 1.7 2001/12/31 18:23:15 fgsch Exp $ */ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_nanosleep.c,v 1.10 1999/08/28 00:03:41 peter Exp $ - */ -#include <stdio.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -nanosleep(const struct timespec * time_to_sleep, - struct timespec * time_remaining) -{ - struct pthread *curthread = _get_curthread(); - int ret = 0; - struct timespec current_time; - struct timespec current_time1; - struct timespec remaining_time; - struct timeval tv; - - /* This is a cancellation point: */ - _thread_enter_cancellation_point(); - - /* Check if the time to sleep is legal: */ - if (time_to_sleep == NULL || time_to_sleep->tv_sec < 0 || - time_to_sleep->tv_nsec < 0 || time_to_sleep->tv_nsec >= 1000000000) { - /* Return an EINVAL error : */ - errno = EINVAL; - ret = -1; - } else { - /* - * As long as we're going to get the time of day, we - * might as well store it in the global time of day: - */ - gettimeofday((struct timeval *) &_sched_tod, NULL); - GET_CURRENT_TOD(tv); - TIMEVAL_TO_TIMESPEC(&tv, ¤t_time); - - /* Calculate the time for the current thread to wake up: */ - curthread->wakeup_time.tv_sec = current_time.tv_sec + time_to_sleep->tv_sec; - curthread->wakeup_time.tv_nsec = current_time.tv_nsec + time_to_sleep->tv_nsec; - - /* Check if the nanosecond field has overflowed: */ - if (curthread->wakeup_time.tv_nsec >= 1000000000) { - /* Wrap the nanosecond field: */ - curthread->wakeup_time.tv_sec += 1; - curthread->wakeup_time.tv_nsec -= 1000000000; - } - curthread->interrupted = 0; - - /* Reschedule the current thread to sleep: */ - _thread_kern_sched_state(PS_SLEEP_WAIT, __FILE__, __LINE__); - - /* - * As long as we're going to get the time of day, we - * might as well store it in the global time of day: - */ - gettimeofday((struct timeval *) &_sched_tod, NULL); - GET_CURRENT_TOD(tv); - TIMEVAL_TO_TIMESPEC(&tv, ¤t_time1); - - /* Calculate the remaining time to sleep: */ - remaining_time.tv_sec = time_to_sleep->tv_sec + current_time.tv_sec - current_time1.tv_sec; - remaining_time.tv_nsec = time_to_sleep->tv_nsec + current_time.tv_nsec - current_time1.tv_nsec; - - /* Check if the nanosecond field has underflowed: */ - if (remaining_time.tv_nsec < 0) { - /* Handle the underflow: */ - remaining_time.tv_sec -= 1; - remaining_time.tv_nsec += 1000000000; - } - - /* Check if the nanosecond field has overflowed: */ - if (remaining_time.tv_nsec >= 1000000000) { - /* Handle the overflow: */ - remaining_time.tv_sec += 1; - remaining_time.tv_nsec -= 1000000000; - } - - /* Check if the sleep was longer than the required time: */ - if (remaining_time.tv_sec < 0) { - /* Reset the time left: */ - remaining_time.tv_sec = 0; - remaining_time.tv_nsec = 0; - } - - /* Check if the time remaining is to be returned: */ - if (time_remaining != NULL) { - /* Return the actual time slept: */ - time_remaining->tv_sec = remaining_time.tv_sec; - time_remaining->tv_nsec = remaining_time.tv_nsec; - } - - /* Check if the sleep was interrupted: */ - if (curthread->interrupted) { - /* Return an EINTR error : */ - errno = EINTR; - ret = -1; - } - } - - /* No longer in a cancellation point: */ - _thread_leave_cancellation_point(); - - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_once.c b/lib/libc_r/uthread/uthread_once.c deleted file mode 100644 index a69116bfa33..00000000000 --- a/lib/libc_r/uthread/uthread_once.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $OpenBSD: uthread_once.c,v 1.4 2000/01/06 07:20:01 d Exp $ */ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_once.c,v 1.3 1999/08/28 00:03:42 peter Exp $ - */ -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_once(pthread_once_t * once_control, void (*init_routine) (void)) -{ - int ret; - - if (once_control->state == PTHREAD_NEEDS_INIT) { - if ((ret = pthread_mutex_lock(&(once_control->mutex))) != 0) - return ret; - if (once_control->state == PTHREAD_NEEDS_INIT) { - init_routine(); - once_control->state = PTHREAD_DONE_INIT; - } - pthread_mutex_unlock(&(once_control->mutex)); - } - return (0); -} -#endif diff --git a/lib/libc_r/uthread/uthread_open.c b/lib/libc_r/uthread/uthread_open.c deleted file mode 100644 index bf55d7d8bb9..00000000000 --- a/lib/libc_r/uthread/uthread_open.c +++ /dev/null @@ -1,80 +0,0 @@ -/* $OpenBSD: uthread_open.c,v 1.6 2000/01/06 07:20:10 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_open.c,v 1.6 1999/08/28 00:03:42 peter Exp $ - * - */ -#include <stdarg.h> -#include <unistd.h> -#include <fcntl.h> -#include <dirent.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -open(const char *path, int flags,...) -{ - int fd; - int mode = 0; - va_list ap; - - /* This is a cancellation point: */ - _thread_enter_cancellation_point(); - - /* Check if the file is being created: */ - if (flags & O_CREAT) { - /* Get the creation mode: */ - va_start(ap, flags); - mode = va_arg(ap, int); - va_end(ap); - } - /* Open the file: */ - if ((fd = _thread_sys_open(path, flags, mode)) < 0) { - } - /* Initialise the file descriptor table entry: */ - else if (_thread_fd_table_init(fd) != 0) { - /* Quietly close the file: */ - _thread_sys_close(fd); - - /* Reset the file descriptor: */ - fd = -1; - } - - /* No longer in a cancellation point: */ - _thread_leave_cancellation_point(); - - /* Return the file descriptor or -1 on error: */ - return (fd); -} -#endif diff --git a/lib/libc_r/uthread/uthread_pipe.c b/lib/libc_r/uthread/uthread_pipe.c deleted file mode 100644 index 6288ab82cbc..00000000000 --- a/lib/libc_r/uthread/uthread_pipe.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $OpenBSD: uthread_pipe.c,v 1.3 1999/11/25 07:01:41 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_pipe.c,v 1.5 1999/08/28 00:03:42 peter Exp $ - */ -#include <unistd.h> -#include <fcntl.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pipe(int fds[2]) -{ - int ret; - if ((ret = _thread_sys_pipe(fds)) >= 0) { - if (_thread_fd_table_init(fds[0]) != 0 || - _thread_fd_table_init(fds[1]) != 0) { - _thread_sys_close(fds[0]); - _thread_sys_close(fds[1]); - ret = -1; - } - } - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_poll.c b/lib/libc_r/uthread/uthread_poll.c deleted file mode 100644 index cb6915fbd36..00000000000 --- a/lib/libc_r/uthread/uthread_poll.c +++ /dev/null @@ -1,101 +0,0 @@ -/* $OpenBSD: uthread_poll.c,v 1.7 2002/01/10 00:38:39 fgsch Exp $ */ -/* - * Copyright (c) 1999 Daniel Eischen <eischen@vigrid.com> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Daniel Eischen. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_poll.c,v 1.4 1999/08/30 00:02:08 deischen Exp $ - */ -#include <unistd.h> -#include <errno.h> -#include <string.h> -#include <poll.h> -#include <sys/types.h> -#include <sys/time.h> -#include <sys/fcntl.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - - -int -poll(struct pollfd fds[], int nfds, int timeout) -{ - struct pthread *curthread = _get_curthread(); - struct timespec ts; - int numfds = nfds; - int i, ret = 0; - struct pthread_poll_data data; - - if (numfds > _thread_dtablesize) { - numfds = _thread_dtablesize; - } - /* Check if a timeout was specified: */ - if (timeout == INFTIM) { - /* Wait for ever: */ - _thread_kern_set_timeout(NULL); - } else if (timeout > 0) { - /* Convert the timeout in msec to a timespec: */ - ts.tv_sec = timeout / 1000; - ts.tv_nsec = (timeout % 1000) * 1000000; - - /* Set the wake up time: */ - _thread_kern_set_timeout(&ts); - } else if (timeout < 0) { - /* a timeout less than zero but not == INFTIM is invalid */ - errno = EINVAL; - return (-1); - } - - if (((ret = _thread_sys_poll(fds, numfds, 0)) == 0) && (timeout != 0)) { - data.nfds = numfds; - data.fds = fds; - - /* - * Clear revents in case of a timeout which leaves fds - * unchanged: - */ - for (i = 0; i < numfds; i++) { - fds[i].revents = 0; - } - - curthread->data.poll_data = &data; - curthread->interrupted = 0; - _thread_kern_sched_state(PS_POLL_WAIT, __FILE__, __LINE__); - if (curthread->interrupted) { - errno = EINTR; - ret = -1; - } else { - ret = data.nfds; - } - } - - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_priority_queue.c b/lib/libc_r/uthread/uthread_priority_queue.c deleted file mode 100644 index 918ff694aec..00000000000 --- a/lib/libc_r/uthread/uthread_priority_queue.c +++ /dev/null @@ -1,330 +0,0 @@ -/* $OpenBSD: uthread_priority_queue.c,v 1.4 2001/09/04 23:28:31 fgsch Exp $ */ -/* - * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Daniel Eischen. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_priority_queue.c,v 1.3 1999/08/28 00:03:43 peter Exp $ - */ -#include <stdlib.h> -#include <sys/queue.h> -#include <string.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* Prototypes: */ -static void pq_insert_prio_list(pq_queue_t *pq, int prio); - -#if defined(_PTHREADS_INVARIANTS) - -static int _pq_active = 0; - -#define _PQ_IN_SCHEDQ (PTHREAD_FLAGS_IN_PRIOQ | PTHREAD_FLAGS_IN_WAITQ | PTHREAD_FLAGS_IN_WORKQ) - -#define _PQ_SET_ACTIVE() _pq_active = 1 -#define _PQ_CLEAR_ACTIVE() _pq_active = 0 -#define _PQ_ASSERT_ACTIVE(msg) do { \ - if (_pq_active == 0) \ - PANIC(msg); \ -} while (0) -#define _PQ_ASSERT_INACTIVE(msg) do { \ - if (_pq_active != 0) \ - PANIC(msg); \ -} while (0) -#define _PQ_ASSERT_IN_WAITQ(thrd, msg) do { \ - if (((thrd)->flags & PTHREAD_FLAGS_IN_WAITQ) == 0) \ - PANIC(msg); \ -} while (0) -#define _PQ_ASSERT_IN_PRIOQ(thrd, msg) do { \ - if (((thrd)->flags & PTHREAD_FLAGS_IN_PRIOQ) == 0) \ - PANIC(msg); \ -} while (0) -#define _PQ_ASSERT_NOT_QUEUED(thrd, msg) do { \ - if (((thrd)->flags & _PQ_IN_SCHEDQ) != 0) \ - PANIC(msg); \ -} while (0) - -#else - -#define _PQ_SET_ACTIVE() -#define _PQ_CLEAR_ACTIVE() -#define _PQ_ASSERT_ACTIVE(msg) -#define _PQ_ASSERT_INACTIVE(msg) -#define _PQ_ASSERT_IN_WAITQ(thrd, msg) -#define _PQ_ASSERT_IN_PRIOQ(thrd, msg) -#define _PQ_ASSERT_NOT_QUEUED(thrd, msg) - -#endif - -int -_pq_alloc(pq_queue_t *pq, int minprio, int maxprio) -{ - int ret = 0; - int prioslots = maxprio - minprio + 1; - - if (pq == NULL) - ret = -1; - - /* Create the priority queue with (maxprio - minprio + 1) slots: */ - else if ((pq->pq_lists = - (pq_list_t *) malloc(sizeof(pq_list_t) * prioslots)) == NULL) - ret = -1; - - else { - /* Remember the queue size: */ - pq->pq_size = prioslots; - ret = _pq_init(pq); - } - return (ret); -} - -int -_pq_init(pq_queue_t *pq) -{ - int i, ret = 0; - - if ((pq == NULL) || (pq->pq_lists == NULL)) - ret = -1; - - else { - /* Initialize the queue for each priority slot: */ - for (i = 0; i < pq->pq_size; i++) { - TAILQ_INIT(&pq->pq_lists[i].pl_head); - pq->pq_lists[i].pl_prio = i; - pq->pq_lists[i].pl_queued = 0; - } - - /* Initialize the priority queue: */ - TAILQ_INIT(&pq->pq_queue); - _PQ_CLEAR_ACTIVE(); - } - return (ret); -} - -void -_pq_remove(pq_queue_t *pq, pthread_t pthread) -{ - int prio = pthread->active_priority; - - /* - * Make some assertions when debugging is enabled: - */ - _PQ_ASSERT_INACTIVE("_pq_remove: pq_active"); - _PQ_SET_ACTIVE(); - _PQ_ASSERT_IN_PRIOQ(pthread, "_pq_remove: Not in priority queue"); - - /* - * Remove this thread from priority list. Note that if - * the priority list becomes empty, it is not removed - * from the priority queue because another thread may be - * added to the priority list (resulting in a needless - * removal/insertion). Priority lists are only removed - * from the priority queue when _pq_first is called. - */ - TAILQ_REMOVE(&pq->pq_lists[prio].pl_head, pthread, pqe); - - /* This thread is now longer in the priority queue. */ - pthread->flags &= ~PTHREAD_FLAGS_IN_PRIOQ; - - _PQ_CLEAR_ACTIVE(); -} - - -void -_pq_insert_head(pq_queue_t *pq, pthread_t pthread) -{ - int prio = pthread->active_priority; - - /* - * Make some assertions when debugging is enabled: - */ - _PQ_ASSERT_INACTIVE("_pq_insert_head: pq_active"); - _PQ_SET_ACTIVE(); - _PQ_ASSERT_NOT_QUEUED(pthread, - "_pq_insert_head: Already in priority queue"); - - TAILQ_INSERT_HEAD(&pq->pq_lists[prio].pl_head, pthread, pqe); - if (pq->pq_lists[prio].pl_queued == 0) - /* Insert the list into the priority queue: */ - pq_insert_prio_list(pq, prio); - - /* Mark this thread as being in the priority queue. */ - pthread->flags |= PTHREAD_FLAGS_IN_PRIOQ; - - _PQ_CLEAR_ACTIVE(); -} - - -void -_pq_insert_tail(pq_queue_t *pq, pthread_t pthread) -{ - int prio = pthread->active_priority; - - /* - * Make some assertions when debugging is enabled: - */ - _PQ_ASSERT_INACTIVE("_pq_insert_tail: pq_active"); - _PQ_SET_ACTIVE(); - _PQ_ASSERT_NOT_QUEUED(pthread, - "_pq_insert_tail: Already in priority queue"); - - TAILQ_INSERT_TAIL(&pq->pq_lists[prio].pl_head, pthread, pqe); - if (pq->pq_lists[prio].pl_queued == 0) - /* Insert the list into the priority queue: */ - pq_insert_prio_list(pq, prio); - - /* Mark this thread as being in the priority queue. */ - pthread->flags |= PTHREAD_FLAGS_IN_PRIOQ; - - _PQ_CLEAR_ACTIVE(); -} - - -pthread_t -_pq_first(pq_queue_t *pq) -{ - pq_list_t *pql; - pthread_t pthread = NULL; - - /* - * Make some assertions when debugging is enabled: - */ - _PQ_ASSERT_INACTIVE("_pq_first: pq_active"); - _PQ_SET_ACTIVE(); - - while (((pql = TAILQ_FIRST(&pq->pq_queue)) != NULL) && - (pthread == NULL)) { - if ((pthread = TAILQ_FIRST(&pql->pl_head)) == NULL) { - /* - * The priority list is empty; remove the list - * from the queue. - */ - TAILQ_REMOVE(&pq->pq_queue, pql, pl_link); - - /* Mark the list as not being in the queue: */ - pql->pl_queued = 0; - } - } - - _PQ_CLEAR_ACTIVE(); - return (pthread); -} - - -static void -pq_insert_prio_list(pq_queue_t *pq, int prio) -{ - pq_list_t *pql; - - /* - * Make some assertions when debugging is enabled: - */ - _PQ_ASSERT_ACTIVE("pq_insert_prio_list: pq_active"); - - /* - * The priority queue is in descending priority order. Start at - * the beginning of the queue and find the list before which the - * new list should be inserted. - */ - pql = TAILQ_FIRST(&pq->pq_queue); - while ((pql != NULL) && (pql->pl_prio > prio)) - pql = TAILQ_NEXT(pql, pl_link); - - /* Insert the list: */ - if (pql == NULL) - TAILQ_INSERT_TAIL(&pq->pq_queue, &pq->pq_lists[prio], pl_link); - else - TAILQ_INSERT_BEFORE(pql, &pq->pq_lists[prio], pl_link); - - /* Mark this list as being in the queue: */ - pq->pq_lists[prio].pl_queued = 1; -} - -void -_waitq_insert(pthread_t pthread) -{ - pthread_t tid; - - /* - * Make some assertions when debugging is enabled: - */ - _PQ_ASSERT_INACTIVE("_waitq_insert: pq_active"); - _PQ_SET_ACTIVE(); - _PQ_ASSERT_NOT_QUEUED(pthread, "_waitq_insert: Already in queue"); - - if (pthread->wakeup_time.tv_sec == -1) - TAILQ_INSERT_TAIL(&_waitingq, pthread, pqe); - else { - tid = TAILQ_FIRST(&_waitingq); - while ((tid != NULL) && (tid->wakeup_time.tv_sec != -1) && - ((tid->wakeup_time.tv_sec < pthread->wakeup_time.tv_sec) || - ((tid->wakeup_time.tv_sec == pthread->wakeup_time.tv_sec) && - (tid->wakeup_time.tv_nsec <= pthread->wakeup_time.tv_nsec)))) - tid = TAILQ_NEXT(tid, pqe); - if (tid == NULL) - TAILQ_INSERT_TAIL(&_waitingq, pthread, pqe); - else - TAILQ_INSERT_BEFORE(tid, pthread, pqe); - } - pthread->flags |= PTHREAD_FLAGS_IN_WAITQ; - - _PQ_CLEAR_ACTIVE(); -} - -void -_waitq_remove(pthread_t pthread) -{ - /* - * Make some assertions when debugging is enabled: - */ - _PQ_ASSERT_INACTIVE("_waitq_remove: pq_active"); - _PQ_SET_ACTIVE(); - _PQ_ASSERT_IN_WAITQ(pthread, "_waitq_remove: Not in queue"); - - TAILQ_REMOVE(&_waitingq, pthread, pqe); - pthread->flags &= ~PTHREAD_FLAGS_IN_WAITQ; - - _PQ_CLEAR_ACTIVE(); -} - -void -_waitq_setactive(void) -{ - _PQ_ASSERT_INACTIVE("_waitq_setactive: pq_active"); - _PQ_SET_ACTIVE(); -} - -void -_waitq_clearactive(void) -{ - _PQ_ASSERT_ACTIVE("_waitq_clearactive: ! pq_active"); - _PQ_CLEAR_ACTIVE(); -} -#endif diff --git a/lib/libc_r/uthread/uthread_read.c b/lib/libc_r/uthread/uthread_read.c deleted file mode 100644 index b491ea99116..00000000000 --- a/lib/libc_r/uthread/uthread_read.c +++ /dev/null @@ -1,105 +0,0 @@ -/* $OpenBSD: uthread_read.c,v 1.7 2001/08/21 19:24:53 fgsch Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_read.c,v 1.8 1999/08/28 00:03:43 peter Exp $ - * - */ -#include <sys/types.h> -#include <sys/fcntl.h> -#include <sys/uio.h> -#include <errno.h> -#include <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -ssize_t -read(int fd, void *buf, size_t nbytes) -{ - struct pthread *curthread = _get_curthread(); - ssize_t ret; - int type; - - /* This is a cancellation point: */ - _thread_enter_cancellation_point(); - - /* POSIX says to do just this: */ - if (nbytes == 0) - ret = 0; - - /* Lock the file descriptor for read: */ - else if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) { - /* Get the read/write mode type: */ - type = _thread_fd_table[fd]->flags & O_ACCMODE; - - /* Check if the file is not open for read: */ - if (type != O_RDONLY && type != O_RDWR) { - /* File is not open for read: */ - errno = EBADF; - ret = -1; - } - - /* Perform a non-blocking read syscall: */ - else while ((ret = _thread_sys_read(fd, buf, nbytes)) < 0) { - if ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0 && - (errno == EWOULDBLOCK || errno == EAGAIN)) { - curthread->data.fd.fd = fd; - _thread_kern_set_timeout(NULL); - - /* Reset the interrupted operation flag: */ - curthread->interrupted = 0; - - _thread_kern_sched_state(PS_FDR_WAIT, - __FILE__, __LINE__); - - /* - * Check if the operation was - * interrupted by a signal - */ - if (curthread->interrupted) { - errno = EINTR; - ret = -1; - break; - } - } else { - break; - } - } - _FD_UNLOCK(fd, FD_READ); - } - - /* No longer in a cancellation point: */ - _thread_leave_cancellation_point(); - - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_readv.c b/lib/libc_r/uthread/uthread_readv.c deleted file mode 100644 index 05661166b4c..00000000000 --- a/lib/libc_r/uthread/uthread_readv.c +++ /dev/null @@ -1,95 +0,0 @@ -/* $OpenBSD: uthread_readv.c,v 1.5 2001/08/21 19:24:53 fgsch Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_readv.c,v 1.8 1999/08/28 00:03:43 peter Exp $ - * - */ -#include <sys/types.h> -#include <sys/fcntl.h> -#include <sys/uio.h> -#include <errno.h> -#include <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -ssize_t -readv(int fd, const struct iovec * iov, int iovcnt) -{ - struct pthread *curthread = _get_curthread(); - ssize_t ret; - int type; - - /* Lock the file descriptor for read: */ - if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) { - /* Get the read/write mode type: */ - type = _thread_fd_table[fd]->flags & O_ACCMODE; - - /* Check if the file is not open for read: */ - if (type != O_RDONLY && type != O_RDWR) { - /* File is not open for read: */ - errno = EBADF; - _FD_UNLOCK(fd, FD_READ); - return (-1); - } - - /* Perform a non-blocking readv syscall: */ - while ((ret = _thread_sys_readv(fd, iov, iovcnt)) < 0) { - if ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0 && - (errno == EWOULDBLOCK || errno == EAGAIN)) { - curthread->data.fd.fd = fd; - _thread_kern_set_timeout(NULL); - - /* Reset the interrupted operation flag: */ - curthread->interrupted = 0; - - _thread_kern_sched_state(PS_FDR_WAIT, - __FILE__, __LINE__); - - /* - * Check if the operation was - * interrupted by a signal - */ - if (curthread->interrupted) { - errno = EINTR; - ret = -1; - break; - } - } else { - break; - } - } - _FD_UNLOCK(fd, FD_READ); - } - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_recvfrom.c b/lib/libc_r/uthread/uthread_recvfrom.c deleted file mode 100644 index fee722f0b68..00000000000 --- a/lib/libc_r/uthread/uthread_recvfrom.c +++ /dev/null @@ -1,75 +0,0 @@ -/* $OpenBSD: uthread_recvfrom.c,v 1.5 2001/08/21 19:24:53 fgsch Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_recvfrom.c,v 1.5 1999/08/28 00:03:44 peter Exp $ - */ -#include <errno.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <fcntl.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -ssize_t -recvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr * from, socklen_t *from_len) -{ - struct pthread *curthread = _get_curthread(); - int ret; - - if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) { - while ((ret = _thread_sys_recvfrom(fd, buf, len, flags, from, from_len)) < 0) { - if (!(_thread_fd_table[fd]->flags & O_NONBLOCK) && ((errno == EWOULDBLOCK) || (errno == EAGAIN))) { - curthread->data.fd.fd = fd; - - /* Set the timeout: */ - _thread_kern_set_timeout(NULL); - curthread->interrupted = 0; - _thread_kern_sched_state(PS_FDR_WAIT, __FILE__, __LINE__); - - /* Check if the wait was interrupted: */ - if (curthread->interrupted) { - /* Return an error status: */ - errno = EINTR; - ret = -1; - break; - } - } else { - ret = -1; - break; - } - } - _FD_UNLOCK(fd, FD_READ); - } - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_recvmsg.c b/lib/libc_r/uthread/uthread_recvmsg.c deleted file mode 100644 index 73fa874b123..00000000000 --- a/lib/libc_r/uthread/uthread_recvmsg.c +++ /dev/null @@ -1,75 +0,0 @@ -/* $OpenBSD: uthread_recvmsg.c,v 1.4 2001/08/21 19:24:53 fgsch Exp $ */ -/* - * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_recvmsg.c,v 1.4 1999/08/28 00:03:44 peter Exp $ - */ -#include <errno.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <fcntl.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -ssize_t -recvmsg(int fd, struct msghdr *msg, int flags) -{ - struct pthread *curthread = _get_curthread(); - int ret; - - if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) { - while ((ret = _thread_sys_recvmsg(fd, msg, flags)) < 0) { - if (!(_thread_fd_table[fd]->flags & O_NONBLOCK) && ((errno == EWOULDBLOCK) || (errno == EAGAIN))) { - curthread->data.fd.fd = fd; - - /* Set the timeout: */ - _thread_kern_set_timeout(NULL); - curthread->interrupted = 0; - _thread_kern_sched_state(PS_FDR_WAIT, __FILE__, __LINE__); - - /* Check if the wait was interrupted: */ - if (curthread->interrupted) { - /* Return an error status: */ - errno = EINTR; - ret = -1; - break; - } - } else { - ret = -1; - break; - } - } - _FD_UNLOCK(fd, FD_READ); - } - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_resume_np.c b/lib/libc_r/uthread/uthread_resume_np.c deleted file mode 100644 index ace16df8e45..00000000000 --- a/lib/libc_r/uthread/uthread_resume_np.c +++ /dev/null @@ -1,97 +0,0 @@ -/* $OpenBSD: uthread_resume_np.c,v 1.5 2001/12/19 02:02:52 fgsch Exp $ */ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_resume_np.c,v 1.7 1999/08/28 00:03:44 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* Resume a thread: */ -int -pthread_resume_np(pthread_t thread) -{ - int ret; - enum pthread_susp old_suspended; - - /* Find the thread in the list of active threads: */ - if ((ret = _find_thread(thread)) == 0) { - /* Cancel any pending suspensions: */ - old_suspended = thread->suspended; - thread->suspended = SUSP_NO; - - /* Is it currently suspended? */ - if (thread->state == PS_SUSPENDED) { - /* - * Defer signals to protect the scheduling queues - * from access by the signal handler: - */ - _thread_kern_sig_defer(); - - switch (old_suspended) { - case SUSP_MUTEX_WAIT: - /* Set the thread's state back. */ - PTHREAD_SET_STATE(thread,PS_MUTEX_WAIT); - break; - case SUSP_COND_WAIT: - /* Set the thread's state back. */ - PTHREAD_SET_STATE(thread,PS_COND_WAIT); - break; - case SUSP_JOIN: - /* Set the thread's state back. */ - PTHREAD_SET_STATE(thread,PS_JOIN); - break; - case SUSP_NOWAIT: - /* Allow the thread to run. */ - PTHREAD_SET_STATE(thread,PS_RUNNING); - PTHREAD_WAITQ_REMOVE(thread); - PTHREAD_PRIOQ_INSERT_TAIL(thread); - break; - case SUSP_NO: - case SUSP_YES: - /* Allow the thread to run. */ - PTHREAD_SET_STATE(thread,PS_RUNNING); - PTHREAD_PRIOQ_INSERT_TAIL(thread); - break; - } - - /* - * Undefer and handle pending signals, yielding if - * necessary: - */ - _thread_kern_sig_undefer(); - } - } - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_rwlock.c b/lib/libc_r/uthread/uthread_rwlock.c deleted file mode 100644 index 144bd5ab826..00000000000 --- a/lib/libc_r/uthread/uthread_rwlock.c +++ /dev/null @@ -1,336 +0,0 @@ -/* $OpenBSD: uthread_rwlock.c,v 1.4 2002/05/07 05:17:15 pvalchev Exp $ */ -/*- - * Copyright (c) 1998 Alex Nash - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_rwlock.c,v 1.4 1999/08/28 00:03:45 peter Exp $ - */ - -#ifdef _THREAD_SAFE -#include <errno.h> -#include <limits.h> -#include <stdlib.h> - -#include <pthread.h> -#include "pthread_private.h" - -/* maximum number of times a read lock may be obtained */ -#define MAX_READ_LOCKS (INT_MAX - 1) - -static int init_static (pthread_rwlock_t *rwlock); - -static spinlock_t static_init_lock = _SPINLOCK_INITIALIZER; - -static int -init_static (pthread_rwlock_t *rwlock) -{ - int ret; - - _SPINLOCK(&static_init_lock); - - if (*rwlock == NULL) - ret = pthread_rwlock_init(rwlock, NULL); - else - ret = 0; - - _SPINUNLOCK(&static_init_lock); - - return(ret); -} - -int -pthread_rwlock_destroy (pthread_rwlock_t *rwlock) -{ - int ret; - - if (rwlock == NULL) - ret = EINVAL; - else { - pthread_rwlock_t prwlock; - - prwlock = *rwlock; - - pthread_mutex_destroy(&prwlock->lock); - pthread_cond_destroy(&prwlock->read_signal); - pthread_cond_destroy(&prwlock->write_signal); - free(prwlock); - - *rwlock = NULL; - - ret = 0; - } - - return(ret); -} - -int -pthread_rwlock_init (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) -{ - pthread_rwlock_t prwlock; - int ret; - - /* allocate rwlock object */ - prwlock = (pthread_rwlock_t)malloc(sizeof(struct pthread_rwlock)); - - if (prwlock == NULL) - return(ENOMEM); - - /* initialize the lock */ - if ((ret = pthread_mutex_init(&prwlock->lock, NULL)) != 0) - free(prwlock); - else { - /* initialize the read condition signal */ - ret = pthread_cond_init(&prwlock->read_signal, NULL); - - if (ret != 0) { - pthread_mutex_destroy(&prwlock->lock); - free(prwlock); - } else { - /* initialize the write condition signal */ - ret = pthread_cond_init(&prwlock->write_signal, NULL); - - if (ret != 0) { - pthread_cond_destroy(&prwlock->read_signal); - pthread_mutex_destroy(&prwlock->lock); - free(prwlock); - } else { - /* success */ - prwlock->state = 0; - prwlock->blocked_writers = 0; - - *rwlock = prwlock; - } - } - } - - return(ret); -} - -int -pthread_rwlock_rdlock (pthread_rwlock_t *rwlock) -{ - pthread_rwlock_t prwlock; - int ret; - - if (rwlock == NULL) - return(EINVAL); - - prwlock = *rwlock; - - /* check for static initialization */ - if (prwlock == NULL) { - if ((ret = init_static(rwlock)) != 0) - return(ret); - - prwlock = *rwlock; - } - - /* grab the monitor lock */ - if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0) - return(ret); - - /* give writers priority over readers */ - while (prwlock->blocked_writers || prwlock->state < 0) { - ret = pthread_cond_wait(&prwlock->read_signal, &prwlock->lock); - - if (ret != 0) { - /* can't do a whole lot if this fails */ - pthread_mutex_unlock(&prwlock->lock); - return(ret); - } - } - - /* check lock count */ - if (prwlock->state == MAX_READ_LOCKS) - ret = EAGAIN; - else - ++prwlock->state; /* indicate we are locked for reading */ - - /* - * Something is really wrong if this call fails. Returning - * error won't do because we've already obtained the read - * lock. Decrementing 'state' is no good because we probably - * don't have the monitor lock. - */ - pthread_mutex_unlock(&prwlock->lock); - - return(ret); -} - -int -pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock) -{ - pthread_rwlock_t prwlock; - int ret; - - if (rwlock == NULL) - return(EINVAL); - - prwlock = *rwlock; - - /* check for static initialization */ - if (prwlock == NULL) { - if ((ret = init_static(rwlock)) != 0) - return(ret); - - prwlock = *rwlock; - } - - /* grab the monitor lock */ - if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0) - return(ret); - - /* give writers priority over readers */ - if (prwlock->blocked_writers || prwlock->state < 0) - ret = EBUSY; - else if (prwlock->state == MAX_READ_LOCKS) - ret = EAGAIN; /* too many read locks acquired */ - else - ++prwlock->state; /* indicate we are locked for reading */ - - /* see the comment on this in pthread_rwlock_rdlock */ - pthread_mutex_unlock(&prwlock->lock); - - return(ret); -} - -int -pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock) -{ - pthread_rwlock_t prwlock; - int ret; - - if (rwlock == NULL) - return(EINVAL); - - prwlock = *rwlock; - - /* check for static initialization */ - if (prwlock == NULL) { - if ((ret = init_static(rwlock)) != 0) - return(ret); - - prwlock = *rwlock; - } - - /* grab the monitor lock */ - if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0) - return(ret); - - if (prwlock->state != 0) - ret = EBUSY; - else - /* indicate we are locked for writing */ - prwlock->state = -1; - - /* see the comment on this in pthread_rwlock_rdlock */ - pthread_mutex_unlock(&prwlock->lock); - - return(ret); -} - -int -pthread_rwlock_unlock (pthread_rwlock_t *rwlock) -{ - pthread_rwlock_t prwlock; - int ret; - - if (rwlock == NULL) - return(EINVAL); - - prwlock = *rwlock; - - if (prwlock == NULL) - return(EINVAL); - - /* grab the monitor lock */ - if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0) - return(ret); - - if (prwlock->state > 0) { - if (--prwlock->state == 0 && prwlock->blocked_writers) - ret = pthread_cond_signal(&prwlock->write_signal); - } else if (prwlock->state < 0) { - prwlock->state = 0; - - if (prwlock->blocked_writers) - ret = pthread_cond_signal(&prwlock->write_signal); - else - ret = pthread_cond_broadcast(&prwlock->read_signal); - } else - ret = EINVAL; - - /* see the comment on this in pthread_rwlock_rdlock */ - pthread_mutex_unlock(&prwlock->lock); - - return(ret); -} - -int -pthread_rwlock_wrlock (pthread_rwlock_t *rwlock) -{ - pthread_rwlock_t prwlock; - int ret; - - if (rwlock == NULL) - return(EINVAL); - - prwlock = *rwlock; - - /* check for static initialization */ - if (prwlock == NULL) { - if ((ret = init_static(rwlock)) != 0) - return(ret); - - prwlock = *rwlock; - } - - /* grab the monitor lock */ - if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0) - return(ret); - - while (prwlock->state != 0) { - ++prwlock->blocked_writers; - - ret = pthread_cond_wait(&prwlock->write_signal, &prwlock->lock); - - if (ret != 0) { - --prwlock->blocked_writers; - pthread_mutex_unlock(&prwlock->lock); - return(ret); - } - - --prwlock->blocked_writers; - } - - /* indicate we are locked for writing */ - prwlock->state = -1; - - /* see the comment on this in pthread_rwlock_rdlock */ - pthread_mutex_unlock(&prwlock->lock); - - return(ret); -} - -#endif /* _THREAD_SAFE */ diff --git a/lib/libc_r/uthread/uthread_rwlockattr.c b/lib/libc_r/uthread/uthread_rwlockattr.c deleted file mode 100644 index 1cc23bfbef4..00000000000 --- a/lib/libc_r/uthread/uthread_rwlockattr.c +++ /dev/null @@ -1,97 +0,0 @@ -/* $OpenBSD: uthread_rwlockattr.c,v 1.4 2000/01/04 22:34:24 alex Exp $ */ -/*- - * Copyright (c) 1998 Alex Nash - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_rwlockattr.c,v 1.3 1999/08/28 00:03:45 peter Exp $ - */ - -#ifdef _THREAD_SAFE -#include <errno.h> -#include <stdlib.h> - -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_rwlockattr_destroy (pthread_rwlockattr_t *rwlockattr) -{ - pthread_rwlockattr_t prwlockattr; - - if (rwlockattr == NULL) - return(EINVAL); - - prwlockattr = *rwlockattr; - - if (prwlockattr == NULL) - return(EINVAL); - - free(prwlockattr); - - return(0); -} - -int -pthread_rwlockattr_getpshared (const pthread_rwlockattr_t *rwlockattr, - int *pshared) -{ - *pshared = (*rwlockattr)->pshared; - - return(0); -} - -int -pthread_rwlockattr_init (pthread_rwlockattr_t *rwlockattr) -{ - pthread_rwlockattr_t prwlockattr; - - if (rwlockattr == NULL) - return(EINVAL); - - prwlockattr = (pthread_rwlockattr_t) - malloc(sizeof(struct pthread_rwlockattr)); - - if (prwlockattr == NULL) - return(ENOMEM); - - prwlockattr->pshared = PTHREAD_PROCESS_PRIVATE; - *rwlockattr = prwlockattr; - - return(0); -} - -int -pthread_rwlockattr_setpshared (pthread_rwlockattr_t *rwlockattr, - int pshared) -{ - /* only PTHREAD_PROCESS_PRIVATE is supported */ - if (pshared != PTHREAD_PROCESS_PRIVATE) - return(EINVAL); - - (*rwlockattr)->pshared = pshared; - - return(0); -} - -#endif /* _THREAD_SAFE */ diff --git a/lib/libc_r/uthread/uthread_select.c b/lib/libc_r/uthread/uthread_select.c deleted file mode 100644 index b4eb7efe7e4..00000000000 --- a/lib/libc_r/uthread/uthread_select.c +++ /dev/null @@ -1,215 +0,0 @@ -/* $OpenBSD: uthread_select.c,v 1.6 2003/01/19 21:22:31 marc Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_select.c,v 1.13 1999/08/30 00:02:08 deischen Exp $ - */ -#include <unistd.h> -#include <errno.h> -#include <poll.h> -#include <stdlib.h> -#include <string.h> -#include <sys/param.h> -#include <sys/types.h> -#include <sys/time.h> -#include <sys/fcntl.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -select(int numfds, fd_set * readfds, fd_set * writefds, - fd_set * exceptfds, struct timeval * timeout) -{ - struct pthread *curthread = _get_curthread(); - struct timespec ts; - int i, ret = 0, f_wait = 1; - int pfd_index, got_one = 0, fd_count = 0; - struct pthread_poll_data data; - - /* this is a cancellation point per IEEE Std 1003.1-2001 */ - _thread_enter_cancellation_point(); - - if (numfds > _thread_dtablesize) { - numfds = _thread_dtablesize; - } - /* Check if a timeout was specified: */ - if (timeout) { - if (timeout->tv_sec < 0 || - timeout->tv_usec < 0 || timeout->tv_usec >= 1000000) { - errno = EINVAL; - ret = -1; - goto done; - } - - /* Convert the timeval to a timespec: */ - TIMEVAL_TO_TIMESPEC(timeout, &ts); - - /* Set the wake up time: */ - _thread_kern_set_timeout(&ts); - if (ts.tv_sec == 0 && ts.tv_nsec == 0) - f_wait = 0; - } else { - /* Wait for ever: */ - _thread_kern_set_timeout(NULL); - } - - /* Count the number of file descriptors to be polled: */ - if (readfds || writefds || exceptfds) { - for (i = 0; i < numfds; i++) { - if ((readfds && FD_ISSET(i, readfds)) || - (exceptfds && FD_ISSET(i, exceptfds)) || - (writefds && FD_ISSET(i, writefds))) { - fd_count++; - } - } - } - - /* - * Allocate memory for poll data if it hasn't already been - * allocated or if previously allocated memory is insufficient. - */ - if ((curthread->poll_data.fds == NULL) || - (curthread->poll_data.nfds < fd_count)) { - data.fds = (struct pollfd *) realloc(curthread->poll_data.fds, - sizeof(struct pollfd) * MAX(128, fd_count)); - if (data.fds == NULL) { - errno = ENOMEM; - ret = -1; - } - else { - /* - * Note that the threads poll data always - * indicates what is allocated, not what is - * currently being polled. - */ - curthread->poll_data.fds = data.fds; - curthread->poll_data.nfds = MAX(128, fd_count); - } - } - if (ret == 0) { - /* Setup the wait data. */ - data.fds = curthread->poll_data.fds; - data.nfds = fd_count; - - /* - * Setup the array of pollfds. Optimize this by - * running the loop in reverse and stopping when - * the number of selected file descriptors is reached. - */ - for (i = numfds - 1, pfd_index = fd_count - 1; - (i >= 0) && (pfd_index >= 0); i--) { - data.fds[pfd_index].events = 0; - if (readfds && FD_ISSET(i, readfds)) { - data.fds[pfd_index].events = POLLRDNORM; - } - if (exceptfds && FD_ISSET(i, exceptfds)) { - data.fds[pfd_index].events |= POLLRDBAND; - } - if (writefds && FD_ISSET(i, writefds)) { - data.fds[pfd_index].events |= POLLWRNORM; - } - if (data.fds[pfd_index].events != 0) { - /* - * Set the file descriptor to be polled and - * clear revents in case of a timeout which - * leaves fds unchanged: - */ - data.fds[pfd_index].fd = i; - data.fds[pfd_index].revents = 0; - pfd_index--; - } - } - if (((ret = _thread_sys_poll(data.fds, data.nfds, 0)) == 0) && - (f_wait != 0)) { - curthread->data.poll_data = &data; - curthread->interrupted = 0; - _thread_kern_sched_state(PS_SELECT_WAIT, __FILE__, __LINE__); - if (curthread->interrupted) { - errno = EINTR; - data.nfds = 0; - ret = -1; - } else - ret = data.nfds; - } - } - - if (ret >= 0) { - numfds = 0; - for (i = 0; i < fd_count; i++) { - /* - * Check the results of the poll and clear - * this file descriptor from the fdset if - * the requested event wasn't ready. - */ - got_one = 0; - if (readfds != NULL) { - if (FD_ISSET(data.fds[i].fd, readfds)) { - if (data.fds[i].revents & (POLLIN | - POLLRDNORM)) - got_one = 1; - else - FD_CLR(data.fds[i].fd, readfds); - } - } - if (writefds != NULL) { - if (FD_ISSET(data.fds[i].fd, writefds)) { - if (data.fds[i].revents & (POLLOUT | - POLLWRNORM | POLLWRBAND)) - got_one = 1; - else - FD_CLR(data.fds[i].fd, - writefds); - } - } - if (exceptfds != NULL) { - if (FD_ISSET(data.fds[i].fd, exceptfds)) { - if (data.fds[i].revents & (POLLRDBAND | - POLLPRI | POLLHUP | POLLERR | - POLLNVAL)) - got_one = 1; - else - FD_CLR(data.fds[i].fd, - exceptfds); - } - } - if (got_one) - numfds++; - } - ret = numfds; - } - -done: - _thread_leave_cancellation_point(); - - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_self.c b/lib/libc_r/uthread/uthread_self.c deleted file mode 100644 index 5c0c53c4cbc..00000000000 --- a/lib/libc_r/uthread/uthread_self.c +++ /dev/null @@ -1,45 +0,0 @@ -/* $OpenBSD: uthread_self.c,v 1.4 2001/08/21 19:24:53 fgsch Exp $ */ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_self.c,v 1.3 1999/08/28 00:03:46 peter Exp $ - */ -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -pthread_t -pthread_self(void) -{ - /* Return the running thread pointer: */ - return (_get_curthread()); -} -#endif diff --git a/lib/libc_r/uthread/uthread_sem.c b/lib/libc_r/uthread/uthread_sem.c deleted file mode 100644 index 21f7cf86975..00000000000 --- a/lib/libc_r/uthread/uthread_sem.c +++ /dev/null @@ -1,247 +0,0 @@ -/* $OpenBSD: uthread_sem.c,v 1.1 2002/01/18 22:07:27 fgsch Exp $ */ -/* - * Copyright (C) 2000 Jason Evans <jasone@freebsd.org>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice(s), this list of conditions and the following disclaimer as - * the first lines of this file unmodified other than the possible - * addition of one or more copyright notices. - * 2. Redistributions in binary form must reproduce the above copyright - * notice(s), this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: uthread_sem.c,v 1.10 2001/05/18 00:36:05 jasone Exp $ - */ - -#include <stdlib.h> -#include <errno.h> -#include <semaphore.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -#define _SEM_CHECK_VALIDITY(sem) \ - if ((*(sem))->magic != SEM_MAGIC) { \ - errno = EINVAL; \ - retval = -1; \ - goto RETURN; \ - } - -int -sem_init(sem_t *sem, int pshared, unsigned int value) -{ - int retval; - - /* - * Range check the arguments. - */ - if (pshared != 0) { - /* - * The user wants a semaphore that can be shared among - * processes, which this implementation can't do. Sounds like a - * permissions problem to me (yeah right). - */ - errno = EPERM; - retval = -1; - goto RETURN; - } - - if (value > SEM_VALUE_MAX) { - errno = EINVAL; - retval = -1; - goto RETURN; - } - - *sem = (sem_t)malloc(sizeof(struct sem)); - if (*sem == NULL) { - errno = ENOSPC; - retval = -1; - goto RETURN; - } - - /* - * Initialize the semaphore. - */ - if (pthread_mutex_init(&(*sem)->lock, NULL) != 0) { - free(*sem); - errno = ENOSPC; - retval = -1; - goto RETURN; - } - - if (pthread_cond_init(&(*sem)->gtzero, NULL) != 0) { - pthread_mutex_destroy(&(*sem)->lock); - free(*sem); - errno = ENOSPC; - retval = -1; - goto RETURN; - } - - (*sem)->count = (u_int32_t)value; - (*sem)->nwaiters = 0; - (*sem)->magic = SEM_MAGIC; - - retval = 0; - RETURN: - return retval; -} - -int -sem_destroy(sem_t *sem) -{ - int retval; - - _SEM_CHECK_VALIDITY(sem); - - /* Make sure there are no waiters. */ - pthread_mutex_lock(&(*sem)->lock); - if ((*sem)->nwaiters > 0) { - pthread_mutex_unlock(&(*sem)->lock); - errno = EBUSY; - retval = -1; - goto RETURN; - } - pthread_mutex_unlock(&(*sem)->lock); - - pthread_mutex_destroy(&(*sem)->lock); - pthread_cond_destroy(&(*sem)->gtzero); - (*sem)->magic = 0; - - free(*sem); - - retval = 0; - RETURN: - return retval; -} - -sem_t * -sem_open(const char *name, int oflag, ...) -{ - errno = ENOSYS; - return SEM_FAILED; -} - -int -sem_close(sem_t *sem) -{ - errno = ENOSYS; - return -1; -} - -int -sem_unlink(const char *name) -{ - errno = ENOSYS; - return -1; -} - -int -sem_wait(sem_t *sem) -{ - int retval; - - _thread_enter_cancellation_point(); - - _SEM_CHECK_VALIDITY(sem); - - pthread_mutex_lock(&(*sem)->lock); - - while ((*sem)->count == 0) { - (*sem)->nwaiters++; - pthread_cond_wait(&(*sem)->gtzero, &(*sem)->lock); - (*sem)->nwaiters--; - } - (*sem)->count--; - - pthread_mutex_unlock(&(*sem)->lock); - - retval = 0; - RETURN: - _thread_leave_cancellation_point(); - return retval; -} - -int -sem_trywait(sem_t *sem) -{ - int retval; - - _SEM_CHECK_VALIDITY(sem); - - pthread_mutex_lock(&(*sem)->lock); - - if ((*sem)->count > 0) { - (*sem)->count--; - retval = 0; - } else { - errno = EAGAIN; - retval = -1; - } - - pthread_mutex_unlock(&(*sem)->lock); - - RETURN: - return retval; -} - -int -sem_post(sem_t *sem) -{ - int retval; - - _SEM_CHECK_VALIDITY(sem); - - /* - * sem_post() is required to be safe to call from within signal - * handlers. Thus, we must defer signals. - */ - _thread_kern_sig_defer(); - - pthread_mutex_lock(&(*sem)->lock); - - (*sem)->count++; - if ((*sem)->nwaiters > 0) - pthread_cond_signal(&(*sem)->gtzero); - - pthread_mutex_unlock(&(*sem)->lock); - - _thread_kern_sig_undefer(); - retval = 0; - RETURN: - return retval; -} - -int -sem_getvalue(sem_t *sem, int *sval) -{ - int retval; - - _SEM_CHECK_VALIDITY(sem); - - pthread_mutex_lock(&(*sem)->lock); - *sval = (int)(*sem)->count; - pthread_mutex_unlock(&(*sem)->lock); - - retval = 0; - RETURN: - return retval; -} - -#endif diff --git a/lib/libc_r/uthread/uthread_sendmsg.c b/lib/libc_r/uthread/uthread_sendmsg.c deleted file mode 100644 index 11d91d85c5c..00000000000 --- a/lib/libc_r/uthread/uthread_sendmsg.c +++ /dev/null @@ -1,74 +0,0 @@ -/* $OpenBSD: uthread_sendmsg.c,v 1.4 2001/08/21 19:24:53 fgsch Exp $ */ -/* - * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_sendmsg.c,v 1.4 1999/08/28 00:03:46 peter Exp $ - */ -#include <errno.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <fcntl.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -ssize_t -sendmsg(int fd, const struct msghdr *msg, int flags) -{ - struct pthread *curthread = _get_curthread(); - int ret; - - if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) { - while ((ret = _thread_sys_sendmsg(fd, msg, flags)) < 0) { - if (!(_thread_fd_table[fd]->flags & O_NONBLOCK) && ((errno == EWOULDBLOCK) || (errno == EAGAIN))) { - curthread->data.fd.fd = fd; - - /* Set the timeout: */ - _thread_kern_set_timeout(NULL); - curthread->interrupted = 0; - _thread_kern_sched_state(PS_FDW_WAIT, __FILE__, __LINE__); - - /* Check if the operation was interrupted: */ - if (curthread->interrupted) { - errno = EINTR; - ret = -1; - break; - } - } else { - ret = -1; - break; - } - } - _FD_UNLOCK(fd, FD_WRITE); - } - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_sendto.c b/lib/libc_r/uthread/uthread_sendto.c deleted file mode 100644 index 062d11e77ac..00000000000 --- a/lib/libc_r/uthread/uthread_sendto.c +++ /dev/null @@ -1,74 +0,0 @@ -/* $OpenBSD: uthread_sendto.c,v 1.5 2001/08/21 19:24:53 fgsch Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_sendto.c,v 1.5 1999/08/28 00:03:46 peter Exp $ - */ -#include <errno.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <fcntl.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -ssize_t -sendto(int fd, const void *msg, size_t len, int flags, const struct sockaddr * to, socklen_t to_len) -{ - struct pthread *curthread = _get_curthread(); - int ret; - - if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) { - while ((ret = _thread_sys_sendto(fd, msg, len, flags, to, to_len)) < 0) { - if (!(_thread_fd_table[fd]->flags & O_NONBLOCK) && ((errno == EWOULDBLOCK) || (errno == EAGAIN))) { - curthread->data.fd.fd = fd; - - /* Set the timeout: */ - _thread_kern_set_timeout(NULL); - curthread->interrupted = 0; - _thread_kern_sched_state(PS_FDW_WAIT, __FILE__, __LINE__); - - /* Check if the operation was interrupted: */ - if (curthread->interrupted) { - errno = EINTR; - ret = -1; - break; - } - } else { - ret = -1; - break; - } - } - _FD_UNLOCK(fd, FD_WRITE); - } - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_seterrno.c b/lib/libc_r/uthread/uthread_seterrno.c deleted file mode 100644 index 1b008122ca3..00000000000 --- a/lib/libc_r/uthread/uthread_seterrno.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $OpenBSD: uthread_seterrno.c,v 1.4 1999/11/27 01:30:11 d Exp $ */ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_seterrno.c,v 1.4 1999/08/28 00:03:46 peter Exp $ - */ -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* - * This function needs to reference the global error variable which is - * normally hidden from the user. - */ -#ifdef errno -#undef errno -#endif -extern int errno; - -void -_thread_seterrno(pthread_t thread, int error) -{ - - /* Don't allow _thread_run to change: */ - _thread_kern_sig_defer(); - - /* Check for the current thread: */ - if (thread == _thread_run) - /* The current thread always uses the global error variable: */ - errno = error; - else - /* - * Threads other than the current thread will keep the error - * field in the thread structure: - */ - thread->error = error; - - _thread_kern_sig_undefer(); -} -#endif diff --git a/lib/libc_r/uthread/uthread_setprio.c b/lib/libc_r/uthread/uthread_setprio.c deleted file mode 100644 index b0be80a20ad..00000000000 --- a/lib/libc_r/uthread/uthread_setprio.c +++ /dev/null @@ -1,54 +0,0 @@ -/* $OpenBSD: uthread_setprio.c,v 1.5 1999/11/25 07:01:43 d Exp $ */ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_setprio.c,v 1.6 1999/08/28 00:03:47 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_setprio(pthread_t pthread, int prio) -{ - int ret, policy; - struct sched_param param; - - if ((ret = pthread_getschedparam(pthread, &policy, ¶m)) == 0) { - param.sched_priority = prio; - ret = pthread_setschedparam(pthread, policy, ¶m); - } - - /* Return the error status: */ - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_setschedparam.c b/lib/libc_r/uthread/uthread_setschedparam.c deleted file mode 100644 index 438691930b8..00000000000 --- a/lib/libc_r/uthread/uthread_setschedparam.c +++ /dev/null @@ -1,119 +0,0 @@ -/* $OpenBSD: uthread_setschedparam.c,v 1.5 2002/01/19 23:49:32 fgsch Exp $ */ -/* - * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Daniel Eischen. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_setschedparam.c,v 1.3 1999/08/28 00:03:47 peter Exp $ - */ -#include <errno.h> -#include <sys/param.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_setschedparam(pthread_t pthread, int policy, const struct sched_param *param) -{ - int old_prio, in_readyq = 0, ret = 0; - - if ((param == NULL) || (policy < SCHED_FIFO) || (policy > SCHED_RR)) { - /* Return an invalid argument error: */ - ret = EINVAL; - } else if ((param->sched_priority < PTHREAD_MIN_PRIORITY) || - (param->sched_priority > PTHREAD_MAX_PRIORITY)) { - /* Return an unsupported value error. */ - ret = ENOTSUP; - - /* Find the thread in the list of active threads: */ - } else if ((ret = _find_thread(pthread)) == 0) { - /* - * Defer signals to protect the scheduling queues from - * access by the signal handler: - */ - _thread_kern_sig_defer(); - - if (param->sched_priority != - PTHREAD_BASE_PRIORITY(pthread->base_priority)) { - /* - * Remove the thread from its current priority - * queue before any adjustments are made to its - * active priority: - */ - old_prio = pthread->active_priority; - if ((pthread->flags & PTHREAD_FLAGS_IN_PRIOQ) != 0) { - in_readyq = 1; - PTHREAD_PRIOQ_REMOVE(pthread); - } - - /* Set the thread base priority: */ - pthread->base_priority &= - (PTHREAD_SIGNAL_PRIORITY | PTHREAD_RT_PRIORITY); - pthread->base_priority = param->sched_priority; - - /* Recalculate the active priority: */ - pthread->active_priority = MAX(pthread->base_priority, - pthread->inherited_priority); - - if (in_readyq) { - if ((pthread->priority_mutex_count > 0) && - (old_prio > pthread->active_priority)) { - /* - * POSIX states that if the priority is - * being lowered, the thread must be - * inserted at the head of the queue for - * its priority if it owns any priority - * protection or inheritence mutexes. - */ - PTHREAD_PRIOQ_INSERT_HEAD(pthread); - } - else - PTHREAD_PRIOQ_INSERT_TAIL(pthread); - } - - /* - * Check for any mutex priority adjustments. This - * includes checking for a priority mutex on which - * this thread is waiting. - */ - _mutex_notify_priochange(pthread); - } - - /* Set the scheduling policy: */ - pthread->attr.sched_policy = policy; - - /* - * Undefer and handle pending signals, yielding if - * necessary: - */ - _thread_kern_sig_undefer(); - } - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_setsockopt.c b/lib/libc_r/uthread/uthread_setsockopt.c deleted file mode 100644 index 77cda0a65c1..00000000000 --- a/lib/libc_r/uthread/uthread_setsockopt.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: uthread_setsockopt.c,v 1.4 1999/11/25 07:01:44 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_setsockopt.c,v 1.5 1999/08/28 00:03:47 peter Exp $ - */ -#include <sys/types.h> -#include <sys/socket.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -setsockopt(int fd, int level, int optname, const void *optval, socklen_t optlen) -{ - int ret; - - if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { - ret = _thread_sys_setsockopt(fd, level, optname, optval, optlen); - _FD_UNLOCK(fd, FD_RDWR); - } - return ret; -} -#endif diff --git a/lib/libc_r/uthread/uthread_shutdown.c b/lib/libc_r/uthread/uthread_shutdown.c deleted file mode 100644 index 991fb2c932d..00000000000 --- a/lib/libc_r/uthread/uthread_shutdown.c +++ /dev/null @@ -1,73 +0,0 @@ -/* $OpenBSD: uthread_shutdown.c,v 1.3 1999/11/25 07:01:44 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_shutdown.c,v 1.6 1999/08/28 00:03:48 peter Exp $ - */ -#include <errno.h> -#include <sys/types.h> -#include <sys/socket.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -shutdown(int fd, int how) -{ - int ret; - - switch (how) { - case 0: - if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) { - ret = _thread_sys_shutdown(fd, how); - _FD_UNLOCK(fd, FD_READ); - } - break; - case 1: - if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) { - ret = _thread_sys_shutdown(fd, how); - _FD_UNLOCK(fd, FD_WRITE); - } - break; - case 2: - if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { - ret = _thread_sys_shutdown(fd, how); - _FD_UNLOCK(fd, FD_RDWR); - } - break; - default: - errno = EBADF; - ret = -1; - break; - } - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_sig.c b/lib/libc_r/uthread/uthread_sig.c deleted file mode 100644 index 1d64e077cde..00000000000 --- a/lib/libc_r/uthread/uthread_sig.c +++ /dev/null @@ -1,435 +0,0 @@ -/* $OpenBSD: uthread_sig.c,v 1.16 2002/11/08 23:18:25 todd Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_sig.c,v 1.20 1999/09/29 15:18:39 marcel Exp $ - */ -#include <string.h> -#include <signal.h> -#include <fcntl.h> -#include <unistd.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* Static variables: */ -static _spinlock_lock_t signal_lock = _SPINLOCK_UNLOCKED; -siginfo_t info_queue[NSIG]; -volatile sig_atomic_t pending_sigs[NSIG]; -volatile sig_atomic_t check_pending = 0; - -/* Initialize signal handling facility: */ -void -_thread_sig_init(void) -{ - int i; - - /* Clear local state */ - for (i = 1; i < NSIG; i++) { - pending_sigs[i - 1] = 0; - } - - /* Clear the lock: */ - signal_lock = _SPINLOCK_UNLOCKED; -} - -/* - * Process a pending signal unless it is already in progress. If the - * SA_NODEFER flag is on, process it any way. - */ -void -_thread_sig_process(int sig, struct sigcontext * scp) -{ - int locked = 0; - - if (_atomic_lock(&signal_lock) == 0) - locked = 1; - - if (locked || _thread_sigact[sig - 1].sa_flags & SA_NODEFER) { - _thread_sig_handle(sig, scp); - pending_sigs[sig - 1] = 0; - } else - check_pending = 1; - if (locked) - signal_lock = _SPINLOCK_UNLOCKED; -} - -/* - * This is the only installed signal handler. In addition to handling - * thread kernel signals it is installed in place of application handlers - * and dispatches signals appropriately. - */ -void -_thread_sig_handler(int sig, siginfo_t *info, struct sigcontext * scp) -{ - struct pthread *curthread = _get_curthread(); - char c; - int i; - - /* - * save the info for this signal in a per signal queue of depth - * one. Per a POSIX suggestion, only the info for the first - * of multiple activations of the same signal is kept. - */ - if (pending_sigs[sig - 1] == 0) { - pending_sigs[sig - 1]++; - memcpy(&info_queue[sig - 1], info, sizeof *info); - } - - if (sig == _SCHED_SIGNAL) { - /* Update the scheduling clock: */ - gettimeofday((struct timeval *)&_sched_tod, NULL); - _sched_ticks++; - - /* only process signal when scheduler isn't running */ - if (_thread_kern_in_sched == 0) { - if (curthread->sig_defer_count > 0) { - /* - * The scheduler interrupt has come when - * the currently running thread has deferred - * thread signals. - */ - curthread->yield_on_sig_undefer = 1; - } else { - /* Schedule the next thread. */ - _thread_kern_sched(scp); - - /* - * The scheduler currently returns here instead - * of calling sigreturn due to a sparc sigreturn - * bug. We should also return. That brings - * us back to the sigtramp code which will - * sigreturn to the context stored on the - * current stack (which is the same as scp, - * above). The code originally did this: - * - * PANIC("Returned to signal function " - * "from scheduler"); - */ - return; - } - } - } else if ((_queue_signals != 0) || - ((_thread_kern_in_sched == 0) && - (curthread->sig_defer_count > 0))) { - /* - * The kernel has been interrupted while the scheduler - * is accessing the scheduling queues or there is a currently - * running thread that has deferred signals. - * - * Cast the signal number to a character variable and Write - * the signal number to the kernel pipe so that it will be - * ready to read when this signal handler returns. - */ - c = sig; - _thread_sys_write(_thread_kern_pipe[1], &c, 1); - _sigq_check_reqd = 1; - } else { - /* process the signal */ - _thread_sig_process(sig, scp); - /* - * process pending signals unless a current signal handler - * is running (signal_lock is locked). When locked - * the pending signals will be processed when the running - * handler returns. - */ - while (check_pending != 0 && _atomic_lock(&signal_lock) == 0) { - check_pending = 0; - signal_lock = _SPINLOCK_UNLOCKED; - for (i = 1; i < NSIG; i++) - if (pending_sigs[i - 1]) - _thread_sig_process(i, scp); - } - } - -} - -/* - * Clear the pending flag for the given signal on all threads - */ -void -_clear_pending_flag(int sig) -{ - pthread_t pthread; - - TAILQ_FOREACH(pthread, &_thread_list, tle) { - sigdelset(&pthread->sigpend, sig); - } -} - - -/* - * Process the given signal. - */ -void -_thread_sig_handle(int sig, struct sigcontext * scp) -{ - struct pthread *curthread = _get_curthread(); - int i; - pthread_t pthread, pthread_next; - - if (sig == SIGINFO) - _thread_dump_info(); /* Dump thread information */ - else if (sig == _SCHED_SIGNAL) - ; /* This shouldn't ever occur (should this panic?). */ - else { - if (sig == SIGCHLD) { - /* - * Go through the file list and set all files - * to non-blocking again in case the child - * set some of them to block. Sigh. - */ - for (i = 0; i < _thread_dtablesize; i++) - if (_thread_fd_table[i] != NULL) - _thread_sys_fcntl(i, F_SETFL, - _thread_fd_table[i]->flags | - O_NONBLOCK); - } - - /* - * POSIX says that pending SIGCONT signals are - * discarded when one of these signals occurs. - */ - if (sig == SIGTSTP || sig == SIGTTIN || sig == SIGTTOU) - _clear_pending_flag(SIGCONT); - - /* - * Enter a loop to process each thread in the waiting - * list that is sigwait-ing on a signal. Since POSIX - * doesn't specify which thread will get the signal - * if there are multiple waiters, we'll give it to the - * first one we find. - */ - for (pthread = TAILQ_FIRST(&_waitingq); - pthread != NULL; pthread = pthread_next) { - /* - * Grab the next thread before possibly destroying - * the link entry. - */ - pthread_next = TAILQ_NEXT(pthread, pqe); - - if ((pthread->state == PS_SIGWAIT) && - sigismember(pthread->data.sigwait, sig)) { - /* Change the state of the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - - /* Return the signal number: */ - pthread->signo = sig; - - /* - * Do not attempt to deliver this signal - * to other threads. - */ - return; - } - } - - if (_thread_sigact[sig - 1].sa_handler != SIG_IGN) { - /* - * mark the signal as pending for each thread - * and give the thread a chance to update - * its state. - */ - TAILQ_FOREACH(pthread, &_thread_list, tle) { - /* Current thread inside critical region? */ - if (curthread->sig_defer_count > 0) - pthread->sig_defer_count++; - _thread_signal(pthread,sig); - if (curthread->sig_defer_count > 0) - pthread->sig_defer_count--; - } - /* - * give each thread a chance to dispatch pending - * signals. - */ - TAILQ_FOREACH(pthread, &_thread_list, tle) { - /* Current thread inside critical region? */ - if (curthread->sig_defer_count > 0) - pthread->sig_defer_count++; - _dispatch_signals(pthread, scp); - if (curthread->sig_defer_count > 0) - pthread->sig_defer_count--; - } - } - } - - /* Returns nothing. */ - return; -} - -/* Perform thread specific actions in response to a signal: */ -void -_thread_signal(pthread_t pthread, int sig) -{ - /* - * Flag the signal as pending. It may be dispatched later. - */ - sigaddset(&pthread->sigpend,sig); - - /* skip this thread if signal is masked */ - if (sigismember(&pthread->sigmask, sig)) - return; - - /* - * Process according to thread state: - */ - switch (pthread->state) { - /* - * States which do not change when a signal is trapped: - */ - case PS_COND_WAIT: - case PS_DEAD: - case PS_FDLR_WAIT: - case PS_FDLW_WAIT: - case PS_FILE_WAIT: - case PS_JOIN: - case PS_MUTEX_WAIT: - case PS_RUNNING: - case PS_SIGTHREAD: - case PS_SIGWAIT: - case PS_SUSPENDED: - case PS_SPINBLOCK: - case PS_DEADLOCK: - case PS_STATE_MAX: /* only here to quell a compiler warning */ - /* Nothing to do here. */ - break; - - /* - * The wait state is a special case due to the handling of - * SIGCHLD signals. - */ - case PS_WAIT_WAIT: - /* - * Check for signals other than the death of a child - * process: - */ - if (sig != SIGCHLD) - /* Flag the operation as interrupted: */ - pthread->interrupted = 1; - - /* Change the state of the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - - /* Return the signal number: */ - pthread->signo = sig; - break; - - /* - * States that are interrupted by the occurrence of a signal - * other than the scheduling alarm: - */ - case PS_FDR_WAIT: - case PS_FDW_WAIT: - case PS_POLL_WAIT: - case PS_SLEEP_WAIT: - case PS_SELECT_WAIT: - if (sig != SIGCHLD || - _thread_sigact[sig - 1].sa_handler != SIG_DFL) { - /* Flag the operation as interrupted: */ - pthread->interrupted = 1; - - if (pthread->flags & PTHREAD_FLAGS_IN_WORKQ) - PTHREAD_WORKQ_REMOVE(pthread); - - /* Change the state of the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - - /* Return the signal number: */ - pthread->signo = sig; - } - break; - - case PS_SIGSUSPEND: - /* - * Only wake up the thread if the signal is unblocked - * and there is a handler installed for the signal. - */ - if (_thread_sigact[sig - 1].sa_handler != SIG_DFL) { - /* Change the state of the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - - /* Return the signal number: */ - pthread->signo = sig; - } - break; - } -} - -/* - * possibly dispatch a signal to the given thread. - */ -void -_dispatch_signals(pthread_t pthread, struct sigcontext * scp) -{ - pthread_t pthread_saved; - struct sigaction act; - void (*action)(int, siginfo_t *, void *); - int i; - - /* - * Check if there are pending signals for the running - * thread that aren't blocked: - */ - if ((pthread->sigpend & ~pthread->sigmask) != 0) - /* Look for all possible pending signals: */ - for (i = 1; i < NSIG; i++) - /* - * Check that a custom handler is installed - * and if the signal is not blocked: - */ - if (_thread_sigact[i - 1].sa_handler != SIG_DFL && - _thread_sigact[i - 1].sa_handler != SIG_IGN && - sigismember(&pthread->sigpend,i) && - !sigismember(&pthread->sigmask,i)) { - action = _thread_sigact[i - 1].sa_sigaction; - _clear_pending_flag(i); - - /* clear custom handler if SA_RESETHAND set. */ - if (_thread_sigact[i - 1].sa_flags & - SA_RESETHAND) { - act.sa_handler = SIG_DFL; - act.sa_flags = 0; - sigemptyset(&act.sa_mask); - sigaction(i, &act, NULL); - } - - /* - * Dispatch the signal via the custom signal - * handler. - */ - pthread_saved = _get_curthread(); - _set_curthread(pthread); - (*action)(i, &info_queue[i - 1], scp); - _set_curthread(pthread_saved); - } -} -#endif diff --git a/lib/libc_r/uthread/uthread_sigaction.c b/lib/libc_r/uthread/uthread_sigaction.c deleted file mode 100644 index 61463f7ef99..00000000000 --- a/lib/libc_r/uthread/uthread_sigaction.c +++ /dev/null @@ -1,104 +0,0 @@ -/* $OpenBSD: uthread_sigaction.c,v 1.6 2002/10/30 19:11:56 marc Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_sigaction.c,v 1.8 1999/08/28 00:03:48 peter Exp $ - */ -#include <signal.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -sigaction(int sig, const struct sigaction * act, struct sigaction * oact) -{ - int ret = 0; - struct sigaction gact; - - /* Check if the signal number is out of range: */ - if (sig < 1 || sig > NSIG) { - /* Return an invalid argument: */ - errno = EINVAL; - ret = -1; - } else { - /* - * Check if the existing signal action structure contents are - * to be returned: - */ - if (oact != NULL) { - /* Return the existing signal action contents: */ - oact->sa_handler = _thread_sigact[sig - 1].sa_handler; - oact->sa_mask = _thread_sigact[sig - 1].sa_mask; - oact->sa_flags = _thread_sigact[sig - 1].sa_flags; - } - - /* Check if a signal action was supplied: */ - if (act != NULL) { - /* Set the new signal handler: */ - _thread_sigact[sig - 1].sa_mask = act->sa_mask; - _thread_sigact[sig - 1].sa_flags = act->sa_flags; - _thread_sigact[sig - 1].sa_handler = act->sa_handler; - } - - /* - * Check if the kernel needs to be advised of a change - * in signal action: - */ - if (act != NULL && sig != _SCHED_SIGNAL && sig != SIGCHLD && - sig != SIGINFO) { - gact.sa_mask = act->sa_mask; - sigaddset(&gact.sa_mask, _SCHED_SIGNAL); - gact.sa_flags = act->sa_flags | SA_SIGINFO; - - /* - * Check if the signal handler is being set to - * the default or ignore handlers: - */ - if (act->sa_handler == SIG_DFL || - act->sa_handler == SIG_IGN) - /* Specify the built in handler: */ - gact.sa_handler = act->sa_handler; - else - /* Specify the thread kernel signal handler */ - gact.sa_handler = - (void (*) ()) _thread_sig_handler; - - /* Change the signal action in the kernel: */ - if (_thread_sys_sigaction(sig, &gact, NULL) != 0) - ret = -1; - } - } - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_sigaltstack.c b/lib/libc_r/uthread/uthread_sigaltstack.c deleted file mode 100644 index fff62da3be2..00000000000 --- a/lib/libc_r/uthread/uthread_sigaltstack.c +++ /dev/null @@ -1,19 +0,0 @@ -/* $OpenBSD: uthread_sigaltstack.c,v 1.2 1999/11/25 07:01:44 d Exp $ */ - -#include <signal.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* - * placeholder for sigaltstack XXX impl to be done - */ - -int -sigaltstack(const struct sigaltstack *ss, struct sigaltstack *oss) -{ - errno = EINVAL; - return (-1); -} -#endif /* _THREAD_SAFE */ diff --git a/lib/libc_r/uthread/uthread_sigblock.c b/lib/libc_r/uthread/uthread_sigblock.c deleted file mode 100644 index dd08126ce70..00000000000 --- a/lib/libc_r/uthread/uthread_sigblock.c +++ /dev/null @@ -1,50 +0,0 @@ -/* $OpenBSD: uthread_sigblock.c,v 1.3 1999/11/25 07:01:44 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_sigblock.c,v 1.4 1999/08/28 00:03:49 peter Exp $ - */ -#include <signal.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -_thread_sys_sigblock(int mask) -{ - int omask, n; - - n = _thread_sys_sigprocmask(SIG_BLOCK, (sigset_t *) & mask, (sigset_t *) & omask); - if (n) - return (n); - return (omask); -} -#endif diff --git a/lib/libc_r/uthread/uthread_sigmask.c b/lib/libc_r/uthread/uthread_sigmask.c deleted file mode 100644 index 12dd6ec3c69..00000000000 --- a/lib/libc_r/uthread/uthread_sigmask.c +++ /dev/null @@ -1,104 +0,0 @@ -/* $OpenBSD: uthread_sigmask.c,v 1.5 2002/02/21 20:57:41 fgsch Exp $ */ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_sigmask.c,v 1.5 1999/09/29 15:18:40 marcel Exp $ - */ -#include <errno.h> -#include <signal.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_sigmask(int how, const sigset_t *set, sigset_t *oset) -{ - struct pthread *curthread = _get_curthread(); - sigset_t sigset; - int ret = 0; - - /* Check if the existing signal process mask is to be returned: */ - if (oset != NULL) { - /* Return the current mask: */ - *oset = curthread->sigmask; - } - /* Check if a new signal set was provided by the caller: */ - if (set != NULL) { - /* Process according to what to do: */ - switch (how) { - /* Block signals: */ - case SIG_BLOCK: - /* Add signals to the existing mask: */ - curthread->sigmask |= *set; - break; - - /* Unblock signals: */ - case SIG_UNBLOCK: - /* Clear signals from the existing mask: */ - curthread->sigmask &= ~(*set); - break; - - /* Set the signal process mask: */ - case SIG_SETMASK: - /* Set the new mask: */ - curthread->sigmask = *set; - break; - - /* Trap invalid actions: */ - default: - /* Return an invalid argument: */ - errno = EINVAL; - ret = -1; - break; - } - - /* Increment the sequence number: */ - curthread->sigmask_seqno++; - - /* - * Check if there are pending signals for the running - * thread or process that aren't blocked: - */ - sigset = curthread->sigpend; - sigset |= _process_sigpending; - sigset &= ~curthread->sigmask; - if (sigset != 0) - /* - * Call the kernel scheduler which will safely - * install a signal frame for the running thread: - */ - _thread_kern_sched_sig(); - } - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_signal.c b/lib/libc_r/uthread/uthread_signal.c deleted file mode 100644 index 3cc2373fc64..00000000000 --- a/lib/libc_r/uthread/uthread_signal.c +++ /dev/null @@ -1,59 +0,0 @@ -/* $OpenBSD: uthread_signal.c,v 1.5 2002/10/30 19:11:56 marc Exp $ */ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_signal.c,v 1.4 1999/08/28 00:03:49 peter Exp $ - */ -#include <signal.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -sig_t -_thread_sys_signal(int s, sig_t a) -{ - struct sigaction sa; - struct sigaction osa; - - /* Initialise the signal action structure: */ - sigemptyset(&sa.sa_mask); - sa.sa_handler = a; - sa.sa_flags = SA_SIGINFO; - - /* Perform the sigaction syscall: */ - if (_thread_sys_sigaction(s, &sa, &osa) < 0) { - /* Return an error: */ - return (SIG_ERR); - } - /* Return a pointer to the old signal handler: */ - return (osa.sa_handler); -} -#endif diff --git a/lib/libc_r/uthread/uthread_sigpending.c b/lib/libc_r/uthread/uthread_sigpending.c deleted file mode 100644 index 911d1b4b891..00000000000 --- a/lib/libc_r/uthread/uthread_sigpending.c +++ /dev/null @@ -1,58 +0,0 @@ -/* $OpenBSD: uthread_sigpending.c,v 1.3 2001/08/21 19:24:53 fgsch Exp $ */ -/* - * Copyright (c) 1999 Daniel Eischen <eischen@vigrid.com>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_sigpending.c,v 1.3 1999/08/28 00:03:50 peter Exp $ - */ -#include <signal.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -sigpending(sigset_t * set) -{ - struct pthread *curthread = _get_curthread(); - int ret = 0; - - /* Check for a null signal set pointer: */ - if (set == NULL) { - /* Return an invalid argument: */ - ret = EINVAL; - } - else { - *set = curthread->sigpend; - } - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_sigprocmask.c b/lib/libc_r/uthread/uthread_sigprocmask.c deleted file mode 100644 index ebe56d899b6..00000000000 --- a/lib/libc_r/uthread/uthread_sigprocmask.c +++ /dev/null @@ -1,46 +0,0 @@ -/* $OpenBSD: uthread_sigprocmask.c,v 1.4 2001/12/30 01:11:07 fgsch Exp $ */ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_sigprocmask.c,v 1.6 1999/09/29 15:18:40 marcel Exp $ - */ -#include <signal.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -sigprocmask(int how, const sigset_t *set, sigset_t *oset) -{ - return (pthread_sigmask(how, set, oset)); -} -#endif diff --git a/lib/libc_r/uthread/uthread_sigsetmask.c b/lib/libc_r/uthread/uthread_sigsetmask.c deleted file mode 100644 index 878efe36add..00000000000 --- a/lib/libc_r/uthread/uthread_sigsetmask.c +++ /dev/null @@ -1,50 +0,0 @@ -/* $OpenBSD: uthread_sigsetmask.c,v 1.3 1999/11/25 07:01:45 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_sigsetmask.c,v 1.4 1999/08/28 00:03:50 peter Exp $ - */ -#include <signal.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -_thread_sys_sigsetmask(int mask) -{ - int omask, n; - - n = _thread_sys_sigprocmask(SIG_SETMASK, (sigset_t *) & mask, (sigset_t *) & omask); - if (n) - return (n); - return (omask); -} -#endif diff --git a/lib/libc_r/uthread/uthread_sigsuspend.c b/lib/libc_r/uthread/uthread_sigsuspend.c deleted file mode 100644 index bbf9c7c9870..00000000000 --- a/lib/libc_r/uthread/uthread_sigsuspend.c +++ /dev/null @@ -1,76 +0,0 @@ -/* $OpenBSD: uthread_sigsuspend.c,v 1.5 2001/08/21 19:24:53 fgsch Exp $ */ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_sigsuspend.c,v 1.7 1999/08/28 00:03:50 peter Exp $ - */ -#include <signal.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -sigsuspend(const sigset_t * set) -{ - struct pthread *curthread = _get_curthread(); - int ret = -1; - sigset_t oset; - - _thread_enter_cancellation_point(); - - /* Check if a new signal set was provided by the caller: */ - if (set != NULL) { - /* Save the current signal mask: */ - oset = curthread->sigmask; - - /* Change the caller's mask: */ - curthread->sigmask = *set; - - /* Wait for a signal: */ - _thread_kern_sched_state(PS_SIGSUSPEND, __FILE__, __LINE__); - - /* Always return an interrupted error: */ - errno = EINTR; - - /* Restore the signal mask: */ - curthread->sigmask = oset; - } else { - /* Return an invalid argument error: */ - errno = EINVAL; - } - - _thread_leave_cancellation_point(); - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_sigwait.c b/lib/libc_r/uthread/uthread_sigwait.c deleted file mode 100644 index b7b72c7ea09..00000000000 --- a/lib/libc_r/uthread/uthread_sigwait.c +++ /dev/null @@ -1,177 +0,0 @@ -/* $OpenBSD: uthread_sigwait.c,v 1.11 2002/10/30 19:11:56 marc Exp $ */ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_sigwait.c,v 1.10 1999/09/30 14:51:31 marcel Exp $ - */ -#include <signal.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -sigwait(const sigset_t * set, int *sig) -{ - struct pthread *curthread = _get_curthread(); - int ret = 0; - int i; - sigset_t tempset, waitset; - struct sigaction act; - - _thread_enter_cancellation_point(); - - /* - * Specify the thread kernel signal handler. - */ - act.sa_handler = (void (*) ()) _thread_sig_handler; - act.sa_flags = SA_SIGINFO | SA_RESTART; - - /* Ensure the signal handler cannot be interrupted by other signals: */ - sigfillset(&act.sa_mask); - - /* - * Initialize the set of signals that will be waited on: - */ - waitset = *set; - - /* These signals can't be waited on. */ - sigdelset(&waitset, SIGKILL); - sigdelset(&waitset, SIGSTOP); - sigdelset(&waitset, _SCHED_SIGNAL); - sigdelset(&waitset, SIGCHLD); - sigdelset(&waitset, SIGINFO); - - /* Check to see if a pending signal is in the wait mask. */ - tempset = curthread->sigpend; - tempset |= _process_sigpending; - tempset &= waitset; - if (tempset != 0) { - /* Enter a loop to find a pending signal: */ - for (i = 1; i < NSIG; i++) { - if (sigismember(&tempset, i)) - break; - } - - /* Clear the pending signal: */ - if (sigismember(&curthread->sigpend, i)) - sigdelset(&curthread->sigpend, i); - else - sigdelset(&_process_sigpending, i); - - /* Return the signal number to the caller: */ - *sig = i; - - _thread_leave_cancellation_point(); - return (0); - } - - /* - * Access the _thread_dfl_count array under the protection of signal - * deferral. - */ - _thread_kern_sig_defer(); - - /* - * Enter a loop to find the signals that are SIG_DFL. For - * these signals we must install a dummy signal handler in - * order for the kernel to pass them in to us. POSIX says - * that the _application_ must explicitly install a dummy - * handler for signals that are SIG_IGN in order to sigwait - * on them. Note that SIG_IGN signals are left in the - * mask because a subsequent sigaction could enable an - * ignored signal. - */ - sigemptyset(&tempset); - for (i = 1; i < NSIG; i++) { - if (sigismember(&waitset, i) && - (_thread_sigact[i - 1].sa_handler == SIG_DFL)) { - _thread_dfl_count[i]++; - sigaddset(&tempset, i); - if (_thread_dfl_count[i] == 1) { - if (_thread_sys_sigaction(i, &act, NULL) != 0) - ret = -1; - } - } - } - - /* Done accessing _thread_dfl_count for now. */ - _thread_kern_sig_undefer(); - - if (ret == 0) { - /* - * Save the wait signal mask. The wait signal - * mask is independent of the threads signal mask - * and requires separate storage. - */ - curthread->data.sigwait = &waitset; - - /* Wait for a signal: */ - _thread_kern_sched_state(PS_SIGWAIT, __FILE__, __LINE__); - - /* Return the signal number to the caller: */ - *sig = curthread->signo; - - /* - * Probably unnecessary, but since it's in a union struct - * we don't know how it could be used in the future. - */ - curthread->data.sigwait = NULL; - } - - /* - * Access the _thread_dfl_count array under the protection of signal - * deferral. - */ - _thread_kern_sig_defer(); - - /* Restore the sigactions: */ - act.sa_handler = SIG_DFL; - for (i = 1; i < NSIG; i++) { - if (sigismember(&tempset, i)) { - _thread_dfl_count[i]--; - if ((_thread_sigact[i - 1].sa_handler == SIG_DFL) && - (_thread_dfl_count[i] == 0)) { - if (_thread_sys_sigaction(i, &act, NULL) != 0) - ret = -1; - } - } - } - - /* Done accessing _thread_dfl_count. */ - _thread_kern_sig_undefer(); - - _thread_leave_cancellation_point(); - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_single_np.c b/lib/libc_r/uthread/uthread_single_np.c deleted file mode 100644 index 242ebd92fa8..00000000000 --- a/lib/libc_r/uthread/uthread_single_np.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: uthread_single_np.c,v 1.5 2002/11/07 02:56:20 marc Exp $ */ -/* - * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_single_np.c,v 1.3 1999/08/28 00:03:51 peter Exp $ - */ -#include <string.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_single_np() -{ - struct pthread *curthread = _get_curthread(); - - /* Enter single-threaded (non-POSIX) scheduling mode: */ - _thread_single = curthread; - return(0); -} -#endif diff --git a/lib/libc_r/uthread/uthread_socket.c b/lib/libc_r/uthread/uthread_socket.c deleted file mode 100644 index b4a96b8185a..00000000000 --- a/lib/libc_r/uthread/uthread_socket.c +++ /dev/null @@ -1,59 +0,0 @@ -/* $OpenBSD: uthread_socket.c,v 1.3 1999/11/25 07:01:46 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_socket.c,v 1.5 1999/08/28 00:03:51 peter Exp $ - */ -#include <sys/types.h> -#include <sys/socket.h> -#include <fcntl.h> -#include <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -socket(int af, int type, int protocol) -{ - int fd; - - /* Create a socket: */ - if ((fd = _thread_sys_socket(af, type, protocol)) < 0) { - /* Error creating socket. */ - - /* Initialise the entry in the file descriptor table: */ - } else if (_thread_fd_table_init(fd) != 0) { - _thread_sys_close(fd); - fd = -1; - } - return (fd); -} -#endif diff --git a/lib/libc_r/uthread/uthread_socketpair.c b/lib/libc_r/uthread/uthread_socketpair.c deleted file mode 100644 index 5ccdf6ee602..00000000000 --- a/lib/libc_r/uthread/uthread_socketpair.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $OpenBSD: uthread_socketpair.c,v 1.4 2000/01/06 07:21:35 d Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_socketpair.c,v 1.6 1999/08/28 00:03:52 peter Exp $ - * - */ -#include <sys/types.h> -#include <sys/socket.h> -#include <fcntl.h> -#include <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -socketpair(int af, int type, int protocol, int pair[2]) -{ - int ret; - if (!((ret = _thread_sys_socketpair(af, type, protocol, pair)) < 0)) - if (_thread_fd_table_init(pair[0]) != 0 || - _thread_fd_table_init(pair[1]) != 0) { - _thread_sys_close(pair[0]); - _thread_sys_close(pair[1]); - ret = -1; - } - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_spec.c b/lib/libc_r/uthread/uthread_spec.c deleted file mode 100644 index b1fdeb9dfa5..00000000000 --- a/lib/libc_r/uthread/uthread_spec.c +++ /dev/null @@ -1,202 +0,0 @@ -/* $OpenBSD: uthread_spec.c,v 1.7 2001/08/21 19:24:53 fgsch Exp $ */ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_spec.c,v 1.13 1999/08/28 00:03:52 peter Exp $ - */ -#include <signal.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* Static variables: */ -static struct pthread_key key_table[PTHREAD_KEYS_MAX]; - -int -pthread_key_create(pthread_key_t * key, void (*destructor) (void *)) -{ - for ((*key) = 0; (*key) < PTHREAD_KEYS_MAX; (*key)++) { - /* Lock the key table entry: */ - _SPINLOCK(&key_table[*key].lock); - - if (key_table[(*key)].allocated == 0) { - key_table[(*key)].allocated = 1; - key_table[(*key)].destructor = destructor; - - /* Unlock the key table entry: */ - _SPINUNLOCK(&key_table[*key].lock); - return (0); - } - - /* Unlock the key table entry: */ - _SPINUNLOCK(&key_table[*key].lock); - } - return (EAGAIN); -} - -int -pthread_key_delete(pthread_key_t key) -{ - int ret = 0; - - if (key < PTHREAD_KEYS_MAX) { - /* Lock the key table entry: */ - _SPINLOCK(&key_table[key].lock); - - if (key_table[key].allocated) - key_table[key].allocated = 0; - else - ret = EINVAL; - - /* Unlock the key table entry: */ - _SPINUNLOCK(&key_table[key].lock); - } else - ret = EINVAL; - return (ret); -} - -void -_thread_cleanupspecific(void) -{ - struct pthread *curthread = _get_curthread(); - void *data; - int key; - int itr; - void (*destructor)( void *); - - for (itr = 0; itr < PTHREAD_DESTRUCTOR_ITERATIONS; itr++) { - for (key = 0; key < PTHREAD_KEYS_MAX; key++) { - if (curthread->specific_data_count) { - /* Lock the key table entry: */ - _SPINLOCK(&key_table[key].lock); - destructor = data = NULL; - - if (key_table[key].allocated) { - if (curthread->specific_data[key]) { - data = (void *) curthread->specific_data[key]; - curthread->specific_data[key] = NULL; - curthread->specific_data_count--; - destructor = key_table[key].destructor; - } - } - - /* Unlock the key table entry: */ - _SPINUNLOCK(&key_table[key].lock); - - /* - * If there is a destructore, call it - * with the key table entry unlocked: - */ - if (destructor) - destructor(data); - } else { - free(curthread->specific_data); - curthread->specific_data = NULL; - return; - } - } - } - free(curthread->specific_data); - curthread->specific_data = NULL; -} - -static inline const void ** -pthread_key_allocate_data(void) -{ - const void **new_data; - if ((new_data = (const void **) malloc(sizeof(void *) * PTHREAD_KEYS_MAX)) != NULL) { - memset((void *) new_data, 0, sizeof(void *) * PTHREAD_KEYS_MAX); - } - return (new_data); -} - -int -pthread_setspecific(pthread_key_t key, const void *value) -{ - struct pthread *pthread; - int ret = 0; - - /* Point to the running thread: */ - pthread = _get_curthread(); - - if ((pthread->specific_data) || - (pthread->specific_data = pthread_key_allocate_data())) { - if (key < PTHREAD_KEYS_MAX) { - if (key_table[key].allocated) { - if (pthread->specific_data[key] == NULL) { - if (value != NULL) - pthread->specific_data_count++; - } else { - if (value == NULL) - pthread->specific_data_count--; - } - pthread->specific_data[key] = value; - ret = 0; - } else - ret = EINVAL; - } else - ret = EINVAL; - } else - ret = ENOMEM; - return (ret); -} - -void * -pthread_getspecific(pthread_key_t key) -{ - struct pthread *pthread; - void *data; - - /* Point to the running thread: */ - pthread = _get_curthread(); - - /* Check if there is specific data: */ - if (pthread->specific_data != NULL && key < PTHREAD_KEYS_MAX) { - /* Check if this key has been used before: */ - if (key_table[key].allocated) { - /* Return the value: */ - data = (void *) pthread->specific_data[key]; - } else { - /* - * This key has not been used before, so return NULL - * instead: - */ - data = NULL; - } - } else - /* No specific data has been created, so just return NULL: */ - data = NULL; - return (data); -} -#endif diff --git a/lib/libc_r/uthread/uthread_spinlock.c b/lib/libc_r/uthread/uthread_spinlock.c deleted file mode 100644 index 2c75863f0db..00000000000 --- a/lib/libc_r/uthread/uthread_spinlock.c +++ /dev/null @@ -1,109 +0,0 @@ -/* $OpenBSD: uthread_spinlock.c,v 1.12 2002/09/12 23:21:42 marc Exp $ */ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_spinlock.c,v 1.7 1999/08/28 00:03:52 peter Exp $ - * - */ - -#include <stdio.h> -#include <sched.h> -#include <unistd.h> -#include <pthread.h> -#include <string.h> -#include "pthread_private.h" - -extern char *__progname; - -/* - * Lock a location for the running thread. Yield to allow other - * threads to run if this thread is blocked because the lock is - * not available. - */ -void -_spinlock(spinlock_t *lck) -{ - struct pthread *curthread = _get_curthread(); - - /* - * Try to grab the lock and loop if another thread grabs - * it before we do. - */ - while(_atomic_lock(&lck->access_lock)) { - /* Block the thread until the lock. */ - curthread->data.spinlock = lck; - _thread_kern_sched_state(PS_SPINBLOCK, __FILE__, __LINE__); - } - - /* The running thread now owns the lock: */ - lck->lock_owner = curthread; -} - -/* - * Lock a location for the running thread. Yield to allow other - * threads to run if this thread is blocked because the lock is - * not available. Note that this function does not sleep. It - * assumes that the lock will be available very soon. - * - * This function checks if the running thread has already locked the - * location, warns if this occurs and creates a thread dump before - * returning. - */ -void -_spinlock_debug(spinlock_t *lck, char *fname, int lineno) -{ - struct pthread *curthread = _get_curthread(); - int cnt = 0; - - /* - * Try to grab the lock and loop if another thread grabs - * it before we do. - */ - while(_atomic_lock(&lck->access_lock)) { - cnt++; - if (cnt > 100) { - char str[256]; - snprintf(str, sizeof(str), "%s - Warning: Thread %p attempted to lock %p from %s (%d) was left locked from %s (%d)\n", __progname, curthread, lck, fname, lineno, lck->fname, lck->lineno); - _thread_sys_write(2,str,strlen(str)); - sleep(1); - cnt = 0; - } - - /* Block the thread until the lock. */ - curthread->data.spinlock = lck; - _thread_kern_sched_state(PS_SPINBLOCK, fname, lineno); - } - - /* The running thread now owns the lock: */ - lck->lock_owner = curthread; - lck->fname = fname; - lck->lineno = lineno; -} diff --git a/lib/libc_r/uthread/uthread_stack.c b/lib/libc_r/uthread/uthread_stack.c deleted file mode 100644 index 6e359b970fb..00000000000 --- a/lib/libc_r/uthread/uthread_stack.c +++ /dev/null @@ -1,118 +0,0 @@ -/* $OpenBSD: uthread_stack.c,v 1.7 2000/03/22 02:06:05 d Exp $ */ -/* - * Copyright 1999, David Leonard. All rights reserved. - * <insert BSD-style license&disclaimer> - */ - -/* - * Thread stack allocation. - * - * If stack pointers grow down, towards the beginning of stack storage, - * the first page of the storage is protected using mprotect() so as - * to generate a SIGSEGV if a thread overflows its stack. Similarly, - * for stacks that grow up, the last page of the storage is protected. - */ - -#include <stddef.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/param.h> -#include <sys/user.h> -#include <sys/mman.h> -#include <pthread.h> -#include <pthread_np.h> -#include "pthread_private.h" - -struct stack * -_thread_stack_alloc(base, size) - void *base; - size_t size; -{ - struct stack *stack; - int nbpg = getpagesize(); - - /* Maintain a stack of default-sized stacks that we can re-use. */ - if (base == NULL && size == PTHREAD_STACK_DEFAULT) { - if (pthread_mutex_lock(&_gc_mutex) != 0) - PANIC("Cannot lock gc mutex"); - - if ((stack = SLIST_FIRST(&_stackq)) != NULL) { - SLIST_REMOVE_HEAD(&_stackq, qe); - if (pthread_mutex_unlock(&_gc_mutex) != 0) - PANIC("Cannot unlock gc mutex"); - return stack; - } - if (pthread_mutex_unlock(&_gc_mutex) != 0) - PANIC("Cannot unlock gc mutex"); - } - - /* Allocate some storage to hold information about the stack: */ - stack = (struct stack *)malloc(sizeof (struct stack)); - if (stack == NULL) - return NULL; - - if (base != NULL) { - /* Use the user's storage */ - stack->base = base; - stack->size = size; - stack->redzone = NULL; - stack->storage = NULL; - return stack; - } - - /* Allocate some storage for the stack, with some overhead: */ - stack->storage = malloc(size + nbpg * 2); - if (stack->storage == NULL) { - free(stack); - return NULL; - } - - /* - * Compute the location of the red zone. - * Use _BSD_PTRDIFF_T_ to convert the storage base pointer - * into an integer so that page alignment can be done with - * integer arithmetic. - */ -#if defined(MACHINE_STACK_GROWS_UP) - /* Red zone is the last page of the storage: */ - stack->redzone = (void *)(((_BSD_PTRDIFF_T_)stack->storage + - size + nbpg - 1) & ~(nbpg - 1)); - stack->base = (caddr_t)stack->storage; - stack->size = size; -#else - /* Red zone is the first page of the storage: */ - stack->redzone = (void *)(((_BSD_PTRDIFF_T_)stack->storage + - nbpg - 1) & ~(nbpg - 1)); - stack->base = (caddr_t)stack->redzone + nbpg; - stack->size = size; -#endif - if (mprotect(stack->redzone, nbpg, 0) == -1) - PANIC("Cannot protect stack red zone"); - - return stack; -} - -void -_thread_stack_free(stack) - struct stack *stack; -{ - int nbpg = getpagesize(); - - /* Cache allocated stacks of default size: */ - if (stack->storage != NULL && stack->size == PTHREAD_STACK_DEFAULT) - SLIST_INSERT_HEAD(&_stackq, stack, qe); - else { - /* Restore storage protection to what malloc gave us: */ - if (stack->redzone) - mprotect(stack->redzone, nbpg, - PROT_READ|PROT_WRITE); - - /* Free storage: */ - if (stack->storage) - free(stack->storage); - - /* Free stack information storage: */ - free(stack); - } -} diff --git a/lib/libc_r/uthread/uthread_suspend_np.c b/lib/libc_r/uthread/uthread_suspend_np.c deleted file mode 100644 index 4fd134ba187..00000000000 --- a/lib/libc_r/uthread/uthread_suspend_np.c +++ /dev/null @@ -1,160 +0,0 @@ -/* $OpenBSD: uthread_suspend_np.c,v 1.7 2001/09/04 22:17:45 fgsch Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_suspend_np.c,v 1.7 1999/08/28 00:03:53 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -static void finish_suspension(void *arg); - -/* Suspend a thread: */ -int -pthread_suspend_np(pthread_t thread) -{ - int ret; - - /* Find the thread in the list of active threads: */ - if ((ret = _find_thread(thread)) == 0) { - /* - * Defer signals to protect the scheduling queues from - * access by the signal handler: - */ - _thread_kern_sig_defer(); - - switch (thread->state) { - case PS_RUNNING: - /* - * Remove the thread from the priority queue and - * set the state to suspended: - */ - PTHREAD_PRIOQ_REMOVE(thread); - PTHREAD_SET_STATE(thread, PS_SUSPENDED); - break; - - case PS_SPINBLOCK: - case PS_FDR_WAIT: - case PS_FDW_WAIT: - case PS_POLL_WAIT: - case PS_SELECT_WAIT: - /* - * Remove these threads from the work queue - * and mark the operation as interrupted: - */ - if ((thread->flags & PTHREAD_FLAGS_IN_WORKQ) != 0) - PTHREAD_WORKQ_REMOVE(thread); - _thread_seterrno(thread, EINTR); - - /* FALLTHROUGH */ - case PS_SLEEP_WAIT: - thread->interrupted = 1; - - /* FALLTHROUGH */ - case PS_SIGTHREAD: - case PS_WAIT_WAIT: - case PS_SIGSUSPEND: - case PS_SIGWAIT: - /* - * Remove these threads from the waiting queue and - * set their state to suspended: - */ - PTHREAD_WAITQ_REMOVE(thread); - PTHREAD_SET_STATE(thread, PS_SUSPENDED); - break; - - case PS_MUTEX_WAIT: - /* Mark the thread as suspended and still in a queue. */ - thread->suspended = SUSP_MUTEX_WAIT; - - PTHREAD_SET_STATE(thread, PS_SUSPENDED); - break; - case PS_COND_WAIT: - /* Mark the thread as suspended and still in a queue. */ - thread->suspended = SUSP_COND_WAIT; - - PTHREAD_SET_STATE(thread, PS_SUSPENDED); - break; - case PS_JOIN: - /* Mark the thread as suspended and joining: */ - thread->suspended = SUSP_JOIN; - - PTHREAD_NEW_STATE(thread, PS_SUSPENDED); - break; - case PS_FDLR_WAIT: - case PS_FDLW_WAIT: - case PS_FILE_WAIT: - /* Mark the thread as suspended: */ - thread->suspended = SUSP_YES; - - /* - * Threads in these states may be in queues. - * In order to preserve queue integrity, the - * cancelled thread must remove itself from the - * queue. Mark the thread as interrupted and - * set the state to running. When the thread - * resumes, it will remove itself from the queue - * and call the suspension completion routine. - */ - thread->interrupted = 1; - _thread_seterrno(thread, EINTR); - PTHREAD_NEW_STATE(thread, PS_RUNNING); - thread->continuation = finish_suspension; - break; - - case PS_DEAD: - case PS_DEADLOCK: - case PS_STATE_MAX: - case PS_SUSPENDED: - /* Nothing needs to be done: */ - break; - } - - /* - * Undefer and handle pending signals, yielding if - * necessary: - */ - _thread_kern_sig_undefer(); - } - return(ret); -} - -static void -finish_suspension(void *arg) -{ - struct pthread *curthread = _get_curthread(); - - if (curthread->suspended != SUSP_NO) - _thread_kern_sched_state(PS_SUSPENDED, __FILE__, __LINE__); -} -#endif diff --git a/lib/libc_r/uthread/uthread_switch_np.c b/lib/libc_r/uthread/uthread_switch_np.c deleted file mode 100644 index 2e7351b9697..00000000000 --- a/lib/libc_r/uthread/uthread_switch_np.c +++ /dev/null @@ -1,71 +0,0 @@ -/* $OpenBSD: uthread_switch_np.c,v 1.2 1999/11/25 07:01:46 d Exp $ */ -/* - * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Daniel Eischen. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_switch_np.c,v 1.3 1999/08/28 00:03:53 peter Exp $ - */ -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include <pthread_np.h> -#include "pthread_private.h" - - -int -pthread_switch_add_np(pthread_switch_routine_t routine) -{ - int ret = 0; - - if (routine == NULL) - /* Return an invalid argument error: */ - ret = EINVAL; - else - /* Shouldn't need a lock to protect this assigment. */ - _sched_switch_hook = routine; - - return(ret); -} - -int -pthread_switch_delete_np(pthread_switch_routine_t routine) -{ - int ret = 0; - - if (routine != _sched_switch_hook) - /* Return an invalid argument error: */ - ret = EINVAL; - else - /* Shouldn't need a lock to protect this assigment. */ - _sched_switch_hook = NULL; - - return(ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_vfork.c b/lib/libc_r/uthread/uthread_vfork.c deleted file mode 100644 index 32ac5cd33c1..00000000000 --- a/lib/libc_r/uthread/uthread_vfork.c +++ /dev/null @@ -1,10 +0,0 @@ -/* $OpenBSD: uthread_vfork.c,v 1.2 1999/11/25 07:01:47 d Exp $ */ -#include <unistd.h> -#ifdef _THREAD_SAFE - -int -vfork(void) -{ - return (fork()); -} -#endif diff --git a/lib/libc_r/uthread/uthread_wait4.c b/lib/libc_r/uthread/uthread_wait4.c deleted file mode 100644 index 51534808d0c..00000000000 --- a/lib/libc_r/uthread/uthread_wait4.c +++ /dev/null @@ -1,91 +0,0 @@ -/* $OpenBSD: uthread_wait4.c,v 1.7 2001/11/09 00:20:26 marc Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_wait4.c,v 1.5 1999/08/28 00:03:53 peter Exp $ - */ -#include <errno.h> -#include <sys/wait.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* - * Note: a thread calling wait4 may have its state changed to waiting - * until awakened by a signal. Also note that system(3), for example, - * blocks SIGCHLD and calls waitpid (which calls wait4). If the process - * started by system(3) doesn't finish before this function is called the - * function will never awaken -- system(3) also ignores SIGINT and SIGQUIT. - * - * Thus always unmask SIGCHLD here. - */ -pid_t -wait4(pid_t pid, int *istat, int options, struct rusage * rusage) -{ - struct pthread *curthread = _get_curthread(); - pid_t ret; - sigset_t mask, omask; - - /* This is a cancellation point: */ - _thread_enter_cancellation_point(); - - _thread_kern_sig_defer(); - - sigemptyset(&mask); - sigaddset(&mask, SIGCHLD); - sigprocmask(SIG_UNBLOCK, &mask, &omask); - - /* Perform a non-blocking wait4 syscall: */ - while ((ret = _thread_sys_wait4(pid, istat, options | WNOHANG, rusage)) == 0 && (options & WNOHANG) == 0) { - /* Reset the interrupted operation flag: */ - curthread->interrupted = 0; - - /* Schedule the next thread while this one waits: */ - _thread_kern_sched_state(PS_WAIT_WAIT, __FILE__, __LINE__); - - /* Check if this call was interrupted by a signal: */ - if (curthread->interrupted) { - errno = EINTR; - ret = -1; - break; - } - } - - sigprocmask(SIG_SETMASK, &omask, NULL); - - _thread_kern_sig_undefer(); - - /* No longer in a cancellation point: */ - _thread_leave_cancellation_point(); - - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_write.c b/lib/libc_r/uthread/uthread_write.c deleted file mode 100644 index 09cd9001055..00000000000 --- a/lib/libc_r/uthread/uthread_write.c +++ /dev/null @@ -1,145 +0,0 @@ -/* $OpenBSD: uthread_write.c,v 1.8 2001/08/21 19:24:53 fgsch Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_write.c,v 1.12 1999/08/28 00:03:54 peter Exp $ - * - */ -#include <sys/types.h> -#include <sys/fcntl.h> -#include <sys/uio.h> -#include <errno.h> -#include <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -ssize_t -write(int fd, const void *buf, size_t nbytes) -{ - struct pthread *curthread = _get_curthread(); - int blocking; - int type; - ssize_t n; - ssize_t num = 0; - ssize_t ret; - - /* This is a cancellation point: */ - _thread_enter_cancellation_point(); - - /* POSIX says to do just this: */ - if (nbytes == 0) - ret = 0; - - /* Lock the file descriptor for write: */ - else if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) { - /* Get the read/write mode type: */ - type = _thread_fd_table[fd]->flags & O_ACCMODE; - - /* Check if the file is not open for write: */ - if (type != O_WRONLY && type != O_RDWR) { - /* File is not open for write: */ - errno = EBADF; - ret = -1; - } - - else { - /* Check if file operations are to block */ - blocking = ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0); - - /* - * Loop while no error occurs and until the expected number - * of bytes are written if performing a blocking write: - */ - while (ret == 0) { - /* Perform a non-blocking write syscall: */ - n = _thread_sys_write(fd, (caddr_t)buf + num, - nbytes - num); - - /* Check if one or more bytes were written: */ - if (n > 0) - /* - * Keep a count of the number of bytes - * written: - */ - num += n; - - /* - * If performing a blocking write, check if the - * write would have blocked or if some bytes - * were written but there are still more to - * write: - */ - if (blocking && ((n < 0 && (errno == EWOULDBLOCK || - errno == EAGAIN)) || (n >= 0 && num < nbytes))) { - curthread->data.fd.fd = fd; - _thread_kern_set_timeout(NULL); - - /* Reset the interrupted operation flag: */ - curthread->interrupted = 0; - - _thread_kern_sched_state(PS_FDW_WAIT, - __FILE__, __LINE__); - - /* - * Check if the operation was - * interrupted by a signal - */ - if (curthread->interrupted) { - /* Return an error: */ - ret = -1; - } - - /* - * If performing a non-blocking write or if an - * error occurred, just return whatever the write - * syscall did: - */ - } else if (!blocking || n < 0) { - /* A non-blocking call might return zero: */ - ret = n; - break; - - /* Check if the write has completed: */ - } else if (num >= nbytes) - /* Return the number of bytes written: */ - ret = num; - } - } - _FD_UNLOCK(fd, FD_WRITE); - } - - /* No longer in a cancellation point: */ - _thread_leave_cancellation_point(); - - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_writev.c b/lib/libc_r/uthread/uthread_writev.c deleted file mode 100644 index eb5d6418a98..00000000000 --- a/lib/libc_r/uthread/uthread_writev.c +++ /dev/null @@ -1,205 +0,0 @@ -/* $OpenBSD: uthread_writev.c,v 1.5 2001/08/21 19:24:53 fgsch Exp $ */ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_writev.c,v 1.12 1999/08/28 00:03:55 peter Exp $ - * - */ -#include <sys/types.h> -#include <sys/fcntl.h> -#include <sys/uio.h> -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -ssize_t -writev(int fd, const struct iovec * iov, int iovcnt) -{ - struct pthread *curthread = _get_curthread(); - int blocking; - int idx = 0; - int type; - ssize_t cnt; - ssize_t n; - ssize_t num = 0; - ssize_t ret; - struct iovec liov[20]; - struct iovec *p_iov = liov; - - /* Check if the array size exceeds to compiled in size: */ - if (iovcnt > (sizeof(liov) / sizeof(struct iovec))) { - /* Allocate memory for the local array: */ - if ((p_iov = (struct iovec *) - malloc(iovcnt * sizeof(struct iovec))) == NULL) { - /* Insufficient memory: */ - errno = ENOMEM; - return (-1); - } - } - - /* Copy the caller's array so that it can be modified locally: */ - memcpy(p_iov,iov,iovcnt * sizeof(struct iovec)); - - /* Lock the file descriptor for write: */ - if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) { - /* Get the read/write mode type: */ - type = _thread_fd_table[fd]->flags & O_ACCMODE; - - /* Check if the file is not open for write: */ - if (type != O_WRONLY && type != O_RDWR) { - /* File is not open for write: */ - errno = EBADF; - _FD_UNLOCK(fd, FD_WRITE); - return (-1); - } - - /* Check if file operations are to block */ - blocking = ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0); - - /* - * Loop while no error occurs and until the expected number - * of bytes are written if performing a blocking write: - */ - while (ret == 0) { - /* Perform a non-blocking write syscall: */ - n = _thread_sys_writev(fd, &p_iov[idx], iovcnt - idx); - - /* Check if one or more bytes were written: */ - if (n > 0) { - /* - * Keep a count of the number of bytes - * written: - */ - num += n; - - /* - * Enter a loop to check if a short write - * occurred and move the index to the - * array entry where the short write - * ended: - */ - cnt = n; - while (cnt > 0 && idx < iovcnt) { - /* - * If the residual count exceeds - * the size of this vector, then - * it was completely written: - */ - if (cnt >= p_iov[idx].iov_len) - /* - * Decrement the residual - * count and increment the - * index to the next array - * entry: - */ - cnt -= p_iov[idx++].iov_len; - else { - /* - * This entry was only - * partially written, so - * adjust it's length - * and base pointer ready - * for the next write: - */ - p_iov[idx].iov_len -= cnt; - p_iov[idx].iov_base += cnt; - cnt = 0; - } - } - } else if (n == 0) { - /* - * Avoid an infinite loop if the last iov_len is - * 0. - */ - while (idx < iovcnt && p_iov[idx].iov_len == 0) - idx++; - - if (idx == iovcnt) { - ret = num; - break; - } - } - - /* - * If performing a blocking write, check if the - * write would have blocked or if some bytes - * were written but there are still more to - * write: - */ - if (blocking && ((n < 0 && (errno == EWOULDBLOCK || - errno == EAGAIN)) || (n >= 0 && idx < iovcnt))) { - curthread->data.fd.fd = fd; - _thread_kern_set_timeout(NULL); - - /* Reset the interrupted operation flag: */ - curthread->interrupted = 0; - - _thread_kern_sched_state(PS_FDW_WAIT, - __FILE__, __LINE__); - - /* - * Check if the operation was - * interrupted by a signal - */ - if (curthread->interrupted) { - /* Return an error: */ - ret = -1; - } - - /* - * If performing a non-blocking write or if an - * error occurred, just return whatever the write - * syscall did: - */ - } else if (!blocking || n < 0) { - /* A non-blocking call might return zero: */ - ret = n; - break; - - /* Check if the write has completed: */ - } else if (idx == iovcnt) - /* Return the number of bytes written: */ - ret = num; - } - _FD_UNLOCK(fd, FD_RDWR); - } - - /* If memory was allocated for the array, free it: */ - if (p_iov != liov) - free(p_iov); - - return (ret); -} -#endif diff --git a/lib/libc_r/uthread/uthread_yield.c b/lib/libc_r/uthread/uthread_yield.c deleted file mode 100644 index 32852ee847a..00000000000 --- a/lib/libc_r/uthread/uthread_yield.c +++ /dev/null @@ -1,66 +0,0 @@ -/* $OpenBSD: uthread_yield.c,v 1.5 2001/08/21 19:24:53 fgsch Exp $ */ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: uthread_yield.c,v 1.4 1999/08/28 00:03:55 peter Exp $ - */ -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -sched_yield(void) -{ - struct pthread *curthread = _get_curthread(); - - /* Reset the accumulated time slice value for the current thread: */ - curthread->slice_usec = -1; - - /* Schedule the next thread: */ - _thread_kern_sched(NULL); - - /* Always return no error. */ - return(0); -} - -/* Draft 4 yield */ -void -pthread_yield(void) -{ - struct pthread *curthread = _get_curthread(); - - /* Reset the accumulated time slice value for the current thread: */ - curthread->slice_usec = -1; - - /* Schedule the next thread: */ - _thread_kern_sched(NULL); -} -#endif |