summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Leonard <d@cvs.openbsd.org>1999-03-10 08:54:11 +0000
committerDavid Leonard <d@cvs.openbsd.org>1999-03-10 08:54:11 +0000
commit7b835a298b0b450e6af3d563b4f601ed753e04de (patch)
tree57757dbac63b32b63654d9246268e75bd98e32b8
parent9755a69c88657c7badce3d6639e42d32b9bfe63d (diff)
Goodbye, MIT pthreads... you were a handy reference implementation
-rw-r--r--lib/libpthread/COPYRIGHT31
-rw-r--r--lib/libpthread/Changes-mysql169
-rw-r--r--lib/libpthread/FAQ122
-rw-r--r--lib/libpthread/Makefile20
-rw-r--r--lib/libpthread/NOTES59
-rw-r--r--lib/libpthread/NOTES_OSR5_BUILD_SKUNKWARE9745
-rw-r--r--lib/libpthread/README85
-rw-r--r--lib/libpthread/TODO-mysql4
-rw-r--r--lib/libpthread/Whats_New198
-rw-r--r--lib/libpthread/arch/alpha/machdep.c204
-rw-r--r--lib/libpthread/arch/alpha/machdep.h111
-rw-r--r--lib/libpthread/arch/alpha/syscall-template.S46
-rw-r--r--lib/libpthread/arch/alpha/syscall.S224
-rw-r--r--lib/libpthread/arch/i386/Makefile.inc4
-rw-r--r--lib/libpthread/arch/i386/SYS.h56
-rw-r--r--lib/libpthread/arch/i386/machdep.c215
-rw-r--r--lib/libpthread/arch/i386/machdep.h97
-rw-r--r--lib/libpthread/arch/i386/syscall-template.S48
-rw-r--r--lib/libpthread/arch/i386/syscall.S248
-rw-r--r--lib/libpthread/arch/m68k/Makefile.inc4
-rw-r--r--lib/libpthread/arch/m68k/machdep.c153
-rw-r--r--lib/libpthread/arch/m68k/machdep.h77
-rw-r--r--lib/libpthread/arch/m68k/syscall.S125
-rw-r--r--lib/libpthread/arch/sparc/syscall-template.S40
-rw-r--r--lib/libpthread/arch/sparc/syscall.S102
-rw-r--r--lib/libpthread/bin/Makefile49
-rw-r--r--lib/libpthread/bin/Makefile.in48
-rw-r--r--lib/libpthread/bin/finger/Makefile61
-rwxr-xr-xlib/libpthread/bin/finger/Makefile.in60
-rwxr-xr-xlib/libpthread/bin/finger/finger.c231
-rwxr-xr-xlib/libpthread/bin/finger/net.c189
-rw-r--r--lib/libpthread/gen/Makefile.inc8
-rw-r--r--lib/libpthread/gen/ctime.c1314
-rw-r--r--lib/libpthread/gen/difftime.c46
-rw-r--r--lib/libpthread/gen/directory.c322
-rw-r--r--lib/libpthread/gen/eprintf.c18
-rw-r--r--lib/libpthread/gen/getcwd.c248
-rw-r--r--lib/libpthread/gen/getpwent.c109
-rw-r--r--lib/libpthread/gen/getpwnamuid.c138
-rw-r--r--lib/libpthread/gen/getwd.c57
-rw-r--r--lib/libpthread/gen/isatty.c95
-rw-r--r--lib/libpthread/gen/popen.c117
-rw-r--r--lib/libpthread/gen/pwd_internal.c97
-rw-r--r--lib/libpthread/gen/pwd_internal.h29
-rw-r--r--lib/libpthread/gen/syslog.c216
-rw-r--r--lib/libpthread/gen/time.c51
-rw-r--r--lib/libpthread/gen/ttyname.c147
-rwxr-xr-xlib/libpthread/include/arpa/inet.h61
-rwxr-xr-xlib/libpthread/include/arpa/nameser.h279
-rw-r--r--lib/libpthread/include/dirent.h97
-rw-r--r--lib/libpthread/include/endian.h95
-rw-r--r--lib/libpthread/include/errno.h52
-rw-r--r--lib/libpthread/include/math.h85
-rw-r--r--lib/libpthread/include/netdb.h146
-rwxr-xr-xlib/libpthread/include/pthread/ac-types.h11
-rwxr-xr-xlib/libpthread/include/pthread/cleanup.h59
-rwxr-xr-xlib/libpthread/include/pthread/cond.h100
-rwxr-xr-xlib/libpthread/include/pthread/config.h4
-rwxr-xr-xlib/libpthread/include/pthread/debug_out.h44
-rwxr-xr-xlib/libpthread/include/pthread/fd.h122
-rwxr-xr-xlib/libpthread/include/pthread/fd_pipe.h54
-rwxr-xr-xlib/libpthread/include/pthread/kernel.h71
-rwxr-xr-xlib/libpthread/include/pthread/kthread.h67
-rwxr-xr-xlib/libpthread/include/pthread/mutex.h102
-rwxr-xr-xlib/libpthread/include/pthread/paths.h12
-rw-r--r--lib/libpthread/include/pthread/posix.h31
-rwxr-xr-xlib/libpthread/include/pthread/prio_queue.h78
-rwxr-xr-xlib/libpthread/include/pthread/pthread_attr.h122
-rwxr-xr-xlib/libpthread/include/pthread/pthread_once.h58
-rwxr-xr-xlib/libpthread/include/pthread/queue.h67
-rwxr-xr-xlib/libpthread/include/pthread/sleep.h63
-rwxr-xr-xlib/libpthread/include/pthread/specific.h66
-rwxr-xr-xlib/libpthread/include/pthread/state.def64
-rwxr-xr-xlib/libpthread/include/pthread/types.h46
-rwxr-xr-xlib/libpthread/include/pthread/unistd.h159
-rwxr-xr-xlib/libpthread/include/pthread/util.h89
-rwxr-xr-xlib/libpthread/include/pthread/version.h43
-rwxr-xr-xlib/libpthread/include/pthread/xtypes.h13
-rw-r--r--lib/libpthread/include/pwd.h93
-rw-r--r--lib/libpthread/include/resolv.h179
-rw-r--r--lib/libpthread/include/signal.h81
-rw-r--r--lib/libpthread/include/stdio.h371
-rw-r--r--lib/libpthread/include/stdlib.h127
-rw-r--r--lib/libpthread/include/string.h85
-rw-r--r--lib/libpthread/include/sys/__math.h6
-rw-r--r--lib/libpthread/include/sys/__path.h14
-rw-r--r--lib/libpthread/include/sys/__signal.h8
-rw-r--r--lib/libpthread/include/sys/__stdio.h8
-rw-r--r--lib/libpthread/include/sys/__stdlib.h66
-rw-r--r--lib/libpthread/include/sys/__string.h21
-rw-r--r--lib/libpthread/include/sys/__time.h70
-rw-r--r--lib/libpthread/include/sys/__unistd.h109
-rw-r--r--lib/libpthread/include/sys/compat.h43
-rw-r--r--lib/libpthread/include/sys/dirent.h64
-rw-r--r--lib/libpthread/include/sys/errno.h160
-rw-r--r--lib/libpthread/include/sys/timers.h45
-rw-r--r--lib/libpthread/include/sys/wait.h162
-rw-r--r--lib/libpthread/include/syslog.h101
-rw-r--r--lib/libpthread/include/time.h102
-rw-r--r--lib/libpthread/include/timers.h45
-rw-r--r--lib/libpthread/include/tzfile.h154
-rw-r--r--lib/libpthread/include/unistd.h183
-rw-r--r--lib/libpthread/lib/Makefile49
-rw-r--r--lib/libpthread/lib/Makefile.in48
-rw-r--r--lib/libpthread/lib/libpthreadutil/Makefile66
-rwxr-xr-xlib/libpthread/lib/libpthreadutil/Makefile.in65
-rwxr-xr-xlib/libpthread/lib/libpthreadutil/pthread_atexit.c135
-rwxr-xr-xlib/libpthread/lib/libpthreadutil/pthread_tad.c170
-rw-r--r--lib/libpthread/lib/libpthreadutil/pthreadutil.h75
-rw-r--r--lib/libpthread/net/Makefile.inc13
-rw-r--r--lib/libpthread/net/gethostbyaddr.c161
-rw-r--r--lib/libpthread/net/gethostbyname.c167
-rw-r--r--lib/libpthread/net/gethostent.c162
-rw-r--r--lib/libpthread/net/getnetbyaddr.c65
-rw-r--r--lib/libpthread/net/getnetbyname.c72
-rw-r--r--lib/libpthread/net/getnetent.c145
-rw-r--r--lib/libpthread/net/getproto.c65
-rw-r--r--lib/libpthread/net/getprotoent.c143
-rw-r--r--lib/libpthread/net/getprotoname.c73
-rw-r--r--lib/libpthread/net/getservbyname.c76
-rw-r--r--lib/libpthread/net/getservbyport.c68
-rw-r--r--lib/libpthread/net/getservent.c146
-rw-r--r--lib/libpthread/net/herror.c92
-rw-r--r--lib/libpthread/net/inet_addr.c156
-rw-r--r--lib/libpthread/net/inet_lnaof.c61
-rw-r--r--lib/libpthread/net/inet_makeaddr.c64
-rw-r--r--lib/libpthread/net/inet_netof.c60
-rw-r--r--lib/libpthread/net/inet_network.c98
-rw-r--r--lib/libpthread/net/inet_ntoa.c85
-rw-r--r--lib/libpthread/net/net_internal.c78
-rw-r--r--lib/libpthread/net/net_internal.h57
-rw-r--r--lib/libpthread/net/proto_internal.c78
-rw-r--r--lib/libpthread/net/proto_internal.h57
-rw-r--r--lib/libpthread/net/res_comp.c340
-rw-r--r--lib/libpthread/net/res_debug.c749
-rw-r--r--lib/libpthread/net/res_init.c55
-rw-r--r--lib/libpthread/net/res_internal.c576
-rw-r--r--lib/libpthread/net/res_internal.h84
-rw-r--r--lib/libpthread/net/res_mkquery.c212
-rw-r--r--lib/libpthread/net/res_query.c97
-rw-r--r--lib/libpthread/net/res_querydomain.c66
-rw-r--r--lib/libpthread/net/res_search.c168
-rw-r--r--lib/libpthread/net/res_send.c313
-rw-r--r--lib/libpthread/net/serv_internal.c80
-rw-r--r--lib/libpthread/net/serv_internal.h57
-rwxr-xr-xlib/libpthread/patches/Streepy.html2873
-rwxr-xr-xlib/libpthread/patches/Streepy2.html93
-rwxr-xr-xlib/libpthread/patches/bill_lear70
-rwxr-xr-xlib/libpthread/patches/chris_demetriou149
-rwxr-xr-xlib/libpthread/patches/mevans642
-rwxr-xr-xlib/libpthread/patches/p15390
-rwxr-xr-xlib/libpthread/patches/p15596
-rw-r--r--lib/libpthread/pthreads/Makefile.inc107
-rw-r--r--lib/libpthread/pthreads/_exit.c80
-rw-r--r--lib/libpthread/pthreads/cleanup.c82
-rw-r--r--lib/libpthread/pthreads/cond.c208
-rw-r--r--lib/libpthread/pthreads/condattr.c90
-rw-r--r--lib/libpthread/pthreads/dump_state.c88
-rw-r--r--lib/libpthread/pthreads/errno.c53
-rw-r--r--lib/libpthread/pthreads/fd.c1081
-rw-r--r--lib/libpthread/pthreads/fd_kern.c1838
-rw-r--r--lib/libpthread/pthreads/fd_pipe.c268
-rw-r--r--lib/libpthread/pthreads/fd_sysv.c897
-rw-r--r--lib/libpthread/pthreads/file.c117
-rw-r--r--lib/libpthread/pthreads/globals.c67
-rw-r--r--lib/libpthread/pthreads/info.c77
-rw-r--r--lib/libpthread/pthreads/init.cc9
-rw-r--r--lib/libpthread/pthreads/malloc.c361
-rw-r--r--lib/libpthread/pthreads/mutex.c227
-rw-r--r--lib/libpthread/pthreads/mutexattr.c90
-rw-r--r--lib/libpthread/pthreads/panic.c58
-rw-r--r--lib/libpthread/pthreads/prio_queue.c176
-rw-r--r--lib/libpthread/pthreads/process.c208
-rw-r--r--lib/libpthread/pthreads/pthread.c204
-rw-r--r--lib/libpthread/pthreads/pthread_attr.c100
-rw-r--r--lib/libpthread/pthreads/pthread_cancel.c258
-rw-r--r--lib/libpthread/pthreads/pthread_detach.c90
-rw-r--r--lib/libpthread/pthreads/pthread_init.c135
-rw-r--r--lib/libpthread/pthreads/pthread_join.c113
-rw-r--r--lib/libpthread/pthreads/pthread_kill.c93
-rw-r--r--lib/libpthread/pthreads/pthread_once.c61
-rw-r--r--lib/libpthread/pthreads/queue.c123
-rw-r--r--lib/libpthread/pthreads/schedparam.c170
-rw-r--r--lib/libpthread/pthreads/select.c255
-rw-r--r--lib/libpthread/pthreads/sig.c452
-rw-r--r--lib/libpthread/pthreads/signal.c642
-rw-r--r--lib/libpthread/pthreads/sleep.c256
-rw-r--r--lib/libpthread/pthreads/specific.c197
-rw-r--r--lib/libpthread/pthreads/stat.c114
-rw-r--r--lib/libpthread/pthreads/wait.c159
-rw-r--r--lib/libpthread/pthreads/wrapper.c130
-rw-r--r--lib/libpthread/scripts/Makefile.inc30
-rwxr-xr-xlib/libpthread/scripts/pgcc.sh32
-rw-r--r--lib/libpthread/stdio/Makefile.inc18
-rw-r--r--lib/libpthread/stdio/README40
-rw-r--r--lib/libpthread/stdio/clrerr.c50
-rw-r--r--lib/libpthread/stdio/fclose.c71
-rw-r--r--lib/libpthread/stdio/fdopen.c92
-rw-r--r--lib/libpthread/stdio/feof.c54
-rw-r--r--lib/libpthread/stdio/ferror.c54
-rw-r--r--lib/libpthread/stdio/fflush.c97
-rw-r--r--lib/libpthread/stdio/fgetc.c51
-rw-r--r--lib/libpthread/stdio/fgetline.c169
-rw-r--r--lib/libpthread/stdio/fgetpos.c50
-rw-r--r--lib/libpthread/stdio/fgets.c108
-rw-r--r--lib/libpthread/stdio/fileno.c54
-rw-r--r--lib/libpthread/stdio/findfp.c151
-rw-r--r--lib/libpthread/stdio/flags.c90
-rw-r--r--lib/libpthread/stdio/floatio.h47
-rw-r--r--lib/libpthread/stdio/fopen.c89
-rw-r--r--lib/libpthread/stdio/fprintf.c71
-rw-r--r--lib/libpthread/stdio/fpurge.c72
-rw-r--r--lib/libpthread/stdio/fputc.c54
-rw-r--r--lib/libpthread/stdio/fputs.c66
-rw-r--r--lib/libpthread/stdio/fread.c83
-rw-r--r--lib/libpthread/stdio/freopen.c146
-rw-r--r--lib/libpthread/stdio/fscanf.c73
-rw-r--r--lib/libpthread/stdio/fseek.c248
-rw-r--r--lib/libpthread/stdio/fsetpos.c53
-rw-r--r--lib/libpthread/stdio/ftell.c90
-rw-r--r--lib/libpthread/stdio/funopen.c105
-rw-r--r--lib/libpthread/stdio/fvwrite.c188
-rw-r--r--lib/libpthread/stdio/fvwrite.h54
-rw-r--r--lib/libpthread/stdio/fwalk.c131
-rw-r--r--lib/libpthread/stdio/fwrite.c77
-rw-r--r--lib/libpthread/stdio/getc.c57
-rw-r--r--lib/libpthread/stdio/getc_unlocked.c54
-rw-r--r--lib/libpthread/stdio/getchar.c57
-rw-r--r--lib/libpthread/stdio/getchar_unlocked.c53
-rw-r--r--lib/libpthread/stdio/gets.c69
-rw-r--r--lib/libpthread/stdio/getw.c50
-rw-r--r--lib/libpthread/stdio/glue.h48
-rw-r--r--lib/libpthread/stdio/local.h88
-rw-r--r--lib/libpthread/stdio/makebuf.c119
-rw-r--r--lib/libpthread/stdio/mktemp.c126
-rw-r--r--lib/libpthread/stdio/perror.c67
-rw-r--r--lib/libpthread/stdio/printf.c54
-rw-r--r--lib/libpthread/stdio/putc.c59
-rw-r--r--lib/libpthread/stdio/putc_unlocked.c55
-rw-r--r--lib/libpthread/stdio/putchar.c59
-rw-r--r--lib/libpthread/stdio/putchar_unlocked.c55
-rw-r--r--lib/libpthread/stdio/puts.c70
-rw-r--r--lib/libpthread/stdio/putw.c63
-rw-r--r--lib/libpthread/stdio/refill.c183
-rw-r--r--lib/libpthread/stdio/remove.c48
-rw-r--r--lib/libpthread/stdio/rewind.c54
-rw-r--r--lib/libpthread/stdio/rget.c57
-rw-r--r--lib/libpthread/stdio/scanf.c72
-rw-r--r--lib/libpthread/stdio/setbuf.c51
-rw-r--r--lib/libpthread/stdio/setbuffer.c63
-rw-r--r--lib/libpthread/stdio/setvbuf.c153
-rw-r--r--lib/libpthread/stdio/snprintf.c79
-rw-r--r--lib/libpthread/stdio/sprintf.c78
-rw-r--r--lib/libpthread/stdio/sscanf.c79
-rw-r--r--lib/libpthread/stdio/stdio.c92
-rw-r--r--lib/libpthread/stdio/strerror.c67
-rw-r--r--lib/libpthread/stdio/tempnam.c87
-rw-r--r--lib/libpthread/stdio/tmpfile.c80
-rw-r--r--lib/libpthread/stdio/tmpnam.c55
-rw-r--r--lib/libpthread/stdio/ungetc.c154
-rw-r--r--lib/libpthread/stdio/vfprintf.c774
-rw-r--r--lib/libpthread/stdio/vfscanf.c750
-rw-r--r--lib/libpthread/stdio/vprintf.c49
-rw-r--r--lib/libpthread/stdio/vscanf.c53
-rw-r--r--lib/libpthread/stdio/vsnprintf.c61
-rw-r--r--lib/libpthread/stdio/vsprintf.c59
-rw-r--r--lib/libpthread/stdio/vsscanf.c60
-rw-r--r--lib/libpthread/stdio/wbuf.c88
-rw-r--r--lib/libpthread/stdio/wsetup.c92
-rw-r--r--lib/libpthread/stdio/xprintf.c883
-rw-r--r--lib/libpthread/stdlib/Makefile.inc5
-rw-r--r--lib/libpthread/stdlib/abort.c67
-rw-r--r--lib/libpthread/stdlib/atexit.h46
-rw-r--r--lib/libpthread/stdlib/exit.c89
-rw-r--r--lib/libpthread/stdlib/getopt.c134
-rw-r--r--lib/libpthread/stdlib/rand.c64
-rw-r--r--lib/libpthread/stdlib/random.c389
-rw-r--r--lib/libpthread/stdlib/strtod.c178
-rw-r--r--lib/libpthread/stdlib/strtol.c131
-rw-r--r--lib/libpthread/stdlib/strtoul.c109
-rw-r--r--lib/libpthread/stdlib/system.c83
-rw-r--r--lib/libpthread/string/Makefile.inc8
-rw-r--r--lib/libpthread/string/strtok.c119
-rw-r--r--lib/libpthread/tests/Makefile124
-rw-r--r--lib/libpthread/tests/Makefile.in164
-rwxr-xr-xlib/libpthread/tests/README26
-rw-r--r--lib/libpthread/tests/bench_fcntl.c82
-rw-r--r--lib/libpthread/tests/bench_pipe.c115
-rw-r--r--lib/libpthread/tests/bench_read.c88
-rw-r--r--lib/libpthread/tests/p_bench_getpid.c78
-rw-r--r--lib/libpthread/tests/p_bench_mutex.c78
-rw-r--r--lib/libpthread/tests/p_bench_pthread_create.c92
-rw-r--r--lib/libpthread/tests/p_bench_read.c103
-rw-r--r--lib/libpthread/tests/p_bench_semaphore.c82
-rw-r--r--lib/libpthread/tests/p_bench_yield.c123
-rw-r--r--lib/libpthread/tests/test_create.c35
-rw-r--r--lib/libpthread/tests/test_cwd.c11
-rw-r--r--lib/libpthread/tests/test_execve.c57
-rw-r--r--lib/libpthread/tests/test_fcntl.c32
-rw-r--r--lib/libpthread/tests/test_fork.c60
-rw-r--r--lib/libpthread/tests/test_netdb.c110
-rw-r--r--lib/libpthread/tests/test_pause.c19
-rw-r--r--lib/libpthread/tests/test_preemption.c38
-rw-r--r--lib/libpthread/tests/test_preemption_float.c98
-rw-r--r--lib/libpthread/tests/test_pthread_cond_timedwait.c93
-rw-r--r--lib/libpthread/tests/test_pthread_join.c78
-rw-r--r--lib/libpthread/tests/test_pthread_mutex.c221
-rw-r--r--lib/libpthread/tests/test_pw.c20
-rw-r--r--lib/libpthread/tests/test_readdir.c42
-rw-r--r--lib/libpthread/tests/test_select.c115
-rw-r--r--lib/libpthread/tests/test_setjmp.c13
-rw-r--r--lib/libpthread/tests/test_sleep.c46
-rw-r--r--lib/libpthread/tests/test_sock_1.c204
-rw-r--r--lib/libpthread/tests/test_sock_2.c116
-rw-r--r--lib/libpthread/tests/test_sock_2a.c87
-rw-r--r--lib/libpthread/tests/test_stdio_1.c124
-rw-r--r--lib/libpthread/tests/test_switch.c97
317 files changed, 0 insertions, 42863 deletions
diff --git a/lib/libpthread/COPYRIGHT b/lib/libpthread/COPYRIGHT
deleted file mode 100644
index 1fb4e43cf26..00000000000
--- a/lib/libpthread/COPYRIGHT
+++ /dev/null
@@ -1,31 +0,0 @@
-Copyright (c) 1993 by Chris Provenzano and contributors, 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 Chris Provenzano,
- the University of California, Berkeley, and contributors.
-4. Neither the name of Chris Provenzano, the University, nor the names of
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO 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 CHRIS PROVENZANO, 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.
-
diff --git a/lib/libpthread/Changes-mysql b/lib/libpthread/Changes-mysql
deleted file mode 100644
index 032a1fded87..00000000000
--- a/lib/libpthread/Changes-mysql
+++ /dev/null
@@ -1,169 +0,0 @@
-Changes done to this distrubtion (pthreads-1_60_beta6) by Monty (monty@tcx.se)
-
-93.04.01
-- socket() didn't return NOTOK (-1) on error.
-- bind() didn't set error code on failure
-
-93.03.27
-- Added patch by D. Richard Hipp <drh@vnet.net> to make strtod and
- printf (of floats/doubles) thread safe. Patch provided by mevans@cti-ltd.com
-- Added patch I got from lucid@secret.org to fix lock in fork().
-
-93.03.26
-- Fixed some include files for BSD 2.0.
-- Changed the prototype of ioctl() for BSD.
-- Fixed new bug in fd_kernel.c; _fd_kern_read returned sometimes wrong errno.
-
-93.03.22
-- Change sys/cdefs.h to get it through Sun cc.
-- Added patches by Mark Evans
- 1. Crashes and hangs.
- 2. Missing functionality (namely flock())
- 3. Use of POSIX reentrant safe routines.
-
-93.03.21
-- Add patches by Larry V. Streepy to fix pthread_cancel.
- Fixed bug in Streepy's patch that checked return values of read,write..
- in fd.c (Already done in fd_sys.c)
-
-1. Added a declaration of &#34;signal&#34; to include/signal.h
-2. Modified PANIC macro to operate like assert and call a new function
- panic_kernel. Added new file pthreads/panic.c.
-3. Added support for fstatfs syscall for linux (mod to
- syscall-i386-linux-1.0.S).
-4. Added missing function declarations to machdep/linux-1.0/socket.h:
- getsockopt
- setsockopt
- getsockname
- getpeername
- send
- recv
- sendto
- recvfrom
- sendmsg
- recvmsg
- shutdown
-5. Added ifdef to avoid type conflict in machdep/linux-1.0/timers.h
-6. Fix bug in getprotoent (bogus semi-colon after if stmt).
-7. Change function name in proto_internal.c from _proto_init to
- _proto_buf.
-8. Fix bug in res_internal.c where buffer pointer was improperly
- maintained.
-9. Fix return value handling for POSIX function implementations.
-10. Fix bug in select handling where a thread could be incorrectly
- resumed with no sockets ready. Also added proper handling of
- selecting for exceptions (this was not implemented at all).
-11. Added deadlock detection to pthread_join (it can now return an
- EDEADLK error).
-12. Added support for pthread_cancel, changes to lots of files for this.
-13. Add new function __pthread_is_valid that searches the pthread list
- for a specified pthread_t value.
-
-93.03.22
-- Fixed some if the tests according to the below changes.
-
-93.03.21 by "Mati Sauks" <mati@psti.com>
-- Fixed bug if priority queue was empty or (*current)->next is empty.
-
-96.03.20 by Josip Gracin
-- Fixed gethostbyname to handle alias
-
-97.02.07
-- Removed CVS directories.
-- Commented make install in GNUmakefile.in.
-
-97.01.26 by David (david@detron.se)
-- Fixed a dist target in the GNUmakefile
-- Added #undef PTHREAD_STACK_MIN to avoid warning on solaris 2.5
-
-97.01.21 by Monty (monty@tcx.se)
-
-- Added file mysql-TODO and the patches directory.
-- Added patch p153 and p155 by Tim Hinderliter and Chris Colohan
- check the patches directory for more info.
-- Changed pthread_cond_timedwait to return ETIME instead of ETIMEDOUT
- (Required by Posix)
-- Changed the include file pthread.h to add prototypes for the following
- functions: pthread_sigmask, sigwait and sigsetwait
-- Added shutdown() and getpeername() prototypes to 'machdep/sunos-5.3/socket.h'
-- Changed __FD_NONBLOCK to (O_NONBLOCK | O_NDELAY) in
- ./machdep/engine-sparc-sunos-5.3.h
-- Added rint() prototype to math.h
-- Added new slot sighandled to 'struct pthread' for easy check if somebody
- interrupts a system call.
-- pthread_kill can now interrupt the following system calls:
- select(), read(), write(), send(), sendto(), sendmsg(), recv_timedwait(),
- recvfrom_timedwait(), readev(), writeev() and some socket functions.
-- Fixed bug in pthread_kill() which count up 'sigcount' wrongly.
- Two pthread_kill() in a row bugged the thread.
-- Merged fd_kern_wait and fd_kern_poll to 1 function and removed a
- a bug when polling select.
-- Implemented getpeername().
-- Some small optimizations.
-- Some re-indentation to make the code readable by me (Sorry about that).
-
-97.08.15 by Monty (monty@tcx.se)
-
-- Added patch by "Chris G. Demetriou" <cgd@pa.dec.com> for NetBSD/alpha.
-
-97.08.18 by Monty (monty@tcx.se)
-
-- Added new machdep definitions for HPUX-10.20,
- by JOERG_HENNE@Non-HP-Germany-om88.om.hp.com
-
-97.09.25 by Monty (monty@tcx.se)
-
-- Added some definitions for i386-SCO from the site:
- http://www.sco.com/skunkware/osr5/libraries/
-
-97.10.12 by Monty (monty@tcx.se)
-
-- Changed prototype macro __P to __P_ to avoid warnings on Solaris.
-- Fixed interruption of select() with pthread_kill() when signal handler
- used read or write.
-
-97.10.16 by Monty (monty@tcx.se)
-
-- Fixed that blocked signals doesn't interrupt threads.
-
-97.10.20 by Monty (monty@tcx.se)
-
-- Fixed broken ftruncate system call for FreeBSD 2.0
- The old one destroyed the orignal file by truncation too much.
-- Fixed prototypes for des_setkey,encrypt and setkey (according to Solaris 2.5)
-
-97.11.26 by Monty (monty@tcx.se)
-
-- Small patch to avoid compile errors on alpha-OSF1 3.2
-
-97.12.18 by Monty (monty@tcx.se)
-
-- Added fix for Irix 5.3 in __unistd.h
-
-98.01.13 by Monty (monty@tcx.se)
-- Added fd_check_entry to dup2 and table sizecheck to fd_check_entry()
- patch by Martin Fuchs <Martin@igdv.fh-darmstadt.de>
-
-98.01.18 by Monty (monty@tcx.se)
-- Added prototype for gettimeofday() for Solars 2.3
-- Added some small fixes for configure and Solaris 2.6
-
-98.01.23 by Monty (monty@tcx.se)
-- Ported to openbsd.
-- Renamed nanosleep() to pthread_nanosleep() to avoid name conflict on
- openbsd.
-- Fixed link problem with variable __sglue for Irix 5.3
- by Vladislav Malyshkin <malyshki@cs.wmich.edu>.
-
-98.03.02 by Monty (monty@tcx.se)
-- Applied patches from Curt Sampson <cjs@portal.ca>; NetBSD 1.3/i386 port.
-
-98.03.09 by Monty (monty@tcx.se)
-- Applied patches from Curt Sampson <cjs@portal.ca>; NetBSD 1.3/Alpha port.
-
-98.05.12
-- Added unixware to config.guess
-
-98.06.07
-- Added patch by Scott Dybiec <sdybiec@humanfactor.com>:
- Fixed select() returning incorrect number of active file descriptors.
diff --git a/lib/libpthread/FAQ b/lib/libpthread/FAQ
deleted file mode 100644
index e4fd3cfc6d8..00000000000
--- a/lib/libpthread/FAQ
+++ /dev/null
@@ -1,122 +0,0 @@
-
- Answers to frequently asked questions
- for my implementation of POSIX threads
-
--------------------------------------------------------------------------------
-1. Pthreads
-
-(1.0) What is Pthreads?
-(1.1) Where can I get info on Pthreads?
-
-2. Getting, Building, Installing and Using proven's Pthreads
-
-(2.0) Where can I get the latest version of proven's Pthreads?
-(2.1) What platforms does proven's Pthreads run on?
-(2.2) What do I need to build proven's Pthreads?
-(2.3) How do I install proven's Pthreads?
-
-3. Known Problems
-
-(3.0) Tests
-(3.1) Installation
-(3.2) Missing functionality
-(3.3) Signals
-
--------------------------------------------------------------------------------
-1. Pthreads
-
-(1.0) What is Pthreads?
-
-Pthreads stands for POSIX threads and is based on the POSIX 1003.1c 1995
-thread standard. This standard passed international Standards Organization
-(ISO) Committee Document (CD) balloting in February 1995 and got the
-IEEE Standards Board approval in June 1995.
-
-
-(1.1) Where can I get info on Pthreads?
-
-You can call IEEE (908) 562-3800 which is the organization which POSIX
-belongs, and ask for POSIX 1003.1c (not 1003.4a) draft 10 (the standard
-won't be out until sometime in 1996). The draft costs $30.00 plus shipping
-which for me was $4.00. The IEEE doesn't make any of the standards available
-online.
-
-I have made documentation for some of the functions available online.
-To reference these use http://www.mit.edu:8001/people/proven/pthreads.html
-
--------------------------------------------------------------------------------
-2. Getting, Building, Installing and Using proven's Pthreads
-
-(2.0) Where can I get the latest version of proven's Pthreads?
-
-The latest version is pthreads-1_60_beta6 was release on November 16, 1996
-and is available from sipb.mit.edu:/pub/pthreads.
-
-
-(2.1) What platforms does proven's Pthreads run on?
-
-Lot's! It should run on the following platforms; the i386 processor
-running NetBSD-1.x, FreeBSD-2.x, BSDOS-2.0, Linux-1.2 and Linux-1.3;
-the r2000 (DECstation) running Ultrix-4.2; the Sparc running NetBSD-1.x,
-SunOS-4.1.3, Solaris-2.3, and Solaris-2.4; the alpha running OSF-2.3 and
-OSF-3.x; the SGI running IRIX-5.2; and the HPPA running HP/UX-9.x.
-
-Because it runs on so many platforms I don't get to compile and test every
-platform for every release. If you have a problem send mail to
-pthreads-bugs@mit.edu with the processor, OS, and version number along with
-a description of the bug.
-
-
-(2.2) What do I need to build proven's Pthreads?
-
-You will need gcc and gmake to build for all but NetBSD, FreeBSD and BSDOS.
-For those you may use either gmake or pmake (the native make).
-
-
-(2.3) How do I install proven's Pthreads?
-
-Installing pthreads is real easy. At the top level of pthreads do
-
-configure
-make
-make install
-
-It will be installed into the directory /usr/local/pthreads. If you don't
-like the location add a --prefix=<dir> option to configure. That's it.
-
-
--------------------------------------------------------------------------------
-3. Known problems.
-
-(3.0) Tests
-
-Under SunOS-4.1.x there is a bug in the kernel that prevents test_sock_1
-from passing. This bug has to do with a process tring to connect to itself.
-In respose I wrote test_sock_2 to test the socket code for SunOS which
-does work. You should have no problems using the socket code in SunOS
-so long as you don't write a program that need to connect to itself.
-
-
-(3.1) Installation
-
-The only know problem is on the SGI. You will need to use GNU tar instead
-of the native supplied one or edit the config.flags file and remove the -h
-option to tar. Aparently the -h option on IRIX 5.3 version of tar does the
-exact opposite of all the other versions of tar I've used and instead of
-following symbolic links and getting the file it archives the link.
-
-
-(3.2) Missing functionality
-
-The current release is missing cancelation, priority mutexes and others.
-I'm continuing to develope pthreads and I plan to put cancelation and
-priority mutexes and as much other stuff as I can into the 1_70 release
-
-
-(3.3) Signals
-
-Currently to intermix signals with pthreads you need to rename all calls
-to signal() and sigaction() to pthread_signal() and pthread_sigaction().
-I plan to write real wrapper routines for signal() and sigaction() for
-the 1_70 release.
-
diff --git a/lib/libpthread/Makefile b/lib/libpthread/Makefile
deleted file mode 100644
index 7946b27ac32..00000000000
--- a/lib/libpthread/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-# Generated automatically from Makefile.in by configure.
-# @(#)Makefile 5.2 (Berkeley) 3/5/91
-#
-
-.include <bsd.own.mk>
-
-LIB=pthread
-NOPIC=no
-CFLAGS+=-DPTHREAD_KERNEL -I. -I${.CURDIR}/include -I${.CURDIR}/arch/${MACHINE_ARCH}
-
-.include "${.CURDIR}/include/Makefile.inc"
-.include "${.CURDIR}/arch/${MACHINE}/Makefile.inc"
-.include "${.CURDIR}/pthreads/Makefile.inc"
-.include "${.CURDIR}/stdlib/Makefile.inc"
-.include "${.CURDIR}/stdio/Makefile.inc"
-.include "${.CURDIR}/string/Makefile.inc"
-.include "${.CURDIR}/gen/Makefile.inc"
-.include "${.CURDIR}/net/Makefile.inc"
-
-.include <bsd.lib.mk>
diff --git a/lib/libpthread/NOTES b/lib/libpthread/NOTES
deleted file mode 100644
index cebdc6a396c..00000000000
--- a/lib/libpthread/NOTES
+++ /dev/null
@@ -1,59 +0,0 @@
-
-Here are some notes on the internals of the implementation.
-
-LIBC routines.
-
- Unfortuanately many of the libc routine return a pointer to static data.
-There are two methods to deal with this. One write a new routine where the
-arguments are different, and have one argument be a pointer to some space
-to store the data, or two use thread specific data and warn the user that
-data isn't valid if the calling thread is terminated.
-
-INTERNAL LOCKING
-To prevent deadlocks the following rules were used for locks.
-
-1. Local locks for mutex queues and other like things are only locked
- by running threads, at NO time will a local lock be held by
- a thread in a non running state.
-2. Only threads that are in a run state can attempt to lock another thread,
- this way, we can assume that the lock will be released shortly, and don't
- have to unlock the local lock.
-3. The only time a thread will have a pthread->lock and is not in a run
- state is when it is in the reschedule routine.
-4. The reschedule routine assumes all local locks have been released,
- there is a lock on the currently running thread (pthread_run),
- and that this thread is being rescheduled to a non running state.
- It is safe to unlock the currently running threads lock after it
- has been rescheduled.
-5. The reschedule routine locks the kernel, sets the state of the currently
- running thread, unlocks the currently running thread, calls the
- context switch routines.
-6 the kernel lock is used only ...
-
-
-7. The order of locking is ...
-
-1 local locks
-2 pthread->lock /* Assumes it will get it soon */
-3 pthread_run->lock /* Assumes it will get it soon, but must release 2 */
-4 kernel lock /* Currently assumes it will ALWAYS get it. */
-
-8. The kernel lock will be changed to a spin lock for systems that
-already support kernel threads, this way we can mutiplex threads onto
-kernel threads.
-9. There are points where the kernel is locked and it needs to get
-either a local lock or a pthread lock, if at these points the code
-fails to get the lock the kernel gives up and sets a flag which will
-be checked at a later point.
-10. Interrupts are dissabled while the kernel is locked, the interrupt
-mask must be checked afterwards or cleared in some way, after interrputs
-have been reenabled, this allows back to back interrupts, but should always
-avoid missing one.
-
-------------------------------------------------------------------------------
-Copyright (c) 1994 Chris Provenzano. All rights reserved.
-This product includes software developed by the Univeristy of California,
-Berkeley and its contributors.
-
-For further licencing and distribution restrictions see the file COPYRIGHT
-included in this directory.
diff --git a/lib/libpthread/NOTES_OSR5_BUILD_SKUNKWARE97 b/lib/libpthread/NOTES_OSR5_BUILD_SKUNKWARE97
deleted file mode 100644
index fd2e00c9860..00000000000
--- a/lib/libpthread/NOTES_OSR5_BUILD_SKUNKWARE97
+++ /dev/null
@@ -1,45 +0,0 @@
-This port to Osr5 was donated by
- ARTURO MONTES mitosys@colomsat.net.co
-Its a snapshot of the 1.60 Beta 5 version
-
-It passes all the tests except test_fork (this seems to be a problem
-with the MIT source)
-and I suspect there may also to be problems with
-the floating point initialisation and perhaps the netdb access as well
-
-
-Regarding the networking API's mind the following (ARTURO):
-
-- Always we are searching host address in /etc/hosts by default, if you
-want other behaviour let me to know.
-
-- If you haven't an entry in /etc/hosts, please create it and after test
-with DNS service.
-
-regarding floating point initialisation (ARTURO)
-
-...mit-pthreads/pthreads/tests> ./test_preemption_float
-test_preemption_float INDETERMINATE
-
-I inhibit the pthread float code, but they are a minor changes in machdep.c.
-
-> What did you do/needs to be done here ??
-
-Look into machdep.c machdep_save_float_state() and
-machdep_restore_float_state() routine. I think the initialization float
-code can have problems with pthread initialization code.
-
-----------------
-
-
-If you wish to rebuild from source you'll need the gnus devsys
-(gmake and gcc) and don't use configure to reconfigure the makefiles, etc
- ( I don't know why this is but it doesn't work)
-
-If Arturo keeps me updated with buildable snapshots I'll endeavour to keep
-the skunkware Website updated with them.
-
-
-Best of luck
-
-hops 01-Aug-97
diff --git a/lib/libpthread/README b/lib/libpthread/README
deleted file mode 100644
index f546325d948..00000000000
--- a/lib/libpthread/README
+++ /dev/null
@@ -1,85 +0,0 @@
-This pthread package is/will be based on the POSIX1003.4a Draft 7 pthread
-standard, and Frank Mullers paper on signal handelling presented
-at the Winter 93 USENIX conference.
-
-It is currently being designed and written by me, Chris Provenzano.
-All bug, comments, and questions can be sent me at either
-proven@athena.mit.edu or proven@sun-lamp.cs.berkeley.edu
-PLEASE, don't send questions, bugs or patches to any of the *BSD* mailing lists.
-
-Thanks goes to John Carr jfc@mit.edu for porting this to the IBM/RT,
-and for his bug reports and fixes, Greg Hudson and Mark Eichin for the
-testing they've done, and all the others.
-
-PORTING
-One of the goals of this user space implementation of pthreads is that it
-be portable. I have minimized the ammount of assembler code necessary,
-but some is.
-
-If you want to port it to another platform here are a few basic hints.
-
-There are currently three files you'll have to creat for your
-architecture, machdep.h, machdep.c and syscall.S.
-The first two are necessary to get the context switch section of
-the pthread package running, the third is for all the syscalls.
-
-To do an initial port, create an appropriate machdep.h, and machdep.c
-and define PTHREAD_INITIAL_PORT in the Makefile
-
-Comment out references to the stdio package.
-
-INCLUDE FILES AND PORTING
-To continue to make this package portable, some basic rules on includes
-files must be followed.
-
-pthread.h should be included first (if it is to be included).
-machdep.h should define size_t if the system doesn't define it already
-
-posix.h should be included last. This file is used to correct non
-POSIX features, after everything else has been defined.
-
-INTERNAL LOCKING
-To prevent deadlocks the following rules were used for locks.
-
-1. Local locks for mutex queues and other like things are only locked
- by running threads, at NO time will a local lock be held by
- a thread in a non running state.
-2. Only threads that are in a run state can attempt to lock another thread,
- this way, we can assume that the lock will be released shortly, and don't
- have to unlock the local lock.
-3. The only time a thread will have a pthread->lock and is not in a run
- state is when it is in the reschedule routine.
-4. The reschedule routine assumes all local locks have been released,
- there is a lock on the currently running thread (pthread_run),
- and that this thread is being rescheduled to a non running state.
- It is safe to unlock the currently running threads lock after it
- has been rescheduled.
-5. The reschedule routine locks the kernel, sets the state of the currently
- running thread, unlocks the currently running thread, calls the
- context switch routines.
-6 the kernel lock is used only ...
-
-
-7. The order of locking is ...
-
-1 local locks
-2 pthread->lock /* Assumes it will get it soon */
-3 pthread_run->lock /* Assumes it will get it soon, but must release 2 */
-4 kernel lock /* Currently assumes it will ALWAYS get it. */
-
-8. The kernel lock will be changed to a spin lock for systems that
-already support kernel threads, this way we can mutiplex threads onto
-kernel threads.
-9. There are points where the kernel is locked and it needs to get
-either a local lock or a pthread lock, if at these points the code
-fails to get the lock the kernel gives up and sets a flag which will
-be checked at a later point.
-10. Interrupts are dissabled while the kernel is locked, the interrupt
-mask must be checked afterwards or cleared in some way, after interrputs
-have been reenabled, this allows back to back interrupts, but should always
-avoid missing one.
-
-Copyright (c) 1993 Chris Provenzano. All rights reserved.
-
-This product includes software developed by the Univeristy of California,
-Berkeley and its contributors.
diff --git a/lib/libpthread/TODO-mysql b/lib/libpthread/TODO-mysql
deleted file mode 100644
index a19b1bd51d6..00000000000
--- a/lib/libpthread/TODO-mysql
+++ /dev/null
@@ -1,4 +0,0 @@
-This what should be done to get more functionally for mysqld.
-
-- open should be interruptable.
-- fcntl lock should be interruptable.
diff --git a/lib/libpthread/Whats_New b/lib/libpthread/Whats_New
deleted file mode 100644
index 556d9f63268..00000000000
--- a/lib/libpthread/Whats_New
+++ /dev/null
@@ -1,198 +0,0 @@
-For patches made to this release, check the file Changes-mysql
-
-For the 96/11/11 release version 1_60_beta6
-
- Ports
- Alpha running NetBSD-1.1 by Chris G Demetriou <cgd+@cs.cmu.edu>
- i386 running BSDi-2.1 by David J MacKenzie <djm@va.pubnix.com>
-
- Bug Fixes
- Test for struct timespec under linux and DTRT.
- include/unistd.h : #define SEEK_SET, SEEK_CUR, and SEEK_END.
- Bug reported by Stephen Tether <tether@MITLNS.MIT.EDU>
- stdlib/system.c : Uses the POSIX signal systemcalls.
- Bug reported by Matthew Newhook <matthew@thor.udc.neweast.ca>.
- net/gethostbyname.c: #include <string.h> and fix dereference problem.
- Bug reported by Chris G Demetriou <cgd+@cs.cmu.edu>
- pthreads/fd.c: Fix bug in close() reported by
- Bug reported by "William S. Lear" <rael@dejanews.com>
- tests/p_bench_pthread_create.c : Only try and create 10000 threads.
- include/pthread/sleep.h : No need to prototype machdep_gettimeofday()
- since it is declared here.
- Bug reported by Stewart Gebbie <stewart@global.co.za>
- stdio/fwrite.c: Fixed bug where if total bytes written = 0 then a divid
- by 0 occurs. Thanks to CTLarsen@lbl.gov for finding is and to
- Jin Guojun <jin@george.lbl.gov> for submitting a patch for it.
- stdio/refill.c (__swalk_lflush()): Second pass of flush should call
- flockfile() not ftrylockfile(). Just like in __swalk_sflush()
- net/res_internal.c (_res_parse_answer()): It looks like if
- iquery is true and type == T_PTR then the result->h_name
- will be over written because the bp isn't incrementd
- appropriately. Thanks to David Halls <David.Halls@cl.cam.ac.uk>
- for finding it.
- net/serv_internal.c (_serv_buf()) : Allocate more than four bytes
- of buffer space. Reported by drh@@tobit.vnet.net.
- pthreads/fd_kern.c: Make sure exception fds are included in
- machdep_sys_select() for support of select(). Thanks to
- Larry V. Streepy, Jr. <streepy@healthcare.com> for the patches.
- pthreads/fd_kern.c: Fix more I/O routines to report NOTOK on error
- instead of the old -error number. Hopefully this is the last of
- them. Thanks to Larry V. Streepy, Jr. <streepy@healthcare.com> for
- the patches.
- machdep/engine-i386-linux-1.0.c: Remove unneeded machdep_sys_readv()
- and machdep_sys_writev() routines. Reported by
- pthreads/process.c : Fix execl() and execle() to work on sparc systems.
- pthreads/fd_sysv.c : Fix accept() to work under Solaris 2.4
-
-
-For the 96/03/09 release version 1_60_beta5
-
- Ports
- Sparc running NetBSD-1.1
-
- Additions
- New reentrant netdb similar to Solaris API (ghudson)
-
- Bug Fixes
- Make default signal handlers work.
- Deadlock scheduling bug reported by Cathy Abbott <cabbot@cs.utk.edu>
- See pthreads-bugs transaction 31
- pthread/queue.c (pthread_queue_remove()): Don't set thread->queue and
- thread->next to NULL unless the thread is removed from the queue.
- pthreads/fd.c (setsockopt(), getsockopt(), getsockname(),
- getpeername()) : Call fd_lock() with appropriate paramaters.
- pthreads/fd_kern.c (sendmsg_timedwait()): Call fd_unlock() with
- FD_WRITE instead of FD_READ paramater.
- machdep/*/timers.h net/res_send.c, pthreads/cond.c, pthreads/select.c
- pthreads/sleep.c, tests/test_pthread_cond_timedwait.c:
- Change timespec to be POSIX compliant.
- include/unistd.h : Change u_int to unsigned [int] in prototypes.
- pthreads/fd.c : Use FD_SETSIZE instead of 1024 for a limit on fds.
-
-
-For the 95/09/xx release version 1_60_beta4
-
- Ports
- SGI running IRIX-5.3
-
- Additions
- Added pthread_sigprocmask().
- Added CV attributes
-
- strtok() and strtok_r() (Greg Hudson)
- getsockname() (Sean Levy)
-
- Bug Fixes
- stdio/fwalk.c, stdio/refill.c : Use flockfile() instead of
- ftrylockfile()/pthread_yield(), for traversing FILE list.
- pthreads/sig.c : Remove enum pthread_sig_flags and just use the vector.
- Added pthread_sigprocmask().
- pthreads/signal.c : Protect calls to pthread_sig_process().
- configure : Create the obj directory.
- tests/test_preemption_float.c : Rewritten to actually work.
- machdep/engine-i386-linux-1.0.c : Added __strtol_internal()
- tests/test_stdio_1.c : Don't use base_name or dir_name as variables.
- gen/getcwd.c : fstat => machdep_sys_fstat, since kernel fd's are
- used in the DIR data structure
- gen/isatty.c : Fixed call to fd_lock() to pass the right # args.
- pthreads/pthread_init.c : Fixed uninitialized members of
- pthread_initial.
-
-
-
-For the 95/06/xx release version 1_60_beta3
-
- Additions
- Add exec variants execl, execlp, execv, execvp (Ken Raeburn)
- pthreads/fd_sysv.c : Added routines setsockopt() and getsockname().
- Added include/endian.h : For machine dependent endian junk. (YUCK)
- Added socketpair()
- Added ttyname_r()
-
- Bug Fixes
- config/Makefile.in : Need $$ to reference shell variables in make.
- config/configure, config/configure.in : Redo freebsd2.* machine.
- machdep/sunos-4.1.3/__stdlib.h : typedef pthread_size_t size_t
- pthreads/fd.c : Fix bug with fd_free(), dup(), dup2(), and close()
- where a fd gets lost after a dup() then close().
- pthreads/fd_kern.c : The fd_table[fd]->flags of the fd that accept()
- returns should be the same as those of the fd passed to accept().
- stdio/fclose.c : Don't call funlockfile(fp) after fp->_file has been
- closed.
- pthreads/select.c : Move pthread_sched_prevent() inside the statement.
- if (machdep_sys_select(...) == OK)
- pthreads/machdep/linux-1.0/cdefs.h : moved the include_next outside
- of the ifdef so that it would eventually find the system cdefs.h
- pthreads/signal.c : Check sig_to_process before and after fd_kern_wait()
- . It is possible for sig_handler_fake() to registered one.
- pthreads/signal.c : Unset pthread_run temporarily around the call to
- sig_handler(0). places where this causes core dumps should check
- pthread_run.
- include/stdlib.h : Fix prototype for bsearch().
- machdep/syscall-i386-freebsd-2.0.S syscall-template-i386-freebsd2.0.S:
- Fix macro expansion problems for FreeBSD-2.0
- machdep/engine-sparc-sunos-5.3.c : Fix machdep_sys_select() to return
- machdep_sys_poll() errors and not the number of entries found.
- gen/getcwd.c : Use strlen(dp->d_name) not dp->d_namlen because there
- may be extra data associated with dp->d_namelen.
- machdep/freebsd-2.0/__unistd.h: Change #define _POSIX_VDISABLE to 0xff
- include/pthread.h : Added prototypes pthread_kill(), pthread_signal()
- machdep/linux-1.0/__signal.h : Added #define __sigmask() and
- #define sigmask, and fixed other SIG macros to use __sigmask.
- machdep/linux-1.0/dirent.h : #include <sys/types.h>
- machdep/linux-1.0/wait.h : Fix #define WIFSTOPPED(x) to use __WSTATUS(x)
- machdep/syscall-i386-linux-1.0.S : Added elf support. (NOT TESTED)
- pthreads/stat.c : Added to separate linux stat calls.
- (SGI will need this too)
- pthreads/signal.c : Whereever #ifdef (SA_RESETHAND) is used then
- #ifdef (SA_RESTART) also
- gen/isatty.c : isatty_basic() is called with the KFD not UFD.
- machdep/sunos-4.1.3/__stdlib.h : #include <sys/stdtypes.h>
- config/sun4os4.mk : Added pipe to SYSCALL_EXCEPTIONS
- machdep/syscall-sparc-sunos-4.1.3.S : Add machdep_sys_pipe().
- include/stdio.h : Remove __getc() and __putc(), because they really
- shouldn't be inlined.
- machdep/sunos-4.1.3/stat.h : Added __BEGIN_DECLS and __END_DECLS.
- machdep/alpha-osf1/cdefs.h, machdep/hpux-9.03/cdefs.h
- machdep/linux-1.0/cdefs.h, machdep/sunos-4.1.3/cdefs.h
- machdep/sunos-5.3/cdefs.h, machdep/ultrix-4.2/cdefs.h :
- #define __INLINE static inline and don't #define
- __CAN_DO_EXTERN_INLINE if __cplusplus and __GCC__ is defined.
- pthreads/fd_sysv.c : Fix so that only systems without socket systemcalls
- compile this file.
- machdep/engine-i386-linux-1.0.c : Fix linux machdep_sys_getdirentries()
- pthreads/gen : Nuke the signal-blocking code in pclose(). It doesn't do
- any good in a threaded program; some other thread would just get
- the signal.
-
-
-For the 94/11/xx release version 1_60
-
- Additions
- Added recvfrom_timedwait(), and similar calls
- Added thread safe time routines: ctime(), localtime(), ...
- Added thread safe rand routines: rand(), random(), ...
- Added priorities and releated routines: pthread_attr_getschedparam(),
- Added signals and releated routines:pthread_kill(), sigwait(), ...
- Added mutex attribues and releated routines: pthread_mutexattr_init(), .
- Added abort
-
- Added counting (recursive) mutexes.
- Added debugging mutexes.
- Added some more tests
-
- Redid entire thread kernel because of priorities, and signals.
- Test and set instructions no longer necessary for versions
- that don't support kernel threads.
-
- More debugging by Greg Hudson along with the network lookup routines
- An Alpha port from Ken Raeburn and Sean Levy
- A solaris port from me.
- select() implementations from Sean Levy and Peter Hofmann
- configure from Ken Raeburn
- pthread_init() no longer necessary for systems with G++ from Ken Raeburn
- net code from Greg Hudson including: gethostbyname(), ...
-
- Bug fixes:
- honor _POSIX_THREAD_DESTRUCTOR_ITERATIONS
- pthread_key_destroy() is really pthread_key_delete()
diff --git a/lib/libpthread/arch/alpha/machdep.c b/lib/libpthread/arch/alpha/machdep.c
deleted file mode 100644
index 0932c421ea2..00000000000
--- a/lib/libpthread/arch/alpha/machdep.c
+++ /dev/null
@@ -1,204 +0,0 @@
-/* ==== machdep.c ============================================================
- * Copyright (c) 1993, 1994 Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Machine dependent functions for NetBSD/Alpha 1.1(+)
- *
- * 1.00 93/08/04 proven
- * -Started coding this file.
- *
- * 95/04/22 cgd
- * -Modified to make it go with NetBSD/Alpha
- */
-
-#ifndef lint
-static const char rcsid[] = "engine-alpha-osf1.c,v 1.4.4.1 1995/12/13 05:41:37 proven Exp";
-#endif
-
-#include <pthread.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/syscall.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <stdio.h>
-
-/* ==========================================================================
- * machdep_save_state()
- */
-int machdep_save_state(void)
-{
- return __machdep_save_int_state(pthread_run->machdep_data.machdep_istate);
-}
-
-void machdep_restore_state(void)
-{
- __machdep_restore_int_state(pthread_run->machdep_data.machdep_istate);
-}
-
-void machdep_save_float_state (void)
-{
- __machdep_save_fp_state(pthread_run->machdep_data.machdep_fstate);
-}
-
-void machdep_restore_float_state (void)
-{
- __machdep_restore_fp_state(pthread_run->machdep_data.machdep_fstate);
-}
-
-/* ==========================================================================
- * machdep_set_thread_timer()
- */
-void machdep_set_thread_timer(struct machdep_pthread *machdep_pthread)
-{
- if (setitimer(ITIMER_VIRTUAL, &(machdep_pthread->machdep_timer), NULL)) {
- PANIC();
- }
-}
-
-/* ==========================================================================
- * machdep_unset_thread_timer()
- */
-void machdep_unset_thread_timer(struct machdep_pthread *machdep_pthread)
-{
- struct itimerval zeroval = { { 0, 0 }, { 0, 0} };
-
- if (setitimer(ITIMER_VIRTUAL, &zeroval, NULL)) {
- PANIC();
- }
-}
-
-/* ==========================================================================
- * machdep_pthread_cleanup()
- */
-void *machdep_pthread_cleanup(struct machdep_pthread *machdep_pthread)
-{
- return(machdep_pthread->machdep_stack);
-}
-
-/* ==========================================================================
- * machdep_pthread_start()
- */
-void machdep_pthread_start(void)
-{
- context_switch_done();
- pthread_sched_resume ();
-
- /* Run current threads start routine with argument */
- pthread_exit(pthread_run->machdep_data.start_routine
- (pthread_run->machdep_data.start_argument));
-
- /* should never reach here */
- PANIC();
-}
-
-/* ==========================================================================
- * __machdep_stack_free()
- */
-void __machdep_stack_free(void * stack)
-{
- free(stack);
-}
-
-/* ==========================================================================
- * __machdep_stack_alloc()
- */
-void * __machdep_stack_alloc(size_t size)
-{
- void * stack;
-
- return(malloc(size));
-}
-
-/* ==========================================================================
- * __machdep_pthread_create()
- */
-void __machdep_pthread_create(struct machdep_pthread *machdep_pthread,
- void *(* start_routine)(), void *start_argument,
- long stack_size, long nsec, long flags)
-{
- machdep_pthread->start_routine = start_routine;
- machdep_pthread->start_argument = start_argument;
-
- machdep_pthread->machdep_timer.it_value.tv_sec = 0;
- machdep_pthread->machdep_timer.it_interval.tv_sec = 0;
- machdep_pthread->machdep_timer.it_interval.tv_usec = 0;
- machdep_pthread->machdep_timer.it_value.tv_usec = nsec / 1000;
-
- /* Set up new stack frame so that it looks like it returned from a
- longjmp() to the beginning of machdep_pthread_start(). */
- machdep_pthread->machdep_istate[8/*ISTATE_RA*/] = 0;
- machdep_pthread->machdep_istate[0/*ISTATE_PC*/] = (long)machdep_pthread_start;
- machdep_pthread->machdep_istate[10/*ISTATE_PV*/] = (long)machdep_pthread_start;
-
- /* Alpha stack starts high and builds down. */
- {
- long stk_addr = (long) machdep_pthread->machdep_stack;
- stk_addr += stack_size - 1024;
- stk_addr &= ~15;
- machdep_pthread->machdep_istate[9/*ISTATE_SP*/] = stk_addr;
- }
-}
-
-int safe_store (loc, new)
- int *loc;
- int new;
-{
- int locked, old;
- asm ("mb" : : : "memory");
- do {
- asm ("ldl_l %0,%1" : "=r" (old) : "m" (*loc));
- asm ("stl_c %0,%1" : "=r" (locked), "=m" (*loc) : "0" (new));
- } while (!locked);
- asm ("mb" : : : "memory");
- return old;
-}
-
-/* ==========================================================================
- * machdep_sys_creat()
- */
-machdep_sys_creat(char * path, int mode)
-{
- return(machdep_sys_open(path, O_WRONLY | O_CREAT | O_TRUNC, mode));
-}
-
-/* ==========================================================================
- * machdep_sys_wait3()
- */
-machdep_sys_wait3(int * b, int c, int * d)
-{
- return(machdep_sys_wait4(0, b, c, d));
-}
-
-/* ==========================================================================
- * machdep_sys_waitpid()
- */
-machdep_sys_waitpid(int a, int * b, int c)
-{
- return(machdep_sys_wait4(a, b, c, NULL));
-}
-
-/* ==========================================================================
- * machdep_sys_getdtablesize()
- */
-machdep_sys_getdtablesize()
-{
- return(sysconf(_SC_OPEN_MAX));
-}
-
-/* ==========================================================================
- * machdep_sys_lseek()
- */
-off_t machdep_sys_lseek(int fd, off_t offset, int whence)
-{
- extern off_t __syscall();
-
- return(__syscall((quad_t)SYS_lseek, fd, 0, offset, whence));
-}
-
-/* ==========================================================================
- * machdep_sys_getdirentries()
- */
-machdep_sys_getdirentries(int fd, char * buf, int len, int * seek)
-{
- return(machdep_sys_getdents(fd, buf, len));
-}
diff --git a/lib/libpthread/arch/alpha/machdep.h b/lib/libpthread/arch/alpha/machdep.h
deleted file mode 100644
index 50c872da7b6..00000000000
--- a/lib/libpthread/arch/alpha/machdep.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/* ==== machdep.h ============================================================
- * Copyright (c) 1994 Chris Provenzano (proven@athena.mit.edu) and
- * Ken Raeburn (raeburn@mit.edu).
- *
- * engine-alpha-osf1.h,v 1.4.4.1 1995/12/13 05:41:42 proven Exp
- *
- */
-
-#include <unistd.h>
-#include <setjmp.h>
-#include <sys/time.h>
-#include <sys/cdefs.h>
-
-/* The first machine dependent functions are the SEMAPHORES needing
- the test and set instruction.
-
- On the Alpha, the actual values here are irrelevant; they just have
- to be different. */
-#define SEMAPHORE_CLEAR 0
-#define SEMAPHORE_SET 1
-
-#if 0
-#define SEMAPHORE_TEST_AND_SET(lock) \
-({ int *_sem_lock = (lock), locked, old; \
- asm ("mb" : : : "memory"); \
- do { asm ("ldl_l %0,%1" : "=r" (old) : "m" (*_sem_lock)); \
- /* ?? if (old != SEMAPHORE_CLEAR) break; */ \
- asm ("stl_c %0,%1" : "=r" (locked), "=m" (*_sem_lock) \
- : "0" (SEMAPHORE_SET)); \
- } while (!locked); \
- asm ("mb" : : : "memory"); \
- old == SEMAPHORE_CLEAR; })
-
-#define SEMAPHORE_RESET(lock) \
-({ int *_sem_lock = (lock); \
- *_sem_lock = SEMAPHORE_CLEAR; \
- asm ("mb" : : : "memory"); })
-#endif
-
-/*
- * New types
- */
-typedef int semaphore;
-
-/*
- * sigset_t macros
- */
-#define SIG_ANY(sig) (sig)
-#define SIGMAX 31
-
-/*
- * New Strutures
- */
-struct machdep_pthread {
- void *(*start_routine)(void *);
- void *start_argument;
- void *machdep_stack;
- struct itimerval machdep_timer;
- unsigned long machdep_istate[11];
- unsigned long machdep_fstate[9];
-};
-
-/*
- * Static machdep_pthread initialization values.
- * For initial thread only.
- */
-#define MACHDEP_PTHREAD_INIT \
- { NULL, NULL, NULL, { { 0, 0 }, { 0, 100000 } }, 0 }
-
-/*
- * Minimum stack size
- */
-#define PTHREAD_STACK_MIN 2048
-
-/*
- * Some fd flag defines that are necessary to distinguish between posix
- * behavior and bsd4.3 behavior.
- */
-#define __FD_NONBLOCK O_NONBLOCK
-
-/*
- * New functions
- */
-
-__BEGIN_DECLS
-
-#if defined(PTHREAD_KERNEL)
-
-#define __machdep_stack_get(x) (x)->machdep_stack
-#define __machdep_stack_set(x, y) (x)->machdep_stack = y
-#define __machdep_stack_repl(x, y) \
-{ \
- if (stack = __machdep_stack_get(x)) { \
- __machdep_stack_free(stack); \
- } \
- __machdep_stack_set(x, y); \
-}
-
-void * __machdep_stack_alloc __P_((size_t));
-void __machdep_stack_free __P_((void *));
-
-int machdep_save_state __P_((void));
-
-int __machdep_save_int_state __P_((unsigned long *));
-void __machdep_restore_int_state __P_((unsigned long *));
-void __machdep_save_fp_state __P_((unsigned long *));
-void __machdep_restore_fp_state __P_((unsigned long *));
-
-#endif
-
-__END_DECLS
diff --git a/lib/libpthread/arch/alpha/syscall-template.S b/lib/libpthread/arch/alpha/syscall-template.S
deleted file mode 100644
index a2941ece7c9..00000000000
--- a/lib/libpthread/arch/alpha/syscall-template.S
+++ /dev/null
@@ -1,46 +0,0 @@
-#include <machine/asm.h>
-#define COMPAT_43
-#include <sys/syscall.h>
-#define CHMK() call_pal 0x83
-
-#undef SYSCALL
-
-/* Kernel syscall interface:
- Input:
- v0 - system call number
- a* - arguments, as in C
- Output:
- a3 - zero iff successful
- v0 - errno value on failure, else result
-
- This macro is similar to SYSCALL in asm.h, but not completely.
- There's room for optimization, if we assume this will continue to
- be assembled as one file.
-
- This macro expansions does not include the return instruction.
- If there's no other work to be done, use something like:
- SYSCALL(foo) ; ret
- If there is other work to do (in fork, maybe?), do it after the
- SYSCALL invocation. */
-
-#define SYSCALL(x) \
- .align 4 ;\
- .globl machdep_sys_##x ;\
- .ent machdep_sys_##x, 0 ;\
-machdep_sys_##x: ;\
- .frame sp,0,ra ;\
- ldiq v0, SYS_##x ;\
- CHMK() ;\
- beq a3, Lsys_noerr_##x ;\
- br gp, Lsys_err_##x ;\
-Lsys_err_##x: ;\
- /* Load gp so we can find cerror to jump to. */;\
- ldgp gp, 0(gp) ;\
- jmp zero, machdep_cerror ;\
-Lsys_noerr_##x:
-
-#define SIMPLE_SYSCALL(x) SYSCALL(x) ; ret ; .end machdep_sys_##x
-
-#define XSYSCALL(x) SIMPLE_SYSCALL(x)
-
-XSYSCALL(SYSCALL_NAME)
diff --git a/lib/libpthread/arch/alpha/syscall.S b/lib/libpthread/arch/alpha/syscall.S
deleted file mode 100644
index eda44311281..00000000000
--- a/lib/libpthread/arch/alpha/syscall.S
+++ /dev/null
@@ -1,224 +0,0 @@
-#include <machine/asm.h>
-#define CHMK() call_pal 0x83
-#define COMPAT_43
-#include <sys/syscall.h>
-#ifndef __CONCAT
-#include <sys/cdefs.h>
-#endif
-#define CONCAT __CONCAT
-
-#undef SYSCALL
-
-/* Kernel syscall interface:
- Input:
- v0 - system call number
- a* - arguments, as in C
- Output:
- a3 - zero iff successful
- v0 - errno value on failure, else result
-
- This macro is similar to SYSCALL in asm.h, but not completely.
- There's room for optimization, if we assume this will continue to
- be assembled as one file.
-
- This macro expansions does not include the return instruction.
- If there's no other work to be done, use something like:
- SYSCALL(foo) ; ret
- If there is other work to do (in fork, maybe?), do it after the
- SYSCALL invocation. */
-
-#define SYSCALL(x) \
- .align 4 ;\
- .globl CONCAT(machdep_sys_,x) ;\
- .ent CONCAT(machdep_sys_,x), 0 ;\
-CONCAT(machdep_sys_,x): ;\
- .frame sp,0,ra ;\
- ldiq v0, CONCAT(SYS_,x) ;\
- CHMK() ;\
- beq a3, CONCAT(Lsys_noerr_,x) ;\
- br gp, CONCAT(Lsys_err_,x) ;\
-CONCAT(Lsys_err_,x): ;\
- /* Load gp so we can find cerror to jump to. */;\
- ldgp gp, 0(gp) ;\
- jmp zero, machdep_cerror ;\
-CONCAT(Lsys_noerr_,x):
-
-#define XSYSCALL(x) SYSCALL(x) ; RET ; .end CONCAT(machdep_sys_,x)
-
- .globl machdep_cerror
-machdep_cerror:
- br t0, Lmachdep_cerror_setgp
-Lmachdep_cerror_setgp:
- ldgp gp, 0(t0)
- stl v0, errno
-#if 0
- ldiq v0, -1
-#else
- subq zero, v0, v0
-#endif
- RET
-
-/* The fork system call is special... */
-SYSCALL(fork)
- cmovne a4, 0, v0
- RET
- .end machdep_sys_fork
-
-/* The pipe system call is special... */
-SYSCALL(pipe)
- stl v0, 0(a0)
- stl a4, 4(a0)
- mov zero, v0
- RET
- .end machdep_sys_pipe
-
-/* The sigsuspend system call is special... */
- .align 4
- .globl machdep_sys_sigsuspend
- .ent machdep_sys_sigsuspend, 0
-machdep_sys_sigsuspend:
- ldl a0, 0(a0) /* pass *mask instead of mask */
- ldiq v0, SYS_sigsuspend
- CHMK()
- mov zero, v0 /* shouldn't need; just in case... */
- RET
- .end machdep_sys_sigsuspend
-
-/* The sigprocmask system call is special... */
- .align 4
- .globl machdep_sys_sigprocmask
- .ent machdep_sys_sigprocmask, 0
-machdep_sys_sigprocmask:
- mov a2, a5 /* safe */
- cmoveq a1, 1, a0 /* if set == NULL, how = SIG_BLOCK */
- beq a1, Ldoit /* and set = 0, and do it. */
- ldl a1, 0(a1) /* load the set from *set */
-Ldoit: ldiq v0, SYS_sigprocmask
- CHMK()
- beq a5, Lret /* if they don't want old mask, done */
- stl v0, 0(a5) /* otherwise, give it to them. */
-Lret: mov zero, v0
- RET
- .end machdep_sys_sigprocmask
-
-/* More stuff ... */
- .align 4
- .global __machdep_save_int_state
- .ent __machdep_save_int_state, 0
-__machdep_save_int_state:
- .frame sp, 16, ra
- ldgp gp, 0(t12)
- lda sp, -16(sp)
- stq ra, 0(sp)
-
- /* save integer registers */
- stq ra, ( 0 * 8)(a0) /* return address */
- stq s0, ( 1 * 8)(a0) /* callee-saved registers */
- stq s1, ( 2 * 8)(a0)
- stq s2, ( 3 * 8)(a0)
- stq s3, ( 4 * 8)(a0)
- stq s4, ( 5 * 8)(a0)
- stq s5, ( 6 * 8)(a0)
- stq s6, ( 7 * 8)(a0)
- stq sp, ( 9 * 8)(a0)
- stq ra, ( 8 * 8)(a0) /* RA on return */
- stq pv, (10 * 8)(a0) /* and PV; we restore it */
-
- mov zero, v0
- lda sp, 16(sp)
- RET
- .end __machdep_save_int_state
-
- .align 4
- .global __machdep_restore_int_state
- .ent __machdep_restore_int_state, 0
-__machdep_restore_int_state:
- .frame sp, 16, ra
- ldgp gp, 0(t12)
- lda sp, -16(sp)
- stq ra, 0(sp)
-
- /* restore integer registers */
- ldq t0, ( 0 * 8)(a0) /* return address */
- ldq s0, ( 1 * 8)(a0) /* callee-saved registers */
- ldq s1, ( 2 * 8)(a0)
- ldq s2, ( 3 * 8)(a0)
- ldq s3, ( 4 * 8)(a0)
- ldq s4, ( 5 * 8)(a0)
- ldq s5, ( 6 * 8)(a0)
- ldq s6, ( 7 * 8)(a0)
- ldq ra, ( 8 * 8)(a0) /* RA after return */
- ldq sp, ( 9 * 8)(a0)
- ldq pv, (10 * 8)(a0) /* and PV; we restore it */
-
- ldiq v0, 1
- ret zero,(t0),1
- .end __machdep_restore_int_state
-
- .align 4
- .global __machdep_save_fp_state
- .ent __machdep_save_fp_state, 0
-__machdep_save_fp_state:
- .frame sp, 16, ra
- ldgp gp, 0(t12)
- lda sp, -16(sp)
- stq ra, 0(sp)
-
- /* save FP registers */
- stt fs0, (0 * 8)(a0) /* callee-saved registers */
- stt fs1, (1 * 8)(a0)
- stt fs2, (2 * 8)(a0)
- stt fs3, (3 * 8)(a0)
- stt fs4, (4 * 8)(a0)
- stt fs5, (5 * 8)(a0)
- stt fs6, (6 * 8)(a0)
- stt fs7, (7 * 8)(a0)
- mf_fpcr ft0 /* and FP control reg */
- stt ft0, (8 * 8)(a0)
-
- lda sp, 16(sp)
- RET
- .end __machdep_save_fp_state
-
- .align 4
- .global __machdep_restore_fp_state
- .ent __machdep_restore_fp_state, 0
-__machdep_restore_fp_state:
- .frame sp, 16, ra
- ldgp gp, 0(t12)
- lda sp, -16(sp)
- stq ra, 0(sp)
-
- /* restore FP registers */
- ldt fs0, (0 * 8)(a0) /* callee-saved registers */
- ldt fs1, (1 * 8)(a0)
- ldt fs2, (2 * 8)(a0)
- ldt fs3, (3 * 8)(a0)
- ldt fs4, (4 * 8)(a0)
- ldt fs5, (5 * 8)(a0)
- ldt fs6, (6 * 8)(a0)
- ldt fs7, (7 * 8)(a0)
- ldt ft0, (8 * 8)(a0)
- mt_fpcr ft0 /* and FP control reg */
-
- lda sp, 16(sp)
- RET
- .end __machdep_restore_fp_state
-
-/* For fstat() we actually syscall fstat13. */
- .align 4
- .globl machdep_sys_fstat
- .ent machdep_sys_fstat, 0
-machdep_sys_fstat:
- .frame sp,0,ra
- ldiq v0, SYS___fstat13
- CHMK()
- beq a3, Lsys_noerr_fstat
- br gp, Lsys_err_fstat
-Lsys_err_fstat:
- /* Load gp so we can find cerror to jump to. */
- ldgp gp, 0(gp)
- jmp zero, machdep_cerror
-Lsys_noerr_fstat:
- RET
- .end machdep_sys_fstat
diff --git a/lib/libpthread/arch/i386/Makefile.inc b/lib/libpthread/arch/i386/Makefile.inc
deleted file mode 100644
index 85468b9aa69..00000000000
--- a/lib/libpthread/arch/i386/Makefile.inc
+++ /dev/null
@@ -1,4 +0,0 @@
-# Machine dependent sources
-.PATH: ${.CURDIR}/arch/${MACHINE}
-
-SRCS+= machdep.c syscall.S
diff --git a/lib/libpthread/arch/i386/SYS.h b/lib/libpthread/arch/i386/SYS.h
deleted file mode 100644
index 91431a6f543..00000000000
--- a/lib/libpthread/arch/i386/SYS.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * $OpenBSD: SYS.h,v 1.1 1998/07/23 08:21:43 peter Exp $
- */
-
-#include <machine/asm.h>
-#include <sys/syscall.h>
-
-#ifdef __STDC__
-
-#define SYSCALL(x) .text; .align 2; 2: jmp PIC_PLT(cerror); ENTRY(machdep_sys_ ## x); movl $(SYS_ ## x),%eax; int $0x80; jc 2b
-#define RSYSCALL(x) SYSCALL(x); ret
-#define PSEUDO(x,y) ENTRY(machdep_sys_ ## x); movl $(SYS_ ## y),%eax; int $0x80; ret
-
-#else /* !__STDC__ */
-
-#define SYSCALL(x) .text; .align 2; 2: jmp PIC_PLT(cerror); ENTRY(machdep_sys_/**/x); movl $(SYS_/**/x),%eax; int $0x80; jc 2b
-#define RSYSCALL(x) SYSCALL(x); ret
-#define PSEUDO(x,y) ENTRY(machdep_sys_/**/x); movl $(SYS_/**/y),%eax; int $0x80; ret
-
-#endif
-
- .globl cerror
diff --git a/lib/libpthread/arch/i386/machdep.c b/lib/libpthread/arch/i386/machdep.c
deleted file mode 100644
index 09ff0072fdc..00000000000
--- a/lib/libpthread/arch/i386/machdep.c
+++ /dev/null
@@ -1,215 +0,0 @@
-/* ==== machdep.c ============================================================
- * Copyright (c) 1995 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 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.
- *
- * Description : Machine dependent functions for NetBSD on i386
- *
- * 1.00 93/08/04 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "engine-i386-freebsd-2.0.c,v 1.1 1995/03/01 01:21:20 proven Exp";
-#endif
-
-#include <pthread.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <stdio.h>
-
-/* ==========================================================================
- * machdep_save_state()
- */
-int machdep_save_state(void)
-{
- return(machdep_sys_setjmp(pthread_run->machdep_data.machdep_state));
-}
-
-/* ==========================================================================
- * machdep_save_state()
- */
-int machdep_save_float_state(struct pthread * pthread)
-{
- char * fdata = (char *)pthread->machdep_data.machdep_float_state;
-
- __asm__ ("fsave %0"::"m" (*fdata));
-}
-
-/* ==========================================================================
- * machdep_restore_state()
- */
-void machdep_restore_state(void)
-{
- machdep_sys_longjmp(pthread_run->machdep_data.machdep_state, 1);
-}
-
-/* ==========================================================================
- * machdep_restore_float_state()
- */
-int machdep_restore_float_state(void)
-{
- char * fdata = (char *)pthread_run->machdep_data.machdep_float_state;
-
- __asm__ ("frstor %0"::"m" (*fdata));
-}
-
-/* ==========================================================================
- * machdep_set_thread_timer()
- */
-void machdep_set_thread_timer(struct machdep_pthread *machdep_pthread)
-{
- if (setitimer(ITIMER_VIRTUAL, &(machdep_pthread->machdep_timer), NULL)) {
- PANIC();
- }
-}
-
-/* ==========================================================================
- * machdep_unset_thread_timer()
- */
-void machdep_unset_thread_timer(struct machdep_pthread *machdep_pthread)
-{
- struct itimerval zeroval = { { 0, 0 }, { 0, 0 } };
- int ret;
-
- if (machdep_pthread) {
- ret = setitimer(ITIMER_VIRTUAL, &zeroval,
- &(machdep_pthread->machdep_timer));
- } else {
- ret = setitimer(ITIMER_VIRTUAL, &zeroval, NULL);
- }
-
- if (ret) {
- PANIC();
- }
-}
-
-/* ==========================================================================
- * machdep_pthread_cleanup()
- */
-void *machdep_pthread_cleanup(struct machdep_pthread *machdep_pthread)
-{
- return(machdep_pthread->machdep_stack);
-}
-
-/* ==========================================================================
- * machdep_pthread_start()
- */
-void machdep_pthread_start(void)
-{
- context_switch_done();
- pthread_sched_resume();
-
- /* Run current threads start routine with argument */
- pthread_exit(pthread_run->machdep_data.start_routine
- (pthread_run->machdep_data.start_argument));
-
- /* should never reach here */
- PANIC();
-}
-
-/* ==========================================================================
- * __machdep_stack_free()
- */
-void __machdep_stack_free(void * stack)
-{
- free(stack);
-}
-
-/* ==========================================================================
- * __machdep_stack_alloc()
- */
-void * __machdep_stack_alloc(size_t size)
-{
- void * stack;
-
- return(malloc(size));
-}
-
-/* ==========================================================================
- * __machdep_pthread_create()
- */
-void __machdep_pthread_create(struct machdep_pthread *machdep_pthread,
- void *(* start_routine)(), void *start_argument,
- long stack_size, long nsec, long flags)
-{
- machdep_pthread->start_routine = start_routine;
- machdep_pthread->start_argument = start_argument;
-
- machdep_pthread->machdep_timer.it_value.tv_sec = 0;
- machdep_pthread->machdep_timer.it_interval.tv_sec = 0;
- machdep_pthread->machdep_timer.it_interval.tv_usec = 0;
- machdep_pthread->machdep_timer.it_value.tv_usec = nsec / 1000;
-
- machdep_sys_setjmp(machdep_pthread->machdep_state);
- /*
- * Set up new stact frame so that it looks like it
- * returned from a longjmp() to the beginning of
- * machdep_pthread_start().
- */
- machdep_pthread->machdep_state[0] = (int)machdep_pthread_start;
-
- /* Stack starts high and builds down. */
- machdep_pthread->machdep_state[2] =
- (int)machdep_pthread->machdep_stack + stack_size;
-}
-
-/* ==========================================================================
- * machdep_sys_creat()
- */
-machdep_sys_creat(char * path, int mode)
-{
- return(machdep_sys_open(path, O_WRONLY | O_CREAT | O_TRUNC, mode));
-}
-
-/* ==========================================================================
- * machdep_sys_wait3()
- */
-machdep_sys_wait3(int * b, int c, int * d)
-{
- return(machdep_sys_wait4(0, b, c, d));
-}
-
-/* ==========================================================================
- * machdep_sys_waitpid()
- */
-machdep_sys_waitpid(int a, int * b, int c)
-{
- return(machdep_sys_wait4(a, b, c, NULL));
-}
-
-/* ==========================================================================
- * machdep_sys_getdtablesize()
- */
-machdep_sys_getdtablesize()
-{
- return(sysconf(_SC_OPEN_MAX));
-}
diff --git a/lib/libpthread/arch/i386/machdep.h b/lib/libpthread/arch/i386/machdep.h
deleted file mode 100644
index 41a3a553cc0..00000000000
--- a/lib/libpthread/arch/i386/machdep.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ==== machdep.h ============================================================
- * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
- *
- * $Id: machdep.h,v 1.2 1998/07/21 16:28:02 peter Exp $
- *
- */
-
-#include <unistd.h>
-#include <setjmp.h>
-#include <sys/time.h>
-
-/*
- * The first machine dependent functions are the SEMAPHORES
- * needing the test and set instruction.
- */
-#define SEMAPHORE_CLEAR 0
-#define SEMAPHORE_SET 1
-
-#define SEMAPHORE_TEST_AND_SET(lock) \
-({ \
-long temp = SEMAPHORE_SET; \
- \
-__asm__ volatile ("xchgl %0,(%2)" \
- :"=r" (temp) \
- :"0" (temp),"r" (lock)); \
-temp; \
-})
-
-#define SEMAPHORE_RESET(lock) *lock = SEMAPHORE_CLEAR
-
-/*
- * New types
- */
-typedef long semaphore;
-
-/*
- * sigset_t macros
- */
-#define SIG_ANY(sig) (sig)
-#define SIGMAX 31
-
-/*
- * New Strutures
- */
-struct machdep_pthread {
- void *(*start_routine)(void *);
- void *start_argument;
- void *machdep_stack;
- struct itimerval machdep_timer;
- jmp_buf machdep_state;
- char machdep_float_state[108];
-};
-
-/*
- * Static machdep_pthread initialization values.
- * For initial thread only.
- */
-#define MACHDEP_PTHREAD_INIT \
-{ NULL, NULL, NULL, { { 0, 0 }, { 0, 100000 } }, 0 }
-
-/*
- * Minimum stack size
- */
-#define PTHREAD_STACK_MIN 1024
-
-/*
- * Some fd flag defines that are necessary to distinguish between posix
- * behavior and bsd4.3 behavior.
- */
-#define __FD_NONBLOCK O_NONBLOCK
-
-/*
- * New functions
- */
-
-__BEGIN_DECLS
-
-#if defined(PTHREAD_KERNEL)
-
-#define __machdep_stack_get(x) (x)->machdep_stack
-#define __machdep_stack_set(x, y) (x)->machdep_stack = y
-#define __machdep_stack_repl(x, y) \
-{ \
- if (stack = __machdep_stack_get(x)) { \
- __machdep_stack_free(stack); \
- } \
- __machdep_stack_set(x, y); \
-}
-
-void * __machdep_stack_alloc __P_((size_t));
-void __machdep_stack_free __P_((void *));
-
-int machdep_save_state __P_((void));
-
-#endif
-
-__END_DECLS
diff --git a/lib/libpthread/arch/i386/syscall-template.S b/lib/libpthread/arch/i386/syscall-template.S
deleted file mode 100644
index 34fb5caaa43..00000000000
--- a/lib/libpthread/arch/i386/syscall-template.S
+++ /dev/null
@@ -1,48 +0,0 @@
-#include <sys/syscall.h>
-
-#ifdef __STDC__
-
-#define SYSCALL(x) \
- .globl _machdep_sys_##x##; \
- \
-_machdep_sys_##x:##; \
- \
- movl $(SYS_##x##), %eax; \
- .byte 0x9a; .long 0; .word 7; \
- jb 1b; \
- ret;
-
-#else
-
-#define SYSCALL(x) \
- .globl _machdep_sys_/**/x; \
- \
-_machdep_sys_/**/x:; \
- \
- movl $(SYS_/**/x), %eax; \
- .byte 0x9a; .long 0; .word 7; \
- jb 1b; \
- ret;
-
-#endif
-
-
-/*
- * Initial asm stuff for all functions.
- */
- .text
- .align 2
-
-
-/* ==========================================================================
- * error code for all syscalls. The error value is returned as the negative
- * of the errno value.
- */
-
-1:
- neg %eax
- ret
-
-#define XSYSCALL(NAME) SYSCALL(NAME)
-
-XSYSCALL(SYSCALL_NAME)
diff --git a/lib/libpthread/arch/i386/syscall.S b/lib/libpthread/arch/i386/syscall.S
deleted file mode 100644
index 8f2060e61e3..00000000000
--- a/lib/libpthread/arch/i386/syscall.S
+++ /dev/null
@@ -1,248 +0,0 @@
-/* ==== syscall.S ============================================================
- * Copyright (c) 1990 The Regents of the University of California.
- * Copyright (c) 1995 Chris Provenzano, proven@mit.edu
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * Description : Machine dependent syscalls for i386/i486/i586
- *
- */
-
-#ifndef lint
- .text
- .asciz "syscall-i386-freebsd-2.0.S,v 1.2 1995/05/26 07:44:29 proven Exp";
-#endif
-
-#if defined(SYSLIBC_SCCS) && !defined(lint)
- .asciz "@(#)syscall.s 5.1 (Berkeley) 4/23/90"
-#endif /* SYSLIBC_SCCS and not lint */
-
-#include <sys/syscall.h>
-
-#ifdef __STDC__
-
-#define SYSCALL(x) \
- .globl _machdep_sys_##x##; \
- \
-_machdep_sys_##x##:; \
- \
- movl $(SYS_##x##), %eax; \
- .byte 0x9a; .long 0; .word 7; \
- jb 1b; \
- ret;
-
-#else
-
-#define SYSCALL(x) \
- .globl _machdep_sys_/**/x; \
- \
-_machdep_sys_/**/x:; \
- \
- movl $(SYS_/**/x), %eax; \
- .byte 0x9a; .long 0; .word 7; \
- jb 1b; \
- ret;
-
-#endif
-
-
-/*
- * Initial asm stuff for all functions.
- */
- .text
- .align 2
-
-
-/* ==========================================================================
- * error code for all syscalls. The error value is returned as the negative
- * of the errno value.
- */
-
-1:
- neg %eax
- ret
-
-/* ==========================================================================
- * machdep_sys_fork()
- */
- .globl _machdep_sys_fork;
-
-_machdep_sys_fork:;
-
- movl $(SYS_fork), %eax;
- .byte 0x9a; .long 0; .word 7;
- cmpl $0, %edx
- je 2f
- movl $0, %eax
-2:
- ret;
-
-/* ==========================================================================
- * machdep_sys___syscall()
- */
-
-_machdep_sys___syscall:;
-
- movl $(SYS___syscall), %eax;
- .byte 0x9a; .long 0; .word 7;
- jb 3f;
- ret
-
-/* ==========================================================================
- * machdep_sys_sigsuspend()
- */
- .globl _machdep_sys_sigsuspend;
-
-_machdep_sys_sigsuspend:;
-
- movl 4(%esp),%eax # fetch mask arg
- movl (%eax),%eax # indirect to mask arg
- movl %eax,4(%esp)
- movl $(SYS_sigsuspend), %eax;
- .byte 0x9a; .long 0; .word 7;
- jb 3f;
- ret
-
-3:
-
- neg %eax
- movl $0xffffffff,%edx
- ret
-
-/* ==========================================================================
- * machdep_sys_sigprocmask()
- */
- .globl _machdep_sys_sigprocmask;
-
-_machdep_sys_sigprocmask:;
-
- movl 8(%esp),%ecx
- movl (%ecx),%ecx
- movl %ecx,8(%esp)
- movl $ SYS_sigprocmask , %eax
- .byte 0x9a; .long 0; .word 7;
- jb 4f;
- ret
-
-4:
- neg %eax
- movl $0xffffffff,%edx
- ret
-
-/* ==========================================================================
- * machdep_sys_lseek()
- */
- .globl _machdep_sys_lseek;
-
-_machdep_sys_lseek:;
-
- pushl %ebp;
- movl %esp,%ebp;
- pushl 0x14(%ebp);
- pushl 0x10(%ebp);
- pushl 0xc(%ebp);
- pushl $0x0;
- pushl 0x8(%ebp);
- pushl $0x0;
- pushl $(SYS_lseek);
- call _machdep_sys___syscall;
- leave
- ret
-
-/* ==========================================================================
- * machdep_sys_ftruncate() ; Added by Monty
- */
- .globl _machdep_sys_ftruncate;
-
-_machdep_sys_ftruncate:;
-
- pushl %ebp;
- movl %esp,%ebp;
- pushl 0x10(%ebp);
- pushl 0xc(%ebp);
- pushl $0x0; # Why this?
- pushl 0x8(%ebp);
- pushl $0x0; # And this?
- pushl $(SYS_ftruncate);
- call _machdep_sys___syscall;
- leave
- ret
-
-/* ==========================================================================
- * machdep_sys_setjmp()
- */
- .globl _machdep_sys_setjmp;
-
-_machdep_sys_setjmp:;
- movl 4(%esp),%eax
- movl 0(%esp),%edx
- movl %edx, 0(%eax) /* rta */
- movl %ebx, 4(%eax)
- movl %esp, 8(%eax)
- movl %ebp,12(%eax)
- movl %esi,16(%eax)
- movl %edi,20(%eax)
- xorl %eax,%eax
- ret
-
-/* ==========================================================================
- * machdep_sys_longjmp()
- */
- .globl _machdep_sys_longjmp;
-
-_machdep_sys_longjmp:;
- movl 4(%esp),%edx
- movl 8(%esp),%eax
- movl 0(%edx),%ecx
- movl 4(%edx),%ebx
- movl 8(%edx),%esp
- movl 12(%edx),%ebp
- movl 16(%edx),%esi
- movl 20(%edx),%edi
- testl %eax,%eax
- jnz 1f
- incl %eax
-1: movl %ecx,0(%esp)
- ret
-
-/* ==========================================================================
- * machdep_sys_pipe()
- */
- .globl _machdep_sys_pipe;
-
-_machdep_sys_pipe:;
- movl 4(%esp),%ecx
- movl %eax,(%ecx)
- movl %edx,4(%ecx)
- xorl %eax,%eax
- ret
diff --git a/lib/libpthread/arch/m68k/Makefile.inc b/lib/libpthread/arch/m68k/Makefile.inc
deleted file mode 100644
index a7c4761a6b4..00000000000
--- a/lib/libpthread/arch/m68k/Makefile.inc
+++ /dev/null
@@ -1,4 +0,0 @@
-# Machine dependent sources
-.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}
-
-SRCS+= machdep.c syscall.S
diff --git a/lib/libpthread/arch/m68k/machdep.c b/lib/libpthread/arch/m68k/machdep.c
deleted file mode 100644
index 80b47c63cae..00000000000
--- a/lib/libpthread/arch/m68k/machdep.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/* ==== machdep.c ============================================================
- * Copyright (c) 1993, 1994 Chris Provenzano, proven@athena.mit.edu
- *
- * Copyright (c) 1993 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 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.
- *
- * Description : Machine dependent functions for NetBSD on i386
- *
- * 1.00 93/08/04 proven
- * -Started coding this file.
- *
- * m68k work from David Leonard <david.leonard@it.uq.edu.au>.
- *
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: machdep.c,v 1.1 1997/04/13 17:13:08 briggs Exp $";
-#endif
-
-#include "pthread.h"
-
-/* ==========================================================================
- * machdep_save_state()
- */
-int machdep_save_state(void)
-{
- return( _setjmp(pthread_run->machdep_data.machdep_state) );
-}
-
-/* ==========================================================================
- * machdep_restore_state()
- */
-void machdep_restore_state(void)
-{
- _longjmp(pthread_run->machdep_data.machdep_state, 1);
-}
-
-/* ==========================================================================
- * machdep_set_thread_timer()
- */
-void machdep_set_thread_timer(struct machdep_pthread *machdep_pthread)
-{
- if (setitimer(ITIMER_VIRTUAL, &(machdep_pthread->machdep_timer), NULL)) {
- PANIC();
- }
-}
-
-/* ==========================================================================
- * machdep_unset_thread_timer()
- */
-void machdep_unset_thread_timer(struct machdep_pthread *machdep_pthread)
-{
- struct itimerval zeroval = { { 0, 0 }, { 0, 0 } };
-
- if (setitimer(ITIMER_VIRTUAL, &zeroval, NULL)) {
- PANIC();
- }
-}
-
-/* ==========================================================================
- * machdep_pthread_cleanup()
- */
-void *machdep_pthread_cleanup(struct machdep_pthread *machdep_pthread)
-{
- return(machdep_pthread->machdep_stack);
-}
-
-/* ==========================================================================
- * machdep_pthread_start()
- */
-void machdep_pthread_start(void)
-{
- context_switch_done();
- sig_check_and_resume();
-
- /* Run current thread's start routine with argument */
- pthread_exit(
- pthread_run->machdep_data.start_routine(
- pthread_run->machdep_data.start_argument
- )
- );
-
- /* should never reach here */
- PANIC();
-}
-
-/* ==========================================================================
- * machdep_pthread_create()
- */
-void machdep_pthread_create(struct machdep_pthread *machdep_pthread,
- void *(* start_routine)(), void *start_argument, long stack_size,
- void *stack_start, long nsec)
-{
- machdep_pthread->machdep_stack = stack_start;
-
- machdep_pthread->start_routine = start_routine;
- machdep_pthread->start_argument = start_argument;
-
- machdep_pthread->machdep_timer.it_value.tv_sec = 0;
- machdep_pthread->machdep_timer.it_interval.tv_sec = 0;
- machdep_pthread->machdep_timer.it_interval.tv_usec = 0;
- machdep_pthread->machdep_timer.it_value.tv_usec = nsec / 1000;
-
- _setjmp(machdep_pthread->machdep_state);
-
- /*
- * Set up new stack frame so that it looks like it
- * returned from a longjmp() to the beginning of
- * machdep_pthread_start().
- *
- * state is the set_jmp structure, which for m68k is:
- * long onstack_flag; // [0]
- * long sigmask; // [1]
- * long sp; // [2]
- * long fp; // [3]
- * long ap; // [4]
- * long pc; // [5]
- * long ps; // [6]
- * long regs[10]; // non scratch registers
- */
- machdep_pthread->machdep_state[5] = (long)machdep_pthread_start;
-
- /* Stack starts high and builds down. */
- machdep_pthread->machdep_state[2] =
- (int)machdep_pthread->machdep_stack + stack_size;
-}
diff --git a/lib/libpthread/arch/m68k/machdep.h b/lib/libpthread/arch/m68k/machdep.h
deleted file mode 100644
index 72b42e45c7b..00000000000
--- a/lib/libpthread/arch/m68k/machdep.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* ==== machdep.h ============================================================
- * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
- *
- * $Id: machdep.h,v 1.2 1998/07/21 16:28:05 peter Exp $
- *
- */
-
-#include <unistd.h>
-#include <setjmp.h>
-#include <sys/time.h>
-
-/*
- * The first machine dependent functions are the SEMAPHORES
- * needing the test and set instruction.
- */
-#define SEMAPHORE_CLEAR 0
-#define SEMAPHORE_SET 0x80;
-
-#define SEMAPHORE_TEST_AND_SET(lock) \
-({ \
-volatile long temp = SEMAPHORE_CLEAR; \
- \
-__asm__ volatile("tas (%2); bpl 0f; movl #1,%0; 0:" \
- :"=r" (temp) \
- :"0" (temp),"r" (lock)); \
-temp; \
-})
-
-#define SEMAPHORE_RESET(lock) *lock = SEMAPHORE_CLEAR
-
-/*
- * New types
- */
-typedef char semaphore;
-
-/*
- * sigset_t macros
- */
-#define SIG_ANY(sig) (sig)
-#define SIGMAX 31
-
-/*
- * New Strutures
- */
-struct machdep_pthread {
- void *(*start_routine)(void *);
- void *start_argument;
- void *machdep_stack;
- struct itimerval machdep_timer;
- jmp_buf machdep_state;
-};
-
-/*
- * Min pthread stacksize
- */
-#define PTHREAD_STACK_MIN 1024
-
-/*
- * Static machdep_pthread initialization values.
- * For initial thread only.
- */
-#define MACHDEP_PTHREAD_INIT \
-{ NULL, NULL, NULL, { { 0, 0 }, { 0, 100000 } }, 0 }
-
-/*
- * New functions
- */
-
-__BEGIN_DECLS
-
-#if defined(PTHREAD_KERNEL)
-
-int machdep_save_state __P_((void));
-
-#endif
-
-__END_DECLS
diff --git a/lib/libpthread/arch/m68k/syscall.S b/lib/libpthread/arch/m68k/syscall.S
deleted file mode 100644
index b68fc846138..00000000000
--- a/lib/libpthread/arch/m68k/syscall.S
+++ /dev/null
@@ -1,125 +0,0 @@
-/* $OpenBSD: syscall.S,v 1.1 1997/04/13 17:13:09 briggs Exp $ */
-
-#ifndef lint
- .text
- .asciz "$Id: syscall.S,v 1.1 1997/04/13 17:13:09 briggs Exp $";
-#endif
-
-#include <machine/asm.h>
-#include <sys/syscall.h>
-
-#ifdef __STDC__
-#define SYSCALL(x) .even; ENTRY(machdep_sys_ ## x); \
- movl \#SYS_ ## x,d0; trap \#0; jcs err; rts
-#else /* !__STDC__ */
-#define SYSCALL(x) .even; ENTRY(machdep_sys_/**/x); \
- movl #SYS_/**/x,d0; trap #0; jcs err; rts
-#endif /* !__STDC__ */
-
-/*
- * Initial asm stuff for all functions.
- */
- .text
- .even
-
-
-/* ==========================================================================
- * error code for all syscalls. The error value is returned as the negative
- * of the errno value.
- */
-
-err:
- negl d0
- rts
-
-/* ==========================================================================
- * machdep_sys_write()
- */
-SYSCALL(write)
-
-/* ==========================================================================
- * machdep_sys_read()
- */
-SYSCALL(read)
-
-/* ==========================================================================
- * machdep_sys_open()
- */
-SYSCALL(open)
-
-/* ==========================================================================
- * machdep_sys_close()
- */
-SYSCALL(close)
-
-/* ==========================================================================
- * machdep_sys_fcntl()
- */
-SYSCALL(fcntl)
-
-/* ==========================================================================
- * machdep_sys_lseek()
- */
-SYSCALL(lseek)
-
-/* ==========================================================================
- * Nonstandard calls used to make the system work
- *
- * ==========================================================================
- * machdep_sys_select()
- */
-SYSCALL(select)
-
-/* ==========================================================================
- * Berkeley socket stuff
- *
- * ==========================================================================
- * machdep_sys_socket()
- */
-SYSCALL(socket)
-
-/* ==========================================================================
- * machdep_sys_bind()
- */
-SYSCALL(bind)
-
-/* ==========================================================================
- * machdep_sys_connect()
- */
-SYSCALL(connect)
-
-/* ==========================================================================
- * machdep_sys_accept()
- */
-SYSCALL(accept)
-
-/* ==========================================================================
- * machdep_sys_listen()
- */
-SYSCALL(listen)
-
-/* ==========================================================================
- * machdep_sys_getsockopt()
- */
-SYSCALL(getsockopt)
-
-/* ==========================================================================
- * machdep_sys_readv()
- */
-SYSCALL(readv)
-
-/* ==========================================================================
- * machdep_sys_writev()
- */
-SYSCALL(writev)
-
-/* ==========================================================================
- * machdep_sys_getpeername()
- */
-SYSCALL(getpeername)
-
-/* ==========================================================================
- * machdep_sys_getsockname()
- */
-SYSCALL(getsockname)
-
diff --git a/lib/libpthread/arch/sparc/syscall-template.S b/lib/libpthread/arch/sparc/syscall-template.S
deleted file mode 100644
index 2d07892a315..00000000000
--- a/lib/libpthread/arch/sparc/syscall-template.S
+++ /dev/null
@@ -1,40 +0,0 @@
-/* ==== syscall.S ============================================================
- * Copyright (c) 1994 Chris Provenzano, proven@mit.edu
- * All rights reserved.
- *
- */
-
-#include <sys/syscall.h>
-
-#define SYSCALL(x) \
- .globl _machdep_sys_##x; \
- \
-_machdep_sys_##x:; \
- \
- mov SYS_##x, %g1; \
- ta 0; \
- bcs,a 2b; \
- sub %r0,%o0,%o0; \
- retl; \
- nop
-
-/*
- * Initial asm stuff for all functions.
- */
- .text
- .align 4
-
-/* ==========================================================================
- * error code for all syscalls. The error value is returned as the negative
- * of the errno value.
- */
-
-1:
- sub %r0, %o0, %o0
-2:
- retl
- nop
-
-#define XSYSCALL(NAME) SYSCALL(NAME)
-
-XSYSCALL(SYSCALL_NAME)
diff --git a/lib/libpthread/arch/sparc/syscall.S b/lib/libpthread/arch/sparc/syscall.S
deleted file mode 100644
index 9312ef7352a..00000000000
--- a/lib/libpthread/arch/sparc/syscall.S
+++ /dev/null
@@ -1,102 +0,0 @@
-/* ==== syscall.S ============================================================
- * Copyright (c) 1994 Chris Provenzano, proven@mit.edu
- * All rights reserved.
- *
- */
-
-#ifndef lint
- .text
- .asciz "$Id: syscall.S,v 1.1 1998/07/21 16:28:06 peter Exp $";
-#endif
-
-#include <sys/syscall.h>
-
-#define SYSCALL(x) \
- .globl _machdep_sys_##x; \
- \
-_machdep_sys_##x:; \
- \
- mov SYS_##x, %g1; \
- ta 0; \
- bcs,a 2b; \
- sub %r0,%o0,%o0; \
- retl
-
-
-/*
- * Initial asm stuff for all functions.
- */
- .text
- .align 4
-
-/* ==========================================================================
- * error code for all syscalls. The error value is returned as the negative
- * of the errno value.
- */
-
-1:
- sub %r0, %o0, %o0
-2:
- retl
- nop
-
-/* ==========================================================================
- * machdep_sys_pipe()
- */
- .globl _machdep_sys_pipe
-
-_machdep_sys_pipe:
- mov %o0, %o2
- mov SYS_pipe, %g1
- ta 0
- bcs 1b
- nop
- st %o0, [ %o2 ]
- st %o1, [ %o2 + 4 ]
- retl
- mov %g0, %o0
-
-/* ==========================================================================
- * machdep_sys_fork()
- */
- .globl _machdep_sys_fork;
-
-_machdep_sys_fork:;
-
- mov SYS_fork, %g1;
- ta 0;
- bcs 1b;
- nop;
- dec %o1;
- retl;
- and %o0, %o1, %o0; ! return 0 in child, pid in parent
-
-/* ==========================================================================
- * machdep_sys_sigprocmask()
- */
- .globl _machdep_sys_sigprocmask;
-
-_machdep_sys_sigprocmask:;
-
- ld [%o1], %o1;
- mov SYS_sigprocmask, %g1;
- ta 0;
- bcs 1b;
- nop;
- retl
- nop
-
-/* ==========================================================================
- * machdep_sys_sigsuspend()
- */
- .globl _machdep_sys_sigsuspend;
-
-_machdep_sys_sigsuspend:;
-
- ld [%o0], %o0;
- mov SYS_sigsuspend, %g1;
- ta 0;
- bcs 1b;
- nop;
- retl
- nop
diff --git a/lib/libpthread/bin/Makefile b/lib/libpthread/bin/Makefile
deleted file mode 100644
index ce18f70b66a..00000000000
--- a/lib/libpthread/bin/Makefile
+++ /dev/null
@@ -1,49 +0,0 @@
-# Generated automatically from Makefile.in by configure.
-# === GNUmakefile ============================================================
-# Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
-#
-# Description: This file is for creating the test programs for libpthread.a
-#
-# 1.00 93/08/03 proven
-# -Initial cut for pthreads.
-#
-
-CC = ../pgcc -notinstalled
-srctop = /dr1/my/masters/mysql/mit-pthreads
-srcdir = /dr1/my/masters/mysql/mit-pthreads/lib
-VPATH = /dr1/my/masters/mysql/mit-pthreads/lib
-CDEBUGFLAGS = -g -O2 -Werror
-
-CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(ADDL_CFLAGS) -DSRCDIR=\"$(srcdir)\"
-
-#
-DIRS = finger
-
-################################################################################
-#
-all:
- (for i in $(DIRS); do cd $$i; $(MAKE) all; cd ..; done)
-
-clean:
- (for i in $(DIRS); do cd $$i; $(MAKE) clean; cd ..; done)
- rm -f *.o $(TESTS) $(BENCHMARKS) a.out core maketmp makeout
-
-depend:
- (for i in $(DIRS); do cd $$i; $(MAKE) depend; cd ..; done)
- sed '/\#\#\# Dependencies/q' < Makefile > maketmp
- (for i in $(CSRC);do $(CPP) -M $$i;done) >> maketmp
- cp maketmp Makefile
-
-install:
- (for i in $(DIRS); do cd $$i; $(MAKE) install; cd ..; done)
-
-realclean: clean
- (for i in $(DIRS); do cd $$i; $(MAKE) realclean; cd ..; done)
- rm -f Makefile
-
-Makefile: Makefile.in
- (cd .. ; sh config.status)
-
-################################################################################
-### Do not remove the following line. It is for depend #########################
-### Dependencies:
diff --git a/lib/libpthread/bin/Makefile.in b/lib/libpthread/bin/Makefile.in
deleted file mode 100644
index 979ad2db2ea..00000000000
--- a/lib/libpthread/bin/Makefile.in
+++ /dev/null
@@ -1,48 +0,0 @@
-# === GNUmakefile ============================================================
-# Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
-#
-# Description: This file is for creating the test programs for libpthread.a
-#
-# 1.00 93/08/03 proven
-# -Initial cut for pthreads.
-#
-
-CC = ../pgcc -notinstalled
-srctop = @srctop@
-srcdir = @srctop@/lib
-VPATH = @srctop@/lib
-CDEBUGFLAGS = @CFLAGS@
-
-CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(ADDL_CFLAGS) -DSRCDIR=\"$(srcdir)\"
-
-#
-DIRS = finger
-
-################################################################################
-#
-all:
- (for i in $(DIRS); do cd $$i; $(MAKE) all; cd ..; done)
-
-clean:
- (for i in $(DIRS); do cd $$i; $(MAKE) clean; cd ..; done)
- rm -f *.o $(TESTS) $(BENCHMARKS) a.out core maketmp makeout
-
-depend:
- (for i in $(DIRS); do cd $$i; $(MAKE) depend; cd ..; done)
- sed '/\#\#\# Dependencies/q' < Makefile > maketmp
- (for i in $(CSRC);do $(CPP) -M $$i;done) >> maketmp
- cp maketmp Makefile
-
-install:
- (for i in $(DIRS); do cd $$i; $(MAKE) install; cd ..; done)
-
-realclean: clean
- (for i in $(DIRS); do cd $$i; $(MAKE) realclean; cd ..; done)
- rm -f Makefile
-
-Makefile: Makefile.in
- (cd .. ; sh config.status)
-
-################################################################################
-### Do not remove the following line. It is for depend #########################
-### Dependencies:
diff --git a/lib/libpthread/bin/finger/Makefile b/lib/libpthread/bin/finger/Makefile
deleted file mode 100644
index 8ee4396b758..00000000000
--- a/lib/libpthread/bin/finger/Makefile
+++ /dev/null
@@ -1,61 +0,0 @@
-# Generated automatically from Makefile.in by configure.
-# === makefile ============================================================
-# Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
-#
-# Description: This file is for creating the test programs for libpthread.a
-#
-# 1.00 93/08/03 proven
-# -Initial cut for pthreads.
-#
-
-srctop = /dr1/my/masters/mysql/mit-pthreads
-srcdir = /dr1/my/masters/mysql/mit-pthreads/bin/finger
-VPATH = /dr1/my/masters/mysql/mit-pthreads/bin/finger
-prefix= /usr/local/pthreads
-exec_prefix= ${prefix}
-
-INSTALL_PATH = ${prefix}
- BINDIR = $(INSTALL_PATH)/bin
- LIBDIR = $(INSTALL_PATH)/lib
- MANDIR = $(INSTALL_PATH)/man
- INCDIR = $(INSTALL_PATH)/include
-
- CC = ../../pgcc -notinstalled
- CDEBUGFLAGS = -g -O2 -Werror
- INCLUDES = -I/dr1/my/masters/mysql/mit-pthreads/lib/libpthreadutil/ -L../../lib/libpthreadutil/
- CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(ADDL_CFLAGS) -DSRCDIR=\"$(srcdir)\"
- RANLIB = ranlib
-
- OBJS = finger.o net.o
- BINARY = finger
-
-################################################################################
-#
-all : $(BINARY)
-
-clean:
- rm -f *.o $(TESTS) $(BENCHMARKS) a.out core maketmp makeout
-
-depend:
- sed '/\#\#\# Dependencies/q' < Makefile > maketmp
- (for i in $(CSRC);do $(CPP) -M $$i;done) >> maketmp
- cp maketmp Makefile
-
-install: $(BINARY)
- install $(BINARY) $(BINDIR)
-
-realclean: clean
- rm -f Makefile
-
-Makefile: Makefile.in
- (cd ../.. ; sh config.status)
-
-.c.o:
- $(CC) $(CFLAGS) -c $<
-
-$(BINARY) : ${OBJS}
- $(CC) $(CFLAGS) -o $(BINARY) ${OBJS} -lpthreadutil
-
-################################################################################
-### Do not remove the following line. It is for depend #########################
-### Dependencies:
diff --git a/lib/libpthread/bin/finger/Makefile.in b/lib/libpthread/bin/finger/Makefile.in
deleted file mode 100755
index ee20f47443d..00000000000
--- a/lib/libpthread/bin/finger/Makefile.in
+++ /dev/null
@@ -1,60 +0,0 @@
-# === makefile ============================================================
-# Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
-#
-# Description: This file is for creating the test programs for libpthread.a
-#
-# 1.00 93/08/03 proven
-# -Initial cut for pthreads.
-#
-
-srctop = @srctop@
-srcdir = @srctop@/bin/finger
-VPATH = @srctop@/bin/finger
-prefix= @prefix@
-exec_prefix= @exec_prefix@
-
-INSTALL_PATH = @exec_prefix@
- BINDIR = $(INSTALL_PATH)/bin
- LIBDIR = $(INSTALL_PATH)/lib
- MANDIR = $(INSTALL_PATH)/man
- INCDIR = $(INSTALL_PATH)/include
-
- CC = ../../pgcc -notinstalled
- CDEBUGFLAGS = @CFLAGS@
- INCLUDES = -I@srctop@/lib/libpthreadutil/ -L../../lib/libpthreadutil/
- CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(ADDL_CFLAGS) -DSRCDIR=\"$(srcdir)\"
- RANLIB = @RANLIB@
-
- OBJS = finger.o net.o
- BINARY = finger
-
-################################################################################
-#
-all : $(BINARY)
-
-clean:
- rm -f *.o $(TESTS) $(BENCHMARKS) a.out core maketmp makeout
-
-depend:
- sed '/\#\#\# Dependencies/q' < Makefile > maketmp
- (for i in $(CSRC);do $(CPP) -M $$i;done) >> maketmp
- cp maketmp Makefile
-
-install: $(BINARY)
- install $(BINARY) $(BINDIR)
-
-realclean: clean
- rm -f Makefile
-
-Makefile: Makefile.in
- (cd ../.. ; sh config.status)
-
-.c.o:
- $(CC) $(CFLAGS) -c $<
-
-$(BINARY) : ${OBJS}
- $(CC) $(CFLAGS) -o $(BINARY) ${OBJS} -lpthreadutil
-
-################################################################################
-### Do not remove the following line. It is for depend #########################
-### Dependencies:
diff --git a/lib/libpthread/bin/finger/finger.c b/lib/libpthread/bin/finger/finger.c
deleted file mode 100755
index 33b3011e8bb..00000000000
--- a/lib/libpthread/bin/finger/finger.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/* ==== finger.c ============================================================
- * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
- *
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Tony Nardo of the Johns Hopkins University/Applied Physics Lab.
- *
- * 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,
- * the University of California, Berkeley and its contributors.
- * 4. Neither the name of Chris Provenzano, the University nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO, THE REGENTS 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.
- *
- * 1.00 93/08/26 proven
- * -Pthread redesign of this file.
- *
- * 1.10 95/02/11 proven
- * -Now that gethostbyname works ....
- */
-
-#ifndef lint
-char copyright[] =
-"@(#) Copyright (c) 1989 The Regents of the University of California.\n\
- @(#) Copyright (c) 1993, 1995 Chris Provenzano.\n\
- @(#) Copyright (c) 1995 Greg Stark.\n\
- All rights reserved.\n";
-#endif /* not lint */
-
-#include <pthreadutil.h>
-#include <sys/param.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-void *netfinger();
-
-void usage(int eval)
-{
- fprintf(stderr,
- "usage: finger [-lps] [-c <net_count>] [-t|T <timeout>] [-f <filename>] [login ...]\n");
- exit(eval);
-}
-
-/*
- * These globals are set initialy and then are only read.
- * They do not need mutexes.
- */
-int thread_time = 0, program_timeout = 0, lflag = 0;
-pthread_tad_t parse_file_tad;
-pthread_tad_t netfinger_tad;
-
-void * timeout_thread(void * arg)
-{
- sleep(program_timeout);
- exit(0);
-}
-
-void * signal_thread(void * arg)
-{
- int sig;
- sigset_t program_signals;
- sigemptyset(&program_signals);
- sigaddset(&program_signals, SIGINT);
- sigwait(&program_signals, &sig);
- exit(0);
-}
-
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 64
-#endif
-
-void * parse_file(void * arg)
-{
- char hostname[MAXHOSTNAMELEN];
- char * filename = arg;
- pthread_atexit_t atexit_id;
- pthread_attr_t attr;
- pthread_t thread_id;
- char * thread_arg;
- FILE * fp;
- int len;
-
- netsetupwait();
-
- /* Parse the file and create a thread per connection */
- if ((fp = fopen(filename, "r")) == NULL) {
- fprintf(stderr, "Can't open file %s\n", filename);
- pthread_exit(NULL);
- }
- pthread_atexit_add(&atexit_id, fclose_nrv, fp);
-
- if (pthread_attr_init(&attr)) {
- fprintf(stderr, "Error: Can't initialize thread attributes\n");
- exit(2);
- }
- pthread_atexit_add(&atexit_id, pthread_attr_destroy_nrv, &attr);
-
- while (fgets(hostname, MAXHOSTNAMELEN, fp)) {
- if ((thread_arg = (char *)malloc(len = strlen(hostname))) == NULL) {
- fprintf(stderr, "Error: out of memory\n");
- exit(2);
- }
-
- hostname[len - 1] = '\0';
- strcpy(thread_arg, hostname);
- pthread_attr_setcleanup(&attr, free, thread_arg);
- if (pthread_tad_create(&netfinger_tad, &thread_id, NULL,
- netfinger, thread_arg)) {
- fprintf(stderr, "Error: pthread_tad_create() netfinger_tad.\n");
- exit(2);
- }
- }
- pthread_exit(NULL);
-}
-
-main(int argc, char **argv)
-{
- pthread_atexit_t atexit_id;
- pthread_t thread_id;
- int max_count = 0;
- char ch;
-
- /* getopt variables */
- extern char *optarg;
- extern int optind;
-
- /* Setup tad for parse_file() threads */
- if (pthread_tad_init(&parse_file_tad, max_count)) {
- fprintf(stderr,"Error: couldn't create parse_file() TAD.\n");
- exit(1);
- }
-
- while ((ch = getopt(argc, argv, "c:f:t:T:ls")) != (char)EOF)
- switch(ch) {
- case 't': /* Time to let each thread run */
- if ((thread_time = atoi(optarg)) <= 0) {
- usage(1);
- }
- break;
- case 'T': /* Time to let entire program run */
- if ((program_timeout = atoi(optarg)) <= 0) {
- usage(1);
- }
- break;
- case 'f': /* Parse file for list of places to finger */
- if (pthread_tad_create(&parse_file_tad, &thread_id, NULL,
- parse_file, optarg)) {
- fprintf(stderr,"Error: pthread_tad_create() parse_file_tad.\n");
- exit(1);
- }
- break;
- case 'c':
- max_count = atoi(optarg);
- break;
- case 'l': /* long format */
- lflag = 1;
- break;
- case 's': /* short format */
- lflag = 0;
- break;
- case '?':
- usage(0);
- default:
- usage(1);
- }
-
- /* The rest of the argumants are hosts */
- argc -= optind;
- argv += optind;
-
- /* Setup timeout thread, if there is one */
- if (program_timeout) {
- if (pthread_create(&thread_id, NULL, timeout_thread, NULL)) {
- fprintf(stderr,"Error: couldn't create program_timeout() thread\n");
- exit(1);
- }
- }
-
- /* Setup cleanup thread for signals */
- if (pthread_create(&thread_id, NULL, signal_thread, NULL)) {
- fprintf(stderr,"Error: couldn't create signal_timeout() thread\n");
- exit(1);
- }
-
- /* Setup tad for netfinger() threads */
- if (pthread_tad_init(&netfinger_tad, max_count)) {
- fprintf(stderr,"Error: couldn't create netfinger() TAD.\n");
- exit(1);
- }
-
- /* Setup the net and let everyone run */
- netsetup();
-
- while (*argv) {
- if (pthread_tad_create(&netfinger_tad, &thread_id, NULL,
- netfinger, *argv)) {
- fprintf(stderr, "Error: pthread_tad_create() netfinger_tad.\n");
- exit(2);
- }
- argv++;
- }
- pthread_tad_wait(&parse_file_tad, 0);
- pthread_tad_wait(&netfinger_tad, 0);
- exit(0);
-}
-
diff --git a/lib/libpthread/bin/finger/net.c b/lib/libpthread/bin/finger/net.c
deleted file mode 100755
index 77ccd92ee8c..00000000000
--- a/lib/libpthread/bin/finger/net.c
+++ /dev/null
@@ -1,189 +0,0 @@
-/* ==== net.c ============================================================
- * Copyright (c) 1993, 1995 by Chris Provenzano, proven@athena.mit.edu
- *
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Tony Nardo of the Johns Hopkins University/Applied Physics Lab.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * 1.00 93/08/26 proven
- * -Pthread redesign of this file.
- */
-
-#include <pthreadutil.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/param.h>
-#include <netinet/in.h>
-#include <stdlib.h>
-#include <string.h>
-#include <netdb.h>
-#include <stdio.h>
-#include <ctype.h>
-
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 64
-#endif
-/*
- * These globals are set initialy and then are only read.
- * They do not need mutexes.
- */
-extern int lflag;
-char myhostname[MAXHOSTNAMELEN];
-
-/*
- * These globals change and therefor do need mutexes
- */
-pthread_mutex_t spmutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_cond_t spcond = PTHREAD_COND_INITIALIZER;
-struct servent *sp = NULL;
-
-void netsetup(void)
-{
- pthread_mutex_lock(&spmutex);
- if (sp) {
- fprintf(stderr, "finger: service pointer already initialized.\n");
- exit(2);
- }
- if ((sp = (struct servent *)malloc(sizeof(struct servent) + 4096)) == NULL){
- fprintf(stderr, "finger: Couldn't allocate service pointer.\n");
- exit(2);
- }
- if (getservbyname_r("finger", "tcp", sp, (char *)sp + sizeof(struct servent), 4096) == NULL) {
- fprintf(stderr, "finger: tcp/finger: unknown service\n");
- exit(2);
- }
- if (gethostname(myhostname, MAXHOSTNAMELEN)) {
- fprintf(stderr, "finger: couldn't get my hostname.\n");
- exit(2);
- }
- pthread_cond_broadcast(&spcond);
- pthread_mutex_unlock(&spmutex);
-}
-
-void netsetupwait(void)
-{
- pthread_mutex_lock(&spmutex);
- while(sp == NULL) {
- pthread_cond_wait(&spcond, &spmutex);
- }
- pthread_mutex_unlock(&spmutex);
-}
-
-void *netfinger(char *name)
-{
- pthread_atexit_t atexit_id;
- register int c, lastc;
- struct in_addr defaddr;
- struct hostent *hp;
- struct sockaddr_in sin;
- int s, i, readbuflen;
- char readbuf[1024];
- char *host;
-
- netsetupwait();
- pthread_atexit_add(&atexit_id, fflush_nrv, NULL);
-
- if (!(host = strrchr(name, '@'))) {
- host = myhostname;
- } else {
- *host++ = '\0';
- }
- if (!(hp = gethostbyname(host))) {
- if ((defaddr.s_addr = inet_addr(host)) < 0) {
- fprintf(stderr, "[%s] gethostbyname: Unknown host\n", host);
- return;
- }
- }
- sin.sin_family = hp->h_addrtype;
- memcpy((char *)&sin.sin_addr, hp->h_addr, hp->h_length);
- sin.sin_port = sp->s_port;
-
- if ((s = socket(sin.sin_family, SOCK_STREAM, 0)) < 0) {
- sprintf(readbuf, "[%s]: socket", hp->h_name);
- perror(readbuf);
- return;
- }
-
- /* have network connection; identify the host connected with */
- if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
- sprintf(readbuf, "[%s]: connect", hp->h_name);
- perror(readbuf);
- close(s);
- return;
- }
-
- /* -l flag for remote fingerd */
- if (lflag)
- write(s, "/W ", 3);
- /* send the name followed by <CR><LF> */
- write(s, name, strlen(name));
- write(s, "\r\n", 2);
-
- /*
- * Read from the remote system; once we're connected, we assume some
- * data. If none arrives, we hang until the user interrupts, or
- * until the thread timeout expires.
- *
- * If we see a <CR> or a <CR> with the high bit set, treat it as
- * a newline; if followed by a newline character, only output one
- * newline.
- *
- * Otherwise, all high bits are stripped; if it isn't printable and
- * it isn't a space, we can simply set the 7th bit. Every ASCII
- * character with bit 7 set is printable.
- */
- for (readbuflen = read(s, readbuf, 1024), flockfile(stdout), lastc = '\n',
- printf("[%s]\n", hp->h_name); readbuflen > 0;
- readbuflen = read(s, readbuf, 1024)) {
- for (i = 0; i < readbuflen; i++) {
- c = readbuf[i] & 0x7f;
- if (c == 0x0d) {
- c = '\n';
- lastc = '\r';
- } else {
- if (!isprint(c) && !isspace(c))
- c |= 0x40;
- if (lastc != '\r' || c != '\n')
- lastc = c;
- else {
- lastc = '\n';
- continue;
- }
- }
- putchar_unlocked(c);
- }
- }
- if (lastc != '\n')
- putchar_unlocked('\n');
- funlockfile(stdout);
-}
diff --git a/lib/libpthread/gen/Makefile.inc b/lib/libpthread/gen/Makefile.inc
deleted file mode 100644
index a2e13b4a205..00000000000
--- a/lib/libpthread/gen/Makefile.inc
+++ /dev/null
@@ -1,8 +0,0 @@
-# from: @(#)Makefile.inc 5.21 (Berkeley) 5/24/91
-# $Id: Makefile.inc,v 1.2 1998/07/21 16:28:06 peter Exp $
-
-.PATH: ${.CURDIR}/gen
-
-SRCS+= ttyname.c isatty.c directory.c popen.c time.c ctime.c difftime.c \
- syslog.c eprintf.c getpwent.c getpwnamuid.c pwd_internal.c getcwd.c \
- getwd.c
diff --git a/lib/libpthread/gen/ctime.c b/lib/libpthread/gen/ctime.c
deleted file mode 100644
index c496e9dfb23..00000000000
--- a/lib/libpthread/gen/ctime.c
+++ /dev/null
@@ -1,1314 +0,0 @@
-/*
- * Copyright (c) 1987, 1989 Regents of the University of California.
- * Copyright (c) 1994 Chris Provenzano, proven@mit.edu
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Arthur David Olson of the National Cancer Institute.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)ctime.c 5.26 (Berkeley) 2/23/91";
-#endif /* LIBC_SCCS and not lint */
-
-/*
-** Leap second handling from Bradley White (bww@k.gp.cs.cmu.edu).
-** POSIX-style TZ environment variable handling from Guy Harris
-** (guy@auspex.com).
-*/
-
-/*LINTLIBRARY*/
-#include <pthread.h>
-#include <sys/param.h>
-#include <fcntl.h>
-#include <time.h>
-#include <tzfile.h>
-#include <string.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#ifndef WILDABBR
-/*
-** Someone might make incorrect use of a time zone abbreviation:
-** 1. They might reference tzname[0] before calling tzset (explicitly
-** or implicitly).
-** 2. They might reference tzname[1] before calling tzset (explicitly
-** or implicitly).
-** 3. They might reference tzname[1] after setting to a time zone
-** in which Daylight Saving Time is never observed.
-** 4. They might reference tzname[0] after setting to a time zone
-** in which Standard Time is never observed.
-** 5. They might reference tm.TM_ZONE after calling offtime.
-** What's best to do in the above cases is open to debate;
-** for now, we just set things up so that in any of the five cases
-** WILDABBR is used. Another possibility: initialize tzname[0] to the
-** string "tzname[0] used before set", and similarly for the other cases.
-** And another: initialize tzname[0] to "ERA", with an explanation in the
-** manual page of what this "time zone abbreviation" means (doing this so
-** that tzname[0] has the "normal" length of three characters).
-*/
-#define WILDABBR " "
-#endif /* !defined WILDABBR */
-
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif /* !defined TRUE */
-
-static const char GMT[] = "GMT";
-
-struct ttinfo { /* time type information */
- long tt_gmtoff; /* GMT offset in seconds */
- int tt_isdst; /* used to set tm_isdst */
- int tt_abbrind; /* abbreviation list index */
- int tt_ttisstd; /* TRUE if transition is std time */
-};
-
-struct lsinfo { /* leap second information */
- time_t ls_trans; /* transition time */
- long ls_corr; /* correction to apply */
-};
-
-struct state {
- int leapcnt;
- int timecnt;
- int typecnt;
- int charcnt;
- time_t ats[TZ_MAX_TIMES];
- unsigned char types[TZ_MAX_TIMES];
- struct ttinfo ttis[TZ_MAX_TYPES];
- char chars[(TZ_MAX_CHARS + 1 > sizeof GMT) ?
- TZ_MAX_CHARS + 1 : sizeof GMT];
- struct lsinfo lsis[TZ_MAX_LEAPS];
-};
-
-struct rule {
- int r_type; /* type of rule--see below */
- int r_day; /* day number of rule */
- int r_week; /* week number of rule */
- int r_mon; /* month number of rule */
- long r_time; /* transition time of rule */
-};
-
-#define JULIAN_DAY 0 /* Jn - Julian day */
-#define DAY_OF_YEAR 1 /* n - day of year */
-#define MONTH_NTH_DAY_OF_WEEK 2 /* Mm.n.d - month, week, day of week */
-
-/*
-** Prototypes for static functions.
-*/
-
-static long detzcode __P_((const char *));
-static const char * getnum __P_((const char *, int *, int, int));
-static const char * getsecs __P_((const char *, long *));
-static const char * getoffset __P_((const char *, long *));
-static const char * getrule __P_((const char *, struct rule *));
-static const char * getzname __P_((const char *));
-static void gmtload __P_((struct state *));
-static void gmtsub __P_((const time_t *, long, struct tm *));
-static void localsub __P_((const time_t *, long, struct tm *));
-static void normalize __P_((int *, int *, int));
-static void settzname __P_((struct state *));
-static time_t time1 __P_((struct tm *, long));
-static time_t time2 __P_((struct tm *, long, int *));
-static void timesub __P_((const time_t *, long, const struct state *,
- struct tm *));
-static int tmcomp __P_((const struct tm *, const struct tm *));
-static time_t transtime __P_((time_t, int, const struct rule *, long));
-static int tzload __P_((const char *, struct state *));
-static int tzparse __P_((const char *, struct state *, int));
-static void tzset_basic __P_((void));
-static void tzsetwall_basic __P_((void));
-
-static pthread_mutex_t lcl_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t gmt_mutex = PTHREAD_MUTEX_INITIALIZER;
-static int lcl_is_set = FALSE;
-static int gmt_is_set = FALSE;
-static struct state lclmem;
-static struct state gmtmem;
-
-#define lclptr (&lclmem)
-#define gmtptr (&gmtmem)
-
-char * tzname[2] = {
- WILDABBR,
- WILDABBR
-};
-
-#ifdef USG_COMPAT
-time_t timezone = 0;
-int daylight = 0;
-#endif /* defined USG_COMPAT */
-
-#ifdef ALTZONE
-time_t altzone = 0;
-#endif /* defined ALTZONE */
-
-static long detzcode(const char * codep)
-{
- long result;
- int i;
-
- result = 0;
- for (i = 0; i < 4; ++i)
- result = (result << 8) | (codep[i] & 0xff);
- return result;
-}
-
-static void settzname(struct state * sp)
-{
- register int i;
-
- tzname[0] = WILDABBR;
- tzname[1] = WILDABBR;
-#ifdef USG_COMPAT
- daylight = 0;
- timezone = 0;
-#endif /* defined USG_COMPAT */
-#ifdef ALTZONE
- altzone = 0;
-#endif /* defined ALTZONE */
- for (i = 0; i < sp->typecnt; ++i) {
- register const struct ttinfo * const ttisp = &sp->ttis[i];
-
- tzname[ttisp->tt_isdst] =
- (char *) &sp->chars[ttisp->tt_abbrind];
-#ifdef USG_COMPAT
- if (ttisp->tt_isdst)
- daylight = 1;
- if (i == 0 || !ttisp->tt_isdst)
- timezone = -(ttisp->tt_gmtoff);
-#endif /* defined USG_COMPAT */
-#ifdef ALTZONE
- if (i == 0 || ttisp->tt_isdst)
- altzone = -(ttisp->tt_gmtoff);
-#endif /* defined ALTZONE */
- }
- /*
- ** And to get the latest zone names into tzname. . .
- */
- for (i = 0; i < sp->timecnt; ++i) {
- register const struct ttinfo * const ttisp =
- &sp->ttis[sp->types[i]];
-
- tzname[ttisp->tt_isdst] =
- (char *) &sp->chars[ttisp->tt_abbrind];
- }
-}
-
-static int tzload(const char * name, struct state * sp)
-{
- register const char * p;
- register int i;
- register int fid;
-
- if (name == NULL && (name = TZDEFAULT) == NULL)
- return -1;
- {
- char fullname[FILENAME_MAX + 1];
-
- if (name[0] == ':')
- ++name;
- if (name[0] != '/') {
- if ((p = TZDIR) == NULL)
- return -1;
- if ((strlen(p) + strlen(name) + 1) >= sizeof fullname)
- return -1;
- (void) strcpy(fullname, p);
- (void) strcat(fullname, "/");
- (void) strcat(fullname, name);
- name = fullname;
- }
- if ((fid = open(name, O_RDONLY)) == -1)
- return -1;
- }
- {
- register const struct tzhead * tzhp;
- char buf[sizeof *sp + sizeof *tzhp];
- int ttisstdcnt;
-
- i = read(fid, buf, sizeof buf);
- if (close(fid) != 0 || i < sizeof *tzhp)
- return -1;
- tzhp = (struct tzhead *) buf;
- ttisstdcnt = (int) detzcode(tzhp->tzh_ttisstdcnt);
- sp->leapcnt = (int) detzcode(tzhp->tzh_leapcnt);
- sp->timecnt = (int) detzcode(tzhp->tzh_timecnt);
- sp->typecnt = (int) detzcode(tzhp->tzh_typecnt);
- sp->charcnt = (int) detzcode(tzhp->tzh_charcnt);
- if (sp->leapcnt < 0 || sp->leapcnt > TZ_MAX_LEAPS ||
- sp->typecnt <= 0 || sp->typecnt > TZ_MAX_TYPES ||
- sp->timecnt < 0 || sp->timecnt > TZ_MAX_TIMES ||
- sp->charcnt < 0 || sp->charcnt > TZ_MAX_CHARS ||
- (ttisstdcnt != sp->typecnt && ttisstdcnt != 0))
- return -1;
- if (i < sizeof *tzhp +
- sp->timecnt * (4 + sizeof (char)) +
- sp->typecnt * (4 + 2 * sizeof (char)) +
- sp->charcnt * sizeof (char) +
- sp->leapcnt * 2 * 4 +
- ttisstdcnt * sizeof (char))
- return -1;
- p = buf + sizeof *tzhp;
- for (i = 0; i < sp->timecnt; ++i) {
- sp->ats[i] = detzcode(p);
- p += 4;
- }
- for (i = 0; i < sp->timecnt; ++i) {
- sp->types[i] = (unsigned char) *p++;
- if (sp->types[i] >= sp->typecnt)
- return -1;
- }
- for (i = 0; i < sp->typecnt; ++i) {
- register struct ttinfo * ttisp;
-
- ttisp = &sp->ttis[i];
- ttisp->tt_gmtoff = detzcode(p);
- p += 4;
- ttisp->tt_isdst = (unsigned char) *p++;
- if (ttisp->tt_isdst != 0 && ttisp->tt_isdst != 1)
- return -1;
- ttisp->tt_abbrind = (unsigned char) *p++;
- if (ttisp->tt_abbrind < 0 ||
- ttisp->tt_abbrind > sp->charcnt)
- return -1;
- }
- for (i = 0; i < sp->charcnt; ++i)
- sp->chars[i] = *p++;
- sp->chars[i] = '\0'; /* ensure '\0' at end */
- for (i = 0; i < sp->leapcnt; ++i) {
- register struct lsinfo * lsisp;
-
- lsisp = &sp->lsis[i];
- lsisp->ls_trans = detzcode(p);
- p += 4;
- lsisp->ls_corr = detzcode(p);
- p += 4;
- }
- for (i = 0; i < sp->typecnt; ++i) {
- register struct ttinfo * ttisp;
-
- ttisp = &sp->ttis[i];
- if (ttisstdcnt == 0)
- ttisp->tt_ttisstd = FALSE;
- else {
- ttisp->tt_ttisstd = *p++;
- if (ttisp->tt_ttisstd != TRUE &&
- ttisp->tt_ttisstd != FALSE)
- return -1;
- }
- }
- }
- return 0;
-}
-
-static const int mon_lengths[2][MONSPERYEAR] = {
- 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
- 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
-};
-
-static const int year_lengths[2] = {
- DAYSPERNYEAR, DAYSPERLYEAR
-};
-
-/*
-** Given a pointer into a time zone string, scan until a character that is not
-** a valid character in a zone name is found. Return a pointer to that
-** character.
-*/
-static const char * getzname(const char * strp)
-{
- register char c;
-
- while ((c = *strp) != '\0' && !isdigit(c) && c != ',' && c != '-' &&
- c != '+')
- ++strp;
- return strp;
-}
-
-/*
-** Given a pointer into a time zone string, extract a number from that string.
-** Check that the number is within a specified range; if it is not, return
-** NULL.
-** Otherwise, return a pointer to the first character not part of the number.
-*/
-
-static const char *getnum(const char * strp, int * nump, int min, int max)
-{
- char c;
- int num;
-
- if (strp == NULL || !isdigit(*strp))
- return NULL;
- num = 0;
- while ((c = *strp) != '\0' && isdigit(c)) {
- num = num * 10 + (c - '0');
- if (num > max)
- return NULL; /* illegal value */
- ++strp;
- }
- if (num < min)
- return NULL; /* illegal value */
- *nump = num;
- return strp;
-}
-
-/*
-** Given a pointer into a time zone string, extract a number of seconds,
-** in hh[:mm[:ss]] form, from the string.
-** If any error occurs, return NULL.
-** Otherwise, return a pointer to the first character not part of the number
-** of seconds.
-*/
-static const char * getsecs(const char * strp, long * secsp)
-{
- int num;
-
- strp = getnum(strp, &num, 0, HOURSPERDAY);
- if (strp == NULL)
- return NULL;
- *secsp = num * SECSPERHOUR;
- if (*strp == ':') {
- ++strp;
- strp = getnum(strp, &num, 0, MINSPERHOUR - 1);
- if (strp == NULL)
- return NULL;
- *secsp += num * SECSPERMIN;
- if (*strp == ':') {
- ++strp;
- strp = getnum(strp, &num, 0, SECSPERMIN - 1);
- if (strp == NULL)
- return NULL;
- *secsp += num;
- }
- }
- return strp;
-}
-
-/*
-** Given a pointer into a time zone string, extract an offset, in
-** [+-]hh[:mm[:ss]] form, from the string.
-** If any error occurs, return NULL.
-** Otherwise, return a pointer to the first character not part of the time.
-*/
-static const char * getoffset(const char * strp, long * offsetp)
-{
- int neg;
-
- if (*strp == '-') {
- neg = 1;
- ++strp;
- } else if (isdigit(*strp) || *strp++ == '+')
- neg = 0;
- else return NULL; /* illegal offset */
- strp = getsecs(strp, offsetp);
- if (strp == NULL)
- return NULL; /* illegal time */
- if (neg)
- *offsetp = -*offsetp;
- return strp;
-}
-
-/*
-** Given a pointer into a time zone string, extract a rule in the form
-** date[/time]. See POSIX section 8 for the format of "date" and "time".
-** If a valid rule is not found, return NULL.
-** Otherwise, return a pointer to the first character not part of the rule.
-*/
-static const char * getrule(const char * strp, struct rule * rulep)
-{
- if (*strp == 'J') {
- /*
- ** Julian day.
- */
- rulep->r_type = JULIAN_DAY;
- ++strp;
- strp = getnum(strp, &rulep->r_day, 1, DAYSPERNYEAR);
- } else if (*strp == 'M') {
- /*
- ** Month, week, day.
- */
- rulep->r_type = MONTH_NTH_DAY_OF_WEEK;
- ++strp;
- strp = getnum(strp, &rulep->r_mon, 1, MONSPERYEAR);
- if (strp == NULL)
- return NULL;
- if (*strp++ != '.')
- return NULL;
- strp = getnum(strp, &rulep->r_week, 1, 5);
- if (strp == NULL)
- return NULL;
- if (*strp++ != '.')
- return NULL;
- strp = getnum(strp, &rulep->r_day, 0, DAYSPERWEEK - 1);
- } else if (isdigit(*strp)) {
- /*
- ** Day of year.
- */
- rulep->r_type = DAY_OF_YEAR;
- strp = getnum(strp, &rulep->r_day, 0, DAYSPERLYEAR - 1);
- } else return NULL; /* invalid format */
- if (strp == NULL)
- return NULL;
- if (*strp == '/') {
- /*
- ** Time specified.
- */
- ++strp;
- strp = getsecs(strp, &rulep->r_time);
- } else rulep->r_time = 2 * SECSPERHOUR; /* default = 2:00:00 */
- return strp;
-}
-
-/*
-** Given the Epoch-relative time of January 1, 00:00:00 GMT, in a year, the
-** year, a rule, and the offset from GMT at the time that rule takes effect,
-** calculate the Epoch-relative time that rule takes effect.
-*/
-static time_t transtime(time_t janfirst, int year,
- const struct rule * rulep, long offset)
-{
- register int leapyear;
- register time_t value;
- register int i;
- int d, m1, yy0, yy1, yy2, dow;
-
- leapyear = isleap(year);
- switch (rulep->r_type) {
-
- case JULIAN_DAY:
- /*
- ** Jn - Julian day, 1 == January 1, 60 == March 1 even in leap
- ** years.
- ** In non-leap years, or if the day number is 59 or less, just
- ** add SECSPERDAY times the day number-1 to the time of
- ** January 1, midnight, to get the day.
- */
- value = janfirst + (rulep->r_day - 1) * SECSPERDAY;
- if (leapyear && rulep->r_day >= 60)
- value += SECSPERDAY;
- break;
-
- case DAY_OF_YEAR:
- /*
- ** n - day of year.
- ** Just add SECSPERDAY times the day number to the time of
- ** January 1, midnight, to get the day.
- */
- value = janfirst + rulep->r_day * SECSPERDAY;
- break;
-
- case MONTH_NTH_DAY_OF_WEEK:
- /*
- ** Mm.n.d - nth "dth day" of month m.
- */
- value = janfirst;
- for (i = 0; i < rulep->r_mon - 1; ++i)
- value += mon_lengths[leapyear][i] * SECSPERDAY;
-
- /*
- ** Use Zeller's Congruence to get day-of-week of first day of
- ** month.
- */
- m1 = (rulep->r_mon + 9) % 12 + 1;
- yy0 = (rulep->r_mon <= 2) ? (year - 1) : year;
- yy1 = yy0 / 100;
- yy2 = yy0 % 100;
- dow = ((26 * m1 - 2) / 10 +
- 1 + yy2 + yy2 / 4 + yy1 / 4 - 2 * yy1) % 7;
- if (dow < 0)
- dow += DAYSPERWEEK;
-
- /*
- ** "dow" is the day-of-week of the first day of the month. Get
- ** the day-of-month (zero-origin) of the first "dow" day of the
- ** month.
- */
- d = rulep->r_day - dow;
- if (d < 0)
- d += DAYSPERWEEK;
- for (i = 1; i < rulep->r_week; ++i) {
- if (d + DAYSPERWEEK >=
- mon_lengths[leapyear][rulep->r_mon - 1])
- break;
- d += DAYSPERWEEK;
- }
-
- /*
- ** "d" is the day-of-month (zero-origin) of the day we want.
- */
- value += d * SECSPERDAY;
- break;
- }
-
- /*
- ** "value" is the Epoch-relative time of 00:00:00 GMT on the day in
- ** question. To get the Epoch-relative time of the specified local
- ** time on that day, add the transition time and the current offset
- ** from GMT.
- */
- return value + rulep->r_time + offset;
-}
-
-/*
-** Given a POSIX section 8-style TZ string, fill in the rule tables as
-** appropriate.
-*/
-static int tzparse(const char * name, struct state * sp, int lastditch)
-{
- const char * stdname;
- const char * dstname;
- int stdlen;
- int dstlen;
- long stdoffset;
- long dstoffset;
- register time_t * atp;
- register unsigned char * typep;
- register char * cp;
- register int load_result;
-
- stdname = name;
- if (lastditch) {
- stdlen = strlen(name); /* length of standard zone name */
- name += stdlen;
- if (stdlen >= sizeof sp->chars)
- stdlen = (sizeof sp->chars) - 1;
- } else {
- name = getzname(name);
- stdlen = name - stdname;
- if (stdlen < 3)
- return -1;
- }
- if (*name == '\0')
- return -1;
- else {
- name = getoffset(name, &stdoffset);
- if (name == NULL)
- return -1;
- }
- load_result = tzload(TZDEFRULES, sp);
- if (load_result != 0)
- sp->leapcnt = 0; /* so, we're off a little */
- if (*name != '\0') {
- dstname = name;
- name = getzname(name);
- dstlen = name - dstname; /* length of DST zone name */
- if (dstlen < 3)
- return -1;
- if (*name != '\0' && *name != ',' && *name != ';') {
- name = getoffset(name, &dstoffset);
- if (name == NULL)
- return -1;
- } else dstoffset = stdoffset - SECSPERHOUR;
- if (*name == ',' || *name == ';') {
- struct rule start;
- struct rule end;
- register int year;
- register time_t janfirst;
- time_t starttime;
- time_t endtime;
-
- ++name;
- if ((name = getrule(name, &start)) == NULL)
- return -1;
- if (*name++ != ',')
- return -1;
- if ((name = getrule(name, &end)) == NULL)
- return -1;
- if (*name != '\0')
- return -1;
- sp->typecnt = 2; /* standard time and DST */
- /*
- ** Two transitions per year, from EPOCH_YEAR to 2037.
- */
- sp->timecnt = 2 * (2037 - EPOCH_YEAR + 1);
- if (sp->timecnt > TZ_MAX_TIMES)
- return -1;
- sp->ttis[0].tt_gmtoff = -dstoffset;
- sp->ttis[0].tt_isdst = 1;
- sp->ttis[0].tt_abbrind = stdlen + 1;
- sp->ttis[1].tt_gmtoff = -stdoffset;
- sp->ttis[1].tt_isdst = 0;
- sp->ttis[1].tt_abbrind = 0;
- atp = sp->ats;
- typep = sp->types;
- janfirst = 0;
- for (year = EPOCH_YEAR; year <= 2037; ++year) {
- starttime = transtime(janfirst, year, &start,
- stdoffset);
- endtime = transtime(janfirst, year, &end,
- dstoffset);
- if (starttime > endtime) {
- *atp++ = endtime;
- *typep++ = 1; /* DST ends */
- *atp++ = starttime;
- *typep++ = 0; /* DST begins */
- } else {
- *atp++ = starttime;
- *typep++ = 0; /* DST begins */
- *atp++ = endtime;
- *typep++ = 1; /* DST ends */
- }
- janfirst +=
- year_lengths[isleap(year)] * SECSPERDAY;
- }
- } else {
- int sawstd;
- int sawdst;
- long stdfix;
- long dstfix;
- long oldfix;
- int isdst;
- register int i;
-
- if (*name != '\0')
- return -1;
- if (load_result != 0)
- return -1;
- /*
- ** Compute the difference between the real and
- ** prototype standard and summer time offsets
- ** from GMT, and put the real standard and summer
- ** time offsets into the rules in place of the
- ** prototype offsets.
- */
- sawstd = FALSE;
- sawdst = FALSE;
- stdfix = 0;
- dstfix = 0;
- for (i = 0; i < sp->typecnt; ++i) {
- if (sp->ttis[i].tt_isdst) {
- oldfix = dstfix;
- dstfix =
- sp->ttis[i].tt_gmtoff + dstoffset;
- if (sawdst && (oldfix != dstfix))
- return -1;
- sp->ttis[i].tt_gmtoff = -dstoffset;
- sp->ttis[i].tt_abbrind = stdlen + 1;
- sawdst = TRUE;
- } else {
- oldfix = stdfix;
- stdfix =
- sp->ttis[i].tt_gmtoff + stdoffset;
- if (sawstd && (oldfix != stdfix))
- return -1;
- sp->ttis[i].tt_gmtoff = -stdoffset;
- sp->ttis[i].tt_abbrind = 0;
- sawstd = TRUE;
- }
- }
- /*
- ** Make sure we have both standard and summer time.
- */
- if (!sawdst || !sawstd)
- return -1;
- /*
- ** Now correct the transition times by shifting
- ** them by the difference between the real and
- ** prototype offsets. Note that this difference
- ** can be different in standard and summer time;
- ** the prototype probably has a 1-hour difference
- ** between standard and summer time, but a different
- ** difference can be specified in TZ.
- */
- isdst = FALSE; /* we start in standard time */
- for (i = 0; i < sp->timecnt; ++i) {
- register const struct ttinfo * ttisp;
-
- /*
- ** If summer time is in effect, and the
- ** transition time was not specified as
- ** standard time, add the summer time
- ** offset to the transition time;
- ** otherwise, add the standard time offset
- ** to the transition time.
- */
- ttisp = &sp->ttis[sp->types[i]];
- sp->ats[i] +=
- (isdst && !ttisp->tt_ttisstd) ?
- dstfix : stdfix;
- isdst = ttisp->tt_isdst;
- }
- }
- } else {
- dstlen = 0;
- sp->typecnt = 1; /* only standard time */
- sp->timecnt = 0;
- sp->ttis[0].tt_gmtoff = -stdoffset;
- sp->ttis[0].tt_isdst = 0;
- sp->ttis[0].tt_abbrind = 0;
- }
- sp->charcnt = stdlen + 1;
- if (dstlen != 0)
- sp->charcnt += dstlen + 1;
- if (sp->charcnt > sizeof sp->chars)
- return -1;
- cp = sp->chars;
- (void) strncpy(cp, stdname, stdlen);
- cp += stdlen;
- *cp++ = '\0';
- if (dstlen != 0) {
- (void) strncpy(cp, dstname, dstlen);
- *(cp + dstlen) = '\0';
- }
- return 0;
-}
-
-static void gmtload(struct state * sp)
-{
- if (tzload(GMT, sp) != 0)
- (void) tzparse(GMT, sp, TRUE);
-}
-
-static void tzset_basic()
-{
- const char * name;
- if ((name = getenv("TZ")) == NULL) {
- tzsetwall_basic();
- return;
- }
-
- if (*name == '\0') {
- /*
- ** User wants it fast rather than right.
- */
- lclptr->leapcnt = 0; /* so, we're off a little */
- lclptr->timecnt = 0;
- lclptr->ttis[0].tt_gmtoff = 0;
- lclptr->ttis[0].tt_abbrind = 0;
- (void) strcpy(lclptr->chars, GMT);
- } else {
- if (tzload(name, lclptr) != 0)
- if (name[0] == ':' || tzparse(name, lclptr, FALSE) != 0)
- (void) gmtload(lclptr);
- }
- lcl_is_set = TRUE;
- settzname(lclptr);
-}
-
-void tzset()
-{
- pthread_mutex_lock(&lcl_mutex);
- tzset_basic();
- pthread_mutex_unlock(&lcl_mutex);
-}
-
-static void tzsetwall_basic()
-{
- if (tzload((char *) NULL, lclptr) != 0)
- gmtload(lclptr);
- settzname(lclptr);
- lcl_is_set = TRUE;
-}
-
-void tzsetwall()
-{
- pthread_mutex_lock(&lcl_mutex);
- tzsetwall_basic();
- pthread_mutex_unlock(&lcl_mutex);
-}
-
-/*
-** The easy way to behave "as if no library function calls" localtime
-** is to not call it--so we drop its guts into "localsub", which can be
-** freely called. (And no, the PANS doesn't require the above behavior--
-** but it *is* desirable.)
-**
-** The unused offset argument is for the benefit of mktime variants.
-*/
-
-static void localsub(const time_t * timep, long offset, struct tm * tmp)
-{
- const struct ttinfo * ttisp;
- const time_t t = *timep;
- struct state * sp;
- int i;
-
- if (!lcl_is_set)
- tzset_basic();
- sp = lclptr;
- if (sp->timecnt == 0 || t < sp->ats[0]) {
- i = 0;
- while (sp->ttis[i].tt_isdst)
- if (++i >= sp->typecnt) {
- i = 0;
- break;
- }
- } else {
- for (i = 1; i < sp->timecnt; ++i)
- if (t < sp->ats[i])
- break;
- i = sp->types[i - 1];
- }
- ttisp = &sp->ttis[i];
- /*
- ** To get (wrong) behavior that's compatible with System V Release 2.0
- ** you'd replace the statement below with
- ** t += ttisp->tt_gmtoff;
- ** timesub(&t, 0L, sp, tmp);
- */
- timesub(&t, ttisp->tt_gmtoff, sp, tmp);
- tzname[tmp->tm_isdst] = (char *) &sp->chars[ttisp->tt_abbrind];
-#ifdef BSD_TM
- tmp->tm_zone = &sp->chars[ttisp->tt_abbrind];
-#endif
- tmp->tm_isdst = ttisp->tt_isdst;
-
- pthread_mutex_unlock(&lcl_mutex);
-}
-
-struct tm * localtime_r(const time_t * timep, struct tm * tm)
-{
- pthread_mutex_lock(&lcl_mutex);
- localsub(timep, 0L, tm);
- pthread_mutex_unlock(&lcl_mutex);
- return(tm);
-}
-
-struct tm * localtime(const time_t * timep)
-{
- static pthread_mutex_t localtime_mutex = PTHREAD_MUTEX_INITIALIZER;
- static pthread_key_t localtime_key = -1;
- struct tm * tm;
-
- pthread_mutex_lock(&localtime_mutex);
- if (localtime_key < 0) {
- if (pthread_key_create(&localtime_key, free) < 0) {
- pthread_mutex_unlock(&localtime_mutex);
- return(NULL);
- }
- }
- pthread_mutex_unlock(&localtime_mutex);
- if ((tm = pthread_getspecific(localtime_key)) == NULL) {
- if ((tm = (struct tm *)malloc(sizeof(struct tm))) == NULL) {
- return(NULL);
- }
- pthread_setspecific(localtime_key, tm);
- }
-
- pthread_mutex_lock(&lcl_mutex);
- localsub(timep, 0L, tm);
- pthread_mutex_unlock(&lcl_mutex);
- return tm;
-}
-
-
-/*
- * gmtsub is to gmtime as localsub is to localtime.
- *
- * Once set there is no need to lock the gmt_mutex to view gmtptr
- */
-static void gmtsub(const time_t * timep, long offset, struct tm * tmp)
-{
- pthread_mutex_lock(&gmt_mutex);
- if (gmt_is_set == FALSE) {
- gmt_is_set = TRUE;
- gmtload(gmtptr);
- }
- pthread_mutex_unlock(&gmt_mutex);
-
- timesub(timep, offset, gmtptr, tmp);
- /*
- ** Could get fancy here and deliver something such as
- ** "GMT+xxxx" or "GMT-xxxx" if offset is non-zero,
- ** but this is no time for a treasure hunt.
- */
-#ifdef BSD_TM
- if (offset != 0) {
- tmp->tm_zone = WILDABBR;
- } else {
- tmp->tm_zone = gmtptr->chars;
- }
-#endif
-}
-
-struct tm * gmtime_r(const time_t * timep, struct tm * tm)
-{
- gmtsub(timep, 0L, tm);
- return(tm);
-}
-
-struct tm * gmtime(const time_t * timep)
-{
- static pthread_mutex_t gmtime_mutex = PTHREAD_MUTEX_INITIALIZER;
- static pthread_key_t gmtime_key = -1;
- struct tm * tm;
-
- pthread_mutex_lock(&gmtime_mutex);
- if (gmtime_key < 0) {
- if (pthread_key_create(&gmtime_key, free) < 0) {
- pthread_mutex_unlock(&gmtime_mutex);
- return(NULL);
- }
- }
- pthread_mutex_unlock(&gmtime_mutex);
- if ((tm = pthread_getspecific(gmtime_key)) == NULL) {
- if ((tm = (struct tm *)malloc(sizeof(struct tm))) == NULL) {
- return(NULL);
- }
- pthread_setspecific(gmtime_key, tm);
- }
-
- gmtsub(timep, 0L, tm);
- return(tm);
-}
-
-static void timesub(const time_t * timep, long offset,
- const struct state * sp, struct tm * tmp)
-{
- register const struct lsinfo * lp;
- register long days;
- register long rem;
- register int y;
- register int yleap;
- register const int * ip;
- register long corr;
- register int hit;
- register int i;
-
- corr = 0;
- hit = FALSE;
- i = sp->leapcnt;
- while (--i >= 0) {
- lp = &sp->lsis[i];
- if (*timep >= lp->ls_trans) {
- if (*timep == lp->ls_trans)
- hit = ((i == 0 && lp->ls_corr > 0) ||
- lp->ls_corr > sp->lsis[i - 1].ls_corr);
- corr = lp->ls_corr;
- break;
- }
- }
- days = *timep / SECSPERDAY;
- rem = *timep % SECSPERDAY;
-#ifdef mc68k
- if (*timep == 0x80000000) {
- /*
- ** A 3B1 muffs the division on the most negative number.
- */
- days = -24855;
- rem = -11648;
- }
-#endif /* mc68k */
- rem += (offset - corr);
- while (rem < 0) {
- rem += SECSPERDAY;
- --days;
- }
- while (rem >= SECSPERDAY) {
- rem -= SECSPERDAY;
- ++days;
- }
- tmp->tm_hour = (int) (rem / SECSPERHOUR);
- rem = rem % SECSPERHOUR;
- tmp->tm_min = (int) (rem / SECSPERMIN);
- tmp->tm_sec = (int) (rem % SECSPERMIN);
- if (hit)
- /*
- ** A positive leap second requires a special
- ** representation. This uses "... ??:59:60".
- */
- ++(tmp->tm_sec);
- tmp->tm_wday = (int) ((EPOCH_WDAY + days) % DAYSPERWEEK);
- if (tmp->tm_wday < 0)
- tmp->tm_wday += DAYSPERWEEK;
- y = EPOCH_YEAR;
- if (days >= 0)
- for ( ; ; ) {
- yleap = isleap(y);
- if (days < (long) year_lengths[yleap])
- break;
- ++y;
- days = days - (long) year_lengths[yleap];
- }
- else do {
- --y;
- yleap = isleap(y);
- days = days + (long) year_lengths[yleap];
- } while (days < 0);
- tmp->tm_year = y - TM_YEAR_BASE;
- tmp->tm_yday = (int) days;
- ip = mon_lengths[yleap];
- for (tmp->tm_mon = 0; days >= (long) ip[tmp->tm_mon]; ++(tmp->tm_mon))
- days = days - (long) ip[tmp->tm_mon];
- tmp->tm_mday = (int) (days + 1);
- tmp->tm_isdst = 0;
-#ifdef BSD_TM
- tmp->tm_gmtoff = offset;
-#endif
-}
-
-/*
- * A la X3J11
- *
- * Made thread safe by using thread specific data
- */
-char * asctime_r(const struct tm * timeptr, char * result)
-{
- static const char wday_name[DAYSPERWEEK][3] = {
- "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
- };
- static const char mon_name[MONSPERYEAR][3] = {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
- };
- (void) sprintf(result, "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %d\n",
- wday_name[timeptr->tm_wday],
- mon_name[timeptr->tm_mon],
- timeptr->tm_mday, timeptr->tm_hour,
- timeptr->tm_min, timeptr->tm_sec,
- TM_YEAR_BASE + timeptr->tm_year);
- return(result);
-}
-
-char * asctime(const struct tm * timeptr)
-{
- static pthread_mutex_t asctime_mutex = PTHREAD_MUTEX_INITIALIZER;
- static pthread_key_t asctime_key = -1;
- char * result;
-
- pthread_mutex_lock(&asctime_mutex);
- if (asctime_key < 0) {
- if (pthread_key_create(&asctime_key, free) < 0) {
- pthread_mutex_unlock(&asctime_mutex);
- return(NULL);
- }
- }
- pthread_mutex_unlock(&asctime_mutex);
- if ((result = pthread_getspecific(asctime_key)) == NULL) {
- if ((result = malloc(26)) == NULL) {
- return(NULL);
- }
- pthread_setspecific(asctime_key, result);
- }
-
- return(asctime_r(timeptr, result));
-}
-
-char * ctime_r(const time_t * timep, char * buf)
-{
- struct tm tm;
- return asctime_r(localtime_r(timep, &tm), buf);
-}
-
-char * ctime(const time_t * timep)
-{
- struct tm tm;
- return asctime(localtime_r(timep, &tm));
-}
-
-/*
-** Adapted from code provided by Robert Elz, who writes:
-** The "best" way to do mktime I think is based on an idea of Bob
-** Kridle's (so its said...) from a long time ago. (mtxinu!kridle now).
-** It does a binary search of the time_t space. Since time_t's are
-** just 32 bits, its a max of 32 iterations (even at 64 bits it
-** would still be very reasonable).
-*/
-static void normalize(int * tensptr,int * unitsptr, int base)
-{
- if (*unitsptr >= base) {
- *tensptr += *unitsptr / base;
- *unitsptr %= base;
- } else if (*unitsptr < 0) {
- --*tensptr;
- *unitsptr += base;
- if (*unitsptr < 0) {
- *tensptr -= 1 + (-*unitsptr) / base;
- *unitsptr = base - (-*unitsptr) % base;
- }
- }
-}
-
-static int tmcomp(const struct tm * atmp, const struct tm * btmp)
-{
- register int result;
-
- if ((result = (atmp->tm_year - btmp->tm_year)) == 0 &&
- (result = (atmp->tm_mon - btmp->tm_mon)) == 0 &&
- (result = (atmp->tm_mday - btmp->tm_mday)) == 0 &&
- (result = (atmp->tm_hour - btmp->tm_hour)) == 0 &&
- (result = (atmp->tm_min - btmp->tm_min)) == 0)
- result = atmp->tm_sec - btmp->tm_sec;
- return result;
-}
-
-static time_t time2(struct tm * tmp, long offset, int * okayp)
-{
- register const struct state * sp;
- register int dir;
- register int bits;
- register int i, j ;
- register int saved_seconds;
- time_t newt;
- time_t t;
- struct tm yourtm, mytm;
-
- *okayp = FALSE;
- yourtm = *tmp;
- if (yourtm.tm_sec >= SECSPERMIN + 2 || yourtm.tm_sec < 0)
- normalize(&yourtm.tm_min, &yourtm.tm_sec, SECSPERMIN);
- normalize(&yourtm.tm_hour, &yourtm.tm_min, MINSPERHOUR);
- normalize(&yourtm.tm_mday, &yourtm.tm_hour, HOURSPERDAY);
- normalize(&yourtm.tm_year, &yourtm.tm_mon, MONSPERYEAR);
- while (yourtm.tm_mday <= 0) {
- --yourtm.tm_year;
- yourtm.tm_mday +=
- year_lengths[isleap(yourtm.tm_year + TM_YEAR_BASE)];
- }
- for ( ; ; ) {
- i = mon_lengths[isleap(yourtm.tm_year +
- TM_YEAR_BASE)][yourtm.tm_mon];
- if (yourtm.tm_mday <= i)
- break;
- yourtm.tm_mday -= i;
- if (++yourtm.tm_mon >= MONSPERYEAR) {
- yourtm.tm_mon = 0;
- ++yourtm.tm_year;
- }
- }
- saved_seconds = yourtm.tm_sec;
- yourtm.tm_sec = 0;
- /*
- ** Calculate the number of magnitude bits in a time_t
- ** (this works regardless of whether time_t is
- ** signed or unsigned, though lint complains if unsigned).
- */
- for (bits = 0, t = 1; t > 0; ++bits, t <<= 1)
- ;
- /*
- ** If time_t is signed, then 0 is the median value,
- ** if time_t is unsigned, then 1 << bits is median.
- */
- t = (t < 0) ? 0 : ((time_t) 1 << bits);
- for ( ; ; ) {
- localsub(&t, offset, &mytm);
- dir = tmcomp(&mytm, &yourtm);
- if (dir != 0) {
- if (bits-- < 0)
- return NOTOK;
- if (bits < 0)
- --t;
- else if (dir > 0)
- t -= (time_t) 1 << bits;
- else t += (time_t) 1 << bits;
- continue;
- }
- if (yourtm.tm_isdst < 0 || mytm.tm_isdst == yourtm.tm_isdst)
- break;
- /*
- ** Right time, wrong type.
- ** Hunt for right time, right type.
- ** It's okay to guess wrong since the guess
- ** gets checked.
- */
- sp = lclptr;
- for (i = 0; i < sp->typecnt; ++i) {
- if (sp->ttis[i].tt_isdst != yourtm.tm_isdst)
- continue;
- for (j = 0; j < sp->typecnt; ++j) {
- if (sp->ttis[j].tt_isdst == yourtm.tm_isdst)
- continue;
- newt = t + sp->ttis[j].tt_gmtoff -
- sp->ttis[i].tt_gmtoff;
- localsub(&newt, offset, &mytm);
- if (tmcomp(&mytm, &yourtm) != 0)
- continue;
- if (mytm.tm_isdst != yourtm.tm_isdst)
- continue;
- /*
- ** We have a match.
- */
- t = newt;
- goto label;
- }
- }
- return NOTOK;
- }
-label:
- t += saved_seconds;
- localsub(&t, offset, tmp);
- *okayp = TRUE;
- return t;
-}
-
-static time_t time1(struct tm * tmp, long offset)
-{
- const struct state * sp;
- int samei, otheri, okay;
- time_t t;
-
- if (tmp->tm_isdst > 1)
- tmp->tm_isdst = 1;
- t = time2(tmp, offset, &okay);
- if (okay || tmp->tm_isdst < 0)
- return t;
- /*
- ** We're supposed to assume that somebody took a time of one type
- ** and did some math on it that yielded a "struct tm" that's bad.
- ** We try to divine the type they started from and adjust to the
- ** type they need.
- */
- sp = lclptr;
- for (samei = 0; samei < sp->typecnt; ++samei) {
- if (sp->ttis[samei].tt_isdst != tmp->tm_isdst)
- continue;
- for (otheri = 0; otheri < sp->typecnt; ++otheri) {
- if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst)
- continue;
- tmp->tm_sec += sp->ttis[otheri].tt_gmtoff -
- sp->ttis[samei].tt_gmtoff;
- tmp->tm_isdst = !tmp->tm_isdst;
- t = time2(tmp, offset, &okay);
- if (okay)
- return t;
- tmp->tm_sec -= sp->ttis[otheri].tt_gmtoff -
- sp->ttis[samei].tt_gmtoff;
- tmp->tm_isdst = !tmp->tm_isdst;
- }
- }
- return NOTOK;
-}
-
-time_t mktime(struct tm * tmp)
-{
- time_t mktime_return_value;
-
- pthread_mutex_lock(&lcl_mutex);
- if (lcl_is_set == FALSE) {
- tzset_basic();
- }
- mktime_return_value = time1(tmp, 0L);
- pthread_mutex_unlock(&lcl_mutex);
- return(mktime_return_value);
-}
diff --git a/lib/libpthread/gen/difftime.c b/lib/libpthread/gen/difftime.c
deleted file mode 100644
index cddd896e04a..00000000000
--- a/lib/libpthread/gen/difftime.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 1989 The Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)difftime.c 5.2 (Berkeley) 6/1/90";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/types.h>
-
-double
-difftime(time1, time0)
- time_t time1, time0;
-{
- return(time1 - time0);
-}
diff --git a/lib/libpthread/gen/directory.c b/lib/libpthread/gen/directory.c
deleted file mode 100644
index d189280fc1f..00000000000
--- a/lib/libpthread/gen/directory.c
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)closedir.c 5.9 (Berkeley) 2/23/91";
-#endif /* LIBC_SCCS and not lint */
-
-/*
- * One of these structures is malloced to describe the current directory
- * position each time telldir is called. It records the current magic
- * cookie returned by getdirentries and the offset within the buffer
- * associated with that return value.
- */
-struct ddloc {
- struct ddloc *loc_next;/* next structure in list */
- long loc_index; /* key associated with structure */
- long loc_seek; /* magic cookie returned by getdirentries */
- long loc_loc; /* offset of entry in buffer */
-};
-
-static long dd_loccnt = 0; /* Index of entry for sequential telldir's */
-
-#include <errno.h>
-#include <pthread.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <dirent.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-
-
-/*
- * close a directory.
- */
-int closedir(DIR * dirp)
-{
- void *ptr, *nextptr;
- int fd;
-
- pthread_mutex_lock (dirp->dd_lock);
- fd = dirp->dd_fd;
- dirp->dd_fd = -1;
- dirp->dd_loc = 0;
- for (ptr = (void *)dirp->dd_ddloc; ptr; ptr = nextptr) {
- nextptr = (void *)(((struct ddloc *)ptr)->loc_next);
- free(ptr);
- }
- for (ptr = (void *)dirp->dd_dp; ptr; ptr = nextptr) {
- nextptr = (void *)(((struct __dirent *)ptr)->next);
- free(ptr);
- }
- free((void *)dirp->dd_buf);
- free (dirp->dd_lock);
- free((void *)dirp);
- return(machdep_sys_close(fd));
-}
-
-/*
- * open a directory.
- */
-DIR * opendir(const char * name)
-{
- DIR *dirp;
- int fd;
-
- if ((fd = machdep_sys_open(name, 0)) < 0)
- return NULL;
- if (machdep_sys_fcntl(fd, F_SETFD, 1) < 0 ||
- (dirp = (DIR *)malloc(sizeof(DIR))) == NULL) {
- machdep_sys_close (fd);
- return NULL;
- }
- dirp->dd_lock = (pthread_mutex_t*) malloc (sizeof (pthread_mutex_t));
- pthread_mutex_init (dirp->dd_lock, 0);
- /*
- * If CLSIZE is an exact multiple of DIRBLKSIZ, use a CLSIZE
- * buffer that it cluster boundary aligned.
- * Hopefully this can be a big win someday by allowing page trades
- * to user space to be done by getdirentries()
- */
-#ifndef CLSIZE
-#define CLSIZE 1
-#endif
- if ((CLSIZE % DIRBLKSIZ) == 0) {
- dirp->dd_buf = malloc(CLSIZE);
- dirp->dd_len = CLSIZE;
- } else {
- dirp->dd_buf = malloc(DIRBLKSIZ);
- dirp->dd_len = DIRBLKSIZ;
- }
- if (dirp->dd_buf == NULL) {
- machdep_sys_close (fd);
- free((void *)dirp);
- return NULL;
- }
-
- dirp->dd_ddloc = NULL;
- dirp->dd_dp = NULL;
- dirp->dd_seek = 0;
- dirp->dd_loc = 0;
- dirp->dd_fd = fd;
- return(dirp);
-}
-
-/*
- * The real work in gettint the next entry in a directory.
- * Return
- * NULL on End of directory
- * &ERR on Error
- * dp on valid directory;
- */
-static struct dirent ERR;
-static struct dirent * readdir_basic(DIR * dirp)
-{
- register struct dirent *dp;
-
- for (;;) {
- if (dirp->dd_loc == 0) {
- dirp->dd_size = machdep_sys_getdirentries(dirp->dd_fd,
- dirp->dd_buf, dirp->dd_len, &dirp->dd_seek);
- if (dirp->dd_size < 0)
- return(&ERR);
- if (dirp->dd_size == 0)
- return(NULL);
- }
- if (dirp->dd_loc >= dirp->dd_size) {
- dirp->dd_loc = 0;
- continue;
- }
- dp = (struct dirent *)(dirp->dd_buf + dirp->dd_loc);
- if ((long)dp & 03) /* bogus pointer check */
- return(&ERR);
- if (dp->d_reclen <= 0 ||
- dp->d_reclen > dirp->dd_len + 1 - dirp->dd_loc)
- return(&ERR);
- dirp->dd_loc += dp->d_reclen;
- if (dp->d_ino == 0)
- continue;
- return(dp);
- }
-}
-
-/*
- * POSIX.1 version of getting the next entry in a directory.
- */
-struct dirent * readdir(DIR * dirp)
-{
- register struct dirent * rp;
- struct __dirent * my__dp;
- pthread_t self;
-
- pthread_mutex_lock (dirp->dd_lock);
-
- self = pthread_self();
- /* Allocate space and return */
- for (my__dp = dirp->dd_dp; my__dp; my__dp = my__dp->next) {
- if (pthread_equal(my__dp->owner, self)) {
- break;
- }
- }
- if (my__dp == NULL) {
- if (my__dp = (struct __dirent *)(malloc(sizeof(struct __dirent)))) {
- my__dp->next = dirp->dd_dp;
- dirp->dd_dp = my__dp;
- my__dp->owner = self;
- } else {
- pthread_mutex_unlock (dirp->dd_lock);
- return(NULL);
- }
- }
- if (rp = readdir_basic(dirp)) {
- if (rp != &ERR) {
- memcpy(& (my__dp->data), rp, sizeof(struct dirent));
- rp = & (my__dp->data);
- } else {
- rp = NULL;
- }
- }
- pthread_mutex_unlock (dirp->dd_lock);
- return(rp);
-}
-
-/*
- * POSIX.4a version of getting the next entry in a directory.
- */
-int readdir_r(DIR * dirp, struct dirent * entry, struct dirent ** result)
-{
- register struct dirent * rp;
- int ret;
-
- pthread_mutex_lock (dirp->dd_lock);
- rp = readdir_basic(dirp);
- if (rp != &ERR) {
- if (rp) {
- memcpy(entry, rp, sizeof(struct dirent));
- *result = entry;
- ret = 0;
- } else {
- *result = NULL;
- ret = 0;
- }
- } else {
- /* Should get it from errno */
- ret = EBADF;
- }
- pthread_mutex_unlock (dirp->dd_lock);
- return(ret);
-}
-
-void rewinddir(DIR * dirp)
-{
- pthread_mutex_lock (dirp->dd_lock);
- (void)machdep_sys_lseek(dirp->dd_fd, 0, 0);
- dirp->dd_seek = 0;
- dirp->dd_loc = 0;
- pthread_mutex_unlock (dirp->dd_lock);
-}
-
-/*
- * Seek to an entry in a directory.
- * _seekdir is in telldir.c so that it can share opaque data structures.
- *
- * Use the POSIX reentrant safe readdir_r to simplify varifying POSIX
- * thread-safe compliance.
- */
-void seekdir(DIR * dirp, long loc)
-{
- register struct ddloc ** prevlp;
- register struct ddloc * lp;
- struct dirent * dp;
- struct dirent de;
-
- pthread_mutex_lock (dirp->dd_lock);
- prevlp = (struct ddloc **)&(dirp->dd_ddloc);
- lp = *prevlp;
- while (lp != NULL) {
- if (lp->loc_index == loc)
- break;
- prevlp = &lp->loc_next;
- lp = lp->loc_next;
- }
- if (lp) {
- if (lp->loc_seek != dirp->dd_seek) {
- if (machdep_sys_lseek(dirp->dd_fd, lp->loc_seek, 0) < 0) {
- *prevlp = lp->loc_next;
- pthread_mutex_unlock (dirp->dd_lock);
- return;
- }
- dirp->dd_seek = lp->loc_seek;
- dirp->dd_loc = 0;
- while (dirp->dd_loc < lp->loc_loc) {
- if (readdir_r(dirp, &de, &dp)) {
- *prevlp = lp->loc_next;
- break;
- }
- }
- }
- }
- pthread_mutex_unlock (dirp->dd_lock);
-}
-
-/*
- * return a pointer into a directory
- */
-long telldir(DIR *dirp)
-{
- struct ddloc *lp, **fakeout;
- int ret;
-
- pthread_mutex_lock (dirp->dd_lock);
- if (lp = (struct ddloc *)malloc(sizeof(struct ddloc))) {
- lp->loc_index = dd_loccnt++;
- lp->loc_seek = dirp->dd_seek;
- lp->loc_loc = dirp->dd_loc;
- lp->loc_next = dirp->dd_ddloc;
-
- /* Compiler won't let us change anything pointed to by db directly */
- /* So we fake to the left and do it anyway */
- /* Wonder if the compile optomizes it to the correct solution */
- fakeout = (struct ddloc **)&(dirp->dd_ddloc);
- *fakeout = lp;
-
- ret = lp->loc_index;
- } else {
- ret = -1;
- }
- pthread_mutex_unlock (dirp->dd_lock);
- return(ret);
-}
-
diff --git a/lib/libpthread/gen/eprintf.c b/lib/libpthread/gen/eprintf.c
deleted file mode 100644
index bcc65757bd4..00000000000
--- a/lib/libpthread/gen/eprintf.c
+++ /dev/null
@@ -1,18 +0,0 @@
-/* This function is a replacement for the version in libgcc.a. This
- is needed because typically libgcc.a won't have been compiled
- against the threads library, so its references to "stderr" will
- come out wrong. */
-
-#include <stdio.h>
-
-void __eprintf (const char *fmt, const char *expr, int line, const char *file)
-{
- /* Considering the very special circumstances where this function
- would be called, perhaps we might want to disable the thread
- scheduler and break any existing locks on stderr? Well, maybe if
- we could be sure that stderr was in a useable state... */
- fprintf (stderr, fmt, expr, line, file);
- fflush (stderr);
-
- abort ();
-}
diff --git a/lib/libpthread/gen/getcwd.c b/lib/libpthread/gen/getcwd.c
deleted file mode 100644
index 333ad902263..00000000000
--- a/lib/libpthread/gen/getcwd.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Copyright (c) 1989, 1991 The Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)getcwd.c 5.11 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: getcwd.c,v 1.1 1998/07/21 13:19:02 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <dirent.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#define ISDOT(dp) \
- (dp->d_name[0] == '.' && (dp->d_name[1] == '\0' || \
- dp->d_name[1] == '.' && dp->d_name[2] == '\0'))
-
-
-/* Only use reentrant safe routines to simplify varifying POSIX thread-safe
- * compliance. (mevans).
- */
-
-char *
-getcwd(pt, size)
- char *pt;
- size_t size;
-{
- register DIR *dir;
- register dev_t dev;
- register ino_t ino;
- register int first;
- register char *bpt, *bup;
- struct stat s;
- struct dirent *dp;
- struct dirent de;
- dev_t root_dev;
- ino_t root_ino;
- size_t ptsize, upsize;
- int save_errno;
- char *ept, *eup, *up;
- int namelen;
-
- /*
- * If no buffer specified by the user, allocate one as necessary.
- * If a buffer is specified, the size has to be non-zero. The path
- * is built from the end of the buffer backwards.
- */
- if (pt) {
- ptsize = 0;
- if (!size) {
- errno = EINVAL;
- return((char *)NULL);
- }
- ept = pt + size;
- } else {
- if (!(pt = (char *)malloc(ptsize = 1024 - 4)))
- return((char *)NULL);
- ept = pt + ptsize;
- }
- bpt = ept - 1;
- *bpt = '\0';
-
- /*
- * Allocate bytes (1024 - malloc space) for the string of "../"'s.
- * Should always be enough (it's 340 levels). If it's not, allocate
- * as necessary. Special * case the first stat, it's ".", not "..".
- */
- if (!(up = (char *)malloc(upsize = 1024 - 4)))
- goto err;
- eup = up + MAXPATHLEN;
- bup = up;
- up[0] = '.';
- up[1] = '\0';
-
- /* Save root values, so know when to stop. */
- if (stat("/", &s))
- goto err;
- root_dev = s.st_dev;
- root_ino = s.st_ino;
-
- SET_ERRNO(0);
-
- for (first = 1;; first = 0) {
- /* Stat the current level. */
- if (lstat(up, &s))
- goto err;
-
- /* Save current node values. */
- ino = s.st_ino;
- dev = s.st_dev;
-
- /* Check for reaching root. */
- if (root_dev == dev && root_ino == ino) {
- *--bpt = '/';
- /*
- * It's unclear that it's a requirement to copy the
- * path to the beginning of the buffer, but it's always
- * been that way and stuff would probably break.
- */
- /* XXX was bcopy */
- (void)memcpy(pt, bpt, ept - bpt);
- free(up);
- return(pt);
- }
-
- /*
- * Build pointer to the parent directory, allocating memory
- * as necessary. Max length is 3 for "../", the largest
- * possible component name, plus a trailing NULL.
- */
- if (bup + 3 + MAXNAMLEN + 1 >= eup) {
- if (!(up = (char *)realloc(up, upsize *= 2)))
- goto err;
- eup = up + upsize;
- }
- *bup++ = '.';
- *bup++ = '.';
- *bup = '\0';
-
- /* Open and stat parent directory. */
- /* XXX opendir() returns kernel fd's instead of
- pthread fd's for some odd reason, so we must
- break the abstraction boundry here as well or
- fix everything in opendir et al. SNL */
- if (!(dir = opendir(up)) ||
- machdep_sys_fstat(dirfd(dir), &s))
- goto err;
-
- /* Add trailing slash for next directory. */
- *bup++ = '/';
-
- /*
- * If it's a mount point, have to stat each element because
- * the inode number in the directory is for the entry in the
- * parent directory, not the inode number of the mounted file.
- */
- save_errno = 0;
- if (s.st_dev == dev) {
- for (;;) {
- if (readdir_r(dir, &de, &dp))
- goto notfound;
- if (dp->d_fileno == ino)
- break;
- }
- } else
- for (;;) {
- if (readdir_r(dir, &de, &dp))
- goto notfound;
- if (ISDOT(dp))
- continue;
- memcpy(bup, dp->d_name, strlen(dp->d_name) + 1);
-
- /* Save the first error for later. */
- if (lstat(up, &s)) {
- if (!save_errno)
- save_errno = errno;
- SET_ERRNO(0);
- continue;
- }
- if (s.st_dev == dev && s.st_ino == ino)
- break;
- }
-
- /*
- * Check for length of the current name, preceding slash,
- * leading slash.
- */
- namelen = strlen(dp->d_name);
- if (bpt - pt <= namelen + (first ? 1 : 2)) {
- size_t len, off;
-
- if (!ptsize) {
- SET_ERRNO(ERANGE);
- goto err;
- }
- off = bpt - pt;
- len = ept - bpt;
- if (!(pt = (char *)realloc(pt, ptsize *= 2)))
- goto err;
- bpt = pt + off;
- ept = pt + ptsize;
- /* XXX was bcopy */
- (void)memcpy(ept - len, bpt, len);
- bpt = ept - len;
- }
- if (!first)
- *--bpt = '/';
- bpt -= namelen;
- memcpy(bpt, dp->d_name, namelen);
- (void)closedir(dir);
-
- /* Truncate any file name. */
- *bup = '\0';
- }
-
-notfound:
- /*
- * If readdir set errno, use it, not any saved error; otherwise,
- * didn't find the current directory in its parent directory, set
- * errno to ENOENT.
- */
- if (!errno) {
- if (!save_errno)
- save_errno = ENOENT;
- SET_ERRNO(save_errno);
- }
- /* FALLTHROUGH */
-err:
- if (ptsize)
- free(pt);
- free(up);
- return((char *)NULL);
-}
diff --git a/lib/libpthread/gen/getpwent.c b/lib/libpthread/gen/getpwent.c
deleted file mode 100644
index 7bcb2cbd610..00000000000
--- a/lib/libpthread/gen/getpwent.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 1984 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getpwent.c 5.2 (Berkeley) 3/9/86";
-#endif
-
-#include <pthread.h>
-#include <stdio.h>
-#include <pwd.h>
-#include "pwd_internal.h"
-
-void
-setpwent()
-{
- pwf_context_t *_data;
-
- _data = _pw_get_data();
-
- if (_data) {
- if (_data->pwf == NULL)
- _data->pwf = fopen(_data->pw_file, "r");
- else
- rewind(_data->pwf);
- }
-}
-
-void
-endpwent()
-{
- pwf_context_t *_data;
-
- _data = _pw_get_data();
-
- if (_data) {
- if (_data->pwf != NULL) {
- fclose(_data->pwf);
- _data->pwf = NULL;
- }
-#ifdef DBM_PWD_SUPPORT
- if (_data->pw_db != (DBM *)0) {
- dbm_close(_data->pw_db);
- _data->pw_db = (DBM *)0;
- _data->pw_stayopen = 0;
- }
-#endif /* DBM_PWD_SUPPORT */
- }
-}
-
-static char *
-pwskip(p)
- char *p;
-{
- while (*p && *p != ':' && *p != '\n')
- ++p;
- if (*p)
- *p++ = 0;
- return(p);
-}
-
-struct passwd *
-getpwent()
-{
- pwf_context_t *_data;
- char *p;
-
- _data = _pw_get_data();
- if (!_data)
- return 0;
-
- if (_data->pwf == NULL) {
- if ((_data->pwf = fopen(_data->pw_file, "r" )) == NULL)
- return(0);
- }
- p = fgets(_data->line, BUFSIZ, _data->pwf);
- if (p == NULL)
- return(0);
- _data->passwd.pw_name = p;
- p = pwskip(p);
- _data->passwd.pw_passwd = p;
- p = pwskip(p);
- _data->passwd.pw_uid = atoi(p);
- p = pwskip(p);
- _data->passwd.pw_gid = atoi(p);
- p = pwskip(p);
- _data->passwd.pw_gecos = p;
- p = pwskip(p);
- _data->passwd.pw_dir = p;
- p = pwskip(p);
- _data->passwd.pw_shell = p;
- while (*p && *p != '\n')
- p++;
- *p = '\0';
- return(&_data->passwd);
-}
-
-void
-setpwfile(file)
- char *file;
-{
- pwf_context_t *_data;
-
- _data = _pw_get_data();
- if (_data)
- _data->pw_file = file;
-}
diff --git a/lib/libpthread/gen/getpwnamuid.c b/lib/libpthread/gen/getpwnamuid.c
deleted file mode 100644
index 0e87081b7a9..00000000000
--- a/lib/libpthread/gen/getpwnamuid.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getpwnamuid.c 5.3 (Berkeley) 12/21/87";
-#endif
-
-#include <stdio.h>
-#include <pwd.h>
-#include <sys/file.h>
-#include "pwd_internal.h"
-
-/*
- * The following are shared with getpwent.c
- */
-
-#ifdef DBM_PWD_SUPPORT
-static struct passwd *
-fetchpw(key)
- datum key;
-{
- char *cp, *tp;
- pwf_context_t *_data;
-
- _data = _pw_get_data();
- if (!_data)
- return 0;
- if (key.dptr == 0)
- return ((struct passwd *)NULL);
- key = dbm_fetch(_data->pw_db, key);
- if (key.dptr == 0)
- return ((struct passwd *)NULL);
- cp = key.dptr;
- tp = _data->line;
-
-#define EXPAND(e) _data->passwd.e = tp; while (*tp++ = *cp++);
- EXPAND(pw_name);
- EXPAND(pw_passwd);
- memcpy((char *)&_data->passwd.pw_uid, cp, sizeof (int));
- cp += sizeof (int);
- memcpy((char *)&_data->passwd.pw_gid, cp, sizeof (int));
- cp += sizeof (int);
- EXPAND(pw_gecos);
- EXPAND(pw_dir);
- EXPAND(pw_shell);
- return (&_data->passwd);
-}
-#endif /* DBM_PWD_SUPPORT */
-
-struct passwd *
-getpwnam(nam)
- const char *nam;
-{
-#ifdef DBM_PWD_SUPPORT
- datum key;
-#endif
- struct passwd *pw, *getpwent();
- pwf_context_t *_data;
-
- _data = _pw_get_data();
- if (!_data)
- return 0;
-
-#ifdef DBM_PWD_SUPPORT
- if (_data->pw_db == (DBM *)0 &&
- (_data->pw_db = dbm_open(_data->pw_file, O_RDONLY)) == (DBM *)0) {
- oldcode:
-#endif
- setpwent();
- while ((pw = getpwent()) && strcmp(nam, pw->pw_name))
- ;
- if (!_data->pw_stayopen)
- endpwent();
- return (pw);
-#ifdef DBM_PWD_SUPPORT
- }
- if (flock(dbm_dirfno(_data->pw_db), LOCK_SH) < 0) {
- dbm_close(_data->pw_db);
- _data->pw_db = (DBM *)0;
- goto oldcode;
- }
- key.dptr = nam;
- key.dsize = strlen(nam);
- pw = fetchpw(key);
- (void) flock(dbm_dirfno(_data->pw_db), LOCK_UN);
- if (!_data->pw_stayopen) {
- dbm_close(_data->pw_db);
- _data->pw_db = (DBM *)0;
- }
- return (pw);
-#endif
-}
-
-struct passwd *
-getpwuid(uid)
- uid_t uid;
-{
-#ifdef DBM_PWD_SUPPORT
- datum key;
-#endif
- struct passwd *pw, *getpwent();
- pwf_context_t *_data;
-
- _data = _pw_get_data();
- if (!_data)
- return 0;
-#ifdef DBM_PWD_SUPPORT
- if (_data->pw_db == (DBM *)0 &&
- (_data->pw_db = dbm_open(_data->pw_file, O_RDONLY)) == (DBM *)0) {
- oldcode:
-#endif
- setpwent();
- while ((pw = getpwent()) && pw->pw_uid != uid)
- ;
- if (!_data->pw_stayopen)
- endpwent();
- return (pw);
-#ifdef DBM_PWD_SUPPORT
- }
- if (flock(dbm_dirfno(_data->pw_db), LOCK_SH) < 0) {
- dbm_close(_data->pw_db);
- _data->pw_db = (DBM *)0;
- goto oldcode;
- }
- key.dptr = (char *) &uid;
- key.dsize = sizeof uid;
- pw = fetchpw(key);
- (void) flock(dbm_dirfno(_data->pw_db), LOCK_UN);
- if (!_data->pw_stayopen) {
- dbm_close(_data->pw_db);
- _data->pw_db = (DBM *)0;
- }
- return (pw);
-#endif
-}
diff --git a/lib/libpthread/gen/getwd.c b/lib/libpthread/gen/getwd.c
deleted file mode 100644
index 6e32561bfc3..00000000000
--- a/lib/libpthread/gen/getwd.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)getwd.c 5.1 (Berkeley) 2/20/91";*/
-static char *rcsid = "$Id: getwd.c,v 1.1 1998/07/21 13:19:02 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/param.h>
-#include <unistd.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-
-char *
-getwd(buf)
- char *buf;
-{
- char *p;
- char *strerror();
-
- if (p = getcwd(buf, MAXPATHLEN))
- return(p);
- (void)strcpy(buf, strerror(errno));
- return((char *)NULL);
-}
diff --git a/lib/libpthread/gen/isatty.c b/lib/libpthread/gen/isatty.c
deleted file mode 100644
index a3a01aad19e..00000000000
--- a/lib/libpthread/gen/isatty.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 1988 The Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)isatty.c 5.6 (Berkeley) 2/23/91";*/
-static char *rcsid = "$Id: isatty.c,v 1.1 1998/07/21 13:19:02 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#ifdef sunos4
-#include <sys/termio.h>
-#else
-#include <termios.h>
-#endif
-#include <unistd.h>
-
-/*
- * If TIOCGETA is not defined try TCGETATTR
- * If TCGETATTR is not defined try TCGETA
- * If that doesn't work try getting it from termio.h
- */
-#ifndef TIOCGETA
-#ifdef TCGETATTR
-#define TIOCGETA TCGETATTR
-#else
-#ifndef TCGETA
-#include <termio.h>
-#endif
-#ifndef TIOCGETA
-#define TIOCGETA TCGETA
-#endif
-#endif
-#endif
-
-/* fd is the real fd to pass to the kernel */
-int isatty_basic(int fd)
-{
-#ifdef sunos4
- struct termio t;
-#else /* !sunos4 */
- struct termios t;
-#endif /* sunos4 */
- return (machdep_sys_ioctl(fd,
-#ifdef sunos4
- TCGETA,
-#else /* !sunos4 */
- TIOCGETA,
-#endif /* sunos4 */
- &t) ? 0 : 1);
-}
-
-int isatty(int fd)
-{
- int ret;
-
- if ((ret = fd_lock(fd, FD_READ, NULL)) == OK) {
- ret = isatty_basic(fd_table[fd]->fd.i);
- fd_unlock(fd, FD_READ);
- } else {
- /* Return 0 or 1 */
- ret = 0;
- }
- return(ret);
-}
-
diff --git a/lib/libpthread/gen/popen.c b/lib/libpthread/gen/popen.c
deleted file mode 100644
index c15fbdce1fe..00000000000
--- a/lib/libpthread/gen/popen.c
+++ /dev/null
@@ -1,117 +0,0 @@
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-static pid_t *pids = NULL;
-static int pids_size = 0;
-static int pids_top = 0;
-static pthread_mutex_t pids_lock = PTHREAD_MUTEX_INITIALIZER;
-
-FILE *popen(const char *cmd, const char *mode)
-{
- int fds[2], parent_fd, child_fd, child_target, new_size, i;
- pid_t pid, *new_pids;
-
- /* Verify the mode. */
- if ((*mode != 'r' && *mode != 'w') || mode[1] != 0)
- return NULL;
-
- /* Generate fds, and choose the parent and child fds. */
- if (pipe(fds) < 0)
- return NULL;
- parent_fd = (*mode == 'r') ? fds[0] : fds[1];
- child_fd = (*mode == 'r') ? fds[1] : fds[0];
-
- /* Ensure that there is space in the pid table. */
- pthread_mutex_lock(&pids_lock);
- if (pids_size <= parent_fd) {
- new_size = parent_fd + 1;
- if ((new_pids = malloc(new_size * sizeof(pid_t))) == NULL) {
- pthread_mutex_unlock(&pids_lock);
- close(parent_fd);
- close(child_fd);
- return NULL;
- }
- if (pids) {
- memcpy(new_pids, pids, pids_size * sizeof(pid_t));
- free(pids);
- }
- while (pids_size < new_size)
- new_pids[pids_size++] = -1;
- pids = new_pids;
- }
- pthread_mutex_unlock(&pids_lock);
-
- /* Fork off a child process. */
- switch (pid = fork()) {
- case -1: /* Failed to fork. */
- close(parent_fd);
- close(child_fd);
- return NULL;
- break;
- case 0: /* Child */
- /*
- * Set the child fd to stdout or stdin as appropriate,
- * and close the parent fd.
- */
- child_target = (*mode == 'r') ? STDOUT_FILENO : STDIN_FILENO;
- if (child_fd != child_target) {
- dup2(child_fd, child_target);
- close(child_fd);
- }
- close(parent_fd);
-
- /* Close all parent fds from previous popens(). */
- for (i = 0; i < pids_top; i++) {
- if (pids[i] != -1)
- close(i);
- }
-
- execl("/bin/sh", "sh", "-c", cmd, NULL);
- exit(1);
- default:
- break;
- }
-
- /* Record the parent fd in the pids table. */
- pthread_mutex_lock(&pids_lock);
- pids[parent_fd] = pid;
- if (pids_top < parent_fd + 1)
- pids_top = parent_fd + 1;
- pthread_mutex_unlock(&pids_lock);
-
- /* Close the child fd and return a stdio buffer for the parent fd. */
- close(child_fd);
- return fdopen(parent_fd, mode);
-}
-
-int pclose(fp)
- FILE *fp;
-{
- pid_t pid, result;
- int fd, pstat;
-
- fd = fileno(fp);
- pthread_mutex_lock(&pids_lock);
- /* Make sure this is a popened file. */
- if ((pids_top <= fd) || ((pid = pids[fd]) == -1)) {
- pthread_mutex_unlock(&pids_lock);
- return -1;
- }
- pids[fd] = -1;
- while (pids_top > 0 && pids[pids_top - 1] == -1)
- pids_top--;
- pthread_mutex_unlock(&pids_lock);
-
- fclose(fp);
-
- /* Wait for the subprocess to quit. */
- return (((result = waitpid(pid, &pstat, 0)) == -1) ? -1 : pstat);
-}
-
diff --git a/lib/libpthread/gen/pwd_internal.c b/lib/libpthread/gen/pwd_internal.c
deleted file mode 100644
index b0ebc27b5c6..00000000000
--- a/lib/libpthread/gen/pwd_internal.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ==== pwd_internal.c ============================================================
- * Copyright (c) 1993, 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 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.
- *
- * Description : Thread-safe password hacking functions.
- *
- * 1.00 95/02/08 snl
- * -Started coding this file.
- */
-
-#include <pthread.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <pwd.h>
-#include <unistd.h>
-#include "pwd_internal.h"
-
-static pthread_once_t __pw_init = PTHREAD_ONCE_INIT;
-static pthread_key_t __pw_key;
-
-void
-_pw_null_cleanup(void *junkola)
-{
- pwf_context_t *x = (pwf_context_t *)junkola;
-
- if (x) {
- if (x->pwf) {
- fclose(x->pwf);
- x->pwf = 0;
- }
-#ifdef DBM_PWD_SUPPORT
- if (x->pw_db) {
- dbm_close(x->pw_db);
- x->pw_db = 0;
- }
-#endif /* DBM_PWD_SUPPORT */
- free((void *)x);
- }
-}
-
-void
-_pw_create_key()
-{
- if (pthread_key_create(&__pw_key, _pw_null_cleanup)) {
- PANIC();
- }
-}
-
-pwf_context_t *
-_pw_get_data()
-{
- pwf_context_t *_data;
-
- pthread_once(&__pw_init, _pw_create_key);
- _data = (pwf_context_t *)pthread_getspecific(__pw_key);
- if (!_data) {
- _data = (pwf_context_t *)malloc(sizeof(pwf_context_t));
- if (_data) {
- _data->pwf = 0;
- _data->line[0] = '\0';
- _data->pw_stayopen = 0;
- _data->pw_file = "/etc/passwd";
-#ifdef DBM_PWD_SUPPORT
- _data->pw_db = 0;
-#endif /* DBM_PWD_SUPPORT */
- pthread_setspecific(__pw_key, (void *)_data);
- }
- }
- return _data;
-}
diff --git a/lib/libpthread/gen/pwd_internal.h b/lib/libpthread/gen/pwd_internal.h
deleted file mode 100644
index 10fdab6cc4e..00000000000
--- a/lib/libpthread/gen/pwd_internal.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef _PWD_INTERNAL_H_
-#define _PWD_INTERNAL_H_
-
-#if 0 /* Turn this off for now until we suck in ndbm or use gdbm -- SNL */
-#ifndef DBM_PWD_SUPPORT
-#if !defined(__alpha) && !defined(linux) && !defined(hpux)
-#define DBM_PWD_SUPPORT 1
-#endif /* !alpha && !linux && !hpux */
-#endif /* !DBM_PWD_SUPPORT */
-#endif
-
-#ifdef DBM_PWD_SUPPORT
-#include <ndbm.h>
-#endif /* DBM_PWD_SUPPORT */
-
-typedef struct pwf_context {
- FILE *pwf;
- char line[BUFSIZ+1];
- struct passwd passwd;
- int pw_stayopen;
- char *pw_file;
-#ifdef DBM_PWD_SUPPORT
- DBM *pw_db;
-#endif /* DBM_PWD_SUPPORT */
-} pwf_context_t;
-
-pwf_context_t *_pw_get_data __P_((void));
-
-#endif /* _PWD_INTERNAL_H_ */
diff --git a/lib/libpthread/gen/syslog.c b/lib/libpthread/gen/syslog.c
deleted file mode 100644
index e49795ecb69..00000000000
--- a/lib/libpthread/gen/syslog.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright (c) 1983, 1988 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of California at Berkeley. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)syslog.c 5.14 (Berkeley) 5/20/88";
-#endif /* LIBC_SCCS and not lint */
-
-
-/*
- * SYSLOG -- print message on log file
- *
- * This routine looks a lot like printf, except that it
- * outputs to the log file instead of the standard output.
- * Also:
- * adds a timestamp,
- * prints the module name in front of the message,
- * has some other formatting types (or will sometime),
- * adds a newline on the end of the message.
- *
- * The output of this routine is intended to be read by /etc/syslogd.
- *
- * Author: Eric Allman
- * Modified to use UNIX domain IPC by Ralph Campbell
- * Modified for pthreads and made more POSIX-compliant by Greg Hudson
- */
-
-#include <pthread.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <fcntl.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <errno.h>
-#include <syslog.h>
-
-int socket();
-char *strerror(int); /* For systems that don't prototype it */
-
-#define MAXLINE 1024 /* max message size */
-
-#define PRIFAC(p) (((p) & LOG_FACMASK) >> 3)
- /* XXX should be in <syslog.h> */
-#define IMPORTANT LOG_ERR
-
-static void basic_init(void);
-
-static char _log_name[] = "/dev/log";
-static char ctty[] = "/dev/console";
-
-static int LogFile = -1; /* fd for log */
-static int LogStat = 0; /* status bits, set by openlog() */
-static char *LogTag = "syslog"; /* string to tag the entry with */
-static int LogMask = 0xff; /* mask of priorities to be logged */
-static int LogFacility = LOG_USER; /* default facility code */
-
-static pthread_mutex_t basic_init_lock = PTHREAD_MUTEX_INITIALIZER;
-
-static struct sockaddr SyslogAddr; /* AF_UNIX address of local logger */
-
-static void basic_init()
-{
- pthread_mutex_lock(&basic_init_lock);
- if (LogFile < 0)
- openlog(LogTag, LogStat | LOG_NDELAY, 0);
- pthread_mutex_unlock(&basic_init_lock);
-}
-
-void syslog(int pri, char *fmt, ...)
-{
- va_list args;
-
- va_start(args, fmt);
- vsyslog(pri, fmt, args);
- va_end(args);
-}
-
-void vsyslog(int pri, char *fmt, va_list args)
-{
- char buf[MAXLINE + 1], outline[MAXLINE + 1];
- register char *b, *f, *o;
- register int c;
- time_t now;
- int olderrno = errno, fd;
-
- /* Do a basic initialization if user didn't call openlog(). */
- if (LogFile < 0)
- basic_init();
-
- /* see if we should just throw out this message */
- if ((unsigned) PRIFAC(pri) >= LOG_NFACILITIES ||
- (LOG_MASK(pri & LOG_PRIMASK) & LogMask) == 0 ||
- (pri &~ (LOG_PRIMASK|LOG_FACMASK)) != 0)
- return;
-
- /* set default facility if none specified */
- if ((pri & LOG_FACMASK) == 0)
- pri |= LogFacility;
-
- /* build the message */
- o = outline;
- (void)sprintf(o, "<%d>", pri);
- o += strlen(o);
- time(&now);
- (void)sprintf(o, "%.15s ", ctime(&now) + 4);
- o += strlen(o);
- if (LogTag) {
- strcpy(o, LogTag);
- o += strlen(o);
- }
- if (LogStat & LOG_PID) {
- (void)sprintf(o, "[%d]", getpid());
- o += strlen(o);
- }
- if (LogTag) {
- strcpy(o, ": ");
- o += 2;
- }
-
- b = buf;
- f = fmt;
- while ((c = *f++) != '\0' && c != '\n' && b < &buf[MAXLINE]) {
- char *strerror();
-
- if (c != '%') {
- *b++ = c;
- continue;
- }
- if ((c = *f++) != 'm') {
- *b++ = '%';
- *b++ = c;
- continue;
- }
- strcpy(b, strerror(olderrno));
- b += strlen(b);
- }
- *b++ = '\n';
- *b = '\0';
- vsprintf(o, buf, args);
- c = strlen(outline);
- if (c > MAXLINE)
- c = MAXLINE;
-
- /* output the message to the local logger */
- if (sendto(LogFile, outline, c, 0, &SyslogAddr, sizeof SyslogAddr) >= 0)
- return;
- if (!(LogStat & LOG_CONS))
- return;
-
- /* output the message to the console */
- fd = open(ctty, O_WRONLY);
- alarm(0);
- strcat(o, "\r");
- o = strchr(outline, '>') + 1;
- write(fd, o, c + 1 - (o - outline));
- close(fd);
-}
-
-/*
- * OPENLOG -- open system log
- */
-
-void openlog(char *ident, int logstat, int logfac)
-{
- int flags;
-
- if (ident != NULL)
- LogTag = ident;
- LogStat = logstat;
- if (logfac != 0 && (logfac &~ LOG_FACMASK) == 0)
- LogFacility = logfac;
- if (LogFile >= 0)
- return;
- SyslogAddr.sa_family = AF_UNIX;
- strncpy(SyslogAddr.sa_data, _log_name, sizeof SyslogAddr.sa_data);
- if (LogStat & LOG_NDELAY) {
- LogFile = socket(AF_UNIX, SOCK_DGRAM, 0);
- flags = fcntl(LogFile, F_GETFD);
- fcntl(LogFile, F_SETFD, flags & O_NONBLOCK);
- }
-}
-
-/*
- * CLOSELOG -- close the system log
- */
-
-void closelog()
-{
- (void) close(LogFile);
- LogFile = -1;
-}
-
-/*
- * SETLOGMASK -- set the log mask level
- */
-int setlogmask(int pmask)
-{
- int omask;
-
- omask = LogMask;
- if (pmask != 0)
- LogMask = pmask;
- return (omask);
-}
diff --git a/lib/libpthread/gen/time.c b/lib/libpthread/gen/time.c
deleted file mode 100644
index 82eec7edc1e..00000000000
--- a/lib/libpthread/gen/time.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)time.c 5.6 (Berkeley) 6/1/90";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/types.h>
-#include <sys/time.h>
-
-time_t time(time_t * t)
-{
- struct timeval tt;
-
- if (gettimeofday(&tt, (struct timezone *)0) < 0)
- return(-1);
- if (t)
- *t = tt.tv_sec;
- return(tt.tv_sec);
-}
diff --git a/lib/libpthread/gen/ttyname.c b/lib/libpthread/gen/ttyname.c
deleted file mode 100644
index 0fe6abe4386..00000000000
--- a/lib/libpthread/gen/ttyname.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright (c) 1988 The Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)ttyname.c 5.10 (Berkeley) 5/6/91";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/__path.h>
-
-static pthread_mutex_t ttyname_lock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_key_t ttyname_key;
-static int ttyname_init = 0;
-extern void free();
-
-char * __ttyname_r_basic(int fd, char * buf, size_t len)
-{
- register struct dirent *dirp;
- register DIR *dp;
- struct stat dsb;
- struct stat sb;
- char * rval;
- int minlen;
-
- rval = NULL;
-
- /* Must be a terminal. */
- if (! isatty_basic(fd))
- return(rval);
- /* Must be a character device. */
- if (machdep_sys_fstat(fd, &sb) || !S_ISCHR(sb.st_mode))
- return(rval);
- /* Must have enough room */
- if (len <= sizeof(_PATH_PTY))
- return(rval);
-
- if ((dp = opendir(_PATH_PTY)) != NULL) {
- memcpy(buf, _PATH_PTY, sizeof(_PATH_PTY));
- for (rval = NULL; dirp = readdir(dp);) {
- if (dirp->d_fileno != sb.st_ino)
- continue;
- minlen = (len - (sizeof(_PATH_PTY) - 1)) < (dirp->d_namlen + 1) ?
- (len - (sizeof(_PATH_PTY) - 1)) : (dirp->d_namlen + 1);
- memcpy (buf + sizeof(_PATH_PTY) - 1, dirp->d_name, minlen);
- if (stat(buf, &dsb) || sb.st_dev != dsb.st_dev ||
- sb.st_ino != dsb.st_ino)
- continue;
- rval = buf;
- break;
- }
- (void)closedir(dp);
- }
- return(rval);
-}
-
-char * __ttyname_basic(int fd)
-{
- char *buf;
-
- pthread_mutex_lock (&ttyname_lock);
- if (ttyname_init == 0) {
- if (pthread_key_create(&ttyname_key, free)) {
- pthread_mutex_unlock (&ttyname_lock);
- return(NULL);
- }
- ttyname_init = 1;
- }
- pthread_mutex_unlock (&ttyname_lock);
-
- /* Must have thread specific data field to put data */
- if ((buf = pthread_getspecific(ttyname_key)) == NULL) {
- if (buf = malloc(sizeof(_PATH_PTY) + MAXNAMLEN)) {
- if (pthread_setspecific(ttyname_key, buf) != OK) {
- free(buf);
- return(NULL);
- }
- } else {
- return(NULL);
- }
- }
- return(__ttyname_r_basic(fd, buf, sizeof(_PATH_PTY) + MAXNAMLEN));
-}
-
-char * ttyname_r(int fd, char * buf, size_t len)
-{
- char * ret;
-
- if (fd_lock(fd, FD_READ) == OK) {
- ret = __ttyname_r_basic(fd_table[fd]->fd.i, buf, len);
- fd_unlock(fd, FD_READ);
- } else {
- ret = NULL;
- }
- return(ret);
-}
-
-char * ttyname(int fd)
-{
- char * ret;
-
- if (fd_lock(fd, FD_READ) == OK) {
- ret = __ttyname_basic(fd_table[fd]->fd.i);
- fd_unlock(fd, FD_READ);
- } else {
- ret = NULL;
- }
- return(ret);
-}
-
-
diff --git a/lib/libpthread/include/arpa/inet.h b/lib/libpthread/include/arpa/inet.h
deleted file mode 100755
index 27e045fa615..00000000000
--- a/lib/libpthread/include/arpa/inet.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 1983, 1993
- * The Regents of the University of California. 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * from: @(#)inet.h 5.7 (Berkeley) 4/3/91
- * $Id: inet.h,v 1.1 1998/07/21 13:19:11 peter Exp $
- */
-
-#ifndef _INET_H_
-#define _INET_H_
-
-/* External definitions for functions in inet(3) */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <pthread/types.h>
-
-__BEGIN_DECLS
-
-pthread_ipaddr_type inet_addr __P_((const char *));
-int inet_aton __P_((const char *, struct in_addr *));
-pthread_ipaddr_type inet_lnaof __P_((struct in_addr));
-struct in_addr inet_makeaddr __P_((pthread_ipaddr_type,
- pthread_ipaddr_type));
-pthread_ipaddr_type inet_netof __P_((struct in_addr));
-pthread_ipaddr_type inet_network __P_((const char *));
-char * inet_ntoa __P_((struct in_addr));
-char * inet_ntoa_r __P_((struct in_addr in, char *buf,
- int bufsize));
-
-__END_DECLS
-
-#endif /* !_INET_H_ */
diff --git a/lib/libpthread/include/arpa/nameser.h b/lib/libpthread/include/arpa/nameser.h
deleted file mode 100755
index 350d67538bd..00000000000
--- a/lib/libpthread/include/arpa/nameser.h
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * Copyright (c) 1983, 1989, 1993
- * The Regents of the University of California. 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * @(#)nameser.h 8.2 (Berkeley) 2/16/94
- * -
- * Portions Copyright (c) 1993 by Digital Equipment Corporation.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies, and that
- * the name of Digital Equipment Corporation not be used in advertising or
- * publicity pertaining to distribution of the document or software without
- * specific, written prior permission.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
- * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- * -
- * --Copyright--
- */
-
-#ifndef _NAMESER_H_
-#define _NAMESER_H_
-
-#include <endian.h>
-#include <sys/types.h>
-#include <pthread/types.h>
-
-/*
- * Define constants based on rfc883
- */
-#define PACKETSZ 512 /* maximum packet size */
-#define MAXDNAME 256 /* maximum domain name */
-#define MAXCDNAME 255 /* maximum compressed domain name */
-#define MAXLABEL 63 /* maximum length of domain label */
- /* Number of bytes of fixed size data in query structure */
-#define QFIXEDSZ 4
- /* number of bytes of fixed size data in resource record */
-#define RRFIXEDSZ 10
-
-/*
- * Internet nameserver port number
- */
-#define NAMESERVER_PORT 53
-
-/*
- * Currently defined opcodes
- */
-#define QUERY 0x0 /* standard query */
-#define IQUERY 0x1 /* inverse query */
-#define STATUS 0x2 /* nameserver status query */
-/*#define xxx 0x3*/ /* 0x3 reserved */
- /* non standard - supports ALLOW_UPDATES stuff from Mike Schwartz */
-#define UPDATEA 0x9 /* add resource record */
-#define UPDATED 0xa /* delete a specific resource record */
-#define UPDATEDA 0xb /* delete all named resource record */
-#define UPDATEM 0xc /* modify a specific resource record */
-#define UPDATEMA 0xd /* modify all named resource record */
-
-#define ZONEINIT 0xe /* initial zone transfer */
-#define ZONEREF 0xf /* incremental zone referesh */
-
-/*
- * Currently defined response codes
- */
-#define NOERROR 0 /* no error */
-#define FORMERR 1 /* format error */
-#define SERVFAIL 2 /* server failure */
-#define NXDOMAIN 3 /* non existent domain */
-#define NOTIMP 4 /* not implemented */
-#define REFUSED 5 /* query refused */
- /* non standard */
-#define NOCHANGE 0xf /* update failed to change db */
-
-/*
- * Type values for resources and queries
- */
-#define T_A 1 /* host address */
-#define T_NS 2 /* authoritative server */
-#define T_MD 3 /* mail destination */
-#define T_MF 4 /* mail forwarder */
-#define T_CNAME 5 /* connonical name */
-#define T_SOA 6 /* start of authority zone */
-#define T_MB 7 /* mailbox domain name */
-#define T_MG 8 /* mail group member */
-#define T_MR 9 /* mail rename name */
-#define T_NULL 10 /* null resource record */
-#define T_WKS 11 /* well known service */
-#define T_PTR 12 /* domain name pointer */
-#define T_HINFO 13 /* host information */
-#define T_MINFO 14 /* mailbox information */
-#define T_MX 15 /* mail routing information */
-#define T_TXT 16 /* text strings */
-#define T_RP 17 /* responsible person */
-#define T_AFSDB 18 /* AFS cell database */
-#define T_NSAP 22 /* NSAP address */
-#define T_NSAP_PTR 23 /* reverse lookup for NSAP */
- /* non standard */
-#define T_UINFO 100 /* user (finger) information */
-#define T_UID 101 /* user ID */
-#define T_GID 102 /* group ID */
-#define T_UNSPEC 103 /* Unspecified format (binary data) */
- /* Query type values which do not appear in resource records */
-#define T_AXFR 252 /* transfer zone of authority */
-#define T_MAILB 253 /* transfer mailbox records */
-#define T_MAILA 254 /* transfer mail agent records */
-#define T_ANY 255 /* wildcard match */
-
-/*
- * Values for class field
- */
-
-#define C_IN 1 /* the arpa internet */
-#define C_CHAOS 3 /* for chaos net (MIT) */
-#define C_HS 4 /* for Hesiod name server (MIT) (XXX) */
- /* Query class values which do not appear in resource records */
-#define C_ANY 255 /* wildcard match */
-
-/*
- * Status return codes for T_UNSPEC conversion routines
- */
-#define CONV_SUCCESS 0
-#define CONV_OVERFLOW -1
-#define CONV_BADFMT -2
-#define CONV_BADCKSUM -3
-#define CONV_BADBUFLEN -4
-
-#if !defined(BYTE_ORDER) || (BYTE_ORDER != BIG_ENDIAN \
- && BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != PDP_ENDIAN)
- /* you must determine what the correct bit order is for
- * your compiler - the next line is an intentional error
- * which will force your compiles to bomb until you fix
- * the above macros.
- */
- #error "Undefined or invalid BYTE_ORDER";
-#endif
-
-/*
- * Structure for query header. The order of the fields is machine- and
- * compiler-dependent, depending on the byte/bit order and the layout
- * of bit fields. We use bit fields only in int variables, as this
- * is all ANSI requires. This requires a somewhat confusing rearrangement.
- */
-
-typedef struct {
- pthread_ipport_type id; /* query identification number */
-#if BYTE_ORDER == BIG_ENDIAN
- /* fields in third byte */
- u_int qr:1; /* response flag */
- u_int opcode:4; /* purpose of message */
- u_int aa:1; /* authoritive answer */
- u_int tc:1; /* truncated message */
- u_int rd:1; /* recursion desired */
- /* fields in fourth byte */
- u_int ra:1; /* recursion available */
- u_int pr:1; /* primary server required (non standard) */
- u_int unused:2; /* unused bits */
- u_int rcode:4; /* response code */
-#endif
-#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
- /* fields in third byte */
- u_int rd:1; /* recursion desired */
- u_int tc:1; /* truncated message */
- u_int aa:1; /* authoritive answer */
- u_int opcode:4; /* purpose of message */
- u_int qr:1; /* response flag */
- /* fields in fourth byte */
- u_int rcode:4; /* response code */
- u_int unused:2; /* unused bits */
- u_int pr:1; /* primary server required (non standard) */
- u_int ra:1; /* recursion available */
-#endif
- /* remaining bytes */
- pthread_ipport_type qdcount; /* number of question entries */
- pthread_ipport_type ancount; /* number of answer entries */
- pthread_ipport_type nscount; /* number of authority entries */
- pthread_ipport_type arcount; /* number of resource entries */
-} HEADER;
-
-/*
- * Defines for handling compressed domain names
- */
-#define INDIR_MASK 0xc0
-
-/*
- * Structure for passing resource records around.
- */
-struct rrec {
- pthread_ipport_type r_zone; /* zone number */
- pthread_ipport_type r_class; /* class number */
- pthread_ipport_type r_type; /* type number */
- pthread_ipaddr_type r_ttl; /* time to live */
- int r_size; /* size of data area */
- char * r_data; /* pointer to data */
-};
-
-extern pthread_ipport_type _getshort();
-extern pthread_ipaddr_type _getlong();
-
-/*
- * Inline versions of get/put short/long. Pointer is advanced.
- * We also assume that a "pthread_ipport_type" holds 2 "chars"
- * and that a "pthread_ipaddr_type" holds 4 "chars".
- *
- * These macros demonstrate the property of C whereby it can be
- * portable or it can be elegant but never both.
- */
-#define GETSHORT(s, cp) { \
- register u_char *t_cp = (u_char *)(cp); \
- (s) = ((pthread_ipport_type)t_cp[0] << 8) | (pthread_ipport_type)t_cp[1]; \
- (cp) += 2; \
-}
-
-#define GETLONG(l, cp) { \
- register u_char *t_cp = (u_char *)(cp); \
- (l) = (((pthread_ipaddr_type)t_cp[0]) << 24) \
- | (((pthread_ipaddr_type)t_cp[1]) << 16) \
- | (((pthread_ipaddr_type)t_cp[2]) << 8) \
- | (((pthread_ipaddr_type)t_cp[3])); \
- (cp) += 4; \
-}
-
-#define PUTSHORT(s, cp) { \
- register pthread_ipport_type t_s = (pthread_ipport_type)(s); \
- register u_char *t_cp = (u_char *)(cp); \
- *t_cp++ = t_s >> 8; \
- *t_cp = t_s; \
- (cp) += 2; \
-}
-
-/*
- * Warning: PUTLONG --no-longer-- destroys its first argument. if you
- * were depending on this "feature", you will lose.
- */
-#define PUTLONG(l, cp) { \
- register pthread_ipaddr_type t_l = (pthread_ipaddr_type)(l); \
- register u_char *t_cp = (u_char *)(cp); \
- *t_cp++ = t_l >> 24; \
- *t_cp++ = t_l >> 16; \
- *t_cp++ = t_l >> 8; \
- *t_cp = t_l; \
- (cp) += 4; \
-}
-
-#endif /* !_NAMESER_H_ */
diff --git a/lib/libpthread/include/dirent.h b/lib/libpthread/include/dirent.h
deleted file mode 100644
index c3e86cb9da1..00000000000
--- a/lib/libpthread/include/dirent.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*-
- * Copyright (c) 1989 The Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * @(#)dirent.h 5.18 (Berkeley) 2/23/91
- */
-
-#ifndef _DIRENT_H_
-#define _DIRENT_H_
-
-#include <sys/dirent.h>
-#include <pthread.h>
-
-struct __dirent {
- struct __dirent * next;
- struct dirent data;
- pthread_t owner;
-};
-
-/* definitions for library routines operating on directories. */
-#define DIRBLKSIZ 1024
-
-/* structure describing an open directory. */
-typedef struct _dirdesc {
- struct __dirent * dd_dp; /* Linked list of struct __dirent pointer */
- int dd_fd; /* file descriptor associated with directory */
- long dd_loc; /* offset in current buffer */
- long dd_size; /* amount of data returned by getdirentries */
- char * dd_buf; /* data buffer */
- int dd_len; /* size of data buffer */
- long dd_seek; /* magic cookie returned by getdirentries */
- void * dd_ddloc; /* Linked list of ddloc structs for telldir/seekdir */
- pthread_mutex_t *dd_lock; /* Lock for open directory structure */
-} DIR;
-
-#define dirfd(dirp) ((dirp)->dd_fd)
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-#ifndef KERNEL
-
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-DIR * opendir __P_((const char *));
-struct dirent * readdir __P_((DIR *));
-int readdir_r __P_((DIR *, struct dirent *, struct dirent **));
-void rewinddir __P_((DIR *));
-int closedir __P_((DIR *));
-#ifndef _POSIX_SOURCE
-long telldir __P_((DIR *));
-void seekdir __P_((DIR *, long));
-
-/*
-int scandir __P_((const char *, struct dirent ***,
- int (*)(struct dirent *),
- int (*)(const void *, const void *)));
-int alphasort __P_((const void *, const void *));
-int getdirentries __P_((int, char *, int, long *));
-*/
-#endif /* not POSIX */
-
-__END_DECLS
-
-#endif /* !KERNEL */
-
-#endif /* !_DIRENT_H_ */
diff --git a/lib/libpthread/include/endian.h b/lib/libpthread/include/endian.h
deleted file mode 100644
index 8fb947dbd33..00000000000
--- a/lib/libpthread/include/endian.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 1983, 1989, 1993
- * The Regents of the University of California. 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * @(#)nameser.h 8.2 (Berkeley) 2/16/94
- * -
- * Portions Copyright (c) 1993 by Digital Equipment Corporation.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies, and that
- * the name of Digital Equipment Corporation not be used in advertising or
- * publicity pertaining to distribution of the document or software without
- * specific, written prior permission.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
- * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- * -
- * --Copyright--
- */
-
-#ifndef _ENDIAN_H_
-#define _ENDIAN_H_
-
-#ifndef BYTE_ORDER
-#define LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */
-#define __LITTLE_ENDIAN 1234
-#define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
-#define __BIG_ENDIAN 4321
-#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/
-#define __PDP_ENDIAN 3412
-
-#if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \
- defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
- defined(__alpha__) || defined(__alpha)
-#define BYTE_ORDER LITTLE_ENDIAN
-#define __BYTE_ORDER LITTLE_ENDIAN
-#endif
-
-#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
- defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
- defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || \
- defined(apollo) || defined(hp9000) || defined(hp9000s300) || \
- defined(hp9000s800) || \
- defined (BIT_ZERO_ON_LEFT)
-#define BYTE_ORDER BIG_ENDIAN
-#define __BYTE_ORDER BIG_ENDIAN
-#endif
-#endif /* BYTE_ORDER */
-
-#if !defined(BYTE_ORDER) || (BYTE_ORDER != BIG_ENDIAN \
- && BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != PDP_ENDIAN)
- /* you must determine what the correct bit order is for
- * your compiler - the next line is an intentional error
- * which will force your compiles to bomb until you fix
- * the above macros.
- */
- #error "Undefined or invalid BYTE_ORDER";
-#endif
-
-#endif /* !_ENDIAN_H */
diff --git a/lib/libpthread/include/errno.h b/lib/libpthread/include/errno.h
deleted file mode 100644
index 24b005e9369..00000000000
--- a/lib/libpthread/include/errno.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * from: @(#)errno.h 7.13 (Berkeley) 2/19/91
- * errno.h,v 1.3 1993/05/20 16:22:09 cgd Exp
- */
-
-#ifndef _ERRNO_H_
-#define _ERRNO_H_
-
-#include <sys/cdefs.h>
-#include <sys/errno.h>
-
-__BEGIN_DECLS
-
-extern int * __error();
-
-__END_DECLS
-
-#define errno (* __error())
-#define pthread_errno(x) pthread_run->error_p = x
-
-#endif /* _ERRNO_H_ */
diff --git a/lib/libpthread/include/math.h b/lib/libpthread/include/math.h
deleted file mode 100644
index d5963ce6023..00000000000
--- a/lib/libpthread/include/math.h
+++ /dev/null
@@ -1,85 +0,0 @@
-#ifndef _MATH_H_
-#define _MATH_H_
-
-/* Needed for HUGE_VAL */
-#include <sys/__math.h>
-
-/* XOPEN/SVID */
-
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
-#define M_E 2.7182818284590452354 /* e */
-#define M_LOG2E 1.4426950408889634074 /* log 2e */
-#define M_LOG10E 0.43429448190325182765 /* log 10e */
-#define M_LN2 0.69314718055994530942 /* log e2 */
-#define M_LN10 2.30258509299404568402 /* log e10 */
-#define M_PI 3.14159265358979323846 /* pi */
-#define M_PI_2 1.57079632679489661923 /* pi/2 */
-#define M_PI_4 0.78539816339744830962 /* pi/4 */
-#define M_1_PI 0.31830988618379067154 /* 1/pi */
-#define M_2_PI 0.63661977236758134308 /* 2/pi */
-#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
-#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
-#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
-
-#define MAXFLOAT ((float)3.40282346638528860e+38)
-
-#if !defined(_XOPEN_SOURCE)
-
-struct exception {
- int type;
- char *name;
- double arg1;
- double arg2;
- double retval;
-};
-
-#define HUGE MAXFLOAT
-
-#define DOMAIN 1
-#define SING 2
-#define OVERFLOW 3
-#define UNDERFLOW 4
-#define TLOSS 5
-#define PLOSS 6
-
-#endif /* !_XOPEN_SOURCE */
-#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
-
-#include <sys/cdefs.h>
-
-/* ANSI/POSIX */
-
-__BEGIN_DECLS
-
-double hypot __P_((double, double));
-double acos __P_((double));
-double asin __P_((double));
-double atan __P_((double));
-double atan2 __P_((double, double));
-double cos __P_((double));
-double sin __P_((double));
-double tan __P_((double));
-
-double cosh __P_((double));
-double sinh __P_((double));
-double tanh __P_((double));
-
-double exp __P_((double));
-double frexp __P_((double, int *));
-double ldexp __P_((double, int));
-double log __P_((double));
-double log10 __P_((double));
-double modf __P_((double, double *));
-
-double pow __P_((double, double));
-double sqrt __P_((double));
-
-double ceil __P_((double));
-double fabs __P_((double));
-double floor __P_((double));
-double fmod __P_((double, double));
-double rint __P_((double)); /* XOPEN; Added by Monty */
-int finite __P_((double dsrc)); /* math.h; added by Monty */
-__END_DECLS
-
-#endif /* _MATH_H_ */
diff --git a/lib/libpthread/include/netdb.h b/lib/libpthread/include/netdb.h
deleted file mode 100644
index 12ecef51a8e..00000000000
--- a/lib/libpthread/include/netdb.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*-
- * Copyright (c) 1980, 1983, 1988 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * from: @(#)netdb.h 5.15 (Berkeley) 4/3/91
- * $Id: netdb.h,v 1.1 1998/07/21 13:19:05 peter Exp $
- */
-
-#ifndef _NETDB_H_
-#define _NETDB_H_
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-
-#define _PATH_HEQUIV "/etc/hosts.equiv"
-#define _PATH_HOSTS "/etc/hosts"
-#define _PATH_NETWORKS "/etc/networks"
-#define _PATH_PROTOCOLS "/etc/protocols"
-#define _PATH_SERVICES "/etc/services"
-#define __NETDB_MAXALIASES 35
-#define __NETDB_MAXADDRS 35
-
-/*
- * Structures returned by network data base library. All addresses are
- * supplied in host order, and returned in network order (suitable for
- * use in system calls).
- */
-struct hostent {
- char *h_name; /* official name of host */
- char **h_aliases; /* alias list */
- int h_addrtype; /* host address type */
- int h_length; /* length of address */
- char **h_addr_list; /* list of addresses from name server */
-#define h_addr h_addr_list[0] /* address, for backward compatiblity */
-};
-
-/*
- * Assumption here is that a network number
- * fits in 32 bits -- probably a poor one.
- */
-struct netent {
- char *n_name; /* official name of net */
- char **n_aliases; /* alias list */
- int n_addrtype; /* net address type */
- unsigned long n_net; /* network # */
-};
-
-struct servent {
- char *s_name; /* official service name */
- char **s_aliases; /* alias list */
- int s_port; /* port # */
- char *s_proto; /* protocol to use */
-};
-
-struct protoent {
- char *p_name; /* official protocol name */
- char **p_aliases; /* alias list */
- int p_proto; /* protocol # */
-};
-
-/*
- * Error return codes from gethostbyname() and gethostbyaddr()
- * (left in extern int h_errno).
- */
-
-#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */
-#define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */
-#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
-#define NO_DATA 4 /* Valid name, no data record of requested type */
-#define NO_ADDRESS NO_DATA /* no address, look for MX record */
-
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-void endhostent __P_((void));
-void endnetent __P_((void));
-void endprotoent __P_((void));
-void endservent __P_((void));
-struct hostent *gethostbyaddr __P_((const char *, int, int));
-struct hostent *gethostbyname __P_((const char *));
-struct hostent *gethostent __P_((void));
-struct netent *getnetbyaddr __P_((long, int)); /* u_long? */
-struct netent *getnetbyname __P_((const char *));
-struct netent *getnetent __P_((void));
-struct protoent *getprotobyname __P_((const char *));
-struct protoent *getprotobynumber __P_((int));
-struct protoent *getprotoent __P_((void));
-struct servent *getservbyname __P_((const char *, const char *));
-struct servent *getservbyport __P_((int, const char *));
-struct servent *getservent __P_((void));
-void herror __P_((const char *));
-char *hstrerror __P_((int));
-void sethostent __P_((int));
-void setnetent __P_((int));
-void setprotoent __P_((int));
-void setservent __P_((int));
-struct hostent *gethostbyaddr_r __P_((const char *, int, int,
- struct hostent *, char *, int, int *));
-struct hostent *gethostbyname_r __P_((const char *, struct hostent *, char *,
- int, int *));
-struct hostent *gethostent_r __P_((struct hostent *, char *, int, int *));
-struct netent *getnetbyaddr_r __P_((long, int, struct netent *, char *, int));
-struct netent *getnetbyname_r __P_((const char *, struct netent *, char *,
- int));
-struct netent *getnetent_r __P_((struct netent *, char *, int));
-struct protoent *getprotobyname_r __P_((const char *, struct protoent *, char *,
- int));
-struct protoent *getprotobynumber_r __P_((int, struct protoent *, char *, int));
-struct protoent *getprotoent_r __P_((struct protoent *, char *, int));
-struct servent *getservbyname_r __P_((const char *, const char *,
- struct servent *, char *, int));
-struct servent *getservbyport_r __P_((int, const char *, struct servent *,
- char *, int));
-struct servent *getservent_r __P_((struct servent *, char *, int));
-__END_DECLS
-
-#endif /* !_NETDB_H_ */
diff --git a/lib/libpthread/include/pthread/ac-types.h b/lib/libpthread/include/pthread/ac-types.h
deleted file mode 100755
index f21fc6806e4..00000000000
--- a/lib/libpthread/include/pthread/ac-types.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef pthread_size_t
-#define pthread_ipaddr_type unsigned long
-#define pthread_ipport_type unsigned short
-#define pthread_clock_t long
-#define pthread_size_t unsigned int
-#define pthread_ssize_t int
-#define pthread_time_t long
-#define pthread_fpos_t long
-#define pthread_off_t long
-#define pthread_va_list void *
-#endif
diff --git a/lib/libpthread/include/pthread/cleanup.h b/lib/libpthread/include/pthread/cleanup.h
deleted file mode 100755
index 720f2d55445..00000000000
--- a/lib/libpthread/include/pthread/cleanup.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* ==== cleanup.h ============================================================
- * 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 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.
- *
- * $Id: cleanup.h,v 1.1 1998/07/21 13:19:11 peter Exp $
- *
- * Description : cleanup header.
- *
- * 1.20 94/02/13 proven
- * -Started coding this file.
- */
-
-/*
- * New cleanup structures
- */
-struct pthread_cleanup {
- struct pthread_cleanup *next;
- void (*routine)();
- void *routine_arg;
-};
-
-/*
- * New functions
- */
-
-__BEGIN_DECLS
-
-int pthread_cleanup_push __P_((void (*routine)(void *), void *routine_arg));
-void pthread_cleanup_pop __P_((int execute));
-
-__END_DECLS
-
diff --git a/lib/libpthread/include/pthread/cond.h b/lib/libpthread/include/pthread/cond.h
deleted file mode 100755
index 28c283b75f4..00000000000
--- a/lib/libpthread/include/pthread/cond.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* ==== cond.h ============================================================
- * Copyright (c) 1993 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 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.
- *
- * $Id: cond.h,v 1.1 1998/07/21 13:19:11 peter Exp $
- *
- * Description : Condition variable header.
- *
- * 1.00 93/10/30 proven
- * -Started coding this file.
- */
-
-#include <timers.h>
-
-/*
- * New cond structures
- */
-enum pthread_condtype {
- COND_TYPE_FAST,
- COND_TYPE_STATIC_FAST,
- COND_TYPE_COUNTING_FAST, /* Used with MUTEX_TYPE_COUNTING_FAST */
- COND_TYPE_METERED,
- COND_TYPE_DEBUG, /* Debug conds will have lots of options */
- COND_TYPE_MAX
-};
-
-#define PTHREAD_CONDTYPE_FAST 1
-#define PTHREAD_CONDTYPE_DEBUG 4
-#define PTHREAD_CONDTYPE_RECURSIVE 2
-
-typedef struct pthread_cond {
- enum pthread_condtype c_type;
- struct pthread_queue c_queue;
- semaphore c_lock;
- void * c_data;
- long c_flags;
-} pthread_cond_t;
-
-typedef struct pthread_condattr {
- enum pthread_condtype c_type;
- long c_flags;
-} pthread_condattr_t;
-
-/*
- * Flags for conds.
- */
-#define COND_FLAGS_PRIVATE 0x01
-#define COND_FLAGS_INITED 0x02
-#define COND_FLAGS_BUSY 0x04
-
-/*
- * Static cond initialization values.
- */
-#define PTHREAD_COND_INITIALIZER \
-{ COND_TYPE_STATIC_FAST, PTHREAD_QUEUE_INITIALIZER, \
- SEMAPHORE_CLEAR, NULL, COND_FLAGS_INITED }
-
-/*
- * New functions
- */
-
-__BEGIN_DECLS
-
-int pthread_cond_init __P_((pthread_cond_t *, const pthread_condattr_t *));
-int pthread_cond_timedwait __P_((pthread_cond_t *, pthread_mutex_t *,
- const struct timespec * abstime));
-int pthread_cond_wait __P_((pthread_cond_t *, pthread_mutex_t *));
-int pthread_cond_signal __P_((pthread_cond_t *));
-int pthread_cond_broadcast __P_((pthread_cond_t *));
-int pthread_cond_destroy __P_((pthread_cond_t *));
-
-__END_DECLS
-
diff --git a/lib/libpthread/include/pthread/config.h b/lib/libpthread/include/pthread/config.h
deleted file mode 100755
index d944b14a8c6..00000000000
--- a/lib/libpthread/include/pthread/config.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifndef _SYS___CONFIG_H_
-#define _SYS___CONFIG_H_
-#define _OS_HAS_TIMESPEC 1
-#endif
diff --git a/lib/libpthread/include/pthread/debug_out.h b/lib/libpthread/include/pthread/debug_out.h
deleted file mode 100755
index 6968c5ea90e..00000000000
--- a/lib/libpthread/include/pthread/debug_out.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* debug_out.h - macros to use for debugging prints in places where calls
- to printf() and gang are ill-advised. */
-
-#ifdef PTHREAD_DEBUGGING
-#define PTHREAD_DEBUG_WriteStr(S) (void)machdep_sys_write(2,S,strlen(S))
-#define PTHREAD_DEBUG_WriteInt32Hex(X) \
- { char _xbuf[8]; int _temp = (int)(X), _temp2; \
- _temp2 = ((_temp>>28)&0xf); \
- _xbuf[0] = (_temp2<10)? (_temp2+'0'): ((_temp2-10)+'a'); \
- _temp2 = ((_temp>>24)&0xf); \
- _xbuf[1] = (_temp2<10)? (_temp2+'0'): ((_temp2-10)+'a'); \
- _temp2 = ((_temp>>20)&0xf); \
- _xbuf[2] = (_temp2<10)? (_temp2+'0'): ((_temp2-10)+'a'); \
- _temp2 = ((_temp>>16)&0xf); \
- _xbuf[3] = (_temp2<10)? (_temp2+'0'): ((_temp2-10)+'a'); \
- _temp2 = ((_temp>>12)&0xf); \
- _xbuf[4] = (_temp2<10)? (_temp2+'0'): ((_temp2-10)+'a'); \
- _temp2 = ((_temp>>8)&0xf); \
- _xbuf[5] = (_temp2<10)? (_temp2+'0'): ((_temp2-10)+'a'); \
- _temp2 = ((_temp>>4)&0xf); \
- _xbuf[6] = (_temp2<10)? (_temp2+'0'): ((_temp2-10)+'a'); \
- _temp2 = (_temp&0xf); \
- _xbuf[7] = (_temp2<10)? (_temp2+'0'): ((_temp2-10)+'a'); \
- (void)machdep_sys_write(2,_xbuf,8); \
- }
-#ifdef __alpha
-#define PTHREAD_DEBUG_WriteInt64Hex(X) \
- { long _tempX = (long)(X),_tempY; \
- _tempY=((_tempX>>32)&0xffffffff); \
- PTHREAD_DEBUG_WriteInt32Hex(_tempY); \
- _tempY=(_tempX&0xffffffff); \
- PTHREAD_DEBUG_WriteInt32Hex(_tempY); \
- }
-#define PTHREAD_DEBUG_WritePointer(X) PTHREAD_DEBUG_WriteInt64Hex(X)
-#else
-#define PTHREAD_DEBUG_WriteInt64Hex(X) PTHREAD_DEBUG_WriteInt32Hex(X)
-#define PTHREAD_DEBUG_WritePointer(X) PTHREAD_DEBUG_WriteInt32Hex(X)
-#endif /* __alpha */
-#else /* ! PTHREAD_DEBUGGING */
-#define PTHREAD_DEBUG_WriteStr(S)
-#define PTHREAD_DEBUG_WriteInt32Hex(X)
-#define PTHREAD_DEBUG_WriteInt64HeX(X)
-#define PTHREAD_DEBUG_WritePointer(X)
-#endif /* PTHREAD_DEBUGGING */
diff --git a/lib/libpthread/include/pthread/fd.h b/lib/libpthread/include/pthread/fd.h
deleted file mode 100755
index 28e55935812..00000000000
--- a/lib/libpthread/include/pthread/fd.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/* ==== fd.h ============================================================
- * Copyright (c) 1993, 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 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.
- *
- * $Id: fd.h,v 1.1 1998/07/21 13:19:11 peter Exp $
- *
- * Description : Basic fd header.
- *
- * 1.00 93/08/14 proven
- * -Started coding this file.
- *
- * 1.01 93/11/13 proven
- * -The functions readv() and writev() added
- */
-
-/*
- * New pthread types.
- */
-enum fd_type {
- FD_NT, /* Not tested */
- FD_NIU, /* Known to be not in use */
- FD_HALF_DUPLEX, /* Files, and seeking devices */
- FD_FULL_DUPLEX, /* pipes, sockets, drivers, ... */
- FD_TEST_HALF_DUPLEX, /* Redo machdep_sys_fcntl */
- FD_TEST_FULL_DUPLEX /* Redo machdep_sys_fcntl */
-};
-
-
-#define FD_READ 0x1
-#define FD_WRITE 0x2
-#define FD_RDWR (FD_READ | FD_WRITE)
-
-union fd_data {
- void *ptr;
- int i;
-};
-
-struct timespec;
-struct iovec;
-struct fd_ops {
- pthread_ssize_t (*write) __P_((union fd_data, int, const void *,
- size_t, struct timespec *));
- pthread_ssize_t (*read) __P_((union fd_data, int, void *, size_t,
- struct timespec *));
- int (*close)();
- int (*fcntl)();
- int (*writev) __P_((union fd_data, int,
- const struct iovec *,
- int, struct timespec *));
- int (*readv) __P_((union fd_data, int,
- const struct iovec *,
- int, struct timespec *));
- off_t (*seek)();
- int use_kfds;
-};
-
-struct fd_table_entry {
- struct pthread_queue r_queue;
- struct pthread_queue w_queue;
- struct pthread *r_owner;
- struct pthread *w_owner;
- pthread_mutex_t mutex;
- struct fd_table_entry *next;
- struct fd_ops *ops;
- enum fd_type type;
- int r_lockcount; /* Count for FILE read locks */
- int w_lockcount; /* Count for FILE write locks */
- int count;
-
- /* data that needs to be passed to the type dependent fd */
- int flags;
- union fd_data fd;
-};
-
-/*
- * Globals
- */
-#if defined(PTHREAD_KERNEL)
-
-extern struct fd_table_entry **fd_table;
-extern int dtablesize;
-
-#endif
-
-/*
- * New functions
- */
-
-__BEGIN_DECLS
-
-#if defined(PTHREAD_KERNEL)
-
-#endif
-
-__END_DECLS
diff --git a/lib/libpthread/include/pthread/fd_pipe.h b/lib/libpthread/include/pthread/fd_pipe.h
deleted file mode 100755
index 1561eeb6a7e..00000000000
--- a/lib/libpthread/include/pthread/fd_pipe.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* ==== fd_pipe.h ============================================================
- * Copyright (c) 1993 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 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.
- *
- * $Id: fd_pipe.h,v 1.1 1998/07/21 13:19:11 peter Exp $
- *
- * Description : The new fast ITC pipe header.
- *
- * 1.00 93/08/14 proven
- * -Started coding this file.
- */
-
-struct __pipe {
- semaphore lock;
- char * buf;
- int size;
- int flags;
- int count;
- int offset;
- struct pthread * wait;
- char * wait_buf;
- size_t wait_size;
-};
-
-#define RD_CLOSED 0x01
-#define WR_CLOSED 0x02
-
diff --git a/lib/libpthread/include/pthread/kernel.h b/lib/libpthread/include/pthread/kernel.h
deleted file mode 100755
index 71518becced..00000000000
--- a/lib/libpthread/include/pthread/kernel.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* ==== kernel.h ============================================================
- * Copyright (c) 1993 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 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.
- *
- * $Id: kernel.h,v 1.1 1998/07/21 13:19:11 peter Exp $
- *
- * Description : mutex header.
- *
- * 1.00 93/07/22 proven
- * -Started coding this file.
- */
-
-/*
- * Defines only for the pthread user kernel.
- */
-#if defined(PTHREAD_KERNEL)
-
-#ifdef __GNUC__
-#include <assert.h>
-#endif
-#ifdef __ASSERT_FUNCTION
-#define PANIC() panic_kernel( __FILE__, __LINE__, __ASSERT_FUNCTION )
-#else
-#define PANIC() panic_kernel( __FILE__, __LINE__, (const char *)0 )
-#endif
-
-
-/* Time each rr thread gets */
-#define PTHREAD_RR_TIMEOUT 100000000
-
-/* Set the errno value */
-#define SET_ERRNO(x) \
-{ \
- if (!pthread_run->error_p) { \
- pthread_run->error_p = &pthread_run->error; \
- } \
- (*(pthread_run->error_p)) = x; \
-}
-
-/* Globals only the internals should see */
-extern struct pthread_prio_queue * pthread_current_prio_queue;
-extern volatile int pthread_kernel_lock;
-
-#endif
diff --git a/lib/libpthread/include/pthread/kthread.h b/lib/libpthread/include/pthread/kthread.h
deleted file mode 100755
index e9eed520ae9..00000000000
--- a/lib/libpthread/include/pthread/kthread.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* ==== kthread.h ============================================================
- * Copyright (c) 1993, 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 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.
- *
- * $Id: kthread.h,v 1.1 1998/07/21 13:19:11 peter Exp $
- *
- * Description : Basic pthread header.
- *
- * 1.00 93/07/20 proven
- * -Started coding this file.
- *
- * 1.32 94/05/25 proven
- * -Started adding kernel thread support
- */
-
-#ifndef _KTHREAD_H_
-#define _KTHREAD_H_
-
-enum kthread_state {
- KS_RUNNING,
- KS_DEAD,
-};
-
-struct kthread {
- enum kthread_state state;
-
- struct pthread_queue pthread_current_queue;
- struct pthread * pthread_link_list;
- struct pthread * pthread_run;
-
- semaphore lock;
-
-};
-
-/*
- * Globals
- */
-extern struct kthread * kthread_link_list;
-
-#endif
diff --git a/lib/libpthread/include/pthread/mutex.h b/lib/libpthread/include/pthread/mutex.h
deleted file mode 100755
index 273ae461e69..00000000000
--- a/lib/libpthread/include/pthread/mutex.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* ==== mutex.h ============================================================
- * Copyright (c) 1993 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 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.
- *
- * $Id: mutex.h,v 1.1 1998/07/21 13:19:11 peter Exp $
- *
- * Description : mutex header.
- *
- * 1.00 93/07/20 proven
- * -Started coding this file.
- */
-
-/*
- * New mutex structures
- */
-enum pthread_mutextype {
- MUTEX_TYPE_STATIC_FAST = 0,
- MUTEX_TYPE_FAST = 1,
- MUTEX_TYPE_COUNTING_FAST = 2, /* Recursive */
- MUTEX_TYPE_METERED = 3,
- MUTEX_TYPE_DEBUG = 4, /* This will have lots of options */
- MUTEX_TYPE_MAX
-};
-
-#define PTHREAD_MUTEXTYPE_FAST 1
-#define PTHREAD_MUTEXTYPE_DEBUG 4
-#define PTHREAD_MUTEXTYPE_RECURSIVE 2
-
-union pthread_mutex_data {
- void * m_ptr;
- int m_count;
-};
-
-typedef struct pthread_mutex {
- enum pthread_mutextype m_type;
- struct pthread_queue m_queue;
- struct pthread * m_owner;
- semaphore m_lock;
- union pthread_mutex_data m_data;
- long m_flags;
-} pthread_mutex_t;
-
-typedef struct pthread_mutexattr {
- enum pthread_mutextype m_type;
- long m_flags;
-} pthread_mutexattr_t;
-
-/*
- * 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_INITIALIZER \
-{ MUTEX_TYPE_STATIC_FAST, PTHREAD_QUEUE_INITIALIZER, \
- NULL, SEMAPHORE_CLEAR, { NULL }, MUTEX_FLAGS_INITED }
-
-/*
- * New functions
- */
-
-__BEGIN_DECLS
-
-int pthread_mutex_init __P_((pthread_mutex_t *, const pthread_mutexattr_t *));
-int pthread_mutex_lock __P_((pthread_mutex_t *));
-int pthread_mutex_unlock __P_((pthread_mutex_t *));
-int pthread_mutex_trylock __P_((pthread_mutex_t *));
-int pthread_mutex_destroy __P_((pthread_mutex_t *));
-
-__END_DECLS
-
diff --git a/lib/libpthread/include/pthread/paths.h b/lib/libpthread/include/pthread/paths.h
deleted file mode 100755
index 3d695546bc3..00000000000
--- a/lib/libpthread/include/pthread/paths.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef _SYS___PATHS_H_
-#define _SYS___PATHS_H_
-#define _PATH_PTY "/devices/pseudo/"
-#define _PATH_TZDIR "/usr/share/lib/zoneinfo"
-#define _PATH_TZFILE "/usr/share/lib/zoneinfo/localtime"
-#define _PATH_RESCONF "/etc/resolv.conf"
-#define _PATH_HOSTS "/etc/hosts"
-#define _PATH_NETWORKS "/etc/networks"
-#define _PATH_PROTOCOLS "/etc/protocols"
-#define _PATH_SERVICES "/etc/services"
-#define _PATH_BSHELL "/bin/sh"
-#endif
diff --git a/lib/libpthread/include/pthread/posix.h b/lib/libpthread/include/pthread/posix.h
deleted file mode 100644
index 87eae80835e..00000000000
--- a/lib/libpthread/include/pthread/posix.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* ==== posix.h ============================================================
- * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Convert an Ultrix-4.2 system to a more or less POSIX system.
- *
- * $Id: posix.h,v 1.1 1998/07/21 19:50:19 peter Exp $
- *
- * 1.00 93/07/20 proven
- * -Started coding this file.
- */
-
-#ifndef _PTHREAD_POSIX_H_
-#define _PTHREAD_POSIX_H_
-
-#include <sys/cdefs.h>
-
-/* More stuff for compiling */
-#if defined(__GNUC__)
-#define __INLINE extern inline
-#else
-#define __INLINE static
-#endif
-
-/* Make sure we have size_t defined */
-#include <pthread/types.h>
-
-#ifndef __WAIT_STATUS
-#define __WAIT_STATUS int *
-#endif
-
-#endif
diff --git a/lib/libpthread/include/pthread/prio_queue.h b/lib/libpthread/include/pthread/prio_queue.h
deleted file mode 100755
index d9c84ad25ed..00000000000
--- a/lib/libpthread/include/pthread/prio_queue.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* ==== priority.h ==========================================================
- * 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 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.
- *
- * $Id: prio_queue.h,v 1.1 1998/07/21 13:19:12 peter Exp $
- *
- * Description : Priority functions.
- *
- * 1.00 94/09/19 proven
- * -Started coding this file.
- */
-
-#ifndef _PTHREAD_PRIO_QUEUE_H_
-#define _PTHREAD_PRIO_QUEUE_H_
-
-/*
- * Static queue initialization values.
- */
-#define PTHREAD_DEFAULT_PRIORITY 64
-#define PTHREAD_MAX_PRIORITY 126
-#define PTHREAD_MIN_PRIORITY 0
-
-/*
- * New prio_queue structures
- */
-struct pthread_prio_level {
- struct pthread * first;
- struct pthread * last;
-};
-
-struct pthread_prio_queue {
- void * data;
- struct pthread * next;
- struct pthread_prio_level level[PTHREAD_MAX_PRIORITY + 1];
-};
-
-/*
- * New functions
- */
-
-__BEGIN_DECLS
-
-void pthread_prio_queue_init __P_((struct pthread_prio_queue *));
-void pthread_prio_queue_enq __P_((struct pthread_prio_queue *,
- struct pthread *));
-struct pthread *pthread_prio_queue_deq
- __P_((struct pthread_prio_queue *));
-
-__END_DECLS
-
-#endif
diff --git a/lib/libpthread/include/pthread/pthread_attr.h b/lib/libpthread/include/pthread/pthread_attr.h
deleted file mode 100755
index 2602c1fa9c2..00000000000
--- a/lib/libpthread/include/pthread/pthread_attr.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/* ==== pthread_attr.h ========================================================
- * Copyright (c) 1993 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 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.
- *
- * $Id: pthread_attr.h,v 1.1 1998/07/21 13:19:12 peter Exp $
- *
- * Description : Basic pthread attributes header.
- *
- * 1.00 93/11/03 proven
- * -Started coding this file.
- */
-
-#define _POSIX_THREAD_ATTR_STACKSIZE
-
-#define PTHREAD_STACK_DEFAULT 65536
-
-/* flags */
-#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
-
-/*
- * New pthread attribute types.
- */
-enum schedparam_policy {
- SCHED_RR,
- SCHED_IO,
- SCHED_FIFO,
- SCHED_OTHER
-};
-
-struct pthread_attr {
- enum schedparam_policy schedparam_policy;
- int sched_priority;
-
- int flags;
- void * arg_attr;
- void (*cleanup_attr)();
- void * stackaddr_attr;
- size_t stacksize_attr;
-};
-
-struct sched_param {
- int sched_priority;
- void * no_data;
-};
-
-/*
- * New functions
- */
-
-__BEGIN_DECLS
-
-#if defined(DCE_COMPAT)
-
-typedef struct pthread_attr * pthread_attr_t;
-
-int pthread_attr_create __P_((pthread_attr_t *));
-int pthread_attr_delete __P_((pthread_attr_t *));
-
-#else
-
-typedef struct pthread_attr pthread_attr_t;
-
-int pthread_attr_init __P_((pthread_attr_t *));
-int pthread_attr_destroy __P_((pthread_attr_t *));
-int pthread_attr_setstacksize __P_((pthread_attr_t *, size_t));
-int pthread_attr_getstacksize __P_((pthread_attr_t *, size_t *));
-int pthread_attr_setstackaddr __P_((pthread_attr_t *, void *));
-int pthread_attr_getstackaddr __P_((pthread_attr_t *, void **));
-int pthread_attr_setdetachstate __P_((pthread_attr_t *, int ));
-int pthread_attr_getdetachstate __P_((pthread_attr_t *, int *));
-int pthread_attr_setscope __P_((pthread_attr_t *, int ));
-int pthread_attr_getscope __P_((pthread_attr_t *, int *));
-int pthread_attr_setinheritsched __P_((pthread_attr_t *, int ));
-int pthread_attr_getinheritsched __P_((pthread_attr_t *, int *));
-int pthread_attr_setschedpolicy __P_((pthread_attr_t *, int ));
-int pthread_attr_getschedpolicy __P_((pthread_attr_t *, int *));
-int pthread_attr_setschedparam __P_((pthread_attr_t *, struct sched_param *));
-int pthread_attr_getschedparam __P_((pthread_attr_t *, struct sched_param *));
-
-int pthread_attr_setfloatstate __P_((pthread_attr_t *, int ));
-int pthread_attr_getfloatstate __P_((pthread_attr_t *, int *));
-int pthread_attr_setcleanup __P_((pthread_attr_t *, void (*routine)(void *),
- void *));
-
-#endif
-
-__END_DECLS
diff --git a/lib/libpthread/include/pthread/pthread_once.h b/lib/libpthread/include/pthread/pthread_once.h
deleted file mode 100755
index a9395c0f7fe..00000000000
--- a/lib/libpthread/include/pthread/pthread_once.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* ==== pthread_once.h ========================================================
- * Copyright (c) 1993 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 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.
- *
- * $Id: pthread_once.h,v 1.1 1998/07/21 13:19:12 peter Exp $
- *
- * Description : mutex header.
- *
- * 1.00 93/12/12 proven
- * -Started coding this file.
- */
-
-/* New pthread_once structures */
-typedef struct pthread_once {
- int state;
- pthread_mutex_t mutex;
-} pthread_once_t;
-
-/* Static pthread_once_t initialization value. */
-#define PTHREAD_NEEDS_INIT 0
-#define PTHREAD_DONE_INIT 1
-#define PTHREAD_ONCE_INIT { PTHREAD_NEEDS_INIT, PTHREAD_MUTEX_INITIALIZER }
-
-/* New functions */
-
-__BEGIN_DECLS
-
-int pthread_once __P_((pthread_once_t *, void (*init_routine)(void)));
-
-__END_DECLS
-
diff --git a/lib/libpthread/include/pthread/queue.h b/lib/libpthread/include/pthread/queue.h
deleted file mode 100755
index 0d7d2d219e3..00000000000
--- a/lib/libpthread/include/pthread/queue.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* ==== queue.h ============================================================
- * Copyright (c) 1993 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 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.
- *
- * $Id: queue.h,v 1.1 1998/07/21 13:19:12 peter Exp $
- *
- * Description : mutex header.
- *
- * 1.00 93/07/20 proven
- * -Started coding this file.
- */
-
-/*
- * New queue structures
- */
-struct pthread_queue {
- struct pthread *q_next;
- struct pthread *q_last;
- void *q_data;
-};
-
-/*
- * Static queue initialization values.
- */
-#define PTHREAD_QUEUE_INITIALIZER { NULL, NULL, NULL }
-
-/*
- * New functions
- * Should make pthread_queue_get a macro
- */
-
-__BEGIN_DECLS
-
-void pthread_queue_init __P_((struct pthread_queue *));
-void pthread_queue_enq __P_((struct pthread_queue *, struct pthread *));
-int pthread_queue_remove __P_((struct pthread_queue *, struct pthread *));
-struct pthread *pthread_queue_get __P_((struct pthread_queue *));
-struct pthread *pthread_queue_deq __P_((struct pthread_queue *));
-
-__END_DECLS
diff --git a/lib/libpthread/include/pthread/sleep.h b/lib/libpthread/include/pthread/sleep.h
deleted file mode 100755
index 9f8f2dccd95..00000000000
--- a/lib/libpthread/include/pthread/sleep.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* ==== sleep.h ============================================================
- * 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 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.
- *
- * $Id: sleep.h,v 1.1 1998/07/21 13:19:12 peter Exp $
- *
- * Description : sleep header.
- *
- * 1.00 94/06/04 proven
- * -Started coding this file.
- */
-
-#if defined(PTHREAD_KERNEL)
-
-#include <timers.h>
-
-/*
- * New functions
- */
-static inline int machdep_gettimeofday(struct timespec * current_time)
-{
- struct timeval current_real_time;
- int ret;
-
- ret = gettimeofday(&current_real_time, NULL);
- TIMEVAL_TO_TIMESPEC((&current_real_time), current_time);
- return(ret);
-}
-
-__BEGIN_DECLS
-
-void sleep_schedule __P_((struct timespec *, struct timespec *));
-
-__END_DECLS
-
-#endif
diff --git a/lib/libpthread/include/pthread/specific.h b/lib/libpthread/include/pthread/specific.h
deleted file mode 100755
index 6757ceeb08e..00000000000
--- a/lib/libpthread/include/pthread/specific.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* ==== specific.h ========================================================
- * 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 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.
- *
- * $Id: specific.h,v 1.1 1998/07/21 13:19:12 peter Exp $
- *
- * Description : Thread specific data management header.
- *
- * 1.20 94/03/30 proven
- * -Started coding this file.
- */
-
-#define PTHREAD_DATAKEYS_MAX 256
-#define _POSIX_THREAD_DESTRUTOR_ITERATIONS 4
-
-/*
- * New thread specific key type.
- */
-struct pthread_key {
- pthread_mutex_t mutex;
- long count;
- void (*destructor)();
-};
-
-typedef int pthread_key_t;
-
-/*
- * New functions
- */
-
-__BEGIN_DECLS
-
-int pthread_key_create __P_((pthread_key_t *, void (*routine)(void *)));
-int pthread_setspecific __P_((pthread_key_t, const void *));
-void *pthread_getspecific __P_((pthread_key_t));
-int pthread_key_delete __P_((pthread_key_t));
-
-__END_DECLS
-
diff --git a/lib/libpthread/include/pthread/state.def b/lib/libpthread/include/pthread/state.def
deleted file mode 100755
index c62d102a9f0..00000000000
--- a/lib/libpthread/include/pthread/state.def
+++ /dev/null
@@ -1,64 +0,0 @@
-/* This file defines the states that a given thread can be in.
-
- The funky macro use here is so that this one header file can also
- define the corresponding state names, so that the two lists can't
- get inconsistent within a given source tree. */
-
-/* The thread is runnable. */
-__pthread_defstate (PS_RUNNING, "running")
-
-/*
- * The rest of the states are where the thread is waiting on some event.
- * Someday maybe the "data" field will point to the object being waited for.
- */
-
-/* Waiting for a mutex (pthread_mutex_lock()). */
-__pthread_defstate (PS_MUTEX_WAIT, "mutex")
-
-/* Waiting on a condition variable
- (pthread_cond_wait(), or pthread_cond_timedwait()). */
-__pthread_defstate (PS_COND_WAIT, "cond")
-
-/*
- * File descriptor stuff.
- *
- * File descriptors have a special lock. If it is a FULL_DUPLEX fd such as
- * a socket or fifo then it has two mutexes, one for reads and one for writes.
- * Some routines will even try to get both. It will always try to get the
- * read lock first before tring to get the write. All other fds only have
- * one mutex which all calls will get. It is displayed as if it is a read lock.
- */
-/* Waiting on a fd read lock (fd_lock()) */
-__pthread_defstate (PS_FDLR_WAIT, "fdlr")
-
-/* Waiting on a fd write lock (fd_lock()) */
-__pthread_defstate (PS_FDLW_WAIT, "fdlw")
-
-/* Waiting for the kernel fd to have data to read,
- (read(), readv(), recv(), recvfrom(), and recvmsg()). */
-__pthread_defstate (PS_FDR_WAIT, "fdr") /* Waiting on a kernel read */
-
-/* Waiting for the kernel fd to allow a write
- (write(), writev(), send(), sendto(), sendmsg()) */
-__pthread_defstate (PS_FDW_WAIT, "fdw")
-
-/* Waiting for several fds in a select() */
-__pthread_defstate (PS_SELECT_WAIT, "select")
-
-/* Waiting on a sleep (sleep(), usleep() or nanosleep()). */
-__pthread_defstate (PS_SLEEP_WAIT, "sleep")
-
-/* Waiting for a child to die (wait(), waitpid(), wait3(), or wait4()). */
-__pthread_defstate (PS_WAIT_WAIT, "wait")
-
-/* Waiting on some set of signals (sigwait()) */
-__pthread_defstate (PS_SIGWAIT, "sig")
-
-/* Waiting for a thread to die (pthread_join()) */
-__pthread_defstate (PS_JOIN, "join")
-
-/* Waiting for some thread to join with me or detach me */
-__pthread_defstate (PS_DEAD, "dead")
-
-/* Waiting for some thread to create me */
-__pthread_defstate (PS_UNALLOCED, "unallocated")
diff --git a/lib/libpthread/include/pthread/types.h b/lib/libpthread/include/pthread/types.h
deleted file mode 100755
index 7fdf001a0bc..00000000000
--- a/lib/libpthread/include/pthread/types.h
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef pthread_types_h
-#define pthread_types_h
-
-#include <pthread/xtypes.h>
-#include <pthread/ac-types.h>
-
-#if !defined (pthread_va_list) && defined (__NetBSD__)
-#include <stdarg.h>
-#define pthread_va_list _BSD_VA_LIST_
-#endif
-
-#if !defined (pthread_va_list) && defined (__GNUC__)
-#define __need_va_list
-#include <stdarg.h>
-#define pthread_va_list __gnuc_va_list
-#endif /* pthread_va_list, __GNUC__ */
-
-/* OSF/1 does it this way. */
-#if !defined (pthread_va_list) && defined (pthread_have_va_list_h)
-#ifndef _VA_LIST
-#define _HIDDEN_VA_LIST
-#include <va_list.h>
-#define pthread_va_list __va_list
-#else
-/* va_list has already been defined */
-#define pthread_va_list va_list
-#endif
-#endif
-
-/* If all else fails... */
-#ifndef pthread_va_list
-#include <stdarg.h>
-#define pthread_va_list va_list
-#endif
-
-#if defined(__STDC__) || defined(__GNUC__)
-#ifndef __P_
-#define __P_(protos) protos
-#endif
-#else
-#ifndef __P_
-#define __P_(protos)
-#endif
-#endif
-
-#endif /* pthread_types_h */
diff --git a/lib/libpthread/include/pthread/unistd.h b/lib/libpthread/include/pthread/unistd.h
deleted file mode 100755
index 3cb07533114..00000000000
--- a/lib/libpthread/include/pthread/unistd.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/*-
- * Copyright (c) 1991 The Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * @(#)unistd.h 5.13 (Berkeley) 6/17/91
- */
-
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-void _exit __P_((int));
-int access __P_((const char *, int));
-int chdir __P_((const char *));
-int chown __P_((const char *, uid_t, gid_t));
-int close __P_((int));
-int dup __P_((int));
-int dup2 __P_((int, int));
-int execve __P_((const char *, char * const *, char * const *));
-pid_t fork __P_((void));
-int isatty __P_((int));
-int link __P_((const char *, const char *));
-off_t lseek __P_((int, off_t, int));
-int pipe __P_((int *));
-ssize_t read __P_((int, void *, size_t));
-u_int sleep __P_((u_int));
-char *ttyname __P_((int));
-int unlink __P_((const char *));
-ssize_t write __P_((int, const void *, size_t));
-
-/* Not implemented for threads yet */
-u_int alarm __P_((u_int));
-char *cuserid __P_((char *));
-int execl __P_((const char *, const char *, ...));
-int execle __P_((const char *, const char *, ...));
-int execlp __P_((const char *, const char *, ...));
-int execv __P_((const char *, char * const *));
-int execvp __P_((const char *, char * const *));
-long fpathconf __P_((int, int)); /* not yet */
-char *getcwd __P_((char *, size_t));
-gid_t getegid __P_((void));
-uid_t geteuid __P_((void));
-gid_t getgid __P_((void));
-int getgroups __P_((int, int *)); /* XXX (gid_t *) */
-char *getlogin __P_((void));
-pid_t getpgrp __P_((void));
-pid_t getpid __P_((void));
-pid_t getppid __P_((void));
-uid_t getuid __P_((void));
-long pathconf __P_((const char *, int)); /* not yet */
-int pause __P_((void));
-int rmdir __P_((const char *));
-int setgid __P_((gid_t));
-int setpgid __P_((pid_t, pid_t));
-pid_t setsid __P_((void));
-int setuid __P_((uid_t));
-long sysconf __P_((int)); /* not yet */
-pid_t tcgetpgrp __P_((int));
-int tcsetpgrp __P_((int, pid_t));
-
-#ifndef _POSIX_SOURCE
-
-int acct __P_((const char *));
-int async_daemon __P_((void));
-char *brk __P_((const char *));
-int chflags __P_((const char *, long));
-int chroot __P_((const char *));
-char *crypt __P_((const char *, const char *));
-int des_cipher __P_((const char *, char *, long, int));
-int des_setkey __P_((const char *key));
-int encrypt __P_((char *, int));
-void endusershell __P_((void));
-int exect __P_((const char *, char * const *, char * const *));
-int fchdir __P_((int));
-int fchflags __P_((int, long));
-int fchown __P_((int, uid_t, gid_t));
-int fsync __P_((int));
-int ftruncate __P_((int, off_t));
-int getdtablesize __P_((void));
-long gethostid __P_((void));
-int gethostname __P_((char *, int));
-mode_t getmode __P_((const void *, mode_t));
-int getpagesize __P_((void));
-char *getpass __P_((const char *));
-char *getusershell __P_((void));
-char *getwd __P_((char *)); /* obsoleted by getcwd() */
-int initgroups __P_((const char *, int));
-int mknod __P_((const char *, mode_t, dev_t));
-int mkstemp __P_((char *));
-char *mktemp __P_((char *));
-int nfssvc __P_((int));
-int nice __P_((int));
-void psignal __P_((u_int, const char *));
-extern char *sys_siglist[];
-int profil __P_((char *, int, int, int));
-int rcmd __P_((char **, int, const char *,
- const char *, const char *, int *));
-char *re_comp __P_((const char *));
-int re_exec __P_((const char *));
-int readlink __P_((const char *, char *, int));
-int reboot __P_((int));
-int revoke __P_((const char *));
-int rresvport __P_((int *));
-int ruserok __P_((const char *, int, const char *, const char *));
-char *sbrk __P_((int));
-int setegid __P_((gid_t));
-int seteuid __P_((uid_t));
-int setgroups __P_((int, const int *));
-void sethostid __P_((long));
-int sethostname __P_((const char *, int));
-int setkey __P_((const char *));
-int setlogin __P_((const char *));
-void *setmode __P_((const char *));
-int setpgrp __P_((pid_t pid, pid_t pgrp)); /* obsoleted by setpgid() */
-int setregid __P_((int, int));
-int setreuid __P_((int, int));
-int setrgid __P_((gid_t));
-int setruid __P_((uid_t));
-void setusershell __P_((void));
-int swapon __P_((const char *));
-int symlink __P_((const char *, const char *));
-void sync __P_((void));
-int syscall __P_((int, ...));
-int truncate __P_((const char *, off_t));
-int ttyslot __P_((void));
-u_int ualarm __P_((u_int, u_int));
-void usleep __P_((u_int));
-int vfork __P_((void));
-
-#endif /* !_POSIX_SOURCE */
-__END_DECLS
-
diff --git a/lib/libpthread/include/pthread/util.h b/lib/libpthread/include/pthread/util.h
deleted file mode 100755
index c9ff1dbcabd..00000000000
--- a/lib/libpthread/include/pthread/util.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* ==== util.h ============================================================
- * Copyright (c) 1991, 1992, 1993 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 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.
- *
- * $Id: util.h,v 1.1 1998/07/21 13:19:12 peter Exp $
- *
- * Description : Header file for generic utility functions.
- *
- * 91/08/31 proven - Added exchange.
- * Exchange any two objects of any size in any table.
- *
- * 91/10/06 proven - Cleaned out all the old junk.
- *
- * 91/03/06 proven - Added getint.
- */
-
-#ifndef _PTHREAD_UTIL_H
-#define _PTHREAD_UTIL_H
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-/* Stuff only pthread internals really uses */
-#if defined(PTHREAD_KERNEL)
-
-#undef FALSE
-#undef TRUE
-
-typedef enum Boolean {
- FALSE,
- TRUE
-} Boolean;
-
-#define OK 0
-#define NUL '\0'
-#define NOTOK -1
-
-#if ! defined(min)
-#define min(a,b) (((a)<(b))?(a):(b))
-#define max(a,b) (((a)>(b))?(a):(b))
-#endif
-
-/* Alingn the size to the next multiple of 4 bytes */
-#define ALIGN4(size) ((size + 3) & ~3)
-#define ALIGN8(size) ((size + 7) & ~7)
-
-#ifdef DEBUG
-#define DEBUG0(s) printf(s)
-#define DEBUG1(s,a) printf(s,a)
-#define DEBUG2(s,a,b) printf(s,a,b)
-#define DEBUG3(s,a,b,c) printf(s,a,b,c)
-#else
-#define DEBUG0(s)
-#define DEBUG1(s)
-#define DEBUG2(s)
-#define DEBUG3(s)
-#endif
-
-#endif
-
-#endif
diff --git a/lib/libpthread/include/pthread/version.h b/lib/libpthread/include/pthread/version.h
deleted file mode 100755
index ae0cbc6f4cb..00000000000
--- a/lib/libpthread/include/pthread/version.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* ==== version.h ============================================================
- * 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 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.
- *
- * $Id: version.h,v 1.1 1998/07/21 13:19:12 peter Exp $
- *
- * Description : Header file for programs that what to KNOW the version.
- *
- * 94/08/24 proven - Added this file for pthreads.
- */
-
-#ifndef _PTHREAD_VERSION_H
-#define _PTHREAD_VERSION_H 1
-#define _PTHREAD_VERSION_M 60
-#define _PTHREAD_VERSION_P 0
-#endif
diff --git a/lib/libpthread/include/pthread/xtypes.h b/lib/libpthread/include/pthread/xtypes.h
deleted file mode 100755
index 4dcc4f04f8c..00000000000
--- a/lib/libpthread/include/pthread/xtypes.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/* If you need any special typedefs for function pointers &c to try
- testing for in configure.in, define them here. */
-
-/* According to ANSI, two struct types in the same module are not
- compatible types. So there's no way to define a type for
- pthread_sigset_t that's compatible with sigset_t when they're
- structure types, if we assume we can't pull in a __sigset_t or
- something by itself from system header files.
-
- Since that was my main reason for creating this file, there isn't
- anything here now. If after working on this code a bit longer we
- don't find anything else to put here, this file should just go
- away. */
diff --git a/lib/libpthread/include/pwd.h b/lib/libpthread/include/pwd.h
deleted file mode 100644
index 4607080607a..00000000000
--- a/lib/libpthread/include/pwd.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*-
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * from: @(#)pwd.h 8.2 (Berkeley) 1/21/94
- * $Id: pwd.h,v 1.1 1998/07/21 13:19:08 peter Exp $
- */
-
-#ifndef _PWD_H_
-#define _PWD_H_
-
-#include <sys/types.h>
-
-#ifndef _POSIX_SOURCE
-#define _PATH_PASSWD "/etc/passwd"
-#define _PATH_MASTERPASSWD "/etc/master.passwd"
-
-#define _PATH_MP_DB "/etc/pwd.db"
-#define _PATH_SMP_DB "/etc/spwd.db"
-
-#define _PATH_PWD_MKDB "/usr/sbin/pwd_mkdb"
-
-#define _PW_KEYBYNAME '1' /* stored by name */
-#define _PW_KEYBYNUM '2' /* stored by entry in the "file" */
-#define _PW_KEYBYUID '3' /* stored by uid */
-
-#define _PASSWORD_EFMT1 '_' /* extended encryption format */
-
-#define _PASSWORD_LEN 128 /* max length, not counting NULL */
-#endif
-
-struct passwd {
- char *pw_name; /* user name */
- char *pw_passwd; /* encrypted password */
- int pw_uid; /* user uid */
- int pw_gid; /* user gid */
- time_t pw_change; /* password change time */
- char *pw_class; /* user access class */
- char *pw_gecos; /* Honeywell login info */
- char *pw_dir; /* home directory */
- char *pw_shell; /* default shell */
- time_t pw_expire; /* account expiration */
-};
-
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-struct passwd *getpwuid __P_((uid_t));
-struct passwd *getpwnam __P_((const char *));
-#ifndef _POSIX_SOURCE
-struct passwd *getpwent __P_((void));
-#ifndef _XOPEN_SOURCE
-int setpassent __P_((int));
-#endif
-void setpwent __P_((void));
-void endpwent __P_((void));
-#endif
-__END_DECLS
-
-#endif /* !_PWD_H_ */
diff --git a/lib/libpthread/include/resolv.h b/lib/libpthread/include/resolv.h
deleted file mode 100644
index 7e2fcc7a5da..00000000000
--- a/lib/libpthread/include/resolv.h
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (c) 1983, 1987, 1989 The Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * from: @(#)resolv.h 5.15 (Berkeley) 4/3/91
- * $Id: resolv.h,v 1.1 1998/07/21 13:19:08 peter Exp $
- */
-
-#ifndef _RESOLV_H_
-#define _RESOLV_H_
-
-#include <netinet/in.h>
-/*
- * This is specificly for Solaris which defines NOERROR in the streams
- * header files and defines it differently than in arpa/nameser.h
- */
-#ifdef NOERROR
-#undef NOERROR
-#endif
-#include <arpa/nameser.h>
-
-/*
- * revision information. this is the release date in YYYYMMDD format.
- * it can change every day so the right thing to do with it is use it
- * in preprocessor commands such as "#if (__RES > 19931104)". do not
- * compare for equality; rather, use it to determine whether your resolver
- * is new enough to contain a certain feature.
- */
-
-#define __RES 19940703
-
-/*
- * Resolver configuration file.
- * Normally not present, but may contain the address of the
- * inital name server(s) to query and the domain search list.
- */
-
-#ifndef _PATH_RESCONF
-#define _PATH_RESCONF "/etc/resolv.conf"
-#endif
-
-/*
- * Global defines and variables for resolver stub.
- */
-#define MAXNS 3 /* max # name servers we'll track */
-#define MAXDFLSRCH 3 /* # default domain levels to try */
-#define MAXDNSRCH 6 /* max # domains in search path */
-#define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */
-#define MAXDNSLUS 4 /* max # of host lookup types */
-
-#define RES_TIMEOUT 5 /* min. seconds between retries */
-#define MAXRESOLVSORT 10 /* number of net to sort on */
-#define RES_MAXNDOTS 15 /* should reflect bit field size */
-
-struct __res_state {
- int retrans; /* retransmition time interval */
- int retry; /* number of times to retransmit */
- long options; /* option flags - see below. */
- int nscount; /* number of name servers */
- struct sockaddr_in nsaddr_list[MAXNS]; /* address of name server */
-#define nsaddr nsaddr_list[0] /* for backward compatibility */
- u_short id; /* current packet id */
- char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */
- char defdname[MAXDNAME]; /* default domain */
- long pfcode; /* RES_PRF_ flags - see below. */
- u_char ndots:4; /* threshold for initial abs. query */
- u_char nsort:4; /* number of elements in sort_list[] */
- char unused[3];
- struct {
- struct in_addr addr;
- u_long mask;
- } sort_list[MAXRESOLVSORT];
- char lookups[MAXDNSLUS];
-};
-
-/*
- * Resolver options
- */
-#define RES_INIT 0x0001 /* address initialized */
-#define RES_DEBUG 0x0002 /* print debug messages */
-#define RES_AAONLY 0x0004 /* authoritative answers only */
-#define RES_USEVC 0x0008 /* use virtual circuit */
-#define RES_PRIMARY 0x0010 /* query primary server only */
-#define RES_IGNTC 0x0020 /* ignore trucation errors */
-#define RES_RECURSE 0x0040 /* recursion desired */
-#define RES_DEFNAMES 0x0080 /* use default domain name */
-#define RES_STAYOPEN 0x0100 /* Keep TCP socket open */
-#define RES_DNSRCH 0x0200 /* search up local domain tree */
-
-#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
-
-/*
- * Resolver "pfcode" values. Used by dig.
- */
-#define RES_PRF_STATS 0x0001
-/* 0x0002 */
-#define RES_PRF_CLASS 0x0004
-#define RES_PRF_CMD 0x0008
-#define RES_PRF_QUES 0x0010
-#define RES_PRF_ANS 0x0020
-#define RES_PRF_AUTH 0x0040
-#define RES_PRF_ADD 0x0080
-#define RES_PRF_HEAD1 0x0100
-#define RES_PRF_HEAD2 0x0200
-#define RES_PRF_TTLID 0x0400
-#define RES_PRF_HEADX 0x0800
-#define RES_PRF_QUERY 0x1000
-#define RES_PRF_REPLY 0x2000
-#define RES_PRF_INIT 0x4000
-/* 0x8000 */
-
-#define _res (*_res_status())
-#define h_errno (_res_get_error())
-
-#include <sys/cdefs.h>
-#include <stdio.h>
-
-/* Private routines shared between libc/net, named, nslookup and others. */
-#define dn_skipname __dn_skipname
-#define fp_query __fp_query
-#define hostalias __hostalias
-#define putlong __putlong
-#define putshort __putshort
-#define p_class __p_class
-#define p_time __p_time
-#define p_type __p_type
-__BEGIN_DECLS
-struct __res_state *_res_status __P_((void));
-int _res_get_error __P_((void));
-
-int __dn_skipname __P_((const u_char *, const u_char *));
-void __fp_query __P_((char *, FILE *));
-char *__hostalias __P_((const char *));
-void __putlong __P_((pthread_ipaddr_type, unsigned char *));
-void __putshort __P_((pthread_ipport_type, unsigned char *));
-char *__p_class __P_((int));
-char *__p_time __P_((unsigned long));
-char *__p_type __P_((int));
-
-int dn_comp __P_((const unsigned char *, unsigned char *, int,
- unsigned char **, unsigned char **));
-int dn_expand __P_((const unsigned char *, const unsigned char *,
- const unsigned char *, unsigned char *, int));
-int res_init __P_((void));
-int res_mkquery __P_((int, const char *, int, int, const char *, int,
- const char *, char *, int));
-int res_send __P_((const char *, int, char *, int));
-__END_DECLS
-
-#endif /* !_RESOLV_H_ */
-
diff --git a/lib/libpthread/include/signal.h b/lib/libpthread/include/signal.h
deleted file mode 100644
index 9fb1ec6e2c8..00000000000
--- a/lib/libpthread/include/signal.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*-
- * Copyright (c) 1991, 1993
- * The Regents of the University of California. 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * @(#)signal.h 8.3 (Berkeley) 3/30/94
- */
-
-#ifndef _SIGNAL_H
-#define _SIGNAL_H
-
-#include <sys/types.h>
-#include <sys/cdefs.h>
-#include <sys/__signal.h>
-
-__BEGIN_DECLS
-
-int raise __P_((int));
-/* RETSIGTYPE signal __P_((int __sig, RETSIGTYPE)); */
-
-#ifndef _ANSI_SOURCE
-
-int sigfillset __P_((sigset_t *));
-int sigemptyset __P_((sigset_t *));
-int sigaddset __P_((sigset_t *, int));
-int sigdelset __P_((sigset_t *, int));
-int sigismember __P_((const sigset_t *, int));
-int sigsuspend __P_((const sigset_t *));
-int sigprocmask __P_((int, const sigset_t *, sigset_t *));
-
-/* Still need work */
-int kill __P_((pid_t, int));
-int sigaction __P_((int, const struct sigaction *, struct sigaction *));
-int sigpending __P_((sigset_t *));
-
-#ifndef _POSIX_SOURCE
-
-int killpg __P_((pid_t, int));
-int siginterrupt __P_((int, int));
-void psignal __P_((unsigned int, const char *));
-
-/* int sigpause __P_((int)); */
-/* int sigsetmask __P_((int)); */
-/* int sigblock __P_((int)); */
-/* int sigreturn __P_((struct sigcontext *)); */
-/* int sigvec __P_((int, struct sigvec *, struct sigvec *)); */
-/* int sigstack __P_((const struct sigstack *, struct sigstack *)); */
-
-#endif /* !_POSIX_SOURCE */
-#endif /* !_ANSI_SOURCE */
-
-__END_DECLS
-
-#endif /* !_USER_SIGNAL_H */
diff --git a/lib/libpthread/include/stdio.h b/lib/libpthread/include/stdio.h
deleted file mode 100644
index 22b263edb75..00000000000
--- a/lib/libpthread/include/stdio.h
+++ /dev/null
@@ -1,371 +0,0 @@
-/* ==== stdio.h ============================================================
- * Copyright (c) 1990 The Regents of the University of California.
- * Copyright (c) 1993 by Chris Provenzano, proven@mit.edu
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * from: @(#)stdio.h 5.17 (Berkeley) 6/3/91
- * $Id: stdio.h,v 1.3 1998/07/21 13:53:52 peter Exp $
- */
-
-#ifndef _STDIO_H_
-#define _STDIO_H_
-
-#include <sys/cdefs.h>
-#include <pthread/types.h>
-#include <pthread/posix.h>
-#include <sys/__stdio.h>
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-#define _FSTDIO /* Define for new stdio with functions. */
-
-/*
- * NB: to fit things in six character monocase externals, the stdio
- * code uses the prefix `__s' for stdio objects, typically followed
- * by a three-character attempt at a mnemonic.
- */
-
-/* stdio buffers */
-struct __sbuf {
- unsigned char *_base;
- int _size;
-};
-
-/*
- * stdio state variables.
- *
- * The following always hold:
- *
- * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),
- * _lbfsize is -_bf._size, else _lbfsize is 0
- * if _flags&__SRD, _w is 0
- * if _flags&__SWR, _r is 0
- *
- * This ensures that the getc and putc macros (or inline functions) never
- * try to write or read from a file that is in `read' or `write' mode.
- * (Moreover, they can, and do, automatically switch from read mode to
- * write mode, and back, on "r+" and "w+" files.)
- *
- * _lbfsize is used only to make the inline line-buffered output stream
- * code as compact as possible.
- *
- * _ub, _up, and _ur are used when ungetc() pushes back more characters
- * than fit in the current _bf, or when ungetc() pushes back a character
- * that does not match the previous one in _bf. When this happens,
- * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff
- * _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
- */
-typedef struct __sFILE {
- unsigned char *_p; /* current position in (some) buffer */
- int _r; /* read space left for getc() */
- int _w; /* write space left for putc() */
- short _flags; /* flags, below; this FILE is free if 0 */
- short _file; /* fileno, if Unix descriptor, else -1 */
- struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */
- int _lbfsize; /* 0 or -_bf._size, for inline putc */
-
- /* separate buffer for long sequences of ungetc() */
- struct __sbuf _ub; /* ungetc buffer */
- unsigned char *_up; /* saved _p when _p is doing ungetc data */
- int _ur; /* saved _r when _r is counting ungetc data */
-
- /* tricks to meet minimum requirements even when malloc() fails */
- unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */
- unsigned char _nbuf[1]; /* guarantee a getc() buffer */
-
- /* separate buffer for fgetline() when line crosses buffer boundary */
- struct __sbuf _lb; /* buffer for fgetline() */
-
- /* Unix stdio files get aligned to block boundaries on fseek() */
- int _blksize; /* stat.st_blksize (may be != _bf._size) */
- int _offset; /* current lseek offset */
-} FILE;
-
-__BEGIN_DECLS
-extern FILE __sF[];
-__END_DECLS
-
-#define __SLBF 0x0001 /* line buffered */
-#define __SNBF 0x0002 /* unbuffered */
-#define __SRD 0x0004 /* OK to read */
-#define __SWR 0x0008 /* OK to write */
- /* RD and WR are never simultaneously asserted */
-#define __SRW 0x0010 /* open for reading & writing */
-#define __SEOF 0x0020 /* found EOF */
-#define __SERR 0x0040 /* found error */
-#define __SMBF 0x0080 /* _buf is from malloc */
-#define __SAPP 0x0100 /* fdopen()ed in append mode */
-#define __SSTR 0x0200 /* this is an sprintf/snprintf string */
-#define __SOPT 0x0400 /* do fseek() optimisation */
-#define __SNPT 0x0800 /* do not do fseek() optimisation */
-#define __SOFF 0x1000 /* set iff _offset is in fact correct */
-#define __SMOD 0x2000 /* true => fgetline modified _p text */
-
-/*
- * The following three definitions are for ANSI C, which took them
- * from System V, which brilliantly took internal interface macros and
- * made them official arguments to setvbuf(), without renaming them.
- * Hence, these ugly _IOxxx names are *supposed* to appear in user code.
- *
- * Although numbered as their counterparts above, the implementation
- * does not rely on this.
- */
-#define _IOFBF 0 /* setvbuf should set fully buffered */
-#define _IOLBF 1 /* setvbuf should set line buffered */
-#define _IONBF 2 /* setvbuf should set unbuffered */
-
-#define BUFSIZ 1024 /* size of buffer used by setbuf */
-#define EOF (-1)
-
-/*
- * FOPEN_MAX is a minimum maximum, and should be the number of descriptors
- * that the kernel can provide without allocation of a resource that can
- * fail without the process sleeping. Do not use this for anything.
- */
-#define FOPEN_MAX 20 /* must be <= OPEN_MAX <sys/syslimits.h> */
-#define FILENAME_MAX 1024 /* must be <= PATH_MAX <sys/syslimits.h> */
-
-/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */
-#ifndef _ANSI_SOURCE
-#define P_tmpdir "/var/tmp/"
-#endif
-#define L_tmpnam 1024 /* XXX must be == PATH_MAX */
-#ifndef TMP_MAX
-#define TMP_MAX 308915776
-#endif
-
-#ifndef SEEK_SET
-#define SEEK_SET 0 /* set file offset to offset */
-#endif
-#ifndef SEEK_CUR
-#define SEEK_CUR 1 /* set file offset to current plus offset */
-#endif
-#ifndef SEEK_END
-#define SEEK_END 2 /* set file offset to EOF plus offset */
-#endif
-
-#define stdin (&__sF[0])
-#define stdout (&__sF[1])
-#define stderr (&__sF[2])
-
-/*
- * Functions defined in ANSI C standard.
- */
-__BEGIN_DECLS
-void clearerr __P_((FILE *));
-int fclose __P_((FILE *));
-int feof __P_((FILE *));
-int ferror __P_((FILE *));
-int fflush __P_((FILE *));
-int fgetc __P_((FILE *));
-int fgetpos __P_((FILE *, fpos_t *));
-char * fgets __P_((char *, size_t, FILE *));
-FILE * fopen __P_((const char *, const char *));
-int fprintf __P_((FILE *, const char *, ...));
-int fputc __P_((int, FILE *));
-int fputs __P_((const char *, FILE *));
-size_t fread __P_((void *, size_t, size_t, FILE *));
-FILE * freopen __P_((const char *, const char *, FILE *));
-int fscanf __P_((FILE *, const char *, ...));
-int fseek __P_((FILE *, long, int));
-int fsetpos __P_((FILE *, const fpos_t *));
-long ftell __P_((const FILE *));
-size_t fwrite __P_((const void *, size_t, size_t, FILE *));
-int getc __P_((FILE *));
-int getchar __P_((void));
-char * gets __P_((char *));
-
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
-extern int sys_nerr; /* perror(3) external variables */
-/* Under NetBSD and BSD 4.4, at least, this is expected to be a const
- array of pointers to const. If you take `const' back out of this
- declaration, please make it conditional on __NetBSD__ and bsd4_4. */
-#ifdef HAVE_SYS_ERRLIST_WITHOUT_CONST
-extern char *sys_errlist[];
-#else
-extern const char *const sys_errlist[];
-#endif
-#endif
-
-void perror __P_((const char *));
-int printf __P_((const char *, ...));
-int putc __P_((int, FILE *));
-int putchar __P_((int));
-int puts __P_((const char *));
-int remove __P_((const char *));
-int rename __P_((const char *, const char *));
-void rewind __P_((FILE *));
-int scanf __P_((const char *, ...));
-void setbuf __P_((FILE *, char *));
-int setvbuf __P_((FILE *, char *, int, size_t));
-int sprintf __P_((char *, const char *, ...));
-int sscanf __P_((const char *, const char *, ...));
-FILE * tmpfile __P_((void));
-char * tmpnam __P_((char *));
-int ungetc __P_((int, FILE *));
-int vfprintf __P_((FILE *, const char *, pthread_va_list));
-int vprintf __P_((const char *, pthread_va_list));
-int vsprintf __P_((char *, const char *, pthread_va_list));
-char *mprintf __P_((const char *, ...));
-char *vmprintf __P_((const char *, pthread_va_list));
-__END_DECLS
-
-/*
- * Functions defined in POSIX 1003.1.
- */
-#ifndef _ANSI_SOURCE
-#define L_ctermid 1024 /* size for ctermid(); PATH_MAX */
-#define L_cuserid 9 /* size for cuserid(); UT_NAMESIZE + 1 */
-
-__BEGIN_DECLS
-char * ctermid __P_((char *));
-char * cuserid __P_((char *));
-FILE * fdopen __P_((int, const char *));
-int fileno __P_((FILE *));
-__END_DECLS
-#endif /* not ANSI */
-
-/*
- * Functions defined in POSIX 1003.4a. (1c)
- */
-#ifndef _ANSI_SOURCE
-__BEGIN_DECLS
-void flockfile __P_((FILE *));
-void funlockfile __P_((FILE *));
-int ftrylockfile __P_((FILE *));
-__END_DECLS
-#endif /* not ANSI */
-
-/*
- * Routines that are purely local.
- */
-#if !defined (_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
-__BEGIN_DECLS
-char *fgetline __P_((FILE *, size_t *));
-int fpurge __P_((FILE *));
-int getw __P_((FILE *));
-int pclose __P_((FILE *));
-FILE *popen __P_((const char *, const char *));
-int putw __P_((int, FILE *));
-void setbuffer __P_((FILE *, char *, int));
-int setlinebuf __P_((FILE *));
-char *tempnam __P_((const char *, const char *));
-int snprintf __P_((char *, size_t, const char *, ...));
-int vsnprintf __P_((char *, size_t, const char *, pthread_va_list));
-int vscanf __P_((const char *, pthread_va_list));
-int vsscanf __P_((const char *, const char *, pthread_va_list));
-__END_DECLS
-
-/*
- * This is a #define because the function is used internally and
- * (unlike vfscanf) the name __svfscanf is guaranteed not to collide
- * with a user function when _ANSI_SOURCE or _POSIX_SOURCE is defined.
- */
-#define vfscanf __svfscanf
-
-/*
- * Stdio function-access interface.
- */
-__BEGIN_DECLS
-FILE *funopen __P_((const void *,
- int (*)(void *, char *, int),
- int (*)(void *, const char *, int),
- fpos_t (*)(void *, fpos_t, int),
- int (*)(void *)));
-__END_DECLS
-#define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0)
-#define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0)
-#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
-
-/*
- * Functions internal to the implementation.
- */
-__BEGIN_DECLS
-int __srget __P_((FILE *));
-int __svfscanf __P_((FILE *, const char *, pthread_va_list));
-int __swbuf __P_((int, FILE *));
-__END_DECLS
-
-/*
- * The __sfoo macros are here so that we can
- * define function versions in the C library.
- */
-#define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++))
-
-__BEGIN_DECLS
-int __getc __P_((FILE *));
-__END_DECLS
-
-#define getc(fp) __getc(fp)
-#define getchar() getc(stdin)
-#define getc_unlocked(fp) __sgetc(fp)
-#define getchar_unlocked() getc_unlocked(stdin)
-
-#ifdef __CAN_DO_EXTERN_INLINE
-__INLINE int __sputc(int _c, FILE *_p)
-{
- if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
- return (*_p->_p++ = _c);
- else
- return (__swbuf(_c, _p));
-}
-#else
-__BEGIN_DECLS
-int __sputc __P_((int, FILE *));
-__END_DECLS
-#endif
-
-__BEGIN_DECLS
-int __putc __P_((int, FILE *));
-__END_DECLS
-
-#define putc(x, fp) __putc(x, fp)
-#define putchar(x) putc(x, stdout)
-#define putc_unlocked(x, fp) __sputc(x, fp)
-#define putchar_unlocked(x) putc_unlocked(x, stdout)
-
-#define __sfeof(p) (((p)->_flags & __SEOF) != 0)
-#define __sferror(p) (((p)->_flags & __SERR) != 0)
-#define __sfileno(p) ((p)->_file)
-
-#define feof(p) __sfeof(p)
-#define ferror(p) __sferror(p)
-
-#ifndef _ANSI_SOURCE
-#define fileno(p) __sfileno(p)
-#endif
-
-#endif
diff --git a/lib/libpthread/include/stdlib.h b/lib/libpthread/include/stdlib.h
deleted file mode 100644
index f51c7edf694..00000000000
--- a/lib/libpthread/include/stdlib.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * from: @(#)time.h 5.12 (Berkeley) 3/9/91
- * $Id: stdlib.h,v 1.1 1998/07/21 13:19:10 peter Exp $
- */
-
-#ifndef _STDLIB_H_
-#define _STDLIB_H_
-
-#include <sys/__stdlib.h>
-
-/* Returned by `div'. */
-typedef struct
- {
- int quot; /* Quotient. */
- int rem; /* Remainder. */
- } div_t;
-
-/* Returned by `ldiv'. */
-typedef struct
- {
- long quot; /* Quotient. */
- long rem; /* Remainder. */
- } ldiv_t;
-
-#ifndef RAND_MAX
-#define RAND_MAX 2147483647
-#endif
-
-#define EXIT_FAILURE 1 /* Failing exit status. */
-#define EXIT_SUCCESS 0 /* Successful exit status. */
-
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-
-double atof __P_((const char *));
-int atoi __P_((const char *));
-long atol __P_((const char *));
-double strtod __P_((const char *, char **));
-long strtol __P_((const char *, char **, int));
-unsigned long strtoul __P_((const char *, char **, int));
-
-int rand __P_((void));
-void srand __P_((unsigned int));
-
-long random __P_((void));
-void srandom __P_((unsigned int));
-char * initstate __P_((unsigned int, char *, int));
-char * setstate __P_((char *));
-
-void * malloc __P_((size_t));
-void * realloc __P_((void *, size_t));
-void * calloc __P_((size_t, size_t));
-void free __P_((void *));
-
-__NORETURN void abort __P_((void));
-int atexit __P_((void (* __func)() ));
-__NORETURN void exit __P_((int));
-int system __P_((const char *));
-
-extern char ** environ;
-
-char * getenv __P_((const char *));
-int putenv __P_((const char *));
-int setenv __P_((const char *, const char *, int));
-void unsetenv __P_((const char *));
-
-void * bsearch __P_((const void *, const void *, size_t, size_t,
- int (* __func)__P_((const void *, const void *)) ));
-void qsort __P_((void *, size_t, size_t,
- int (* __func)__P_((const void *, const void *)) ));
-
-int abs __P_((int));
-long labs __P_((long));
-div_t div __P_((int, int));
-ldiv_t ldiv __P_((long, long));
-
-void * memchr __P_((const void *, int, size_t));
-
-/* Stuff to do */
-int mblen __P_((const char *, size_t));
-int mbtowc __P_((wchar_t *, const char *, size_t));
-int wctomb __P_((char *, wchar_t));
-size_t mbstowcs __P_((wchar_t *, const char *, size_t));
-size_t wcstombs __P_((char *, const wchar_t *, size_t));
-
-
-__END_DECLS
-
-#endif /* !_STDLIB_H_ */
diff --git a/lib/libpthread/include/string.h b/lib/libpthread/include/string.h
deleted file mode 100644
index 4143a1cfec7..00000000000
--- a/lib/libpthread/include/string.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* $NetBSD: string.h,v 1.6 1994/10/26 00:56:30 cgd Exp $ */
-
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * @(#)string.h 5.10 (Berkeley) 3/9/91
- */
-
-#ifndef _STRING_H_
-#define _STRING_H_
-#include <sys/cdefs.h>
-#include <pthread/types.h>
-#include <pthread/posix.h>
-#include <sys/__string.h>
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-__BEGIN_DECLS
-void *memchr __P_((const void *, int, size_t));
-int memcmp __P_((const void *, const void *, size_t));
-void *memcpy __P_((void *, const void *, size_t));
-void *memmove __P_((void *, const void *, size_t));
-void *memset __P_((void *, int, size_t));
-char *strcat __P_((char *, const char *));
-char *strchr __P_((const char *, int));
-int strcmp __P_((const char *, const char *));
-int strcoll __P_((const char *, const char *));
-char *strcpy __P_((char *, const char *));
-size_t strcspn __P_((const char *, const char *));
-char *strerror __P_((int));
-size_t strlen __P_((const char *));
-char *strncat __P_((char *, const char *, size_t));
-int strncmp __P_((const char *, const char *, size_t));
-char *strncpy __P_((char *, const char *, size_t));
-char *strpbrk __P_((const char *, const char *));
-char *strrchr __P_((const char *, int));
-size_t strspn __P_((const char *, const char *));
-char *strstr __P_((const char *, const char *));
-char *strtok __P_((char *, const char *));
-char *strtok_r __P_((char *, const char *, char **));
-size_t strxfrm __P_((char *, const char *, size_t));
-
-/* Nonstandard routines common to all pthreads supported platforms */
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
-int ffs __P_((int));
-void *memccpy __P_((void *, const void *, int, size_t));
-int strcasecmp __P_((const char *, const char *));
-int strncasecmp __P_((const char *, const char *, size_t));
-char *strsignal __P_((int));
-void swab __P_((const void *, void *, size_t));
-#endif
-__END_DECLS
-
-#endif /* _STRING_H_ */
diff --git a/lib/libpthread/include/sys/__math.h b/lib/libpthread/include/sys/__math.h
deleted file mode 100644
index 27ed0f2575d..00000000000
--- a/lib/libpthread/include/sys/__math.h
+++ /dev/null
@@ -1,6 +0,0 @@
-/*
- * ANSI/POSIX
- */
-extern char __infinity[];
-#define HUGE_VAL (*(double *) __infinity)
-
diff --git a/lib/libpthread/include/sys/__path.h b/lib/libpthread/include/sys/__path.h
deleted file mode 100644
index e5a48d8ab73..00000000000
--- a/lib/libpthread/include/sys/__path.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * from: @(#)time.h 5.12 (Berkeley) 3/9/91
- * $Id: __path.h,v 1.1 1998/07/21 16:28:08 peter Exp $
- */
-
-#ifndef _SYS__PATH_H_
-#define _SYS__PATH_H_
-
-#define _PATH_PTY "/dev/"
-#define _PATH_TZDIR "/usr/share/zoneinfo"
-#define _PATH_TZFILE "/etc/localtime"
-
-#endif /* !_SYS__PATH_H_ */
-
diff --git a/lib/libpthread/include/sys/__signal.h b/lib/libpthread/include/sys/__signal.h
deleted file mode 100644
index 918955c9948..00000000000
--- a/lib/libpthread/include/sys/__signal.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <sys/signal.h>
-
-#define __SIGEMPTYSET 0
-#define __SIGFILLSET 0xffffffff
-#define __SIGADDSET(s, n) (*(s) |= 1 << ((n) - 1), 0)
-#define __SIGDELSET(s, n) (*(s) &= ~(1 << ((n) - 1)), 0)
-#define __SIGISMEMBER(s, n) ((*(s) & (1 << ((n) - 1))) != 0)
-
diff --git a/lib/libpthread/include/sys/__stdio.h b/lib/libpthread/include/sys/__stdio.h
deleted file mode 100644
index d60b9df7a54..00000000000
--- a/lib/libpthread/include/sys/__stdio.h
+++ /dev/null
@@ -1,8 +0,0 @@
-
-#include <machine/ansi.h>
-#ifdef _BSD_SIZE_T_
-typedef _BSD_SIZE_T_ size_t;
-#undef _BSD_SIZE_T_
-#endif
-
-typedef pthread_fpos_t fpos_t; /* Must match off_t <sys/types.h> */
diff --git a/lib/libpthread/include/sys/__stdlib.h b/lib/libpthread/include/sys/__stdlib.h
deleted file mode 100644
index cfcbe91867c..00000000000
--- a/lib/libpthread/include/sys/__stdlib.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * from: @(#)stdlib.h 5.13 (Berkeley) 6/4/91
- * $Id: __stdlib.h,v 1.1 1998/07/21 16:28:08 peter Exp $
- */
-
-#ifndef _SYS___STDLIB_H_
-#define _SYS___STDLIB_H_
-
-#include <machine/ansi.h>
-
-#ifdef _BSD_SIZE_T_
-typedef _BSD_SIZE_T_ size_t;
-#undef _BSD_SIZE_T_
-#endif
-
-#ifdef _BSD_WCHAR_T_
-typedef _BSD_WCHAR_T_ wchar_t;
-#ifdef _BSD_RUNE_T_
-typedef _BSD_RUNE_T_ rune_t;
-#undef _BSD_RUNE_T_
-#else
-typedef _BSD_WCHAR_T_ rune_t;
-#endif
-#undef _BSD_WCHAR_T_
-#endif
-
-#ifndef __NORETURN
-#define __NORETURN
-#endif
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-#endif /* _STDLIB_H_ */
diff --git a/lib/libpthread/include/sys/__string.h b/lib/libpthread/include/sys/__string.h
deleted file mode 100644
index 93d4fcf9dd2..00000000000
--- a/lib/libpthread/include/sys/__string.h
+++ /dev/null
@@ -1,21 +0,0 @@
-
-#include <machine/ansi.h>
-#ifdef _BSD_SIZE_T_
-typedef _BSD_SIZE_T_ size_t;
-#undef _BSD_SIZE_T_
-#endif
-
-/* Non-standard NetBSD string routines. */
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
-__BEGIN_DECLS
-int bcmp __P_((const void *, const void *, size_t));
-void bcopy __P_((const void *, void *, size_t));
-void bzero __P_((void *, size_t));
-char *index __P_((const char *, int));
-char *rindex __P_((const char *, int));
-char *strdup __P_((const char *));
-void strmode __P_((int, char *));
-char *strsep __P_((char **, const char *));
-__END_DECLS
-#endif
-
diff --git a/lib/libpthread/include/sys/__time.h b/lib/libpthread/include/sys/__time.h
deleted file mode 100644
index 536ec0400ad..00000000000
--- a/lib/libpthread/include/sys/__time.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * from: @(#)time.h 5.12 (Berkeley) 3/9/91
- * $Id: __time.h,v 1.1 1998/07/21 16:28:08 peter Exp $
- */
-
-#ifndef _SYS__TIME_H_
-#define _SYS__TIME_H_
-
-#include <machine/ansi.h>
-#include <machine/limits.h>
-
-#ifdef _BSD_CLOCK_T_
-typedef _BSD_CLOCK_T_ clock_t;
-#undef _BSD_CLOCK_T_
-#endif
-
-#ifdef _BSD_TIME_T_
-typedef _BSD_TIME_T_ time_t;
-#undef _BSD_TIME_T_
-#endif
-
-#ifdef _BSD_SIZE_T_
-typedef _BSD_SIZE_T_ size_t;
-#undef _BSD_SIZE_T_
-#endif
-
-#define CLOCKS_PER_SEC 100
-
-#if !defined(CLK_TCK)
-#define CLK_TCK 100
-#endif /* not CLK_TCK */
-
-#endif /* !_SYS__TIME_H_ */
diff --git a/lib/libpthread/include/sys/__unistd.h b/lib/libpthread/include/sys/__unistd.h
deleted file mode 100644
index d4d621a8618..00000000000
--- a/lib/libpthread/include/sys/__unistd.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * from: @(#)stdlib.h 5.13 (Berkeley) 6/4/91
- * $Id: __unistd.h,v 1.1 1998/07/21 16:28:08 peter Exp $
- */
-
-#ifndef _SYS___UNISTD_H_
-#define _SYS___UNISTD_H_
-
-#include <sys/types.h>
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-#define ioctl_request_type unsigned long /* For fd.c */
-
-/* compile-time symbolic constants */
-#define _POSIX_JOB_CONTROL /* implementation supports job control */
-
-#ifdef _NOT_AVAILABLE
-#define _POSIX_SAVED_IDS /* saved set-user-ID and set-group-ID */
-#endif
-
-#define _POSIX_VERSION 198808L
-#define _POSIX2_VERSION 199212L
-
-/* execution-time symbolic constants */
- /* chown requires appropriate privileges */
-#define _POSIX_CHOWN_RESTRICTED 1
- /* too-long path components generate errors */
-#define _POSIX_NO_TRUNC 1
- /* may disable terminal special characters */
-/* #define _POSIX_VDISABLE 0xff */
-
-/* configurable pathname variables */
-#define _PC_LINK_MAX 1
-#define _PC_MAX_CANON 2
-#define _PC_MAX_INPUT 3
-#define _PC_NAME_MAX 4
-#define _PC_PATH_MAX 5
-#define _PC_PIPE_BUF 6
-#define _PC_CHOWN_RESTRICTED 7
-#define _PC_NO_TRUNC 8
-#define _PC_VDISABLE 9
-
-/* configurable system variables */
-#define _SC_ARG_MAX 1
-#define _SC_CHILD_MAX 2
-#define _SC_CLK_TCK 3
-#define _SC_NGROUPS_MAX 4
-#define _SC_OPEN_MAX 5
-#define _SC_JOB_CONTROL 6
-#define _SC_SAVED_IDS 7
-#define _SC_VERSION 8
-#define _SC_BC_BASE_MAX 9
-#define _SC_BC_DIM_MAX 10
-#define _SC_BC_SCALE_MAX 11
-#define _SC_BC_STRING_MAX 12
-#define _SC_COLL_WEIGHTS_MAX 13
-#define _SC_EXPR_NEST_MAX 14
-#define _SC_LINE_MAX 15
-#define _SC_RE_DUP_MAX 16
-#define _SC_2_VERSION 17
-#define _SC_2_C_BIND 18
-#define _SC_2_C_DEV 19
-#define _SC_2_CHAR_TERM 20
-#define _SC_2_FORT_DEV 21
-#define _SC_2_FORT_RUN 22
-#define _SC_2_LOCALEDEF 23
-#define _SC_2_SW_DEV 24
-#define _SC_2_UPE 25
-#define _SC_STREAM_MAX 26
-#define _SC_TZNAME_MAX 27
-
-/* configurable system strings */
-#define _CS_PATH 1
-
-#endif
diff --git a/lib/libpthread/include/sys/compat.h b/lib/libpthread/include/sys/compat.h
deleted file mode 100644
index 604b61e3907..00000000000
--- a/lib/libpthread/include/sys/compat.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* ==== compat.h ============================================================
- * 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 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.
- *
- * $Id: compat.h,v 1.1 1998/07/21 16:28:08 peter Exp $
- *
- * Description : COmpat header to make socket code compile.
- *
- * 1.00 94/08/01 proven
- * -Started coding this file.
- */
-
-#ifndef _SYS_COMPAT_H_
-#define _SYS_COMPAT_H_
-
-#endif
diff --git a/lib/libpthread/include/sys/dirent.h b/lib/libpthread/include/sys/dirent.h
deleted file mode 100644
index 5226443f86b..00000000000
--- a/lib/libpthread/include/sys/dirent.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * Copyright (c) 1989 The Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * @(#)dirent.h 5.18 (Berkeley) 2/23/91
- */
-
-#ifndef _SYS_DIRENT_H_
-#define _SYS_DIRENT_H_
-
-/*
- * A directory entry has a struct dirent at the front of it, containing its
- * inode number, the length of the entry, and the length of the name
- * contained in the entry. These are followed by the name padded to a 4
- * byte boundary with null bytes. All names are guaranteed null terminated.
- * The maximum length of a name in a directory is MAXNAMLEN.
- */
-
-struct dirent {
- u_long d_fileno; /* file number of entry */
- u_short d_reclen; /* length of this record */
- u_short d_namlen; /* length of string in d_name */
-#ifdef _POSIX_SOURCE
- char d_name[255 + 1]; /* name must be no longer than this */
-#else
-#define MAXNAMLEN 255
- char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */
-#endif
-};
-
-#define d_ino d_fileno /* backward compatibility */
-
-/* definitions for library routines operating on directories. */
-#define DIRBLKSIZ 1024
-
-#endif /* !_DIRENT_H_ */
diff --git a/lib/libpthread/include/sys/errno.h b/lib/libpthread/include/sys/errno.h
deleted file mode 100644
index 3da61d692a3..00000000000
--- a/lib/libpthread/include/sys/errno.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/* $NetBSD: errno.h,v 1.8 1994/06/29 06:44:02 cgd Exp $ */
-
-/*
- * Copyright (c) 1982, 1986, 1989, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * @(#)errno.h 8.5 (Berkeley) 1/21/94
- */
-
-#ifndef _SYS_ERRNO_H_
-#define _SYS_ERRNO_H_
-
-#define EPERM 1 /* Operation not permitted */
-#define ENOENT 2 /* No such file or directory */
-#define ESRCH 3 /* No such process */
-#define EINTR 4 /* Interrupted system call */
-#define EIO 5 /* Input/output error */
-#define ENXIO 6 /* Device not configured */
-#define E2BIG 7 /* Argument list too long */
-#define ENOEXEC 8 /* Exec format error */
-#define EBADF 9 /* Bad file descriptor */
-#define ECHILD 10 /* No child processes */
-#define EDEADLK 11 /* Resource deadlock avoided */
- /* 11 was EAGAIN */
-#define ENOMEM 12 /* Cannot allocate memory */
-#define EACCES 13 /* Permission denied */
-#define EFAULT 14 /* Bad address */
-#ifndef _POSIX_SOURCE
-#define ENOTBLK 15 /* Block device required */
-#endif
-#define EBUSY 16 /* Device busy */
-#define EEXIST 17 /* File exists */
-#define EXDEV 18 /* Cross-device link */
-#define ENODEV 19 /* Operation not supported by device */
-#define ENOTDIR 20 /* Not a directory */
-#define EISDIR 21 /* Is a directory */
-#define EINVAL 22 /* Invalid argument */
-#define ENFILE 23 /* Too many open files in system */
-#define EMFILE 24 /* Too many open files */
-#define ENOTTY 25 /* Inappropriate ioctl for device */
-#ifndef _POSIX_SOURCE
-#define ETXTBSY 26 /* Text file busy */
-#endif
-#define EFBIG 27 /* File too large */
-#define ENOSPC 28 /* No space left on device */
-#define ESPIPE 29 /* Illegal seek */
-#define EROFS 30 /* Read-only file system */
-#define EMLINK 31 /* Too many links */
-#define EPIPE 32 /* Broken pipe */
-
-/* math software */
-#define EDOM 33 /* Numerical argument out of domain */
-#define ERANGE 34 /* Result too large */
-
-/* non-blocking and interrupt i/o */
-#define EAGAIN 35 /* Resource temporarily unavailable */
-#ifndef _POSIX_SOURCE
-#define EWOULDBLOCK EAGAIN /* Operation would block */
-#define EINPROGRESS 36 /* Operation now in progress */
-#define EALREADY 37 /* Operation already in progress */
-
-/* ipc/network software -- argument errors */
-#define ENOTSOCK 38 /* Socket operation on non-socket */
-#define EDESTADDRREQ 39 /* Destination address required */
-#define EMSGSIZE 40 /* Message too long */
-#define EPROTOTYPE 41 /* Protocol wrong type for socket */
-#define ENOPROTOOPT 42 /* Protocol not available */
-#define EPROTONOSUPPORT 43 /* Protocol not supported */
-#define ESOCKTNOSUPPORT 44 /* Socket type not supported */
-#define EOPNOTSUPP 45 /* Operation not supported */
-#define EPFNOSUPPORT 46 /* Protocol family not supported */
-#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */
-#define EADDRINUSE 48 /* Address already in use */
-#define EADDRNOTAVAIL 49 /* Can't assign requested address */
-
-/* ipc/network software -- operational errors */
-#define ENETDOWN 50 /* Network is down */
-#define ENETUNREACH 51 /* Network is unreachable */
-#define ENETRESET 52 /* Network dropped connection on reset */
-#define ECONNABORTED 53 /* Software caused connection abort */
-#define ECONNRESET 54 /* Connection reset by peer */
-#define ENOBUFS 55 /* No buffer space available */
-#define EISCONN 56 /* Socket is already connected */
-#define ENOTCONN 57 /* Socket is not connected */
-#define ESHUTDOWN 58 /* Can't send after socket shutdown */
-#define ETOOMANYREFS 59 /* Too many references: can't splice */
-#define ETIMEDOUT 60 /* Operation timed out */
-#define ECONNREFUSED 61 /* Connection refused */
-
-#define ELOOP 62 /* Too many levels of symbolic links */
-#endif /* _POSIX_SOURCE */
-#define ENAMETOOLONG 63 /* File name too long */
-
-/* should be rearranged */
-#ifndef _POSIX_SOURCE
-#define EHOSTDOWN 64 /* Host is down */
-#define EHOSTUNREACH 65 /* No route to host */
-#endif /* _POSIX_SOURCE */
-#define ENOTEMPTY 66 /* Directory not empty */
-
-/* quotas & mush */
-#ifndef _POSIX_SOURCE
-#define EPROCLIM 67 /* Too many processes */
-#define EUSERS 68 /* Too many users */
-#define EDQUOT 69 /* Disc quota exceeded */
-
-/* Network File System */
-#define ESTALE 70 /* Stale NFS file handle */
-#define EREMOTE 71 /* Too many levels of remote in path */
-#define EBADRPC 72 /* RPC struct is bad */
-#define ERPCMISMATCH 73 /* RPC version wrong */
-#define EPROGUNAVAIL 74 /* RPC prog. not avail */
-#define EPROGMISMATCH 75 /* Program version wrong */
-#define EPROCUNAVAIL 76 /* Bad procedure for program */
-#endif /* _POSIX_SOURCE */
-
-#define ENOLCK 77 /* No locks available */
-#define ENOSYS 78 /* Function not implemented */
-
-#ifndef _POSIX_SOURCE
-#define EFTYPE 79 /* Inappropriate file type or format */
-#define EAUTH 80 /* Authentication error */
-#define ENEEDAUTH 81 /* Need authenticator */
-#define ELAST 81 /* Must be equal largest errno */
-#endif /* _POSIX_SOURCE */
-
-#endif
diff --git a/lib/libpthread/include/sys/timers.h b/lib/libpthread/include/sys/timers.h
deleted file mode 100644
index c15b91d34ba..00000000000
--- a/lib/libpthread/include/sys/timers.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* ==== timers.h ============================================================
- * 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 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.
- *
- * $Id: timers.h,v 1.1 1998/07/21 16:28:09 peter Exp $
- *
- * Description : Basic timers header.
- *
- * 1.00 94/06/13 proven
- * -Started coding this file.
- */
-
-#ifndef _SYS_TIMERS_H_
-#define _SYS_TIMERS_H_
-
-#include <sys/time.h>
-
-#endif
diff --git a/lib/libpthread/include/sys/wait.h b/lib/libpthread/include/sys/wait.h
deleted file mode 100644
index 063dc3d766c..00000000000
--- a/lib/libpthread/include/sys/wait.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (c) 1982, 1986, 1989, 1993
- * The Regents of the University of California. 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * @(#)wait.h 8.1 (Berkeley) 6/2/93
- * $Id: wait.h,v 1.1 1998/07/21 16:28:09 peter Exp $
- */
-
-#ifndef _SYS_WAIT_H_
-#define _SYS_WAIT_H_
-
-/*
- * This file holds definitions relevent to the wait4 system call
- * and the alternate interfaces that use it (wait, wait3, waitpid).
- */
-
-/*
- * Macros to test the exit status returned by wait
- * and extract the relevant values.
- */
-#ifdef _POSIX_SOURCE
-#define _W_INT(i) (i)
-#else
-#define _W_INT(w) (*(int *)&(w)) /* convert union wait to int */
-#define WCOREFLAG 0200
-#endif
-
-#define _WSTATUS(x) (_W_INT(x) & 0177)
-#define _WSTOPPED 0177 /* _WSTATUS if process is stopped */
-#define WIFSTOPPED(x) (_WSTATUS(x) == _WSTOPPED)
-#define WSTOPSIG(x) (_W_INT(x) >> 8)
-#define WIFSIGNALED(x) (_WSTATUS(x) != _WSTOPPED && _WSTATUS(x) != 0)
-#define WTERMSIG(x) (_WSTATUS(x))
-#define WIFEXITED(x) (_WSTATUS(x) == 0)
-#define WEXITSTATUS(x) (_W_INT(x) >> 8)
-#ifndef _POSIX_SOURCE
-#define WCOREDUMP(x) (_W_INT(x) & WCOREFLAG)
-
-#define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
-#define W_STOPCODE(sig) ((sig) << 8 | _WSTOPPED)
-#endif
-
-/*
- * Option bits for the third argument of wait4. WNOHANG causes the
- * wait to not hang if there are no stopped or terminated processes, rather
- * returning an error indication in this case (pid==0). WUNTRACED
- * indicates that the caller should receive status about untraced children
- * which stop due to signals. If children are stopped and a wait without
- * this option is done, it is as though they were still running... nothing
- * about them is returned.
- */
-#define WNOHANG 1 /* dont hang in wait */
-#define WUNTRACED 2 /* tell about stopped, untraced children */
-
-#ifndef _POSIX_SOURCE
-/* POSIX extensions and 4.2/4.3 compatability: */
-
-/*
- * Tokens for special values of the "pid" parameter to wait4.
- */
-#define WAIT_ANY (-1) /* any process */
-#define WAIT_MYPGRP 0 /* any process in my process group */
-
-#include <machine/endian.h>
-
-/*
- * Deprecated:
- * Structure of the information in the status word returned by wait4.
- * If w_stopval==WSTOPPED, then the second structure describes
- * the information returned, else the first.
- */
-union wait {
- int w_status; /* used in syscall */
- /*
- * Terminated process status.
- */
- struct {
-#if BYTE_ORDER == LITTLE_ENDIAN
- unsigned int w_Termsig:7, /* termination signal */
- w_Coredump:1, /* core dump indicator */
- w_Retcode:8, /* exit code if w_termsig==0 */
- w_Filler:16; /* upper bits filler */
-#endif
-#if BYTE_ORDER == BIG_ENDIAN
- unsigned int w_Filler:16, /* upper bits filler */
- w_Retcode:8, /* exit code if w_termsig==0 */
- w_Coredump:1, /* core dump indicator */
- w_Termsig:7; /* termination signal */
-#endif
- } w_T;
- /*
- * Stopped process status. Returned
- * only for traced children unless requested
- * with the WUNTRACED option bit.
- */
- struct {
-#if BYTE_ORDER == LITTLE_ENDIAN
- unsigned int w_Stopval:8, /* == W_STOPPED if stopped */
- w_Stopsig:8, /* signal that stopped us */
- w_Filler:16; /* upper bits filler */
-#endif
-#if BYTE_ORDER == BIG_ENDIAN
- unsigned int w_Filler:16, /* upper bits filler */
- w_Stopsig:8, /* signal that stopped us */
- w_Stopval:8; /* == W_STOPPED if stopped */
-#endif
- } w_S;
-};
-#define w_termsig w_T.w_Termsig
-#define w_coredump w_T.w_Coredump
-#define w_retcode w_T.w_Retcode
-#define w_stopval w_S.w_Stopval
-#define w_stopsig w_S.w_Stopsig
-
-#define WSTOPPED _WSTOPPED
-#endif /* _POSIX_SOURCE */
-
-#ifndef KERNEL
-#include <sys/types.h>
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-struct rusage; /* forward declaration */
-
-pid_t wait __P_((int *));
-pid_t waitpid __P_((pid_t, int *, int));
-#ifndef _POSIX_SOURCE
-pid_t wait3 __P_((int *, int, void *));
-pid_t wait4 __P_((pid_t, int *, int, void *));
-#endif
-__END_DECLS
-#endif
-
-#endif
diff --git a/lib/libpthread/include/syslog.h b/lib/libpthread/include/syslog.h
deleted file mode 100644
index 31b42285fc1..00000000000
--- a/lib/libpthread/include/syslog.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 1982, 1986 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
- *
- * @(#)syslog.h 7.8 (Berkeley) 5/26/88
- */
-
-#ifndef SYSLOG_H
-#define SYSLOG_H
-
-/* Added __[BEGIN/END]_DECLS so this file would work with C++. (mevans) */
-#include <sys/cdefs.h>
-#include <stdarg.h>
-
-/* Discipline: openlog(), closelog(), and setlogmask() are not thread-safe
- * and should only be called when other threads will not be calling syslog
- * functions. syslog() and vsyslog() are thread-safe and may be called
- * asynchronously, even if openlog() has not been called. */
-
-/*
- * Facility codes
- */
-
-#define LOG_KERN (0<<3) /* kernel messages */
-#define LOG_USER (1<<3) /* random user-level messages */
-#define LOG_MAIL (2<<3) /* mail system */
-#define LOG_DAEMON (3<<3) /* system daemons */
-#define LOG_AUTH (4<<3) /* security/authorization messages */
-#define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
-#define LOG_LPR (6<<3) /* line printer subsystem */
-#define LOG_NEWS (7<<3) /* network news subsystem */
-#define LOG_UUCP (8<<3) /* UUCP subsystem */
- /* other codes through 15 reserved for system use */
-#define LOG_LOCAL0 (16<<3) /* reserved for local use */
-#define LOG_LOCAL1 (17<<3) /* reserved for local use */
-#define LOG_LOCAL2 (18<<3) /* reserved for local use */
-#define LOG_LOCAL3 (19<<3) /* reserved for local use */
-#define LOG_LOCAL4 (20<<3) /* reserved for local use */
-#define LOG_LOCAL5 (21<<3) /* reserved for local use */
-#define LOG_LOCAL6 (22<<3) /* reserved for local use */
-#define LOG_LOCAL7 (23<<3) /* reserved for local use */
-
-#define LOG_NFACILITIES 24 /* maximum number of facilities */
-#define LOG_FACMASK 0x03f8 /* mask to extract facility part */
-
-#define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) /* facility of pri */
-
-/*
- * Priorities (these are ordered)
- */
-
-#define LOG_EMERG 0 /* system is unusable */
-#define LOG_ALERT 1 /* action must be taken immediately */
-#define LOG_CRIT 2 /* critical conditions */
-#define LOG_ERR 3 /* error conditions */
-#define LOG_WARNING 4 /* warning conditions */
-#define LOG_NOTICE 5 /* normal but signification condition */
-#define LOG_INFO 6 /* informational */
-#define LOG_DEBUG 7 /* debug-level messages */
-
-#define LOG_PRIMASK 0x0007 /* mask to extract priority part (internal) */
-#define LOG_PRI(p) ((p) & LOG_PRIMASK) /* extract priority */
-
-#define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
-
-#ifdef KERNEL
-#define LOG_PRINTF -1 /* pseudo-priority to indicate use of printf */
-#endif
-
-/*
- * arguments to setlogmask.
- */
-#define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */
-#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */
-
-/*
- * Option flags for openlog.
- *
- * LOG_ODELAY no longer does anything; LOG_NDELAY is the
- * inverse of what it used to be.
- */
-#define LOG_PID 0x01 /* log the pid with each message */
-#define LOG_CONS 0x02 /* log on the console if errors in sending */
-#define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */
-#define LOG_NDELAY 0x08 /* don't delay open */
-#define LOG_NOWAIT 0x10 /* if forking to log on console, don't wait() */
-
-__BEGIN_DECLS
-
-/* Syslogging functions. */
-void syslog(int pri, char *fmt, ...);
-void vsyslog(int pri, char *fmt, va_list args);
-void openlog(char *ident, int logstat, int logfac);
-void closelog(void);
-int setlogmask(int pmask);
-
-__END_DECLS
-
-#endif
-
diff --git a/lib/libpthread/include/time.h b/lib/libpthread/include/time.h
deleted file mode 100644
index c27e66838a3..00000000000
--- a/lib/libpthread/include/time.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * from: @(#)time.h 5.12 (Berkeley) 3/9/91
- * $Id: time.h,v 1.1 1998/07/21 13:19:10 peter Exp $
- */
-
-#ifndef _TIME_H_
-#define _TIME_H_
-
-#include <sys/__time.h>
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-#ifndef __hpux__
-struct tm {
- int tm_sec; /* seconds after the minute [0-60] */
- int tm_min; /* minutes after the hour [0-59] */
- int tm_hour; /* hours since midnight [0-23] */
- int tm_mday; /* day of the month [1-31] */
- int tm_mon; /* months since January [0-11] */
- int tm_year; /* years since 1900 */
- int tm_wday; /* days since Sunday [0-6] */
- int tm_yday; /* days since January 1 [0-365] */
- int tm_isdst; /* Daylight Savings Time flag */
- long tm_gmtoff; /* offset from CUT in seconds */
- char *tm_zone; /* timezone abbreviation */
-};
-#endif /* __hpux__ */
-
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-/* clock_t clock __P_((void)); */
-
-char * asctime __P_((const struct tm *));
-double difftime __P_((time_t, time_t));
-char * ctime __P_((const time_t *));
-struct tm * gmtime __P_((const time_t *));
-struct tm * localtime __P_((const time_t *));
-
-char * asctime_r __P_((const struct tm *, char *));
-char * ctime_r __P_((const time_t *, char *));
-struct tm * gmtime_r __P_((const time_t *, struct tm *));
-struct tm * localtime_r __P_((const time_t *, struct tm *));
-
-time_t mktime __P_((struct tm *));
-
-/* size_t strftime __P_((char *, size_t, const char *, const struct tm *)); */
-time_t time __P_((time_t *));
-
-#if !defined(_ANSI_SOURCE)
-/* #define CLK_TCK 100 */
-extern char *tzname[2];
-void tzset __P_((void));
-#endif /* not ANSI */
-
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
-/* char *timezone __P_((int, int)); */
-void tzsetwall __P_((void));
-#endif /* neither ANSI nor POSIX */
-
-__END_DECLS
-
-#endif /* !_TIME_H_ */
diff --git a/lib/libpthread/include/timers.h b/lib/libpthread/include/timers.h
deleted file mode 100644
index af9db4a5b01..00000000000
--- a/lib/libpthread/include/timers.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* ==== timers.h ============================================================
- * 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 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.
- *
- * $Id: timers.h,v 1.1 1998/07/21 13:19:10 peter Exp $
- *
- * Description : Basic timers header.
- *
- * 1.00 94/06/13 proven
- * -Started coding this file.
- */
-
-#ifndef _TIMERS_H_
-#define _TIMERS_H_
-
-#include <sys/timers.h>
-
-#endif
diff --git a/lib/libpthread/include/tzfile.h b/lib/libpthread/include/tzfile.h
deleted file mode 100644
index 95bbc424be7..00000000000
--- a/lib/libpthread/include/tzfile.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (c) 1988 Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Arthur David Olson of the National Cancer Institute.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * from: @(#)tzfile.h 5.10 (Berkeley) 4/3/91
- * $Id: tzfile.h,v 1.1 1998/07/21 13:19:10 peter Exp $
- */
-
-#ifndef _TZFILE_H_
-#define _TZFILE_H_
-
-#include <pthread/paths.h>
-
-/*
- * Information about time zone files.
- */
-#define TZDIR _PATH_TZDIR
-#define TZDEFAULT _PATH_TZFILE
-#define TZDEFRULES "posixrules"
-
-/*
-** Each file begins with. . .
-*/
-
-struct tzhead {
- char tzh_reserved[24]; /* reserved for future use */
- char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */
- char tzh_leapcnt[4]; /* coded number of leap seconds */
- char tzh_timecnt[4]; /* coded number of transition times */
- char tzh_typecnt[4]; /* coded number of local time types */
- char tzh_charcnt[4]; /* coded number of abbr. chars */
-};
-
-/*
-** . . .followed by. . .
-**
-** tzh_timecnt (char [4])s coded transition times a la time(2)
-** tzh_timecnt (unsigned char)s types of local time starting at above
-** tzh_typecnt repetitions of
-** one (char [4]) coded GMT offset in seconds
-** one (unsigned char) used to set tm_isdst
-** one (unsigned char) that's an abbreviation list index
-** tzh_charcnt (char)s '\0'-terminated zone abbreviations
-** tzh_leapcnt repetitions of
-** one (char [4]) coded leap second transition times
-** one (char [4]) total correction after above
-** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition
-** time is standard time, if FALSE,
-** transition time is wall clock time
-** if absent, transition times are
-** assumed to be wall clock time
-*/
-
-/*
-** In the current implementation, "tzset()" refuses to deal with files that
-** exceed any of the limits below.
-*/
-
-/*
-** The TZ_MAX_TIMES value below is enough to handle a bit more than a
-** year's worth of solar time (corrected daily to the nearest second) or
-** 138 years of Pacific Presidential Election time
-** (where there are three time zone transitions every fourth year).
-*/
-#define TZ_MAX_TIMES 370
-
-#define NOSOLAR /* 4BSD doesn't currently handle solar time */
-
-#ifndef NOSOLAR
-#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
-#else
-#define TZ_MAX_TYPES 10 /* Maximum number of local time types */
-#endif
-
-#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
-
-#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */
-
-#define SECSPERMIN 60
-#define MINSPERHOUR 60
-#define HOURSPERDAY 24
-#define DAYSPERWEEK 7
-#define DAYSPERNYEAR 365
-#define DAYSPERLYEAR 366
-#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
-#define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY)
-#define MONSPERYEAR 12
-
-#define TM_SUNDAY 0
-#define TM_MONDAY 1
-#define TM_TUESDAY 2
-#define TM_WEDNESDAY 3
-#define TM_THURSDAY 4
-#define TM_FRIDAY 5
-#define TM_SATURDAY 6
-
-#define TM_JANUARY 0
-#define TM_FEBRUARY 1
-#define TM_MARCH 2
-#define TM_APRIL 3
-#define TM_MAY 4
-#define TM_JUNE 5
-#define TM_JULY 6
-#define TM_AUGUST 7
-#define TM_SEPTEMBER 8
-#define TM_OCTOBER 9
-#define TM_NOVEMBER 10
-#define TM_DECEMBER 11
-
-#define TM_YEAR_BASE 1900
-
-#define EPOCH_YEAR 1970
-#define EPOCH_WDAY TM_THURSDAY
-
-/*
-** Accurate only for the past couple of centuries;
-** that will probably do.
-*/
-
-#define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0)
-
-#endif /* !_TZFILE_H_ */
-
diff --git a/lib/libpthread/include/unistd.h b/lib/libpthread/include/unistd.h
deleted file mode 100644
index 213aa983172..00000000000
--- a/lib/libpthread/include/unistd.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/*-
- * Copyright (c) 1991 The Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * @(#)unistd.h 5.13 (Berkeley) 6/17/91
- */
-
-#ifndef _UNISTD_H_
-#define _UNISTD_H_
-
-#include <sys/cdefs.h>
-#include <sys/__unistd.h>
-
-#define R_OK 4
-#define W_OK 2
-#define X_OK 1
-#define F_OK 0
-
-#ifndef SEEK_SET
-#define SEEK_SET 0 /* set file offset to offset */
-#endif
-#ifndef SEEK_CUR
-#define SEEK_CUR 1 /* set file offset to current plus offset */
-#endif
-#ifndef SEEK_END
-#define SEEK_END 2 /* set file offset to EOF plus offset */
-#endif
-
-#define STDIN_FILENO 0 /* standard input file descriptor */
-#define STDOUT_FILENO 1 /* standard output file descriptor */
-#define STDERR_FILENO 2 /* standard error file descriptor */
-
-__BEGIN_DECLS
-void _exit __P_((int));
-int access __P_((const char *, int));
-int chdir __P_((const char *));
-int chown __P_((const char *, uid_t, gid_t));
-int close __P_((int));
-int dup __P_((int));
-int dup2 __P_((int, int));
-int execve __P_((const char *, char * const *, char * const *));
-pid_t fork __P_((void));
-int isatty __P_((int));
-int link __P_((const char *, const char *));
-off_t lseek __P_((int, off_t, int));
-int pipe __P_((int *));
-ssize_t read __P_((int, void *, size_t));
-unsigned sleep __P_((unsigned));
-char *ttyname __P_((int));
-int unlink __P_((const char *));
-ssize_t write __P_((int, const void *, size_t));
-
-/* Not implemented for threads yet */
-unsigned alarm __P_((unsigned));
-char *cuserid __P_((char *));
-int execl __P_((const char *, const char *, ...));
-int execle __P_((const char *, const char *, ...));
-int execlp __P_((const char *, const char *, ...));
-int execv __P_((const char *, char * const *));
-int execvp __P_((const char *, char * const *));
-long fpathconf __P_((int, int)); /* not yet */
-char *getcwd __P_((char *, size_t));
-gid_t getegid __P_((void));
-uid_t geteuid __P_((void));
-gid_t getgid __P_((void));
-int getgroups __P_((int, gid_t *)); /* XXX (gid_t *) */
-char *getlogin __P_((void));
-pid_t getpgrp __P_((void));
-pid_t getpid __P_((void));
-pid_t getppid __P_((void));
-uid_t getuid __P_((void));
-long pathconf __P_((const char *, int)); /* not yet */
-int pause __P_((void));
-int rmdir __P_((const char *));
-int setgid __P_((gid_t));
-int setpgid __P_((pid_t, pid_t));
-pid_t setsid __P_((void));
-int setuid __P_((uid_t));
-long sysconf __P_((int)); /* not yet */
-pid_t tcgetpgrp __P_((int));
-int tcsetpgrp __P_((int, pid_t));
-
-#ifndef _POSIX_SOURCE
-
-int acct __P_((const char *));
-int async_daemon __P_((void));
-char *brk __P_((const char *));
-/* int chflags __P_((const char *, long)); */
-int chroot __P_((const char *));
-char *crypt __P_((const char *, const char *));
-int des_cipher __P_((const char *, char *, long, int));
-void des_setkey __P_((const char *key));
-void encrypt __P_((char *, int));
-void endusershell __P_((void));
-int exect __P_((const char *, char * const *, char * const *));
-int fchdir __P_((int));
-/* int fchflags __P_((int, long)); */
-int fchown __P_((int, uid_t, gid_t));
-int fsync __P_((int));
-int ftruncate __P_((int, off_t));
-int getdtablesize __P_((void));
-long gethostid __P_((void));
-int gethostname __P_((char *, int));
-mode_t getmode __P_((const void *, mode_t));
-int getpagesize __P_((void));
-char *getpass __P_((const char *));
-char *getusershell __P_((void));
-char *getwd __P_((char *)); /* obsoleted by getcwd() */
-int initgroups __P_((const char *, gid_t));
-int mknod __P_((const char *, mode_t, dev_t));
-int mkstemp __P_((char *));
-char *mktemp __P_((char *));
-int nfssvc __P_((int));
-int nice __P_((int));
-void psignal __P_((unsigned, const char *));
-/* extern char *sys_siglist[]; */
-int profil __P_((char *, int, int, int));
-int rcmd __P_((char **, int, const char *,
- const char *, const char *, int *));
-char *re_comp __P_((const char *));
-int re_exec __P_((const char *));
-int readlink __P_((const char *, char *, int));
-int reboot __P_((int));
-int revoke __P_((const char *));
-int rresvport __P_((int *));
-int ruserok __P_((const char *, int, const char *, const char *));
-char *sbrk __P_((int));
-int setegid __P_((gid_t));
-int seteuid __P_((uid_t));
-int setgroups __P_((int, const gid_t *));
-void sethostid __P_((long));
-int sethostname __P_((const char *, int));
-void setkey __P_((const char *));
-int setlogin __P_((const char *));
-void *setmode __P_((const char *));
-int setpgrp __P_((pid_t pid, pid_t pgrp)); /* obsoleted by setpgid() */
-int setregid __P_((int, int));
-int setreuid __P_((int, int));
-int setrgid __P_((gid_t));
-int setruid __P_((uid_t));
-void setusershell __P_((void));
-int swapon __P_((const char *));
-int symlink __P_((const char *, const char *));
-void sync __P_((void));
-int syscall __P_((int, ...));
-int truncate __P_((const char *, off_t));
-int ttyslot __P_((void));
-unsigned ualarm __P_((unsigned, unsigned));
-void usleep __P_((unsigned));
-int vfork __P_((void));
-
-#endif /* !_POSIX_SOURCE */
-__END_DECLS
-
-#endif
diff --git a/lib/libpthread/lib/Makefile b/lib/libpthread/lib/Makefile
deleted file mode 100644
index 3775a11b38e..00000000000
--- a/lib/libpthread/lib/Makefile
+++ /dev/null
@@ -1,49 +0,0 @@
-# Generated automatically from Makefile.in by configure.
-# === GNUmakefile ============================================================
-# Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
-#
-# Description: This file is for creating the test programs for libpthread.a
-#
-# 1.00 93/08/03 proven
-# -Initial cut for pthreads.
-#
-
-CC = ../pgcc -notinstalled
-srctop = /dr1/my/masters/mysql/mit-pthreads
-srcdir = /dr1/my/masters/mysql/mit-pthreads/lib
-VPATH = /dr1/my/masters/mysql/mit-pthreads/lib
-CDEBUGFLAGS = -g -O2 -Werror
-
-CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(ADDL_CFLAGS) -DSRCDIR=\"$(srcdir)\"
-
-#
-DIRS = libpthreadutil
-
-################################################################################
-#
-all:
- (for i in $(DIRS); do cd $$i; $(MAKE) all; cd ..; done)
-
-clean:
- (for i in $(DIRS); do cd $$i; $(MAKE) clean; cd ..; done)
- rm -f *.o $(TESTS) $(BENCHMARKS) a.out core maketmp makeout
-
-depend:
- (for i in $(DIRS); do cd $$i; $(MAKE) depend; cd ..; done)
- sed '/\#\#\# Dependencies/q' < Makefile > maketmp
- (for i in $(CSRC);do $(CPP) -M $$i;done) >> maketmp
- cp maketmp Makefile
-
-install:
- (for i in $(DIRS); do cd $$i; $(MAKE) install; cd ..; done)
-
-realclean: clean
- (for i in $(DIRS); do cd $$i; $(MAKE) realclean; cd ..; done)
- rm -f Makefile
-
-Makefile: Makefile.in
- (cd .. ; sh config.status)
-
-################################################################################
-### Do not remove the following line. It is for depend #########################
-### Dependencies:
diff --git a/lib/libpthread/lib/Makefile.in b/lib/libpthread/lib/Makefile.in
deleted file mode 100644
index 821d293d896..00000000000
--- a/lib/libpthread/lib/Makefile.in
+++ /dev/null
@@ -1,48 +0,0 @@
-# === GNUmakefile ============================================================
-# Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
-#
-# Description: This file is for creating the test programs for libpthread.a
-#
-# 1.00 93/08/03 proven
-# -Initial cut for pthreads.
-#
-
-CC = ../pgcc -notinstalled
-srctop = @srctop@
-srcdir = @srctop@/lib
-VPATH = @srctop@/lib
-CDEBUGFLAGS = @CFLAGS@
-
-CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(ADDL_CFLAGS) -DSRCDIR=\"$(srcdir)\"
-
-#
-DIRS = libpthreadutil
-
-################################################################################
-#
-all:
- (for i in $(DIRS); do cd $$i; $(MAKE) all; cd ..; done)
-
-clean:
- (for i in $(DIRS); do cd $$i; $(MAKE) clean; cd ..; done)
- rm -f *.o $(TESTS) $(BENCHMARKS) a.out core maketmp makeout
-
-depend:
- (for i in $(DIRS); do cd $$i; $(MAKE) depend; cd ..; done)
- sed '/\#\#\# Dependencies/q' < Makefile > maketmp
- (for i in $(CSRC);do $(CPP) -M $$i;done) >> maketmp
- cp maketmp Makefile
-
-install:
- (for i in $(DIRS); do cd $$i; $(MAKE) install; cd ..; done)
-
-realclean: clean
- (for i in $(DIRS); do cd $$i; $(MAKE) realclean; cd ..; done)
- rm -f Makefile
-
-Makefile: Makefile.in
- (cd .. ; sh config.status)
-
-################################################################################
-### Do not remove the following line. It is for depend #########################
-### Dependencies:
diff --git a/lib/libpthread/lib/libpthreadutil/Makefile b/lib/libpthread/lib/libpthreadutil/Makefile
deleted file mode 100644
index 58bd76446ec..00000000000
--- a/lib/libpthread/lib/libpthreadutil/Makefile
+++ /dev/null
@@ -1,66 +0,0 @@
-# Generated automatically from Makefile.in by configure.
-# === makefile ============================================================
-# Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
-#
-# Description: This file is for creating the test programs for libpthread.a
-#
-# 1.00 93/08/03 proven
-# -Initial cut for pthreads.
-#
-
-srctop = /dr1/my/masters/mysql/mit-pthreads
-srcdir = /dr1/my/masters/mysql/mit-pthreads/lib/libpthreadutil
-VPATH = /dr1/my/masters/mysql/mit-pthreads/lib/libpthreadutil
-prefix= /usr/local/pthreads
-exec_prefix= ${prefix}
-
-INSTALL_PATH = ${prefix}
- BINDIR = $(INSTALL_PATH)/bin
- LIBDIR = $(INSTALL_PATH)/lib
- MANDIR = $(INSTALL_PATH)/man
- INCDIR = $(INSTALL_PATH)/include
-
- CC = ../../pgcc -notinstalled
- CDEBUGFLAGS = -g -O2 -Werror
- CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(ADDL_CFLAGS) -DSRCDIR=\"$(srcdir)\"
- RANLIB = ranlib
-
- OBJS = pthread_tad.o pthread_atexit.o
- LIBRARY = libpthreadutil.a
- HEADERS = pthreadutil.h
-
-################################################################################
-#
-all : $(LIBRARY)
-
-clean:
- rm -f *.o $(TESTS) $(BENCHMARKS) a.out core maketmp makeout
-
-depend:
- sed '/\#\#\# Dependencies/q' < Makefile > maketmp
- (for i in $(CSRC);do $(CPP) -M $$i;done) >> maketmp
- cp maketmp Makefile
-
-install: $(LIBRARY)
- install $(LIBRARY) $(LIBDIR)
- for x in $(HEADERS); \
- do cp $(srcdir)/$$x $(INCDIR); \
- done
-
-realclean: clean
- rm -f Makefile
-
-Makefile: Makefile.in
- (cd ../.. ; sh config.status)
-
-.c.o:
- $(CC) $(CFLAGS) -c $<
-
-$(LIBRARY) : ${OBJS}
- ar r new.a ${OBJS} && \
- $(RANLIB) new.a && \
- mv -f new.a $(LIBRARY)
-
-################################################################################
-### Do not remove the following line. It is for depend #########################
-### Dependencies:
diff --git a/lib/libpthread/lib/libpthreadutil/Makefile.in b/lib/libpthread/lib/libpthreadutil/Makefile.in
deleted file mode 100755
index 94034f426b3..00000000000
--- a/lib/libpthread/lib/libpthreadutil/Makefile.in
+++ /dev/null
@@ -1,65 +0,0 @@
-# === makefile ============================================================
-# Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
-#
-# Description: This file is for creating the test programs for libpthread.a
-#
-# 1.00 93/08/03 proven
-# -Initial cut for pthreads.
-#
-
-srctop = @srctop@
-srcdir = @srctop@/lib/libpthreadutil
-VPATH = @srctop@/lib/libpthreadutil
-prefix= @prefix@
-exec_prefix= @exec_prefix@
-
-INSTALL_PATH = @exec_prefix@
- BINDIR = $(INSTALL_PATH)/bin
- LIBDIR = $(INSTALL_PATH)/lib
- MANDIR = $(INSTALL_PATH)/man
- INCDIR = $(INSTALL_PATH)/include
-
- CC = ../../pgcc -notinstalled
- CDEBUGFLAGS = @CFLAGS@
- CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(ADDL_CFLAGS) -DSRCDIR=\"$(srcdir)\"
- RANLIB = @RANLIB@
-
- OBJS = pthread_tad.o pthread_atexit.o
- LIBRARY = libpthreadutil.a
- HEADERS = pthreadutil.h
-
-################################################################################
-#
-all : $(LIBRARY)
-
-clean:
- rm -f *.o $(TESTS) $(BENCHMARKS) a.out core maketmp makeout
-
-depend:
- sed '/\#\#\# Dependencies/q' < Makefile > maketmp
- (for i in $(CSRC);do $(CPP) -M $$i;done) >> maketmp
- cp maketmp Makefile
-
-install: $(LIBRARY)
- install $(LIBRARY) $(LIBDIR)
- for x in $(HEADERS); \
- do cp $(srcdir)/$$x $(INCDIR); \
- done
-
-realclean: clean
- rm -f Makefile
-
-Makefile: Makefile.in
- (cd ../.. ; sh config.status)
-
-.c.o:
- $(CC) $(CFLAGS) -c $<
-
-$(LIBRARY) : ${OBJS}
- ar r new.a ${OBJS} && \
- $(RANLIB) new.a && \
- mv -f new.a $(LIBRARY)
-
-################################################################################
-### Do not remove the following line. It is for depend #########################
-### Dependencies:
diff --git a/lib/libpthread/lib/libpthreadutil/pthread_atexit.c b/lib/libpthread/lib/libpthreadutil/pthread_atexit.c
deleted file mode 100755
index 1d1e1ec3a6d..00000000000
--- a/lib/libpthread/lib/libpthreadutil/pthread_atexit.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/* ==== pthread_atexit.c =====================================================
- * 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 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.
- *
- * Description : Pthread attribute functions.
- *
- * 1.20 94/02/13 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: pthread_atexit.c,v 1.1 1998/07/21 13:22:22 peter Exp $";
-#endif
-
-#define PTHREAD_KERNEL
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "pthreadutil.h"
-
-static int pthread_atexit_inited = 0;
-static pthread_key_t pthread_atexit_key;
-static pthread_mutex_t pthread_atexit_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-/* ==========================================================================
- * pthread_atexit_done()
- */
-static void pthread_atexit_done(void * arg)
-{
- pthread_atexit_t id, id_next;
-
- for (id = arg; id; id = id_next) {
- id_next = id->next;
- id->rtn(id->arg);
- free(id);
- }
-}
-
-/* ==========================================================================
- * pthread_atexit_add()
- */
-int pthread_atexit_add(pthread_atexit_t *id, void (*rtn)(void *), void * arg)
-{
- int ret;
-
- if (ret = pthread_mutex_lock(&pthread_atexit_mutex)) {
- return(ret);
- }
- if (!pthread_atexit_inited) {
- if (ret = pthread_key_create(&pthread_atexit_key, pthread_atexit_done)){
- pthread_mutex_unlock(&pthread_atexit_mutex);
- return(ret);
- }
- pthread_atexit_inited++;
- }
- pthread_mutex_unlock(&pthread_atexit_mutex);
-
- if ((*id) = (pthread_atexit_t)malloc(sizeof(struct pthread_atexit))) {
- if ((*id)->next = pthread_getspecific(pthread_atexit_key)) {
- (*id)->next->prev = (*id);
- }
- pthread_setspecific(pthread_atexit_key, (void *)*id);
- (*id)->prev = NULL;
- (*id)->rtn = rtn;
- (*id)->arg = arg;
- return(OK);
- }
- return(ENOMEM);
-}
-
-/* ==========================================================================
- * pthread_atexit_remove()
- */
-int pthread_atexit_remove(pthread_atexit_t * id, int execute)
-{
- pthread_atexit_t old;
-
- if (old = pthread_getspecific(pthread_atexit_key)) {
- if (old == *id) {
- old = old->next;
- old->prev = NULL;
- pthread_setspecific(pthread_atexit_key, old);
- } else {
- if ((*id)->next) {
- (*id)->next->prev = (*id)->prev;
- }
- (*id)->prev->next = (*id)->next;
- }
- if (execute) {
- (*id)->rtn((*id)->arg);
- }
- free((*id));
- return(OK);
- }
- return(EINVAL);
-}
-
-/* ==========================================================================
- * A few non void functions that are often used as void functions
- */
-void fflush_nrv(void * fp) { fflush((FILE *)fp); }
-void fclose_nrv(void * fp) { fclose((FILE *)fp); }
-
-void pthread_attr_destroy_nrv(void * attr)
-{
- pthread_attr_destroy((pthread_attr_t *)attr);
-}
diff --git a/lib/libpthread/lib/libpthreadutil/pthread_tad.c b/lib/libpthread/lib/libpthreadutil/pthread_tad.c
deleted file mode 100755
index a59fd9b87bf..00000000000
--- a/lib/libpthread/lib/libpthreadutil/pthread_tad.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/* ==== pthread_tad.c =========================================================
- * Copyright (c) 1995 by Chris Provenzano, proven@athena.mit.edu
- *
- * 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,
- * and its contributors.
- * 4. Neither the name of Chris Provenzano, nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO, 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 lint
-static char copyright[] =
- "@(#) Copyright (c) 1995 Chris Provenzano.\nAll rights reserved.\n";
-#endif /* not lint */
-
-/* tad = thread allocation domain */
-#define PTHREAD_KERNEL
-
-#include "pthreadutil.h"
-#include <stdio.h>
-#include <errno.h>
-
-int pthread_tad_count(pthread_tad_t * tad)
-{
- int ret;
-
- pthread_mutex_lock(&tad->mutex);
- ret = tad->count_current;
- pthread_mutex_unlock(&tad->mutex);
- return(ret);
-}
-
-static void pthread_tad_done(void * arg)
-{
- pthread_tad_t * tad = arg;
- pthread_mutex_lock(&tad->mutex);
- --tad->count_current;
-/* if (--tad->count_current < tad->count_max) */
- pthread_cond_broadcast(&tad->cond);
- pthread_mutex_unlock(&tad->mutex);
-}
-
-#ifndef PTHREAD_KERNEL
-struct tad_start {
- pthread_tad_t * tad;
- void * (*routine)();
- void * arg;
-};
-
-static void * pthread_tad_start(struct tad_start * tad_start)
-{
- void * (*routine)() = tad_start->routine;
- void * arg = tad_start->arg;
-
- pthread_mutex_lock(&tad_start->tad->mutex);
- pthread_cleanup_push(pthread_tad_done, tad_start->tad);
- pthread_mutex_unlock(&tad_start->tad->mutex);
- free(tad_start);
- return(routine(arg));
-}
-#else
-static void * pthread_tad_start(void * tad_start_arg)
-{
- pthread_tad_t * tad = tad_start_arg;
- void * (*routine)() = tad->routine;
- void * arg = tad->arg;
-
- tad->count_current++;
- pthread_cleanup_push(pthread_tad_done, tad);
- pthread_mutex_unlock(&tad->mutex);
- return(routine(arg));
-}
-#endif
-
-int pthread_tad_create(pthread_tad_t * tad, pthread_t *thread_id,
- pthread_attr_t *attr, void * (*routine)(), void * arg)
-{
-#ifndef PTHREAD_KERNEL
- struct tad_start tad;
-#endif
- int ret;
-
- pthread_mutex_lock(&tad->mutex);
- while (tad->count_max && (tad->count_current > tad->count_max))
- pthread_cond_wait(&tad->cond, &tad->mutex);
-
-#ifndef PTHREAD_KERNEL
- if ((tad_start = malloc(sizeof(struct tad_start))) == NULL) {
- pthread_mutex_unlock(&tad->mutex);
- return(ENOMEM);
- }
- tad_start->routine = routine;
- tad_start->arg = arg;
- tad_start->tad = tad;
- if ((ret = pthread_create(thread_id, attr,
- pthread_tad_start, tad_start)) == OK)
- tad->count_current++;
- pthread_mutex_unlock(&tad->mutex);
-#else
- tad->routine = routine;
- tad->arg = arg;
- if (ret = pthread_create(thread_id, attr, pthread_tad_start, tad))
- pthread_mutex_unlock(&tad->mutex);
-#endif
- return(ret);
-}
-
-int pthread_tad_wait(pthread_tad_t * tad, unsigned int count)
-{
- if ((tad->count_max) && (tad->count_max < count)) {
- return(EINVAL);
- }
- pthread_mutex_lock(&tad->mutex);
- while (tad->count_current > count)
- pthread_cond_wait(&tad->cond, &tad->mutex);
- pthread_mutex_unlock(&tad->mutex);
- return(OK);
-}
-
-int pthread_tad_init(pthread_tad_t * tad, unsigned int max_count)
-{
- int ret;
-
- if ((ret = pthread_mutex_init(&tad->mutex, NULL)) == OK) {
- if (ret = pthread_cond_init(&tad->cond, NULL)) {
- pthread_mutex_destroy(&tad->mutex);
- } else {
- tad->count_max = max_count;
- tad->count_current = 0;
- }
- }
- return(ret);
-}
-
-/* User is responsible to make sure their are no threads running */
-int pthread_tad_destroy(pthread_tad_t * tad)
-{
- int ret;
-
- if ((ret = pthread_mutex_destroy(&tad->mutex)) == OK) {
- ret = pthread_cond_destroy(&tad->cond);
- } else {
- pthread_cond_destroy(&tad->cond);
- }
- tad->count_max = NOTOK;
- return(ret);
-}
diff --git a/lib/libpthread/lib/libpthreadutil/pthreadutil.h b/lib/libpthread/lib/libpthreadutil/pthreadutil.h
deleted file mode 100644
index 0d8e6a6ef5f..00000000000
--- a/lib/libpthread/lib/libpthreadutil/pthreadutil.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* ==== pthread_tad.h ========================================================
- * Copyright (c) 1995 by Chris Provenzano, proven@athena.mit.edu
- *
- * 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,
- * and its contributors.
- * 4. Neither the name of Chris Provenzano, nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO, 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 <pthread.h>
-#include <sys/cdefs.h>
-
-typedef struct pthread_tad_t {
- pthread_mutex_t mutex;
- pthread_cond_t cond;
- unsigned int count_current;
- unsigned int count_max;
- void * arg;
- void * (*routine)();
-} pthread_tad_t;
-
-typedef struct pthread_atexit {
- struct pthread_atexit * next;
- struct pthread_atexit * prev;
- void (*rtn)(void *);
- void * arg;
-} * pthread_atexit_t;
-
-/*
- * New functions
- */
-
-__BEGIN_DECLS
-
-int pthread_tad_count __P_((pthread_tad_t *));
-int pthread_tad_create __P_((pthread_tad_t *, pthread_t *, pthread_attr_t *,
- void *(*routine)(), void *));
-int pthread_tad_wait __P_((pthread_tad_t *, unsigned int));
-int pthread_tad_init __P_((pthread_tad_t *, unsigned int));
-int pthread_tad_destroy __P_((pthread_tad_t *));
-
-int pthread_atexit_add __P_((pthread_atexit_t *, void (*)(void *), void *));
-int pthread_atexit_remove __P_((pthread_atexit_t *, int));
-
-
-void fclose_nrv __P_((void *));
-void fflush_nrv __P_((void *));
-void pthread_attr_destroy_nrv __P_((void *));
-
-__END_DECLS
-
diff --git a/lib/libpthread/net/Makefile.inc b/lib/libpthread/net/Makefile.inc
deleted file mode 100644
index 76726e79e3a..00000000000
--- a/lib/libpthread/net/Makefile.inc
+++ /dev/null
@@ -1,13 +0,0 @@
-# from: @(#)Makefile.inc 5.21 (Berkeley) 5/24/91
-# $Id: Makefile.inc,v 1.2 1998/07/21 16:28:42 peter Exp $
-
-.PATH: ${.CURDIR}/net
-
-SRCS+= gethostbyaddr.c gethostbyname.c gethostent.c getnetbyaddr.c \
- getnetbyname.c getnetent.c getproto.c getprotoent.c getprotoname.c \
- getservbyname.c getservbyport.c getservent.c herror.c inet_addr.c \
- inet_lnaof.c inet_makeaddr.c inet_netof.c inet_network.c inet_ntoa.c \
- net_internal.c proto_internal.c res_comp.c res_init.c res_internal.c \
- res_mkquery.c res_query.c res_querydomain.c res_search.c res_send.c \
- serv_internal.c
-
diff --git a/lib/libpthread/net/gethostbyaddr.c b/lib/libpthread/net/gethostbyaddr.c
deleted file mode 100644
index c996137138e..00000000000
--- a/lib/libpthread/net/gethostbyaddr.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (c) 1985, 1988 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)gethostbyaddr.c 6.45 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: gethostbyaddr.c,v 1.1 1998/07/21 13:19:44 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-
-#include <pthread.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <resolv.h>
-#include <netinet/in.h>
-#include <errno.h>
-#include <sys/socket.h>
-#include "res_internal.h"
-
-static struct hostent *file_find_addr(const char *addr, int len, int type,
- struct hostent *result, char *buf,
- int bufsize, int *errval);
-
-struct hostent *gethostbyaddr(const char *addr, int len, int type)
-{
- struct res_data *data = _res_init();
-
- if (!data)
- return NULL;
- if (!data->buf) {
- data->buf = malloc(sizeof(struct hostent) + HOST_BUFSIZE);
- if (!data->buf) {
- errno = 0;
- data->errval = NO_RECOVERY;
- return NULL;
- }
- }
- return gethostbyaddr_r(addr, len, type, (struct hostent *) data->buf,
- data->buf + sizeof(struct hostent), HOST_BUFSIZE,
- &data->errval);
-}
-
-struct hostent *gethostbyaddr_r(const char *addr, int len, int type,
- struct hostent *result, char *buf, int bufsize,
- int *errval)
-{
- struct res_data *data;
- querybuf qbuf;
- char lookups[MAXDNSLUS], addrbuf[MAXDNAME], *abuf;
- struct hostent *hp;
- int n, i;
-
- /* Default failure condition is not a range error and not recoverable. */
- errno = 0;
- *errval = NO_RECOVERY;
-
- data = _res_init();
- if (!data)
- return NULL;
-
- if (type != AF_INET)
- return NULL;
- sprintf(addrbuf, "%u.%u.%u.%u.in-addr.arpa",
- (unsigned)addr[3] & 0xff, (unsigned)addr[2] & 0xff,
- (unsigned)addr[1] & 0xff, (unsigned)addr[0] & 0xff);
-
- memcpy(lookups, data->state.lookups, sizeof(lookups));
- if (*lookups == 0)
- strncpy(lookups, "bf", sizeof(lookups));
-
- hp = NULL;
- for (i = 0; i < MAXDNSLUS && hp == NULL && lookups[i]; i++) {
- switch (lookups[i]) {
- case 'b':
-
- /* Allocate space for a one-item list of addresses. */
- abuf = SP(SP(buf, char *, 2), struct in_addr, 1);
- if (abuf > buf + bufsize) {
- errno = ERANGE;
- return NULL;
- }
-
- /* Perform and parse the query. */
- n = res_query(addrbuf, C_IN, T_PTR, (char *)&qbuf, sizeof(qbuf));
- if (n < 0)
- break;
- hp = _res_parse_answer(&qbuf, n, 1, result, abuf,
- bufsize - (abuf - buf), errval);
- if (hp == NULL)
- break;
-
- /* Fill in our own address list. */
- result->h_addrtype = type;
- result->h_length = len;
- result->h_addr_list = (char **) ALIGN(buf, char *);
- result->h_addr_list[0] = ALIGN(&result->h_addr_list[2],
- struct in_addr);
- result->h_addr_list[1] = NULL;
- break;
-
- case 'f':
- hp = file_find_addr(addr, len, type, result, buf, bufsize, errval);
- break;
- }
- }
-
- return hp;
-}
-
-static struct hostent *file_find_addr(const char *addr, int len, int type,
- struct hostent *result, char *buf,
- int bufsize, int *errval)
-{
- FILE *fp = NULL;
-
- pthread_mutex_lock(&host_iterate_lock);
- sethostent(0);
- while ((result = gethostent_r(result, buf, bufsize, errval)) != NULL) {
- /* Check the entry against the given address. */
- if (result->h_addrtype == type &&
- memcmp(result->h_addr, addr, len) == 0)
- break;
- }
- pthread_mutex_unlock(&host_iterate_lock);
- if (!result && errno != ERANGE)
- *errval = HOST_NOT_FOUND;
- return result;
-}
-
diff --git a/lib/libpthread/net/gethostbyname.c b/lib/libpthread/net/gethostbyname.c
deleted file mode 100644
index 2a5e898134c..00000000000
--- a/lib/libpthread/net/gethostbyname.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (c) 1985, 1988 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)gethostbyname.c 6.45 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: gethostbyname.c,v 1.1 1998/07/21 13:19:44 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <resolv.h>
-#include "res_internal.h"
-
-static struct hostent *fake_hostent(const char *hostname, struct in_addr addr,
- struct hostent *result, char *buf,
- int bufsize, int *errval);
-static struct hostent *file_find_name(const char *name, struct hostent *result,
- char *buf, int bufsize, int *errval);
-
-struct hostent *gethostbyname(const char *hostname)
-{
- struct res_data *data = _res_init();
-
- if (!data)
- return NULL;
- if (!data->buf) {
- data->buf = malloc(sizeof(struct hostent) + HOST_BUFSIZE);
- if (!data->buf) {
- errno = 0;
- data->errval = NO_RECOVERY;
- return NULL;
- }
- }
- return gethostbyname_r(hostname, (struct hostent *) data->buf,
- data->buf + sizeof(struct hostent), HOST_BUFSIZE,
- &data->errval);
-}
-
-struct hostent *gethostbyname_r(const char *hostname, struct hostent *result,
- char *buf, int bufsize, int *errval)
-{
- struct in_addr addr;
- querybuf qbuf;
- const char *p;
- int n;
-
- /* Default failure condition is not a range error and not recoverable. */
- errno = 0;
- *errval = NO_RECOVERY;
-
- /* Check for all-numeric hostname with no trailing dot. */
- if (isdigit(hostname[0])) {
- p = hostname;
- while (*p && (isdigit(*p) || *p == '.'))
- p++;
- if (!*p && p[-1] != '.') {
- /* Looks like an IP address; convert it. */
- if (inet_aton(hostname, &addr) == -1) {
- *errval = HOST_NOT_FOUND;
- return NULL;
- }
- return fake_hostent(hostname, addr, result, buf, bufsize, errval);
- }
- }
-
- /* Do the search. */
- n = res_search(hostname, C_IN, T_A, qbuf.buf, sizeof(qbuf));
- if (n >= 0)
- return _res_parse_answer(&qbuf, n, 0, result, buf, bufsize, errval);
- else if (errno == ECONNREFUSED)
- return file_find_name(hostname, result, buf, bufsize, errval);
- else
- return NULL;
-}
-
-static struct hostent *fake_hostent(const char *hostname, struct in_addr addr,
- struct hostent *result, char *buf,
- int bufsize, int *errval)
-{
- int len = strlen(hostname);
- char *name, *addr_ptr;
-
- if (SP(SP(SP(buf, char, len + 1), addr, 1), char *, 3) > buf + bufsize) {
- errno = ERANGE;
- return NULL;
- }
-
- /* Copy faked name and address into buffer. */
- strcpy(buf, hostname);
- name = buf;
- buf = ALIGN(buf + len + 1, addr);
- *((struct in_addr *) buf) = addr;
- addr_ptr = buf;
- buf = ALIGN(buf + sizeof(addr), char *);
- ((char **) buf)[0] = addr_ptr;
- ((char **) buf)[1] = NULL;
- ((char **) buf)[2] = NULL;
-
- result->h_name = name;
- result->h_aliases = ((char **) buf) + 2;
- result->h_addrtype = AF_INET;
- result->h_length = sizeof(addr);
- result->h_addr_list = (char **) buf;
-
- return result;
-}
-
-static struct hostent *file_find_name(const char *name, struct hostent *result,
- char *buf, int bufsize, int *errval)
-{
- char **alias;
- FILE *fp = NULL;
-
- pthread_mutex_lock(&host_iterate_lock);
- sethostent(0);
- while ((result = gethostent_r(result, buf, bufsize, errval)) != NULL) {
- /* Check the entry's name and aliases against the given name. */
- if (strcasecmp(result->h_name, name) == 0)
- break;
- for (alias = result->h_aliases; *alias; alias++) {
- if (strcasecmp(*alias, name) == 0)
- goto end; /* Josip Gracin */
- }
- }
-end:
- pthread_mutex_unlock(&host_iterate_lock);
- if (!result && errno != ERANGE)
- *errval = HOST_NOT_FOUND;
- return result;
-}
-
diff --git a/lib/libpthread/net/gethostent.c b/lib/libpthread/net/gethostent.c
deleted file mode 100644
index feb065129dd..00000000000
--- a/lib/libpthread/net/gethostent.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)gethostent.c 5.8 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: gethostent.c,v 1.1 1998/07/21 13:19:45 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include "res_internal.h"
-
-static pthread_mutex_t res_file_lock = PTHREAD_MUTEX_INITIALIZER;
-static int res_file_stayopen;
-static FILE *res_file;
-
-void sethostent(int stayopen)
-{
- pthread_mutex_lock(&res_file_lock);
- res_file_stayopen |= stayopen;
- if (res_file)
- rewind(res_file);
- else
- res_file = fopen(_PATH_HOSTS, "r");
- pthread_mutex_unlock(&res_file_lock);
-}
-
-void endhostent()
-{
- pthread_mutex_lock(&res_file_lock);
- if (res_file)
- fclose(res_file);
- pthread_mutex_unlock(&res_file_lock);
-}
-
-struct hostent *gethostent()
-{
- struct res_data *data = _res_init();
-
- if (!data)
- return NULL;
- if (!data->buf) {
- data->buf = malloc(sizeof(struct hostent) + HOST_BUFSIZE);
- if (!data->buf) {
- data->errval = NO_RECOVERY;
- return NULL;
- }
- }
- return gethostent_r((struct hostent *) data->buf,
- data->buf + sizeof(struct hostent), HOST_BUFSIZE,
- &data->errval);
-}
-
-struct hostent *gethostent_r(struct hostent *result, char *buf, int bufsize,
- int *errval)
-{
- char *p, **alias;
- struct in_addr *addr;
- int l;
-
- errno = 0;
- pthread_mutex_lock(&res_file_lock);
- if (res_file == NULL && (res_file = fopen(_PATH_HOSTS, "r")) == NULL) {
- pthread_mutex_unlock(&res_file_lock);
- return NULL;
- }
- while (fgets(buf, bufsize, res_file)) {
- if (*buf == '#')
- continue;
- p = strpbrk(buf, "#\n");
- if (p == NULL)
- continue;
- l = strlen(buf) + 1;
- *p = '\0';
- p = strpbrk(buf, " \t");
- if (p == NULL)
- continue;
- *p++ = '\0';
-
- /* THIS STUFF IS INTERNET SPECIFIC */
- if (SP(SP(SP(buf, char, l), *addr, 1), char *, 3) > buf + bufsize) {
- errno = ERANGE;
- break;
- }
- addr = (struct in_addr *) ALIGN(buf + l, struct in_addr);
- if (inet_aton(buf, addr) == 0)
- continue;
- result->h_length = sizeof(*addr);
- result->h_addrtype = AF_INET;
- result->h_addr_list = (char **) ALIGN(addr + sizeof(*addr), char *);
- result->h_addr_list[0] = (char *) addr;
- result->h_addr_list[1] = NULL;
- result->h_aliases = result->h_addr_list + 2;
- while (*p == ' ' || *p == '\t')
- p++;
- result->h_name = p;
- alias = result->h_aliases;
- p = strpbrk(p, " \t");
- if (p != NULL)
- *p++ = '\0';
- while (p && *p) {
- if (*p == ' ' || *p == '\t') {
- p++;
- continue;
- }
- if ((char *) &alias[2] > buf + bufsize) {
- errno = ERANGE;
- break;
- }
- *alias++ = p;
- p = strpbrk(p, " \t");
- if (p != NULL)
- *p++ = '\0';
- }
- if (p && *p)
- break;
- *alias = NULL;
- pthread_mutex_unlock(&res_file_lock);
- return result;
- }
-
- pthread_mutex_unlock(&res_file_lock);
- *errval = (errno == ERANGE) ? NO_RECOVERY : 0;
- return NULL;
-}
-
diff --git a/lib/libpthread/net/getnetbyaddr.c b/lib/libpthread/net/getnetbyaddr.c
deleted file mode 100644
index d836d3938d7..00000000000
--- a/lib/libpthread/net/getnetbyaddr.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)getnetbyaddr.c 5.7 (Berkeley) 6/1/90";*/
-static char *rcsid = "$Id: getnetbyaddr.c,v 1.1 1998/07/21 13:19:45 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-#include <netdb.h>
-#include "net_internal.h"
-
-struct netent *getnetbyaddr(long net, int type)
-{
- char *buf = _net_buf();
-
- if (!buf)
- return NULL;
- return getnetbyaddr_r(net, type, (struct netent *) buf,
- buf + sizeof(struct netent), NET_BUFSIZE);
-}
-
-struct netent *getnetbyaddr_r(long net, int type, struct netent *result,
- char *buf, int bufsize)
-{
- pthread_mutex_lock(&net_iterate_lock);
- setnetent(0);
- while ((result = getnetent_r(result, buf, bufsize)) != NULL) {
- if (result->n_addrtype == type && result->n_net == net)
- break;
- }
- pthread_mutex_unlock(&net_iterate_lock);
- return result;
-}
-
diff --git a/lib/libpthread/net/getnetbyname.c b/lib/libpthread/net/getnetbyname.c
deleted file mode 100644
index 41a05ad7422..00000000000
--- a/lib/libpthread/net/getnetbyname.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)getnetbyname.c 5.7 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: getnetbyname.c,v 1.1 1998/07/21 13:19:45 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <netdb.h>
-#include <string.h>
-#include "net_internal.h"
-
-struct netent *getnetbyname(const char *name)
-{
- char *buf = _net_buf();
-
- if (!buf)
- return NULL;
- return getnetbyname_r(name, (struct netent *) buf,
- buf + sizeof(struct netent), NET_BUFSIZE);
-}
-
-struct netent *getnetbyname_r(const char *name, struct netent *result,
- char *buf, int bufsize)
-{
- char **alias;
-
- pthread_mutex_lock(&net_iterate_lock);
- setnetent(0);
- while ((result = getnetent_r(result, buf, bufsize)) != NULL) {
- /* Check the entry's name and aliases against the given name. */
- if (strcmp(result->n_name, name) == 0)
- break;
- for (alias = result->n_aliases; *alias != 0; alias++) {
- if (strcmp(*alias, name) == 0)
- break;
- }
- }
- pthread_mutex_unlock(&net_iterate_lock);
- return result;
-}
-
diff --git a/lib/libpthread/net/getnetent.c b/lib/libpthread/net/getnetent.c
deleted file mode 100644
index 192cc03ce39..00000000000
--- a/lib/libpthread/net/getnetent.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)getnetent.c 5.8 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: getnetent.c,v 1.1 1998/07/21 13:19:45 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include "net_internal.h"
-
-static pthread_mutex_t net_file_lock = PTHREAD_MUTEX_INITIALIZER;
-static int net_file_stayopen;
-static FILE *net_file;
-
-void setnetent(int stayopen)
-{
- pthread_mutex_lock(&net_file_lock);
- net_file_stayopen |= stayopen;
- if (net_file)
- rewind(net_file);
- else
- net_file = fopen(_PATH_NETWORKS, "r");
- pthread_mutex_unlock(&net_file_lock);
-}
-
-void endnetent()
-{
- pthread_mutex_lock(&net_file_lock);
- if (net_file)
- fclose(net_file);
- pthread_mutex_unlock(&net_file_lock);
-}
-
-struct netent *getnetent()
-{
- char *buf = _net_buf();
-
- return getnetent_r((struct netent *) buf, buf + sizeof(struct netent),
- NET_BUFSIZE);
-}
-
-struct netent *getnetent_r(struct netent *result, char *buf, int bufsize)
-{
- char *p, *q, **alias;
- int l;
-
- errno = 0;
- pthread_mutex_lock(&net_file_lock);
- if (net_file == NULL && (net_file = fopen(_PATH_NETWORKS, "r")) == NULL) {
- pthread_mutex_unlock(&net_file_lock);
- return NULL;
- }
- while (fgets(buf, bufsize, net_file)) {
- if (*buf == '#')
- continue;
- p = strpbrk(buf, "#\n");
- if (p == NULL)
- continue;
- *p = '\0';
- l = strlen(buf) + 1;
- result->n_name = buf;
- p = strpbrk(buf, " \t");
- if (p == NULL)
- continue;
- *p++ = '\0';
- while (*p == ' ' || *p == '\t')
- p++;
- q = strpbrk(p, " \t");
- if (q != NULL)
- *q++ = '\0';
- if (SP(SP(buf, char, l), char *, 1) > buf + bufsize) {
- errno = ERANGE;
- break;
- }
- result->n_net = inet_network(p);
- result->n_addrtype = AF_INET;
- result->n_aliases = (char **) ALIGN(buf + l, char *);
- alias = result->n_aliases;
- if (q != NULL) {
- p = q;
- while (p && *p) {
- if (*p == ' ' || *p == '\t') {
- p++;
- continue;
- }
- if ((char *) &alias[2] > buf + bufsize) {
- errno = ERANGE;
- break;
- }
- *alias++ = p;
- p = strpbrk(p, " \t");
- if (p != NULL)
- *p++ = '\0';
- }
- if (p && *p)
- break;
- }
- *alias = NULL;
- pthread_mutex_unlock(&net_file_lock);
- return result;
- }
-
- pthread_mutex_unlock(&net_file_lock);
- return NULL;
-}
-
diff --git a/lib/libpthread/net/getproto.c b/lib/libpthread/net/getproto.c
deleted file mode 100644
index a4366fc7b61..00000000000
--- a/lib/libpthread/net/getproto.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)getproto.c 5.6 (Berkeley) 6/1/90";*/
-static char *rcsid = "$Id: getproto.c,v 1.1 1998/07/21 13:19:45 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-#include <netdb.h>
-#include "proto_internal.h"
-
-struct protoent *getprotobynumber(int proto)
-{
- char *buf = _proto_buf();
-
- if (!buf)
- return NULL;
- return getprotobynumber_r(proto, (struct protoent *) buf,
- buf + sizeof(struct protoent), PROTO_BUFSIZE);
-}
-
-struct protoent *getprotobynumber_r(int proto, struct protoent *result,
- char *buf, int bufsize)
-{
- pthread_mutex_lock(&proto_iterate_lock);
- setprotoent(0);
- while ((result = getprotoent_r(result, buf, bufsize)) != NULL) {
- if (result->p_proto == proto)
- break;
- }
- pthread_mutex_unlock(&proto_iterate_lock);
- return result;
-}
-
diff --git a/lib/libpthread/net/getprotoent.c b/lib/libpthread/net/getprotoent.c
deleted file mode 100644
index be8d13d4f12..00000000000
--- a/lib/libpthread/net/getprotoent.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)getprotoent.c 5.8 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: getprotoent.c,v 1.1 1998/07/21 13:19:45 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include "proto_internal.h"
-
-static pthread_mutex_t proto_file_lock = PTHREAD_MUTEX_INITIALIZER;
-static int proto_file_stayopen;
-static FILE *proto_file;
-
-void setprotoent(int stayopen)
-{
- pthread_mutex_lock(&proto_file_lock);
- proto_file_stayopen |= stayopen;
- if (proto_file)
- rewind(proto_file);
- else
- proto_file = fopen(_PATH_PROTOCOLS, "r");
- pthread_mutex_unlock(&proto_file_lock);
-}
-
-void endprotoent()
-{
- pthread_mutex_lock(&proto_file_lock);
- if (proto_file)
- fclose(proto_file);
- pthread_mutex_unlock(&proto_file_lock);
-}
-
-struct protoent *getprotoent()
-{
- char *buf = _proto_buf();
-
- return getprotoent_r((struct protoent *) buf,
- buf + sizeof(struct protoent), PROTO_BUFSIZE);
-}
-
-struct protoent *getprotoent_r(struct protoent *result, char *buf, int bufsize)
-{
- char *p, *q, **alias;
- int l;
-
- errno = 0;
- pthread_mutex_lock(&proto_file_lock);
- if (proto_file == NULL && !(proto_file = fopen(_PATH_PROTOCOLS, "r"))) {
- pthread_mutex_unlock(&proto_file_lock);
- return NULL;
- }
- while (fgets(buf, bufsize, proto_file)) {
- if (*buf == '#')
- continue;
- p = strpbrk(buf, "#\n");
- if (p == NULL)
- continue;
- *p = '\0';
- l = strlen(buf) + 1;
- result->p_name = buf;
- p = strpbrk(buf, " \t");
- if (p == NULL)
- continue;
- *p++ = '\0';
- while (*p == ' ' || *p == '\t')
- p++;
- q = strpbrk(p, " \t");
- if (q != NULL)
- *q++ = '\0';
- if (SP(SP(buf, char, l), char *, 1) > buf + bufsize) {
- errno = ERANGE;
- break;
- }
- result->p_proto = atoi(p);
- result->p_aliases = (char **) ALIGN(buf + l, char *);
- alias = result->p_aliases;
- if (q != NULL) {
- p = q;
- while (p && *p) {
- if (*p == ' ' || *p == '\t') {
- p++;
- continue;
- }
- if ((char *) &alias[2] > buf + bufsize) {
- errno = ERANGE;
- break;
- }
- *alias++ = p;
- p = strpbrk(p, " \t");
- if (p != NULL)
- *p++ = '\0';
- }
- if (p && *p)
- break;
- }
- *alias = NULL;
- pthread_mutex_unlock(&proto_file_lock);
- return result;
- }
-
- pthread_mutex_unlock(&proto_file_lock);
- return NULL;
-}
-
diff --git a/lib/libpthread/net/getprotoname.c b/lib/libpthread/net/getprotoname.c
deleted file mode 100644
index b31704453ee..00000000000
--- a/lib/libpthread/net/getprotoname.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)getprotoname.c 5.7 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: getprotoname.c,v 1.1 1998/07/21 13:19:45 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <netdb.h>
-#include <string.h>
-#include "proto_internal.h"
-
-struct protoent *getprotobyname(const char *name)
-{
- char *buf = _proto_buf();
-
- if (!buf)
- return NULL;
- return getprotobyname_r(name, (struct protoent *) buf,
- buf + sizeof(struct protoent), PROTO_BUFSIZE);
-}
-
-struct protoent *getprotobyname_r(const char *name, struct protoent *result,
- char *buf, int bufsize)
-{
- char **alias;
-
- pthread_mutex_lock(&proto_iterate_lock);
- setprotoent(0);
- while ((result = getprotoent_r(result, buf, bufsize)) != NULL) {
- /* Check the entry's name and aliases against the given name. */
- if (strcmp(result->p_name, name) == 0)
- break;
- for (alias = result->p_aliases; *alias != 0; alias++) {
- if (strcmp(*alias, name) == 0)
- break;
- }
- }
- pthread_mutex_unlock(&proto_iterate_lock);
- return result;
-}
-
diff --git a/lib/libpthread/net/getservbyname.c b/lib/libpthread/net/getservbyname.c
deleted file mode 100644
index 7fc81aec97a..00000000000
--- a/lib/libpthread/net/getservbyname.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)getservbyname.c 5.7 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: getservbyname.c,v 1.1 1998/07/21 13:19:45 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <netdb.h>
-#include <string.h>
-#include "serv_internal.h"
-
-struct servent *getservbyname(const char *name, const char *proto)
-{
- char *buf = _serv_buf();
-
- if (!buf)
- return NULL;
- return getservbyname_r(name, proto, (struct servent *) buf,
- buf + sizeof(struct servent), SERV_BUFSIZE);
-}
-
-struct servent *getservbyname_r(const char *name, const char *proto,
- struct servent *result, char *buf, int bufsize)
-{
- char **alias;
-
- pthread_mutex_lock(&serv_iterate_lock);
- setservent(0);
- while ((result = getservent_r(result, buf, bufsize)) != NULL) {
- /* Check the entry's name and aliases against the given name. */
- if (strcmp(result->s_name, name) != 0) {
- for (alias = result->s_aliases; *alias != NULL; alias++) {
- if (strcmp(*alias, name) == 0)
- break;
- }
- if (*alias == NULL)
- continue;
- }
- if (proto == NULL || strcmp(result->s_proto, proto) == 0)
- break;
- }
- pthread_mutex_unlock(&serv_iterate_lock);
- return result;
-}
-
diff --git a/lib/libpthread/net/getservbyport.c b/lib/libpthread/net/getservbyport.c
deleted file mode 100644
index da16b55070e..00000000000
--- a/lib/libpthread/net/getservbyport.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)getservbyport.c 5.7 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: getservbyport.c,v 1.1 1998/07/21 13:19:45 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-#include <netdb.h>
-#include <string.h>
-#include "serv_internal.h"
-
-struct servent *getservbyport(int port, const char *proto)
-{
- char *buf = _serv_buf();
-
- if (!buf)
- return NULL;
- return getservbyport_r(port, proto, (struct servent *) buf,
- buf + sizeof(struct servent), SERV_BUFSIZE);
-}
-
-struct servent *getservbyport_r(int port, const char *proto,
- struct servent *result, char *buf, int bufsize)
-{
- pthread_mutex_lock(&serv_iterate_lock);
- setservent(0);
- while ((result = getservent_r(result, buf, bufsize)) != NULL) {
- if (result->s_port != port)
- continue;
- if (proto == NULL || strcmp(result->s_proto, proto) == 0)
- break;
- }
- pthread_mutex_unlock(&serv_iterate_lock);
- return result;
-}
-
diff --git a/lib/libpthread/net/getservent.c b/lib/libpthread/net/getservent.c
deleted file mode 100644
index a3990ef535a..00000000000
--- a/lib/libpthread/net/getservent.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)getservent.c 5.9 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: getservent.c,v 1.1 1998/07/21 13:19:45 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include "serv_internal.h"
-
-static pthread_mutex_t serv_file_lock = PTHREAD_MUTEX_INITIALIZER;
-static int serv_file_stayopen=0;
-static FILE *serv_file=NULL;
-
-void setservent(int stayopen)
-{
- pthread_mutex_lock(&serv_file_lock);
- serv_file_stayopen |= stayopen;
- if (serv_file)
- rewind(serv_file);
- else
- serv_file = fopen(_PATH_SERVICES, "r");
- pthread_mutex_unlock(&serv_file_lock);
-}
-
-void endservent()
-{
- pthread_mutex_lock(&serv_file_lock);
- if (serv_file)
- {
- fclose(serv_file);
- serv_file=NULL;
- }
- pthread_mutex_unlock(&serv_file_lock);
-}
-
-struct servent *getservent()
-{
- char *buf = _serv_buf();
-
- return getservent_r((struct servent *) buf, buf + sizeof(struct servent),
- SERV_BUFSIZE);
-}
-
-struct servent *getservent_r(struct servent *result, char *buf, int bufsize)
-{
- char *p, *q, **alias;
- int l;
-
- errno = 0;
- pthread_mutex_lock(&serv_file_lock);
- if (serv_file == NULL && !(serv_file = fopen(_PATH_SERVICES, "r"))) {
- pthread_mutex_unlock(&serv_file_lock);
- return NULL;
- }
- while (fgets(buf, bufsize, serv_file)) {
- if (*buf == '#')
- continue;
- p = strpbrk(buf, "#\n");
- if (p == NULL)
- continue;
- *p = '\0';
- l = strlen(buf) + 1;
- result->s_name = buf;
- q = strpbrk(buf, " \t");
- if (q == NULL)
- continue;
- *q++ = '\0';
- while (*q == ' ' || *q == '\t')
- q++;
- p = strpbrk(q, ",/");
- if (p == NULL)
- continue;
- *p++ = '\0';
- if (SP(SP(buf, char, l), char *, 1) > buf + bufsize) {
- errno = ERANGE;
- break;
- }
- result->s_port = htons((u_short)atoi(q));
- result->s_proto = p;
- result->s_aliases = (char **) ALIGN(buf + l, char *);
- alias = result->s_aliases;
- p = strpbrk(p, " \t");
- if (p != NULL)
- *p++ = '\0';
- while (p && *p) {
- if (*p == ' ' || *p == '\t') {
- p++;
- continue;
- }
- if ((char *) &alias[2] > buf + bufsize) {
- errno = ERANGE;
- break;
- }
- *alias++ = p;
- p = strpbrk(p, " \t");
- if (p != NULL)
- *p++ = '\0';
- }
- *alias = NULL;
- pthread_mutex_unlock(&serv_file_lock);
- return result;
- }
-
- pthread_mutex_unlock(&serv_file_lock);
- return NULL;
-}
-
diff --git a/lib/libpthread/net/herror.c b/lib/libpthread/net/herror.c
deleted file mode 100644
index 70c3026dab2..00000000000
--- a/lib/libpthread/net/herror.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 1987 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)herror.c 6.6 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: herror.c,v 1.1 1998/07/21 13:19:45 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <string.h>
-#include <resolv.h>
-
-char *h_errlist[] = {
- "Error 0",
- "Unknown host", /* 1 HOST_NOT_FOUND */
- "Host name lookup failure", /* 2 TRY_AGAIN */
- "Unknown server error", /* 3 NO_RECOVERY */
- "No address associated with name", /* 4 NO_ADDRESS */
-};
-int h_nerr = { sizeof(h_errlist)/sizeof(h_errlist[0]) };
-
-/*
- * herror --
- * print the error indicated by the h_errno value.
- */
-void
-herror(s)
- const char *s;
-{
- struct iovec iov[4];
- register struct iovec *v = iov;
- int error = h_errno;
-
- if (s && *s) {
- v->iov_base = (char *)s;
- v->iov_len = strlen(s);
- v++;
- v->iov_base = ": ";
- v->iov_len = 2;
- v++;
- }
- v->iov_base = ((unsigned int)(error) < h_nerr) ?
- h_errlist[error] : "Unknown error";
- v->iov_len = strlen(v->iov_base);
- v++;
- v->iov_base = "\n";
- v->iov_len = 1;
- writev(STDERR_FILENO, iov, (v - iov) + 1);
-}
-
-char *
-hstrerror(err)
- int err;
-{
- return ((unsigned int)(err) < h_nerr) ? h_errlist[err]
- : "Unknown resolver error";
-}
-
diff --git a/lib/libpthread/net/inet_addr.c b/lib/libpthread/net/inet_addr.c
deleted file mode 100644
index 9da10ccbcc0..00000000000
--- a/lib/libpthread/net/inet_addr.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (c) 1983, 1990 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)inet_addr.c 5.10 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: inet_addr.c,v 1.1 1998/07/21 13:19:45 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/param.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <ctype.h>
-
-#ifndef INADDR_NONE
-#define INADDR_NONE 0xffffffff
-#endif
-/*
- * Ascii internet address interpretation routine.
- * The value returned is in network order.
- */
-pthread_ipaddr_type
-inet_addr(cp)
- register const char *cp;
-{
- struct in_addr val;
-
- if (inet_aton(cp, &val))
- return (val.s_addr);
- return (INADDR_NONE);
-}
-
-/*
- * Check whether "cp" is a valid ascii representation
- * of an Internet address and convert to a binary address.
- * Returns 1 if the address is valid, 0 if not.
- * This replaces inet_addr, the return value from which
- * cannot distinguish between failure and a local broadcast address.
- */
-
-inet_aton(cp, addr)
- const register char *cp;
- struct in_addr *addr;
-{
- pthread_ipaddr_type parts[4], *pp = parts;
- pthread_ipaddr_type val, base, n;
- register char c;
-
- for (;;) {
- /*
- * Collect number up to ``.''.
- * Values are specified as for C:
- * 0x=hex, 0=octal, other=decimal.
- */
- val = 0; base = 10;
- if (*cp == '0') {
- if (*++cp == 'x' || *cp == 'X')
- base = 16, cp++;
- else
- base = 8;
- }
- while ((c = *cp) != '\0') {
- if (isascii(c) && isdigit(c)) {
- val = (val * base) + (c - '0');
- cp++;
- continue;
- }
- if (base == 16 && isascii(c) && isxdigit(c)) {
- val = (val << 4) +
- (c + 10 - (islower(c) ? 'a' : 'A'));
- cp++;
- continue;
- }
- break;
- }
- if (*cp == '.') {
- /*
- * Internet format:
- * a.b.c.d
- * a.b.c (with c treated as 16-bits)
- * a.b (with b treated as 24 bits)
- */
- if (pp >= parts + 3 || val > 0xff)
- return (0);
- *pp++ = val, cp++;
- } else
- break;
- }
- /*
- * Check for trailing characters.
- */
- if (*cp && (!isascii(*cp) || !isspace(*cp)))
- return (0);
- /*
- * Concoct the address according to
- * the number of parts specified.
- */
- n = pp - parts + 1;
- switch (n) {
-
- case 1: /* a -- 32 bits */
- break;
-
- case 2: /* a.b -- 8.24 bits */
- if (val > 0xffffff)
- return (0);
- val |= parts[0] << 24;
- break;
-
- case 3: /* a.b.c -- 8.8.16 bits */
- if (val > 0xffff)
- return (0);
- val |= (parts[0] << 24) | (parts[1] << 16);
- break;
-
- case 4: /* a.b.c.d -- 8.8.8.8 bits */
- if (val > 0xff)
- return (0);
- val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
- break;
- }
- if (addr)
- addr->s_addr = htonl(val);
- return (1);
-}
-
diff --git a/lib/libpthread/net/inet_lnaof.c b/lib/libpthread/net/inet_lnaof.c
deleted file mode 100644
index 41c1d6d74ff..00000000000
--- a/lib/libpthread/net/inet_lnaof.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)inet_lnaof.c 5.7 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: inet_lnaof.c,v 1.1 1998/07/21 13:19:46 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/param.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-/*
- * Return the local network address portion of an
- * internet address; handles class a/b/c network
- * number formats.
- */
-pthread_ipaddr_type
-inet_lnaof(in)
- struct in_addr in;
-{
- register pthread_ipaddr_type i = ntohl(in.s_addr);
-
- if (IN_CLASSA(i))
- return ((i)&IN_CLASSA_HOST);
- else if (IN_CLASSB(i))
- return ((i)&IN_CLASSB_HOST);
- else
- return ((i)&IN_CLASSC_HOST);
-}
diff --git a/lib/libpthread/net/inet_makeaddr.c b/lib/libpthread/net/inet_makeaddr.c
deleted file mode 100644
index 0c1dcbbeed3..00000000000
--- a/lib/libpthread/net/inet_makeaddr.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)inet_makeaddr.c 5.6 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: inet_makeaddr.c,v 1.1 1998/07/21 13:19:46 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/param.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-/*
- * Formulate an Internet address from network + host. Used in
- * building addresses stored in the ifnet structure.
- */
-struct in_addr
-inet_makeaddr(net, host)
- pthread_ipaddr_type net, host;
-{
- pthread_ipaddr_type addr;
-
- if (net < 128)
- addr = (net << IN_CLASSA_NSHIFT) | (host & IN_CLASSA_HOST);
- else if (net < 65536)
- addr = (net << IN_CLASSB_NSHIFT) | (host & IN_CLASSB_HOST);
- else if (net < 16777216L)
- addr = (net << IN_CLASSC_NSHIFT) | (host & IN_CLASSC_HOST);
- else
- addr = net | host;
- addr = htonl(addr);
- return (*(struct in_addr *)&addr);
-}
diff --git a/lib/libpthread/net/inet_netof.c b/lib/libpthread/net/inet_netof.c
deleted file mode 100644
index a33185541b0..00000000000
--- a/lib/libpthread/net/inet_netof.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)inet_netof.c 5.7 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: inet_netof.c,v 1.1 1998/07/21 13:19:46 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/param.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-/*
- * Return the network number from an internet
- * address; handles class a/b/c network #'s.
- */
-pthread_ipaddr_type
-inet_netof(in)
- struct in_addr in;
-{
- register pthread_ipaddr_type i = ntohl(in.s_addr);
-
- if (IN_CLASSA(i))
- return (((i)&IN_CLASSA_NET) >> IN_CLASSA_NSHIFT);
- else if (IN_CLASSB(i))
- return (((i)&IN_CLASSB_NET) >> IN_CLASSB_NSHIFT);
- else
- return (((i)&IN_CLASSC_NET) >> IN_CLASSC_NSHIFT);
-}
diff --git a/lib/libpthread/net/inet_network.c b/lib/libpthread/net/inet_network.c
deleted file mode 100644
index 4f443c2535c..00000000000
--- a/lib/libpthread/net/inet_network.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)inet_network.c 5.8 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: inet_network.c,v 1.1 1998/07/21 13:19:46 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <ctype.h>
-
-#ifndef INADDR_NONE
-#define INADDR_NONE 0xffffffff
-#endif
-/*
- * Internet network address interpretation routine.
- * The library routines call this routine to interpret
- * network numbers.
- */
-pthread_ipaddr_type
-inet_network(cp)
- register const char *cp;
-{
- pthread_ipaddr_type parts[4], *pp = parts;
- pthread_ipaddr_type val, base, n;
- register char c;
- register int i;
-
-again:
- val = 0; base = 10;
- if (*cp == '0')
- base = 8, cp++;
- if (*cp == 'x' || *cp == 'X')
- base = 16, cp++;
- while (c = *cp) {
- if (isdigit(c)) {
- val = (val * base) + (c - '0');
- cp++;
- continue;
- }
- if (base == 16 && isxdigit(c)) {
- val = (val << 4) + (c + 10 - (islower(c) ? 'a' : 'A'));
- cp++;
- continue;
- }
- break;
- }
- if (*cp == '.') {
- if (pp >= parts + 4)
- return (INADDR_NONE);
- *pp++ = val, cp++;
- goto again;
- }
- if (*cp && !isspace(*cp))
- return (INADDR_NONE);
- *pp++ = val;
- n = pp - parts;
- if (n > 4)
- return (INADDR_NONE);
- for (val = 0, i = 0; i < n; i++) {
- val <<= 8;
- val |= parts[i] & 0xff;
- }
- return (val);
-}
diff --git a/lib/libpthread/net/inet_ntoa.c b/lib/libpthread/net/inet_ntoa.c
deleted file mode 100644
index d3c75e9da47..00000000000
--- a/lib/libpthread/net/inet_ntoa.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)inet_ntoa.c 5.6 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: inet_ntoa.c,v 1.1 1998/07/21 13:19:46 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-/*
- * Convert network-format internet address
- * to base 256 d.d.d.d representation.
- */
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-char *inet_ntoa(struct in_addr in)
-{
- static pthread_mutex_t inet_ntoa_mutex = PTHREAD_MUTEX_INITIALIZER;
- static pthread_key_t inet_ntoa_key = -1;
- char *buf, *inet_ntoa_r();
-
- if (inet_ntoa_key < 0) {
- pthread_mutex_lock(&inet_ntoa_mutex);
- if (inet_ntoa_key < 0) {
- if (pthread_key_create(&inet_ntoa_key, free) < 0) {
- pthread_mutex_unlock(&inet_ntoa_mutex);
- return(NULL);
- }
- }
- pthread_mutex_unlock(&inet_ntoa_mutex);
- }
- if ((buf = pthread_getspecific(inet_ntoa_key)) == NULL) {
- if ((buf = (char *) malloc(18)) == NULL) {
- return(NULL);
- }
- pthread_setspecific(inet_ntoa_key, buf);
- }
- return inet_ntoa_r(in, buf, 18);
-}
-
-char *inet_ntoa_r(struct in_addr in, char *buf, int bufsize)
-{
- register char *p;
-
- p = (char *)&in;
-#define UC(b) (((int)b)&0xff)
- (void)snprintf(buf, bufsize,
- "%d.%d.%d.%d", UC(p[0]), UC(p[1]), UC(p[2]), UC(p[3]));
- return (buf);
-}
-
diff --git a/lib/libpthread/net/net_internal.c b/lib/libpthread/net/net_internal.c
deleted file mode 100644
index f3638fad42d..00000000000
--- a/lib/libpthread/net/net_internal.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 1985 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)net_internal.c 6.22 (Berkeley) 3/19/91";*/
-static char *rcsid = "$Id: net_internal.c,v 1.1 1998/07/21 13:19:46 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "net_internal.h"
-
-static void _net_init_global(void);
-
-pthread_mutex_t net_iterate_lock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_once_t init_once = PTHREAD_ONCE_INIT;
-static pthread_key_t key;
-static int init_status;
-
-/* Performs global initialization. */
-char *_net_buf()
-{
- char *buf;
-
- /* Make sure the global initializations have been done. */
- pthread_once(&init_once, _net_init_global);
-
- /* Initialize thread-specific data for this thread if it hasn't
- * been done already. */
- buf = (char *) pthread_getspecific(key);
- if (!buf) {
- buf = (char *) malloc(NET_BUFSIZE);
- if (buf == NULL)
- return NULL;
- if (pthread_setspecific(key, buf) < 0) {
- free(buf);
- return NULL;
- }
- }
- return buf;
-}
-
-static void _net_init_global()
-{
- init_status = pthread_key_create(&key, free);
-}
-
diff --git a/lib/libpthread/net/net_internal.h b/lib/libpthread/net/net_internal.h
deleted file mode 100644
index d4a7fc9f216..00000000000
--- a/lib/libpthread/net/net_internal.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 1985 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)net_internal.h 6.22 (Berkeley) 3/19/91";*/
-static char *rcsid = "$Id: net_internal.h,v 1.1 1998/07/21 13:19:46 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#ifndef _NET_INTERNAL_H
-#define _NET_INTERNAL_H
-
-#include <pthread.h>
-#include <netdb.h>
-#include <resolv.h>
-
-#define NET_BUFSIZE 4096
-#define ALIGN(p, t) ((char *)(((((long)(p) - 1) / sizeof(t)) + 1) * sizeof(t)))
-#define SP(p, t, n) (ALIGN(p, t) + (n) * sizeof(t))
-
-extern pthread_mutex_t net_iterate_lock;
-
-__BEGIN_DECLS
-char *_net_buf(void);
-__END_DECLS
-
-#endif
-
diff --git a/lib/libpthread/net/proto_internal.c b/lib/libpthread/net/proto_internal.c
deleted file mode 100644
index f25dc4ff6af..00000000000
--- a/lib/libpthread/net/proto_internal.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 1985 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)proto_internal.c 6.22 (Berkeley) 3/19/91";*/
-static char *rcsid = "$Id: proto_internal.c,v 1.1 1998/07/21 13:19:46 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "proto_internal.h"
-
-static void _proto_init_global(void);
-
-pthread_mutex_t proto_iterate_lock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_once_t init_once = PTHREAD_ONCE_INIT;
-static pthread_key_t key;
-static int init_status;
-
-/* Performs global initialization. */
-char *_proto_buf()
-{
- char *buf;
-
- /* Make sure the global initializations have been done. */
- pthread_once(&init_once, _proto_init_global);
-
- /* Initialize thread-specific data for this thread if it hasn't
- * been done already. */
- buf = (char *) pthread_getspecific(key);
- if (!buf) {
- buf = (char *) malloc(PROTO_BUFSIZE);
- if (buf == NULL)
- return NULL;
- if (pthread_setspecific(key, buf) < 0) {
- free(buf);
- return NULL;
- }
- }
- return buf;
-}
-
-static void _proto_init_global()
-{
- init_status = pthread_key_create(&key, free);
-}
-
diff --git a/lib/libpthread/net/proto_internal.h b/lib/libpthread/net/proto_internal.h
deleted file mode 100644
index 916680d533d..00000000000
--- a/lib/libpthread/net/proto_internal.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 1985 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)proto_internal.h 6.22 (Berkeley) 3/19/91";*/
-static char *rcsid = "$Id: proto_internal.h,v 1.1 1998/07/21 13:19:46 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#ifndef _PROTO_INTERNAL_H
-#define _PROTO_INTERNAL_H
-
-#include <pthread.h>
-#include <netdb.h>
-#include <resolv.h>
-
-#define PROTO_BUFSIZE 4096
-#define ALIGN(p, t) ((char *)(((((long)(p) - 1) / sizeof(t)) + 1) * sizeof(t)))
-#define SP(p, t, n) (ALIGN(p, t) + (n) * sizeof(t))
-
-extern pthread_mutex_t proto_iterate_lock;
-
-__BEGIN_DECLS
-char *_proto_buf(void);
-__END_DECLS
-
-#endif
-
diff --git a/lib/libpthread/net/res_comp.c b/lib/libpthread/net/res_comp.c
deleted file mode 100644
index 20cb49131c7..00000000000
--- a/lib/libpthread/net/res_comp.c
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * Copyright (c) 1985 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)res_comp.c 6.22 (Berkeley) 3/19/91";*/
-static char *rcsid = "$Id: res_comp.c,v 1.1 1998/07/21 13:19:46 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/param.h>
-#include <sys/cdefs.h>
-#include <netinet/in.h>
-#include <resolv.h>
-#include <stdio.h>
-
-static dn_find();
-
-/*
- * Expand compressed domain name 'comp_dn' to full domain name.
- * 'msg' is a pointer to the begining of the message,
- * 'eomorig' points to the first location after the message,
- * 'exp_dn' is a pointer to a buffer of size 'length' for the result.
- * Return size of compressed name or -1 if there was an error.
- */
-dn_expand(msg, eomorig, comp_dn, exp_dn, length)
- const u_char *msg, *eomorig, *comp_dn;
- u_char *exp_dn;
- int length;
-{
- register u_char *cp, *dn;
- register int n, c;
- u_char *eom;
- int len = -1, checked = 0;
-
- dn = exp_dn;
- cp = (u_char *)comp_dn;
- eom = exp_dn + length;
- /*
- * fetch next label in domain name
- */
- while (n = *cp++) {
- /*
- * Check for indirection
- */
- switch (n & INDIR_MASK) {
- case 0:
- if (dn != exp_dn) {
- if (dn >= eom)
- return (-1);
- *dn++ = '.';
- }
- if (dn+n >= eom)
- return (-1);
- checked += n + 1;
- while (--n >= 0) {
- if ((c = *cp++) == '.') {
- if (dn + n + 2 >= eom)
- return (-1);
- *dn++ = '\\';
- }
- *dn++ = c;
- if (cp >= eomorig) /* out of range */
- return(-1);
- }
- break;
-
- case INDIR_MASK:
- if (len < 0)
- len = cp - comp_dn + 1;
- cp = (u_char *)msg + (((n & 0x3f) << 8) | (*cp & 0xff));
- if (cp < msg || cp >= eomorig) /* out of range */
- return(-1);
- checked += 2;
- /*
- * Check for loops in the compressed name;
- * if we've looked at the whole message,
- * there must be a loop.
- */
- if (checked >= eomorig - msg)
- return (-1);
- break;
-
- default:
- return (-1); /* flag error */
- }
- }
- *dn = '\0';
- if (len < 0)
- len = cp - comp_dn;
- return (len);
-}
-
-/*
- * Compress domain name 'exp_dn' into 'comp_dn'.
- * Return the size of the compressed name or -1.
- * 'length' is the size of the array pointed to by 'comp_dn'.
- * 'dnptrs' is a list of pointers to previous compressed names. dnptrs[0]
- * is a pointer to the beginning of the message. The list ends with NULL.
- * 'lastdnptr' is a pointer to the end of the arrary pointed to
- * by 'dnptrs'. Side effect is to update the list of pointers for
- * labels inserted into the message as we compress the name.
- * If 'dnptr' is NULL, we don't try to compress names. If 'lastdnptr'
- * is NULL, we don't update the list.
- */
-dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr)
- const u_char *exp_dn;
- u_char *comp_dn, **dnptrs, **lastdnptr;
- int length;
-{
- register u_char *cp, *dn;
- register int c, l;
- u_char **cpp, **lpp, *sp, *eob;
- u_char *msg;
-
- dn = (u_char *)exp_dn;
- cp = comp_dn;
- eob = cp + length;
- if (dnptrs != NULL) {
- if ((msg = *dnptrs++) != NULL) {
- for (cpp = dnptrs; *cpp != NULL; cpp++)
- ;
- lpp = cpp; /* end of list to search */
- }
- } else
- msg = NULL;
- for (c = *dn++; c != '\0'; ) {
- /* look to see if we can use pointers */
- if (msg != NULL) {
- if ((l = dn_find(dn-1, msg, dnptrs, lpp)) >= 0) {
- if (cp+1 >= eob)
- return (-1);
- *cp++ = (l >> 8) | INDIR_MASK;
- *cp++ = l % 256;
- return (cp - comp_dn);
- }
- /* not found, save it */
- if (lastdnptr != NULL && cpp < lastdnptr-1) {
- *cpp++ = cp;
- *cpp = NULL;
- }
- }
- sp = cp++; /* save ptr to length byte */
- do {
- if (c == '.') {
- c = *dn++;
- break;
- }
- if (c == '\\') {
- if ((c = *dn++) == '\0')
- break;
- }
- if (cp >= eob) {
- if (msg != NULL)
- *lpp = NULL;
- return (-1);
- }
- *cp++ = c;
- } while ((c = *dn++) != '\0');
- /* catch trailing '.'s but not '..' */
- if ((l = cp - sp - 1) == 0 && c == '\0') {
- cp--;
- break;
- }
- if (l <= 0 || l > MAXLABEL) {
- if (msg != NULL)
- *lpp = NULL;
- return (-1);
- }
- *sp = l;
- }
- if (cp >= eob) {
- if (msg != NULL)
- *lpp = NULL;
- return (-1);
- }
- *cp++ = '\0';
- return (cp - comp_dn);
-}
-
-/*
- * Skip over a compressed domain name. Return the size or -1.
- */
-__dn_skipname(comp_dn, eom)
- const u_char *comp_dn, *eom;
-{
- register u_char *cp;
- register int n;
-
- cp = (u_char *)comp_dn;
- while (cp < eom && (n = *cp++)) {
- /*
- * check for indirection
- */
- switch (n & INDIR_MASK) {
- case 0: /* normal case, n == len */
- cp += n;
- continue;
- case INDIR_MASK: /* indirection */
- cp++;
- break;
- default: /* illegal type */
- return (-1);
- }
- break;
- }
- if (cp > eom)
- return -1;
- return (cp - comp_dn);
-}
-
-/*
- * Search for expanded name from a list of previously compressed names.
- * Return the offset from msg if found or -1.
- * dnptrs is the pointer to the first name on the list,
- * not the pointer to the start of the message.
- */
-static int
-dn_find(exp_dn, msg, dnptrs, lastdnptr)
- u_char *exp_dn, *msg;
- u_char **dnptrs, **lastdnptr;
-{
- register u_char *dn, *cp, **cpp;
- register int n;
- u_char *sp;
-
- for (cpp = dnptrs; cpp < lastdnptr; cpp++) {
- dn = exp_dn;
- sp = cp = *cpp;
- while (n = *cp++) {
- /*
- * check for indirection
- */
- switch (n & INDIR_MASK) {
- case 0: /* normal case, n == len */
- while (--n >= 0) {
- if (*dn == '.')
- goto next;
- if (*dn == '\\')
- dn++;
- if (*dn++ != *cp++)
- goto next;
- }
- if ((n = *dn++) == '\0' && *cp == '\0')
- return (sp - msg);
- if (n == '.')
- continue;
- goto next;
-
- default: /* illegal type */
- return (-1);
-
- case INDIR_MASK: /* indirection */
- cp = msg + (((n & 0x3f) << 8) | *cp);
- }
- }
- if (*dn == '\0')
- return (sp - msg);
- next: ;
- }
- return (-1);
-}
-
-/*
- * Routines to insert/extract short/long's. Must account for byte
- * order and non-alignment problems. This code at least has the
- * advantage of being portable.
- *
- * used by sendmail.
- */
-
-u_short
-_getshort(msgp)
- register const u_char *msgp;
-{
- register u_short u;
-
- GETSHORT(u, msgp);
- return (u);
-}
-
-pthread_ipaddr_type
-_getlong(msgp)
- const u_char *msgp;
-{
- pthread_ipaddr_type u;
-
- GETLONG(u, msgp);
- return (u);
-}
-
-void
-#ifdef __STDC__
-__putshort(register u_short s, register u_char *msgp)
-#else
- __putshort(s, msgp)
- register u_short s;
- register u_char *msgp;
-#endif
-{
- PUTSHORT(s, msgp);
-}
-
-void
-__putlong(l, msgp)
- register pthread_ipaddr_type l;
- register u_char *msgp;
-{
- PUTLONG(l, msgp);
-}
-
diff --git a/lib/libpthread/net/res_debug.c b/lib/libpthread/net/res_debug.c
deleted file mode 100644
index 329b9478c87..00000000000
--- a/lib/libpthread/net/res_debug.c
+++ /dev/null
@@ -1,749 +0,0 @@
-/*
- * Copyright (c) 1985, 1990, 1993
- * The Regents of the University of California. 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * Portions Copyright (c) 1993 by Digital Equipment Corporation.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies, and that
- * the name of Digital Equipment Corporation not be used in advertising or
- * publicity pertaining to distribution of the document or software without
- * specific, written prior permission.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
- * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$Id: res_debug.c,v 1.1 1998/07/21 13:19:46 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/param.h>
-#include <stdio.h>
-#include <string.h>
-#include <resolv.h>
-#include <arpa/inet.h>
-
-void __fp_query();
-char *__p_class(), *__p_time(), *__p_type();
-char *p_cdname(), *p_fqname(), *p_rr();
-static char *p_option __P_((u_long));
-
-char *_res_opcodes[] = {
- "QUERY",
- "IQUERY",
- "CQUERYM",
- "CQUERYU",
- "4",
- "5",
- "6",
- "7",
- "8",
- "UPDATEA",
- "UPDATED",
- "UPDATEDA",
- "UPDATEM",
- "UPDATEMA",
- "ZONEINIT",
- "ZONEREF",
-};
-
-char *_res_resultcodes[] = {
- "NOERROR",
- "FORMERR",
- "SERVFAIL",
- "NXDOMAIN",
- "NOTIMP",
- "REFUSED",
- "6",
- "7",
- "8",
- "9",
- "10",
- "11",
- "12",
- "13",
- "14",
- "NOCHANGE",
-};
-
-static char retbuf[16];
-
-static char *
-dewks(wks)
- int wks;
-{
- switch (wks) {
- case 5: return("rje");
- case 7: return("echo");
- case 9: return("discard");
- case 11: return("systat");
- case 13: return("daytime");
- case 15: return("netstat");
- case 17: return("qotd");
- case 19: return("chargen");
- case 20: return("ftp-data");
- case 21: return("ftp");
- case 23: return("telnet");
- case 25: return("smtp");
- case 37: return("time");
- case 39: return("rlp");
- case 42: return("name");
- case 43: return("whois");
- case 53: return("domain");
- case 57: return("apts");
- case 59: return("apfs");
- case 67: return("bootps");
- case 68: return("bootpc");
- case 69: return("tftp");
- case 77: return("rje");
- case 79: return("finger");
- case 87: return("link");
- case 95: return("supdup");
- case 100: return("newacct");
- case 101: return("hostnames");
- case 102: return("iso-tsap");
- case 103: return("x400");
- case 104: return("x400-snd");
- case 105: return("csnet-ns");
- case 109: return("pop-2");
- case 111: return("sunrpc");
- case 113: return("auth");
- case 115: return("sftp");
- case 117: return("uucp-path");
- case 119: return("nntp");
- case 121: return("erpc");
- case 123: return("ntp");
- case 133: return("statsrv");
- case 136: return("profile");
- case 144: return("NeWS");
- case 161: return("snmp");
- case 162: return("snmp-trap");
- case 170: return("print-srv");
- default: (void) sprintf(retbuf, "%d", wks); return(retbuf);
- }
-}
-
-static char *
-deproto(protonum)
- int protonum;
-{
- switch (protonum) {
- case 1: return("icmp");
- case 2: return("igmp");
- case 3: return("ggp");
- case 5: return("st");
- case 6: return("tcp");
- case 7: return("ucl");
- case 8: return("egp");
- case 9: return("igp");
- case 11: return("nvp-II");
- case 12: return("pup");
- case 16: return("chaos");
- case 17: return("udp");
- default: (void) sprintf(retbuf, "%d", protonum); return(retbuf);
- }
-}
-
-static char *
-do_rrset(msg, cp, cnt, pflag, file, hs)
- int cnt, pflag;
- char *cp,*msg, *hs;
- FILE *file;
-{
- int n;
- int sflag;
- /*
- * Print answer records
- */
- sflag = (_res.pfcode & pflag);
- if (n = ntohs(cnt)) {
- if ((!_res.pfcode) || ((sflag) && (_res.pfcode & RES_PRF_HEAD1)))
- fprintf(file, hs);
- while (--n >= 0) {
- cp = p_rr(cp, msg, file);
- if ((cp-msg) > PACKETSZ)
- return (NULL);
- }
- if ((!_res.pfcode) || ((sflag) && (_res.pfcode & RES_PRF_HEAD1)))
- putc('\n', file);
- }
- return(cp);
-}
-
-__p_query(msg)
- char *msg;
-{
- __fp_query(msg, stdout);
-}
-
-/*
- * Print the current options.
- * This is intended to be primarily a debugging routine.
- */
-void
-__fp_resstat(statp, file)
- struct __res_state *statp;
- FILE *file;
-{
- int bit;
-
- fprintf(file, ";; res options:");
- if (!statp)
- statp = &_res;
- for (bit = 0; bit < 32; bit++) { /* XXX 32 - bad assumption! */
- if (statp->options & (1<<bit))
- fprintf(file, " %s", p_option(1<<bit));
- }
- putc('\n', file);
-}
-
-/*
- * Print the contents of a query.
- * This is intended to be primarily a debugging routine.
- */
-void
-__fp_query(msg,file)
- char *msg;
- FILE *file;
-{
- register char *cp;
- register HEADER *hp;
- register int n;
-
- /*
- * Print header fields.
- */
- hp = (HEADER *)msg;
- cp = msg + sizeof(HEADER);
- if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEADX) || hp->rcode) {
- fprintf(file,";; ->>HEADER<<- opcode: %s, status: %s, id: %d",
- _res_opcodes[hp->opcode],
- _res_resultcodes[hp->rcode],
- ntohs(hp->id));
- putc('\n', file);
- }
- putc(';', file);
- if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEAD2)) {
- fprintf(file,"; flags:");
- if (hp->qr)
- fprintf(file," qr");
- if (hp->aa)
- fprintf(file," aa");
- if (hp->tc)
- fprintf(file," tc");
- if (hp->rd)
- fprintf(file," rd");
- if (hp->ra)
- fprintf(file," ra");
- if (hp->pr)
- fprintf(file," pr");
- }
- if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEAD1)) {
- fprintf(file,"; Ques: %d", ntohs(hp->qdcount));
- fprintf(file,", Ans: %d", ntohs(hp->ancount));
- fprintf(file,", Auth: %d", ntohs(hp->nscount));
- fprintf(file,", Addit: %d", ntohs(hp->arcount));
- }
-#if 1
- if ((!_res.pfcode) || (_res.pfcode &
- (RES_PRF_HEADX | RES_PRF_HEAD2 | RES_PRF_HEAD1))) {
- putc('\n',file);
- }
-#endif
- /*
- * Print question records.
- */
- if (n = ntohs(hp->qdcount)) {
- if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
- fprintf(file,";; QUESTIONS:\n");
- while (--n >= 0) {
- fprintf(file,";;\t");
- cp = p_cdname(cp, msg, file);
- if (cp == NULL)
- return;
- if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
- fprintf(file, ", type = %s",
- __p_type(_getshort(cp)));
- cp += sizeof(u_short);
- if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
- fprintf(file, ", class = %s\n",
- __p_class(_getshort(cp)));
- cp += sizeof(u_short);
- putc('\n', file);
- }
- }
- /*
- * Print authoritative answer records
- */
- cp = do_rrset(msg, cp, hp->ancount, RES_PRF_ANS, file,
- ";; ANSWERS:\n");
- if (cp == NULL)
- return;
-
- /*
- * print name server records
- */
- cp = do_rrset(msg, cp, hp->nscount, RES_PRF_AUTH, file,
- ";; AUTHORITY RECORDS:\n");
- if (!cp)
- return;
-
- /*
- * print additional records
- */
- cp = do_rrset(msg, cp, hp->arcount, RES_PRF_ADD, file,
- ";; ADDITIONAL RECORDS:\n");
- if (!cp)
- return;
-}
-
-char *
-p_cdname(cp, msg, file)
- char *cp, *msg;
- FILE *file;
-{
- char name[MAXDNAME];
- int n;
-
- if ((n = dn_expand((u_char *)msg, (u_char *)cp + MAXCDNAME,
- (u_char *)cp, (u_char *)name, sizeof(name))) < 0)
- return (NULL);
- if (name[0] == '\0')
- putc('.', file);
- else
- fputs(name, file);
- return (cp + n);
-}
-
-char *
-p_fqname(cp, msg, file)
- char *cp, *msg;
- FILE *file;
-{
- char name[MAXDNAME];
- int n, len;
-
- if ((n = dn_expand((u_char *)msg, (u_char *)cp + MAXCDNAME,
- (u_char *)cp, (u_char *)name, sizeof(name))) < 0)
- return (NULL);
- if (name[0] == '\0') {
- putc('.', file);
- } else {
- fputs(name, file);
- if (name[strlen(name) - 1] != '.')
- putc('.', file);
- }
- return (cp + n);
-}
-
-/*
- * Print resource record fields in human readable form.
- *
- * Removed calls to non-reentrant routines to simplify varifying
- * POSIX thread-safe implementations. (mevans).
- */
-char *
-p_rr(cp, msg, file)
- char *cp, *msg;
- FILE *file;
-{
- int type, class, dlen, n, c;
- struct in_addr inaddr;
- char *cp1, *cp2;
- u_long tmpttl, t;
- int lcnt;
- char buf[32];
-
- if ((cp = p_fqname(cp, msg, file)) == NULL)
- return (NULL); /* compression error */
- type = _getshort(cp);
- cp += sizeof(u_short);
- class = _getshort(cp);
- cp += sizeof(u_short);
- tmpttl = _getlong(cp);
- cp += sizeof(u_long);
- dlen = _getshort(cp);
- cp += sizeof(u_short);
- cp1 = cp;
- if ((!_res.pfcode) || (_res.pfcode & RES_PRF_TTLID))
- fprintf(file, "\t%lu", tmpttl);
- if ((!_res.pfcode) || (_res.pfcode & RES_PRF_CLASS))
- fprintf(file, "\t%s", __p_class(class));
- fprintf(file, "\t%s", __p_type(type));
- /*
- * Print type specific data, if appropriate
- */
- switch (type) {
- case T_A:
- switch (class) {
- case C_IN:
- case C_HS:
- bcopy(cp, (char *)&inaddr, sizeof(inaddr));
- if (dlen == 4) {
- fprintf(file,"\t%s",
- inet_ntoa_r(inaddr, buf, sizeof(buf)));
- cp += dlen;
- } else if (dlen == 7) {
- char *address;
- u_char protocol;
- u_short port;
-
- address = inet_ntoa_r(inaddr,
- buf, sizeof(buf));
- cp += sizeof(inaddr);
- protocol = *(u_char*)cp;
- cp += sizeof(u_char);
- port = _getshort(cp);
- cp += sizeof(u_short);
- fprintf(file, "\t%s\t; proto %d, port %d",
- address, protocol, port);
- }
- break;
- default:
- cp += dlen;
- }
- break;
- case T_CNAME:
- case T_MB:
- case T_MG:
- case T_MR:
- case T_NS:
- case T_PTR:
- putc('\t', file);
- cp = p_fqname(cp, msg, file);
- break;
-
- case T_HINFO:
- if (n = *cp++) {
- fprintf(file,"\t%.*s", n, cp);
- cp += n;
- }
- if (n = *cp++) {
- fprintf(file,"\t%.*s", n, cp);
- cp += n;
- }
- break;
-
- case T_SOA:
- putc('\t', file);
- cp = p_fqname(cp, msg, file); /* origin */
- putc(' ', file);
- cp = p_fqname(cp, msg, file); /* mail addr */
- fputs(" (\n", file);
- t = _getlong(cp); cp += sizeof(u_long);
- fprintf(file,"\t\t\t%lu\t; serial\n", t);
- t = _getlong(cp); cp += sizeof(u_long);
- fprintf(file,"\t\t\t%lu\t; refresh (%s)\n", t, __p_time(t));
- t = _getlong(cp); cp += sizeof(u_long);
- fprintf(file,"\t\t\t%lu\t; retry (%s)\n", t, __p_time(t));
- t = _getlong(cp); cp += sizeof(u_long);
- fprintf(file,"\t\t\t%lu\t; expire (%s)\n", t, __p_time(t));
- t = _getlong(cp); cp += sizeof(u_long);
- fprintf(file,"\t\t\t%lu )\t; minimum (%s)", t, __p_time(t));
- break;
-
- case T_MX:
- case T_AFSDB:
- fprintf(file,"\t%d ", _getshort(cp));
- cp += sizeof(u_short);
- cp = p_fqname(cp, msg, file);
- break;
-
- case T_TXT:
- (void) fputs("\t\"", file);
- cp2 = cp1 + dlen;
- while (cp < cp2) {
- if (n = (unsigned char) *cp++) {
- for (c = n; c > 0 && cp < cp2; c--)
- if (*cp == '\n') {
- (void) putc('\\', file);
- (void) putc(*cp++, file);
- } else
- (void) putc(*cp++, file);
- }
- }
- putc('"', file);
- break;
-
- case T_MINFO:
- case T_RP:
- putc('\t', file);
- cp = p_fqname(cp, msg, file);
- putc(' ', file);
- cp = p_fqname(cp, msg, file);
- break;
-
- case T_UINFO:
- putc('\t', file);
- fputs(cp, file);
- cp += dlen;
- break;
-
- case T_UID:
- case T_GID:
- if (dlen == 4) {
- fprintf(file,"\t%u", _getlong(cp));
- cp += sizeof(long);
- }
- break;
-
- case T_WKS:
- if (dlen < sizeof(u_long) + 1)
- break;
- bcopy(cp, (char *)&inaddr, sizeof(inaddr));
- cp += sizeof(u_long);
- fprintf(file, "\t%s %s ( ",
- inet_ntoa_r(inaddr, buf, sizeof(buf)),
- deproto((int) *cp));
- cp += sizeof(u_char);
- n = 0;
- lcnt = 0;
- while (cp < cp1 + dlen) {
- c = *cp++;
- do {
- if (c & 0200) {
- if (lcnt == 0) {
- fputs("\n\t\t\t", file);
- lcnt = 5;
- }
- fputs(dewks(n), file);
- putc(' ', file);
- lcnt--;
- }
- c <<= 1;
- } while (++n & 07);
- }
- putc(')', file);
- break;
-
-#ifdef ALLOW_T_UNSPEC
- case T_UNSPEC:
- {
- int NumBytes = 8;
- char *DataPtr;
- int i;
-
- if (dlen < NumBytes) NumBytes = dlen;
- fprintf(file, "\tFirst %d bytes of hex data:",
- NumBytes);
- for (i = 0, DataPtr = cp; i < NumBytes; i++, DataPtr++)
- fprintf(file, " %x", *DataPtr);
- cp += dlen;
- }
- break;
-#endif /* ALLOW_T_UNSPEC */
-
- default:
- fprintf(file,"\t?%d?", type);
- cp += dlen;
- }
-#if 0
- fprintf(file, "\t; dlen=%d, ttl %s\n", dlen, __p_time(tmpttl));
-#else
- putc('\n', file);
-#endif
- if (cp - cp1 != dlen) {
- fprintf(file,";; packet size error (found %d, dlen was %d)\n",
- cp - cp1, dlen);
- cp = NULL;
- }
- return (cp);
-}
-
-static char nbuf[40];
-
-/*
- * Return a string for the type
- */
-char *
-__p_type(type)
- int type;
-{
- switch (type) {
- case T_A:
- return("A");
- case T_NS: /* authoritative server */
- return("NS");
- case T_CNAME: /* canonical name */
- return("CNAME");
- case T_SOA: /* start of authority zone */
- return("SOA");
- case T_MB: /* mailbox domain name */
- return("MB");
- case T_MG: /* mail group member */
- return("MG");
- case T_MR: /* mail rename name */
- return("MR");
- case T_NULL: /* null resource record */
- return("NULL");
- case T_WKS: /* well known service */
- return("WKS");
- case T_PTR: /* domain name pointer */
- return("PTR");
- case T_HINFO: /* host information */
- return("HINFO");
- case T_MINFO: /* mailbox information */
- return("MINFO");
- case T_MX: /* mail routing info */
- return("MX");
- case T_TXT: /* text */
- return("TXT");
- case T_RP: /* responsible person */
- return("RP");
- case T_AFSDB: /* AFS cell database */
- return("AFSDB");
- case T_AXFR: /* zone transfer */
- return("AXFR");
- case T_MAILB: /* mail box */
- return("MAILB");
- case T_MAILA: /* mail address */
- return("MAILA");
- case T_ANY: /* matches any type */
- return("ANY");
- case T_UINFO:
- return("UINFO");
- case T_UID:
- return("UID");
- case T_GID:
- return("GID");
-#ifdef ALLOW_T_UNSPEC
- case T_UNSPEC:
- return("UNSPEC");
-#endif /* ALLOW_T_UNSPEC */
-
- default:
- (void)sprintf(nbuf, "%d", type);
- return(nbuf);
- }
-}
-
-/*
- * Return a mnemonic for class
- */
-char *
-__p_class(class)
- int class;
-{
-
- switch (class) {
- case C_IN: /* internet class */
- return("IN");
- case C_HS: /* hesiod class */
- return("HS");
- case C_ANY: /* matches any class */
- return("ANY");
- default:
- (void)sprintf(nbuf, "%d", class);
- return(nbuf);
- }
-}
-
-/*
- * Return a mnemonic for an option
- */
-static char *
-p_option(option)
- u_long option;
-{
- switch (option) {
- case RES_INIT: return "init";
- case RES_DEBUG: return "debug";
- case RES_AAONLY: return "aaonly";
- case RES_USEVC: return "usevc";
- case RES_PRIMARY: return "primry";
- case RES_IGNTC: return "igntc";
- case RES_RECURSE: return "recurs";
- case RES_DEFNAMES: return "defnam";
- case RES_STAYOPEN: return "styopn";
- case RES_DNSRCH: return "dnsrch";
- default: sprintf(nbuf, "?0x%x?", option); return nbuf;
- }
-}
-
-/*
- * Return a mnemonic for a time to live
- */
-char *
-__p_time(value)
- u_long value;
-{
- int secs, mins, hours, days;
- register char *p;
-
- if (value == 0) {
- strcpy(nbuf, "0 secs");
- return(nbuf);
- }
-
- secs = value % 60;
- value /= 60;
- mins = value % 60;
- value /= 60;
- hours = value % 24;
- value /= 24;
- days = value;
- value = 0;
-
-#define PLURALIZE(x) x, (x == 1) ? "" : "s"
- p = nbuf;
- if (days) {
- (void)sprintf(p, "%d day%s", PLURALIZE(days));
- while (*++p);
- }
- if (hours) {
- if (days)
- *p++ = ' ';
- (void)sprintf(p, "%d hour%s", PLURALIZE(hours));
- while (*++p);
- }
- if (mins) {
- if (days || hours)
- *p++ = ' ';
- (void)sprintf(p, "%d min%s", PLURALIZE(mins));
- while (*++p);
- }
- if (secs || ! (days || hours || mins)) {
- if (days || hours || mins)
- *p++ = ' ';
- (void)sprintf(p, "%d sec%s", PLURALIZE(secs));
- }
- return(nbuf);
-}
diff --git a/lib/libpthread/net/res_init.c b/lib/libpthread/net/res_init.c
deleted file mode 100644
index 73532a9144b..00000000000
--- a/lib/libpthread/net/res_init.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 1985 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)res_init.c 6.22 (Berkeley) 3/19/91";*/
-static char *rcsid = "$Id: res_init.c,v 1.1 1998/07/21 13:19:47 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <resolv.h>
-#include <netdb.h>
-#include "res_internal.h"
-
-int res_init()
-{
- if (_res_init()) {
- return 0;
- } else {
- /* Due to clever tricks in _res_init(), a check for h_errno will
- * return NO_RECOVERY even if the next try at initialization
- * succeeds, so it's okay that we can't set an error value here. */
- return -1;
- }
-}
-
diff --git a/lib/libpthread/net/res_internal.c b/lib/libpthread/net/res_internal.c
deleted file mode 100644
index 6f51aec1aa0..00000000000
--- a/lib/libpthread/net/res_internal.c
+++ /dev/null
@@ -1,576 +0,0 @@
-/*
- * Copyright (c) 1985 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)res_internal.c 6.22 (Berkeley) 3/19/91";*/
-static char *rcsid = "$Id: res_internal.c,v 1.1 1998/07/21 13:19:47 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <resolv.h>
-#include <netdb.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <string.h>
-#include <errno.h>
-#include "res_internal.h"
-
-#define DEFAULT_RETRIES 4
-
-pthread_mutex_t host_iterate_lock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_once_t init_once = PTHREAD_ONCE_INIT;
-static pthread_key_t key;
-static int init_status;
-
-static void _res_init_global(void);
-static void set_options(const char *options, const char *source);
-static pthread_ipaddr_type net_mask(struct in_addr in);
-static int qcomp(const void *arg1, const void *arg2);
-
-static struct __res_state start;
-/* We want to define _res for partial binary compatibility with libraries. */
-#undef _res
-struct __res_state _res = {
- RES_TIMEOUT, /* retransmition time interval */
- 4, /* number of times to retransmit */
- RES_DEFAULT, /* options flags */
- 1, /* number of name servers */
-};
-
-struct hostent *_res_parse_answer(querybuf *answer, int anslen, int iquery,
- struct hostent *result, char *buf,
- int bufsize, int *errval)
-{
- struct res_data *data = _res_init();
- register HEADER *hp;
- register u_char *cp;
- register int n;
- u_char *eom;
- char *aliases[__NETDB_MAXALIASES], *addrs[__NETDB_MAXADDRS];
- char *bp = buf, **ap = aliases, **hap = addrs;
- int type, class, ancount, qdcount, getclass = C_ANY, iquery_done = 0;
-
- eom = answer->buf + anslen;
- /*
- * find first satisfactory answer
- */
- hp = &answer->hdr;
- ancount = ntohs(hp->ancount);
- qdcount = ntohs(hp->qdcount);
- bp = buf;
- cp = answer->buf + sizeof(HEADER);
-
- /* Read in the hostname if this is an address lookup. */
- if (qdcount) {
- if (iquery) {
- if ((n = dn_expand((u_char *) answer->buf,
- (u_char *) eom, (u_char *) cp, (u_char *) bp,
- bufsize - (bp - buf))) < 0) {
- *errval = NO_RECOVERY;
- return ((struct hostent *) NULL);
- }
- cp += n + QFIXEDSZ;
- result->h_name = bp;
- bp += strlen(bp) + 1;
- } else {
- cp += __dn_skipname(cp, eom) + QFIXEDSZ;
- }
- while (--qdcount > 0)
- cp += __dn_skipname(cp, eom) + QFIXEDSZ;
- } else if (iquery) {
- *errval = (hp->aa) ? HOST_NOT_FOUND : TRY_AGAIN;
- return ((struct hostent *) NULL);
- }
-
- /* Read in the answers. */
- *ap = NULL;
- *hap = NULL;
- while (--ancount >= 0 && cp < eom) {
- if ((n = dn_expand((u_char *) answer->buf, (u_char *) eom,
- (u_char *) cp, (u_char *) bp,
- bufsize - (bp - buf))) < 0)
- break;
- cp += n;
- type = _getshort(cp);
- cp += sizeof(u_short);
- class = _getshort(cp);
- cp += sizeof(u_short) + sizeof(pthread_ipaddr_type);
- n = _getshort(cp);
- cp += sizeof(u_short);
- if (type == T_CNAME) {
- cp += n;
- if (ap >= aliases + __NETDB_MAXALIASES - 1)
- continue;
- *ap++ = bp;
- bp += strlen(bp) + 1;
- continue;
- }
- if (iquery && type == T_PTR) {
- if ((n = dn_expand((u_char *) answer->buf, (u_char *) eom,
- (u_char *) cp, (u_char *) bp,
- bufsize - (bp - buf))) < 0)
- break;
- cp += n;
- result->h_name = bp;
- bp += strlen(bp) + 1;
- iquery_done = 1;
- break;
- }
- if (iquery || type != T_A) {
-#ifdef DEBUG_RESOLVER
- if (data->state.options & RES_DEBUG)
- printf("unexpected answer type %d, size %d\n",
- type, n);
-#endif
- cp += n;
- continue;
- }
- if (hap > addrs) {
- if (n != result->h_length) {
- cp += n;
- continue;
- }
- if (class != getclass) {
- cp += n;
- continue;
- }
- } else {
- result->h_length = n;
- getclass = class;
- result->h_addrtype = (class == C_IN) ? AF_INET : AF_UNSPEC;
- if (!iquery) {
- result->h_name = bp;
- bp += strlen(bp) + 1;
- }
- }
- bp = ALIGN(bp, pthread_ipaddr_type);
- if (bp + n >= buf + bufsize) {
- errno = ERANGE;
- return NULL;
- }
- memcpy(bp, cp, n);
- cp += n;
- if (hap >= addrs + __NETDB_MAXADDRS - 1)
- continue;
- *hap++ = bp;
- bp += n;
- cp += n;
- }
-
- if (hap > addrs || iquery_done) {
- *ap++ = NULL;
- *hap++ = NULL;
- if (data->state.nsort)
- qsort(addrs, hap - addrs, sizeof(struct in_addr), qcomp);
- if (SP(bp, char *, (hap - addrs) + (ap - aliases)) > buf + bufsize) {
- errno = ERANGE;
- return NULL;
- }
- result->h_addr_list = (char **) ALIGN(bp, char *);
- memcpy(result->h_addr_list, addrs, (hap - addrs) * sizeof(char *));
- result->h_aliases = result->h_addr_list + (hap - addrs);
- memcpy(result->h_aliases, aliases, (ap - aliases) * sizeof(char *));
- return result;
- } else {
- *errval = TRY_AGAIN;
- return NULL;
- }
-}
-
-/* Performs global initialization. */
-struct res_data *_res_init()
-{
- struct res_data *data;
-
- /* Make sure the global initializations have been done. */
- pthread_once(&init_once, _res_init_global);
- if (init_status < 0)
- return NULL;
-
- /* Initialize thread-specific data for this thread if it hasn't
- * been done already. */
- data = (struct res_data *) pthread_getspecific(key);
- if (!data) {
- data = (struct res_data *) malloc(sizeof(struct res_data));
- if (data == NULL)
- return NULL;
- if (pthread_setspecific(key, data) < 0) {
- free(data);
- return NULL;
- }
- data->buf = NULL;
- data->state = start;
- data->errval = NO_RECOVERY;
- data->sock = -1;
- }
- return data;
-}
-
-static void _res_init_global()
-{
- int result;
- char line[BUFSIZ], buf[BUFSIZ], *domain, *p, *net;
- int i, localdomain_set = 0, num_servers = 0, num_sorts = 0;
- FILE *fp;
- struct in_addr addr;
-
- /* Assume an error state until we finish. */
- init_status = -1;
-
- /* Initialize the key for thread-specific data. */
- result = pthread_key_create(&key, free);
- if (result < 0)
- return;
-
- /* Initialize starting state. */
- start.retrans = RES_TIMEOUT;
- start.retry = DEFAULT_RETRIES;
- start.options = RES_DEFAULT;
- start.id = 0;
- start.nscount = 1;
- start.nsaddr.sin_addr.s_addr = INADDR_ANY;
- start.nsaddr.sin_family = AF_INET;
- start.nsaddr.sin_port = htons(NAMESERVER_PORT);
- start.nscount = 1;
- start.ndots = 1;
- start.pfcode = 0;
- strncpy(start.lookups, "f", sizeof(start.lookups));
-
- /* Look for a LOCALDOMAIN definition. */
- domain = getenv("LOCALDOMAIN");
- if (domain != NULL) {
- strncpy(start.defdname, domain, sizeof(start.defdname));
- domain = start.defdname;
- localdomain_set = 1;
-
- /* Construct a search path from the LOCALDOMAIN value, which is
- * a space-separated list of strings. For backwards-compatibility,
- * a newline terminates the list. */
- i = 0;
- while (*domain && i < MAXDNSRCH) {
- start.dnsrch[i] = domain;
- while (*domain && !isspace(*domain))
- domain++;
- if (!*domain || *domain == '\n') {
- *domain = 0;
- break;
- }
- *domain++ = 0;
- while (isspace(*domain))
- domain++;
- i++;
- }
- }
-
- /* Look for a config file and read it in. */
- fp = fopen(_PATH_RESCONF, "r");
- if (fp != NULL) {
- strncpy(start.lookups, "bf", sizeof(start.lookups));
-
- /* Read in the configuration file. */
- while (fgets(line, sizeof(line), fp)) {
-
- /* Ignore blank lines and comments. */
- if (*line == ';' || *line == '#' || !*line)
- continue;
-
- if (strncmp(line, "domain", 6) == 0) {
-
- /* Read in the default domain, and initialize a one-
- * element search path. Skip the domain line if we
- * already got one from the LOCALDOMAIN environment
- * variable. */
- if (localdomain_set)
- continue;
-
- /* Look for the next word in the line. */
- p = line + 6;
- while (*p == ' ' || *p == '\t')
- p++;
- if (!*p || *p == '\n')
- continue;
-
- /* Copy in the domain, and null-terminate it at the
- * first tab or newline. */
- strncpy(start.defdname, p, sizeof(start.defdname) - 1);
- p = strpbrk(start.defdname, "\t\n");
- if (p)
- *p = 0;
-
- start.dnsrch[0] = start.defdname;
- start.dnsrch[1] = NULL;
-
- } else if (strncmp(line, "lookup", 6) == 0) {
-
- /* Get a list of lookup types. */
- memset(start.lookups, 0, sizeof(start.lookups));
-
- /* Find the next word in the line. */
- p = line + 6;
- while (isspace(*p))
- p++;
-
- i = 0;
- while (*p && i < MAXDNSLUS) {
- /* Add a lookup type. */
- if (*p == 'y' || *p == 'b' || *p == 'f')
- start.lookups[i++] = *p;
-
- /* Find the next word. */
- while (*p && !isspace(*p))
- p++;
- while (isspace(*p))
- p++;
- }
-
- } else if (strncmp(line, "search", 6) == 0) {
-
- /* Read in a space-separated list of domains to search
- * when a name is not fully-qualified. Skip this line
- * if the LOCALDOMAIN environment variable was set. */
- if (localdomain_set)
- continue;
-
- /* Look for the next word on the line. */
- p = line + 6;
- while (*p == ' ' || *p == '\t')
- p++;
- if (!*p || *p == '\n')
- continue;
-
- /* Copy the rest of the line into start.defdname. */
- strncpy(start.defdname, p, sizeof(start.defdname) - 1);
- domain = start.defdname;
- p = strchr(domain, '\n');
- if (*p)
- *p = 0;
-
- /* Construct a search path from the line, which is a
- * space-separated list of strings. */
- i = 0;
- while (*domain && i < MAXDNSRCH) {
- start.dnsrch[i] = domain;
- while (*domain && !isspace(*domain))
- domain++;
- if (!*domain || *domain == '\n') {
- *domain = 0;
- break;
- }
- *domain++ = 0;
- while (isspace(*domain))
- domain++;
- i++;
- }
-
- } else if (strncmp(line, "nameserver", 10) == 0) {
-
- /* Add an address to the list of name servers we can
- * connect to. */
-
- /* Look for the next word in the line. */
- p = line + 10;
- while (*p == ' ' || *p == '\t')
- p++;
- if (*p && *p != '\n' && inet_aton(p, &addr)) {
- start.nsaddr_list[num_servers].sin_addr = addr;
- start.nsaddr_list[num_servers].sin_family = AF_INET;
- start.nsaddr_list[num_servers].sin_port =
- htons(NAMESERVER_PORT);
- if (++num_servers >= MAXNS)
- break;
- }
-
- } else if (strncmp(line, "sortlist", 8) == 0) {
-
- p = line + 8;
- while (num_sorts < MAXRESOLVSORT) {
-
- /* Find the next word in the line. */
- p = line + 8;
- while (*p == ' ' || *p == '\t')
- p++;
-
- /* Read in an IP address and netmask. */
- if (sscanf(p, "%[0-9./]s", buf) != 1)
- break;
- net = strchr(buf, '/');
- if (net)
- *net = 0;
-
- /* Translate the address into an IP address
- * and netmask. */
- if (inet_aton(buf, &addr)) {
- start.sort_list[num_sorts].addr = addr;
- if (net && inet_aton(net + 1, &addr)) {
- start.sort_list[num_sorts].mask = addr.s_addr;
- } else {
- start.sort_list[num_sorts].mask =
- net_mask(start.sort_list[num_sorts].addr);
- }
- num_sorts++;
- }
-
- /* Skip past this word. */
- if (net)
- *net = '/';
- p += strlen(buf);
- }
-
- }
- }
- fclose(fp);
- }
-
- /* If we don't have a default domain, strip off the first
- * component of this machine's domain name, and make a one-
- * element search path consisting of the default domain. */
- if (*start.defdname == 0) {
- if (gethostname(buf, sizeof(start.defdname) - 1) == 0) {
- p = strchr(buf, '.');
- if (p)
- strcpy(start.defdname, p + 1);
- }
- start.dnsrch[0] = start.defdname;
- start.dnsrch[1] = NULL;
- }
-
- p = getenv("RES_OPTIONS");
- if (p)
- set_options(p, "env");
-
- start.options |= RES_INIT;
- _res = start;
- init_status = 0;
-}
-
-static void set_options(const char *options, const char *source)
-{
- const char *p = options;
- int i;
-
- while (*p) {
-
- /* Skip leading and inner runs of spaces. */
- while (*p == ' ' || *p == '\t')
- p++;
-
- /* Search for and process individual options. */
- if (strncmp(p, "ndots:", 6) == 0) {
- i = atoi(p + 6);
- start.ndots = (i <= RES_MAXNDOTS) ? i : RES_MAXNDOTS;
- } else if (!strncmp(p, "debug", 5))
- start.options |= RES_DEBUG;
- else if (!strncmp(p, "usevc", 5))
- start.options |= RES_USEVC;
- else if (!strncmp(p, "stayopen", 8))
- start.options |= RES_STAYOPEN;
-
- /* Skip to next run of spaces */
- while (*p && *p != ' ' && *p != '\t')
- p++;
- }
-}
-
-static pthread_ipaddr_type net_mask(struct in_addr in)
-{
- pthread_ipaddr_type i = ntohl(in.s_addr);
-
- if (IN_CLASSA(i))
- return htonl(IN_CLASSA_NET);
- if (IN_CLASSB(i))
- return htonl(IN_CLASSB_NET);
- return htonl(IN_CLASSC_NET);
-}
-
-/* Get the error value for this thread, or NO_RECOVERY if none has been
- * successfully set. The screw case to worry about here is if
- * __res_init() fails for a resolver routine because it can't allocate
- * or set the thread-specific data, and then __res_init() succeeds here.
- * Because __res_init() sets errval to NO_RECOVERY after a successful
- * initialization, we return NO_RECOVERY in that case, which is correct. */
-int _res_get_error()
-{
- struct res_data *data;
-
- data = _res_init();
- return (data) ? data->errval : NO_RECOVERY;
-}
-
-struct __res_state *_res_status()
-{
- struct res_data *data;
-
- data = _res_init();
- return (data) ? &data->state : NULL;
-}
-
-static int qcomp(const void *arg1, const void *arg2)
-{
- const struct in_addr **a1 = (const struct in_addr **) arg1;
- const struct in_addr **a2 = (const struct in_addr **) arg2;
- struct __res_state *state = _res_status();
-
- int pos1, pos2;
-
- for (pos1 = 0; pos1 < state->nsort; pos1++) {
- if (state->sort_list[pos1].addr.s_addr ==
- ((*a1)->s_addr & state->sort_list[pos1].mask))
- break;
- }
- for (pos2 = 0; pos2 < state->nsort; pos2++) {
- if (state->sort_list[pos2].addr.s_addr ==
- ((*a2)->s_addr & state->sort_list[pos2].mask))
- break;
- }
- return pos1 - pos2;
-}
-
-/*
- * This routine is for closing the socket if a virtual circuit is used and
- * the program wants to close it. We don't use this routine, but libc
- * might reference it.
- *
- * This routine is not expected to be user visible.
- */
-void _res_close()
-{
- struct res_data *data;
-
- data = _res_init();
- if (data && data->sock != -1) {
- (void) close(data->sock);
- data->sock = -1;
- }
-}
diff --git a/lib/libpthread/net/res_internal.h b/lib/libpthread/net/res_internal.h
deleted file mode 100644
index f189471a196..00000000000
--- a/lib/libpthread/net/res_internal.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 1985 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)res_internal.h 6.22 (Berkeley) 3/19/91";*/
-static char *rcsid = "$Id: res_internal.h,v 1.1 1998/07/21 13:19:47 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#ifndef _RES_INTERNAL_H
-#define _RES_INTERNAL_H
-
-#include <pthread.h>
-#include <netdb.h>
-#include <resolv.h>
-
-#define HOST_BUFSIZE 4096
-#define ALIGN(p, t) ((char *)(((((long)(p) - 1) / sizeof(t)) + 1) * sizeof(t)))
-#define SP(p, t, n) (ALIGN(p, t) + (n) * sizeof(t))
-
-struct res_data {
- char *buf;
- struct __res_state state;
- int errval;
- int sock;
-};
-
-#if PACKETSZ > 1024
-#define MAXPACKET PACKETSZ
-#else
-#define MAXPACKET 1024
-#endif
-
-typedef union {
- HEADER hdr;
- unsigned char buf[MAXPACKET];
-} querybuf;
-
-typedef union {
- long al;
- char ac;
-} align;
-
-extern pthread_mutex_t host_iterate_lock;
-
-__BEGIN_DECLS
-struct hostent *_res_parse_answer(querybuf *answer, int anslen, int iquery,
- struct hostent *result, char *buf,
- int buflen, int *errval);
-void _res_set_error(int val);
-struct res_data *_res_init(void);
-__END_DECLS
-
-#endif
-
diff --git a/lib/libpthread/net/res_mkquery.c b/lib/libpthread/net/res_mkquery.c
deleted file mode 100644
index 6f642fef23a..00000000000
--- a/lib/libpthread/net/res_mkquery.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Copyright (c) 1985 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)res_mkquery.c 6.16 (Berkeley) 3/6/91";*/
-static char *rcsid = "$Id: res_mkquery.c,v 1.1 1998/07/21 13:19:47 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/param.h>
-#include <sys/cdefs.h>
-#include <netinet/in.h>
-#include <resolv.h>
-#include <stdio.h>
-#include <string.h>
-
-/*
- * Form all types of queries.
- * Returns the size of the result or -1.
- */
-res_mkquery(op, dname, class, type, data, datalen, newrr_in, buf, buflen)
- int op; /* opcode of query */
- const char *dname; /* domain name */
- int class, type; /* class and type of query */
- const char *data; /* resource record data */
- int datalen; /* length of data */
- const char *newrr_in; /* new rr for modify or append */
- char *buf; /* buffer to put query */
- int buflen; /* size of buffer */
-{
- register HEADER *hp;
- register char *cp;
- register int n;
- struct rrec *newrr = (struct rrec *) newrr_in;
- char *dnptrs[10], **dpp, **lastdnptr;
- struct __res_state *_rs;
-
- /*
- * Initialize header fields.
- */
-
- _rs = _res_status();
- if (!_rs)
- return -1;
- if ((buf == NULL) || (buflen < sizeof(HEADER)))
- return(-1);
- memset(buf, 0, sizeof(HEADER));
- hp = (HEADER *) buf;
- hp->id = htons(++_rs->id);
- hp->opcode = op;
- hp->pr = (_rs->options & RES_PRIMARY) != 0;
- hp->rd = (_rs->options & RES_RECURSE) != 0;
- hp->rcode = NOERROR;
- cp = buf + sizeof(HEADER);
- buflen -= sizeof(HEADER);
- dpp = dnptrs;
- *dpp++ = buf;
- *dpp++ = NULL;
- lastdnptr = dnptrs + sizeof(dnptrs)/sizeof(dnptrs[0]);
- /*
- * perform opcode specific processing
- */
- switch (op) {
- case QUERY:
- if ((buflen -= QFIXEDSZ) < 0)
- return(-1);
- if ((n = dn_comp((u_char *)dname, (u_char *)cp, buflen,
- (u_char **)dnptrs, (u_char **)lastdnptr)) < 0)
- return (-1);
- cp += n;
- buflen -= n;
- __putshort(type, (u_char *)cp);
- cp += sizeof(u_short);
- __putshort(class, (u_char *)cp);
- cp += sizeof(u_short);
- hp->qdcount = htons(1);
- if (op == QUERY || data == NULL)
- break;
- /*
- * Make an additional record for completion domain.
- */
- buflen -= RRFIXEDSZ;
- if ((n = dn_comp((u_char *)data, (u_char *)cp, buflen,
- (u_char **)dnptrs, (u_char **)lastdnptr)) < 0)
- return (-1);
- cp += n;
- buflen -= n;
- __putshort(T_NULL, (u_char *)cp);
- cp += sizeof(u_short);
- __putshort(class, (u_char *)cp);
- cp += sizeof(u_short);
- __putlong(0, (u_char *)cp);
- cp += sizeof(pthread_ipaddr_type);
- __putshort(0, (u_char *)cp);
- cp += sizeof(u_short);
- hp->arcount = htons(1);
- break;
-
- case IQUERY:
- /*
- * Initialize answer section
- */
- if (buflen < 1 + RRFIXEDSZ + datalen)
- return (-1);
- *cp++ = '\0'; /* no domain name */
- __putshort(type, (u_char *)cp);
- cp += sizeof(u_short);
- __putshort(class, (u_char *)cp);
- cp += sizeof(u_short);
- __putlong(0, (u_char *)cp);
- cp += sizeof(pthread_ipaddr_type);
- __putshort(datalen, (u_char *)cp);
- cp += sizeof(u_short);
- if (datalen) {
- memcpy(cp, data, datalen);
- cp += datalen;
- }
- hp->ancount = htons(1);
- break;
-
-#ifdef ALLOW_UPDATES
- /*
- * For UPDATEM/UPDATEMA, do UPDATED/UPDATEDA followed by UPDATEA
- * (Record to be modified is followed by its replacement in msg.)
- */
- case UPDATEM:
- case UPDATEMA:
-
- case UPDATED:
- /*
- * The res code for UPDATED and UPDATEDA is the same; user
- * calls them differently: specifies data for UPDATED; server
- * ignores data if specified for UPDATEDA.
- */
- case UPDATEDA:
- buflen -= RRFIXEDSZ + datalen;
- if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
- return (-1);
- cp += n;
- __putshort(type, cp);
- cp += sizeof(u_short);
- __putshort(class, cp);
- cp += sizeof(u_short);
- __putlong(0, cp);
- cp += sizeof(pthread_ipaddr_type);
- __putshort(datalen, cp);
- cp += sizeof(u_short);
- if (datalen) {
- memcpy(cp, data, datalen);
- cp += datalen;
- }
- if ( (op == UPDATED) || (op == UPDATEDA) ) {
- hp->ancount = htons(0);
- break;
- }
- /* Else UPDATEM/UPDATEMA, so drop into code for UPDATEA */
-
- case UPDATEA: /* Add new resource record */
- buflen -= RRFIXEDSZ + datalen;
- if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
- return (-1);
- cp += n;
- __putshort(newrr->r_type, cp);
- cp += sizeof(u_short);
- __putshort(newrr->r_class, cp);
- cp += sizeof(u_short);
- __putlong(0, cp);
- cp += sizeof(pthread_ipaddr_type);
- __putshort(newrr->r_size, cp);
- cp += sizeof(u_short);
- if (newrr->r_size) {
- memcpy(cp, newrr->r_data, newrr->r_size);
- cp += newrr->r_size;
- }
- hp->ancount = htons(0);
- break;
-
-#endif /* ALLOW_UPDATES */
- }
- return (cp - buf);
-}
-
diff --git a/lib/libpthread/net/res_query.c b/lib/libpthread/net/res_query.c
deleted file mode 100644
index a00a1c164ac..00000000000
--- a/lib/libpthread/net/res_query.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 1985 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)res_query.c 6.22 (Berkeley) 3/19/91";*/
-static char *rcsid = "$Id: res_query.c,v 1.1 1998/07/21 13:19:47 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <resolv.h>
-#include <netdb.h>
-#include "res_internal.h"
-
-#if PACKETSZ > 1024
-#define MAXPACKET PACKETSZ
-#else
-#define MAXPACKET 1024
-#endif
-
-int res_query(char *name, int class, int type, unsigned char *answer,
- int anslen)
-{
- struct res_data *data;
- char buf[MAXPACKET];
- int result;
- HEADER *hp;
-
- data = _res_init();
- if (!data)
- return -1;
-
- /* Make the query. */
- result = res_mkquery(QUERY, name, class, type, NULL, 0, NULL, buf,
- sizeof(buf));
- if (result <= 0) {
- data->errval = NO_RECOVERY;
- return result;
- }
-
- result = res_send(buf, result, (char *) answer, anslen);
- if (result < 0) {
- data->errval = TRY_AGAIN;
- return result;
- }
-
- hp = (HEADER *) answer;
- if (hp->rcode == NOERROR && ntohs(hp->ancount) != 0)
- return result;
-
- /* Translate the error code and return. */
- switch(hp->rcode) {
- case NOERROR:
- data->errval = NO_DATA;
- break;
- case SERVFAIL:
- data->errval = TRY_AGAIN;
- break;
- case NXDOMAIN:
- data->errval = HOST_NOT_FOUND;
- break;
- default:
- data->errval = NO_RECOVERY;
- break;
- }
- return -1;
-}
-
diff --git a/lib/libpthread/net/res_querydomain.c b/lib/libpthread/net/res_querydomain.c
deleted file mode 100644
index 817974d476b..00000000000
--- a/lib/libpthread/net/res_querydomain.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 1985 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)res_querydomain.c 6.22 (Berkeley) 3/19/91";*/
-static char *rcsid = "$Id: res_querydomain.c,v 1.1 1998/07/21 13:19:47 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <resolv.h>
-#include <string.h>
-
-/* For backwards compatibility. */
-int res_querydomain(char *name, char *domain, int class, int type,
- unsigned char *answer, int anslen)
-{
- char buf[2 * MAXDNAME + 2];
- char *longname = buf;
- int len;
-
- if (domain == NULL) {
- /* Check for trailing '.'; copy without '.' if present. */
- len = strlen(name);
- if (len > 0 && name[len - 1] == '.' && len < sizeof(buf)) {
- memcpy(buf, name, len - 1);
- buf[len - 1] = '\0';
- } else {
- longname = name;
- }
- } else {
- sprintf(buf, "%.*s.%.*s", MAXDNAME, name, MAXDNAME, domain);
- }
-
- return (res_query(longname, class, type, answer, anslen));
-}
-
diff --git a/lib/libpthread/net/res_search.c b/lib/libpthread/net/res_search.c
deleted file mode 100644
index 64cddea20d4..00000000000
--- a/lib/libpthread/net/res_search.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (c) 1985, 1988 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)res_search.c 6.45 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: res_search.c,v 1.1 1998/07/21 13:19:47 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <resolv.h>
-#include <netdb.h>
-#include "res_internal.h"
-
-static char *search_aliases(const char *name, char *buf, int bufsize);
-
-int res_search(const char *name, int class, int type, unsigned char *answer,
- int anslen)
-{
- struct res_data *data;
- const char *p;
- int num_dots, len, result, no_data = 0, error;
- char buf[2 * MAXDNAME + 2], *domain, **dptr, *alias;
-
- data = _res_init();
- if (!data)
- return -1;
-
- /* Count the dots in name, and get a pointer to the end of name. */
- num_dots = 0;
- for (p = name; *p; p++) {
- if (*p == '.')
- num_dots++;
- }
- len = p - name;
-
- /* If there aren't any dots, check to see if name is an alias for
- * another host. If so, try the resolved alias as a fully-qualified
- * name. */
- alias = search_aliases(name, buf, sizeof(buf));
- if (alias != NULL)
- return res_query(alias, class, type, answer, anslen);
-
- /* If there's a trailing dot, try to strip it off and query the name. */
- if (len > 0 && p[-1] == '.') {
- if (len > sizeof(buf)) {
- /* It's too long; just query the original name. */
- return res_query(name, class, type, answer, anslen);
- } else {
- /* Copy the name without the trailing dot and query. */
- memcpy(buf, name, len - 1);
- buf[len] = 0;
- return res_query(buf, class, type, answer, anslen);
- }
- }
-
- if (data->state.options & RES_DNSRCH) {
- /* If RES_DNSRCH is set, query all the domains until we get a
- * definitive answer. */
- for (dptr = data->state.dnsrch; *dptr; dptr++) {
- domain = *dptr;
- sprintf(buf, "%.*s.%.*s", MAXDNAME, name, MAXDNAME, domain);
- result = res_query(buf, class, type, answer, anslen);
- if (result > 0)
- return result;
- if (data->errval == NO_DATA)
- no_data = 1;
- else if (data->errval != HOST_NOT_FOUND)
- break;
- }
- } else if (num_dots == 0 && data->state.options & RES_DEFNAMES) {
- /* If RES_DEFNAMES is set and there is no dot, query the default
- * domain. */
- domain = data->state.defdname;
- sprintf(buf, "%.*s.%.%s", MAXDNAME, name, MAXDNAME, domain);
- result = res_query(buf, class, type, answer, anslen);
- if (result > 0)
- return result;
- if (data->errval == NO_DATA)
- no_data = 1;
- }
-
- /* If all the domain queries failed, try the name as fully-qualified.
- * Only do this if there is at least one dot in the name. */
- if (num_dots > 0) {
- result = res_query(name, class, type, answer, anslen);
- if (result > 0)
- return result;
- }
-
- if (no_data)
- data->errval = NO_DATA;
-
- return -1;
-}
-
-static char *search_aliases(const char *name, char *buf, int bufsize)
-{
- FILE *fp;
- char *filename, *p;
- int len;
-
- filename = getenv("HOSTALIASES");
- if (filename == NULL)
- return NULL;
-
- fp = fopen(filename, "r");
- if (fp == NULL)
- return NULL;
-
- len = strlen(name);
- while (fgets(buf, bufsize, fp)) {
-
- /* Get the first word from the buffer. */
- p = buf;
- while (*p && !isspace(*p))
- p++;
- if (!*p)
- break;
-
- /* Null-terminate the first word and compare it with the name. */
- *p = 0;
- if (strcasecmp(buf, name) != 0)
- continue;
-
- p++;
- while (isspace(*p))
- p++;
- fclose(fp);
- return (*p) ? p : NULL;
- }
-
- fclose(fp);
- return NULL;
-}
-
diff --git a/lib/libpthread/net/res_send.c b/lib/libpthread/net/res_send.c
deleted file mode 100644
index d2d2ad68413..00000000000
--- a/lib/libpthread/net/res_send.c
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * Copyright (c) 1985, 1988 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)res_send.c 6.45 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: res_send.c,v 1.1 1998/07/21 13:19:47 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-#include <errno.h>
-#include <resolv.h>
-#include <netdb.h>
-#include <time.h>
-#include <sys/timers.h>
-#include <sys/socket.h>
-#include <sys/uio.h>
-#include <netinet/in.h>
-#include "res_internal.h"
-
-enum { SEND_GIVE_UP = -1, SEND_TRY_NEXT = -2, SEND_TRY_SAME = -3,
- SEND_TIMEOUT = -4, SEND_TRUNCATED = -5 };
-
-static int send_datagram(int server, int sock, const char *buf, int buflen,
- char *answer, int anslen, int try,
- struct res_data *data);
-static int send_circuit(int server, const char *buf, int buflen, char *answer,
- int anslen, struct res_data *data);
-static int close_save_errno(int sock);
-
-int res_send(const char *buf, int buflen, char *answer, int anslen)
-{
- struct res_data *data;
- struct sockaddr_in local;
- int use_virtual_circuit, result, udp_sock, have_seen_same, terrno = 0;
- int try, server;
-
- data = _res_init();
- if (!data)
- return -1;
-
- try = 0;
- server = 0;
-
- /* Try doing connectionless queries if appropriate. */
- if (!(data->state.options & RES_USEVC) && buflen <= PACKETSZ) {
- /* Create and bind a local UDP socket. */
- udp_sock = socket(AF_INET, SOCK_DGRAM, 0);
- if (udp_sock < 0)
- return -1;
- local.sin_family = AF_INET;
- local.sin_addr.s_addr = htonl(INADDR_ANY);
- local.sin_port = htons(0);
- if (bind(udp_sock, (struct sockaddr *) &local, sizeof(local)) < 0) {
- close(udp_sock);
- return -1;
- }
-
- /* Cycle through the retries and servers, sending off queries and
- * waiting for responses. */
- for (; try < data->state.retry; try++) {
- for (; server < data->state.nscount; server++) {
- result = send_datagram(server, udp_sock, buf, buflen, answer,
- anslen, try, data);
- if (result == SEND_TIMEOUT)
- terrno = ETIMEDOUT;
- else if (result != SEND_TRY_NEXT)
- break;
- }
- if (server < data->state.nscount)
- break;
- }
-
- close(udp_sock);
- if (result < 0)
- errno = (terrno == ETIMEDOUT) ? ETIMEDOUT : ECONNREFUSED;
- else
- errno = 0;
- if (result != SEND_TRUNCATED)
- return (result >= 0) ? result : -1;
- }
-
- /* Either we have to use the virtual circuit, or the server couldn't
- * fit its response in a UDP packet. Cycle through the retries and
- * servers, sending off queries and waiting for responses. Allow a
- * response of SEND_TRY_SAME to cause an extra retry once. */
- for (; try < data->state.retry; try++) {
- for (; server < data->state.nscount; server++) {
- result = send_circuit(server, buf, buflen, answer, anslen, data);
- terrno = errno;
- if (result == SEND_TRY_SAME) {
- if (!have_seen_same)
- server--;
- have_seen_same = 1;
- } else if (result != SEND_TRY_NEXT) {
- break;
- }
- }
- }
-
- errno = terrno;
- return (result >= 0) ? result : -1;
-}
-
-static int send_datagram(int server, int sock, const char *buf, int buflen,
- char *answer, int anslen, int try,
- struct res_data *data)
-{
- int count, interval;
- struct sockaddr_in local_addr;
- HEADER *request = (HEADER *) buf, *response = (HEADER *) answer;
- struct timespec timeout;
- struct timeval current;
- struct timezone zone;
-
-#ifdef DEBUG_RESOLVER
- if (_res.options & RES_DEBUG) {
- printf("res_send: request:\n");
- __p_query(buf);
- }
-#endif /* DEBUG_RESOLVER */
- /* Send a packet to the server. */
- count = sendto(sock, buf, buflen, 0,
- (struct sockaddr *) &data->state.nsaddr_list[server],
- sizeof(struct sockaddr_in));
-
- if (count != buflen) {
-#ifdef DEBUG_RESOLVER
- if (count < 0){
- if (_res.options & RES_DEBUG)
- perror("send_datagram:sendto");
- }
-#endif /* DEBUG_RESOLVER */
- return SEND_TRY_NEXT;
- }
-
- /* Await a reply with the correct ID. */
- while (1) {
- struct sockaddr_in from;
- int from_len;
-
- from_len = sizeof(from);
- interval = data->state.retrans << try;
- if (try > 0)
- interval /= data->state.nscount;
- gettimeofday(&current, &zone);
- current.tv_sec += interval;
- TIMEVAL_TO_TIMESPEC(&current, &timeout);
- count = recvfrom_timedwait(sock, answer, anslen, 0,
- &from, &from_len, &timeout);
- if (count < 0)
- return SEND_TRY_NEXT;
- /* If the ID is wrong, it's from an old query; ignore it. */
- if (response->id == request->id)
- break;
-#ifdef DEBUG_RESOLVER
- if (_res.options & RES_DEBUG) {
- printf("res_sendto: count=%d, response:\n", count);
- __p_query(answer);
- }
-#endif /* DEBUG_RESOLVER */
- }
-
- /* Report a truncated response unless RES_IGNTC is set. This will
- * cause the res_send() loop to fall back to TCP. */
- if (response->tc && !(data->state.options & RES_IGNTC))
- return SEND_TRUNCATED;
-
- return count;
-}
-
-static int send_circuit(int server, const char *buf, int buflen, char *answer,
- int anslen, struct res_data *data)
-{
- HEADER *response = (HEADER *) answer;
- int sock = -1, result, n, response_len, count;
- unsigned short len;
- struct iovec iov[2];
- char *p, junk[512];
-
- /* If data->sock is valid, then it's an open connection to the
- * first server. Grab it if it's appropriate; close it if not. */
- if (data->sock) {
- if (server == 0)
- sock = data->sock;
- else
- close(data->sock);
- data->sock = -1;
- }
-
- /* Initialize our socket if we didn't grab it from data. */
- if (sock == -1) {
- sock = socket(AF_INET, SOCK_STREAM, 0);
- if (sock < 0)
- return SEND_GIVE_UP;
- result = connect(sock,
- (struct sockaddr *) &data->state.nsaddr_list[server],
- sizeof(struct sockaddr_in));
- if (result < 0) {
- close_save_errno(sock);
- return SEND_TRY_NEXT;
- }
- }
-
- /* Send length and message. */
- len = htons((unsigned short) buflen);
- iov[0].iov_base = (caddr_t) &len;
- iov[0].iov_len = sizeof(len);
- iov[1].iov_base = (char *) buf;
- iov[1].iov_len = buflen;
- if (writev(sock, iov, 2) != sizeof(len) + buflen) {
- close_save_errno(sock);
- return SEND_TRY_NEXT;
- }
-
- /* Receive length. */
- p = (char *) &len;
- n = sizeof(len);
- while (n) {
- count = read(sock, p, n);
- if (count <= 0) {
- /* If we got ECONNRESET, the remote server may have restarted,
- * and we report SEND_TRY_SAME. (The main loop will only
- * allow one of these, so we don't have to worry about looping
- * indefinitely.) */
- close_save_errno(sock);
- return (errno == ECONNRESET) ? SEND_TRY_SAME : SEND_TRY_NEXT;
- }
- p += count;
- n -= count;
- }
- len = ntohs(len);
- response_len = (len > anslen) ? anslen : len;
- len -= response_len;
-
- /* Receive message. */
- p = answer;
- n = response_len;
- while (n) {
- count = read(sock, p, n);
- if (count <= 0) {
- close_save_errno(sock);
- return SEND_TRY_NEXT;
- }
- p += count;
- n -= count;
- }
-
- /* If the reply is longer than our answer buffer, set the truncated
- * bit and flush the rest of the reply, to keep the connection in
- * sync. */
- if (len) {
- response->tc = 1;
- while (len) {
- n = (len > sizeof(junk)) ? sizeof(junk) : len;
- count = read(sock, junk, n);
- if (count <= 0) {
- close_save_errno(sock);
- return response_len;
- }
- len -= count;
- }
- }
-
- /* If this is the first server, and RES_USEVC and RES_STAYOPEN are
- * both set, save the connection. Otherwise, close it. */
- if (server == 0 && (data->state.options & RES_USEVC &&
- data->state.options & RES_STAYOPEN))
- data->sock = sock;
- else
- close_save_errno(sock);
-
- return response_len;
-}
-
-static int close_save_errno(int sock)
-{
- int terrno;
-
- terrno = errno;
- close(sock);
- errno = terrno;
-}
diff --git a/lib/libpthread/net/serv_internal.c b/lib/libpthread/net/serv_internal.c
deleted file mode 100644
index 305d024259e..00000000000
--- a/lib/libpthread/net/serv_internal.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 1985 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)serv_internal.c 6.22 (Berkeley) 3/19/91";*/
-static char *rcsid = "$Id: serv_internal.c,v 1.1 1998/07/21 13:19:47 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "serv_internal.h"
-
-#define DEFAULT_RETRIES 4
-
-static void _serv_init_global();
-
-pthread_mutex_t serv_iterate_lock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_once_t init_once = PTHREAD_ONCE_INIT;
-static pthread_key_t key;
-static int init_status;
-
-/* Performs global initialization. */
-char *_serv_buf()
-{
- char *buf;
-
- /* Make sure the global initializations have been done. */
- pthread_once(&init_once, _serv_init_global);
-
- /* Initialize thread-specific data for this thread if it hasn't
- * been done already. */
- buf = (char *) pthread_getspecific(key);
- if (!buf) {
- buf = (char *) malloc(sizeof(struct servent) + SERV_BUFSIZE);
- if (buf == NULL)
- return NULL;
- if (pthread_setspecific(key, buf) < 0) {
- free(buf);
- return NULL;
- }
- }
- return buf;
-}
-
-static void _serv_init_global()
-{
- init_status = pthread_key_create(&key, free);
-}
-
diff --git a/lib/libpthread/net/serv_internal.h b/lib/libpthread/net/serv_internal.h
deleted file mode 100644
index 781a9120064..00000000000
--- a/lib/libpthread/net/serv_internal.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 1985 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)serv_internal.h 6.22 (Berkeley) 3/19/91";*/
-static char *rcsid = "$Id: serv_internal.h,v 1.1 1998/07/21 13:19:47 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#ifndef _SERV_INTERNAL_H
-#define _SERV_INTERNAL_H
-
-#include <pthread.h>
-#include <netdb.h>
-#include <resolv.h>
-
-#define SERV_BUFSIZE 4096
-#define ALIGN(p, t) ((char *)(((((long)(p) - 1) / sizeof(t)) + 1) * sizeof(t)))
-#define SP(p, t, n) (ALIGN(p, t) + (n) * sizeof(t))
-
-extern pthread_mutex_t serv_iterate_lock;
-
-__BEGIN_DECLS
-char *_serv_buf(void);
-__END_DECLS
-
-#endif
-
diff --git a/lib/libpthread/patches/Streepy.html b/lib/libpthread/patches/Streepy.html
deleted file mode 100755
index a3b4faa815f..00000000000
--- a/lib/libpthread/patches/Streepy.html
+++ /dev/null
@@ -1,2873 +0,0 @@
-diff -c -r1.1.1.1 pthread.h
-*** pthread.h 1996/03/13 04:30:57 1.1.1.1
---- pthread.h 1996/10/02 17:52:47
-***************
-*** 35,40 ****
---- 35,43 ----
- *
- * 1.00 93/07/20 proven
- * -Started coding this file.
-+ *
-+ * 93/9/28 streepy - Added support for pthread cancel
-+ *
- */
-
- #ifndef _PTHREAD_H_
-***************
-*** 65,70 ****
---- 68,82 ----
- /* More includes, that need size_t */
- #include <pthread/pthread_attr.h>
-
-+ /* Constants for use with pthread_setcancelstate and pthread_setcanceltype */
-+ #define PTHREAD_CANCEL_DISABLE 0
-+ #define PTHREAD_CANCEL_ENABLE 1
-+ #define PTHREAD_CANCEL_DEFERRED 0
-+ #define PTHREAD_CANCEL_ASYNCHRONOUS 1
-+
-+ #define PTHREAD_CANCELLED (void *)1 /* Exit status of a cancelled thread */
-+
-+
- #ifdef PTHREAD_KERNEL
-
- #include <signal.h> /* for sigset_t */
-***************
-*** 78,120 ****
- PS_STATE_MAX
- };
-
-- #define PF_WAIT_EVENT 0x01
-- #define PF_DONE_EVENT 0x02
--
- /* Put PANIC inside an expression that evaluates to non-void type, to
- make it easier to combine it in expressions. */
-! #define DO_PANIC() (PANIC (), 0)
-! #define PANICIF(x) ((x) ? DO_PANIC () : 0)
-
-! #define SET_PF_DONE_EVENT(x) \
-! ( !(x->flags & PF_DONE_EVENT) \
-! ? ( (x->flags & PF_WAIT_EVENT) \
-! ? (x->flags = PF_DONE_EVENT, OK) \
-! : DO_PANIC ()) \
- : NOTOK )
-
-! #define SET_PF_WAIT_EVENT(x) \
-! ( PANICIF (x->flags & (PF_WAIT_EVENT | PF_DONE_EVENT)), \
-! (x->flags = PF_WAIT_EVENT), 0)
-!
-! #define CLEAR_PF_DONE_EVENT(x) \
-! ( PANICIF (!(x->flags & PF_DONE_EVENT)), \
-! x->flags = 0 )
-
- struct pthread_select_data {
-! int nfds;
-! fd_set readfds;
-! fd_set writefds;
-! fd_set exceptfds;
- };
-
- 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 */
- } fd;
- struct pthread_select_data * select_data;
- };
---- 90,185 ----
- PS_STATE_MAX
- };
-
- /* Put PANIC inside an expression that evaluates to non-void type, to
- make it easier to combine it in expressions. */
-! #define DO_PANIC() (PANIC (), 0)
-! #define PANICIF(x) ((x) ? DO_PANIC () : 0)
-!
-! /* In the thread flag field, we use a series of bit flags. Flags can
-! * organized into "groups" of mutually exclusive flags. Other flags
-! * are unrelated and can be set and cleared with a single bit operation.
-! */
-
-! #define PF_WAIT_EVENT 0x01
-! #define PF_DONE_EVENT 0x02
-! #define PF_EVENT_GROUP 0x03 /* All event bits */
-!
-! #define PF_CANCEL_STATE 0x04 /* cancellability state */
-! #define PF_CANCEL_TYPE 0x08 /* cancellability type */
-! #define PF_THREAD_CANCELLED 0x10 /* thread has been cancelled */
-! #define PF_RUNNING_TO_CANCEL 0x20 /* Thread is running so it can cancel*/
-! #define PF_AT_CANCEL_POINT 0x40 /* Thread is at a cancel point */
-!
-! /* Flag operations */
-!
-! #define SET_PF_FLAG(x,f) ( (x)->flags |= (f) )
-! #define TEST_PF_FLAG(x,f) ( (x)->flags & (f) )
-! #define CLEAR_PF_FLAG(x,f) ( (x)->flags &= ~(f) )
-! #define CLEAR_PF_GROUP(x,g) ( (x)->flags &= ~(g) )
-! #define SET_PF_FLAG_IN_GROUP(x,g,f) ( CLEAR_PF_GROUP(x,g),SET_PF_FLAG(x,f))
-! #define TEST_PF_GROUP(x,g) ( (x)->flags & (g) )
-!
-! #define SET_PF_DONE_EVENT(x) \
-! ( !TEST_PF_FLAG(x,PF_DONE_EVENT) \
-! ? ( TEST_PF_FLAG(x,PF_WAIT_EVENT) \
-! ? (SET_PF_FLAG_IN_GROUP(x,PF_EVENT_GROUP,PF_DONE_EVENT), OK) \
-! : DO_PANIC ()) \
- : NOTOK )
-
-! #define SET_PF_WAIT_EVENT(x) \
-! ( PANICIF (TEST_PF_GROUP(x,PF_EVENT_GROUP) ), \
-! SET_PF_FLAG_IN_GROUP(x,PF_EVENT_GROUP,PF_WAIT_EVENT), 0)
-!
-! #define CLEAR_PF_DONE_EVENT(x) \
-! ( PANICIF (!TEST_PF_FLAG(x,PF_DONE_EVENT)), \
-! CLEAR_PF_GROUP(x,PF_EVENT_GROUP) )
-!
-! #define SET_PF_CANCELLED(x) ( SET_PF_FLAG(x,PF_THREAD_CANCELLED) )
-! #define TEST_PF_CANCELLED(x) ( TEST_PF_FLAG(x,PF_THREAD_CANCELLED) )
-!
-! #define SET_PF_RUNNING_TO_CANCEL(x) ( SET_PF_FLAG(x,PF_RUNNING_TO_CANCEL) )
-! #define CLEAR_PF_RUNNING_TO_CANCEL(x)( CLEAR_PF_FLAG(x,PF_RUNNING_TO_CANCEL) )
-! #define TEST_PF_RUNNING_TO_CANCEL(x)( TEST_PF_FLAG(x,PF_RUNNING_TO_CANCEL) )
-!
-! #define SET_PF_AT_CANCEL_POINT(x) ( SET_PF_FLAG(x,PF_AT_CANCEL_POINT) )
-! #define CLEAR_PF_AT_CANCEL_POINT(x) ( CLEAR_PF_FLAG(x,PF_AT_CANCEL_POINT) )
-! #define TEST_PF_AT_CANCEL_POINT(x) ( TEST_PF_FLAG(x,PF_AT_CANCEL_POINT) )
-!
-! #define SET_PF_CANCEL_STATE(x,f) \
-! ( (f) ? SET_PF_FLAG(x,PF_CANCEL_STATE) : CLEAR_PF_FLAG(x,PF_CANCEL_STATE) )
-! #define TEST_PF_CANCEL_STATE(x) \
-! ( (TEST_PF_FLAG(x,PF_CANCEL_STATE)) ? PTHREAD_CANCEL_ENABLE \
-! : PTHREAD_CANCEL_DISABLE )
-!
-! #define SET_PF_CANCEL_TYPE(x,f) \
-! ( (f) ? SET_PF_FLAG(x,PF_CANCEL_TYPE) : CLEAR_PF_FLAG(x,PF_CANCEL_TYPE) )
-! #define TEST_PF_CANCEL_TYPE(x) \
-! ( (TEST_PF_FLAG(x,PF_CANCEL_TYPE)) ? PTHREAD_CANCEL_ASYNCHRONOUS \
-! : PTHREAD_CANCEL_DEFERRED )
-!
-! /* See if a thread is in a state that it can be cancelled */
-! #define TEST_PTHREAD_IS_CANCELLABLE(x) \
-! ( (TEST_PF_CANCEL_STATE(x) == PTHREAD_CANCEL_ENABLE && TEST_PF_CANCELLED(x)) \
-! ? ((TEST_PF_CANCEL_TYPE(x) == PTHREAD_CANCEL_ASYNCHRONOUS) \
-! ? 1 \
-! : TEST_PF_AT_CANCEL_POINT(x)) \
-! : 0 )
-!
-
- struct pthread_select_data {
-! int nfds;
-! fd_set readfds;
-! fd_set writefds;
-! fd_set exceptfds;
- };
-
- 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 */
- } fd;
- struct pthread_select_data * select_data;
- };
-***************
-*** 122,143 ****
- #define PTT_USER_THREAD 0x0001
-
- struct pthread {
-! int thread_type;
- struct machdep_pthread machdep_data;
-! pthread_attr_t attr;
-
- /* Signal interface */
-! sigset_t sigmask;
-! sigset_t sigpending;
-! int sigcount; /* Number of signals pending */
-
- /* Timeout time */
-! struct timespec wakeup_time;
-
- /* Join queue for waiting threads */
- struct pthread_queue join_queue;
-
--
- /*
- * Thread implementations are just multiple queue type implemenations,
- * Below are the various link lists currently necessary
---- 187,207 ----
- #define PTT_USER_THREAD 0x0001
-
- struct pthread {
-! int thread_type;
- struct machdep_pthread machdep_data;
-! pthread_attr_t attr;
-
- /* Signal interface */
-! sigset_t sigmask;
-! sigset_t sigpending;
-! int sigcount; /* Number of signals pending */
-
- /* Timeout time */
-! struct timespec wakeup_time;
-
- /* Join queue for waiting threads */
- struct pthread_queue join_queue;
-
- /*
- * Thread implementations are just multiple queue type implemenations,
- * Below are the various link lists currently necessary
-***************
-*** 152,165 ****
- * ALL threads, in any state.
- * Must lock kernel lock before manipulating.
- */
-! struct pthread * pll;
-
- /*
- * Standard link list for running threads, mutexes, etc ...
- * It can't be on both a running link list and a wait queue.
- * Must lock kernel lock before manipulating.
- */
-! struct pthread * next;
- union pthread_wait_data data;
-
- /*
---- 216,229 ----
- * ALL threads, in any state.
- * Must lock kernel lock before manipulating.
- */
-! struct pthread * pll;
-
- /*
- * Standard link list for running threads, mutexes, etc ...
- * It can't be on both a running link list and a wait queue.
- * Must lock kernel lock before manipulating.
- */
-! struct pthread * next;
- union pthread_wait_data data;
-
- /*
-***************
-*** 167,197 ****
- * (Note: "priority" is a reserved word in Concurrent C, please
- * don't use it. --KR)
- */
-! struct pthread_queue * queue;
-! enum pthread_state state;
-! char flags;
-! char pthread_priority;
-
- /*
- * Sleep queue, this is different from the standard link list
- * because it is possible to be on both (pthread_cond_timedwait();
- * Must lock sleep mutex before manipulating
- */
-! struct pthread *sll; /* For sleeping threads */
-
- /*
- * Data that doesn't need to be locked
-! * Mostly it's because only the thread owning the data can manipulate it
- */
-! void * ret;
-! int error;
-! int * error_p;
-! const void ** specific_data;
-! int specific_data_count;
-
- /* Cleanup handlers Link List */
- struct pthread_cleanup *cleanup;
--
- };
-
- #else /* not PTHREAD_KERNEL */
---- 231,261 ----
- * (Note: "priority" is a reserved word in Concurrent C, please
- * don't use it. --KR)
- */
-! struct pthread_queue * queue;
-! enum pthread_state state;
-! enum pthread_state old_state; /* Used when cancelled */
-! char flags;
-! char pthread_priority;
-
- /*
- * Sleep queue, this is different from the standard link list
- * because it is possible to be on both (pthread_cond_timedwait();
- * Must lock sleep mutex before manipulating
- */
-! struct pthread *sll; /* For sleeping threads */
-
- /*
- * Data that doesn't need to be locked
-! * Mostly because only the thread owning the data can manipulate it
- */
-! void * ret;
-! int error;
-! int * error_p;
-! const void ** specific_data;
-! int specific_data_count;
-
- /* Cleanup handlers Link List */
- struct pthread_cleanup *cleanup;
- };
-
- #else /* not PTHREAD_KERNEL */
-***************
-*** 200,223 ****
-
- #endif
-
-! typedef struct pthread * pthread_t;
-
- /*
- * Globals
- */
- #ifdef PTHREAD_KERNEL
-
-! extern struct pthread * pthread_run;
-! extern struct pthread * pthread_initial;
-! extern struct pthread * pthread_link_list;
- extern struct pthread_queue pthread_dead_queue;
- extern struct pthread_queue pthread_alloc_queue;
-
-! extern pthread_attr_t pthread_attr_default;
-! extern volatile int fork_lock;
-! extern pthread_size_t pthread_pagesize;
-!
-! extern sigset_t * uthread_sigmask;
-
- #endif
-
---- 264,293 ----
-
- #endif
-
-! typedef struct pthread *pthread_t;
-
- /*
- * Globals
- */
- #ifdef PTHREAD_KERNEL
-
-! extern struct pthread * pthread_run;
-! extern struct pthread * pthread_initial;
-! extern struct pthread * pthread_link_list;
- extern struct pthread_queue pthread_dead_queue;
- extern struct pthread_queue pthread_alloc_queue;
-
-! extern pthread_attr_t pthread_attr_default;
-! extern volatile int fork_lock;
-! extern pthread_size_t pthread_pagesize;
-!
-! extern sigset_t * uthread_sigmask;
-!
-! /* Kernel global functions */
-! extern void pthread_sched_prevent(void);
-! extern void pthread_sched_resume(void);
-! extern int __pthread_is_valid( pthread_t );
-! extern void pthread_cancel_internal( int freelocks );
-
- #endif
-
-***************
-*** 229,271 ****
-
- #if defined(DCE_COMPAT)
-
-! typedef void * (*pthread_startroutine_t)(void *)
-! typedef void * pthread_addr_t
-
-! int pthread_create __P((pthread_t *, pthread_attr_t,
-! pthread_startroutine_t,
-! pthread_addr_t));
-! void pthread_exit __P((pthread_addr_t));
-! int pthread_join __P((pthread_t, pthread_addr_t *));
-
- #else
-
-! void pthread_init __P((void));
-! int pthread_create __P((pthread_t *,
-! const pthread_attr_t *,
-! void * (*start_routine)(void *),
-! void *));
-! void pthread_exit __P((void *));
-! pthread_t pthread_self __P((void));
-! int pthread_equal __P((pthread_t, pthread_t));
-! int pthread_join __P((pthread_t, void **));
-! int pthread_detach __P((pthread_t));
-! void pthread_yield __P((void));
-!
-! int pthread_setschedparam __P((pthread_t pthread, int policy,
-! struct sched_param * param));
-! int pthread_getschedparam __P((pthread_t pthread, int * policy,
-! struct sched_param * param));
-!
-! int pthread_kill __P((struct pthread *, int));
-! int pthread_signal __P((int, void (*)(int)));
-
- #endif
-
- #if defined(PTHREAD_KERNEL)
-
- /* Not valid, but I can't spell so this will be caught at compile time */
-! #define pthread_yeild(notvalid)
-
- #endif
-
---- 299,343 ----
-
- #if defined(DCE_COMPAT)
-
-! typedef void * (*pthread_startroutine_t)(void *);
-! typedef void * pthread_addr_t;
-
-! int pthread_create __P((pthread_t *, pthread_attr_t,
-! pthread_startroutine_t, pthread_addr_t));
-! void pthread_exit __P((pthread_addr_t));
-! int pthread_join __P((pthread_t, pthread_addr_t *));
-
- #else
-
-! void pthread_init __P((void));
-! int pthread_create __P((pthread_t *, const pthread_attr_t *,
-! void * (*start_routine)(void *), void *));
-! void pthread_exit __P((void *));
-! pthread_t pthread_self __P((void));
-! int pthread_equal __P((pthread_t, pthread_t));
-! int pthread_join __P((pthread_t, void **));
-! int pthread_detach __P((pthread_t));
-! void pthread_yield __P((void));
-!
-! int pthread_setschedparam __P((pthread_t pthread, int policy,
-! struct sched_param * param));
-! int pthread_getschedparam __P((pthread_t pthread, int * policy,
-! struct sched_param * param));
-!
-! int pthread_kill __P((struct pthread *, int));
-! int pthread_signal __P((int, void (*)(int)));
-!
-! int pthread_cancel __P(( pthread_t pthread ));
-! int pthread_setcancelstate __P(( int state, int *oldstate ));
-! int pthread_setcanceltype __P(( int type, int *oldtype ));
-! void pthread_testcancel __P(( void ));
-
- #endif
-
- #if defined(PTHREAD_KERNEL)
-
- /* Not valid, but I can't spell so this will be caught at compile time */
-! #define pthread_yeild(notvalid)
-
- #endif
-
-=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/include/signal.h,v retrieving revision 1.1.1.1
-diff -c -r1.1.1.1 signal.h
-*** signal.h 1995/12/25 03:03:09 1.1.1.1
---- signal.h 1996/09/26 21:46:04
-***************
-*** 43,48 ****
---- 43,49 ----
- __BEGIN_DECLS
-
- int raise __P((int));
-+ __sighandler_t signal __P((int __sig, __sighandler_t));
-
- #ifndef _ANSI_SOURCE
-
-=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/include/pthread/kernel.h,v retrieving revision 1.1.1.1
-diff -c -r1.1.1.1 kernel.h
-*** kernel.h 1994/12/13 07:09:01 1.1.1.1
---- kernel.h 1996/10/02 19:08:41
-***************
-*** 42,48 ****
- */
- #if defined(PTHREAD_KERNEL)
-
-! #define PANIC() abort()
-
- /* Time each rr thread gets */
- #define PTHREAD_RR_TIMEOUT 100000000
---- 42,54 ----
- */
- #if defined(PTHREAD_KERNEL)
-
-! #ifdef __GNUC__
-! #include <assert.h>
-! #define PANIC() panic_kernel( __FILE__, __LINE__, __ASSERT_FUNCTION )
-! #else
-! #define PANIC() panic_kernel( __FILE__, __LINE__, (const char *)0 )
-! #endif
-!
-
- /* Time each rr thread gets */
- #define PTHREAD_RR_TIMEOUT 100000000
-=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/machdep/syscall-i386-linux-1.0.S,v retrieving revision 1.1.1.1
-diff -c -r1.1.1.1 syscall-i386-linux-1.0.S
-*** syscall-i386-linux-1.0.S 1995/09/27 04:38:55 1.1.1.1
---- syscall-i386-linux-1.0.S 1996/06/04 19:20:17
-***************
-*** 147,154 ****
-
- /* =========================================================================
- * exit 1 select 82
-! * fork 2 socketcall 102
-! * read 3
- * write 4
- * open 5
- * creat 8
---- 147,154 ----
-
- /* =========================================================================
- * exit 1 select 82
-! * fork 2 fstatfs 100
-! * read 3 socketcall 102
- * write 4
- * open 5
- * creat 8
-***************
-*** 160,166 ****
- * chown 16
- * lseek 19
- * rename 38
-! * dup 41
- * pipe 42
- * ioctl 54
- * fcntl 55
---- 160,166 ----
- * chown 16
- * lseek 19
- * rename 38
-! * dup 41
- * pipe 42
- * ioctl 54
- * fcntl 55
-***************
-*** 302,314 ****
- #endif
-
- /* ==========================================================================
-! * machdep_sys_fstat()
- */
- #ifdef __ELF__
- STATCALL2(lstat)
- #else
- SYSCALL2(lstat)
- #endif
-
- /* ==========================================================================
- * machdep_sys_ftruncate()
---- 302,320 ----
- #endif
-
- /* ==========================================================================
-! * machdep_sys_lstat()
- */
- #ifdef __ELF__
- STATCALL2(lstat)
- #else
- SYSCALL2(lstat)
- #endif
-+
-+ /* ==========================================================================
-+ * machdep_sys_fstatfs()
-+ */
-+ SYSCALL2(fstatfs)
-+
-
- /* ==========================================================================
- * machdep_sys_ftruncate()
-=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/machdep/linux-1.0/socket.h,v retrieving revision 1.1.1.1
-diff -c -r1.1.1.1 socket.h
-*** socket.h 1995/12/26 02:28:03 1.1.1.1
---- socket.h 1996/09/27 18:12:45
-***************
-*** 26,32 ****
-
- #endif
-
-! /* #include <asm/socket.h> /* arch-dependent defines */
- #include <linux/sockios.h> /* the SIOCxxx I/O controls */
- #include <pthread/posix.h>
-
---- 26,32 ----
-
- #endif
-
-! /* #include <asm/socket.h> arch-dependent defines */
- #include <linux/sockios.h> /* the SIOCxxx I/O controls */
- #include <pthread/posix.h>
-
-***************
-*** 161,166 ****
---- 161,188 ----
- int connect __P((int, const struct sockaddr *, int));
- int listen __P((int, int));
- int socket __P((int, int, int));
-+
-+ int getsockopt __P ((int __s, int __level, int __optname,
-+ void *__optval, int *__optlen));
-+ int setsockopt __P ((int __s, int __level, int __optname,
-+ __const void *__optval, int optlen));
-+ int getsockname __P ((int __sockfd, struct sockaddr *__addr,
-+ int *__paddrlen));
-+ int getpeername __P ((int __sockfd, struct sockaddr *__peer,
-+ int *__paddrlen));
-+ ssize_t send __P ((int __sockfd, __const void *__buff, size_t __len, int __flags));
-+ ssize_t recv __P ((int __sockfd, void *__buff, size_t __len, int __flags));
-+ ssize_t sendto __P ((int __sockfd, __const void *__buff, size_t __len,
-+ int __flags, __const struct sockaddr *__to,
-+ int __tolen));
-+ ssize_t recvfrom __P ((int __sockfd, void *__buff, size_t __len,
-+ int __flags, struct sockaddr *__from,
-+ int *__fromlen));
-+ extern ssize_t sendmsg __P ((int __fd, __const struct msghdr *__message,
-+ int __flags));
-+ extern ssize_t recvmsg __P ((int __fd, struct msghdr *__message,
-+ int __flags));
-+ int shutdown __P ((int __sockfd, int __how));
-
- __END_DECLS
-
-=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/machdep/linux-1.0/timers.h,v retrieving revision 1.1.1.1
-diff -c -r1.1.1.1 timers.h
-*** timers.h 1996/03/05 08:28:36 1.1.1.1
---- timers.h 1996/05/25 21:30:08
-***************
-*** 43,52 ****
---- 43,54 ----
- #include <sys/types.h>
- #include <time.h>
-
-+ #ifndef _LINUX_TIME_H
- struct timespec {
- time_t tv_sec;
- long tv_nsec;
- };
-+ #endif /* _LINUX_TIME_H */
-
- #define TIMEVAL_TO_TIMESPEC(tv, ts) { \
- (ts)->tv_sec = (tv)->tv_sec; \
-=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/net/getprotoent.c,v retrieving revision 1.1.1.1
-diff -c -r1.1.1.1 getprotoent.c
-*** getprotoent.c 1996/02/09 05:39:41 1.1.1.1
---- getprotoent.c 1996/05/27 01:11:27
-***************
-*** 128,135 ****
- if (p != NULL)
- *p++ = '\0';
- }
-! if (p && *p);
-! break;
- }
- *alias = NULL;
- pthread_mutex_unlock(&proto_file_lock);
---- 128,135 ----
- if (p != NULL)
- *p++ = '\0';
- }
-! if (p && *p)
-! break;
- }
- *alias = NULL;
- pthread_mutex_unlock(&proto_file_lock);
-=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/net/proto_internal.c,v retrieving revision 1.1.1.1
-diff -c -r1.1.1.1 proto_internal.c
-*** proto_internal.c 1996/02/09 05:39:49 1.1.1.1
---- proto_internal.c 1996/06/04 16:25:57
-***************
-*** 49,55 ****
- static int init_status;
-
- /* Performs global initialization. */
-! char *_proto_init()
- {
- char *buf;
-
---- 49,55 ----
- static int init_status;
-
- /* Performs global initialization. */
-! char *_proto_buf()
- {
- char *buf;
-
-***************
-*** 75,78 ****
- {
- init_status = pthread_key_create(&key, free);
- }
--
---- 75,77 ----
-=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/net/res_internal.c,v retrieving revision 1.1.1.1
-diff -c -r1.1.1.1 res_internal.c
-*** res_internal.c 1996/02/09 05:39:53 1.1.1.1
---- res_internal.c 1996/09/25 23:31:11
-***************
-*** 144,149 ****
---- 144,150 ----
- break;
- cp += n;
- result->h_name = bp;
-+ bp += strlen(bp) + 1;
- iquery_done = 1;
- break;
- }
-=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/pthreads/GNUmakefile.inc,v retrieving revision 1.1.1.1
-diff -c -r1.1.1.1 GNUmakefile.inc
-*** GNUmakefile.inc 1995/08/30 22:27:04 1.1.1.1
---- GNUmakefile.inc 1996/10/02 19:04:29
-***************
-*** 8,14 ****
- syscall.S pthread_join.c pthread_detach.c pthread_once.c sleep.c \
- specific.c process.c wait.c errno.c schedparam.c _exit.c prio_queue.c \
- pthread_init.c init.cc sig.c info.c mutexattr.c select.c wrapper.c \
-! dump_state.c pthread_kill.c stat.c readv.c writev.c condattr.c $(SRCS)
-
- ifeq ($(HAVE_SYSCALL_TEMPLATE),yes)
- SYSCALL_FILTER_RULE= for s in $(AVAILABLE_SYSCALLS) ; do \
---- 8,15 ----
- syscall.S pthread_join.c pthread_detach.c pthread_once.c sleep.c \
- specific.c process.c wait.c errno.c schedparam.c _exit.c prio_queue.c \
- pthread_init.c init.cc sig.c info.c mutexattr.c select.c wrapper.c \
-! dump_state.c pthread_kill.c stat.c readv.c writev.c condattr.c \
-! pthread_cancel.c panic.c $(SRCS)
-
- ifeq ($(HAVE_SYSCALL_TEMPLATE),yes)
- SYSCALL_FILTER_RULE= for s in $(AVAILABLE_SYSCALLS) ; do \
-=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/pthreads/Makefile.inc,v retrieving revision 1.1.1.1
-diff -c -r1.1.1.1 Makefile.inc
-*** Makefile.inc 1995/08/22 22:09:07 1.1.1.1
---- Makefile.inc 1996/10/02 19:04:38
-***************
-*** 8,14 ****
- pthread_join.c pthread_detach.c pthread_once.c sleep.c specific.c \
- process.c wait.c errno.c schedparam.c _exit.c prio_queue.c \
- pthread_init.c init.cc sig.c info.c mutexattr.c select.c wrapper.c \
-! dump_state.c pthread_kill.c condattr.c
-
- .if $(HAVE_SYSCALL_TEMPLATE) == yes
- OBJS+= syscalls.o
---- 8,14 ----
- pthread_join.c pthread_detach.c pthread_once.c sleep.c specific.c \
- process.c wait.c errno.c schedparam.c _exit.c prio_queue.c \
- pthread_init.c init.cc sig.c info.c mutexattr.c select.c wrapper.c \
-! dump_state.c pthread_kill.c condattr.c pthread_cancel.c panic.c
-
- .if $(HAVE_SYSCALL_TEMPLATE) == yes
- OBJS+= syscalls.o
-=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/pthreads/cond.c,v retrieving revision 1.1.1.1
-diff -c -r1.1.1.1 cond.c
-*** cond.c 1996/03/05 08:29:12 1.1.1.1
---- cond.c 1996/10/03 18:19:04
-***************
-*** 188,197 ****
---- 188,204 ----
- pthread_queue_enq(&cond->c_queue, pthread_run);
- pthread_mutex_unlock(mutex);
-
-+ pthread_run->data.mutex = mutex;
-+
- SET_PF_WAIT_EVENT(pthread_run);
-+ SET_PF_AT_CANCEL_POINT(pthread_run); /* This is a cancel point */
- /* Reschedule will unlock pthread_run */
- pthread_resched_resume(PS_COND_WAIT);
-+ CLEAR_PF_AT_CANCEL_POINT(pthread_run); /* No longer at cancel point */
- CLEAR_PF_DONE_EVENT(pthread_run);
-+
-+ pthread_run->data.mutex = NULL;
-+
- rval = pthread_mutex_lock(mutex);
- return(rval);
- break;
-***************
-*** 203,212 ****
---- 210,226 ----
- pthread_mutex_unlock(mutex);
- mutex->m_data.m_count = 1;
-
-+ pthread_run->data.mutex = mutex;
-+
- SET_PF_WAIT_EVENT(pthread_run);
-+ SET_PF_AT_CANCEL_POINT(pthread_run); /* This is a cancel point */
- /* Reschedule will unlock pthread_run */
- pthread_resched_resume(PS_COND_WAIT);
-+ CLEAR_PF_AT_CANCEL_POINT(pthread_run); /* No longer at cancel point */
- CLEAR_PF_DONE_EVENT(pthread_run);
-+
-+ pthread_run->data.mutex = NULL;
-+
- rval = pthread_mutex_lock(mutex);
- mutex->m_data.m_count = count;
- return(rval);
-***************
-*** 258,265 ****
---- 272,285 ----
- SET_PF_WAIT_EVENT(pthread_run);
- pthread_mutex_unlock(mutex);
-
-+ pthread_run->data.mutex = mutex;
-+
-+ SET_PF_AT_CANCEL_POINT(pthread_run); /* This is a cancel point */
- /* Reschedule will unlock pthread_run */
- pthread_resched_resume(PS_COND_WAIT);
-+ CLEAR_PF_AT_CANCEL_POINT(pthread_run); /* No longer at cancel point */
-+
-+ pthread_run->data.mutex = NULL;
-
- /* Remove ourselves from sleep queue. If we fail then we timedout */
- if (sleep_cancel(pthread_run) == NOTOK) {
-***************
-*** 285,292 ****
---- 305,318 ----
- SET_PF_WAIT_EVENT(pthread_run);
- pthread_mutex_unlock(mutex);
-
-+ pthread_run->data.mutex = mutex;
-+
-+ SET_PF_AT_CANCEL_POINT(pthread_run); /* This is a cancel point */
- /* Reschedule will unlock pthread_run */
- pthread_resched_resume(PS_COND_WAIT);
-+ CLEAR_PF_AT_CANCEL_POINT(pthread_run); /* No longer at cancel point */
-+
-+ pthread_run->data.mutex = NULL;
-
- /* Remove ourselves from sleep queue. If we fail then we timedout */
- if (sleep_cancel(pthread_run) == NOTOK) {
-=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/pthreads/fd.c,v retrieving revision 1.1.1.1
-diff -c -r1.1.1.1 fd.c
-*** fd.c 1996/02/09 02:54:19 1.1.1.1
---- fd.c 1996/10/03 01:33:03
-***************
-*** 48,54 ****
---- 48,59 ----
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <sys/uio.h>
-+ #include <sys/ioctl.h>
-+ #if __STDC__
- #include <stdarg.h>
-+ #else
-+ #include <varargs.h>
-+ #endif
- #include <fcntl.h>
- #include <errno.h>
- #include <pthread/posix.h>
-***************
-*** 62,67 ****
---- 67,74 ----
- static const int dtablecount = 4096/sizeof(struct fd_table_entry);
- int dtablesize;
-
-+ static int fd_get_pthread_fd_from_kernel_fd( int );
-+
- /* ==========================================================================
- * Allocate dtablecount entries at once and populate the fd_table.
- *
-***************
-*** 199,204 ****
---- 206,244 ----
- return(NOTOK);
- }
-
-+ /*----------------------------------------------------------------------
-+ * Function: fd_get_pthread_fd_from_kernel_fd
-+ * Purpose: get the fd_table index of a kernel fd
-+ * Args: fd = kernel fd to convert
-+ * Returns: fd_table index, -1 if not found
-+ * Notes:
-+ *----------------------------------------------------------------------*/
-+ static int
-+ fd_get_pthread_fd_from_kernel_fd( int kfd )
-+ {
-+ int j;
-+
-+ /* This is *SICK*, but unless there is a faster way to
-+ * turn a kernel fd into an fd_table index, this has to do.
-+ */
-+ for( j=0; j < dtablesize; j++ ) {
-+ if( fd_table[j] &&
-+ fd_table[j]->type != FD_NT &&
-+ fd_table[j]->type != FD_NIU &&
-+ fd_table[j]->fd.i == kfd ) {
-+ return j;
-+ }
-+ }
-+
-+ /* Not listed byfd, Check for kernel fd == pthread fd */
-+ if( fd_table[kfd] == NULL || fd_table[kfd]->type == FD_NT ) {
-+ /* Assume that the kernel fd is the same */
-+ return kfd;
-+ }
-+
-+ return NOTOK; /* Not found */
-+ }
-+
- /* ==========================================================================
- * fd_basic_basic_unlock()
- *
-***************
-*** 288,293 ****
---- 328,334 ----
- switch (fd_table[fd]->type) {
- case FD_NIU:
- /* If not in use return EBADF error */
-+ SET_ERRNO(EBADF);
- return(NOTOK);
- break;
- case FD_NT:
-***************
-*** 297,302 ****
---- 338,344 ----
- */
- fd_kern_init(fd);
- if (fd_table[fd]->type == FD_NIU) {
-+ SET_ERRNO(EBADF);
- return(NOTOK);
- }
- break;
-***************
-*** 409,414 ****
---- 451,545 ----
- return(OK);
- }
-
-+ /*----------------------------------------------------------------------
-+ * Function: fd_unlock_for_cancel
-+ * Purpose: Unlock all fd locks held prior to being cancelled
-+ * Args: void
-+ * Returns:
-+ * OK or NOTOK
-+ * Notes:
-+ * Assumes the kernel is locked on entry
-+ *----------------------------------------------------------------------*/
-+ int
-+ fd_unlock_for_cancel( void )
-+ {
-+ int i, fd;
-+ struct pthread_select_data *data;
-+ int rdlk, wrlk, lktype;
-+ int found;
-+
-+ /* What we do depends on the previous state of the thread */
-+ switch( pthread_run->old_state ) {
-+ case PS_RUNNING:
-+ case PS_JOIN:
-+ case PS_SLEEP_WAIT:
-+ case PS_WAIT_WAIT:
-+ case PS_SIGWAIT:
-+ case PS_FDLR_WAIT:
-+ case PS_FDLW_WAIT:
-+ case PS_DEAD:
-+ case PS_UNALLOCED:
-+ break; /* Nothing to do */
-+
-+ case PS_COND_WAIT:
-+ CLEAR_PF_GROUP( pthread_run, PF_EVENT_GROUP );
-+ /* Must reaquire the mutex according to the standard */
-+ if( pthread_run->data.mutex == NULL ) {
-+ PANIC();
-+ }
-+ pthread_mutex_lock( pthread_run->data.mutex );
-+ break;
-+
-+ case PS_FDR_WAIT:
-+ CLEAR_PF_GROUP( pthread_run, PF_EVENT_GROUP);
-+ /* Free the lock on the fd being used */
-+ fd = fd_get_pthread_fd_from_kernel_fd( pthread_run->data.fd.fd );
-+ if( fd == NOTOK ) {
-+ PANIC(); /* Can't find fd */
-+ }
-+ fd_unlock( fd, FD_READ );
-+ break;
-+
-+ case PS_FDW_WAIT: /* Waiting on i/o */
-+ CLEAR_PF_GROUP( pthread_run, PF_EVENT_GROUP);
-+ /* Free the lock on the fd being used */
-+ fd = fd_get_pthread_fd_from_kernel_fd( pthread_run->data.fd.fd );
-+ if( fd == NOTOK ) {
-+ PANIC(); /* Can't find fd */
-+ }
-+ fd_unlock( fd, FD_WRITE );
-+ break;
-+
-+ case PS_SELECT_WAIT:
-+ data = pthread_run->data.select_data;
-+
-+ CLEAR_PF_GROUP( pthread_run, PF_EVENT_GROUP);
-+
-+ for( i = 0; i < data->nfds; i++) {
-+ rdlk =(FD_ISSET(i,&data->readfds)
-+ || FD_ISSET(i,&data->exceptfds));
-+ wrlk = FD_ISSET(i, &data->writefds);
-+ lktype = rdlk ? (wrlk ? FD_RDWR : FD_READ) : FD_WRITE;
-+
-+ if( ! (rdlk || wrlk) )
-+ continue; /* No locks, no unlock */
-+
-+ if( (fd = fd_get_pthread_fd_from_kernel_fd( i )) == NOTOK ) {
-+ PANIC(); /* Can't find fd */
-+ }
-+
-+ fd_unlock( fd, lktype );
-+ }
-+ break;
-+
-+ case PS_MUTEX_WAIT:
-+ PANIC(); /* Should never cancel a mutex wait */
-+
-+ default:
-+ PANIC(); /* Unknown thread status */
-+ }
-+ }
-+
- /* ==========================================================================
- * fd_lock()
- */
-***************
-*** 476,481 ****
---- 607,616 ----
- ret = fd_table[fd]->ops->read(fd_table[fd]->fd,
- fd_table[fd]->flags, buf, nbytes, timeout);
- fd_unlock(fd, FD_READ);
-+ if( ret < 0 ) {
-+ SET_ERRNO(-ret);
-+ ret = NOTOK;
-+ }
- }
- return(ret);
- }
-***************
-*** 500,505 ****
---- 635,644 ----
- ret = fd_table[fd]->ops->readv(fd_table[fd]->fd,
- fd_table[fd]->flags, iov, iovcnt, timeout);
- fd_unlock(fd, FD_READ);
-+ if( ret < 0 ) {
-+ SET_ERRNO(-ret);
-+ ret = NOTOK;
-+ }
- }
- return(ret);
- }
-***************
-*** 524,529 ****
---- 663,672 ----
- ret = fd_table[fd]->ops->write(fd_table[fd]->fd,
- fd_table[fd]->flags, buf, nbytes, timeout);
- fd_unlock(fd, FD_WRITE);
-+ if( ret < 0 ) {
-+ SET_ERRNO(-ret);
-+ ret = NOTOK;
-+ }
- }
- return(ret);
- }
-***************
-*** 548,553 ****
---- 691,700 ----
- ret = fd_table[fd]->ops->writev(fd_table[fd]->fd,
- fd_table[fd]->flags, iov, iovcnt, timeout);
- fd_unlock(fd, FD_WRITE);
-+ if( ret < 0 ) {
-+ SET_ERRNO(-ret);
-+ ret = NOTOK;
-+ }
- }
- return(ret);
- }
-***************
-*** 599,677 ****
- union fd_data realfd;
- int ret, flags;
-
- /* Need to lock the newfd by hand */
-! if (fd < dtablesize) {
-! pthread_mutex_lock(&fd_table_mutex);
-! if (fd_table[fd]) {
-! pthread_mutex_unlock(&fd_table_mutex);
-! mutex = &(fd_table[fd]->mutex);
-! pthread_mutex_lock(mutex);
-
-! /*
-! * XXX Gross hack ... because of fork(), any fd closed by the
-! * parent should not change the fd of the child, unless it owns it.
- */
-! switch(fd_table[fd]->type) {
-! case FD_NIU:
-! pthread_mutex_unlock(mutex);
-! ret = -EINVAL;
-! break;
-! case FD_NT:
-! /*
-! * If it's not tested then the only valid possibility is it's
-! * kernel fd.
-! */
-! ret = machdep_sys_close(fd);
-! fd_table[fd]->type = FD_NIU;
-! pthread_mutex_unlock(mutex);
-! break;
-! case FD_TEST_FULL_DUPLEX:
-! case FD_TEST_HALF_DUPLEX:
- realfd = fd_table[fd]->fd;
- flags = fd_table[fd]->flags;
- if ((entry = fd_free(fd)) == NULL) {
-! ret = fd_table[fd]->ops->close(realfd, flags);
- } else {
-! /* There can't be any others waiting for fd. */
- pthread_mutex_unlock(&entry->mutex);
- /* Note: entry->mutex = mutex */
-- mutex = &(fd_table[fd]->mutex);
- }
- pthread_mutex_unlock(mutex);
-- break;
-- default:
-- ret = fd_basic_lock(fd, FD_RDWR, mutex, NULL);
-- if (ret == OK) {
-- realfd = fd_table[fd]->fd;
-- flags = fd_table[fd]->flags;
-- pthread_mutex_unlock(mutex);
-- if ((entry = fd_free(fd)) == NULL) {
-- ret = fd_table[fd]->ops->close(realfd, flags);
-- } else {
-- fd_basic_basic_unlock(entry, FD_RDWR);
-- pthread_mutex_unlock(&entry->mutex);
-- /* Note: entry->mutex = mutex */
-- }
-- fd_unlock(fd, FD_RDWR);
-- } else {
-- pthread_mutex_unlock(mutex);
-- }
-- break;
- }
-! } else {
-! /* Don't bother creating a table entry */
-! pthread_mutex_unlock(&fd_table_mutex);
-! ret = machdep_sys_close(fd);
- }
-! return(ret);
- }
-! return(-EINVAL);
- }
-
- /* ==========================================================================
- * fd_basic_dup()
- *
- * Might need to do more than just what's below.
- */
- static inline void fd_basic_dup(int fd, int newfd)
- {
---- 746,836 ----
- union fd_data realfd;
- int ret, flags;
-
-+ if( fd < 0 || fd >= dtablesize ) {
-+ SET_ERRNO(EBADF);
-+ return -1;
-+ }
-+
- /* Need to lock the newfd by hand */
-! pthread_mutex_lock(&fd_table_mutex);
-! if (fd_table[fd]) {
-! pthread_mutex_unlock(&fd_table_mutex);
-! mutex = &(fd_table[fd]->mutex);
-! pthread_mutex_lock(mutex);
-
-! /*
-! * XXX Gross hack ... because of fork(), any fd closed by the
-! * parent should not change the fd of the child, unless it owns it.
-! */
-! switch(fd_table[fd]->type) {
-! case FD_NIU:
-! pthread_mutex_unlock(mutex);
-! ret = -EBADF;
-! break;
-! case FD_NT:
-! /*
-! * If it's not tested then the only valid possibility is it's
-! * kernel fd.
- */
-! ret = machdep_sys_close(fd);
-! fd_table[fd]->type = FD_NIU;
-! pthread_mutex_unlock(mutex);
-! break;
-! case FD_TEST_FULL_DUPLEX:
-! case FD_TEST_HALF_DUPLEX:
-! realfd = fd_table[fd]->fd;
-! flags = fd_table[fd]->flags;
-! if ((entry = fd_free(fd)) == NULL) {
-! ret = fd_table[fd]->ops->close(realfd, flags);
-! } else {
-! /* There can't be any others waiting for fd. */
-! pthread_mutex_unlock(&entry->mutex);
-! /* Note: entry->mutex = mutex */
-! mutex = &(fd_table[fd]->mutex);
-! }
-! pthread_mutex_unlock(mutex);
-! break;
-! default:
-! ret = fd_basic_lock(fd, FD_RDWR, mutex, NULL);
-! if (ret == OK) {
- realfd = fd_table[fd]->fd;
- flags = fd_table[fd]->flags;
-+ pthread_mutex_unlock(mutex);
- if ((entry = fd_free(fd)) == NULL) {
-! ret = fd_table[fd]->ops->close(realfd, flags);
- } else {
-! fd_basic_basic_unlock(entry, FD_RDWR);
- pthread_mutex_unlock(&entry->mutex);
- /* Note: entry->mutex = mutex */
- }
-+ fd_unlock(fd, FD_RDWR);
-+ } else {
- pthread_mutex_unlock(mutex);
- }
-! break;
- }
-! } else {
-! /* Don't bother creating a table entry */
-! pthread_mutex_unlock(&fd_table_mutex);
-! ret = machdep_sys_close(fd);
-! }
-!
-! if( ret < 0 ) {
-! SET_ERRNO(-ret);
-! ret = -1;
- }
-!
-! return ret;
- }
-
- /* ==========================================================================
- * fd_basic_dup()
- *
- * Might need to do more than just what's below.
-+ *
-+ * This is a MAJOR guess!! I don't know if the mutext unlock is valid
-+ * in the BIG picture. But it seems to be needed to avoid deadlocking
-+ * with ourselves when we try to close the duped file descriptor.
- */
- static inline void fd_basic_dup(int fd, int newfd)
- {
-***************
-*** 679,684 ****
---- 838,845 ----
- fd_table[fd]->next = fd_table[newfd];
- fd_table[newfd] = fd_table[fd];
- fd_table[fd]->count++;
-+ pthread_mutex_unlock(&fd_table[newfd]->next->mutex);
-+
- }
-
- /* ==========================================================================
-***************
-*** 896,904 ****
- * ala select()... --SNL
- */
- int
-! ioctl(int fd, unsigned long request, caddr_t arg)
- {
- int ret;
-
- if (fd < 0 || fd >= dtablesize)
- ret = NOTOK;
---- 1057,1071 ----
- * ala select()... --SNL
- */
- int
-! ioctl(int fd, int request, ...)
- {
- int ret;
-+ pthread_va_list ap;
-+ caddr_t arg;
-+
-+ va_start( ap, request ); /* Get the arg */
-+ arg = va_arg(ap,caddr_t);
-+ va_end( ap );
-
- if (fd < 0 || fd >= dtablesize)
- ret = NOTOK;
-***************
-*** 906,911 ****
---- 1073,1086 ----
- ret = machdep_sys_ioctl(fd, request, arg);
- else if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
- ret = machdep_sys_ioctl(fd_table[fd]->fd.i, request, arg);
-+ if( ret == 0 && request == FIONBIO ) {
-+ /* Properly set NONBLOCK flag */
-+ int v = *(int *)arg;
-+ if( v )
-+ fd_table[fd]->flags |= __FD_NONBLOCK;
-+ else
-+ fd_table[fd]->flags &= ~__FD_NONBLOCK;
-+ }
- fd_unlock(fd, FD_RDWR);
- }
- return ret;
-=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/pthreads/fd_kern.c,v retrieving revision 1.1.1.1
-diff -c -r1.1.1.1 fd_kern.c
-*** fd_kern.c 1996/02/12 00:58:30 1.1.1.1
---- fd_kern.c 1996/10/03 01:54:15
-***************
-*** 128,134 ****
-
-
- if ((count = machdep_sys_select(dtablesize, &fd_set_read,
-! &fd_set_write, NULL, &__fd_kern_poll_timeout)) < OK) {
- if (count == -EINTR) {
- return;
- }
---- 128,134 ----
-
-
- if ((count = machdep_sys_select(dtablesize, &fd_set_read,
-! &fd_set_write, &fd_set_except, &__fd_kern_poll_timeout)) < OK) {
- if (count == -EINTR) {
- return;
- }
-***************
-*** 167,200 ****
-
- for (pthread = fd_wait_select.q_next; count && pthread; ) {
- int found_one = 0;
-
- for (i = 0; i < pthread->data.select_data->nfds; i++) {
- int count_dec = 0;
-
-! if ((FD_ISSET(i, &pthread->data.select_data->exceptfds) &&
-! ! FD_ISSET(i, &fd_set_except))) {
-! FD_CLR(i, &pthread->data.select_data->exceptfds);
-! } else {
-! count_dec++;
- }
-! if ((FD_ISSET(i, &pthread->data.select_data->writefds) &&
-! ! FD_ISSET(i, &fd_set_write))) {
-! FD_CLR(i, &pthread->data.select_data->writefds);
-! } else {
-! count_dec++;
- }
-! if ((FD_ISSET(i, &pthread->data.select_data->readfds) &&
-! ! FD_ISSET(i, &fd_set_read))) {
-! FD_CLR(i, &pthread->data.select_data->readfds);
-! } else {
-! count_dec++;
- }
- if (count_dec) {
- found_one++;
- count--;
- }
- }
- if (found_one) {
- deq = pthread;
- pthread = pthread->next;
- pthread_queue_remove(&fd_wait_select, deq);
---- 167,223 ----
-
- for (pthread = fd_wait_select.q_next; count && pthread; ) {
- int found_one = 0;
-+ fd_set tmp_readfds, tmp_writefds, tmp_exceptfds;
-+
-+ memcpy(&tmp_readfds, &pthread->data.select_data->readfds,
-+ sizeof(fd_set));
-+ memcpy(&tmp_writefds, &pthread->data.select_data->writefds,
-+ sizeof(fd_set));
-+ memcpy(&tmp_exceptfds, &pthread->data.select_data->exceptfds,
-+ sizeof(fd_set));
-
- for (i = 0; i < pthread->data.select_data->nfds; i++) {
- int count_dec = 0;
-
-! if( (FD_ISSET(i, &tmp_exceptfds)) ) {
-! if( FD_ISSET(i, &fd_set_except) ) {
-! count_dec++; /* got a hit */
-! } else {
-! FD_CLR(i, &tmp_exceptfds);
-! }
- }
-!
-! if( (FD_ISSET(i, &tmp_writefds)) ) {
-! if( FD_ISSET(i, &fd_set_write) ) {
-! count_dec++; /* got a hit */
-! } else {
-! FD_CLR(i, &tmp_writefds);
-! }
- }
-!
-! if( (FD_ISSET(i, &tmp_readfds)) ) {
-! if( FD_ISSET(i, &fd_set_read) ) {
-! count_dec++; /* got a hit */
-! } else {
-! FD_CLR(i, &tmp_readfds);
-! }
- }
-+
- if (count_dec) {
- found_one++;
- count--;
- }
- }
-+
- if (found_one) {
-+ /* Update the threads saved select data fd sets */
-+ memcpy(&pthread->data.select_data->readfds, &tmp_readfds,
-+ sizeof(fd_set));
-+ memcpy(&pthread->data.select_data->writefds, &tmp_writefds,
-+ sizeof(fd_set));
-+ memcpy(&pthread->data.select_data->exceptfds, &tmp_exceptfds,
-+ sizeof(fd_set));
-+
- deq = pthread;
- pthread = pthread->next;
- pthread_queue_remove(&fd_wait_select, deq);
-***************
-*** 266,272 ****
- */
-
- while ((count = machdep_sys_select(dtablesize, &fd_set_read,
-! &fd_set_write, NULL, &__fd_kern_wait_timeout)) < OK) {
- if (count == -EINTR) {
- return;
- }
---- 289,295 ----
- */
-
- while ((count = machdep_sys_select(dtablesize, &fd_set_read,
-! &fd_set_write, &fd_set_except, &__fd_kern_wait_timeout)) < OK) {
- if (count == -EINTR) {
- return;
- }
-***************
-*** 305,338 ****
-
- for (pthread = fd_wait_select.q_next; count && pthread; ) {
- int found_one = 0;
-
- for (i = 0; i < pthread->data.select_data->nfds; i++) {
- int count_dec = 0;
-
-! if ((FD_ISSET(i, &pthread->data.select_data->exceptfds) &&
-! ! FD_ISSET(i, &fd_set_except))) {
-! FD_CLR(i, &pthread->data.select_data->exceptfds);
-! } else {
-! count_dec++;
- }
-! if ((FD_ISSET(i, &pthread->data.select_data->writefds) &&
-! ! FD_ISSET(i, &fd_set_write))) {
-! FD_CLR(i, &pthread->data.select_data->writefds);
-! } else {
-! count_dec++;
- }
-! if ((FD_ISSET(i, &pthread->data.select_data->readfds) &&
-! ! FD_ISSET(i, &fd_set_read))) {
-! FD_CLR(i, &pthread->data.select_data->readfds);
-! } else {
-! count_dec++;
- }
- if (count_dec) {
- found_one++;
- count--;
- }
- }
- if (found_one) {
- deq = pthread;
- pthread = pthread->next;
- pthread_queue_remove(&fd_wait_select, deq);
---- 328,383 ----
-
- for (pthread = fd_wait_select.q_next; count && pthread; ) {
- int found_one = 0;
-+ fd_set tmp_readfds, tmp_writefds, tmp_exceptfds;
-+
-+ memcpy(&tmp_readfds, &pthread->data.select_data->readfds,
-+ sizeof(fd_set));
-+ memcpy(&tmp_writefds, &pthread->data.select_data->writefds,
-+ sizeof(fd_set));
-+ memcpy(&tmp_exceptfds, &pthread->data.select_data->exceptfds,
-+ sizeof(fd_set));
-
- for (i = 0; i < pthread->data.select_data->nfds; i++) {
- int count_dec = 0;
-
-! if( (FD_ISSET(i, &tmp_exceptfds)) ) {
-! if( FD_ISSET(i, &fd_set_except) ) {
-! count_dec++; /* got a hit */
-! } else {
-! FD_CLR(i, &tmp_exceptfds);
-! }
- }
-!
-! if( (FD_ISSET(i, &tmp_writefds)) ) {
-! if( FD_ISSET(i, &fd_set_write) ) {
-! count_dec++; /* got a hit */
-! } else {
-! FD_CLR(i, &tmp_writefds);
-! }
- }
-!
-! if( (FD_ISSET(i, &tmp_readfds)) ) {
-! if( FD_ISSET(i, &fd_set_read) ) {
-! count_dec++; /* got a hit */
-! } else {
-! FD_CLR(i, &tmp_readfds);
-! }
- }
-+
- if (count_dec) {
- found_one++;
- count--;
- }
- }
- if (found_one) {
-+ /* Update the threads saved select data fd sets */
-+ memcpy(&pthread->data.select_data->readfds, &tmp_readfds,
-+ sizeof(fd_set));
-+ memcpy(&pthread->data.select_data->writefds, &tmp_writefds,
-+ sizeof(fd_set));
-+ memcpy(&pthread->data.select_data->exceptfds, &tmp_exceptfds,
-+ sizeof(fd_set));
-+
- deq = pthread;
- pthread = pthread->next;
- pthread_queue_remove(&fd_wait_select, deq);
-***************
-*** 380,404 ****
- machdep_gettimeofday(&current_time);
- sleep_schedule(&current_time, timeout);
-
- pthread_resched_resume(PS_FDR_WAIT);
-
- /* We're awake */
- pthread_sched_prevent();
- if (sleep_cancel(pthread_run) == NOTOK) {
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
-- SET_ERRNO(ETIMEDOUT);
- ret = -ETIMEDOUT;
- break;
- }
- pthread_sched_resume();
- } else {
- pthread_resched_resume(PS_FDR_WAIT);
- }
- CLEAR_PF_DONE_EVENT(pthread_run);
- } else {
-- SET_ERRNO(-ret);
-- ret = NOTOK;
- break;
- }
- }
---- 425,450 ----
- machdep_gettimeofday(&current_time);
- sleep_schedule(&current_time, timeout);
-
-+ SET_PF_AT_CANCEL_POINT(pthread_run);
- pthread_resched_resume(PS_FDR_WAIT);
-+ CLEAR_PF_AT_CANCEL_POINT(pthread_run);
-
- /* We're awake */
- pthread_sched_prevent();
- if (sleep_cancel(pthread_run) == NOTOK) {
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- ret = -ETIMEDOUT;
- break;
- }
- pthread_sched_resume();
- } else {
-+ SET_PF_AT_CANCEL_POINT(pthread_run);
- pthread_resched_resume(PS_FDR_WAIT);
-+ CLEAR_PF_AT_CANCEL_POINT(pthread_run);
- }
- CLEAR_PF_DONE_EVENT(pthread_run);
- } else {
- break;
- }
- }
-***************
-*** 437,443 ****
- if (sleep_cancel(pthread_run) == NOTOK) {
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
-- SET_ERRNO(ETIMEDOUT);
- ret = -ETIMEDOUT;
- break;
- }
---- 483,488 ----
-***************
-*** 447,454 ****
- }
- CLEAR_PF_DONE_EVENT(pthread_run);
- } else {
-- SET_ERRNO(-ret);
-- ret = NOTOK;
- break;
- }
- }
---- 492,497 ----
-***************
-*** 480,504 ****
- machdep_gettimeofday(&current_time);
- sleep_schedule(&current_time, timeout);
-
- pthread_resched_resume(PS_FDW_WAIT);
-
- /* We're awake */
- pthread_sched_prevent();
- if (sleep_cancel(pthread_run) == NOTOK) {
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
-- SET_ERRNO(ETIMEDOUT);
- ret = -ETIMEDOUT;
- break;
- }
- pthread_sched_resume();
- } else {
- pthread_resched_resume(PS_FDW_WAIT);
- }
- CLEAR_PF_DONE_EVENT(pthread_run);
- } else {
-- SET_ERRNO(-ret);
-- ret = NOTOK;
- break;
- }
- }
---- 523,548 ----
- machdep_gettimeofday(&current_time);
- sleep_schedule(&current_time, timeout);
-
-+ SET_PF_AT_CANCEL_POINT(pthread_run);
- pthread_resched_resume(PS_FDW_WAIT);
-+ CLEAR_PF_AT_CANCEL_POINT(pthread_run);
-
- /* We're awake */
- pthread_sched_prevent();
- if (sleep_cancel(pthread_run) == NOTOK) {
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- ret = -ETIMEDOUT;
- break;
- }
- pthread_sched_resume();
- } else {
-+ SET_PF_AT_CANCEL_POINT(pthread_run);
- pthread_resched_resume(PS_FDW_WAIT);
-+ CLEAR_PF_AT_CANCEL_POINT(pthread_run);
- }
- CLEAR_PF_DONE_EVENT(pthread_run);
- } else {
- break;
- }
- }
-***************
-*** 537,543 ****
- if (sleep_cancel(pthread_run) == NOTOK) {
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
-- SET_ERRNO(ETIMEDOUT);
- ret = -ETIMEDOUT;
- break;
- }
---- 581,586 ----
-***************
-*** 547,554 ****
- }
- CLEAR_PF_DONE_EVENT(pthread_run);
- } else {
-- SET_ERRNO(-ret);
-- ret = NOTOK;
- break;
- }
- }
---- 590,595 ----
-***************
-*** 662,668 ****
- */
- int create(const char *path, mode_t mode)
- {
-! return creat (path, mode);
- }
-
- /* ==========================================================================
---- 703,709 ----
- */
- int create(const char *path, mode_t mode)
- {
-! return creat (path, mode);
- }
-
- /* ==========================================================================
-***************
-*** 672,678 ****
-
- int creat(const char *path, mode_t mode)
- {
-! return open (path, O_CREAT | O_TRUNC | O_WRONLY, mode);
- }
-
- /* ==========================================================================
---- 713,719 ----
-
- int creat(const char *path, mode_t mode)
- {
-! return open (path, O_CREAT | O_TRUNC | O_WRONLY, mode);
- }
-
- /* ==========================================================================
-***************
-*** 1079,1090 ****
- int bind(int fd, const struct sockaddr *name, int namelen)
- {
- /* Not much to do in bind */
-- semaphore *plock;
- int ret;
-
- if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
- if ((ret = machdep_sys_bind(fd_table[fd]->fd.i, name, namelen)) < OK) {
- SET_ERRNO(-ret);
- }
- fd_unlock(fd, FD_RDWR);
- }
---- 1120,1131 ----
- int bind(int fd, const struct sockaddr *name, int namelen)
- {
- /* Not much to do in bind */
- int ret;
-
- if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
- if ((ret = machdep_sys_bind(fd_table[fd]->fd.i, name, namelen)) < OK) {
- SET_ERRNO(-ret);
-+ ret = NOTOK;
- }
- fd_unlock(fd, FD_RDWR);
- }
-***************
-*** 1100,1113 ****
- */
- int connect(int fd, const struct sockaddr *name, int namelen)
- {
-! struct sockaddr tmpname;
-! int ret, tmpnamelen;
-
-! if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
- if ((ret = machdep_sys_connect(fd_table[fd]->fd.i, name, namelen)) < OK) {
- if (!(fd_table[fd]->flags & __FD_NONBLOCK) &&
-! ((ret == -EWOULDBLOCK) || (ret == -EINPROGRESS) ||
-! (ret == -EALREADY) || (ret == -EAGAIN))) {
- pthread_sched_prevent();
-
- /* queue pthread for a FDW_WAIT */
---- 1141,1154 ----
- */
- int connect(int fd, const struct sockaddr *name, int namelen)
- {
-! struct sockaddr tmpname;
-! int ret, tmpnamelen;
-
-! if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
- if ((ret = machdep_sys_connect(fd_table[fd]->fd.i, name, namelen)) < OK) {
- if (!(fd_table[fd]->flags & __FD_NONBLOCK) &&
-! ((ret == -EWOULDBLOCK) || (ret == -EINPROGRESS) ||
-! (ret == -EALREADY) || (ret == -EAGAIN))) {
- pthread_sched_prevent();
-
- /* queue pthread for a FDW_WAIT */
-***************
-*** 1121,1131 ****
- tmpnamelen = sizeof(tmpname);
- /* OK now lets see if it really worked */
- if (((ret = machdep_sys_getpeername(fd_table[fd]->fd.i,
-! &tmpname, &tmpnamelen)) < OK) && (ret == -ENOTCONN)) {
-
- /* Get the error, this function should not fail */
- machdep_sys_getsockopt(fd_table[fd]->fd.i, SOL_SOCKET,
-! SO_ERROR, &pthread_run->error, &tmpnamelen);
- }
- } else {
- SET_ERRNO(-ret);
---- 1162,1180 ----
- tmpnamelen = sizeof(tmpname);
- /* OK now lets see if it really worked */
- if (((ret = machdep_sys_getpeername(fd_table[fd]->fd.i,
-! &tmpname, &tmpnamelen)) < OK)
-! && (ret == -ENOTCONN)) {
-
- /* Get the error, this function should not fail */
- machdep_sys_getsockopt(fd_table[fd]->fd.i, SOL_SOCKET,
-! SO_ERROR, &ret, &tmpnamelen);
-! SET_ERRNO(-ret);
-! ret = NOTOK;
-! } else {
-! if( ret < 0 ) {
-! SET_ERRNO(-ret);
-! ret = NOTOK;
-! }
- }
- } else {
- SET_ERRNO(-ret);
-***************
-*** 1133,1140 ****
- }
- }
- fd_unlock(fd, FD_RDWR);
-! }
-! return(ret);
- }
-
- #endif
---- 1182,1189 ----
- }
- }
- fd_unlock(fd, FD_RDWR);
-! }
-! return(ret);
- }
-
- #endif
-***************
-*** 1164,1170 ****
- } else {
- fd_unlock(fd, FD_RDWR);
- SET_ERRNO(-fd_kern);
-! return(fd_kern);
- }
- }
- fd_unlock(fd, FD_RDWR);
---- 1213,1219 ----
- } else {
- fd_unlock(fd, FD_RDWR);
- SET_ERRNO(-fd_kern);
-! return(NOTOK);
- }
- }
- fd_unlock(fd, FD_RDWR);
-***************
-*** 1198,1205 ****
- int ret;
-
- if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
-! ret = machdep_sys_listen(fd_table[fd]->fd.i, backlog);
-! if ((ret = machdep_sys_listen(fd_table[fd]->fd.i, backlog)) < OK) {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
---- 1247,1253 ----
- int ret;
-
- if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
-! if ((ret = machdep_sys_listen(fd_table[fd]->fd.i, backlog)) < OK) {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
-***************
-*** 1246,1252 ****
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- SET_ERRNO(ETIMEDOUT);
-! ret = -ETIMEDOUT;
- break;
- }
- pthread_sched_resume();
---- 1294,1300 ----
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- SET_ERRNO(ETIMEDOUT);
-! ret = NOTOK;
- break;
- }
- pthread_sched_resume();
-***************
-*** 1311,1317 ****
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- SET_ERRNO(ETIMEDOUT);
-! ret = -ETIMEDOUT;
- break;
- }
- pthread_sched_resume();
---- 1359,1365 ----
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- SET_ERRNO(ETIMEDOUT);
-! ret = NOTOK;
- break;
- }
- pthread_sched_resume();
-***************
-*** 1405,1411 ****
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- SET_ERRNO(ETIMEDOUT);
-! ret = -ETIMEDOUT;
- break;
- }
- pthread_sched_resume();
---- 1453,1459 ----
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- SET_ERRNO(ETIMEDOUT);
-! ret = NOTOK;
- break;
- }
- pthread_sched_resume();
-***************
-*** 1471,1477 ****
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- SET_ERRNO(ETIMEDOUT);
-! ret = -ETIMEDOUT;
- break;
- }
- pthread_sched_resume();
---- 1519,1525 ----
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- SET_ERRNO(ETIMEDOUT);
-! ret = NOTOK;
- break;
- }
- pthread_sched_resume();
-***************
-*** 1536,1542 ****
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- SET_ERRNO(ETIMEDOUT);
-! ret = -ETIMEDOUT;
- break;
- }
- pthread_sched_resume();
---- 1584,1590 ----
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- SET_ERRNO(ETIMEDOUT);
-! ret = NOTOK;
- break;
- }
- pthread_sched_resume();
-***************
-*** 1603,1609 ****
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- SET_ERRNO(ETIMEDOUT);
-! ret = -ETIMEDOUT;
- break;
- }
- pthread_sched_resume();
---- 1651,1657 ----
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- SET_ERRNO(ETIMEDOUT);
-! ret = NOTOK;
- break;
- }
- pthread_sched_resume();
-***************
-*** 1734,1744 ****
- */
- int getsockopt(int fd, int level, int optname, void * optval, int * optlen)
- {
-! int ret;
-
-! if ((ret = fd_lock(fd, FD_READ, NULL)) == OK) {
- if ((ret = machdep_sys_getsockopt(fd_table[fd]->fd.i, level,
-! optname, optval, optlen)) < OK) {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
---- 1782,1792 ----
- */
- int getsockopt(int fd, int level, int optname, void * optval, int * optlen)
- {
-! int ret;
-
-! if ((ret = fd_lock(fd, FD_READ, NULL)) == OK) {
- if ((ret = machdep_sys_getsockopt(fd_table[fd]->fd.i, level,
-! optname, optval, optlen)) < OK) {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
-***************
-*** 1756,1772 ****
- */
- int getsockname(int fd, struct sockaddr * name, int * naddrlen)
- {
-! int ret;
-
-! if ((ret = fd_lock(fd, FD_READ, NULL)) == OK) {
-! if ((ret = machdep_sys_getsockname(fd_table[fd]->fd.i,
-! name, naddrlen)) < OK) {
-! SET_ERRNO(-ret);
-! ret = NOTOK;
-! }
-! fd_unlock(fd, FD_RDWR);
-! }
-! return ret;
- }
-
- #endif
---- 1804,1820 ----
- */
- int getsockname(int fd, struct sockaddr * name, int * naddrlen)
- {
-! int ret;
-
-! if ((ret = fd_lock(fd, FD_READ, NULL)) == OK) {
-! if ((ret = machdep_sys_getsockname(fd_table[fd]->fd.i,
-! name, naddrlen)) < OK) {
-! SET_ERRNO(-ret);
-! ret = NOTOK;
-! }
-! fd_unlock(fd, FD_RDWR);
-! }
-! return ret;
- }
-
- #endif
-***************
-*** 1778,1793 ****
- */
- int getpeername(int fd, struct sockaddr * peer, int * paddrlen)
- {
-! int ret;
-
-! if ((ret = fd_lock(fd, FD_READ, NULL)) == OK) {
-! if ((ret = machdep_sys_getpeername(fd_table[fd]->fd.i,
-! peer, paddrlen)) < OK) {
- SET_ERRNO(-ret);
- ret = NOTOK;
-! }
-! fd_unlock(fd, FD_READ);
-! }
- return ret;
- }
-
---- 1826,1841 ----
- */
- int getpeername(int fd, struct sockaddr * peer, int * paddrlen)
- {
-! int ret;
-
-! if ((ret = fd_lock(fd, FD_READ, NULL)) == OK) {
-! if ((ret = machdep_sys_getpeername(fd_table[fd]->fd.i,
-! peer, paddrlen)) < OK) {
- SET_ERRNO(-ret);
- ret = NOTOK;
-! }
-! fd_unlock(fd, FD_READ);
-! }
- return ret;
- }
-
-=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/pthreads/pthread.c,v retrieving revision 1.1.1.1
-diff -c -r1.1.1.1 pthread.c
-*** pthread.c 1995/12/13 05:53:01 1.1.1.1
---- pthread.c 1996/10/01 21:42:01
-***************
-*** 129,134 ****
---- 129,160 ----
-
- }
-
-+ /*----------------------------------------------------------------------
-+ * Function: __pthread_is_valid
-+ * Purpose: Scan the list of threads to see if a specified thread exists
-+ * Args:
-+ * pthread = The thread to scan for
-+ * Returns:
-+ * int = 1 if found, 0 if not
-+ * Notes:
-+ * The kernel is assumed to be locked
-+ *----------------------------------------------------------------------*/
-+ int
-+ __pthread_is_valid( pthread_t pthread )
-+ {
-+ int rtn = 0; /* Assume not found */
-+ pthread_t t;
-+
-+ for( t = pthread_link_list; t; t = t->pll ) {
-+ if( t == pthread ) {
-+ rtn = 1; /* Found it */
-+ break;
-+ }
-+ }
-+
-+ return rtn;
-+ }
-+
- /* ==========================================================================
- * __pthread_free()
- */
-***************
-*** 242,247 ****
---- 268,277 ----
- new_thread->next = NULL;
- new_thread->flags = 0;
-
-+ /* PTHREADS spec says we start with cancellability on and deferred */
-+ SET_PF_CANCEL_STATE(new_thread, PTHREAD_CANCEL_ENABLE);
-+ SET_PF_CANCEL_TYPE(new_thread, PTHREAD_CANCEL_DEFERRED);
-+
- new_thread->error_p = NULL;
- new_thread->sll = NULL;
-
-***************
-*** 261,269 ****
- }
- return(retval);
- }
--
-- /* ==========================================================================
-- * pthread_cancel()
-- *
-- * This routine will also require a sig_prevent/sig_check_and_resume()
-- */
---- 291,293 ----
-=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/pthreads/pthread_init.c,v retrieving revision 1.1.1.1
-diff -c -r1.1.1.1 pthread_init.c
-*** pthread_init.c 1996/03/13 04:33:10 1.1.1.1
---- pthread_init.c 1996/10/01 21:43:59
-***************
-*** 92,99 ****
- pthread_initial->next = NULL;
- pthread_initial->flags = 0;
- pthread_initial->pll = NULL;
-- pthread_initial->flags = 0;
- pthread_initial->sll = NULL;
-
- /* Ugly errno hack */
- pthread_initial->error_p = &errno;
---- 92,103 ----
- pthread_initial->next = NULL;
- pthread_initial->flags = 0;
- pthread_initial->pll = NULL;
- pthread_initial->sll = NULL;
-+
-+ /* PTHREADS spec says we start with cancellability on and deferred */
-+ SET_PF_CANCEL_STATE(pthread_initial, PTHREAD_CANCEL_ENABLE);
-+ SET_PF_CANCEL_TYPE(pthread_initial, PTHREAD_CANCEL_DEFERRED);
-+
-
- /* Ugly errno hack */
- pthread_initial->error_p = &errno;
-=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/pthreads/pthread_join.c,v retrieving revision 1.1.1.1
-diff -c -r1.1.1.1 pthread_join.c
-*** pthread_join.c 1995/12/13 05:53:07 1.1.1.1
---- pthread_join.c 1996/10/02 16:54:36
-***************
-*** 42,47 ****
---- 42,49 ----
- #include <pthread.h>
- #include <errno.h>
-
-+ static int testDeadlock( struct pthread_queue *queue, pthread_t target );
-+
- /* ==========================================================================
- * pthread_join()
- */
-***************
-*** 51,56 ****
---- 53,64 ----
-
- pthread_sched_prevent();
-
-+ /* Ensure they gave us a legal pthread pointer */
-+ if( ! __pthread_is_valid( pthread ) ) {
-+ pthread_sched_resume();
-+ return(EINVAL);
-+ }
-+
- /* Check that thread isn't detached already */
- if (pthread->attr.flags & PTHREAD_DETACHED) {
- pthread_sched_resume();
-***************
-*** 62,81 ****
- * Note: This must happen after checking detached state.
- */
- if (pthread_queue_remove(&pthread_dead_queue, pthread) != OK) {
-! pthread_queue_enq(&(pthread->join_queue), pthread_run);
-! pthread_resched_resume(PS_JOIN);
-! pthread_sched_prevent();
-!
-! if (pthread_queue_remove(&pthread_dead_queue, pthread) == OK) {
-! pthread_queue_enq(&pthread_alloc_queue, pthread);
-! pthread->attr.flags |= PTHREAD_DETACHED;
-! pthread->state = PS_UNALLOCED;
-! if (thread_return) {
-! *thread_return = pthread->ret;
-! }
-! ret = OK;
- } else {
-! ret = ESRCH;
- }
- } else {
- /* Just get the return value and detach the thread */
---- 70,98 ----
- * Note: This must happen after checking detached state.
- */
- if (pthread_queue_remove(&pthread_dead_queue, pthread) != OK) {
-!
-! /* Before we pend on the join, ensure there is no dead lock */
-!
-! if( testDeadlock( &pthread_run->join_queue, pthread ) == NOTOK ) {
-! ret = EDEADLK;
- } else {
-! pthread_queue_enq(&(pthread->join_queue), pthread_run);
-! SET_PF_AT_CANCEL_POINT(pthread_run); /* This is a cancel point */
-! pthread_resched_resume(PS_JOIN);
-! CLEAR_PF_AT_CANCEL_POINT(pthread_run); /* No longer at cancel point */
-! pthread_sched_prevent();
-!
-! if (pthread_queue_remove(&pthread_dead_queue, pthread) == OK) {
-! pthread_queue_enq(&pthread_alloc_queue, pthread);
-! pthread->attr.flags |= PTHREAD_DETACHED;
-! pthread->state = PS_UNALLOCED;
-! if (thread_return) {
-! *thread_return = pthread->ret;
-! }
-! ret = OK;
-! } else {
-! ret = ESRCH;
-! }
- }
- } else {
- /* Just get the return value and detach the thread */
-***************
-*** 89,92 ****
---- 106,139 ----
- }
- pthread_sched_resume();
- return(ret);
-+ }
-+
-+ /*----------------------------------------------------------------------
-+ * Function: testDeadlock
-+ * Purpose: recursive queue walk to check for deadlocks
-+ * Args:
-+ * queue = the queue to walk
-+ * pthread = target to scan for
-+ * Returns:
-+ * OK = no deadlock, NOTOK = deadlock
-+ * Notes:
-+ *----------------------------------------------------------------------*/
-+ static int
-+ testDeadlock( struct pthread_queue *queue, pthread_t target )
-+ {
-+ pthread_t t;
-+
-+ if( queue == NULL )
-+ return OK; /* Empty queue, obviously ok */
-+
-+ for( t = queue->q_next; t; t = t->next ) {
-+ if( t == target )
-+ return NOTOK; /* bang, your dead */
-+
-+ if( testDeadlock( &t->join_queue, target ) == NOTOK ) {
-+ return NOTOK;
-+ }
-+ }
-+
-+ return OK; /* No deadlock */
- }
-=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/pthreads/select.c,v retrieving revision 1.1.1.1
-diff -c -r1.1.1.1 select.c
-*** select.c 1996/03/05 08:29:14 1.1.1.1
---- select.c 1996/10/02 16:56:27
-***************
-*** 56,220 ****
- int select(int numfds, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds, struct timeval *timeout)
- {
-! fd_set real_exceptfds, real_readfds, real_writefds; /* mapped fd_sets */
-! fd_set * real_readfds_p, * real_writefds_p, * real_exceptfds_p;
-! fd_set read_locks, write_locks, rdwr_locks;
-! struct timespec timeout_time, current_time;
-! struct timeval zero_timeout = { 0, 0 };
-! int i, j, ret = 0, got_all_locks = 1;
-! struct pthread_select_data data;
-!
-! if (numfds > dtablesize) {
-! numfds = dtablesize;
-! }
-!
-! data.nfds = 0;
-! FD_ZERO(&data.readfds);
-! FD_ZERO(&data.writefds);
-! FD_ZERO(&data.exceptfds);
-
-! /* Do this first */
-! if (timeout) {
- machdep_gettimeofday(&current_time);
-! timeout_time.tv_sec = current_time.tv_sec + timeout->tv_sec;
-! if ((timeout_time.tv_nsec = current_time.tv_nsec +
-! (timeout->tv_usec * 1000)) > 1000000000) {
-! timeout_time.tv_nsec -= 1000000000;
-! timeout_time.tv_sec++;
-! }
-! }
-!
-! FD_ZERO(&read_locks);
-! FD_ZERO(&write_locks);
-! FD_ZERO(&rdwr_locks);
-! FD_ZERO(&real_readfds);
-! FD_ZERO(&real_writefds);
-! FD_ZERO(&real_exceptfds);
-!
-! /* lock readfds */
-! if (readfds || writefds || exceptfds) {
-! for (i = 0; i < numfds; i++) {
-! if ((readfds && (FD_ISSET(i, readfds))) ||
-! (exceptfds && FD_ISSET(i, exceptfds))) {
-! if (writefds && FD_ISSET(i ,writefds)) {
-! if ((ret = fd_lock(i, FD_RDWR, NULL)) != OK) {
-! got_all_locks = 0;
-! break;
-! }
-! FD_SET(i, &rdwr_locks);
-! FD_SET(fd_table[i]->fd.i,&real_writefds);
-! } else {
-! if ((ret = fd_lock(i, FD_READ, NULL)) != OK) {
-! got_all_locks = 0;
-! break;
-! }
-! FD_SET(i, &read_locks);
-! }
-! if (readfds && FD_ISSET(i,readfds)) {
-! FD_SET(fd_table[i]->fd.i, &real_readfds);
-! }
-! if (exceptfds && FD_ISSET(i,exceptfds)) {
-! FD_SET(fd_table[i]->fd.i, &real_exceptfds);
-! }
-! if (fd_table[i]->fd.i >= data.nfds) {
-! data.nfds = fd_table[i]->fd.i + 1;
-! }
-! } else {
-! if (writefds && FD_ISSET(i, writefds)) {
-! if ((ret = fd_lock(i, FD_WRITE, NULL)) != OK) {
-! got_all_locks = 0;
-! break;
-! }
-! FD_SET(i, &write_locks);
-! FD_SET(fd_table[i]->fd.i,&real_writefds);
-! }
-! if (fd_table[i]->fd.i >= data.nfds) {
-! data.nfds = fd_table[i]->fd.i + 1;
-! }
-! }
-! }
-! }
-!
-! if (got_all_locks) {
-!
-! memcpy(&data.readfds,&real_readfds,sizeof(fd_set));
-! memcpy(&data.writefds,&real_writefds,sizeof(fd_set));
-! memcpy(&data.exceptfds,&real_exceptfds,sizeof(fd_set));
-!
-! real_readfds_p = (readfds == NULL) ? NULL : &real_readfds;
-! real_writefds_p = (writefds == NULL) ? NULL : &real_writefds;
-! real_exceptfds_p = (exceptfds == NULL) ? NULL : &real_exceptfds;
-!
-! if ((ret = machdep_sys_select(data.nfds, real_readfds_p,
-! real_writefds_p, real_exceptfds_p, &zero_timeout)) == OK) {
-!
-! pthread_sched_prevent();
-!
-! real_exceptfds_p = (exceptfds == NULL) ? NULL : &data.exceptfds;
-! real_writefds_p = (writefds == NULL) ? NULL : &data.writefds;
-! real_readfds_p = (readfds == NULL) ? NULL : &data.readfds;
-!
-! pthread_queue_enq(&fd_wait_select, pthread_run);
-! pthread_run->data.select_data = &data;
-! SET_PF_WAIT_EVENT(pthread_run);
-!
-! if (timeout) {
-! machdep_gettimeofday(&current_time);
-! sleep_schedule(&current_time, &timeout_time);
-!
-! pthread_resched_resume(PS_SELECT_WAIT);
-!
-! /* We're awake */
-! CLEAR_PF_DONE_EVENT(pthread_run);
-! if (sleep_cancel(pthread_run) == NOTOK) {
-! ret = OK;
-! } else {
-! ret = data.nfds;
-! }
-! } else {
-! pthread_resched_resume(PS_SELECT_WAIT);
-! CLEAR_PF_DONE_EVENT(pthread_run);
-! ret = data.nfds; /* XXX ??? snl */
-! }
-! } else if (ret < 0) {
-! SET_ERRNO(-ret);
-! ret = NOTOK;
-! }
-! }
-!
-! /* clean up the locks */
-! for (i = 0; i < numfds; i++)
-! if (FD_ISSET(i,&read_locks)) fd_unlock(i,FD_READ);
-! for (i = 0; i < numfds; i++)
-! if (FD_ISSET(i,&rdwr_locks)) fd_unlock(i,FD_RDWR);
-! for (i = 0; i < numfds; i++)
-! if (FD_ISSET(i,&write_locks)) fd_unlock(i,FD_WRITE);
-!
-! if (ret > 0) {
-! if (readfds != NULL) {
-! for (i = 0; i < numfds; i++) {
-! if (! (FD_ISSET(i,readfds) &&
-! FD_ISSET(fd_table[i]->fd.i,real_readfds_p)))
-! FD_CLR(i,readfds);
-! }
-! }
-! if (writefds != NULL) {
-! for (i = 0; i < numfds; i++)
-! if (! (FD_ISSET(i,writefds) &&
-! FD_ISSET(fd_table[i]->fd.i,real_writefds_p)))
-! FD_CLR(i,writefds);
-! }
-! if (exceptfds != NULL) {
-! for (i = 0; i < numfds; i++)
-! if (! (FD_ISSET(i,exceptfds) &&
-! FD_ISSET(fd_table[i]->fd.i,real_exceptfds_p)))
-! FD_CLR(i,exceptfds);
-! }
-! } else {
-! if (exceptfds != NULL) FD_ZERO(exceptfds);
-! if (writefds != NULL) FD_ZERO(writefds);
-! if (readfds != NULL) FD_ZERO(readfds);
- }
-
-! return(ret);
- }
---- 56,223 ----
- int select(int numfds, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds, struct timeval *timeout)
- {
-! fd_set real_exceptfds, real_readfds, real_writefds; /* mapped fd_sets */
-! fd_set * real_readfds_p, * real_writefds_p, * real_exceptfds_p;
-! fd_set read_locks, write_locks, rdwr_locks;
-! struct timespec timeout_time, current_time;
-! struct timeval zero_timeout = { 0, 0 };
-! int i, j, ret = 0, got_all_locks = 1;
-! struct pthread_select_data data;
-!
-! if (numfds > dtablesize) {
-! numfds = dtablesize;
-! }
-!
-! data.nfds = 0;
-! FD_ZERO(&data.readfds);
-! FD_ZERO(&data.writefds);
-! FD_ZERO(&data.exceptfds);
-!
-! /* Do this first */
-! if (timeout) {
-! machdep_gettimeofday(&current_time);
-! timeout_time.tv_sec = current_time.tv_sec + timeout->tv_sec;
-! if ((timeout_time.tv_nsec = current_time.tv_nsec +
-! (timeout->tv_usec * 1000)) > 1000000000) {
-! timeout_time.tv_nsec -= 1000000000;
-! timeout_time.tv_sec++;
-! }
-! }
-!
-! FD_ZERO(&read_locks);
-! FD_ZERO(&write_locks);
-! FD_ZERO(&rdwr_locks);
-! FD_ZERO(&real_readfds);
-! FD_ZERO(&real_writefds);
-! FD_ZERO(&real_exceptfds);
-!
-! /* lock readfds */
-! if (readfds || writefds || exceptfds) {
-! for (i = 0; i < numfds; i++) {
-! if ((readfds && (FD_ISSET(i, readfds))) ||
-! (exceptfds && FD_ISSET(i, exceptfds))) {
-! if (writefds && FD_ISSET(i ,writefds)) {
-! if ((ret = fd_lock(i, FD_RDWR, NULL)) != OK) {
-! got_all_locks = 0;
-! break;
-! }
-! FD_SET(i, &rdwr_locks);
-! FD_SET(fd_table[i]->fd.i,&real_writefds);
-! } else {
-! if ((ret = fd_lock(i, FD_READ, NULL)) != OK) {
-! got_all_locks = 0;
-! break;
-! }
-! FD_SET(i, &read_locks);
-! }
-! if (readfds && FD_ISSET(i,readfds)) {
-! FD_SET(fd_table[i]->fd.i, &real_readfds);
-! }
-! if (exceptfds && FD_ISSET(i,exceptfds)) {
-! FD_SET(fd_table[i]->fd.i, &real_exceptfds);
-! }
-! if (fd_table[i]->fd.i >= data.nfds) {
-! data.nfds = fd_table[i]->fd.i + 1;
-! }
-! } else {
-! if (writefds && FD_ISSET(i, writefds)) {
-! if ((ret = fd_lock(i, FD_WRITE, NULL)) != OK) {
-! got_all_locks = 0;
-! break;
-! }
-! FD_SET(i, &write_locks);
-! FD_SET(fd_table[i]->fd.i,&real_writefds);
-! if (fd_table[i]->fd.i >= data.nfds) {
-! data.nfds = fd_table[i]->fd.i + 1;
-! }
-! }
-! }
-! }
-! }
-!
-! if (got_all_locks) {
-! memcpy(&data.readfds,&real_readfds,sizeof(fd_set));
-! memcpy(&data.writefds,&real_writefds,sizeof(fd_set));
-! memcpy(&data.exceptfds,&real_exceptfds,sizeof(fd_set));
-!
-! real_readfds_p = (readfds == NULL) ? NULL : &real_readfds;
-! real_writefds_p = (writefds == NULL) ? NULL : &real_writefds;
-! real_exceptfds_p = (exceptfds == NULL) ? NULL : &real_exceptfds;
-!
-! if ((ret = machdep_sys_select(data.nfds, real_readfds_p,
-! real_writefds_p, real_exceptfds_p,
-! &zero_timeout)) == OK) {
-! pthread_sched_prevent();
-!
-! real_exceptfds_p = (exceptfds == NULL) ? NULL : &data.exceptfds;
-! real_writefds_p = (writefds == NULL) ? NULL : &data.writefds;
-! real_readfds_p = (readfds == NULL) ? NULL : &data.readfds;
-!
-! pthread_queue_enq(&fd_wait_select, pthread_run);
-! pthread_run->data.select_data = &data;
-! SET_PF_WAIT_EVENT(pthread_run);
-
-! if (timeout) {
- machdep_gettimeofday(&current_time);
-! sleep_schedule(&current_time, &timeout_time);
-!
-! SET_PF_AT_CANCEL_POINT(pthread_run);
-! pthread_resched_resume(PS_SELECT_WAIT);
-! CLEAR_PF_AT_CANCEL_POINT(pthread_run);
-!
-! /* We're awake */
-! CLEAR_PF_DONE_EVENT(pthread_run);
-! if (sleep_cancel(pthread_run) == NOTOK) {
-! ret = OK;
-! } else {
-! ret = data.nfds;
-! }
-! } else {
-! SET_PF_AT_CANCEL_POINT(pthread_run);
-! pthread_resched_resume(PS_SELECT_WAIT);
-! CLEAR_PF_AT_CANCEL_POINT(pthread_run);
-! CLEAR_PF_DONE_EVENT(pthread_run);
-! ret = data.nfds; /* XXX ??? snl */
-! }
-! } else if (ret < 0) {
-! SET_ERRNO(-ret);
-! ret = NOTOK;
-! }
-! }
-!
-! /* clean up the locks */
-! for (i = 0; i < numfds; i++)
-! if (FD_ISSET(i,&read_locks)) fd_unlock(i,FD_READ);
-! for (i = 0; i < numfds; i++)
-! if (FD_ISSET(i,&rdwr_locks)) fd_unlock(i,FD_RDWR);
-! for (i = 0; i < numfds; i++)
-! if (FD_ISSET(i,&write_locks)) fd_unlock(i,FD_WRITE);
-!
-! if (ret > 0) {
-! if (readfds != NULL) {
-! for (i = 0; i < numfds; i++) {
-! if (! (FD_ISSET(i,readfds) &&
-! FD_ISSET(fd_table[i]->fd.i,real_readfds_p)))
-! FD_CLR(i,readfds);
-! }
-! }
-! if (writefds != NULL) {
-! for (i = 0; i < numfds; i++)
-! if (! (FD_ISSET(i,writefds) &&
-! FD_ISSET(fd_table[i]->fd.i,real_writefds_p)))
-! FD_CLR(i,writefds);
-! }
-! if (exceptfds != NULL) {
-! for (i = 0; i < numfds; i++)
-! if (! (FD_ISSET(i,exceptfds) &&
-! FD_ISSET(fd_table[i]->fd.i,real_exceptfds_p)))
-! FD_CLR(i,exceptfds);
- }
-+ } else {
-+ if (exceptfds != NULL) FD_ZERO(exceptfds);
-+ if (writefds != NULL) FD_ZERO(writefds);
-+ if (readfds != NULL) FD_ZERO(readfds);
-+ }
-
-! return(ret);
- }
-=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/pthreads/sig.c,v retrieving revision 1.1.1.1
-diff -c -r1.1.1.1 sig.c
-*** sig.c 1996/03/13 04:33:13 1.1.1.1
---- sig.c 1996/10/03 01:07:54
-***************
-*** 301,307 ****
---- 301,310 ----
- pthread_run->data.sigwait = set;
- pthread_run->ret = sig;
-
-+ SET_PF_AT_CANCEL_POINT(pthread_run); /* This is a cancel point */
- pthread_resched_resume(PS_SIGWAIT);
-+ CLEAR_PF_AT_CANCEL_POINT(pthread_run); /* No longer at cancel point */
-+
- return(OK);
- }
-
-=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/pthreads/signal.c,v retrieving revision 1.1.1.1
-diff -c -r1.1.1.1 signal.c
-*** signal.c 1996/03/13 04:33:17 1.1.1.1
---- signal.c 1996/10/03 17:30:16
-***************
-*** 72,77 ****
---- 72,78 ----
-
- static void sig_handler(int signal);
- static void set_thread_timer();
-+ static void __cleanup_after_resume( void );
- void sig_prevent(void);
- void sig_resume(void);
-
-***************
-*** 482,502 ****
- }
- }
-
-! /* Only bother if we are truly unlocking the kernel */
-! while (!(--pthread_kernel_lock)) {
-! if (sig_to_process) {
-! /* if (SIG_ANY(sig_to_process)) { */
-! pthread_kernel_lock++;
-! sig_handler(0);
-! continue;
-! }
-! if (pthread_run && pthread_run->sigcount) {
-! pthread_kernel_lock++;
-! pthread_sig_process();
-! continue;
-! }
-! break;
-! }
- }
-
- /* ==========================================================================
---- 483,489 ----
- }
- }
-
-! __cleanup_after_resume();
- }
-
- /* ==========================================================================
-***************
-*** 508,530 ****
- void pthread_resched_resume(enum pthread_state state)
- {
- pthread_run->state = state;
-- sig_handler(SIGVTALRM);
-
-! /* Only bother if we are truely unlocking the kernel */
-! while (!(--pthread_kernel_lock)) {
-! if (sig_to_process) {
-! /* if (SIG_ANY(sig_to_process)) { */
-! pthread_kernel_lock++;
-! sig_handler(0);
-! continue;
-! }
-! if (pthread_run && pthread_run->sigcount) {
-! pthread_kernel_lock++;
-! pthread_sig_process();
-! continue;
-! }
-! break;
- }
- }
-
- /* ==========================================================================
---- 495,523 ----
- void pthread_resched_resume(enum pthread_state state)
- {
- pthread_run->state = state;
-
-! /* Since we are about to block this thread, lets see if we are
-! * at a cancel point and if we've been cancelled.
-! * Avoid cancelling dead or unalloced threads.
-! */
-! if( ! TEST_PF_RUNNING_TO_CANCEL(pthread_run) &&
-! TEST_PTHREAD_IS_CANCELLABLE(pthread_run) &&
-! state != PS_DEAD && state != PS_UNALLOCED ) {
-!
-! /* Set this flag to avoid recursively calling pthread_exit */
-! /* We have to set this flag here because we will unlock the
-! * kernel prior to calling pthread_cancel_internal.
-! */
-! SET_PF_RUNNING_TO_CANCEL(pthread_run);
-!
-! pthread_run->old_state = state; /* unlock needs this data */
-! pthread_sched_resume(); /* Unlock kernel before cancel */
-! pthread_cancel_internal( 1 ); /* free locks and exit */
- }
-+
-+ sig_handler(SIGVTALRM);
-+
-+ __cleanup_after_resume();
- }
-
- /* ==========================================================================
-***************
-*** 532,537 ****
---- 525,543 ----
- */
- void pthread_sched_resume()
- {
-+ __cleanup_after_resume();
-+ }
-+
-+ /*----------------------------------------------------------------------
-+ * Function: __cleanup_after_resume
-+ * Purpose: cleanup kernel locks after a resume
-+ * Args: void
-+ * Returns: void
-+ * Notes:
-+ *----------------------------------------------------------------------*/
-+ static void
-+ __cleanup_after_resume( void )
-+ {
- /* Only bother if we are truely unlocking the kernel */
- while (!(--pthread_kernel_lock)) {
- /* if (SIG_ANY(sig_to_process)) { */
-***************
-*** 546,551 ****
---- 552,568 ----
- continue;
- }
- break;
-+ }
-+
-+ if( pthread_run == NULL )
-+ return; /* Must be during init processing */
-+
-+ /* Test for cancel that should be handled now */
-+
-+ if( ! TEST_PF_RUNNING_TO_CANCEL(pthread_run) &&
-+ TEST_PTHREAD_IS_CANCELLABLE(pthread_run) ) {
-+ /* Kernel is already unlocked */
-+ pthread_cancel_internal( 1 ); /* free locks and exit */
- }
- }
-
-=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/pthreads/sleep.c,v retrieving revision 1.1.1.1
-diff -c -r1.1.1.1 sleep.c
-*** sleep.c 1996/03/11 08:33:32 1.1.1.1
---- sleep.c 1996/10/03 01:14:58
-***************
-*** 249,255 ****
---- 249,257 ----
-
- /* Reschedule thread */
- SET_PF_WAIT_EVENT(pthread_run);
-+ SET_PF_AT_CANCEL_POINT(pthread_run); /* This is a cancel point */
- pthread_resched_resume(PS_SLEEP_WAIT);
-+ CLEAR_PF_AT_CANCEL_POINT(pthread_run); /* No longer at cancel point */
- CLEAR_PF_DONE_EVENT(pthread_run);
-
- /* Return actual time slept */
-***************
-*** 332,338 ****
- current_time.tv_sec++;
- }
- machdep_start_timer(&(current_time),
-! &(pthread_sleep->wakeup_time));
- }
- } else {
- for (pthread_last = pthread_sleep; pthread_last;
---- 334,340 ----
- current_time.tv_sec++;
- }
- machdep_start_timer(&(current_time),
-! &(pthread_sleep->wakeup_time));
- }
- } else {
- for (pthread_last = pthread_sleep; pthread_last;
-=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/pthreads/stat.c,v retrieving revision 1.1.1.1
-diff -c -r1.1.1.1 stat.c
-*** stat.c 1995/09/21 02:36:05 1.1.1.1
---- stat.c 1996/06/04 19:17:33
-***************
-*** 43,48 ****
---- 43,49 ----
- #include <errno.h>
-
- struct stat;
-+ struct statfs;
-
- /* ==========================================================================
- * fstat()
-***************
-*** 91,95 ****
---- 92,115 ----
- }
- return(ret);
-
-+ }
-+
-+ /* ==========================================================================
-+ * fstatfs()
-+ *
-+ * Might want to indirect this.
-+ */
-+ int fstatfs(int fd, struct statfs *buf)
-+ {
-+ int ret;
-+
-+ if ((ret = fd_lock(fd, FD_READ, NULL)) == OK) {
-+ if ((ret = machdep_sys_fstatfs(fd_table[fd]->fd.i, buf)) < OK) {
-+ SET_ERRNO(-ret);
-+ ret = NOTOK;
-+ }
-+ fd_unlock(fd, FD_READ);
-+ }
-+ return(ret);
- }
-
-=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/pthreads/wait.c,v retrieving revision 1.1.1.1
-diff -c -r1.1.1.1 wait.c
-*** wait.c 1995/02/21 08:07:24 1.1.1.1
---- wait.c 1996/10/03 01:20:02
-***************
-*** 103,109 ****
---- 103,111 ----
- pthread_queue_enq(&wait_queue, pthread_run);
-
- /* reschedule unlocks scheduler */
-+ SET_PF_AT_CANCEL_POINT(pthread_run); /* This is a cancel point */
- pthread_resched_resume(PS_WAIT_WAIT);
-+ CLEAR_PF_AT_CANCEL_POINT(pthread_run); /* No longer at cancel point */
-
- pthread_sched_prevent();
- }
-***************
-*** 126,132 ****
---- 128,136 ----
- pthread_queue_enq(&wait_queue, pthread_run);
-
- /* reschedule unlocks scheduler */
-+ SET_PF_AT_CANCEL_POINT(pthread_run); /* This is a cancel point */
- pthread_resched_resume(PS_WAIT_WAIT);
-+ CLEAR_PF_AT_CANCEL_POINT(pthread_run); /* No longer at cancel point */
-
- pthread_sched_prevent();
- }
-<pre><font size=-1>
diff --git a/lib/libpthread/patches/Streepy2.html b/lib/libpthread/patches/Streepy2.html
deleted file mode 100755
index 80d44d6440c..00000000000
--- a/lib/libpthread/patches/Streepy2.html
+++ /dev/null
@@ -1,93 +0,0 @@
-<html>
-<head>
- <title>Diffs on diffs :-) by Larry V. Streepy, Jr.</title>
- <base target=_top>
- <meta name="GENERATOR" content="FindMail Communications">
- <meta name="Date" content="Monday, October 07, 1996 02:03 PM PST">
- <meta name="Author" content="Larry V. Streepy, Jr.">
-</head>
-<body background="/gifs/betafm.gif" bgcolor="#ffffff" text="#000000" link="#0000ee" vlink="#ff0000" alink="#000099">
-<h3>Diffs on diffs :-)</h3>
-Larry V. Streepy, Jr. (<a href="mailto.html?mid=2079859748&num=398" target="_top">@healthcare.com</a>)<br>Monday, October 07, 1996 02:03 PM PST<br>
-<p>
-This is a multi-part message in MIME format.<p>
---------------65BE18E23639BCDD7BE55F7F <br>
-Content-Type: text/plain; charset=us-ascii <br>
-Content-Transfer-Encoding: 7bit<p>
-Unfortunately, there are a couple of bugs in my pthread_cancel support (no, say it isn't so :-)<p>
-Oh well, I cam across a couple of cases that I missed in my testing last week. Here are the bugs:<p>
-1. If a thread calls pthread_testcancel during it's cleanup processing after being cancelled, the pthread kernel would hang.<p>
-2. I didn't realize that threads in PS_SLEEP_WAIT state are *NOT* on any queue, they are handled using a linked list. So, when cancelling a thread that was sleeping, a PANIC() I put in possiblymakeRunnable would go off.<p>
-Both of these are fixed. The diffs are attached.<br>
--- <br>
-Larry V. Streepy, Jr. <br>
-Chief Technical Officer, Healthcare Communications, Inc. mailto:<a href="mailto.html?mid=2079859748&num=398" target="_top">@healthcare.com</a> <br>
-(214) 851-7033 (Dallas Main #) <br>
-(970) 626-5028 (My office #) (970) 626-4425 (Fax)<p>
---------------65BE18E23639BCDD7BE55F7F <br>
-Content-Type: text/plain; charset=us-ascii; name=&#34;cancel.diffs&#34; Content-Transfer-Encoding: 7bit <br>
-Content-Disposition: inline; filename=&#34;cancel.diffs&#34;<p>
-Index: pthread_cancel.c<br>
-=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/pthreads/pthread_cancel.c,v retrieving revision 1.1 <br>
-diff -c -r1.1 pthread_cancel.c<br>
-*** pthread_cancel.c 1996/10/06 00:31:27 1.1<br>
---- pthread_cancel.c 1996/10/07 18:33:27<br>
-***************<br>
-*** 187,192 ****<br>
---- 187,197 ----<br>
- return; /* Can't be cancelled */<br>
- }<br>
- <br>
-+ /* Ensure that we aren't in the process of exiting already */<br>
-+ if( TEST_PF_RUNNING_TO_CANCEL(pthread_run) ) {<br>
-+ return;<br>
-+ }<br>
-+ <br>
- /* See if we have been cancelled */<br>
- if( TEST_PF_CANCELLED(pthread_run) ) {<br>
- /* Set this flag to avoid recursively calling pthread_exit */<br>
-***************<br>
-*** 266,277 ****<br>
- if( pthread-&gt;state == PS_RUNNING )<br>
- return; /* will happen at context switch */<br>
- <br>
-! /* Otherwise, we need to take it off the queue and make it runnable */<br>
-! if( pthread-&gt;queue == NULL ) {<br>
-! PANIC(); /* Must be on a queue */<br>
-! }<br>
- <br>
-- pthread_queue_remove(pthread-&gt;queue, pthread);<br>
- pthread_prio_queue_enq(pthread_current_prio_queue, pthread);<br>
- pthread-&gt;old_state = pthread-&gt;state;<br>
- pthread-&gt;state = PS_RUNNING;<br>
---- 271,291 ----<br>
- if( pthread-&gt;state == PS_RUNNING )<br>
- return; /* will happen at context switch */<br>
- <br>
-! /* If the thread is sleeping, the it isn't on a queue. */<br>
-! if( pthread-&gt;state == PS_SLEEP_WAIT ) {<br>
-! sleep_cancel( pthread ); /* Remove from sleep list */<br>
-! } else {<br>
-! /* Otherwise, we need to take it off the queue and make it runnable */<br>
-! <br>
-! if( pthread-&gt;queue == NULL ) {<br>
-! PANIC(); /* Must be on a queue */<br>
-! }<br>
-! <br>
-! pthread_queue_remove(pthread-&gt;queue, pthread);<br>
-! }<br>
-! <br>
-! /* And make it runnable */<br>
- <br>
- pthread_prio_queue_enq(pthread_current_prio_queue, pthread);<br>
- pthread-&gt;old_state = pthread-&gt;state;<br>
- pthread-&gt;state = PS_RUNNING;<p>
-<pre><font size=-1>
---------------65BE18E23639BCDD7BE55F7F--
-
-</pre><p></pre>
-<hr>
-<a href="http://www.findmail.com/" target="_top"><font size=-1>Powered by FindMail Communications</font><br></a>
-<br>Please email comments and suggestions to:<a href="/cgi-bin/comments.py" target="_top">comments@findmail.com</a>
-<br><font size=-3 color="#ffffff">xmlarchive</font>
-</body></html> \ No newline at end of file
diff --git a/lib/libpthread/patches/bill_lear b/lib/libpthread/patches/bill_lear
deleted file mode 100755
index f49b79c4272..00000000000
--- a/lib/libpthread/patches/bill_lear
+++ /dev/null
@@ -1,70 +0,0 @@
-From rael@dejanews.com Wed Jan 29 06:06:14 1997
-X-VM-v5-Data: ([nil nil nil t nil nil nil nil nil]
- ["1497" "Tue" "28" "January" "1997" "21:52:57" "-0600" "William S. Lear" "rael@dejanews.com" "<199701290352.VAA08678@homer.dejanews.com>" "53" "Patches for linux2.0" "^From:" nil nil "1" "1997012903:52:57" "Patches for linux2.0" nil nil]
- nil)
-Received: from MIT.EDU (PACIFIC-CARRIER-ANNEX.MIT.EDU [18.69.0.28])
- by analytik.analytikerna.se (8.8.4/8.8.4) with SMTP
- id GAA23245 for <monty@analytikerna.se>; Wed, 29 Jan 1997 06:06:12 +0100 (MET)
-Received: from host-205-238-143-2.dejanews.com by MIT.EDU with SMTP
- id AA25254; Tue, 28 Jan 97 22:53:08 EST
-Received: (from rael@localhost) by homer.dejanews.com (8.7.6/8.6.12) id VAA08678 for pthreads@mit.edu; Tue, 28 Jan 1997 21:52:57 -0600 (CST)
-Message-Id: <199701290352.VAA08678@homer.dejanews.com>
-Content-Length: 1496
-From: "William S. Lear" <rael@dejanews.com>
-To: pthreads@MIT.EDU
-Subject: Patches for linux2.0
-Date: Tue, 28 Jan 1997 21:52:57 -0600 (CST)
-
-
-The following are some patches I found necessary to run smoothly
-under linux2.0. The PTEST directory below refers to the original
-pthreads 1.60 beta 6 release. Of course, the '-O2' "fix" is not strictly
-needed.
-
-#============================================================
-# < pthreads-1_60beta6/config/configure
-# > PTEST/pthreads-1_60beta6/config/configure
-#------------------------------------------------------------
-642c642
-< CFLAGS="-g -O2"
----
-> CFLAGS="-g -O"
-1104,1106d1103
-< cat >> confdefs.h <<EOF
-< #define BSD_TM 1
-< EOF
-
-# Diff for:
-#============================================================
-# < pthreads-1_60beta6/config/config.h.in
-# > PTEST/pthreads-1_60beta6/config/config.h.in
-#------------------------------------------------------------
-3,8d2
-< /* Does the OS have tm needing bsd'ish initialization? */
-< #undef BSD_TM
-<
-< /* Does the OS already support struct timespec */
-< #undef _OS_HAS_TIMESPEC
-<
-
-# Diff for:
-#============================================================
-# < pthreads-1_60beta6/gen/ctime.c
-# > PTEST/pthreads-1_60beta6/gen/ctime.c
-#------------------------------------------------------------
-49c49
-< #include "config.h"
----
->
-
-# Diff for:
-#============================================================
-# < pthreads-1_60beta6/include/math.h
-# > PTEST/pthreads-1_60beta6/include/math.h
-#------------------------------------------------------------
-54d53
-< double hypot __P((double, double));
-
-
-Bill Lear (rael@dejanews.com)
-
diff --git a/lib/libpthread/patches/chris_demetriou b/lib/libpthread/patches/chris_demetriou
deleted file mode 100755
index 41d2dfefe82..00000000000
--- a/lib/libpthread/patches/chris_demetriou
+++ /dev/null
@@ -1,149 +0,0 @@
-From cgd@pa.dec.com Fri Aug 15 04:22:21 1997
-X-VM-v5-Data: ([nil nil nil nil nil nil nil nil nil]
- ["3982" "Thu" "14" "August" "1997" "18:57:55" "-0700" "Chris G. Demetriou" "cgd@pa.dec.com" "<15218.871610275@dnaunix.pa.dec.com>" "126" "patches to get 1.60 beta6 to build on ELF NetBSD/alpha systems" "^From:" nil nil "8" "1997081501:57:55" "patches to get 1.60 beta6 to build on ELF NetBSD/alpha systems" nil nil]
- nil)
-Received: from MIT.EDU (PACIFIC-CARRIER-ANNEX.MIT.EDU [18.69.0.28])
- by analytik.analytikerna.se (8.8.4/8.8.4) with SMTP
- id EAA10207 for <monty@analytikerna.se>; Fri, 15 Aug 1997 04:22:19 +0200 (MET DST)
-Received: from mail2.digital.com by MIT.EDU with SMTP
- id AA13470; Thu, 14 Aug 97 22:01:37 EDT
-Received: from dnaunix.pa.dec.com (dnaunix.pa.dec.com [16.4.208.21])
- by mail2.digital.com (8.7.5/UNX 1.5/1.0/WV) with SMTP id SAA15366;
- Thu, 14 Aug 1997 18:58:16 -0700 (PDT)
-Received: by dnaunix.pa.dec.com; id AA15044; Thu, 14 Aug 1997 18:57:56 -0700
-Message-Id: <15218.871610275@dnaunix.pa.dec.com>
-X-Mts: smtp
-Content-Length: 3981
-From: "Chris G. Demetriou" <cgd@pa.dec.com>
-Sender: cgd@pa.dec.com
-To: pthreads-bugs@MIT.EDU
-Cc: "Chris G. Demetriou" <cgd@pa.dec.com>, pthreads@MIT.EDU
-Subject: patches to get 1.60 beta6 to build on ELF NetBSD/alpha systems
-Date: Thu, 14 Aug 97 18:57:55 -0700
-
-Enclosed below are patches to pthreads 1.60 beta6 to build on
-current NetBSD/alpha systems (which use ELF). With these patches,
-pthreads passes 'make check.'
-
-As an aside, the test_switch test generates _340k_ of output ("a"
-for a while, then "ab" for a while) when run one the machine I was
-testing on. In my opinion, that's a ... bit excessive, especially
-since 'make check' has to be run interactively!
-
-
-
-chris
-============================================================================
-diff -rc pthreads-1_60_beta6.orig/config/Makefile.in pthreads-1_60_beta6/config/Makefile.in
-*** pthreads-1_60_beta6.orig/config/Makefile.in Thu Mar 21 20:29:54 1996
---- pthreads-1_60_beta6/config/Makefile.in Thu Aug 14 17:56:55 1997
-***************
-*** 29,35 ****
- # pathname for srcdir here, and live with it.
- srcdir = $(srctop)
-
-! beforeinstall:: install-dirs
-
- .include "${srcdir}/pthreads/Makefile.inc"
- .include "${srcdir}/stdlib/Makefile.inc"
---- 29,35 ----
- # pathname for srcdir here, and live with it.
- srcdir = $(srctop)
-
-! beforeinstall: install-dirs
-
- .include "${srcdir}/pthreads/Makefile.inc"
- .include "${srcdir}/stdlib/Makefile.inc"
-diff -rc pthreads-1_60_beta6.orig/machdep/syscall-alpha-netbsd-1.1.S pthreads-1_60_beta6/machdep/syscall-alpha-netbsd-1.1.S
-*** pthreads-1_60_beta6.orig/machdep/syscall-alpha-netbsd-1.1.S Wed Nov 13 13:03:28 1996
---- pthreads-1_60_beta6/machdep/syscall-alpha-netbsd-1.1.S Thu Aug 14 18:03:27 1997
-***************
-*** 35,54 ****
- .frame sp,0,ra ;\
- ldiq v0, CONCAT(SYS_,x) ;\
- CHMK() ;\
-! beq a3, 2f ;\
-! br gp, 1f ;\
-! 1: ;\
- /* Load gp so we can find cerror to jump to. */;\
- ldgp gp, 0(gp) ;\
-! jmp zero, machdep_cerror ;\
-! 2:
-
- #define XSYSCALL(x) SYSCALL(x) ; RET ; .end CONCAT(machdep_sys_,x)
-
- .globl machdep_cerror
- machdep_cerror:
-! br t0, 1f
-! 1:
- ldgp gp, 0(t0)
- stl v0, errno
- #if 0
---- 35,54 ----
- .frame sp,0,ra ;\
- ldiq v0, CONCAT(SYS_,x) ;\
- CHMK() ;\
-! beq a3, CONCAT(Lsys_noerr_,x) ;\
-! br gp, CONCAT(Lsys_err_,x) ;\
-! CONCAT(Lsys_err_,x): ;\
- /* Load gp so we can find cerror to jump to. */;\
- ldgp gp, 0(gp) ;\
-! jmp zero, machdep_cerror ;\
-! CONCAT(Lsys_noerr_,x):
-
- #define XSYSCALL(x) SYSCALL(x) ; RET ; .end CONCAT(machdep_sys_,x)
-
- .globl machdep_cerror
- machdep_cerror:
-! br t0, Lmachdep_cerror_setgp
-! Lmachdep_cerror_setgp:
- ldgp gp, 0(t0)
- stl v0, errno
- #if 0
-diff -rc pthreads-1_60_beta6.orig/machdep/syscall-template-alpha-netbsd-1.1.S pthreads-1_60_beta6/machdep/syscall-template-alpha-netbsd-1.1.S
-*** pthreads-1_60_beta6.orig/machdep/syscall-template-alpha-netbsd-1.1.S Mon Apr 22 23:15:42 1996
---- pthreads-1_60_beta6/machdep/syscall-template-alpha-netbsd-1.1.S Thu Aug 14 17:58:14 1997
-***************
-*** 31,43 ****
- .frame sp,0,ra ;\
- ldiq v0, SYS_##x ;\
- CHMK() ;\
-! beq a3, 2f ;\
-! br gp, 1f ;\
-! 1: ;\
- /* Load gp so we can find cerror to jump to. */;\
- ldgp gp, 0(gp) ;\
-! jmp zero, machdep_cerror ;\
-! 2:
-
- #define SIMPLE_SYSCALL(x) SYSCALL(x) ; ret ; .end machdep_sys_##x
-
---- 31,43 ----
- .frame sp,0,ra ;\
- ldiq v0, SYS_##x ;\
- CHMK() ;\
-! beq a3, Lsys_noerr_##x ;\
-! br gp, Lsys_err_##x ;\
-! Lsys_err_##x: ;\
- /* Load gp so we can find cerror to jump to. */;\
- ldgp gp, 0(gp) ;\
-! jmp zero, machdep_cerror ;\
-! Lsys_noerr_##x:
-
- #define SIMPLE_SYSCALL(x) SYSCALL(x) ; ret ; .end machdep_sys_##x
-
-diff -rc pthreads-1_60_beta6.orig/pthreads/process.c pthreads-1_60_beta6/pthreads/process.c
-*** pthreads-1_60_beta6.orig/pthreads/process.c Tue Nov 12 05:45:16 1996
---- pthreads-1_60_beta6/pthreads/process.c Thu Aug 14 18:12:49 1997
-***************
-*** 40,45 ****
---- 40,47 ----
- #include <stdarg.h>
- #include <unistd.h>
-
-+ extern void *alloca();
-+
- #ifndef lint
- static const char rcsid[] = "$Id: chris_demetriou,v 1.1 1998/07/21 13:22:22 peter Exp $";
- #endif
-
diff --git a/lib/libpthread/patches/mevans b/lib/libpthread/patches/mevans
deleted file mode 100755
index d5ff2f27610..00000000000
--- a/lib/libpthread/patches/mevans
+++ /dev/null
@@ -1,642 +0,0 @@
-=A0
-Attached are several patches for pthreads-1_60_beta6. The patches fall
-into 3 catagories:
-
- 1. Crashes and hangs.
- 2. Missing functionality (namely flock())
- 3. Use of POSIX reentrant safe routines.
-
-Most of the patches contain a comment as to why the change was made.
-The one major exception is to fd_kern.c at line 257 (unpatched). The
-change to that line is to fix a "hang" that prevents threads for
-scheduling for an hour if there is no external I/O event.
-
-I also include patches that modify several functions to use POSIX
-reentrant safe routines. I know that MIT pthreads implements routine
-like gethostbyname in a thread safe manner, but we're pretty, um, anal
-about trying to keep our code as portable as possible. By excluding
-using routines that are not reentrant safe according to the PTHREAD
-safe, it's easy for us to stub out the unsafe routines and catch
-non-compliant code. I almost left these patches out, but I'm hoping
-they'll be adopted. :-)
-
-WARNING: None of the MIT pthreads routines that convert floats/doubles
-between their native forms and strings are thread safe! (i.e printf,
-sprintf, fprintf, atod, strtod, etc) I have replacements, but I need to
-check with the author of the replacements and my employer.
-
-Mark Evans
-
-------------69CDAAF52A3566916F8ED01A0
-Content-Disposition: inline; filename="pthreads-1_60_beta6.patch"
-Content-Type: text/plain; charset=us-ascii; name="pthreads-1_60_beta6.patch"
-Content-Transfer-Encoding: 7bit
-
-diff -c -b -r -d -I .*$Id:.* pthreads-1_60_beta6/config/config.h.in pthreads-1_60_beta6+/config/config.h.in
-*** pthreads-1_60_beta6/config/config.h.in Thu Mar 21 21:30:04 1996
---- pthreads-1_60_beta6+/config/config.h.in Sat Mar 15 14:08:55 1997
-***************
-*** 137,142 ****
---- 137,145 ----
- /* Define if you have the syscall_ftruncate function. */
- #undef HAVE_SYSCALL_FTRUNCATE
-
-+ /* Define if you have the syscall_flock function. */
-+ #undef HAVE_SYSCALL_FLOCK
-+
- /* Define if you have the syscall_getdents function. */
- #undef HAVE_SYSCALL_GETDENTS
-
-diff -c -b -r -d -I .*$Id:.* pthreads-1_60_beta6/config/configure.in pthreads-1_60_beta6+/config/configure.in
-*** pthreads-1_60_beta6/config/configure.in Wed Nov 13 14:03:08 1996
---- pthreads-1_60_beta6+/config/configure.in Sat Mar 15 14:08:55 1997
-***************
-*** 241,247 ****
-
- PTHREADS_CHECK_SYSCALLS(open write read creat close fcntl lseek dup2 dup pipe
- fchmod fchown execve fstat lstat link unlink chdir chown chmod stat
-! rename select getdtablesize ioctl ftruncate
- dnl - signals
- sigsuspend sigaction sigpause sigprocmask ksigaction
- dnl - directory reading
---- 241,247 ----
-
- PTHREADS_CHECK_SYSCALLS(open write read creat close fcntl lseek dup2 dup pipe
- fchmod fchown execve fstat lstat link unlink chdir chown chmod stat
-! rename select getdtablesize ioctl ftruncate flock
- dnl - signals
- sigsuspend sigaction sigpause sigprocmask ksigaction
- dnl - directory reading
-diff -c -b -r -d -I .*$Id:.* pthreads-1_60_beta6/gen/directory.c pthreads-1_60_beta6+/gen/directory.c
-*** pthreads-1_60_beta6/gen/directory.c Sat May 20 10:55:34 1995
---- pthreads-1_60_beta6+/gen/directory.c Sat Mar 15 14:08:55 1997
-***************
-*** 251,262 ****
---- 251,266 ----
- /*
- * Seek to an entry in a directory.
- * _seekdir is in telldir.c so that it can share opaque data structures.
-+ *
-+ * Use the POSIX reentrant safe readdir_r to simplify varifying POSIX
-+ * thread-safe compliance.
- */
- void seekdir(DIR * dirp, long loc)
- {
- register struct ddloc ** prevlp;
- register struct ddloc * lp;
- struct dirent * dp;
-+ struct dirent de;
-
- pthread_mutex_lock (dirp->dd_lock);
- prevlp = (struct ddloc **)&(dirp->dd_ddloc);
-***************
-*** 277,283 ****
- dirp->dd_seek = lp->loc_seek;
- dirp->dd_loc = 0;
- while (dirp->dd_loc < lp->loc_loc) {
-! if (!(dp = readdir(dirp))) {
- *prevlp = lp->loc_next;
- break;
- }
---- 281,287 ----
- dirp->dd_seek = lp->loc_seek;
- dirp->dd_loc = 0;
- while (dirp->dd_loc < lp->loc_loc) {
-! if (readdir_r(dirp, &de, &dp)) {
- *prevlp = lp->loc_next;
- break;
- }
-diff -c -b -r -d -I .*$Id:.* pthreads-1_60_beta6/gen/getcwd.c pthreads-1_60_beta6+/gen/getcwd.c
-*** pthreads-1_60_beta6/gen/getcwd.c Sat Sep 2 17:39:30 1995
---- pthreads-1_60_beta6+/gen/getcwd.c Sat Mar 15 14:08:55 1997
-***************
-*** 50,67 ****
- (dp->d_name[0] == '.' && (dp->d_name[1] == '\0' || \
- dp->d_name[1] == '.' && dp->d_name[2] == '\0'))
-
- char *
- getcwd(pt, size)
- char *pt;
- size_t size;
- {
-- register struct dirent *dp;
- register DIR *dir;
- register dev_t dev;
- register ino_t ino;
- register int first;
- register char *bpt, *bup;
- struct stat s;
- dev_t root_dev;
- ino_t root_ino;
- size_t ptsize, upsize;
---- 50,71 ----
- (dp->d_name[0] == '.' && (dp->d_name[1] == '\0' || \
- dp->d_name[1] == '.' && dp->d_name[2] == '\0'))
-
-+ /* Only use reentrant safe routines to simplify varifying POSIX thread-safe
-+ * compliance. (mevans).
-+ */
- char *
- getcwd(pt, size)
- char *pt;
- size_t size;
- {
- register DIR *dir;
- register dev_t dev;
- register ino_t ino;
- register int first;
- register char *bpt, *bup;
- struct stat s;
-+ struct dirent *dp;
-+ struct dirent de;
- dev_t root_dev;
- ino_t root_ino;
- size_t ptsize, upsize;
-***************
-*** 166,179 ****
- save_errno = 0;
- if (s.st_dev == dev) {
- for (;;) {
-! if (!(dp = readdir(dir)))
- goto notfound;
- if (dp->d_fileno == ino)
- break;
- }
- } else
- for (;;) {
-! if (!(dp = readdir(dir)))
- goto notfound;
- if (ISDOT(dp))
- continue;
---- 170,183 ----
- save_errno = 0;
- if (s.st_dev == dev) {
- for (;;) {
-! if (readdir_r(dir, &de, &dp))
- goto notfound;
- if (dp->d_fileno == ino)
- break;
- }
- } else
- for (;;) {
-! if (readdir_r(dir, &de, &dp))
- goto notfound;
- if (ISDOT(dp))
- continue;
-diff -c -b -r -d -I .*$Id:.* pthreads-1_60_beta6/include/syslog.h pthreads-1_60_beta6+/include/syslog.h
-*** pthreads-1_60_beta6/include/syslog.h Mon Sep 26 21:26:29 1994
---- pthreads-1_60_beta6+/include/syslog.h Sat Mar 15 14:08:56 1997
-***************
-*** 9,14 ****
---- 9,16 ----
- #ifndef SYSLOG_H
- #define SYSLOG_H
-
-+ /* Added __[BEGIN/END]_DECLS so this file would work with C++. (mevans) */
-+ #include <sys/cdefs.h>
- #include <stdarg.h>
-
- /* Discipline: openlog(), closelog(), and setlogmask() are not thread-safe
-***************
-*** 84,95 ****
---- 86,101 ----
- #define LOG_NDELAY 0x08 /* don't delay open */
- #define LOG_NOWAIT 0x10 /* if forking to log on console, don't wait() */
-
-+ __BEGIN_DECLS
-+
- /* Syslogging functions. */
- void syslog(int pri, char *fmt, ...);
- void vsyslog(int pri, char *fmt, va_list args);
- void openlog(char *ident, int logstat, int logfac);
- void closelog(void);
- int setlogmask(int pmask);
-+
-+ __END_DECLS
-
- #endif
-
-diff -c -b -r -d -I .*$Id:.* pthreads-1_60_beta6/machdep/engine-i386-linux-1.0.c pthreads-1_60_beta6+/machdep/engine-i386-linux-1.0.c
-*** pthreads-1_60_beta6/machdep/engine-i386-linux-1.0.c Mon Oct 21 20:39:13 1996
---- pthreads-1_60_beta6+/machdep/engine-i386-linux-1.0.c Sat Mar 15 14:08:56 1997
-***************
-*** 142,147 ****
---- 142,149 ----
- * machdep_pthread_start().
- */
- machdep_pthread->machdep_state->__pc = (char *)machdep_pthread_start;
-+ machdep_pthread->machdep_state->__bp = (char *)0;/* So the backtrace
-+ * is sensible (mevans) */
-
- /* Stack starts high and builds down. */
- machdep_pthread->machdep_state->__sp =
-diff -c -b -r -d -I .*$Id:.* pthreads-1_60_beta6/machdep/syscall-i386-linux-1.0.S pthreads-1_60_beta6+/machdep/syscall-i386-linux-1.0.S
-*** pthreads-1_60_beta6/machdep/syscall-i386-linux-1.0.S Mon Oct 21 22:17:32 1996
---- pthreads-1_60_beta6+/machdep/syscall-i386-linux-1.0.S Sat Mar 15 14:08:56 1997
-***************
-*** 148,156 ****
- /* =========================================================================
- * exit 1 select 82
- * fork 2 socketcall 102
-! * read 3 readv 145
-! * write 4 writev 146
-! * open 5
- * creat 8
- * link 9
- * unlink 10
---- 148,156 ----
- /* =========================================================================
- * exit 1 select 82
- * fork 2 socketcall 102
-! * read 3 flock 143
-! * write 4 readv 145
-! * open 5 writev 146
- * creat 8
- * link 9
- * unlink 10
-***************
-*** 390,394 ****
---- 390,401 ----
- */
- #ifdef HAVE_SYSCALL_WRITEV
- SYSCALL3(writev)
-+ #endif
-+
-+ /* ==========================================================================
-+ * machdep_sys_flock()
-+ */
-+ #ifdef HAVE_SYSCALL_FLOCK
-+ SYSCALL2(flock)
- #endif
-
-diff -c -b -r -d -I .*$Id:.* pthreads-1_60_beta6/net/gethostbyname.c pthreads-1_60_beta6+/net/gethostbyname.c
-*** pthreads-1_60_beta6/net/gethostbyname.c Mon Apr 22 22:41:21 1996
---- pthreads-1_60_beta6+/net/gethostbyname.c Sat Mar 15 14:08:58 1997
-***************
-*** 146,161 ****
- {
- char **alias;
- FILE *fp = NULL;
-
- pthread_mutex_lock(&host_iterate_lock);
- sethostent(0);
-! while ((result = gethostent_r(result, buf, bufsize, errval)) != NULL) {
- /* Check the entry's name and aliases against the given name. */
- if (strcasecmp(result->h_name, name) == 0)
- break;
- for (alias = result->h_aliases; *alias; alias++) {
-! if (strcasecmp(*alias, name) == 0)
- break;
- }
- }
- pthread_mutex_unlock(&host_iterate_lock);
---- 146,166 ----
- {
- char **alias;
- FILE *fp = NULL;
-+ int fFound = FALSE;
-
- pthread_mutex_lock(&host_iterate_lock);
- sethostent(0);
-! while (!fFound && (result = gethostent_r(result, buf, bufsize, errval))
-! != NULL) {
- /* Check the entry's name and aliases against the given name. */
- if (strcasecmp(result->h_name, name) == 0)
- break;
- for (alias = result->h_aliases; *alias; alias++) {
-! if (strcasecmp(*alias, name) == 0) {
-! /* fFound will exit while loop. (mevans). */
-! fFound = TRUE;
- break;
-+ }
- }
- }
- pthread_mutex_unlock(&host_iterate_lock);
-diff -c -b -r -d -I .*$Id:.* pthreads-1_60_beta6/net/res_debug.c pthreads-1_60_beta6+/net/res_debug.c
-*** pthreads-1_60_beta6/net/res_debug.c Thu Feb 23 22:42:35 1995
---- pthreads-1_60_beta6+/net/res_debug.c Sat Mar 15 14:08:58 1997
-***************
-*** 375,380 ****
---- 375,383 ----
-
- /*
- * Print resource record fields in human readable form.
-+ *
-+ * Removed calls to non-reentrant routines to simplify varifying
-+ * POSIX thread-safe implementations. (mevans).
- */
- char *
- p_rr(cp, msg, file)
-***************
-*** 386,391 ****
---- 389,395 ----
- char *cp1, *cp2;
- u_long tmpttl, t;
- int lcnt;
-+ char buf[32];
-
- if ((cp = p_fqname(cp, msg, file)) == NULL)
- return (NULL); /* compression error */
-***************
-*** 413,426 ****
- case C_HS:
- bcopy(cp, (char *)&inaddr, sizeof(inaddr));
- if (dlen == 4) {
-! fprintf(file,"\t%s", inet_ntoa(inaddr));
- cp += dlen;
- } else if (dlen == 7) {
- char *address;
- u_char protocol;
- u_short port;
-
-! address = inet_ntoa(inaddr);
- cp += sizeof(inaddr);
- protocol = *(u_char*)cp;
- cp += sizeof(u_char);
---- 417,432 ----
- case C_HS:
- bcopy(cp, (char *)&inaddr, sizeof(inaddr));
- if (dlen == 4) {
-! fprintf(file,"\t%s",
-! inet_ntoa_r(inaddr, buf, sizeof(buf)));
- cp += dlen;
- } else if (dlen == 7) {
- char *address;
- u_char protocol;
- u_short port;
-
-! address = inet_ntoa_r(inaddr,
-! buf, sizeof(buf));
- cp += sizeof(inaddr);
- protocol = *(u_char*)cp;
- cp += sizeof(u_char);
-***************
-*** 524,530 ****
- bcopy(cp, (char *)&inaddr, sizeof(inaddr));
- cp += sizeof(u_long);
- fprintf(file, "\t%s %s ( ",
-! inet_ntoa(inaddr),
- deproto((int) *cp));
- cp += sizeof(u_char);
- n = 0;
---- 530,536 ----
- bcopy(cp, (char *)&inaddr, sizeof(inaddr));
- cp += sizeof(u_long);
- fprintf(file, "\t%s %s ( ",
-! inet_ntoa_r(inaddr, buf, sizeof(buf)),
- deproto((int) *cp));
- cp += sizeof(u_char);
- n = 0;
-diff -c -b -r -d -I .*$Id:.* pthreads-1_60_beta6/pthreads/fd_kern.c pthreads-1_60_beta6+/pthreads/fd_kern.c
-*** pthreads-1_60_beta6/pthreads/fd_kern.c Tue Oct 1 12:26:48 1996
---- pthreads-1_60_beta6+/pthreads/fd_kern.c Sat Mar 15 14:09:00 1997
-***************
-*** 215,221 ****
- * Called when there is no active thread to run.
- */
- extern struct timeval __fd_kern_wait_timeout;
-!
- void fd_kern_wait()
- {
- fd_set fd_set_read, fd_set_write, fd_set_except;
---- 215,221 ----
- * Called when there is no active thread to run.
- */
- extern struct timeval __fd_kern_wait_timeout;
-! extern volatile sig_atomic_t sig_to_process;
- void fd_kern_wait()
- {
- fd_set fd_set_read, fd_set_write, fd_set_except;
-***************
-*** 254,260 ****
-
- machdep_unset_thread_timer(NULL);
- __fd_kern_wait_timeout.tv_usec = 0;
-! __fd_kern_wait_timeout.tv_sec = 3600;
-
- machdep_sys_sigprocmask(SIG_UNBLOCK, &sig_to_block, &oset);
-
---- 254,260 ----
-
- machdep_unset_thread_timer(NULL);
- __fd_kern_wait_timeout.tv_usec = 0;
-! __fd_kern_wait_timeout.tv_sec = (sig_to_process) ? 0 : 3600;
-
- machdep_sys_sigprocmask(SIG_UNBLOCK, &sig_to_block, &oset);
-
-***************
-*** 726,731 ****
---- 726,753 ----
- return(ret);
- }
-
-+ #if defined (HAVE_SYSCALL_FLOCK)
-+ /* ==========================================================================
-+ * flock()
-+ *
-+ * Added (mevans)
-+ */
-+ int flock(int fd, int operation)
-+ {
-+ int ret;
-+
-+ if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
-+ if ((ret = machdep_sys_flock(fd_table[fd]->fd.i,
-+ operation)) < OK) {
-+ SET_ERRNO(-ret);
-+ ret = NOTOK;
-+ }
-+ fd_unlock(fd, FD_RDWR);
-+ }
-+ return(ret);
-+ }
-+ #endif
-+
- /* ==========================================================================
- * pipe()
- */
-***************
-*** 1126,1132 ****
- /* Get the error, this function should not fail */
- machdep_sys_getsockopt(fd_table[fd]->fd.i, SOL_SOCKET,
- SO_ERROR, &ret, &tmpnamelen);
-! SET_ERRNO(-ret);
- ret = NOTOK;
- }
- } else {
---- 1148,1155 ----
- /* Get the error, this function should not fail */
- machdep_sys_getsockopt(fd_table[fd]->fd.i, SOL_SOCKET,
- SO_ERROR, &ret, &tmpnamelen);
-! /* ret is already positive (mevans) */
-! SET_ERRNO(ret);
- ret = NOTOK;
- }
- } else {
-diff -c -b -r -d -I .*$Id:.* pthreads-1_60_beta6/pthreads/malloc.c pthreads-1_60_beta6+/pthreads/malloc.c
-*** pthreads-1_60_beta6/pthreads/malloc.c Thu Mar 9 21:06:43 1995
---- pthreads-1_60_beta6+/pthreads/malloc.c Sat Mar 15 14:09:00 1997
-***************
-*** 196,204 ****
- else
- n = n - x;
- if (n) {
-! if (sbrk(n) == (char *)-1)
- return (NULL);
- }
- bucket = 0;
- amt = 8;
- while (pagesz > amt) {
---- 196,207 ----
- else
- n = n - x;
- if (n) {
-! if (sbrk(n) == (char *)-1) {
-! /* Unlock before returning (mevans) */
-! pthread_mutex_unlock(mutex);
- return (NULL);
- }
-+ }
- bucket = 0;
- amt = 8;
- while (pagesz > amt) {
-***************
-*** 363,366 ****
---- 366,382 ----
- free(cp);
-
- return (res);
-+ }
-+ /* ==========================================================================
-+ * calloc()
-+ *
-+ * Added to ensure pthread's allocation is used (mevans).
-+ */
-+ void *calloc(size_t nmemb, size_t size)
-+ {
-+ void *p;
-+ size *= nmemb;
-+ p = malloc(size);
-+ if (p) memset(p, 0, size);
-+ return (p);
- }
-diff -c -b -r -d -I .*$Id:.* pthreads-1_60_beta6/pthreads/select.c pthreads-1_60_beta6+/pthreads/select.c
-*** pthreads-1_60_beta6/pthreads/select.c Sat Jul 6 21:58:55 1996
---- pthreads-1_60_beta6+/pthreads/select.c Sat Mar 15 14:09:00 1997
-***************
-*** 165,176 ****
- pthread_resched_resume(PS_SELECT_WAIT);
-
- /* We're awake */
-- CLEAR_PF_DONE_EVENT(pthread_run);
- if (sleep_cancel(pthread_run) == NOTOK) {
- ret = OK;
- } else {
- ret = data.nfds;
- }
- } else {
- pthread_resched_resume(PS_SELECT_WAIT);
- CLEAR_PF_DONE_EVENT(pthread_run);
---- 165,180 ----
- pthread_resched_resume(PS_SELECT_WAIT);
-
- /* We're awake */
- if (sleep_cancel(pthread_run) == NOTOK) {
- ret = OK;
- } else {
- ret = data.nfds;
- }
-+ /* Moving this after the sleep_cancel() seemed
-+ * to fix intermittent crashes during heavy
-+ * socket use. (mevans)
-+ */
-+ CLEAR_PF_DONE_EVENT(pthread_run);
- } else {
- pthread_resched_resume(PS_SELECT_WAIT);
- CLEAR_PF_DONE_EVENT(pthread_run);
-diff -c -b -r -d -I .*$Id:.* pthreads-1_60_beta6/pthreads/signal.c pthreads-1_60_beta6+/pthreads/signal.c
-*** pthreads-1_60_beta6/pthreads/signal.c Tue Mar 12 21:33:17 1996
---- pthreads-1_60_beta6+/pthreads/signal.c Sat Mar 15 14:09:00 1997
-***************
-*** 65,71 ****
- */
-
- static sig_atomic_t signum_to_process[SIGMAX + 1] = { 0, };
-! static sig_atomic_t sig_to_process = 0;
-
- /* static volatile sigset_t sig_to_process; */
- static volatile int sig_count = 0;
---- 65,71 ----
- */
-
- static sig_atomic_t signum_to_process[SIGMAX + 1] = { 0, };
-! volatile sig_atomic_t sig_to_process = 0;
-
- /* static volatile sigset_t sig_to_process; */
- static volatile int sig_count = 0;
-***************
-*** 303,309 ****
- break;
- case NOTOK:
- /* Do the registered action, no threads were sleeping */
-! sigdefault(sig);
- break;
- }
- break;
---- 303,317 ----
- break;
- case NOTOK:
- /* Do the registered action, no threads were sleeping */
-! /* There is a timing window that gets
-! * here when no threads are on the
-! * sleep queue. This is a quick fix.
-! * The real problem is possibly related
-! * to heavy use of condition variables
-! * with time outs.
-! * (mevans)
-! *sigdefault(sig);
-! */
- break;
- }
- break;
-diff -c -b -r -d -I .*$Id:.* pthreads-1_60_beta6/stdio/setvbuf.c pthreads-1_60_beta6+/stdio/setvbuf.c
-*** pthreads-1_60_beta6/stdio/setvbuf.c Sat Sep 3 20:58:36 1994
---- pthreads-1_60_beta6+/stdio/setvbuf.c Sat Mar 15 14:09:00 1997
-***************
-*** 142,148 ****
- flags |= __SLBF;
- if (flags & __SRW)
- flags &= ~(__SRD | __SWR);
-! fp->_w = 0;
- fp->_flags = flags;
- fp->_bf._base = fp->_p = (unsigned char *)buf;
- fp->_bf._size = size;
---- 142,148 ----
- flags |= __SLBF;
- if (flags & __SRW)
- flags &= ~(__SRD | __SWR);
-! fp->_w = size; /* Was 0 (mevans) */
- fp->_flags = flags;
- fp->_bf._base = fp->_p = (unsigned char *)buf;
- fp->_bf._size = size;
-diff -c -b -r -d -I .*$Id:.* pthreads-1_60_beta6/stdlib/system.c pthreads-1_60_beta6+/stdlib/system.c
-*** pthreads-1_60_beta6/stdlib/system.c Wed Apr 24 21:18:56 1996
---- pthreads-1_60_beta6+/stdlib/system.c Sat Mar 15 14:09:01 1997
-***************
-*** 62,68 ****
- argp[2] = (char *) command;
- sigemptyset(&tmp_mask);
- sigaddset(&tmp_mask, SIGCHLD);
-! pthread_sigmask(SIG_BLOCK, tmp_mask, &old_mask);
- switch(pid = fork()) {
- case -1: /* error */
- (void)pthread_sigmask(SIG_SETMASK, &old_mask, NULL);
---- 62,69 ----
- argp[2] = (char *) command;
- sigemptyset(&tmp_mask);
- sigaddset(&tmp_mask, SIGCHLD);
-! /* Pass the address of tmp_mask to avoid a sigfault. (mevans). */
-! pthread_sigmask(SIG_BLOCK, &tmp_mask, &old_mask);
- switch(pid = fork()) {
- case -1: /* error */
- (void)pthread_sigmask(SIG_SETMASK, &old_mask, NULL);
diff --git a/lib/libpthread/patches/p153 b/lib/libpthread/patches/p153
deleted file mode 100755
index 4e374e29a10..00000000000
--- a/lib/libpthread/patches/p153
+++ /dev/null
@@ -1,90 +0,0 @@
-<HEAD><TITLE>discuss@charon.mit.edu: [153] in "Pthreads Bugs"</TITLE>
-<H1>[153] in Pthreads Bugs</H1></HEAD>
-<A HREF="/"><IMG SRC="/i-d.gif" ALT="root"></A>
-<A HREF="?153"><IMG SRC="/i-back.gif" ALT="meeting"></A>
-<A HREF="/help.html"><IMG SRC="/i-help.gif" ALT="help"></A>
-<A HREF="1"><IMG SRC="/i-first.gif" ALT="first"></A>
-<A HREF="151"><IMG SRC="/i-fref.gif" ALT="first in chain"></A>
-<A HREF="152"><IMG SRC="/i-pref.gif" ALT="previous in chain"></A>
-<A HREF="152"><IMG SRC="/i-prev.gif" ALT="previous"></A>
-<A HREF="154"><IMG SRC="/i-next.gif" ALT="next"></A>
-<IMG SRC="/n-nref.gif" ALT="">
-<IMG SRC="/n-lref.gif" ALT="">
-<A HREF="161"><IMG SRC="/i-last.gif" ALT="last"></A>
-<HR><H2>Re: sleep / SIGALRM problem in 1_60_beta6</H2>
-<H3>daemon@ATHENA.MIT.EDU (Mon Dec 9 19:32:22 1996
-)</H3>
-<PRE>
-Date: Mon, 09 Dec 1996 17:22:50 -0700
-From: "Mark M. Evans" &lt;mevans@cti-ltd.com&gt;
-To: Tim Hinderliter &lt;kyd@internap.com&gt;
-Cc: pthreads-bugs@MIT.EDU
-
-I think I found what caused fd_kern_wait() to block for the entire
-hour (instead of waking up due to the SIGALRM). Basically, the
-SIGALRM that would move the sleeping thread to the run queue occurs
-while pthread_kernel_lock is set, but *before* the critical section in
-fd_kern_wait() that sets __fd_kern_wait_timeout.tv_sec to 3600. So,
-sig_handler_real() clears __fd_kern_wait_timeout.tv_sec "too soon."
-
-I've worked around this by checking sig_to_process in the critical
-section to determine if we are truly idle. To do this I had to make
-sig_to_process publicly available.
-
-Here are the diffs (relative to the pthreads/pthreads directory):
-
-diff -c -r1.2 -r1.3
-*** signal.c 1996/11/20 05:09:50 1.2
---- signal.c 1996/12/09 23:14:52 1.3
-***************
-*** 65,71 ****
- */
-
- static sig_atomic_t signum_to_process[SIGMAX + 1] = { 0, };
-! static sig_atomic_t sig_to_process = 0;
-
- /* static volatile sigset_t sig_to_process; */
- static volatile int sig_count = 0;
---- 65,71 ----
- */
-
- static sig_atomic_t signum_to_process[SIGMAX + 1] = { 0, };
-! sig_atomic_t sig_to_process = 0;
-
- /* static volatile sigset_t sig_to_process; */
- static volatile int sig_count = 0;
-*** fd_kern.c 1996/12/03 04:14:59 1.6
---- fd_kern.c 1996/12/09 23:14:51 1.7
-***************
-*** 215,221 ****
- * Called when there is no active thread to run.
- */
- extern struct timeval __fd_kern_wait_timeout;
-!
- void fd_kern_wait()
- {
- fd_set fd_set_read, fd_set_write, fd_set_except;
---- 215,221 ----
- * Called when there is no active thread to run.
- */
- extern struct timeval __fd_kern_wait_timeout;
-! extern volatile sig_atomic_t sig_to_process;
- void fd_kern_wait()
- {
- fd_set fd_set_read, fd_set_write, fd_set_except;
-***************
-*** 254,260 ****
-
- machdep_unset_thread_timer(NULL);
- __fd_kern_wait_timeout.tv_usec = 0;
-! __fd_kern_wait_timeout.tv_sec = 3600;
-
- machdep_sys_sigprocmask(SIG_UNBLOCK, &amp;sig_to_block, &amp;oset);
-
---- 254,260 ----
-
- machdep_unset_thread_timer(NULL);
- __fd_kern_wait_timeout.tv_usec = 0;
-! __fd_kern_wait_timeout.tv_sec = (sig_to_process) ? 0 : 3600;
-
- machdep_sys_sigprocmask(SIG_UNBLOCK, &amp;sig_to_block, &amp;oset);
diff --git a/lib/libpthread/patches/p155 b/lib/libpthread/patches/p155
deleted file mode 100755
index dbdfa7de899..00000000000
--- a/lib/libpthread/patches/p155
+++ /dev/null
@@ -1,96 +0,0 @@
-<HEAD><TITLE>discuss@charon.mit.edu: [155] in "Pthreads Bugs"</TITLE>
-<H1>[155] in Pthreads Bugs</H1></HEAD>
-<A HREF="/"><IMG SRC="/i-d.gif" ALT="root"></A>
-<A HREF="?155"><IMG SRC="/i-back.gif" ALT="meeting"></A>
-<A HREF="/help.html"><IMG SRC="/i-help.gif" ALT="help"></A>
-<A HREF="1"><IMG SRC="/i-first.gif" ALT="first"></A>
-<IMG SRC="/n-fref.gif" ALT="">
-<IMG SRC="/n-pref.gif" ALT="">
-<A HREF="154"><IMG SRC="/i-prev.gif" ALT="previous"></A>
-<A HREF="156"><IMG SRC="/i-next.gif" ALT="next"></A>
-<IMG SRC="/n-nref.gif" ALT="">
-<IMG SRC="/n-lref.gif" ALT="">
-<A HREF="161"><IMG SRC="/i-last.gif" ALT="last"></A>
-<HR><H2>pthread_kill() Bug</H2>
-<H3>daemon@ATHENA.MIT.EDU (Thu Dec 26 20:34:45 1996
-)</H3>
-<PRE>
-From: Chris Colohan &lt;colohan@eecg.toronto.edu&gt;
-To: pthreads-bugs@MIT.EDU, proven@MIT.EDU
-Date: Thu, 26 Dec 1996 20:33:48 -0500
-
-pthread_kill() has a problem in PThreads 1.60beta6. It checks to see
-if the target thread is in the state PS_SIGWAIT, and if it is it
-reschedules it. But it does not check if there is more than one
-thread in the PS_SIGWAIT state, and hence mangles the pthread_sigwait
-linked list, potentially resulting in threads getting blocked forever,
-and signals never being delivered. I have a *very* contrived test
-case that demonstrates this problem if you would like it. Please let
-me know...
-
-Chris
-===
-
-Diffs created with diff -c:
-
-*** /home/colohan/thesis/t/pthreads-1_60_beta6/pthreads/pthread_kill.c Tue Feb 21 03:07:18 1995
---- pthread_kill.c Thu Dec 26 19:50:22 1996
-***************
-*** 41,51 ****
---- 41,58 ----
-
- #include &lt;pthread.h&gt;
-
-+ /* Defined in sig.c, a linked list of threads currently
-+ * blocked in sigwait(): */
-+ extern struct pthread * pthread_sigwait;
-+
-+
- /* ==========================================================================
- * pthread_kill()
- */
- int pthread_kill(struct pthread * pthread, int sig)
- {
-+ struct pthread ** pthread_ptr;
-+
- pthread_sched_prevent();
-
- /* Check who is the current owner of pthread */
-***************
-*** 53,62 ****
- if (0) {
- } else {
- if (pthread-&gt;state == PS_SIGWAIT) {
-! if (sigismember(pthread-&gt;data.sigwait, sig)) {
-! *(int *)(pthread-&gt;ret) = sig;
-! pthread_sched_other_resume(pthread);
-! return(OK);
- }
- }
- sigaddset(&amp;(pthread-&gt;sigpending), sig);
---- 60,84 ----
- if (0) {
- } else {
- if (pthread-&gt;state == PS_SIGWAIT) {
-! if(sigismember(pthread-&gt;data.sigwait, sig)) {
-! for (pthread_ptr = &amp;pthread_sigwait;
-! (*pthread_ptr);
-! pthread_ptr = &amp;((*pthread_ptr)-&gt;next)) {
-! if ((*pthread_ptr) == pthread) {
-!
-! /* Take the thread out of the
-! * pthread_sigwait linked list: */
-! *pthread_ptr=(*pthread_ptr)-&gt;next;
-!
-! *(int *)(pthread-&gt;ret) = sig;
-! pthread_sched_other_resume(pthread);
-! return(OK);
-! }
-! }
-! /* A thread should not be in the state PS_SIGWAIT
-! * without being in the pthread_sigwait linked
-! * list: */
-! PANIC();
- }
- }
- sigaddset(&amp;(pthread-&gt;sigpending), sig);
diff --git a/lib/libpthread/pthreads/Makefile.inc b/lib/libpthread/pthreads/Makefile.inc
deleted file mode 100644
index 6e4d8a39d49..00000000000
--- a/lib/libpthread/pthreads/Makefile.inc
+++ /dev/null
@@ -1,107 +0,0 @@
-# from: @(#)Makefile.inc 5.6 (Berkeley) 6/4/91
-
-.PATH: ${.CURDIR}/pthreads
-
-SRCS+= cleanup.c cond.c fd.c fd_kern.c fd_pipe.c file.c globals.c malloc.c \
- mutex.c pthread.c pthread_attr.c queue.c signal.c machdep.c syscall.S \
- pthread_join.c pthread_detach.c pthread_once.c sleep.c specific.c \
- process.c wait.c errno.c schedparam.c _exit.c prio_queue.c \
- pthread_init.c init.cc sig.c info.c mutexattr.c select.c wrapper.c \
- dump_state.c pthread_kill.c condattr.c pthread_cancel.c panic.c
-
-# glue to provide compatibility between GCC 1.X and 2.X and for compat
-# with old syscall interfaces.
-#SRCS+= ftruncate.c lseek.c mmap.c semctl.c truncate.c \
-# timer_create.c timer_delete.c timer_getoverrun.c timer_gettime.c \
-# timer_settime.c
-
-# modules with default implementations on all architectures:
-ASM= accept.o access.o acct.o adjtime.o bind.o chdir.o chflags.o chmod.o \
- chown.o chroot.o clock_gettime.o clock_settime.o clock_getres.o \
- close.o connect.o dup.o dup2.o execve.o fchdir.o \
- fchflags.o fchmod.o fchown.o fcntl.o flock.o fpathconf.o fstat.o \
- fstatfs.o fsync.o futimes.o getdirentries.o getegid.o geteuid.o \
- getfh.o getfsstat.o getgid.o getgroups.o getitimer.o getpeername.o \
- getpgid.o \
- getpgrp.o getpid.o getppid.o getpriority.o getrlimit.o getrusage.o \
- getsid.o \
- getsockname.o getsockopt.o gettimeofday.o getuid.o issetugid.o \
- ioctl.o kill.o \
- ktrace.o lchown.o lfs_bmapv.o lfs_markv.o lfs_segclean.o lfs_segwait.o \
- link.o listen.o lstat.o madvise.o mincore.o minherit.o mkdir.o \
- mkfifo.o mknod.o mlock.o \
- mount.o mprotect.o msgctl.o msgget.o msgrcv.o msgsnd.o msync.o \
- munlock.o munmap.o nanosleep.o nfssvc.o \
- ntp_gettime.o ntp_adjtime.o \
- open.o pathconf.o poll.o profil.o quotactl.o \
- read.o readlink.o readv.o reboot.o recvfrom.o recvmsg.o rename.o \
- revoke.o rfork.o \
- rmdir.o select.o semconfig.o semget.o semop.o sendmsg.o sendto.o \
- setegid.o seteuid.o setgid.o setgroups.o setitimer.o setpgid.o \
- setpriority.o setrlimit.o setsid.o setsockopt.o settimeofday.o \
- setuid.o shmat.o shmctl.o shmdt.o shmget.o shutdown.o sigaction.o \
- sigaltstack.o socket.o socketpair.o stat.o statfs.o swapon.o \
- symlink.o sync.o sysarch.o umask.o undelete.o unlink.o unmount.o \
- utimes.o vadvise.o wait4.o write.o writev.o __semctl.o \
- __sysctl.o
-
-PASM= ${ASM:.o=.po}
-SASM= ${ASM:.o=.so}
-
-PSEUDO= _exit.o _getlogin.o
-PPSEUDO=${PSEUDO:.o=.po}
-SPSEUDO=${PSEUDO:.o=.so}
-
-OBJS+= ${ASM} ${PSEUDO}
-
-${PASM}: ${.CURDIR}/arch/${MACHINE_ARCH}/SYS.h /usr/include/sys/syscall.h
- @echo creating ${.TARGET}
- @printf '#include "SYS.h"\nRSYSCALL(${.PREFIX})\n' | \
- ${CPP} -DPROF ${CFLAGS:M-[ID]*} ${AINC} | ${AS} -o ${.TARGET}.o
- @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
- @rm -f ${.TARGET}.o
-
-.if (${MACHINE_ARCH} != "mips")
-${SASM}: ${.CURDIR}/arch/${MACHINE_ARCH}/SYS.h /usr/include/sys/syscall.h
- @echo creating ${.TARGET}
- @printf '#include "SYS.h"\nRSYSCALL(${.PREFIX})\n' | \
- ${CPP} -DPIC ${CFLAGS:M-[ID]*} ${AINC} | ${AS} -k -o ${.TARGET}
-.else
-${SASM}: ${.CURDIR}/arch/${MACHINE_ARCH}/SYS.h /usr/include/sys/syscall.h
- @echo creating ${.TARGET}
- @printf '#include "SYS.h"\nRSYSCALL(${.PREFIX})\n' | \
- ${CPP} -DPIC ${CFLAGS:M-[ID]*} ${AINC} | ${AS} -o ${.TARGET}
-.endif
-
-${ASM}: ${.CURDIR}/arch/${MACHINE_ARCH}/SYS.h /usr/include/sys/syscall.h
- @echo creating ${.TARGET}
- @printf '#include "SYS.h"\nRSYSCALL(${.PREFIX})\n' | \
- ${CPP} ${CFLAGS:M-[ID]*} ${AINC} | ${AS} -o ${.TARGET}.o
- @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
- @rm -f ${.TARGET}.o
-
-${PPSEUDO}: ${.CURDIR}/arch/${MACHINE_ARCH}/SYS.h /usr/include/sys/syscall.h
- @echo creating ${.TARGET}
- @printf '#include "SYS.h"\nPSEUDO(${.PREFIX},${.PREFIX:S/_//})\n' | \
- ${CPP} -DPROF ${CFLAGS:M-[ID]*} ${AINC} | ${AS} -o ${.TARGET}.o
- @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
- @rm -f ${.TARGET}.o
-
-.if (${MACHINE_ARCH} != "mips")
-${SPSEUDO}: ${.CURDIR}/arch/${MACHINE_ARCH}/SYS.h /usr/include/sys/syscall.h
- @echo creating ${.TARGET}
- @printf '#include "SYS.h"\nPSEUDO(${.PREFIX},${.PREFIX:S/_//})\n' | \
- ${CPP} -DPIC ${CFLAGS:M-[ID]*} ${AINC} | ${AS} -k -o ${.TARGET}
-.else
-${SPSEUDO}: ${.CURDIR}/arch/${MACHINE_ARCH}/SYS.h /usr/include/sys/syscall.h
- @echo creating ${.TARGET}
- @printf '#include "SYS.h"\nPSEUDO(${.PREFIX},${.PREFIX:S/_//})\n' | \
- ${CPP} -DPIC ${CFLAGS:M-[ID]*} ${AINC} | ${AS} -o ${.TARGET}
-.endif
-
-${PSEUDO}: ${.CURDIR}/arch/${MACHINE_ARCH}/SYS.h /usr/include/sys/syscall.h
- @echo creating ${.TARGET}
- @printf '#include "SYS.h"\nPSEUDO(${.PREFIX},${.PREFIX:S/_//})\n' | \
- ${CPP} ${CFLAGS:M-[ID]*} ${AINC} | ${AS} -o ${.TARGET}.o
- @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
- @rm -f ${.TARGET}.o
diff --git a/lib/libpthread/pthreads/_exit.c b/lib/libpthread/pthreads/_exit.c
deleted file mode 100644
index dab873a80a7..00000000000
--- a/lib/libpthread/pthreads/_exit.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/* ==== _exit.c ============================================================
- * 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 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.
- *
- * Description : The locking functions for stdio.
- *
- * 1.00 94/09/04 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: _exit.c,v 1.1 1998/07/21 13:19:50 peter Exp $";
-#endif
-
-#include <pthread.h>
-#include <fcntl.h>
-
-/* ==========================================================================
- * _exit()
- *
- * Change all file descriptors back to their original state,
- * before exiting for good.
- */
-void _exit(int status)
-{
- int fd;
-
- pthread_sched_prevent();
-
- for (fd = 0; fd < dtablesize; fd++) {
- if (fd_table[fd] == NULL) {
- continue;
- }
- /* Is it a kernel fd ? */
- if ((!fd_table[fd]->ops) || (fd_table[fd]->ops->use_kfds != 1)) {
- continue;
- }
- switch (fd_table[fd]->type) {
- case FD_HALF_DUPLEX:
- machdep_sys_fcntl(fd_table[fd]->fd.i, F_SETFL, fd_table[fd]->flags);
- fd_table[fd]->type = FD_TEST_HALF_DUPLEX;
- break;
- case FD_FULL_DUPLEX:
- machdep_sys_fcntl(fd_table[fd]->fd.i, F_SETFL, fd_table[fd]->flags);
- fd_table[fd]->type = FD_TEST_FULL_DUPLEX;
- break;
- default:
- break;
- }
- }
- machdep_sys_exit(status);
-}
-
diff --git a/lib/libpthread/pthreads/cleanup.c b/lib/libpthread/pthreads/cleanup.c
deleted file mode 100644
index e569697d40e..00000000000
--- a/lib/libpthread/pthreads/cleanup.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* ==== cleanup.c =======================================================
- * 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 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.
- *
- * Description : Pthread attribute functions.
- *
- * 1.20 94/02/13 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: cleanup.c,v 1.1 1998/07/21 13:19:50 peter Exp $";
-#endif
-
-#include <pthread.h>
-#include <errno.h>
-#include <stdlib.h>
-
-/* ==========================================================================
- * pthread_cleanup_push()
- */
-int pthread_cleanup_push(void (*routine)(void *), void *routine_arg)
-{
- struct pthread_cleanup *new;
- int ret;
-
- if (new = (struct pthread_cleanup*)malloc(sizeof(struct pthread_cleanup))) {
- new->routine = routine;
- new->routine_arg = routine_arg;
- new->next = pthread_run->cleanup;
-
- pthread_run->cleanup = new;
- ret = OK;
- } else {
- ret = ENOMEM;
- }
- return(ret);
-}
-
-/* ==========================================================================
- * pthread_cleanup_pop()
- */
-void pthread_cleanup_pop(int execute)
-{
- struct pthread_cleanup *old;
-
- if (old = pthread_run->cleanup) {
- pthread_run->cleanup = old->next;
- if (execute) {
- old->routine(old->routine_arg);
- }
- free(old);
- }
-}
-
diff --git a/lib/libpthread/pthreads/cond.c b/lib/libpthread/pthreads/cond.c
deleted file mode 100644
index 7251f550d16..00000000000
--- a/lib/libpthread/pthreads/cond.c
+++ /dev/null
@@ -1,208 +0,0 @@
-/* ==== cond.c ============================================================
- * Copyright (c) 1993, 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 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.
- *
- * Description : Condition cariable functions.
- *
- * 1.00 93/10/28 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: cond.c,v 1.1 1995/10/18 08:43:04 deraadt Exp $ $provenid: cond.c,v 1.16 1994/02/07 02:18:35 proven Exp $";
-#endif
-
-#include <pthread.h>
-#include <errno.h>
-
-/* ==========================================================================
- * pthread_cond_init()
- *
- * In this implementation I don't need to allocate memory.
- * ENOMEM, EAGAIN should never be returned. Arch that have
- * weird constraints may need special coding.
- */
-int pthread_cond_init(pthread_cond_t *cond, pthread_condattr_t *cond_attr)
-{
- /* Only check if attr specifies some mutex type other than fast */
- if ((cond_attr) && (cond_attr->c_type != COND_TYPE_FAST)) {
- if (cond_attr->c_type >= COND_TYPE_MAX) {
- return(EINVAL);
- }
- if (cond->c_flags & COND_FLAGS_INITED) {
- return(EBUSY);
- }
- cond->c_type = cond_attr->c_type;
- } else {
- cond->c_type = COND_TYPE_FAST;
- }
- /* Set all other paramaters */
- pthread_queue_init(&cond->c_queue);
- cond->c_flags |= COND_FLAGS_INITED;
- cond->c_lock = SEMAPHORE_CLEAR;
- return(OK);
-}
-
-/* ==========================================================================
- * pthread_cond_destroy()
- */
-int pthread_cond_destroy(pthread_cond_t *cond)
-{
- /* Only check if cond is of type other than fast */
- switch(cond->c_type) {
- case COND_TYPE_FAST:
- break;
- case COND_TYPE_STATIC_FAST:
- default:
- return(EINVAL);
- break;
- }
-
- /* Cleanup cond, others might want to use it. */
- pthread_queue_init(&cond->c_queue);
- cond->c_flags |= COND_FLAGS_INITED;
- cond->c_lock = SEMAPHORE_CLEAR;
- cond->c_flags = 0;
- return(OK);
-}
-
-/* ==========================================================================
- * pthread_cond_wait()
- */
-int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
-{
- semaphore *lock, *plock;
- int rval;
-
- lock = &(cond->c_lock);
- while (SEMAPHORE_TEST_AND_SET(lock)) {
- pthread_yield();
- }
-
- switch (cond->c_type) {
- /*
- * Fast condition variables do not check for any error conditions.
- */
- case COND_TYPE_FAST:
- case COND_TYPE_STATIC_FAST:
- plock = &(pthread_run->lock);
- while (SEMAPHORE_TEST_AND_SET(plock)) {
- pthread_yield();
- }
- pthread_queue_enq(&cond->c_queue, pthread_run);
- pthread_mutex_unlock(mutex);
- SEMAPHORE_RESET(lock);
-
- /* Reschedule will unlock pthread_run */
- reschedule(PS_COND_WAIT);
-
- return(pthread_mutex_lock(mutex));
- break;
- default:
- rval = EINVAL;
- break;
- }
- SEMAPHORE_RESET(lock);
- return(rval);
-}
-
-/* ==========================================================================
- * pthread_cond_signal()
- */
-int pthread_cond_signal(pthread_cond_t *cond)
-{
- struct pthread *pthread;
- semaphore *lock, *plock;
- int rval;
-
- lock = &(cond->c_lock);
- while (SEMAPHORE_TEST_AND_SET(lock)) {
- pthread_yield();
- }
-
- switch (cond->c_type) {
- case COND_TYPE_FAST:
- case COND_TYPE_STATIC_FAST:
- if (pthread = pthread_queue_get(&cond->c_queue)) {
- plock = &(pthread->lock);
- while (SEMAPHORE_TEST_AND_SET(plock)) {
- pthread_yield();
- }
- pthread_queue_deq(&cond->c_queue);
- pthread->state = PS_RUNNING;
- SEMAPHORE_RESET(plock);
- }
- rval = OK;
- break;
- default:
- rval = EINVAL;
- break;
- }
- SEMAPHORE_RESET(lock);
- return(rval);
-}
-
-/* ==========================================================================
- * pthread_cond_broadcast()
- *
- * Not much different then the above routine.
- */
-int pthread_cond_broadcast(pthread_cond_t *cond)
-{
- struct pthread *pthread;
- semaphore *lock, *plock;
- int rval;
-
- lock = &(cond->c_lock);
- while (SEMAPHORE_TEST_AND_SET(lock)) {
- pthread_yield();
- }
-
- switch (cond->c_type) {
- case COND_TYPE_FAST:
- case COND_TYPE_STATIC_FAST:
- while (pthread = pthread_queue_get(&cond->c_queue)) {
- plock = &(pthread->lock);
- while (SEMAPHORE_TEST_AND_SET(plock)) {
- pthread_yield();
- }
- pthread_queue_deq(&cond->c_queue);
- pthread->state = PS_RUNNING;
- SEMAPHORE_RESET(plock);
- }
- rval = OK;
- break;
- default:
- rval = EINVAL;
- break;
- }
- SEMAPHORE_RESET(lock);
- return(rval);
-}
diff --git a/lib/libpthread/pthreads/condattr.c b/lib/libpthread/pthreads/condattr.c
deleted file mode 100644
index 79fd340c96d..00000000000
--- a/lib/libpthread/pthreads/condattr.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* ==== condattr.c ===========================================================
- * Copyright (c) 1995 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 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.
- *
- * Description : Mutex functions.
- *
- * 1.00 95/08/22 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: condattr.c,v 1.1 1998/07/21 13:19:52 peter Exp $";
-#endif
-
-#include <pthread.h>
-#include <errno.h>
-
-/* ==========================================================================
- * pthread_condattr_init()
- */
-int pthread_condattr_init(pthread_condattr_t *attr)
-{
- attr->c_type = COND_TYPE_FAST;
- return(OK);
-}
-
-/* ==========================================================================
- * pthread_condattr_destroy()
- */
-int pthread_condattr_destroy(pthread_condattr_t *attr)
-{
- return(OK);
-}
-
-/* ==========================================================================
- * pthread_condattr_settype()
- */
-int pthread_condattr_settype(pthread_condattr_t *attr, unsigned int type)
-{
- switch(type) {
- case PTHREAD_CONDTYPE_FAST:
- attr->c_type = COND_TYPE_FAST;
- break;
- case PTHREAD_CONDTYPE_RECURSIVE:
- attr->c_type = COND_TYPE_COUNTING_FAST;
- break;
- case PTHREAD_CONDTYPE_DEBUG:
- attr->c_type = COND_TYPE_DEBUG;
- break;
- default:
- return(EINVAL);
- }
- return(OK);
-}
-
-/* ==========================================================================
- * pthread_condattr_gettype()
- */
-int pthread_condattr_gettype(pthread_condattr_t *attr, unsigned int * type)
-{
- *type = (unsigned int)attr->c_type;
- return(OK);
-}
diff --git a/lib/libpthread/pthreads/dump_state.c b/lib/libpthread/pthreads/dump_state.c
deleted file mode 100644
index 6d46ac32c53..00000000000
--- a/lib/libpthread/pthreads/dump_state.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ==== dump_state.c ============================================================
- * Copyright (c) 1993, 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 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.
- *
- * $Id: dump_state.c,v 1.1 1998/07/21 13:19:52 peter Exp $
- *
- * Description : Bogus debugging output routines.
- *
- * 1.00 95/02/08 snl
- * -Started coding this file.
- */
-
-#include <pthread.h>
-#include <stdio.h>
-
-/* ==========================================================================
- * pthread_dump_state()
- *
- * Totally, totally bogus routine to dump the state of pthreads.
- */
-
-void
-pthread_dump_state()
-{
- pthread_t thread;
-
- for (thread = pthread_link_list; thread; thread = thread->pll) {
- printf("Thread %lx", thread);
- if (thread == pthread_initial)
- printf("*");
- if (thread == pthread_run)
- printf("^");
- printf(" ");
- switch (thread->state) {
- case PS_RUNNING: printf("RUNNING "); break;
- case PS_MUTEX_WAIT: printf("MUTEX_WAIT "); break;
- case PS_COND_WAIT: printf("COND_WAIT "); break;
- case PS_FDLR_WAIT: printf("FDLR_WAIT "); break;
- case PS_FDLW_WAIT: printf("FDLW_WAIT "); break;
- case PS_FDR_WAIT: printf("FDR_WAIT "); break;
- case PS_FDW_WAIT: printf("FDW_WAIT "); break;
- case PS_SELECT_WAIT: printf("SELECT "); break;
- case PS_SLEEP_WAIT: printf("SLEEP_WAIT "); break;
- case PS_WAIT_WAIT: printf("WAIT_WAIT "); break;
- case PS_SIGWAIT: printf("SIGWAIT "); break;
- case PS_JOIN: printf("JOIN "); break;
- case PS_DEAD: printf("DEAD "); break;
- default: printf("*UNKNOWN %d* ", thread->state);
- break;
- }
- switch (thread->attr.schedparam_policy) {
- case SCHED_RR: printf("RR "); break;
- case SCHED_IO: printf("IO "); break;
- case SCHED_FIFO: printf("FIFO "); break;
- case SCHED_OTHER: printf("OTHER "); break;
- default: printf("*UNKNOWN %d* ",
- thread->attr.schedparam_policy);
- break;
- }
- }
-}
diff --git a/lib/libpthread/pthreads/errno.c b/lib/libpthread/pthreads/errno.c
deleted file mode 100644
index edc36c68524..00000000000
--- a/lib/libpthread/pthreads/errno.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/* ==== errno.c ============================================================
- * 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 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.
- *
- * Description : Return the pointer to the threads errno address.
- *
- * 1.32 94/05/25 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: errno.c,v 1.1 1998/07/21 13:19:52 peter Exp $";
-#endif
-
-#include <pthread.h>
-
-/* ==========================================================================
- * __error()
- */
-int * __error()
-{
- if (!pthread_run->error_p) {
- pthread_run->error_p = &pthread_run->error;
- }
- return(pthread_run->error_p);
-}
diff --git a/lib/libpthread/pthreads/fd.c b/lib/libpthread/pthreads/fd.c
deleted file mode 100644
index e603c0da0f9..00000000000
--- a/lib/libpthread/pthreads/fd.c
+++ /dev/null
@@ -1,1081 +0,0 @@
-/* ==== fd.c ============================================================
- * Copyright (c) 1993, 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 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.
- *
- * Description : All the syscalls dealing with fds.
- *
- * 1.00 93/08/14 proven
- * -Started coding this file.
- *
- * 1.01 93/11/13 proven
- * -The functions readv() and writev() added.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: fd.c,v 1.2 1998/07/21 19:48:00 peter Exp $";
-#endif
-
-#include <pthread.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/uio.h>
-#include <sys/ioctl.h>
-#ifdef HAVE_SYS_FILIO_H
-#include <sys/filio.h> /* For ioctl */
-#endif
-#if __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-#include <fcntl.h>
-#include <errno.h>
-#include <pthread/posix.h>
-
-/*
- * These first functions really should not be called by the user.
- *
- * I really should dynamically figure out what the table size is.
- */
-static pthread_mutex_t fd_table_mutex = PTHREAD_MUTEX_INITIALIZER;
-static const int dtablecount = 4096/sizeof(struct fd_table_entry);
-int dtablesize;
-
-static int fd_get_pthread_fd_from_kernel_fd( int );
-
-/* ==========================================================================
- * Allocate dtablecount entries at once and populate the fd_table.
- *
- * fd_init_entry()
- */
-int fd_init_entry(int entry)
-{
- struct fd_table_entry *fd_entry;
- int i, round;
-
- if (fd_table[entry] == NULL) {
- round = entry - entry % dtablecount;
-
- if ((fd_entry = (struct fd_table_entry *)malloc(
- sizeof(struct fd_table_entry) * dtablecount)) == NULL) {
- return(NOTOK);
- }
-
- for (i = 0; i < dtablecount && round+i < dtablesize; i++) {
- fd_table[round + i] = &fd_entry[i];
-
- fd_table[round + i]->ops = NULL;
- fd_table[round + i]->type = FD_NT;
- fd_table[round + i]->fd.i = NOTOK;
- fd_table[round + i]->flags = 0;
- fd_table[round + i]->count = 0;
-
- pthread_mutex_init(&(fd_table[round + i]->mutex), NULL);
- pthread_queue_init(&(fd_table[round + i]->r_queue));
- pthread_queue_init(&(fd_table[round + i]->w_queue));
- fd_table[round + i]->r_owner = NULL;
- fd_table[round + i]->w_owner = NULL;
- fd_table[round + i]->r_lockcount= 0;
- fd_table[round + i]->w_lockcount= 0;
-
- fd_table[round + i]->next = NULL;
- }
- }
- return(OK);
-}
-
-/* ==========================================================================
- * fd_check_entry()
- */
-int fd_check_entry(unsigned int entry)
-{
- int ret = OK;
-
- pthread_mutex_lock(&fd_table_mutex);
-
- if (entry < dtablesize) {
- if (fd_table[entry] == NULL) {
- if (fd_init_entry(entry)) {
- SET_ERRNO(EBADF);
- ret = -EBADF;
- }
- }
- } else {
- SET_ERRNO(EBADF);
- ret = -EBADF;
- }
-
- pthread_mutex_unlock(&fd_table_mutex);
- return(ret);
-}
-
-/* ==========================================================================
- * fd_init()
- */
-void fd_init(void)
-{
- int i;
-
- if ((dtablesize = machdep_sys_getdtablesize()) < 0) {
- /* Can't figure out the table size. */
- PANIC();
- }
-
- /* select() can only handle FD_SETSIZE descriptors, so our inner loop will
- * break if dtablesize is higher than that. This should be removed if and
- * when the inner loop is rewritten to use poll(). */
- if (dtablesize > FD_SETSIZE) {
- dtablesize = FD_SETSIZE;
- }
-
- if (fd_table = (struct fd_table_entry **)malloc(
- sizeof(struct fd_table_entry) * dtablesize)) {
- memset(fd_table, 0, sizeof(struct fd_table_entry) * dtablesize);
- if (fd_check_entry(0) == OK) {
- return;
- }
- }
-
- /*
- * There isn't enough memory to allocate a fd table at init time.
- * This is a problem.
- */
- PANIC();
-
-}
-
-/* ==========================================================================
- * fd_allocate()
- */
-int fd_allocate()
-{
- pthread_mutex_t * mutex;
- int i;
-
- for (i = 0; i < dtablesize; i++) {
- if (fd_check_entry(i) == OK) {
- mutex = &(fd_table[i]->mutex);
- if (pthread_mutex_trylock(mutex)) {
- continue;
- }
- if (fd_table[i]->count || fd_table[i]->r_owner
- || fd_table[i]->w_owner) {
- pthread_mutex_unlock(mutex);
- continue;
- }
- if (fd_table[i]->type == FD_NT) {
- /* Test to see if the kernel version is in use */
- if ((machdep_sys_fcntl(i, F_GETFL, NULL)) >= OK) {
- /* If so continue; */
- pthread_mutex_unlock(mutex);
- continue;
- }
- }
- fd_table[i]->count++;
- pthread_mutex_unlock(mutex);
- return(i);
- }
- }
- SET_ERRNO(ENFILE);
- return(NOTOK);
-}
-
-/*----------------------------------------------------------------------
- * Function: fd_get_pthread_fd_from_kernel_fd
- * Purpose: get the fd_table index of a kernel fd
- * Args: fd = kernel fd to convert
- * Returns: fd_table index, -1 if not found
- * Notes:
- *----------------------------------------------------------------------*/
-static int
-fd_get_pthread_fd_from_kernel_fd( int kfd )
-{
- int j;
-
- /* This is *SICK*, but unless there is a faster way to
- * turn a kernel fd into an fd_table index, this has to do.
- */
- for( j=0; j < dtablesize; j++ ) {
- if( fd_table[j] &&
- fd_table[j]->type != FD_NT &&
- fd_table[j]->type != FD_NIU &&
- fd_table[j]->fd.i == kfd ) {
- return j;
- }
- }
-
- /* Not listed byfd, Check for kernel fd == pthread fd */
- if( fd_table[kfd] == NULL || fd_table[kfd]->type == FD_NT ) {
- /* Assume that the kernel fd is the same */
- return kfd;
- }
-
- return NOTOK; /* Not found */
-}
-
-/* ==========================================================================
- * fd_basic_basic_unlock()
- *
- * The real work of unlock without the locking of fd_table[fd].lock.
- */
-void fd_basic_basic_unlock(struct fd_table_entry * entry, int lock_type)
-{
- struct pthread *pthread;
-
- if (entry->r_owner == pthread_run) {
- if ((entry->type == FD_HALF_DUPLEX) ||
- (entry->type == FD_TEST_HALF_DUPLEX) ||
- (lock_type == FD_READ) || (lock_type == FD_RDWR)) {
- if (entry->r_lockcount == 0) {
- if (pthread = pthread_queue_deq(&entry->r_queue)) {
- pthread_sched_prevent();
- entry->r_owner = pthread;
- if ((SET_PF_DONE_EVENT(pthread)) == OK) {
- pthread_sched_other_resume(pthread);
- } else {
- pthread_sched_resume();
- }
- } else {
- entry->r_owner = NULL;
- }
- } else {
- entry->r_lockcount--;
- }
- }
- }
-
- if (entry->w_owner == pthread_run) {
- if ((entry->type != FD_HALF_DUPLEX) &&
- (entry->type != FD_TEST_HALF_DUPLEX) &&
- ((lock_type == FD_WRITE) || (lock_type == FD_RDWR))) {
- if (entry->w_lockcount == 0) {
- if (pthread = pthread_queue_deq(&entry->w_queue)) {
- pthread_sched_prevent();
- entry->w_owner = pthread;
- if ((SET_PF_DONE_EVENT(pthread)) == OK) {
- pthread_sched_other_resume(pthread);
- } else {
- pthread_sched_resume();
- }
- } else {
- entry->w_owner = NULL;
- }
- } else {
- entry->w_lockcount--;
- }
- }
- }
-}
-
-/* ==========================================================================
- * fd_basic_unlock()
- */
-void fd_basic_unlock(int fd, int lock_type)
-{
- fd_basic_basic_unlock(fd_table[fd], lock_type);
-}
-
-/* ==========================================================================
- * fd_unlock()
- */
-void fd_unlock(int fd, int lock_type)
-{
- pthread_mutex_t *mutex;
-
- mutex = &(fd_table[fd]->mutex);
- pthread_mutex_lock(mutex);
- fd_basic_basic_unlock(fd_table[fd], lock_type);
- pthread_mutex_unlock(mutex);
-}
-
-/* ==========================================================================
- * fd_basic_lock()
- *
- * The real work of lock without the locking of fd_table[fd].lock.
- * Be sure to leave the lock the same way you found it. i.e. locked.
- */
-int fd_basic_lock(unsigned int fd, int lock_type, pthread_mutex_t * mutex,
- struct timespec * timeout)
-{
- semaphore *plock;
-
- switch (fd_table[fd]->type) {
- case FD_NIU:
- /* If not in use return EBADF error */
- SET_ERRNO(EBADF);
- return(NOTOK);
- break;
- case FD_NT:
- /*
- * If not tested, test it and see if it is valid
- * If not ok return EBADF error
- */
- fd_kern_init(fd);
- if (fd_table[fd]->type == FD_NIU) {
- SET_ERRNO(EBADF);
- return(NOTOK);
- }
- break;
- case FD_TEST_HALF_DUPLEX:
- case FD_TEST_FULL_DUPLEX:
- /* If a parent process reset the fd to its proper state */
- if (!fork_lock) {
- /* It had better be a kernel fd */
- fd_kern_reset(fd);
- }
- break;
- default:
- break;
- }
-
- if ((fd_table[fd]->type == FD_HALF_DUPLEX) ||
- (fd_table[fd]->type == FD_TEST_HALF_DUPLEX) ||
- (lock_type == FD_READ) || (lock_type == FD_RDWR)) {
- if (fd_table[fd]->r_owner) {
- if (fd_table[fd]->r_owner != pthread_run) {
- pthread_sched_prevent();
- pthread_queue_enq(&fd_table[fd]->r_queue, pthread_run);
- SET_PF_WAIT_EVENT(pthread_run);
- pthread_mutex_unlock(mutex);
-
- if (timeout) {
- /* get current time */
- struct timespec current_time;
- machdep_gettimeofday(&current_time);
- sleep_schedule(&current_time, timeout);
-
- /* Reschedule will unlock pthread_run */
- pthread_run->data.fd.fd = fd;
- pthread_run->data.fd.branch = __LINE__;
- pthread_resched_resume(PS_FDLR_WAIT);
- pthread_mutex_lock(mutex);
-
- /* If we're the owner then we have to cancel the sleep */
- if (fd_table[fd]->r_owner != pthread_run) {
- CLEAR_PF_DONE_EVENT(pthread_run);
- SET_ERRNO(ETIMEDOUT);
- return(NOTOK);
- }
- sleep_cancel(pthread_run);
- } else {
- /* Reschedule will unlock pthread_run */
- pthread_run->data.fd.fd = fd;
- pthread_run->data.fd.branch = __LINE__;
- pthread_resched_resume(PS_FDLR_WAIT);
- pthread_mutex_lock(mutex);
- }
- CLEAR_PF_DONE_EVENT(pthread_run);
- } else {
- fd_table[fd]->r_lockcount++;
- }
- }
- fd_table[fd]->r_owner = pthread_run;
- }
- if ((fd_table[fd]->type != FD_HALF_DUPLEX) &&
- (fd_table[fd]->type != FD_TEST_HALF_DUPLEX) &&
- ((lock_type == FD_WRITE) || (lock_type == FD_RDWR))) {
- if (fd_table[fd]->w_owner) {
- if (fd_table[fd]->w_owner != pthread_run) {
- pthread_sched_prevent();
- pthread_queue_enq(&fd_table[fd]->w_queue, pthread_run);
- SET_PF_WAIT_EVENT(pthread_run);
- pthread_mutex_unlock(mutex);
-
- if (timeout) {
- /* get current time */
- struct timespec current_time;
- machdep_gettimeofday(&current_time);
- sleep_schedule(&current_time, timeout);
-
- /* Reschedule will unlock pthread_run */
- pthread_run->data.fd.fd = fd;
- pthread_run->data.fd.branch = __LINE__;
- pthread_resched_resume(PS_FDLR_WAIT);
- pthread_mutex_lock(mutex);
-
- /* If we're the owner then we have to cancel the sleep */
- if (fd_table[fd]->w_owner != pthread_run) {
- if (lock_type == FD_RDWR) {
- /* Unlock current thread */
- fd_basic_unlock(fd, FD_READ);
- }
- CLEAR_PF_DONE_EVENT(pthread_run);
- SET_ERRNO(ETIMEDOUT);
- return(NOTOK);
- }
- sleep_cancel(pthread_run);
- } else {
- /* Reschedule will unlock pthread_run */
- pthread_run->data.fd.fd = fd;
- pthread_run->data.fd.branch = __LINE__;
- pthread_resched_resume(PS_FDLR_WAIT);
- pthread_mutex_lock(mutex);
- }
- CLEAR_PF_DONE_EVENT(pthread_run);
- } else {
- fd_table[fd]->w_lockcount++;
- }
- }
- fd_table[fd]->w_owner = pthread_run;
- }
- if (!fd_table[fd]->count) {
- fd_basic_unlock(fd, lock_type);
- return(NOTOK);
- }
- return(OK);
-}
-
-/*----------------------------------------------------------------------
- * Function: fd_unlock_for_cancel
- * Purpose: Unlock all fd locks held prior to being cancelled
- * Args: void
- * Returns:
- * OK or NOTOK
- * Notes:
- * Assumes the kernel is locked on entry
- *----------------------------------------------------------------------*/
-int
-fd_unlock_for_cancel( void )
-{
- int i, fd;
- struct pthread_select_data *data;
- int rdlk, wrlk, lktype;
- int found;
-
- /* What we do depends on the previous state of the thread */
- switch( pthread_run->old_state ) {
- case PS_RUNNING:
- case PS_JOIN:
- case PS_SLEEP_WAIT:
- case PS_WAIT_WAIT:
- case PS_SIGWAIT:
- case PS_FDLR_WAIT:
- case PS_FDLW_WAIT:
- case PS_DEAD:
- case PS_UNALLOCED:
- break; /* Nothing to do */
-
- case PS_COND_WAIT:
- CLEAR_PF_GROUP( pthread_run, PF_EVENT_GROUP );
- /* Must reaquire the mutex according to the standard */
- if( pthread_run->data.mutex == NULL ) {
- PANIC();
- }
- pthread_mutex_lock( pthread_run->data.mutex );
- break;
-
- case PS_FDR_WAIT:
- CLEAR_PF_GROUP( pthread_run, PF_EVENT_GROUP);
- /* Free the lock on the fd being used */
- fd = fd_get_pthread_fd_from_kernel_fd( pthread_run->data.fd.fd );
- if( fd == NOTOK ) {
- PANIC(); /* Can't find fd */
- }
- fd_unlock( fd, FD_READ );
- break;
-
- case PS_FDW_WAIT: /* Waiting on i/o */
- CLEAR_PF_GROUP( pthread_run, PF_EVENT_GROUP);
- /* Free the lock on the fd being used */
- fd = fd_get_pthread_fd_from_kernel_fd( pthread_run->data.fd.fd );
- if( fd == NOTOK ) {
- PANIC(); /* Can't find fd */
- }
- fd_unlock( fd, FD_WRITE );
- break;
-
- case PS_SELECT_WAIT:
- data = pthread_run->data.select_data;
-
- CLEAR_PF_GROUP( pthread_run, PF_EVENT_GROUP);
-
- for( i = 0; i < data->nfds; i++) {
- rdlk =(FD_ISSET(i,&data->readfds)
- || FD_ISSET(i,&data->exceptfds));
- wrlk = FD_ISSET(i, &data->writefds);
- lktype = rdlk ? (wrlk ? FD_RDWR : FD_READ) : FD_WRITE;
-
- if( ! (rdlk || wrlk) )
- continue; /* No locks, no unlock */
-
- if( (fd = fd_get_pthread_fd_from_kernel_fd( i )) == NOTOK ) {
- PANIC(); /* Can't find fd */
- }
-
- fd_unlock( fd, lktype );
- }
- break;
-
- case PS_MUTEX_WAIT:
- PANIC(); /* Should never cancel a mutex wait */
-
- default:
- PANIC(); /* Unknown thread status */
- }
-}
-
-/* ==========================================================================
- * fd_lock()
- */
-#define pthread_mutex_lock_timedwait(a, b) pthread_mutex_lock(a)
-
-int fd_lock(unsigned int fd, int lock_type, struct timespec * timeout)
-{
- struct timespec current_time;
- pthread_mutex_t *mutex;
- int error;
-
- if ((error = fd_check_entry(fd)) == OK) {
- mutex = &(fd_table[fd]->mutex);
- if (pthread_mutex_lock_timedwait(mutex, timeout)) {
- SET_ERRNO(ETIMEDOUT);
- return(-ETIMEDOUT);
- }
- error = fd_basic_lock(fd, lock_type, mutex, timeout);
- pthread_mutex_unlock(mutex);
- }
- return(error);
-}
-
-/* ==========================================================================
- * fd_free()
- *
- * Assumes fd is locked and owner by pthread_run
- * Don't clear the queues, fd_unlock will do that.
- */
-struct fd_table_entry * fd_free(int fd)
-{
- struct fd_table_entry *fd_valid;
-
- fd_valid = NULL;
- fd_table[fd]->r_lockcount = 0;
- fd_table[fd]->w_lockcount = 0;
- if (--fd_table[fd]->count) {
- fd_valid = fd_table[fd];
- fd_table[fd] = fd_table[fd]->next;
- fd_valid->next = fd_table[fd]->next;
- /* Don't touch queues of fd_valid */
- }
-
- fd_table[fd]->type = FD_NIU;
- fd_table[fd]->fd.i = NOTOK;
- fd_table[fd]->next = NULL;
- fd_table[fd]->flags = 0;
- fd_table[fd]->count = 0;
- return(fd_valid);
-}
-
-
-/* ==========================================================================
- * ======================================================================= */
-
-/* ==========================================================================
- * read_timedwait()
- */
-ssize_t read_timedwait(int fd, void *buf, size_t nbytes,
- struct timespec * timeout)
-{
- int ret;
-
- if ((ret = fd_lock(fd, FD_READ, NULL)) == OK) {
- ret = fd_table[fd]->ops->read(fd_table[fd]->fd,
- fd_table[fd]->flags, buf, nbytes, timeout);
- fd_unlock(fd, FD_READ);
- }
- return(ret);
-}
-
-/* ==========================================================================
- * read()
- */
-ssize_t read(int fd, void *buf, size_t nbytes)
-{
- return(read_timedwait(fd, buf, nbytes, NULL));
-}
-
-/* ==========================================================================
- * readv_timedwait()
- */
-int readv_timedwait(int fd, const struct iovec *iov, int iovcnt,
- struct timespec * timeout)
-{
- int ret;
-
- if ((ret = fd_lock(fd, FD_READ, NULL)) == OK) {
- ret = fd_table[fd]->ops->readv(fd_table[fd]->fd,
- fd_table[fd]->flags, iov, iovcnt, timeout);
- fd_unlock(fd, FD_READ);
- }
- return(ret);
-}
-
-/* ==========================================================================
- * readv()
- */
-ssize_t readv(int fd, const struct iovec *iov, int iovcnt)
-{
- return(readv_timedwait(fd, iov, iovcnt, NULL));
-}
-
-/* ==========================================================================
- * write()
- */
-ssize_t write_timedwait(int fd, const void *buf, size_t nbytes,
- struct timespec * timeout)
-{
- int ret;
-
- if ((ret = fd_lock(fd, FD_WRITE, NULL)) == OK)
- {
- ret = fd_table[fd]->ops->write(fd_table[fd]->fd,
- fd_table[fd]->flags, buf, nbytes,
- timeout);
- fd_unlock(fd, FD_WRITE);
- }
- return(ret);
-}
-
-/* ==========================================================================
- * write()
- */
-ssize_t write(int fd, const void * buf, size_t nbytes)
-{
- return(write_timedwait(fd, buf, nbytes, NULL));
-}
-
-/* ==========================================================================
- * writev_timedwait()
- */
-int writev_timedwait(int fd, const struct iovec *iov, int iovcnt,
- struct timespec * timeout)
-{
- int ret;
-
- if ((ret = fd_lock(fd, FD_WRITE, NULL)) == OK) {
- ret = fd_table[fd]->ops->writev(fd_table[fd]->fd,
- fd_table[fd]->flags, iov, iovcnt, timeout);
- fd_unlock(fd, FD_WRITE);
- }
- return(ret);
-}
-
-/* ==========================================================================
- * writev()
- */
-ssize_t writev(int fd, const struct iovec *iov, int iovcnt)
-{
- return(writev_timedwait(fd, iov, iovcnt, NULL));
-}
-
-/* ==========================================================================
- * lseek()
- */
-off_t lseek(int fd, off_t offset, int whence)
-{
- int ret;
-
- if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
- ret = fd_table[fd]->ops->seek(fd_table[fd]->fd,
- fd_table[fd]->flags, offset, whence);
- fd_unlock(fd, FD_RDWR);
- }
- return(ret);
-}
-
-/* ==========================================================================
- * close()
- *
- * The whole close procedure is a bit odd and needs a bit of a rethink.
- * For now close() locks the fd, calls fd_free() which checks to see if
- * there are any other fd values poinging to the same real fd. If so
- * It breaks the wait queue into two sections those that are waiting on fd
- * and those waiting on other fd's. Those that are waiting on fd are connected
- * to the fd_table[fd] queue, and the count is set to zero, (BUT THE LOCK IS NOT
- * RELEASED). close() then calls fd_unlock which give the fd to the next queued
- * element which determins that the fd is closed and then calls fd_unlock etc...
- *
- * XXX close() is even uglier now. You may assume that the kernel fd is the
- * same as fd if fd_table[fd] == NULL or if fd_table[fd]->type == FD_NT.
- * This is true because before any fd_table[fd] is allocated the corresponding
- * kernel fd must be checks to see if it's valid.
- */
-int close(int fd)
-{
- struct fd_table_entry * entry;
- pthread_mutex_t *mutex;
- union fd_data realfd;
- int ret, flags;
-
- if(fd < 0 || fd >= dtablesize)
- {
- SET_ERRNO(EBADF);
- return -1;
- }
- /* Need to lock the newfd by hand */
- pthread_mutex_lock(&fd_table_mutex);
- if (fd_table[fd]) {
- pthread_mutex_unlock(&fd_table_mutex);
- mutex = &(fd_table[fd]->mutex);
- pthread_mutex_lock(mutex);
-
- /*
- * XXX Gross hack ... because of fork(), any fd closed by the
- * parent should not change the fd of the child, unless it owns it.
- */
- switch(fd_table[fd]->type) {
- case FD_NIU:
- pthread_mutex_unlock(mutex);
- ret = -EBADF;
- break;
- case FD_NT:
- /*
- * If it's not tested then the only valid possibility is it's
- * kernel fd.
- */
- ret = machdep_sys_close(fd);
- fd_table[fd]->type = FD_NIU;
- pthread_mutex_unlock(mutex);
- break;
- case FD_TEST_FULL_DUPLEX:
- case FD_TEST_HALF_DUPLEX:
- realfd = fd_table[fd]->fd;
- flags = fd_table[fd]->flags;
- if ((entry = fd_free(fd)) == NULL) {
- ret = fd_table[fd]->ops->close(realfd, flags);
- } else {
- /* There can't be any others waiting for fd. */
- pthread_mutex_unlock(&entry->mutex);
- /* Note: entry->mutex = mutex */
- mutex = &(fd_table[fd]->mutex);
- }
- pthread_mutex_unlock(mutex);
- break;
- default:
- ret = fd_basic_lock(fd, FD_RDWR, mutex, NULL);
- if (ret == OK) {
- realfd = fd_table[fd]->fd;
- flags = fd_table[fd]->flags;
- pthread_mutex_unlock(mutex);
- if ((entry = fd_free(fd)) == NULL) {
- ret = fd_table[fd]->ops->close(realfd, flags);
- } else {
- fd_basic_basic_unlock(entry, FD_RDWR);
- pthread_mutex_unlock(&entry->mutex);
- /* Note: entry->mutex = mutex */
- }
- fd_unlock(fd, FD_RDWR);
- } else {
- pthread_mutex_unlock(mutex);
- }
- break;
- }
- } else {
- /* Don't bother creating a table entry */
- pthread_mutex_unlock(&fd_table_mutex);
- ret = machdep_sys_close(fd);
- }
- if( ret < 0) {
- SET_ERRNO(-ret);
- ret = -1;
- }
- return(ret);
-}
-
-/* ==========================================================================
- * fd_basic_dup()
- *
- *
- * This is a MAJOR guess!! I don't know if the mutext unlock is valid
- * in the BIG picture. But it seems to be needed to avoid deadlocking
- * with ourselves when we try to close the duped file descriptor.
- */
-static inline void fd_basic_dup(int fd, int newfd)
-{
- fd_table[newfd]->next = fd_table[fd]->next;
- fd_table[fd]->next = fd_table[newfd];
- fd_table[newfd] = fd_table[fd];
- fd_table[fd]->count++;
- pthread_mutex_unlock(&fd_table[newfd]->next->mutex);
-
-}
-
-/* ==========================================================================
- * dup2()
- *
- * Note: Always lock the lower number fd first to avoid deadlocks.
- * Note: Leave the newfd locked. It will be unlocked at close() time.
- * Note: newfd must be locked by hand so it can be closed if it is open,
- * or it won't be opened while dup is in progress.
- */
-int dup2(fd, newfd)
-{
- struct fd_table_entry * entry;
- pthread_mutex_t *mutex;
- union fd_data realfd;
- int ret, flags;
-
- if ((ret = fd_check_entry(newfd)) != OK)
- return ret;
-
- if (newfd < dtablesize) {
- if (fd < newfd) {
- if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
- /* Need to lock the newfd by hand */
- mutex = &(fd_table[newfd]->mutex);
- pthread_mutex_lock(mutex);
-
- /* Is it inuse */
- if (fd_basic_lock(newfd, FD_RDWR, mutex, NULL) == OK) {
- realfd = fd_table[newfd]->fd;
- flags = fd_table[newfd]->flags;
- /* free it and check close status */
- if ((entry = fd_free(newfd)) == NULL) {
- entry = fd_table[newfd];
- entry->ops->close(realfd, flags);
- if (entry->r_queue.q_next) {
- if (fd_table[fd]->next) {
- fd_table[fd]->r_queue.q_last->next =
- entry->r_queue.q_next;
- } else {
- fd_table[fd]->r_queue.q_next =
- entry->r_queue.q_next;
- }
- fd_table[fd]->r_queue.q_last =
- entry->r_queue.q_last;
- }
- if (entry->w_queue.q_next) {
- if (fd_table[fd]->next) {
- fd_table[fd]->w_queue.q_last->next =
- entry->w_queue.q_next;
- } else {
- fd_table[fd]->w_queue.q_next =
- entry->w_queue.q_next;
- }
- fd_table[fd]->w_queue.q_last =
- entry->w_queue.q_last;
- }
- entry->r_queue.q_next = NULL;
- entry->w_queue.q_next = NULL;
- entry->r_queue.q_last = NULL;
- entry->w_queue.q_last = NULL;
- entry->r_owner = NULL;
- entry->w_owner = NULL;
- ret = OK;
- } else {
- fd_basic_basic_unlock(entry, FD_RDWR);
- pthread_mutex_unlock(&entry->mutex);
- /* Note: entry->mutex = mutex */
- }
- }
- fd_basic_dup(fd, newfd);
- }
- fd_unlock(fd, FD_RDWR);
- } else {
- /* Need to lock the newfd by hand */
- mutex = &(fd_table[newfd]->mutex);
- pthread_mutex_lock(mutex);
-
- if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
- /* Is newfd inuse */
- if ((ret = fd_basic_lock(newfd, FD_RDWR, mutex, NULL)) == OK) {
- realfd = fd_table[newfd]->fd;
- flags = fd_table[newfd]->flags;
- /* free it and check close status */
- if ((entry = fd_free(newfd)) == NULL) {
- entry = fd_table[newfd];
- entry->ops->close(realfd, flags);
- if (entry->r_queue.q_next) {
- if (fd_table[fd]->next) {
- fd_table[fd]->r_queue.q_last->next =
- entry->r_queue.q_next;
- } else {
- fd_table[fd]->r_queue.q_next =
- entry->r_queue.q_next;
- }
- fd_table[fd]->r_queue.q_last =
- entry->r_queue.q_last;
- }
- if (entry->w_queue.q_next) {
- if (fd_table[fd]->next) {
- fd_table[fd]->w_queue.q_last->next =
- entry->w_queue.q_next;
- } else {
- fd_table[fd]->w_queue.q_next =
- entry->w_queue.q_next;
- }
- fd_table[fd]->w_queue.q_last =
- entry->w_queue.q_last;
- }
- entry->r_queue.q_next = NULL;
- entry->w_queue.q_next = NULL;
- entry->r_queue.q_last = NULL;
- entry->w_queue.q_last = NULL;
- entry->r_owner = NULL;
- entry->w_owner = NULL;
- ret = OK;
- } else {
- fd_basic_basic_unlock(entry, FD_RDWR);
- pthread_mutex_unlock(&entry->mutex);
- /* Note: entry->mutex = mutex */
- }
- fd_basic_dup(fd, newfd);
- }
- fd_unlock(fd, FD_RDWR);
- }
- }
- } else {
- ret = NOTOK;
- }
- return(ret);
-
-}
-
-/* ==========================================================================
- * dup()
- */
-int dup(int fd)
-{
- int ret;
-
- if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
- ret = fd_allocate();
- fd_basic_dup(fd, ret);
- fd_unlock(fd, FD_RDWR);
- }
- return(ret);
-}
-
-/* ==========================================================================
- * fcntl()
- */
-int fcntl(int fd, int cmd, ...)
-{
- int ret, realfd, flags;
- struct flock *flock;
- semaphore *plock;
- va_list ap;
-
- flags = 0;
- if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
- va_start(ap, cmd);
- switch(cmd) {
- case F_DUPFD:
- ret = fd_allocate();
- fd_basic_dup(va_arg(ap, int), ret);
- break;
- case F_SETFD:
- break;
- case F_GETFD:
- break;
- case F_GETFL:
- ret = fd_table[fd]->flags;
- break;
- case F_SETFL:
- flags = va_arg(ap, int);
- if ((ret = fd_table[fd]->ops->fcntl(fd_table[fd]->fd,
- fd_table[fd]->flags, cmd, flags | __FD_NONBLOCK)) == OK) {
- fd_table[fd]->flags = flags;
- }
- break;
-/* case F_SETLKW: */
- /*
- * Do the same as SETLK but if it fails with EACCES or EAGAIN
- * block the thread and try again later, not implemented yet
- */
-/* case F_SETLK: */
-/* case F_GETLK:
- flock = va_arg(ap, struct flock*);
- ret = fd_table[fd]->ops->fcntl(fd_table[fd]->fd,
- fd_table[fd]->flags, cmd, flock);
- break; */
- default:
- /* Might want to make va_arg use a union */
- ret = fd_table[fd]->ops->fcntl(fd_table[fd]->fd,
- fd_table[fd]->flags, cmd, va_arg(ap, void*));
- break;
- }
- va_end(ap);
- fd_unlock(fd, FD_RDWR);
- }
- return(ret);
-}
-
-/* ==========================================================================
- * getdtablesize()
- */
-int getdtablesize()
-{
- return dtablesize;
-}
-
-/* ==========================================================================
- * ioctl()
- *
- * Really want to do a real implementation of this that parses the args ala
- * fcntl(), above, but it will have to be a totally platform-specific,
- * nightmare-on-elm-st-style sort of thing. Might even deserve its own file
- * ala select()... --SNL
- */
-#ifndef ioctl_request_type
-#define ioctl_request_type unsigned long /* Dummy patch by Monty */
-#endif
-
-int
-ioctl(int fd, ioctl_request_type request, ...)
-{
- int ret;
- pthread_va_list ap;
- caddr_t arg;
-
- va_start( ap, request ); /* Get the arg */
- arg = va_arg(ap,caddr_t);
- va_end( ap );
-
- if (fd < 0 || fd >= dtablesize)
- ret = NOTOK;
- else if (fd_table[fd]->fd.i == NOTOK)
- ret = machdep_sys_ioctl(fd, request, arg);
- else if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
- ret = machdep_sys_ioctl(fd_table[fd]->fd.i, request, arg);
- if( ret == 0 && request == FIONBIO ) {
- /* Properly set NONBLOCK flag */
- int v = *(int *)arg;
- if( v )
- fd_table[fd]->flags |= __FD_NONBLOCK;
- else
- fd_table[fd]->flags &= ~__FD_NONBLOCK;
- }
- fd_unlock(fd, FD_RDWR);
- }
- return ret;
-}
-
diff --git a/lib/libpthread/pthreads/fd_kern.c b/lib/libpthread/pthreads/fd_kern.c
deleted file mode 100644
index 23b7b074e21..00000000000
--- a/lib/libpthread/pthreads/fd_kern.c
+++ /dev/null
@@ -1,1838 +0,0 @@
-/* ==== fd_kern.c ============================================================
- * Copyright (c) 1993, 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 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.
- *
- * Description : Deals with the valid kernel fds.
- *
- * 1.00 93/09/27 proven
- * -Started coding this file.
- *
- * 1.01 93/11/13 proven
- * -The functions readv() and writev() added.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: fd_kern.c,v 1.3 1998/07/22 10:46:51 peter Exp $";
-#endif
-
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/compat.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/uio.h>
-#include <stdarg.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <pthread/posix.h>
-#include <string.h>
-
-pthread_ssize_t machdep_sys_send (int fd, const void *msg, size_t len,
- int flags)
-{
- return machdep_sys_sendto (fd, msg, len, flags,
- (const struct sockaddr *) 0, 0);
-}
-
-pthread_ssize_t machdep_sys_recv (int fd, void *buf, size_t len, int flags)
-{
- return machdep_sys_recvfrom (fd, buf, len, flags,
- (struct sockaddr *) 0, (int *) 0);
-}
-
-/* ==========================================================================
- * Check if there is any signal with must be handled. Added by Monty
- * This could be somewhat system dependent but it should work.
- */
-
-static int fd_check_if_pending_signal(struct pthread *pthread)
-{
- int i;
- unsigned long *pending,*mask;
- if (!pthread->sigcount)
- return 0;
- pending= (unsigned long*) &pthread->sigpending;
- mask= (unsigned long*) &pthread->sigmask;
-
- for (i=0 ; i < sizeof(pthread->sigpending)/sizeof(unsigned long); i++)
- {
- if (*pending && (*mask ^ (unsigned) ~0L))
- return 1;
- pending++;
- mask++;
- }
- return 0;
-}
-
-/* ==========================================================================
- * Variables used by both fd_kern_poll and fd_kern_wait
- */
-struct pthread_queue fd_wait_read = PTHREAD_QUEUE_INITIALIZER;
-struct pthread_queue fd_wait_write = PTHREAD_QUEUE_INITIALIZER;
-struct pthread_queue fd_wait_select = PTHREAD_QUEUE_INITIALIZER;
-
-static struct timeval __fd_kern_poll_timeout = { 0, 0 }; /* Moved by monty */
-extern struct timeval __fd_kern_wait_timeout;
-extern volatile sig_atomic_t sig_to_process;
-
-/*
- * ==========================================================================
- * Do a select if there is someting to wait for.
- * This is to a combination of the old fd_kern_poll() and fd_kern_wait()
- * Return 1 if nothing to do.
- */
-
-static int fd_kern_select(struct timeval *timeout)
-{
- fd_set fd_set_read, fd_set_write, fd_set_except;
- struct pthread *pthread, *deq;
- int count, i;
-
- if (!fd_wait_read.q_next && !fd_wait_write.q_next && !fd_wait_select.q_next)
- return 1; /* Nothing to do */
-
- FD_ZERO(&fd_set_read);
- FD_ZERO(&fd_set_write);
- FD_ZERO(&fd_set_except);
- for (pthread = fd_wait_read.q_next; pthread; pthread = pthread->next)
- FD_SET(pthread->data.fd.fd, &fd_set_read);
- for (pthread = fd_wait_write.q_next; pthread; pthread = pthread->next)
- FD_SET(pthread->data.fd.fd, &fd_set_write);
- for (pthread = fd_wait_select.q_next; pthread; pthread = pthread->next)
- {
- for (i = 0; i < pthread->data.select_data->nfds; i++) {
- if (FD_ISSET(i, &pthread->data.select_data->exceptfds))
- FD_SET(i, &fd_set_except);
- if (FD_ISSET(i, &pthread->data.select_data->writefds))
- FD_SET(i, &fd_set_write);
- if (FD_ISSET(i, &pthread->data.select_data->readfds))
- FD_SET(i, &fd_set_read);
- }
- }
-
- /* Turn off interrupts for real while we set the timer. */
-
- if (timeout == &__fd_kern_wait_timeout)
- { /* from fd_kern_wait() */
- sigset_t sig_to_block, oset;
- sigfillset(&sig_to_block);
- machdep_sys_sigprocmask(SIG_BLOCK, &sig_to_block, &oset);
-
- machdep_unset_thread_timer(NULL);
- __fd_kern_wait_timeout.tv_usec = 0;
- __fd_kern_wait_timeout.tv_sec = (sig_to_process) ? 0 : 3600;
-
- machdep_sys_sigprocmask(SIG_UNBLOCK, &sig_to_block, &oset);
- }
- /*
- * There is a small but finite chance that an interrupt will
- * occure between the unblock and the select. Because of this
- * sig_handler_real() sets the value of __fd_kern_wait_timeout
- * to zero causing the select to do a poll instead of a wait.
- */
-
- while ((count = machdep_sys_select(dtablesize, &fd_set_read,
- &fd_set_write, &fd_set_except,
- timeout)) < OK)
- {
- if (count == -EINTR)
- return 0;
- PANIC();
- }
-
- for (pthread = fd_wait_read.q_next; pthread; ) {
- if (count && FD_ISSET(pthread->data.fd.fd, &fd_set_read) ||
- fd_check_if_pending_signal(pthread))
- {
- if (FD_ISSET(pthread->data.fd.fd, &fd_set_read))
- count--;
- deq = pthread;
- pthread = pthread->next;
- pthread_queue_remove(&fd_wait_read, deq);
- if (SET_PF_DONE_EVENT(deq) == OK) {
- pthread_prio_queue_enq(pthread_current_prio_queue, deq);
- deq->state = PS_RUNNING;
- }
- continue;
- }
- pthread = pthread->next;
- }
-
- for (pthread = fd_wait_write.q_next; pthread; ) {
- if (count && FD_ISSET(pthread->data.fd.fd, &fd_set_write) ||
- fd_check_if_pending_signal(pthread))
- {
- if (FD_ISSET(pthread->data.fd.fd, &fd_set_read))
- count--;
- deq = pthread;
- pthread = pthread->next;
- pthread_queue_remove(&fd_wait_write, deq);
- if (SET_PF_DONE_EVENT(deq) == OK) {
- pthread_prio_queue_enq(pthread_current_prio_queue, deq);
- deq->state = PS_RUNNING;
- }
- continue;
- }
- pthread = pthread->next;
- }
-
- for (pthread = fd_wait_select.q_next; pthread; )
- {
- int found_one=0; /* Loop fixed by monty */
- if (count)
- {
- fd_set tmp_readfds, tmp_writefds, tmp_exceptfds;
- memcpy(&tmp_readfds, &pthread->data.select_data->readfds,
- sizeof(fd_set));
- memcpy(&tmp_writefds, &pthread->data.select_data->writefds,
- sizeof(fd_set));
- memcpy(&tmp_exceptfds, &pthread->data.select_data->exceptfds,
- sizeof(fd_set));
-
- for (i = 0; i < pthread->data.select_data->nfds; i++) {
- if (FD_ISSET(i, &tmp_exceptfds))
- {
- if (! FD_ISSET(i, &fd_set_except))
- FD_CLR(i, &tmp_exceptfds);
- else
- found_one=1;
- }
- if (FD_ISSET(i, &tmp_writefds))
- {
- if (! FD_ISSET(i, &fd_set_write))
- FD_CLR(i, &tmp_writefds);
- else
- found_one=1;
- }
- if (FD_ISSET(i, &tmp_readfds))
- {
- if (! FD_ISSET(i, &fd_set_read))
- FD_CLR(i, &tmp_readfds);
- else
- found_one=1;
- }
- }
- if (found_one)
- {
- memcpy(&pthread->data.select_data->readfds, &tmp_readfds,
- sizeof(fd_set));
- memcpy(&pthread->data.select_data->writefds, &tmp_writefds,
- sizeof(fd_set));
- memcpy(&pthread->data.select_data->exceptfds, &tmp_exceptfds,
- sizeof(fd_set));
- }
- }
- if (found_one || fd_check_if_pending_signal(pthread))
- {
- deq = pthread;
- pthread = pthread->next;
- pthread_queue_remove(&fd_wait_select, deq);
- if (SET_PF_DONE_EVENT(deq) == OK) {
- pthread_prio_queue_enq(pthread_current_prio_queue, deq);
- deq->state = PS_RUNNING;
- }
- } else {
- pthread = pthread->next;
- }
- }
- return 0;
-}
-
-
-/* ==========================================================================
- * fd_kern_poll()
- *
- * Called only from context_switch(). The kernel must be locked.
- *
- * This function uses a linked list of waiting pthreads, NOT a queue.
- */
-
-void fd_kern_poll()
-{
- fd_kern_select(&__fd_kern_poll_timeout);
-}
-
-
-/* ==========================================================================
- * fd_kern_wait()
- *
- * Called when there is no active thread to run.
- */
-
-void fd_kern_wait()
-{
- if (fd_kern_select(&__fd_kern_wait_timeout))
- /* No threads, waiting on I/O, do a sigsuspend */
- sig_handler_pause();
-}
-
-
-/* ==========================================================================
- * Special Note: All operations return the errno as a negative of the errno
- * listed in errno.h
- * ======================================================================= */
-
-/* ==========================================================================
- * read()
- */
-pthread_ssize_t __fd_kern_read(union fd_data fd_data, int flags, void *buf,
- size_t nbytes, struct timespec * timeout)
-{
- int fd = fd_data.i;
- int ret;
-
- pthread_run->sighandled=0; /* Added by monty */
- while ((ret = machdep_sys_read(fd, buf, nbytes)) < OK) {
- if (!(flags & __FD_NONBLOCK) &&
- ((ret == -EWOULDBLOCK) || (ret == -EAGAIN))) {
- pthread_sched_prevent();
-
- /* queue pthread for a FDR_WAIT */
- SET_PF_WAIT_EVENT(pthread_run);
- pthread_run->data.fd.fd = fd;
- pthread_queue_enq(&fd_wait_read, pthread_run);
-
- if (timeout) {
- /* get current time */
- struct timespec current_time;
- machdep_gettimeofday(&current_time);
- sleep_schedule(&current_time, timeout);
-
- SET_PF_AT_CANCEL_POINT(pthread_run);
- pthread_resched_resume(PS_FDR_WAIT);
- CLEAR_PF_AT_CANCEL_POINT(pthread_run);
-
- /* We're awake */
- pthread_sched_prevent();
- if (sleep_cancel(pthread_run) == NOTOK) {
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- SET_ERRNO(ETIMEDOUT);
- ret= NOTOK;
- break;
- }
- pthread_sched_resume();
- } else {
- SET_PF_AT_CANCEL_POINT(pthread_run);
- pthread_resched_resume(PS_FDR_WAIT);
- CLEAR_PF_AT_CANCEL_POINT(pthread_run);
- }
- CLEAR_PF_DONE_EVENT(pthread_run);
- if (pthread_run->sighandled) /* Added by monty */
- { /* We where aborted */
- SET_ERRNO(EINTR);
- ret= NOTOK;
- break;
- }
- } else {
- SET_ERRNO(-ret);
- ret = NOTOK;
- break;
- }
- }
- return(ret);
-}
-
-/* ==========================================================================
- * readv()
- */
-int __fd_kern_readv(union fd_data fd_data, int flags, const struct iovec *iov,
- int iovcnt, struct timespec * timeout)
-{
- int fd = fd_data.i;
- int ret;
-
- pthread_run->sighandled=0; /* Added by monty */
- while ((ret = machdep_sys_readv(fd, iov, iovcnt)) < OK) {
- if (!(flags & __FD_NONBLOCK) &&
- ((ret == -EWOULDBLOCK) || (ret == -EAGAIN))) {
- pthread_sched_prevent();
-
- /* queue pthread for a FDR_WAIT */
- pthread_run->data.fd.fd = fd;
- SET_PF_WAIT_EVENT(pthread_run);
- pthread_queue_enq(&fd_wait_read, pthread_run);
-
- if (timeout) {
- /* get current time */
- struct timespec current_time;
- machdep_gettimeofday(&current_time);
- sleep_schedule(&current_time, timeout);
-
- SET_PF_AT_CANCEL_POINT(pthread_run);
- pthread_resched_resume(PS_FDW_WAIT);
- CLEAR_PF_AT_CANCEL_POINT(pthread_run);
-
- /* We're awake */
- pthread_sched_prevent();
- if (sleep_cancel(pthread_run) == NOTOK) {
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- SET_ERRNO(ETIMEDOUT);
- ret = NOTOK;
- break;
- }
- pthread_sched_resume();
- } else {
- SET_PF_AT_CANCEL_POINT(pthread_run);
- pthread_resched_resume(PS_FDW_WAIT);
- CLEAR_PF_AT_CANCEL_POINT(pthread_run);
- }
- CLEAR_PF_DONE_EVENT(pthread_run);
- if (pthread_run->sighandled) /* Added by monty */
- { /* We where aborted */
- SET_ERRNO(EINTR);
- ret= NOTOK;
- break;
- }
- } else {
- SET_ERRNO(-ret);
- ret = NOTOK;
- break;
- }
- }
- return(ret);
-}
-
-/* ==========================================================================
- * write()
- */
-pthread_ssize_t __fd_kern_write(union fd_data fd_data, int flags,
- const void *buf, size_t nbytes, struct timespec * timeout)
-{
- int fd = fd_data.i;
- int ret;
-
- pthread_run->sighandled=0; /* Added by monty */
- while ((ret = machdep_sys_write(fd, buf, nbytes)) < OK) {
- if (!(flags & __FD_NONBLOCK) &&
- ((ret == -EWOULDBLOCK) || (ret == -EAGAIN))) {
- pthread_sched_prevent();
-
- /* queue pthread for a FDW_WAIT */
- pthread_run->data.fd.fd = fd;
- SET_PF_WAIT_EVENT(pthread_run);
- pthread_queue_enq(&fd_wait_write, pthread_run);
-
- if (timeout) {
- /* get current time */
- struct timespec current_time;
- machdep_gettimeofday(&current_time);
- sleep_schedule(&current_time, timeout);
-
- pthread_resched_resume(PS_FDW_WAIT);
-
- /* We're awake */
- pthread_sched_prevent();
- if (sleep_cancel(pthread_run) == NOTOK) {
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- SET_ERRNO(ETIMEDOUT);
- ret = NOTOK;
- break;
- }
- pthread_sched_resume();
- } else {
- pthread_resched_resume(PS_FDW_WAIT);
- }
- CLEAR_PF_DONE_EVENT(pthread_run);
- if (pthread_run->sighandled) /* Added by monty */
- { /* We where aborted */
- SET_ERRNO(EINTR);
- ret= NOTOK;
- break;
- }
- } else {
- SET_ERRNO(-ret);
- ret = NOTOK;
- break;
- }
- }
- return(ret);
-}
-
-/* ==========================================================================
- * writev()
- */
-int __fd_kern_writev(union fd_data fd_data, int flags, const struct iovec *iov,
- int iovcnt, struct timespec * timeout)
-{
- int fd = fd_data.i;
- int ret;
-
- pthread_run->sighandled=0; /* Added by monty */
- while ((ret = machdep_sys_writev(fd, iov, iovcnt)) < OK) {
- if (!(flags & __FD_NONBLOCK) &&
- ((ret == -EWOULDBLOCK) || (ret == -EAGAIN))) {
- pthread_sched_prevent();
-
- /* queue pthread for a FDW_WAIT */
- pthread_run->data.fd.fd = fd;
- SET_PF_WAIT_EVENT(pthread_run);
- pthread_queue_enq(&fd_wait_write, pthread_run);
-
- if (timeout) {
- /* get current time */
- struct timespec current_time;
- machdep_gettimeofday(&current_time);
- sleep_schedule(&current_time, timeout);
-
- pthread_resched_resume(PS_FDW_WAIT);
-
- /* We're awake */
- pthread_sched_prevent();
- if (sleep_cancel(pthread_run) == NOTOK) {
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- SET_ERRNO(ETIMEDOUT);
- ret = NOTOK;
- break;
- }
- pthread_sched_resume();
- } else {
- pthread_resched_resume(PS_FDW_WAIT);
- }
- CLEAR_PF_DONE_EVENT(pthread_run);
- if (pthread_run->sighandled) /* Added by monty */
- { /* We where aborted */
- SET_ERRNO(EINTR);
- ret= NOTOK;
- break;
- }
- } else {
- break;
- }
- }
- return(ret);
-}
-
-/* ==========================================================================
- * For blocking version we really should set an interrupt
- * fcntl()
- */
-int __fd_kern_fcntl(union fd_data fd_data, int flags, int cmd, int arg)
-{
- int fd = fd_data.i;
-
- return(machdep_sys_fcntl(fd, cmd, arg));
-}
-
-/* ==========================================================================
- * close()
- */
-int __fd_kern_close(union fd_data fd_data, int flags)
-{
- int fd = fd_data.i;
-
- return(machdep_sys_close(fd));
-}
-
-/* ==========================================================================
- * lseek()
- * Assume that error number is in the range 0- 255 to get bigger
- * range of seek. ; Monty
- */
-off_t __fd_kern_lseek(union fd_data fd_data, int f, off_t offset, int whence)
-{
- int fd = fd_data.i;
- off_t ret=machdep_sys_lseek(fd, offset, whence);
- if ((long) ret < 0L && (long) ret >= -255L)
- {
- SET_ERRNO(ret);
- ret= NOTOK;
- }
- return ret;
-}
-
-/*
- * File descriptor operations
- */
-extern machdep_sys_close();
-
-/* Normal file operations */
-static struct fd_ops __fd_kern_ops = {
- __fd_kern_write, __fd_kern_read, __fd_kern_close, __fd_kern_fcntl,
- __fd_kern_writev, __fd_kern_readv, __fd_kern_lseek, 1
-};
-
-/* NFS file opperations */
-
-/* FIFO file opperations */
-
-/* Device operations */
-
-/* ==========================================================================
- * open()
- *
- * Because open could potentially block opening a file from a remote
- * system, we want to make sure the call will timeout. We then try and open
- * the file, and stat the file to determine what operations we should
- * associate with the fd.
- *
- * This is not done yet
- *
- * A regular file on the local system needs no special treatment.
- */
-int open(const char *path, int flags, ...)
-{
- int fd, mode, fd_kern;
- struct stat stat_buf;
- va_list ap;
-
- /* If pthread scheduling == FIFO set a virtual timer */
- if (flags & O_CREAT) {
- va_start(ap, flags);
- mode = va_arg(ap, int);
- va_end(ap);
- } else {
- mode = 0;
- }
-
- if (!((fd = fd_allocate()) < OK)) {
- fd_table[fd]->flags = flags;
- flags |= __FD_NONBLOCK;
-
- if (!((fd_kern = machdep_sys_open(path, flags, mode)) < OK)) {
-
- /* fstat the file to determine what type it is */
- if (machdep_sys_fstat(fd_kern, &stat_buf)) {
- PANIC();
- }
- if (S_ISREG(stat_buf.st_mode)) {
- fd_table[fd]->ops = &(__fd_kern_ops);
- fd_table[fd]->type = FD_HALF_DUPLEX;
- } else {
- fd_table[fd]->ops = &(__fd_kern_ops);
- fd_table[fd]->type = FD_FULL_DUPLEX;
- }
- fd_table[fd]->fd.i = fd_kern;
- return(fd);
- }
-
- fd_table[fd]->count = 0;
- SET_ERRNO(-fd_kern);
- }
- return(NOTOK);
-}
-
-/* ==========================================================================
- * create()
- */
-int create(const char *path, mode_t mode)
-{
- return creat (path, mode);
-}
-
-/* ==========================================================================
- * creat()
- */
-#undef creat
-
-int creat(const char *path, mode_t mode)
-{
- return open (path, O_CREAT | O_TRUNC | O_WRONLY, mode);
-}
-
-/* ==========================================================================
- * fchown()
- */
-int fchown(int fd, uid_t owner, gid_t group)
-{
- int ret;
-
- if ((ret = fd_lock(fd, FD_WRITE, NULL)) == OK) {
- if ((ret = machdep_sys_fchown(fd_table[fd]->fd.i, owner, group)) < OK) {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
- fd_unlock(fd, FD_WRITE);
- }
- return(ret);
-}
-
-/* ==========================================================================
- * fchmod()
- */
-int fchmod(int fd, mode_t mode)
-{
- int ret;
-
- if ((ret = fd_lock(fd, FD_WRITE, NULL)) == OK) {
- if ((ret = machdep_sys_fchmod(fd_table[fd]->fd.i, mode)) < OK) {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
- fd_unlock(fd, FD_WRITE);
- }
- return(ret);
-}
-
-/* ==========================================================================
- * ftruncate()
- */
-int ftruncate(int fd, off_t length)
-{
- int ret;
-
- if ((ret = fd_lock(fd, FD_WRITE, NULL)) == OK) {
- if ((ret = machdep_sys_ftruncate(fd_table[fd]->fd.i, length)) < OK) {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
- fd_unlock(fd, FD_WRITE);
- }
- return(ret);
-}
-
-/* ==========================================================================
- * flock()
- *
- * Added (mevans)
- */
-int flock(int fd, int operation)
-{
- int ret;
-
- if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
- if ((ret = machdep_sys_flock(fd_table[fd]->fd.i,
- operation)) < OK) {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
- fd_unlock(fd, FD_RDWR);
- }
- return(ret);
-}
-
-/* ==========================================================================
- * pipe()
- */
-int pipe(int fds[2])
-{
- int kfds[2];
- int ret;
-
- if ((fds[0] = fd_allocate()) >= OK) {
- if ((fds[1] = fd_allocate()) >= OK) {
- if ((ret = machdep_sys_pipe(kfds)) >= OK) {
- fd_table[fds[0]]->flags = machdep_sys_fcntl(kfds[0], F_GETFL, NULL);
- machdep_sys_fcntl(kfds[0], F_SETFL, fd_table[fds[0]]->flags | __FD_NONBLOCK);
- fd_table[fds[1]]->flags = machdep_sys_fcntl(kfds[1], F_GETFL, NULL);
- machdep_sys_fcntl(kfds[1], F_SETFL, fd_table[fds[1]]->flags | __FD_NONBLOCK);
-
- fd_table[fds[0]]->ops = &(__fd_kern_ops);
- fd_table[fds[1]]->ops = &(__fd_kern_ops);
-
- /* Not really full duplex but ... */
- fd_table[fds[0]]->type = FD_FULL_DUPLEX;
- fd_table[fds[1]]->type = FD_FULL_DUPLEX;
-
- fd_table[fds[0]]->fd.i = kfds[0];
- fd_table[fds[1]]->fd.i = kfds[1];
-
- return(OK);
- } else {
- SET_ERRNO(-ret);
- }
- fd_table[fds[1]]->count = 0;
- }
- fd_table[fds[0]]->count = 0;
- }
- return(NOTOK);
-}
-
-/* ==========================================================================
- * fd_kern_reset()
- * Change the fcntl blocking flag back to NONBLOCKING. This should only
- * be called after a fork.
- */
-void fd_kern_reset(int fd)
-{
- switch (fd_table[fd]->type) {
- case FD_TEST_HALF_DUPLEX:
- machdep_sys_fcntl(fd_table[fd]->fd.i, F_SETFL,
- fd_table[fd]->flags | __FD_NONBLOCK);
- fd_table[fd]->type = FD_HALF_DUPLEX;
- break;
- case FD_TEST_FULL_DUPLEX:
- machdep_sys_fcntl(fd_table[fd]->fd.i, F_SETFL,
- fd_table[fd]->flags | __FD_NONBLOCK);
- fd_table[fd]->type = FD_FULL_DUPLEX;
- break;
- default:
- break;
- }
-}
-
-/* ==========================================================================
- * fd_kern_init()
- *
- * Assume the entry is locked before routine is invoked
- *
- * This may change. The problem is setting the fd to nonblocking changes
- * the parents fd too, which may not be the desired result.
- *
- * New added feature: If the fd in question is a tty then we open it again
- * and close the original, this way we don't have to worry about the
- * fd being NONBLOCKING to the outside world.
- */
-void fd_kern_init(int fd)
-{
- if ((fd_table[fd]->flags = machdep_sys_fcntl(fd, F_GETFL, NULL)) >= OK) {
- if (isatty_basic(fd)) {
- int new_fd;
-
- if ((new_fd = machdep_sys_open(__ttyname_basic(fd), O_RDWR)) >= OK){
- if (machdep_sys_dup2(new_fd, fd) == OK) {
- /* Should print a warning */
-
- /* Should also set the flags to that of opened outside of
- process */
- }
- machdep_sys_close(new_fd);
- }
- }
- /* We do these things regaurdless of the above results */
- machdep_sys_fcntl(fd, F_SETFL, fd_table[fd]->flags | __FD_NONBLOCK);
- fd_table[fd]->ops = &(__fd_kern_ops);
- fd_table[fd]->type = FD_HALF_DUPLEX;
- fd_table[fd]->fd.i = fd;
- fd_table[fd]->count = 1;
-
- }
-}
-
-/* ==========================================================================
- * fd_kern_gettableentry()
- *
- * Remember only return a a file descriptor that I will modify later.
- * Don't return file descriptors that aren't owned by the child, or don't
- * have kernel operations.
- */
-static int fd_kern_gettableentry(const int child, int fd)
-{
- int i;
-
- for (i = 0; i < dtablesize; i++) {
- if (fd_table[i]) {
- if (fd_table[i]->fd.i == fd) {
- if (child) {
- if ((fd_table[i]->type != FD_TEST_HALF_DUPLEX) &&
- (fd_table[i]->type != FD_TEST_FULL_DUPLEX)) {
- continue;
- }
- } else {
- if ((fd_table[i]->type == FD_NT) ||
- (fd_table[i]->type == FD_NIU)) {
- continue;
- }
- }
- /* Is it a kernel fd ? */
- if ((!fd_table[i]->ops) ||
- (fd_table[i]->ops->use_kfds != 1)) {
- continue;
- }
- return(i);
- }
- }
- }
- return(NOTOK);
-}
-
-/* ==========================================================================
- * fd_kern_exec()
- *
- * Fixup the fd_table such that (fd == fd_table[fd]->fd.i) this way
- * the new immage will be OK.
- *
- * Only touch those that won't be used by the parent if we're in a child
- * otherwise fixup all.
- *
- * Returns:
- * 0 no fixup necessary
- * 1 fixup without problems
- * 2 failed fixup on some descriptors, and clobbered them.
- */
-int fd_kern_exec(const int child)
-{
- int ret = 0;
- int fd, i;
-
- for (fd = 0; fd < dtablesize; fd++) {
- if (fd_table[fd] == NULL) {
- continue;
- }
- /* Is the fd already in use ? */
- if (child) {
- if ((fd_table[fd]->type != FD_TEST_HALF_DUPLEX) &&
- (fd_table[fd]->type != FD_TEST_FULL_DUPLEX)) {
- continue;
- }
- } else {
- if ((fd_table[fd]->type == FD_NT) ||
- (fd_table[fd]->type == FD_NIU)) {
- continue;
- }
- }
- /* Is it a kernel fd ? */
- if ((!fd_table[fd]->ops) ||
- (fd_table[fd]->ops->use_kfds != 1)) {
- continue;
- }
- /* Does it match ? */
- if (fd_table[fd]->fd.i == fd) {
- continue;
- }
- /* OK, fixup entry: Read comments before changing. This isn't obvious */
-
- /* i is the real file descriptor fd currently represents */
- if (((i = fd_table[fd]->fd.i) >= dtablesize) || (i < 0)) {
- /* This should never happen */
- PANIC();
- }
-
- /*
- * if the real file descriptor with the same number as the fake file
- * descriptor number fd is actually in use by the program, we have
- * to move it out of the way
- */
- if ((machdep_sys_fcntl(fd, F_GETFL, NULL)) >= OK) {
- /* fd is busy */
- int j;
-
- /*
- * j is the fake file descriptor that represents the real file
- * descriptor that we want to move. This way the fake file
- * descriptor fd can move its real file descriptor i such that
- * fd == i.
- */
- if ((j = fd_kern_gettableentry(child, fd)) >= OK) {
-
- /*
- * Since j represents a fake file descriptor and fd represents
- * a fake file descriptor. If j < fd then a previous pass
- * should have set fd_table[j]->fd.i == j.
- */
- if (fd < j) {
- if ((fd_table[j]->fd.i = machdep_sys_dup(fd)) < OK) {
- /* Close j, there is nothing else we can do */
- fd_table[j]->type = FD_NIU;
- ret = 2;
- }
- } else {
- /* This implies fd_table[j]->fd.i != j */
- PANIC();
- }
- }
- }
-
- /*
- * Here the real file descriptor i is set to equel the fake file
- * descriptor fd
- */
- machdep_sys_dup2(i, fd);
-
- /*
- * Now comes the really complicated part: UNDERSTAND before changing
- *
- * Here are the things this routine wants to do ...
- *
- * Case 1. The real file descriptor has only one fake file descriptor
- * representing it.
- * fd -> i, fd != i ===> fd -> fd, close(i)
- * Example fd = 4, i = 2: then close(2), set fd -> i = 4
- *
- * Case 2. The real file descriptor has more than one fake file
- * descriptor representing it, and this is the first fake file
- * descriptor representing the real file descriptor
- * fd -> i, fd' -> i, fd != i ===> fd -> fd, fd' -> fd, close(i)
- *
- * The problem is achiving the above is very messy and difficult,
- * but I should be able to take a short cut. If fd > i then there
- * will be no need to ever move i, this is because the fake file
- * descriptor foo that we would have wanted to represent the real
- * file descriptor i has already been processed. If fd < i then by
- * moving i to fd all subsequent fake file descriptors fd' should fall
- * into the previous case and won't need aditional adjusting.
- *
- * Does this break the above fd < j check .... It shouldn't because j
- * is a fake file descriptor and if j < fd then j has already moved
- * its real file descriptor foo such that foo <= j therefore foo < fd
- * and not foo == fd therefor j cannot represent the real
- * filedescriptor that fd want to move to and be less than fd
- */
- if (fd < i) {
- fd_table[fd]->fd.i = fd;
- machdep_sys_close(i);
- }
- if (ret < 1) {
- ret = 1;
- }
- }
-}
-
-/* ==========================================================================
- * fd_kern_fork()
- */
-void fd_kern_fork()
-{
- pthread_mutex_t *mutex;
- int fd;
-
- for (fd = 0; fd < dtablesize; fd++) {
- if (fd_table[fd] == NULL) {
- continue;
- }
- mutex = & (fd_table[fd]->mutex);
- if (pthread_mutex_trylock(mutex)) {
- continue;
- }
- if ((fd_table[fd]->r_owner) || (fd_table[fd]->w_owner)) {
- pthread_mutex_unlock(mutex);
- continue;
- }
- /* Is it a kernel fd ? */
- if ((!fd_table[fd]->ops) || (fd_table[fd]->ops->use_kfds != 1)) {
- pthread_mutex_unlock(mutex);
- continue;
- }
- switch (fd_table[fd]->type) {
- case FD_HALF_DUPLEX:
- machdep_sys_fcntl(fd_table[fd]->fd.i, F_SETFL, fd_table[fd]->flags);
- fd_table[fd]->type = FD_TEST_HALF_DUPLEX;
- break;
- case FD_FULL_DUPLEX:
- machdep_sys_fcntl(fd_table[fd]->fd.i, F_SETFL, fd_table[fd]->flags);
- fd_table[fd]->type = FD_TEST_FULL_DUPLEX;
- break;
- default:
- break;
- }
- pthread_mutex_unlock(mutex);
- }
-}
-
-/* ==========================================================================
- * Here are the berkeley socket functions. These are not POSIX.
- * ======================================================================= */
-
-/* ==========================================================================
- * socket()
- */
-int socket(int af, int type, int protocol)
-{
- int fd, fd_kern;
-
- if (!((fd = fd_allocate()) < OK)) {
-
- if (!((fd_kern = machdep_sys_socket(af, type, protocol)) < OK)) {
- int tmp_flags;
-
- tmp_flags = machdep_sys_fcntl(fd_kern, F_GETFL, 0);
- machdep_sys_fcntl(fd_kern, F_SETFL, tmp_flags | __FD_NONBLOCK);
-
- /* Should fstat the file to determine what type it is */
- fd_table[fd]->ops = & __fd_kern_ops;
- fd_table[fd]->type = FD_FULL_DUPLEX;
- fd_table[fd]->fd.i = fd_kern;
- fd_table[fd]->flags = tmp_flags;
- return(fd);
- }
-
- fd_table[fd]->count = 0;
- SET_ERRNO(-fd_kern);
- }
- return(NOTOK);
-}
-
-/* ==========================================================================
- * bind()
- */
-int bind(int fd, const struct sockaddr *name, int namelen)
-{
- /* Not much to do in bind */
- int ret;
-
- if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
- if ((ret = machdep_sys_bind(fd_table[fd]->fd.i, name, namelen)) < OK) {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
- fd_unlock(fd, FD_RDWR);
- }
- return(ret);
-}
-
-/* ==========================================================================
- * connect()
- */
-int connect(int fd, const struct sockaddr *name, int namelen)
-{
- struct sockaddr tmpname;
- int ret, tmpnamelen;
-
- if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
- if ((ret = machdep_sys_connect(fd_table[fd]->fd.i, name, namelen)) < OK) {
- if (!(fd_table[fd]->flags & __FD_NONBLOCK) &&
- ((ret == -EWOULDBLOCK) || (ret == -EINPROGRESS) ||
- (ret == -EALREADY) || (ret == -EAGAIN))) {
- pthread_sched_prevent();
-
- /* queue pthread for a FDW_WAIT */
- SET_PF_WAIT_EVENT(pthread_run);
- pthread_run->data.fd.fd = fd_table[fd]->fd.i;
- pthread_queue_enq(&fd_wait_write, pthread_run);
-
- pthread_resched_resume(PS_FDW_WAIT);
- CLEAR_PF_DONE_EVENT(pthread_run);
-
- tmpnamelen = sizeof(tmpname);
- /* OK now lets see if it really worked */
- if (((ret = machdep_sys_getpeername(fd_table[fd]->fd.i,
- &tmpname, &tmpnamelen)) < OK) &&
- (ret == -ENOTCONN))
- {
- /* Get the error, this function should not fail */
- machdep_sys_getsockopt(fd_table[fd]->fd.i, SOL_SOCKET,
- SO_ERROR, &ret, &tmpnamelen);
- SET_ERRNO(ret); /* ret is already positive (mevans) */
- ret = NOTOK;
- }
- } else {
- if (ret < 0)
- {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
- }
- }
- fd_unlock(fd, FD_RDWR);
- }
- return(ret);
-}
-
-/* ==========================================================================
- * accept()
- */
-int accept(int fd, struct sockaddr *name, int *namelen)
-{
- int ret, fd_kern;
-
- if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
- while ((fd_kern = machdep_sys_accept(fd_table[fd]->fd.i, name, namelen)) < OK) {
- if (!(fd_table[fd]->flags & __FD_NONBLOCK) &&
- ((fd_kern == -EWOULDBLOCK) || (fd_kern == -EAGAIN))) {
- pthread_sched_prevent();
-
- /* queue pthread for a FDR_WAIT */
- SET_PF_WAIT_EVENT(pthread_run);
- pthread_run->data.fd.fd = fd_table[fd]->fd.i;
- pthread_queue_enq(&fd_wait_read, pthread_run);
-
- pthread_resched_resume(PS_FDR_WAIT);
- CLEAR_PF_DONE_EVENT(pthread_run);
- } else {
- fd_unlock(fd, FD_RDWR);
- SET_ERRNO(-fd_kern);
- return(NOTOK);
- }
- }
- fd_unlock(fd, FD_RDWR);
-
- if (!((ret = fd_allocate()) < OK)) {
-
- /* This may be unnecessary */
- machdep_sys_fcntl(fd_kern, F_SETFL, __FD_NONBLOCK);
-
- /* Should fstat the file to determine what type it is */
- fd_table[ret]->ops = & __fd_kern_ops;
- fd_table[ret]->type = FD_FULL_DUPLEX;
- fd_table[ret]->fd.i = fd_kern;
-
- /* XXX Flags should be the same as those on the listening fd */
- fd_table[ret]->flags = fd_table[fd]->flags;
- }
- }
- return(ret);
-}
-
-/* ==========================================================================
- * listen()
- */
-int listen(int fd, int backlog)
-{
- int ret;
-
- if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
- if ((ret = machdep_sys_listen(fd_table[fd]->fd.i, backlog)) < OK) {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
- fd_unlock(fd, FD_RDWR);
- }
- return(ret);
-}
-
-#if 0
-/* ==========================================================================
- * send_timedwait()
- */
-ssize_t send_timedwait(int fd, const void * msg, size_t len, int flags,
- struct timespec * timeout)
-{
- int ret;
-
- pthread_run->sighandled=0; /* Added by monty */
- if ((ret = fd_lock(fd, FD_WRITE, timeout)) == OK) {
- while ((ret = machdep_sys_send(fd_table[fd]->fd.i,
- msg, len, flags)) < OK)
- {
- if (!(fd_table[fd]->flags & __FD_NONBLOCK) &&
- ((ret == -EWOULDBLOCK) || (ret == -EAGAIN)))
- {
- pthread_sched_prevent();
-
- /* queue pthread for a FDW_WAIT */
- SET_PF_WAIT_EVENT(pthread_run);
- pthread_run->data.fd.fd = fd_table[fd]->fd.i;
- pthread_queue_enq(&fd_wait_write, pthread_run);
-
- if (timeout) {
- /* get current time */
- struct timespec current_time;
- machdep_gettimeofday(&current_time);
- sleep_schedule(&current_time, timeout);
-
- pthread_resched_resume(PS_FDW_WAIT);
-
- /* We're awake */
- pthread_sched_prevent();
- if (sleep_cancel(pthread_run) == NOTOK) {
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- ret = -ETIMEDOUT;
- break;
- }
- pthread_sched_resume();
- } else {
- pthread_resched_resume(PS_FDW_WAIT);
- }
- CLEAR_PF_DONE_EVENT(pthread_run);
- if (pthread_run->sighandled) /* Added by monty */
- { /* We where aborted */
- ret= -EINTR;
- break;
- }
- } else {
- break;
- }
- }
- fd_unlock(fd, FD_WRITE);
- }
- if (ret < 0)
- {
- SET_ERRNO(-ret);
- return(NOTOK);
- }
- return ret;
-}
-
-/* ==========================================================================
- * send()
- */
-ssize_t send(int fd, const void * msg, size_t len, int flags)
-{
- return(send_timedwait(fd, msg, len, flags, NULL));
-}
-
-#endif
-
-/* ==========================================================================
- * sendto_timedwait()
- */
-ssize_t sendto_timedwait(int fd, const void * msg, size_t len,
- int flags, const struct sockaddr *to, int to_len,
- struct timespec * timeout)
-{
- int ret;
-
- pthread_run->sighandled=0; /* Added by monty */
- if ((ret = fd_lock(fd, FD_WRITE, timeout)) == OK) {
- while ((ret = machdep_sys_sendto(fd_table[fd]->fd.i,
- msg, len, flags, to, to_len)) < OK) {
- if (!(fd_table[fd]->flags & __FD_NONBLOCK) &&
- ((ret == -EWOULDBLOCK) || (ret == -EAGAIN))) {
- pthread_sched_prevent();
-
- /* queue pthread for a FDW_WAIT */
- SET_PF_WAIT_EVENT(pthread_run);
- pthread_run->data.fd.fd = fd_table[fd]->fd.i;
- pthread_queue_enq(&fd_wait_write, pthread_run);
-
- if (timeout) {
- /* get current time */
- struct timespec current_time;
- machdep_gettimeofday(&current_time);
- sleep_schedule(&current_time, timeout);
-
- pthread_resched_resume(PS_FDW_WAIT);
-
- /* We're awake */
- pthread_sched_prevent();
- if (sleep_cancel(pthread_run) == NOTOK) {
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- ret= -ETIMEDOUT;
- break;
- }
- pthread_sched_resume();
- } else {
- pthread_resched_resume(PS_FDW_WAIT);
- }
- CLEAR_PF_DONE_EVENT(pthread_run);
- if (pthread_run->sighandled) /* Added by monty */
- { /* We where aborted */
- ret= -EINTR;
- break;
- }
- }
- else
- break; /* ret contains the errorcode */
- }
- fd_unlock(fd, FD_WRITE);
- }
- if (ret < 0)
- {
- SET_ERRNO(-ret);
- return(NOTOK);
- }
- return(ret);
-}
-
-/* ==========================================================================
- * sendto()
- */
-ssize_t sendto(int fd, const void * msg, size_t len, int flags,
- const struct sockaddr *to, int to_len)
-{
- return(sendto_timedwait(fd, msg, len, flags, to, to_len, NULL));
-}
-
-/* ==========================================================================
- * sendmsg_timedwait()
- */
-ssize_t sendmsg_timedwait(int fd, const struct msghdr *msg, int flags,
- struct timespec * timeout)
-{
- int passed_fd, ret, i;
-
- /* Handle getting the real file descriptor */
- for(i = 0; i < (((struct omsghdr *)msg)->msg_accrightslen/sizeof(i)); i++) {
- passed_fd = *(((int *)((struct omsghdr *)msg)->msg_accrights) + i);
- if ((ret = fd_lock(passed_fd, FD_RDWR, NULL)) == OK) {
- *(((int *)((struct omsghdr *)msg)->msg_accrights) + i)
- = fd_table[passed_fd]->fd.i;
- machdep_sys_fcntl(fd_table[passed_fd]->fd.i, F_SETFL,
- fd_table[passed_fd]->flags);
- switch(fd_table[passed_fd]->type) {
- case FD_TEST_FULL_DUPLEX:
- case FD_TEST_HALF_DUPLEX:
- break;
- case FD_FULL_DUPLEX:
- fd_table[passed_fd]->type = FD_TEST_FULL_DUPLEX;
- break;
- case FD_HALF_DUPLEX:
- fd_table[passed_fd]->type = FD_TEST_HALF_DUPLEX;
- break;
- default:
- PANIC();
- }
- } else {
- fd_unlock(fd, FD_RDWR);
- SET_ERRNO(EBADF);
- return(NOTOK);
- }
- fd_unlock(fd, FD_RDWR);
- }
-
- pthread_run->sighandled=0; /* Added by monty */
- if ((ret = fd_lock(fd, FD_WRITE, timeout)) == OK) {
- while((ret = machdep_sys_sendmsg(fd_table[fd]->fd.i, msg, flags)) < OK){
- if (!(fd_table[fd]->flags & __FD_NONBLOCK) &&
- ((ret == -EWOULDBLOCK) || (ret == -EAGAIN))) {
- pthread_sched_prevent();
-
- /* queue pthread for a FDW_WAIT */
- SET_PF_WAIT_EVENT(pthread_run);
- pthread_run->data.fd.fd = fd_table[fd]->fd.i;
- pthread_queue_enq(&fd_wait_write, pthread_run);
-
- if (timeout) {
- /* get current time */
- struct timespec current_time;
- machdep_gettimeofday(&current_time);
- sleep_schedule(&current_time, timeout);
-
- pthread_resched_resume(PS_FDW_WAIT);
-
- /* We're awake */
- pthread_sched_prevent();
- if (sleep_cancel(pthread_run) == NOTOK) {
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- SET_ERRNO(ETIMEDOUT);
- ret = NOTOK;
- break;
- }
- pthread_sched_resume();
-
- } else {
- pthread_resched_resume(PS_FDW_WAIT);
- }
- CLEAR_PF_DONE_EVENT(pthread_run);
- if (pthread_run->sighandled) /* Added by monty */
- { /* We where aborted */
- SET_ERRNO(EINTR);
- ret= NOTOK;
- break;
- }
-
- } else {
- SET_ERRNO(-ret);
- ret = NOTOK;
- break;
- }
- }
- fd_unlock(fd, FD_WRITE);
- }
- return(ret);
-}
-
-/* ==========================================================================
- * sendmsg()
- */
-ssize_t sendmsg(int fd, const struct msghdr *msg, int flags)
-{
- return(sendmsg_timedwait(fd, msg, flags, NULL));
-}
-
-#if 0
-/* ==========================================================================
- * recv_timedwait()
- */
-ssize_t recv_timedwait(int fd, void * buf, size_t len, int flags,
- struct timespec * timeout)
-{
- int ret;
-
- pthread_run->sighandled=0; /* Added by monty */
- if ((ret = fd_lock(fd, FD_READ, timeout)) == OK) {
- while ((ret = machdep_sys_recv(fd_table[fd]->fd.i,
- buf, len, flags)) < OK) {
- if (!(fd_table[fd]->flags & __FD_NONBLOCK) &&
- ((ret == -EWOULDBLOCK) || (ret == -EAGAIN))) {
- pthread_sched_prevent();
-
- /* queue pthread for a FDR_WAIT */
- SET_PF_WAIT_EVENT(pthread_run);
- pthread_run->data.fd.fd = fd_table[fd]->fd.i;
- pthread_queue_enq(&fd_wait_read, pthread_run);
-
- if (timeout) {
- /* get current time */
- struct timespec current_time;
- machdep_gettimeofday(&current_time);
- sleep_schedule(&current_time, timeout);
-
- pthread_resched_resume(PS_FDR_WAIT);
-
- /* We're awake */
- pthread_sched_prevent();
- if (sleep_cancel(pthread_run) == NOTOK) {
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- ret = -ETIMEDOUT;
- break;
- }
- pthread_sched_resume();
- } else {
- pthread_resched_resume(PS_FDR_WAIT);
- }
- CLEAR_PF_DONE_EVENT(pthread_run);
- if (pthread_run->sighandled) /* Added by monty */
- { /* We where aborted */
- ret= -EINTR;
- break;
- }
-
- } else {
- break;
- }
- }
- fd_unlock(fd, FD_READ);
- }
- if (ret < 0)
- {
- SET_ERRNO(-ret);
- return(NOTOK);
- }
- return(ret);
-}
-
-/* ==========================================================================
- * recv()
- */
-ssize_t recv(int fd, void * buf, size_t len, int flags)
-{
- return(recv_timedwait(fd, buf, len, flags, NULL));
-}
-
-#endif
-
-/* ==========================================================================
- * recvfrom_timedwait()
- */
-ssize_t recvfrom_timedwait(int fd, void * buf, size_t len, int flags,
- struct sockaddr * from, int * from_len,
- struct timespec * timeout)
-{
- int ret;
-
- pthread_run->sighandled=0; /* Added by monty */
- if ((ret = fd_lock(fd, FD_READ, timeout)) == OK) {
- while ((ret = machdep_sys_recvfrom(fd_table[fd]->fd.i,
- buf, len, flags, from, from_len)) < OK) {
- if (!(fd_table[fd]->flags & __FD_NONBLOCK) &&
- ((ret == -EWOULDBLOCK) || (ret == -EAGAIN))) {
- pthread_sched_prevent();
-
- /* queue pthread for a FDR_WAIT */
- SET_PF_WAIT_EVENT(pthread_run);
- pthread_run->data.fd.fd = fd_table[fd]->fd.i;
- pthread_queue_enq(&fd_wait_read, pthread_run);
-
- if (timeout) {
- /* get current time */
- struct timespec current_time;
- machdep_gettimeofday(&current_time);
- sleep_schedule(&current_time, timeout);
-
- pthread_resched_resume(PS_FDR_WAIT);
-
- /* We're awake */
- pthread_sched_prevent();
- if (sleep_cancel(pthread_run) == NOTOK) {
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- ret= -ETIMEDOUT;
- break;
- }
- pthread_sched_resume();
-
- } else {
- pthread_resched_resume(PS_FDR_WAIT);
- }
- CLEAR_PF_DONE_EVENT(pthread_run);
- if (pthread_run->sighandled) /* Added by monty */
- { /* We where aborted */
- ret= -EINTR;
- break;
- }
- } else {
- break;
- }
- }
- fd_unlock(fd, FD_READ);
- }
- if (ret < 0)
- {
- SET_ERRNO(-ret);
- return(NOTOK);
- }
- return(ret);
-}
-
-/* ==========================================================================
- * recvfrom()
- */
-ssize_t recvfrom(int fd, void * buf, size_t len, int flags,
- struct sockaddr * from, int * from_len)
-{
- return(recvfrom_timedwait(fd, buf, len, flags, from, from_len, NULL));
-}
-
-/* ==========================================================================
- * recvmsg_timedwait()
- */
-ssize_t recvmsg_timedwait(int fd, struct msghdr *msg, int flags,
- struct timespec * timeout)
-{
- struct stat stat_buf;
- int passed_fd, ret, i;
-
- pthread_run->sighandled=0; /* Added by monty */
- if ((ret = fd_lock(fd, FD_READ, timeout)) == OK) {
- while ((ret = machdep_sys_recvmsg(fd_table[fd]->fd.i, msg, flags)) < OK) {
- if (!(fd_table[fd]->flags & __FD_NONBLOCK) &&
- ((ret == -EWOULDBLOCK) || (ret == -EAGAIN))) {
- pthread_sched_prevent();
-
- /* queue pthread for a FDR_WAIT */
- SET_PF_WAIT_EVENT(pthread_run);
- pthread_run->data.fd.fd = fd_table[fd]->fd.i;
- pthread_queue_enq(&fd_wait_read, pthread_run);
-
- if (timeout) {
- /* get current time */
- struct timespec current_time;
- machdep_gettimeofday(&current_time);
- sleep_schedule(&current_time, timeout);
-
- pthread_resched_resume(PS_FDR_WAIT);
-
- /* We're awake */
- pthread_sched_prevent();
- if (sleep_cancel(pthread_run) == NOTOK) {
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- SET_ERRNO(ETIMEDOUT);
- ret = NOTOK;
- break;
- }
- pthread_sched_resume();
-
- } else {
- pthread_resched_resume(PS_FDR_WAIT);
- }
- CLEAR_PF_DONE_EVENT(pthread_run);
- if (pthread_run->sighandled) /* Added by monty */
- { /* We where aborted */
- SET_ERRNO(EINTR);
- ret= NOTOK;
- break;
- }
- } else {
- SET_ERRNO(-ret);
- ret = NOTOK;
- break;
- }
- }
- fd_unlock(fd, FD_READ);
-
- /* Handle getting the real file descriptor */
- for (i = 0; i < (((struct omsghdr *)msg)->msg_accrightslen / sizeof(i));
- i++) {
- passed_fd = *(((int *)((struct omsghdr *)msg)->msg_accrights) + i);
- if (!((fd = fd_allocate()) < OK)) {
- fd_table[fd]->flags = machdep_sys_fcntl(passed_fd, F_GETFL);
-
- if (!( fd_table[fd]->flags & __FD_NONBLOCK)) {
- machdep_sys_fcntl(passed_fd, F_SETFL,
- fd_table[fd]->flags | __FD_NONBLOCK);
- }
-
- /* fstat the file to determine what type it is */
- machdep_sys_fstat(passed_fd, &stat_buf);
- if (S_ISREG(stat_buf.st_mode)) {
- fd_table[fd]->type = FD_HALF_DUPLEX;
- } else {
- fd_table[fd]->type = FD_FULL_DUPLEX;
- }
- *(((int *)((struct omsghdr *)msg)->msg_accrights) + i) = fd;
- fd_table[fd]->ops = &(__fd_kern_ops);
- fd_table[fd]->fd.i = passed_fd;
- } else {
- SET_ERRNO(EBADF);
- return(NOTOK);
- break;
- }
- }
- }
- return(ret);
-}
-
-/* ==========================================================================
- * recvmsg()
- */
-ssize_t recvmsg(int fd, struct msghdr *msg, int flags)
-{
- return(recvmsg_timedwait(fd, msg, flags, NULL));
-}
-
-/* ==========================================================================
- * shutdown()
- */
-int shutdown(int fd, int how)
-{
- int ret;
-
- switch(how) {
- case 0: /* Read */
- if ((ret = fd_lock(fd, FD_READ, NULL)) == OK) {
- if ((ret = machdep_sys_shutdown(fd_table[fd]->fd.i, how)) < OK) {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
- fd_unlock(fd, FD_READ);
- }
- case 1: /* Write */
- if ((ret = fd_lock(fd, FD_WRITE, NULL)) == OK) {
- if ((ret = machdep_sys_shutdown(fd_table[fd]->fd.i, how)) < OK) {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
- fd_unlock(fd, FD_WRITE);
- }
- case 2: /* Read-Write */
- if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
- if ((ret = machdep_sys_shutdown(fd_table[fd]->fd.i, how)) < OK) {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
- fd_unlock(fd, FD_RDWR);
- }
- default:
- SET_ERRNO(EBADF);
- ret = NOTOK;
- break;
- }
- return(ret);
-}
-
-/* ==========================================================================
- * setsockopt()
- */
-int setsockopt(int fd, int level, int optname, const void * optval, int optlen)
-{
- int ret;
-
- if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
- if ((ret = machdep_sys_setsockopt(fd_table[fd]->fd.i, level,
- optname, optval, optlen)) < OK) {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
- fd_unlock(fd, FD_RDWR);
- }
- return ret;
-}
-
-/* ==========================================================================
- * getsockopt()
- */
-int getsockopt(int fd, int level, int optname, void * optval, int * optlen)
-{
- int ret;
-
- if ((ret = fd_lock(fd, FD_READ, NULL)) == OK) {
- if ((ret = machdep_sys_getsockopt(fd_table[fd]->fd.i, level,
- optname, optval, optlen)) < OK) {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
- fd_unlock(fd, FD_RDWR);
- }
- return ret;
-}
-
-/* ==========================================================================
- * getsockname()
- */
-int getsockname(int fd, struct sockaddr * name, int * naddrlen)
-{
- int ret;
-
- if ((ret = fd_lock(fd, FD_READ, NULL)) == OK) {
- if ((ret = machdep_sys_getsockname(fd_table[fd]->fd.i,
- name, naddrlen)) < OK) {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
- fd_unlock(fd, FD_RDWR);
- }
- return ret;
-}
-
-/* ==========================================================================
- * getpeername()
- */
-int getpeername(int fd, struct sockaddr * peer, int * paddrlen)
-{
- int ret;
-
- if ((ret = fd_lock(fd, FD_READ, NULL)) == OK) {
- if ((ret = machdep_sys_getpeername(fd_table[fd]->fd.i,
- peer, paddrlen)) < OK) {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
- fd_unlock(fd, FD_READ);
- }
- return ret;
-}
-
-/* ==========================================================================
- * socketpair()
- */
-int socketpair(int af, int type, int protocol, int pair[2])
-{
- int ret, fd[2];
-
- if (!((pair[0] = fd_allocate()) < OK)) {
- if (!((pair[1] = fd_allocate()) < OK)) {
- if (!((ret = machdep_sys_socketpair(af, type, protocol, fd)) < OK)){
- int tmp_flags;
-
- tmp_flags = machdep_sys_fcntl(fd[0], F_GETFL, 0);
- machdep_sys_fcntl(fd[0], F_SETFL, tmp_flags | __FD_NONBLOCK);
- fd_table[pair[0]]->ops = & __fd_kern_ops;
- fd_table[pair[0]]->type = FD_FULL_DUPLEX;
- fd_table[pair[0]]->flags = tmp_flags;
- fd_table[pair[0]]->fd.i = fd[0];
-
- tmp_flags = machdep_sys_fcntl(fd[1], F_GETFL, 0);
- machdep_sys_fcntl(fd[1], F_SETFL, tmp_flags | __FD_NONBLOCK);
- fd_table[pair[1]]->ops = & __fd_kern_ops;
- fd_table[pair[1]]->type = FD_FULL_DUPLEX;
- fd_table[pair[1]]->flags = tmp_flags;
- fd_table[pair[1]]->fd.i = fd[1];
-
- return(ret);
- }
- fd_table[pair[1]]->count = 0;
- }
- fd_table[pair[0]]->count = 0;
- SET_ERRNO(-ret);
- }
- return(NOTOK);
-}
diff --git a/lib/libpthread/pthreads/fd_pipe.c b/lib/libpthread/pthreads/fd_pipe.c
deleted file mode 100644
index d4cf6f2cb9e..00000000000
--- a/lib/libpthread/pthreads/fd_pipe.c
+++ /dev/null
@@ -1,268 +0,0 @@
-/* ==== fd_pipe.c ============================================================
- * Copyright (c) 1993, 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 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.
- *
- * Description : The new fast ITC pipe routines.
- *
- * 1.00 93/08/14 proven
- * -Started coding this file.
- *
- * 1.01 93/11/13 proven
- * -The functions readv() and writev() added.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: fd_pipe.c,v 1.1 1995/10/18 08:43:05 deraadt Exp $ $provenid: fd_pipe.c,v 1.16 1994/02/07 02:18:52 proven Exp $";
-#endif
-
-#include <pthread.h>
-#include <pthread/fd_pipe.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <pthread/posix.h>
-
-/* ==========================================================================
- * The pipe lock is never unlocked until all pthreads waiting are done with it
- * read()
- */
-ssize_t __pipe_read(struct __pipe *fd, int flags, void *buf, size_t nbytes)
-{
- semaphore *lock, *plock;
- int ret = 0;
-
- if (flags & O_ACCMODE) { return(NOTOK); }
-
- lock = &(fd->lock);
- while (SEMAPHORE_TEST_AND_SET(lock)) {
- pthread_yield();
- }
- /* If there is nothing to read, go to sleep */
- if (fd->count == 0) {
- if (flags == WR_CLOSED) {
- SEMAPHORE_RESET(lock);
- return(0);
- } /* Lock pthread */
- plock = &(pthread_run->lock);
- while (SEMAPHORE_TEST_AND_SET(plock)) {
- pthread_yield();
- }
-
- /* queue pthread for a FDR_WAIT */
- pthread_run->next = NULL;
- fd->wait = pthread_run;
- SEMAPHORE_RESET(lock);
- reschedule(PS_FDR_WAIT);
- ret = fd->size;
- } else {
- ret = MIN(nbytes, fd->count);
- memcpy(buf, fd->buf + fd->offset, ret);
- if (!(fd->count -= ret)) {
- fd->offset = 0;
- }
-
- /* Should try to read more from the waiting writer */
-
- if (fd->wait) {
- plock = &(fd->wait->lock);
- while (SEMAPHORE_TEST_AND_SET(plock)) {
- pthread_yield();
- }
- fd->wait->state = PS_RUNNING;
- SEMAPHORE_RESET(plock);
- } else {
- SEMAPHORE_RESET(lock);
- }
- }
- return(ret);
-}
-
-/* ==========================================================================
- * __pipe_write()
- *
- * First check to see if the read side is still open, then
- * check to see if there is a thread in a read wait for this pipe, if so
- * copy as much data as possible directly into the read waiting threads
- * buffer. The write thread(whether or not there was a read thread)
- * copies as much data as it can into the pipe buffer and it there
- * is still data it goes to sleep.
- */
-ssize_t __pipe_write(struct __pipe *fd, int flags, const void *buf, size_t nbytes) {
- semaphore *lock, *plock;
- int ret, count;
-
- if (!(flags & O_ACCMODE)) { return(NOTOK); }
-
- lock = &(fd->lock);
- while (SEMAPHORE_TEST_AND_SET(lock)) {
- pthread_yield();
- }
- while (fd->flags != RD_CLOSED) {
- if (fd->wait) {
- /* Lock pthread */
- plock = &(fd->wait->lock);
- while (SEMAPHORE_TEST_AND_SET(plock)) {
- pthread_yield();
- }
-
- /* Copy data directly into waiting pthreads buf */
- fd->wait_size = MIN(nbytes, fd->wait_size);
- memcpy(fd->wait_buf, buf, fd->wait_size);
- buf = (const char *)buf + fd->wait_size;
- nbytes -= fd->wait_size;
- ret = fd->wait_size;
-
- /* Wake up waiting pthread */
- fd->wait->state = PS_RUNNING;
- SEMAPHORE_RESET(plock);
- fd->wait = NULL;
- }
-
- if (count = MIN(nbytes, fd->size - (fd->offset + fd->count))) {
- memcpy(fd->buf + (fd->offset + fd->count), buf, count);
- buf = (const char *)buf + count;
- nbytes -= count;
- ret += count;
- }
- if (nbytes) {
- /* Lock pthread */
- plock = &(fd->wait->lock);
- while (SEMAPHORE_TEST_AND_SET(plock)) {
- pthread_yield();
- }
-
- fd->wait = pthread_run;
- SEMAPHORE_RESET(lock);
- reschedule(PS_FDW_WAIT);
- } else {
- return(ret);
- }
- }
- return(NOTOK);
-}
-
-/* ==========================================================================
- * __pipe_close()
- *
- * The whole close procedure is a bit odd and needs a bit of a rethink.
- * For now close() locks the fd, calls fd_free() which checks to see if
- * there are any other fd values poinging to the same real fd. If so
- * It breaks the wait queue into two sections those that are waiting on fd
- * and those waiting on other fd's. Those that are waiting on fd are connected
- * to the fd_table[fd] queue, and the count is set to zero, (BUT THE LOCK IS NOT
- * RELEASED). close() then calls fd_unlock which give the fd to the next queued
- * element which determins that the fd is closed and then calls fd_unlock etc...
- */
-int __pipe_close(struct __pipe *fd, int flags)
-{
- semaphore *lock, *plock;
-
- lock = &(fd->lock);
- while (SEMAPHORE_TEST_AND_SET(lock)) {
- pthread_yield();
- }
- if (!(fd->flags)) {
- if (fd->wait) {
- if (flags & O_ACCMODE) {
- fd->flags |= WR_CLOSED;
- /* Lock pthread */
- /* Write side closed, wake read side and return EOF */
- plock = &((fd->wait)->lock);
- while (SEMAPHORE_TEST_AND_SET(plock)) {
- pthread_yield();
- }
-
- fd->count = 0;
-
- /* Wake up waiting pthread */
- fd->wait->state = PS_RUNNING;
- SEMAPHORE_RESET(plock);
- fd->wait = NULL;
- } else {
- /* Should send a signal */
- fd->flags |= RD_CLOSED;
- }
- }
- } else {
- free(fd);
- return(OK);
- }
- SEMAPHORE_RESET(lock);
-}
-
-/* ==========================================================================
- * For those function that aren't implemented yet
- * __pipe_enosys()
- */
-static int __pipe_enosys()
-{
- pthread_run->error = ENOSYS;
- return(NOTOK);
-}
-
-/*
- * File descriptor operations
- */
-struct fd_ops fd_ops[] = {
-{ NULL, NULL, }, /* Non operations */
-{ __pipe_write, __pipe_read, __pipe_close, __pipe_enosys, __pipe_enosys,
- __pipe_enosys },
-};
-
-/* ==========================================================================
- * open()
- */
-/* int __pipe_open(const char *path, int flags, ...) */
-int newpipe(int fd[2])
-{
- struct __pipe *fd_data;
-
- if ((!((fd[0] = fd_allocate()) < OK)) && (!((fd[1] = fd_allocate()) < OK))) {
- fd_data = malloc(sizeof(struct __pipe));
- fd_data->buf = malloc(4096);
- fd_data->size = 4096;
- fd_data->count = 0;
- fd_data->offset = 0;
-
- fd_data->wait = NULL;
- fd_data->flags = 0;
-
- fd_table[fd[0]]->fd.ptr = fd_data;
- fd_table[fd[0]]->flags = O_RDONLY;
- fd_table[fd[1]]->fd.ptr = fd_data;
- fd_table[fd[1]]->flags = O_WRONLY;
-
- return(OK);
- }
- return(NOTOK);
-}
-
diff --git a/lib/libpthread/pthreads/fd_sysv.c b/lib/libpthread/pthreads/fd_sysv.c
deleted file mode 100644
index 896163b57ea..00000000000
--- a/lib/libpthread/pthreads/fd_sysv.c
+++ /dev/null
@@ -1,897 +0,0 @@
-/* ==== fd_sysv.c ============================================================
- * 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 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.
- *
- * Description : Transforms BSD socket calls to SYSV streams.
- *
- * 1.00 94/11/19 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: fd_sysv.c,v 1.1 1998/07/21 13:19:59 peter Exp $";
-#endif
-
-#include <pthread.h>
-#include <config.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#if defined (HAVE_SYSCALL_PUTMSG) && defined (HAVE_SYSCALL_GETMSG) && !defined(HAVE_SYSCALL_SOCKETCALL) && !defined(HAVE_SYSCALL_SOCKET)
-#define HAVE_STREAMS 1
-
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <sys/socket.h>
-#include <sys/stream.h>
-#include <sys/stropts.h>
-#include <tiuser.h>
-#include <sys/tihdr.h>
-#include <netinet/in.h>
-#include <sys/timod.h>
-
-#define STREAM_BUF_SIZE sizeof(union T_primitives) + sizeof(struct sockaddr)
-
-extern struct pthread_queue fd_wait_read, fd_wait_write;
-
-/* ==========================================================================
- * putmsg_timedwait_basic()
- */
-static int putmsg_timedwait_basic(int fd, struct strbuf * ctlptr,
- struct strbuf * dataptr, int flags, struct timespec * timeout)
-{
-
- int ret;
-
- pthread_run->sighandled=0; /* Added by monty */
- while ((ret = machdep_sys_putmsg(fd_table[fd]->fd.i,
- ctlptr, dataptr, flags)) < OK) {
- if (!(fd_table[fd]->flags & __FD_NONBLOCK) &&
- ((ret == -EWOULDBLOCK) || (ret == -EAGAIN))) {
- pthread_sched_prevent();
-
- /* queue pthread for a FDW_WAIT */
- SET_PF_WAIT_EVENT(pthread_run);
- pthread_run->data.fd.fd = fd_table[fd]->fd.i;
- pthread_queue_enq(&fd_wait_write, pthread_run);
-
- if (timeout) {
- /* get current time */
- struct timespec current_time;
- machdep_gettimeofday(&current_time);
- sleep_schedule(& current_time, timeout);
-
- pthread_resched_resume(PS_FDW_WAIT);
-
- /* We're awake */
- pthread_sched_prevent();
- if (sleep_cancel(pthread_run) == NOTOK) {
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- SET_ERRNO(ETIMEDOUT);
- ret = -ETIMEDOUT;
- break;
- }
- pthread_sched_resume();
- } else {
- pthread_resched_resume(PS_FDW_WAIT);
- }
- CLEAR_PF_DONE_EVENT(pthread_run);
- if (pthread_run->sighandled) /* Added by monty */
- { /* We where aborted */
- SET_ERRNO(EINTR);
- ret= -EINTR;
- break;
- }
- } else {
- SET_ERRNO(-ret);
- break;
- }
- }
- return(ret);
-}
-
-/* ==========================================================================
- * putmsg_timedwait()
- */
-int putmsg_timedwait(int fd, struct strbuf * ctlptr, struct strbuf * dataptr,
- int flags, struct timespec * timeout)
-{
- int ret;
-
- if ((ret = fd_lock(fd, FD_WRITE, timeout)) == OK) {
- ret = putmsg_timedwait_basic(fd, ctlptr, dataptr, flags, timeout);
- fd_unlock(fd, FD_WRITE);
- }
- return(ret);
-}
-
-/* ==========================================================================
- * putmsg()
- */
-int putmsg(int fd, struct strbuf * ctlptr, struct strbuf * dataptr,
- int flags)
-{
- return(putmsg_timedwait(fd, ctlptr, dataptr, flags, NULL));
-}
-
-/* ==========================================================================
- * getmsg_timedwait_basic()
- */
-int getmsg_timedwait_basic(int fd, struct strbuf * ctlptr,
- struct strbuf * dataptr, int * flags, struct timespec * timeout)
-{
- int ret;
-
- pthread_run->sighandled=0; /* Added by monty */
- while ((ret = machdep_sys_getmsg(fd_table[fd]->fd.i,
- ctlptr, dataptr, flags)) < OK) {
- if (!(fd_table[fd]->flags & __FD_NONBLOCK) &&
- ((ret == -EWOULDBLOCK) || (ret == -EAGAIN))) {
- pthread_sched_prevent();
-
- /* queue pthread for a FDR_WAIT */
- SET_PF_WAIT_EVENT(pthread_run);
- pthread_run->data.fd.fd = fd_table[fd]->fd.i;
- pthread_queue_enq(&fd_wait_read, pthread_run);
-
- if (timeout) {
- /* get current time */
- struct timespec current_time;
- machdep_gettimeofday(&current_time);
- sleep_schedule(& current_time, timeout);
-
- pthread_resched_resume(PS_FDR_WAIT);
-
- /* We're awake */
- pthread_sched_prevent();
- if (sleep_cancel(pthread_run) == NOTOK) {
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- SET_ERRNO(ETIMEDOUT);
- ret = -ETIMEDOUT;
- break;
- }
- pthread_sched_resume();
- } else {
- pthread_resched_resume(PS_FDR_WAIT);
- }
- CLEAR_PF_DONE_EVENT(pthread_run);
- if (pthread_run->sighandled) /* Added by monty */
- { /* We where aborted */
- SET_ERRNO(EINTR);
- ret= -EINTR;
- break;
- }
-
- } else {
- SET_ERRNO(-ret);
- break;
- }
- }
- return(ret);
-}
-
-/* ==========================================================================
- * getmsg_timedwait()
- */
-int getmsg_timedwait(int fd, struct strbuf * ctlptr, struct strbuf * dataptr,
- int * flags, struct timespec * timeout)
-{
- int ret;
-
- if ((ret = fd_lock(fd, FD_READ, timeout)) == OK) {
- ret = getmsg_timedwait_basic(fd, ctlptr, dataptr, flags, timeout);
- fd_unlock(fd, FD_READ);
- }
- return (ret);
-}
-
-/* ==========================================================================
- * getmsg()
- */
-int getmsg(int fd, struct strbuf * ctlptr, struct strbuf * dataptr,
- int * flags)
-{
- return(getmsg_timedwait(fd, ctlptr, dataptr, flags, NULL));
-}
-
-#endif
-
-/* ==========================================================================
- * Here are the berkeley socket functions implemented with stream calls.
- * These are not POSIX.
- * ======================================================================= */
-
-#if (!defined (HAVE_SYSCALL_BIND)) && defined(HAVE_STREAMS)
-
-/* ==========================================================================
- * bind()
- */
-int bind(int fd, const struct sockaddr *name, int namelen)
-{
- char buf[STREAM_BUF_SIZE];
- union T_primitives * res;
- struct T_bind_req * req;
- struct T_bind_ack * ack;
- struct strbuf strbuf;
- int flags, ret;
-
- if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK)
- {
- req = (struct T_bind_req *)buf;
- req->PRIM_type = T_BIND_REQ;
- req->ADDR_length = namelen;
- req->ADDR_offset = sizeof(struct T_bind_req);
- req->CONIND_number = 4;
- memcpy(buf + sizeof(struct T_bind_req), name, namelen);
-
- strbuf.len = sizeof(struct T_bind_req) + namelen;
- strbuf.maxlen = STREAM_BUF_SIZE;
- strbuf.buf = buf;
-
- if ((ret=putmsg_timedwait_basic(fd, &strbuf, NULL, 0, NULL)) == OK)
- {
- memset(buf, 0, STREAM_BUF_SIZE);
-
- strbuf.len = sizeof(struct T_bind_ack) + namelen;
- strbuf.maxlen = STREAM_BUF_SIZE;
- strbuf.buf = buf;
- flags = 0;
-
- if ((ret = getmsg_timedwait_basic(fd, &strbuf, NULL,
- &flags, NULL)) >= OK)
- {
- res = (union T_primitives *)buf;
-
- switch(res->type) {
- case T_BIND_ACK:
- ret = OK;
- break;
- default:
- SET_ERRNO(EPROTO); /* What should this be? */
- ret = NOTOK;
- break;
- }
- }
- else
- {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
- }
- else
- {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
- fd_unlock(fd, FD_RDWR);
- }
- return(ret);
-}
-
-#endif
-
-#if (!defined (HAVE_SYSCALL_CONNECT)) && defined(HAVE_STREAMS)
-
-/* ==========================================================================
- * connect()
- */
-int connect(int fd, const struct sockaddr *name, int namelen)
-{
- char buf[STREAM_BUF_SIZE];
- union T_primitives * res;
- struct T_conn_req * req;
- struct T_conn_con * con;
- struct T_ok_ack * ok;
- struct strbuf strbuf;
- int flags, ret;
-
- if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK)
- {
- req = (struct T_conn_req *)buf;
- req->PRIM_type = T_CONN_REQ;
- req->DEST_length = namelen;
- req->DEST_offset = sizeof(struct T_conn_req);
- req->OPT_length = 0;
- req->OPT_offset = 0;
- memcpy(buf + sizeof(struct T_conn_req), name, namelen);
-
- strbuf.len = sizeof(struct T_conn_req) + namelen;
- strbuf.maxlen = STREAM_BUF_SIZE;
- strbuf.buf = buf;
-
- if ((ret=putmsg_timedwait_basic(fd, &strbuf, NULL, 0, NULL)) != OK)
- goto err;
-
- memset(buf, 0, STREAM_BUF_SIZE);
- ok = (struct T_ok_ack *)buf;
-
- strbuf.maxlen = STREAM_BUF_SIZE;
- strbuf.len = STREAM_BUF_SIZE;
- strbuf.buf = buf;
- flags = 0;
-
- if ((ret=getmsg_timedwait_basic(fd, &strbuf, NULL, &flags, NULL)) < OK)
- goto err; /* Fixed by monty */
- if (ok->PRIM_type != T_OK_ACK)
- {
- ret= -EPROTO; /* What should this be? */
- goto err;
- }
-
- memset(buf, 0, STREAM_BUF_SIZE);
- strbuf.maxlen = STREAM_BUF_SIZE;
- strbuf.len = STREAM_BUF_SIZE;
- strbuf.buf = buf;
- flags = 0;
-
- if ((ret=getmsg_timedwait_basic(fd, &strbuf, NULL, &flags, NULL) < OK))
- goto err;
-
- res = (union T_primitives *) buf;
- switch(res->type) {
- case T_CONN_CON:
- ret = OK;
- break;
- case T_DISCON_IND:
- ret= -ECONNREFUSED;
- goto err;
- default:
- ret= -EPROTO; /* What should this be? */
- goto err;
- }
- fd_unlock(fd, FD_RDWR);
- }
- return(ret);
-
- err:
- fd_unlock(fd, FD_RDWR);
- SET_ERRNO(-ret); /* Proably not needed... */
- return NOTOK;
-}
-
-#endif
-
-#if (!defined (HAVE_SYSCALL_LISTEN)) && defined(HAVE_STREAMS)
-
-/* ==========================================================================
- * listen()
- */
-int listen(int fd, int backlog)
-{
- return(OK);
-}
-
-#endif
-
-#if (!defined (HAVE_SYSCALL_SOCKET)) && defined(HAVE_STREAMS)
-
-extern ssize_t __fd_kern_write();
-static pthread_ssize_t __fd_sysv_read();
-extern int __fd_kern_close();
-extern int __fd_kern_fcntl();
-extern int __fd_kern_writev();
-extern int __fd_kern_readv();
-extern off_t __fd_kern_lseek();
-
-/* Normal file operations */
-static struct fd_ops __fd_sysv_ops = {
- __fd_kern_write, __fd_sysv_read, __fd_kern_close, __fd_kern_fcntl,
- __fd_kern_writev, __fd_kern_readv, __fd_kern_lseek, 1
-};
-
-/* ==========================================================================
- * read()
- */
-static pthread_ssize_t __fd_sysv_read(union fd_data fd_data, int flags,
- void *buf, size_t nbytes, struct timespec * timeout)
-{
- struct strbuf dataptr;
- int fd = fd_data.i;
- int getmsg_flags;
- int ret;
-
- getmsg_flags = 0;
- dataptr.len = 0;
- dataptr.buf = buf;
- dataptr.maxlen = nbytes;
-
- pthread_run->sighandled=0; /* Added by monty */
- while ((ret = machdep_sys_getmsg(fd, NULL, &dataptr, &getmsg_flags)) < OK) {
- if (!(fd_table[fd]->flags & __FD_NONBLOCK) &&
- ((ret == -EWOULDBLOCK) || (ret == -EAGAIN))) {
- pthread_sched_prevent();
-
- /* queue pthread for a FDR_WAIT */
- pthread_run->data.fd.fd = fd;
- SET_PF_WAIT_EVENT(pthread_run);
- pthread_queue_enq(&fd_wait_read, pthread_run);
-
- if (timeout) {
- /* get current time */
- struct timespec current_time;
- machdep_gettimeofday(&current_time);
- sleep_schedule(& current_time, timeout);
-
- pthread_resched_resume(PS_FDR_WAIT);
-
- /* We're awake */
- pthread_sched_prevent();
- if (sleep_cancel(pthread_run) == NOTOK) {
- CLEAR_PF_DONE_EVENT(pthread_run);
- pthread_sched_resume();
- SET_ERRNO(ETIMEDOUT);
- ret = -ETIMEDOUT;
- break;
- }
- pthread_sched_resume();
- } else {
- pthread_resched_resume(PS_FDR_WAIT);
- }
- CLEAR_PF_DONE_EVENT(pthread_run);
- if (pthread_run->sighandled) /* Added by monty */
- { /* We where aborted */
- SET_ERRNO(EINTR);
- return(NOTOK);
- }
- } else {
- SET_ERRNO(-ret);
- return(NOTOK);
- break;
- }
- }
- return(dataptr.len);
-}
-
-/* ==========================================================================
- * socket_tcp()
- */
-static int socket_tcp(int fd)
-{
- int ret;
-
- if ((ret = machdep_sys_open("/dev/tcp", O_RDWR | O_NONBLOCK, 0)) >= OK) {
- /* Should fstat the file to determine what type it is */
- fd_table[fd]->ops = & __fd_sysv_ops;
- fd_table[fd]->type = FD_FULL_DUPLEX;
- fd_table[fd]->fd.i = ret;
- fd_table[fd]->flags = 0;
- }
- return(ret);
-}
-
-/* ==========================================================================
- * socket()
- */
-int socket(int af, int type, int protocol)
-{
- int fd, fd_kern;
-
- if ((fd = fd_allocate()) < OK)
- return (fd);
-
- switch(af) {
- case AF_INET:
- switch(type) {
- case SOCK_STREAM:
- if ((fd_kern = socket_tcp(fd)) >= OK)
- return(fd);
- SET_ERRNO(-fd_kern);
- break;
- case SOCK_DGRAM:
- if ((fd_kern = machdep_sys_open("/dev/udp",
- O_RDWR | O_NONBLOCK, 0)) >= OK) {
- /* Should fstat the file to determine what type it is */
- fd_table[fd]->ops = & __fd_sysv_ops;
- fd_table[fd]->type = FD_FULL_DUPLEX;
- fd_table[fd]->fd.i = fd_kern;
- fd_table[fd]->flags = 0;
- return(fd);
- }
- SET_ERRNO(-fd_kern);
- break;
- default:
- SET_ERRNO(EPROTONOSUPPORT);
- break;
- }
- break;
- case AF_UNIX:
- case AF_ISO:
- case AF_NS:
- default:
- SET_ERRNO(EPROTONOSUPPORT);
- break;
- }
- fd_table[fd]->count = 0;
- return(NOTOK); /* Fixed by monty */
-}
-
-#endif
-
-#if (!defined (HAVE_SYSCALL_ACCEPT)) && defined(HAVE_STREAMS)
-
-/* ==========================================================================
- * accept_fd()
- */
-static int accept_fd(int fd, struct sockaddr *name, int *namelen, char * buf,
- int SEQ_number)
-{
- struct T_conn_res * res;
- struct strbuf strbuf;
- int fd_new, fd_kern;
-
- /* Get a new table entry */
- if ((fd_new = fd_allocate()) < OK)
- return(NOTOK);
-
- /* Get the new kernel entry */
- if (!((fd_kern = socket_tcp(fd_new)) < OK)) {
- res = (struct T_conn_res *)buf;
- res->PRIM_type = T_CONN_RES;
- /* res->QUEUE_ptr = (queue_t *)&fd_kern; */
- res->OPT_length = 0;
- res->OPT_offset = 0;
- res->SEQ_number = SEQ_number;
-
- strbuf.maxlen = sizeof(union T_primitives) +sizeof(struct sockaddr);
- strbuf.len = sizeof(struct T_conn_ind) + (*namelen);
- strbuf.buf = buf;
-
- {
- struct strfdinsert insert;
-
- insert.ctlbuf.maxlen = (sizeof(union T_primitives) +
- sizeof(struct sockaddr));
- insert.ctlbuf.len = sizeof(struct T_conn_ind);
- insert.ctlbuf.buf = buf;
- insert.databuf.maxlen = 0;
- insert.databuf.len = 0;
- insert.databuf.buf = NULL;
- insert.flags = 0;
- insert.fildes = fd_kern;
- insert.offset = 4;
- /* Should the following be checked ? */
- machdep_sys_ioctl(fd_table[fd]->fd.i, I_FDINSERT, &insert);
- }
-
- /* if (putmsg_timedwait_basic(fd, &strbuf, NULL, 0, NULL) == OK) {
- /* return(fd_new); */
- {
- int flags = 0;
- int ret;
-
- /* Should the following be checked ? */
- ret = getmsg_timedwait_basic(fd, &strbuf, NULL, &flags, NULL);
- return(fd_new);
-
- }
- machdep_sys_close(fd_kern);
- }
- fd_table[fd_new]->count = 0;
- return(NOTOK);
-}
-
-
-/* ==========================================================================
- * accept()
- */
-int accept(int fd, struct sockaddr *name, int *namelen)
-{
- char buf[sizeof(union T_primitives) + sizeof(struct sockaddr)];
- struct T_conn_ind * ind;
- struct strbuf strbuf;
- int flags, ret;
-
- if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK)
- {
- ind = (struct T_conn_ind *)buf;
- ind->PRIM_type = T_CONN_IND;
- ind->SRC_length = (*namelen);
- ind->SRC_offset = sizeof(struct T_conn_ind);
- ind->OPT_length = 0;
- ind->OPT_offset = 0;
- ind->SEQ_number = 0;
-
- strbuf.maxlen = sizeof(union T_primitives) + sizeof(struct sockaddr);
- strbuf.len = sizeof(struct T_conn_ind) + (*namelen);
- strbuf.buf = buf;
- flags = 0;
-
- if ((ret=getmsg_timedwait_basic(fd, &strbuf, NULL, &flags, NULL)) < OK)
- {
- SET_ERRNO(-ret);
- ret= NOTOK;
- }
- else
- ret = accept_fd(fd, name, namelen, buf, ind->SEQ_number);
- fd_unlock(fd, FD_RDWR);
- }
- return(ret);
-}
-
-#endif /* HAVE_SYSCALL_ACCEPT */
-
-#if (!defined (HAVE_SYSCALL_SENDTO)) && defined (HAVE_STREAMS)
-
-/* ==========================================================================
- * sendto_timedwait()
- */
-ssize_t sendto_timedwait(int fd, const void * msg, size_t len, int flags,
- const struct sockaddr *name, int namelen, struct timespec * timeout)
-{
- char buf[STREAM_BUF_SIZE];
- struct T_unitdata_req * req;
- struct strbuf dataptr;
- struct strbuf ctlptr;
- ssize_t ret, prio;
-
- req = (struct T_unitdata_req *)buf;
- req->PRIM_type = T_UNITDATA_REQ;
- req->DEST_length = namelen;
- req->DEST_offset = sizeof(struct T_unitdata_req);
- req->OPT_length = 0;
- req->OPT_offset = 0;
- memcpy(buf + sizeof(struct T_unitdata_req), name, namelen);
-
- ctlptr.len = sizeof(struct T_unitdata_req) + namelen;
- ctlptr.maxlen = STREAM_BUF_SIZE;
- ctlptr.buf = buf;
-
- dataptr.len = len;
- dataptr.maxlen = len;
- dataptr.buf = (void *)msg;
-
- if ((ret = putmsg_timedwait(fd, &ctlptr, &dataptr, 0, timeout)) == OK) {
- ret = len;
- }
- return(ret);
-}
-
-/* ==========================================================================
- * sendto()
- */
-ssize_t sendto(int fd, const void * msg, size_t len, int flags,
- const struct sockaddr *to, int to_len)
-{
- return(sendto_timedwait(fd, msg, len, flags, to, to_len, NULL));
-}
-
-#endif
-
-#if (!defined (HAVE_SYSCALL_SEND)) && defined (HAVE_STREAMS)
-
-/* ==========================================================================
- * send_timedwait()
- */
-ssize_t send_timedwait(int fd, const void * msg, size_t len, int flags,
- struct timespec * timeout)
-{
- char buf[STREAM_BUF_SIZE];
- struct T_unitdata_req * req;
- struct strbuf dataptr;
- struct strbuf ctlptr;
- ssize_t ret, prio;
-
- req = (struct T_unitdata_req *)buf;
- req->PRIM_type = T_UNITDATA_REQ;
- req->DEST_length = 0;
- req->DEST_offset = 0;
- req->OPT_length = 0;
- req->OPT_offset = 0;
-
- ctlptr.len = sizeof(struct T_unitdata_req);
- ctlptr.maxlen = STREAM_BUF_SIZE;
- ctlptr.buf = buf;
-
- dataptr.len = len;
- dataptr.maxlen = len;
- dataptr.buf = (void *)msg;
-
- if ((ret = putmsg_timedwait(fd, &ctlptr, &dataptr, 0, timeout)) == OK) {
- ret = len;
- }
- return(ret);
-}
-
-/* ==========================================================================
- * send()
- */
-ssize_t send(int fd, const void * msg, size_t len, int flags)
-{
- return(send_timedwait(fd, msg, len, flags, NULL));
-}
-
-#endif
-
-#if (!defined (HAVE_SYSCALL_RECVFROM)) && defined(HAVE_STREAMS)
-
-/* ==========================================================================
- * recvfrom_timedwait()
- */
-ssize_t recvfrom_timedwait(int fd, void * msg, size_t len, int flags,
- struct sockaddr * name, int * namelen, struct timespec * timeout)
-{
- char buf[STREAM_BUF_SIZE];
- struct T_unitdata_ind * ind;
- struct strbuf dataptr;
- struct strbuf ctlptr;
- int ret, prio;
-
- ctlptr.len = 0;
- ctlptr.maxlen = STREAM_BUF_SIZE;
- ctlptr.buf = buf;
-
- dataptr.maxlen = len;
- dataptr.len = 0;
- dataptr.buf = msg;
-
- prio = 0;
-
- ret = getmsg_timedwait(fd, &ctlptr, &dataptr, &prio, timeout);
- if (ret >= OK) {
- if (name != NULL) {
- ind = (struct T_unitdata_ind *)buf;
-
- if (*namelen > ind->SRC_length)
- *namelen = ind->SRC_length;
- memcpy(name, buf + ind->SRC_offset, *namelen);
- }
- ret = dataptr.len;
- }
-
- return(ret);
-}
-
-/* ==========================================================================
- * recvfrom()
- */
-ssize_t recvfrom(int fd, void * buf, size_t len, int flags,
- struct sockaddr * from, int * from_len)
-{
- return(recvfrom_timedwait(fd, buf, len, flags, from, from_len, NULL));
-}
-
-#endif
-
-#if (!defined (HAVE_SYSCALL_RECV)) && defined(HAVE_STREAMS)
-
-/* ==========================================================================
- * recv_timedwait()
- */
-ssize_t recv_timedwait(int fd, void * msg, size_t len, int flags,
- struct timespec * timeout)
-{
- char buf[STREAM_BUF_SIZE];
- struct T_unitdata_ind * ind;
- struct strbuf dataptr;
- struct strbuf ctlptr;
- int ret, prio;
-
- ctlptr.len = 0;
- ctlptr.maxlen = STREAM_BUF_SIZE;
- ctlptr.buf = buf;
-
- dataptr.maxlen = len;
- dataptr.len = 0;
- dataptr.buf = msg;
-
- prio = 0;
-
- ret = getmsg_timedwait(fd, &ctlptr, &dataptr, &prio, timeout);
- if (ret >= OK)
- ret = dataptr.len;
-
- return(ret);
-}
-
-/* ==========================================================================
- * recv()
- */
-ssize_t recv(int fd, void * buf, size_t len, int flags,
- struct sockaddr * from, int * from_len)
-{
- return(recv_timedwait(fd, buf, len, flags, NULL));
-}
-
-#endif
-
-#if (!defined (HAVE_SYSCALL_SETSOCKOPT)) && defined(HAVE_STREAMS)
-/* ==========================================================================
- * setsockopt()
- */
-int setsockopt(int s, int level, int optname, const void *optval, int optlen)
-{
- return(0);
-}
-#endif
-
-struct foo { /* Used by getsockname and getpeername */
- long a;
- int b;
- struct sockaddr *name;
-};
-
-#if (!defined (HAVE_SYSCALL_GETSOCKNAME)) && defined(HAVE_STREAMS)
-/* ==========================================================================
- * getsockname()
- */
-
-
-int getsockname(int s, struct sockaddr *name, int *namelen)
-{
- struct foo foo;
- int i;
- if (*namelen < sizeof(struct sockaddr)) {
- SET_ERRNO(ENOMEM);
- return(-1);
- }
- foo.a = 0x84;
- foo.b = 0;
- foo.name = name;
- i = ioctl(s, TI_GETMYNAME, &foo);
- *namelen = foo.b;
- return(i);
-}
-#endif
-
-#if (!defined (HAVE_SYSCALL_GETPEERNAME)) && defined(HAVE_STREAMS)
-/* ==========================================================================
- * getpeername() ; Added by Monty
- */
-
-int getpeername(int s, struct sockaddr *name, int *namelen)
-{
- struct foo foo;
- int i;
- if (*namelen < sizeof(struct sockaddr)) {
- SET_ERRNO(ENOMEM);
- return(-1);
- }
- foo.a = 0x84; /* Max length ? */
- foo.b = 0; /* Return length */
- foo.name = name; /* Return buffer */
- i = ioctl(s, TI_GETPEERNAME, &foo);
- *namelen = foo.b;
- return(i);
-}
-#endif
-
-
-#if (!defined (HAVE_SYSCALL_SHUTDOWN)) && defined(HAVE_STREAMS)
-/* ==========================================================================
- * shutdown()
- */
-
-int shutdown(int s, int how)
-{
- return(0);
-}
-#endif
diff --git a/lib/libpthread/pthreads/file.c b/lib/libpthread/pthreads/file.c
deleted file mode 100644
index f22b3761c5a..00000000000
--- a/lib/libpthread/pthreads/file.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/* ==== file.c ============================================================
- * Copyright (c) 1993, 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 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.
- *
- * Description : The locking functions for stdio.
- *
- * 1.00 93/09/04 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: file.c,v 1.1 1995/10/18 08:43:05 deraadt Exp $ $provenid: file.c,v 1.16 1994/02/07 02:18:55 proven Exp $";
-#endif
-
-#include <pthread.h>
-#include <stdio.h>
-
-/* ==========================================================================
- * flockfile()
- */
-void flockfile(FILE *fp)
-{
- semaphore *lock;
- int fd;
-
- fd = fileno(fp);
- lock = &(fd_table[fd]->lock);
- while (SEMAPHORE_TEST_AND_SET(lock)) {
- pthread_yield();
- }
-
- if (fd_table[fd]->r_owner != pthread_run) {
- /* This might fail but POSIX doesn't give a damn. */
- fd_basic_lock(fd, FD_RDWR, lock);
- }
- fd_table[fd]->lockcount++;
- SEMAPHORE_RESET(lock);
-}
-
-/* ==========================================================================
- * ftrylockfile()
- */
-int ftrylockfile(FILE *fp)
-{
- semaphore *lock;
- int fd;
-
- fd = fileno(fp);
- lock = &(fd_table[fd]->lock);
- while (SEMAPHORE_TEST_AND_SET(lock)) {
- pthread_yield();
- }
-
- if (fd_table[fd]->r_owner != pthread_run) {
- if (!(fd_table[fd]->r_owner && fd_table[fd]->w_owner)) {
- fd_basic_lock(fd, FD_RDWR, lock);
- fd = OK;
- } else {
- fd = NOTOK;
- }
- } else {
- fd_table[fd]->lockcount++;
- fd = OK;
- }
- SEMAPHORE_RESET(lock);
- return(fd);
-}
-
-/* ==========================================================================
- * funlockfile()
- */
-void funlockfile(FILE *fp)
-{
- semaphore *lock;
- int fd;
-
- fd = fileno(fp);
- lock = &(fd_table[fd]->lock);
- while (SEMAPHORE_TEST_AND_SET(lock)) {
- pthread_yield();
- }
-
- if (fd_table[fd]->r_owner == pthread_run) {
- if (--fd_table[fd]->lockcount == 0) {
- fd_basic_unlock(fd, FD_RDWR);
- }
- }
- SEMAPHORE_RESET(lock);
-}
-
diff --git a/lib/libpthread/pthreads/globals.c b/lib/libpthread/pthreads/globals.c
deleted file mode 100644
index 00774e0a2f8..00000000000
--- a/lib/libpthread/pthreads/globals.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/* ==== globals.c ============================================================
- * Copyright (c) 1993, 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 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.
- *
- * Description : Global variables.
- *
- * 1.00 93/07/26 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: globals.c,v 1.1 1995/10/18 08:43:05 deraadt Exp $ $provenid: globals.c,v 1.16 1994/02/07 02:18:57 proven Exp $";
-#endif
-
-#include <pthread.h>
-
-/*
- * Initial thread, running thread, and top of link list
- * of all threads.
- */
-struct pthread *pthread_run;
-struct pthread *pthread_initial;
-struct pthread *pthread_link_list;
-
-/*
- * default thread attributes
- */
-pthread_attr_t pthread_default_attr = { SCHED_RR, NULL, PTHREAD_STACK_DEFAULT };
-
-/*
- * Queue for all threads elidgeable to run this scheduling round.
- */
-struct pthread_queue pthread_current_queue = PTHREAD_QUEUE_INITIALIZER;
-
-/*
- * File table information
- */
-struct fd_table_entry *fd_table[64];
-
-
diff --git a/lib/libpthread/pthreads/info.c b/lib/libpthread/pthreads/info.c
deleted file mode 100644
index 2b9722ba291..00000000000
--- a/lib/libpthread/pthreads/info.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/* hello */
-
-#include <stdio.h>
-#include <pthread.h>
-#include <signal.h>
-
-static const char *const state_names[] = {
-#define __pthread_defstate(S,NAME) NAME,
-#include "pthread/state.def"
-#undef __pthread_defstate
- 0
-};
-
-void (*dump_thread_info_fn) (struct pthread *, FILE *);
-
-static void
-dump_thread_info (thread, file)
- struct pthread *thread;
- FILE *file;
-{
- /* machdep */
- /* attr */
- /* signals */
- /* wakeup_time */
- /* join */
- fprintf (file, " thread @%p prio %3d %s", thread,
- thread->pthread_priority, state_names[(int) thread->state]);
- switch (thread->state) {
- case PS_FDLR_WAIT:
- fprintf (file, " fd %d[%d]", thread->data.fd.fd,
- thread->data.fd.branch);
- fprintf (file, " owner %pr/%pw",
- fd_table[thread->data.fd.fd]->r_owner,
- fd_table[thread->data.fd.fd]->w_owner);
- break;
- }
- /* show where the signal handler gets run */
- if (thread == pthread_run)
- fprintf (file, "\t\t[ME!]");
- fprintf (file, "\n");
- if (dump_thread_info_fn)
- (*dump_thread_info_fn) (thread, file);
-}
-
-static void
-pthread_dump_info_to_file (file)
- FILE *file;
-{
- pthread_t t;
- for (t = pthread_link_list; t; t = t->pll)
- dump_thread_info (t, file);
-}
-
-void
-pthread_dump_info ()
-{
- if (ftrylockfile (stderr) != 0)
- return;
- fprintf (stderr, "process id %ld:\n", (long) getpid ());
- pthread_dump_info_to_file (stderr);
- funlockfile (stderr);
-}
-
-#ifdef SIGINFO
-static void
-sig_handler (sig)
- int sig;
-{
- pthread_dump_info ();
-}
-
-void
-pthread_setup_siginfo ()
-{
- (void) signal (SIGINFO, sig_handler);
-}
-#endif
diff --git a/lib/libpthread/pthreads/init.cc b/lib/libpthread/pthreads/init.cc
deleted file mode 100644
index 24a131a60a5..00000000000
--- a/lib/libpthread/pthreads/init.cc
+++ /dev/null
@@ -1,9 +0,0 @@
-
-/*
- * DO not delete this file. The hack here ensures that pthread_init() gets
- * called before main does. This doesn't fix everything. It is still
- * possible for a c++ module to reley on constructors that need pthreads.
- */
-#include <pthread.h>
-
-char __pthread_init_hack = 42;
diff --git a/lib/libpthread/pthreads/malloc.c b/lib/libpthread/pthreads/malloc.c
deleted file mode 100644
index 0c5937ddb12..00000000000
--- a/lib/libpthread/pthreads/malloc.c
+++ /dev/null
@@ -1,361 +0,0 @@
-/* ==== malloc.c ============================================================
- * Copyright (c) 1983 Regents of the University of California.
- * Copyright (c) 1993, 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * Description : Malloc functions.
- * This is a very fast storage allocator. It allocates blocks of a small
- * number of different sizes, and keeps free lists of each size. Blocks that
- * don't exactly fit are passed up to the next larger size. In this
- * implementation, the available sizes are 2^n-4 (or 2^n-10) bytes long.
- * This is designed for use in a virtual memory environment.
- *
- * 0.00 82/02/21 Chris Kingsley kingsley@cit-20
- *
- * 1.00 93/11/06 proven
- * -Modified BSD libc malloc to be threadsafe.
- *
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: malloc.c,v 1.1 1995/10/18 08:43:05 deraadt Exp $ $provenid: malloc.c,v 1.16 1994/02/07 02:19:00 proven Exp $";
-#endif
-
-#include <pthread.h>
-#include <sys/types.h>
-#include <string.h>
-#include <pthread/posix.h>
-
-/*
- * The overhead on a block is at least 4 bytes. When free, this space
- * contains a pointer to the next free block, and the bottom two bits must
- * be zero. When in use, the first byte is set to MAGIC, and the second
- * byte is the size index. The remaining bytes are for alignment.
- * If range checking is enabled then a second word holds the size of the
- * requested block, less 1, rounded up to a multiple of sizeof(RMAGIC).
- * The order of elements is critical: ov_magic must overlay the low order
- * bits of ov_next, and ov_magic can not be a valid ov_next bit pattern.
- */
-union overhead {
- union overhead *ov_next; /* when free */
- struct {
- u_char ovu_magic; /* magic number */
- u_char ovu_index; /* bucket # */
-#ifdef RCHECK
- u_short ovu_rmagic; /* range magic number */
- u_int ovu_size; /* actual block size */
-#endif
- } ovu;
-#define ov_magic ovu.ovu_magic
-#define ov_index ovu.ovu_index
-#define ov_rmagic ovu.ovu_rmagic
-#define ov_size ovu.ovu_size
-};
-
-#define MAGIC 0xef /* magic # on accounting info */
-#define RMAGIC 0x5555 /* magic # on range info */
-
-#ifdef RCHECK
-#define RSLOP sizeof (u_short)
-#else
-#define RSLOP 0
-#endif
-
-/*
- * nextf[i] is the pointer to the next free block of size 2^(i+3). The
- * smallest allocatable block is 8 bytes. The overhead information
- * precedes the data area returned to the user.
- */
-#define NBUCKETS 30
-static union overhead *nextf[NBUCKETS];
-extern char *sbrk();
-
-static int pagesz; /* page size */
-static int pagebucket; /* page size bucket */
-static semaphore malloc_lock = SEMAPHORE_CLEAR;
-
-#if defined(DEBUG) || defined(RCHECK)
-#define ASSERT(p) if (!(p)) botch("p")
-#include <stdio.h>
-static
-botch(s)
- char *s;
-{
- fprintf(stderr, "\r\nassertion botched: %s\r\n", s);
- (void) fflush(stderr); /* just in case user buffered it */
- abort();
-}
-#else
-#define ASSERT(p)
-#endif
-
-/* ==========================================================================
- * morecore()
- *
- * Allocate more memory to the indicated bucket
- */
-static inline void morecore(int bucket)
-{
- register union overhead *op;
- register int sz; /* size of desired block */
- int amt; /* amount to allocate */
- int nblks; /* how many blocks we get */
-
- /*
- * sbrk_size <= 0 only for big, FLUFFY, requests (about
- * 2^30 bytes on a VAX, I think) or for a negative arg.
- */
- sz = 1 << (bucket + 3);
-#ifdef DEBUG
- ASSERT(sz > 0);
-#else
- if (sz <= 0)
- return;
-#endif
- if (sz < pagesz) {
- amt = pagesz;
- nblks = amt / sz;
- } else {
- amt = sz + pagesz;
- nblks = 1;
- }
- op = (union overhead *)sbrk(amt);
- /* no more room! */
- if ((int)op == -1)
- return;
- /*
- * Add new memory allocated to that on
- * free list for this hash bucket.
- */
- nextf[bucket] = op;
- while (--nblks > 0) {
- op->ov_next = (union overhead *)((caddr_t)op + sz);
- op = (union overhead *)((caddr_t)op + sz);
- }
-}
-
-/* ==========================================================================
- * malloc()
- */
-void *malloc(size_t nbytes)
-{
- union overhead *op;
- unsigned int amt;
- int bucket, n;
- semaphore *lock;
-
- lock = &malloc_lock;
- while(SEMAPHORE_TEST_AND_SET(lock)) {
- pthread_yield();
- }
- /*
- * First time malloc is called, setup page size and
- * align break pointer so all data will be page aligned.
- */
- if (pagesz == 0) {
- pagesz = n = getpagesize();
- op = (union overhead *)sbrk(0);
- n = n - sizeof (*op) - ((int)op & (n - 1));
- if (n < 0)
- n += pagesz;
- if (n) {
- if (sbrk(n) == (char *)-1)
- return (NULL);
- }
- bucket = 0;
- amt = 8;
- while (pagesz > amt) {
- amt <<= 1;
- bucket++;
- }
- pagebucket = bucket;
- }
- /*
- * Convert amount of memory requested into closest block size
- * stored in hash buckets which satisfies request.
- * Account for space used per block for accounting.
- */
- if (nbytes <= (n = pagesz - sizeof (*op) - RSLOP)) {
-#ifndef RCHECK
- amt = 8; /* size of first bucket */
- bucket = 0;
-#else
- amt = 16; /* size of first bucket */
- bucket = 1;
-#endif
- n = -(sizeof (*op) + RSLOP);
- } else {
- amt = pagesz;
- bucket = pagebucket;
- }
- while (nbytes > amt + n) {
- amt <<= 1;
- if (amt == 0) {
- SEMAPHORE_RESET(lock);
- return (NULL);
- }
- bucket++;
- }
- /*
- * If nothing in hash bucket right now,
- * request more memory from the system.
- */
- if ((op = nextf[bucket]) == NULL) {
- morecore(bucket);
- if ((op = nextf[bucket]) == NULL) {
- SEMAPHORE_RESET(lock);
- return (NULL);
- }
- }
- /* remove from linked list */
- nextf[bucket] = op->ov_next;
- op->ov_magic = MAGIC;
- op->ov_index = bucket;
-#ifdef RCHECK
- /*
- * Record allocated size of block and
- * bound space with magic numbers.
- */
- op->ov_size = (nbytes + RSLOP - 1) & ~(RSLOP - 1);
- op->ov_rmagic = RMAGIC;
- *(u_short *)((caddr_t)(op + 1) + op->ov_size) = RMAGIC;
-#endif
- SEMAPHORE_RESET(lock);
- return ((char *)(op + 1));
-}
-
-/* ==========================================================================
- * free()
- */
-void free(void *cp)
-{
- union overhead *op;
- semaphore *lock;
- int size;
-
- lock = &malloc_lock;
- while(SEMAPHORE_TEST_AND_SET(lock)) {
- pthread_yield();
- }
- if (cp == NULL) {
- SEMAPHORE_RESET(lock);
- return;
- }
- op = (union overhead *)((caddr_t)cp - sizeof (union overhead));
-#ifdef DEBUG
- ASSERT(op->ov_magic == MAGIC); /* make sure it was in use */
-#else
- if (op->ov_magic != MAGIC) {
- SEMAPHORE_RESET(lock);
- return; /* sanity */
- }
-#endif
-#ifdef RCHECK
- ASSERT(op->ov_rmagic == RMAGIC);
- ASSERT(*(u_short *)((caddr_t)(op + 1) + op->ov_size) == RMAGIC);
-#endif
- size = op->ov_index;
- ASSERT(size < NBUCKETS);
- op->ov_next = nextf[size]; /* also clobbers ov_magic */
- nextf[size] = op;
-
- SEMAPHORE_RESET(lock);
-}
-
-/* ==========================================================================
- * realloc()
- *
- * Storage compaction is no longer supported, fix program and try again.
- */
-void *realloc(void *cp, size_t nbytes)
-{
- u_int onb;
- int i;
- semaphore *lock;
- union overhead *op;
- char *res;
-
- if (cp == NULL)
- return (malloc(nbytes));
- op = (union overhead *)((caddr_t)cp - sizeof (union overhead));
-
- if (op->ov_magic == MAGIC) {
- i = op->ov_index;
- } else {
- /*
- * This will cause old programs using storage compaction feature of
- * realloc to break in a pseudo resonable way that is easy to debug.
- * Returning a malloced buffer without the copy may cause
- * indeterministic behavior.
- */
- return(NULL);
- }
-
- lock = &malloc_lock;
- while(SEMAPHORE_TEST_AND_SET(lock)) {
- pthread_yield();
- }
- onb = 1 << (i + 3);
- if (onb < pagesz)
- onb -= sizeof (*op) + RSLOP;
- else
- onb += pagesz - sizeof (*op) - RSLOP;
-
- /* avoid the copy if same size block */
- if (i) {
- i = 1 << (i + 2);
- if (i < pagesz)
- i -= sizeof (*op) + RSLOP;
- else
- i += pagesz - sizeof (*op) - RSLOP;
- }
-
- if (nbytes <= onb && nbytes > i) {
-#ifdef RCHECK
- op->ov_size = (nbytes + RSLOP - 1) & ~(RSLOP - 1);
- *(u_short *)((caddr_t)(op + 1) + op->ov_size) = RMAGIC;
-#endif
- SEMAPHORE_RESET(lock);
- return(cp);
- }
- SEMAPHORE_RESET(lock);
-
- if ((res = malloc(nbytes)) == NULL) {
- free(cp);
- return (NULL);
- }
-
- bcopy(cp, res, (nbytes < onb) ? nbytes : onb);
- free(cp);
-
- return (res);
-}
-
diff --git a/lib/libpthread/pthreads/mutex.c b/lib/libpthread/pthreads/mutex.c
deleted file mode 100644
index a269284ae2f..00000000000
--- a/lib/libpthread/pthreads/mutex.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/* ==== mutex.c ============================================================
- * Copyright (c) 1993, 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 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.
- *
- * Description : Mutex functions.
- *
- * 1.00 93/07/19 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: mutex.c,v 1.1 1995/10/18 08:43:05 deraadt Exp $ $provenid: mutex.c,v 1.16 1994/02/07 02:19:03 proven Exp $";
-#endif
-
-#include <pthread.h>
-#include <errno.h>
-
-/*
- * Basic mutex functionality
-
- * This is the basic lock order
- * queue
- * pthread
- * global
- *
- * semaphore functionality is defined in machdep.h
- */
-
-/* ==========================================================================
- * pthread_mutex_init()
- *
- * In this implementation I don't need to allocate memory.
- * ENOMEM, EAGAIN should never be returned. Arch that have
- * weird constraints may need special coding.
- */
-int pthread_mutex_init(pthread_mutex_t *mutex, pthread_mutexattr_t *mutex_attr)
-{
- /* Only check if attr specifies some mutex type other than fast */
- if ((mutex_attr) && (mutex_attr->m_type != MUTEX_TYPE_FAST)) {
- if (mutex_attr->m_type >= MUTEX_TYPE_MAX) {
- return(EINVAL);
- }
- if (mutex->m_flags & MUTEX_FLAGS_INITED) {
- return(EBUSY);
- }
- mutex->m_type = mutex_attr->m_type;
- } else {
- mutex->m_type = MUTEX_TYPE_FAST;
- }
- /* Set all other paramaters */
- pthread_queue_init(&mutex->m_queue);
- mutex->m_flags |= MUTEX_FLAGS_INITED;
- mutex->m_lock = SEMAPHORE_CLEAR;
- mutex->m_owner = NULL;
- return(OK);
-}
-
-/* ==========================================================================
- * pthread_mutex_destroy()
- */
-int pthread_mutex_destroy(pthread_mutex_t *mutex)
-{
- /* Only check if mutex is of type other than fast */
- switch(mutex->m_type) {
- case MUTEX_TYPE_FAST:
- break;
- case MUTEX_TYPE_STATIC_FAST:
- default:
- return(EINVAL);
- break;
- }
-
- /* Cleanup mutex, others might want to use it. */
- pthread_queue_init(&mutex->m_queue);
- mutex->m_flags |= MUTEX_FLAGS_INITED;
- mutex->m_lock = SEMAPHORE_CLEAR;
- mutex->m_owner = NULL;
- mutex->m_flags = 0;
- return(OK);
-}
-
-/* ==========================================================================
- * pthread_mutex_trylock()
- */
-int pthread_mutex_trylock(pthread_mutex_t *mutex)
-{
- semaphore *lock;
- int rval;
-
- lock = &(mutex->m_lock);
- while (SEMAPHORE_TEST_AND_SET(lock)) {
- pthread_yield();
- }
-
- switch (mutex->m_type) {
- /*
- * Fast mutexes do not check for any error conditions.
- */
- case MUTEX_TYPE_FAST:
- case MUTEX_TYPE_STATIC_FAST:
- if (!mutex->m_owner) {
- mutex->m_owner = pthread_run;
- rval = OK;
- } else {
- rval = EBUSY;
- }
- break;
- default:
- rval = EINVAL;
- break;
- }
- SEMAPHORE_RESET(lock);
- return(rval);
-}
-
-/* ==========================================================================
- * pthread_mutex_lock()
- */
-int pthread_mutex_lock(pthread_mutex_t *mutex)
-{
- semaphore *lock, *plock;
- int rval;
-
- lock = &(mutex->m_lock);
- while (SEMAPHORE_TEST_AND_SET(lock)) {
- pthread_yield();
- }
-
- switch (mutex->m_type) {
- /*
- * Fast mutexes do not check for any error conditions.
- */
- case MUTEX_TYPE_FAST:
- case MUTEX_TYPE_STATIC_FAST:
- if (mutex->m_owner) {
- plock = &(pthread_run->lock);
- while (SEMAPHORE_TEST_AND_SET(plock)) {
- pthread_yield();
- }
- pthread_queue_enq(&mutex->m_queue, pthread_run);
- SEMAPHORE_RESET(lock);
-
- /* Reschedule will unlock pthread_run */
- reschedule(PS_MUTEX_WAIT);
- return(OK);
- }
- mutex->m_owner = pthread_run;
- rval = OK;
- break;
- default:
- rval = EINVAL;
- break;
- }
- SEMAPHORE_RESET(lock);
- return(rval);
-}
-
-/* ==========================================================================
- * pthread_mutex_unlock()
- */
-int pthread_mutex_unlock(pthread_mutex_t *mutex)
-{
- struct pthread *pthread;
- semaphore *lock, *plock;
- int rval;
-
- lock = &(mutex->m_lock);
- while (SEMAPHORE_TEST_AND_SET(lock)) {
- pthread_yield();
- }
-
- switch (mutex->m_type) {
- /*
- * Fast mutexes do not check for any error conditions.
- */
- case MUTEX_TYPE_FAST:
- case MUTEX_TYPE_STATIC_FAST:
- if (pthread = pthread_queue_get(&mutex->m_queue)) {
- plock = &(pthread->lock);
- while (SEMAPHORE_TEST_AND_SET(plock)) {
- pthread_yield();
- }
- mutex->m_owner = pthread;
-
- /* Reset pthread state */
- pthread_queue_deq(&mutex->m_queue);
- pthread->state = PS_RUNNING;
- SEMAPHORE_RESET(plock);
- } else {
- mutex->m_owner = NULL;
- }
- rval = OK;
- break;
- default:
- rval = EINVAL;
- break;
- }
- SEMAPHORE_RESET(lock);
- return(rval);
-}
diff --git a/lib/libpthread/pthreads/mutexattr.c b/lib/libpthread/pthreads/mutexattr.c
deleted file mode 100644
index db6e561ac8f..00000000000
--- a/lib/libpthread/pthreads/mutexattr.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* ==== mutexattr.c ===========================================================
- * Copyright (c) 1993, 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 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.
- *
- * Description : Mutex functions.
- *
- * 1.00 93/07/19 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: mutexattr.c,v 1.1 1998/07/21 13:20:09 peter Exp $";
-#endif
-
-#include <pthread.h>
-#include <errno.h>
-
-/* ==========================================================================
- * pthread_mutexattr_init()
- */
-int pthread_mutexattr_init(pthread_mutexattr_t *attr)
-{
- attr->m_type = MUTEX_TYPE_FAST;
- return(OK);
-}
-
-/* ==========================================================================
- * pthread_mutexattr_destroy()
- */
-int pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
-{
- return(OK);
-}
-
-/* ==========================================================================
- * pthread_mutexattr_settype()
- */
-int pthread_mutexattr_settype(pthread_mutexattr_t *attr, unsigned int type)
-{
- switch(type) {
- case PTHREAD_MUTEXTYPE_FAST:
- attr->m_type = MUTEX_TYPE_FAST;
- break;
- case PTHREAD_MUTEXTYPE_RECURSIVE:
- attr->m_type = MUTEX_TYPE_COUNTING_FAST;
- break;
- case PTHREAD_MUTEXTYPE_DEBUG:
- attr->m_type = MUTEX_TYPE_DEBUG;
- break;
- default:
- return(EINVAL);
- }
- return(OK);
-}
-
-/* ==========================================================================
- * pthread_mutexattr_gettype()
- */
-int pthread_mutexattr_gettype(pthread_mutexattr_t *attr, unsigned int * type)
-{
- *type = (unsigned int)attr->m_type;
- return(OK);
-}
diff --git a/lib/libpthread/pthreads/panic.c b/lib/libpthread/pthreads/panic.c
deleted file mode 100644
index 6b963acd651..00000000000
--- a/lib/libpthread/pthreads/panic.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/* ==== panic.c =======================================================
- * Copyright (c) 1996 by Larry V. Streepy, Jr.
- * 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 Larry V. Streepy, Jr.
- * 4. The name of Larry V. Streepy, Jr. may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Larry V. Streepy, Jr. ``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 Larry V. Streepy, Jr. 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.
- *
- * Description : pthread kernel panic
- *
- * 02 Oct 1996 - Larry V. Streepy, Jr.
- * - Initial coding
- */
-
-#include <pthread.h>
-#include <stdio.h>
-/*----------------------------------------------------------------------
- * Function: panic_kernel
- * Purpose: print a message and panic the pthreads kernel
- * Args: file name, line number, and function
- * Returns: doesn't
- * Notes:
- *----------------------------------------------------------------------*/ void
-panic_kernel( const char *file, unsigned int line, const char *func )
-{
-#ifdef __GNUC__
- (void) fprintf( stderr, "%s:%u: %s%sPhtreads kernel panic.\n",
- file, line, func ? func : "", func ? ": " : "" );
- (void) fflush (stderr);
-#else
- (void) fprintf( stderr, "%s:%u: Phtreads kernel panic.\n", file, line );
- (void) fflush (stderr);
-#endif
- abort();
-}
diff --git a/lib/libpthread/pthreads/prio_queue.c b/lib/libpthread/pthreads/prio_queue.c
deleted file mode 100644
index b03fa788a58..00000000000
--- a/lib/libpthread/pthreads/prio_queue.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/* ==== prio_queue.c ==========================================================
- * 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 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.
- *
- * Description : Priority Queue functions.
- *
- * 1.00 94/09/19 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: prio_queue.c,v 1.1 1998/07/21 13:20:09 peter Exp $";
-#endif
-
-#include <pthread.h>
-
-/* A thread when it becomes eligeble to run is placed on the run queue.
- This requires locking the kernel lock
-*/
-
-/* ==========================================================================
- * pthread_prio_queue_init()
- */
-void pthread_prio_queue_init(struct pthread_prio_queue * queue)
-{
- int i;
-
- for (i = 0; i <= PTHREAD_MAX_PRIORITY; i++) {
- queue->level[i].first = NULL;
- queue->level[i].last = NULL;
- }
- queue->next = NULL;
- queue->data = NULL;
-}
-
-/* ==========================================================================
- * pthread_priority_enq()
- */
-void pthread_prio_queue_enq(struct pthread_prio_queue * queue,
- struct pthread * pthread)
-{
- int priority = pthread->pthread_priority;
-
- if (queue->next) {
- if (queue->level[priority].first) {
- pthread->next = (queue->level[priority].last)->next;
- (queue->level[priority].last)->next = pthread;
- queue->level[priority].last = pthread;
- return;
- }
- if (priority != PTHREAD_MAX_PRIORITY) {
- int prev_priority;
- /* Find first higher priority thread queued on queue */
- for (prev_priority = priority + 1; prev_priority <=
- PTHREAD_MAX_PRIORITY; prev_priority++) {
- if (queue->level[prev_priority].first) {
- pthread->next = (queue->level[prev_priority].last)->next;
- (queue->level[prev_priority].last)->next = pthread;
- queue->level[priority].first = pthread;
- queue->level[priority].last = pthread;
- return;
- }
- }
- }
- }
- queue->level[priority].first = pthread;
- queue->level[priority].last = pthread;
- pthread->next = queue->next;
- queue->next = pthread;
-}
-
-/* ==========================================================================
- * pthread_prio_queue_deq()
- */
-struct pthread * pthread_prio_queue_deq(struct pthread_prio_queue * queue)
-{
- struct pthread * pthread;
- int priority;
-
- if (pthread = queue->next) {
- priority = queue->next->pthread_priority;
- if (queue->level[priority].first == queue->level[priority].last) {
- queue->level[priority].first = NULL;
- queue->level[priority].last = NULL;
- } else {
- queue->level[priority].first = pthread->next;
- }
- queue->next = pthread->next;
- pthread->next = NULL;
- }
- return(pthread);
-}
-
-/* ==========================================================================
- * pthread_prio_queue_remove()
- */
-int pthread_prio_queue_remove(struct pthread_prio_queue *queue,
- struct pthread *thread)
-{
- /* XXX This is slow, should start with thread priority */
- int priority = thread->pthread_priority;
- struct pthread **current = &(queue->level[priority].first);
- struct pthread *prev = NULL;
-
- if (thread==*current) {
- int current_priority=priority+1;
-
- if (*current == queue->next){
- pthread_prio_queue_deq(queue);
- thread->next = NULL;
- return(OK);
- }
- for (current_priority; current_priority <= PTHREAD_MAX_PRIORITY;
- current_priority++) {
- if (queue->level[current_priority].last) {
- queue->level[current_priority].last->next = (*current)->next;
- if ((*current)->next &&
- (*current)->next->pthread_priority == priority)
- queue->level[priority].first = (*current)->next;
- else {
- queue->level[priority].first = NULL;
- queue->level[priority].last = NULL;
- }
- thread->next = NULL;
- return(OK);
- }
- }
- }
-
- if (*current == NULL) /* Mati Sauks */
- {
- return (NOTOK);
- }
- for (prev=*current,current=&((*current)->next);
- *current && ((*current)->pthread_priority == priority);
- prev=*current,current=&((*current)->next)) {
- if (*current == thread) {
- if (*current == queue->level[priority].last) {
- queue->level[priority].last = prev;
- }
-
- *current = (*current)->next;
- thread->next=NULL;
- return(OK);
- }
- }
- return(NOTOK);
-}
-
diff --git a/lib/libpthread/pthreads/process.c b/lib/libpthread/pthreads/process.c
deleted file mode 100644
index 56e5d882d77..00000000000
--- a/lib/libpthread/pthreads/process.c
+++ /dev/null
@@ -1,208 +0,0 @@
-/* ==== process.c ============================================================
- * 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 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.
- *
- * Description : Process functions (fork, exec, ...).
- *
- * 1.23 94/04/18 proven
- * -Started coding this file.
- */
-
-#include <pthread.h>
-#include <sys/types.h>
-#include <pthread.h>
-#include <stdarg.h>
-#include <unistd.h>
-#ifdef HAVE_ALLOC_H
-#include <alloc.h>
-#endif
-
-extern void *alloca();
-
-#ifndef lint
-static const char rcsid[] = "$Id: process.c,v 1.1 1998/07/21 13:20:09 peter Exp $";
-#endif
-
-/* ==========================================================================
- * fork()
- *
- * This function requires a sig_prevent()/sig_check_and_resume() for the
- * parent. The child never unlocks.
- */
-pid_t fork()
-{
- pid_t ret;
-
- pthread_sched_prevent();
-
- fd_kern_fork();
- if (ret = machdep_sys_fork()) { /* Parent or error */
- pthread_sched_resume();
- } else { /* Child */
- machdep_unset_thread_timer(NULL);
- machdep_stop_timer(NULL);
- fork_lock++;
- pthread_kernel_lock--;
- }
- return(ret);
-}
-
-#ifdef HAVE_VFORK
-/* The semantics of vfork probably won't mix well with the pthread
- library code. Don't even try. */
-pid_t vfork ()
-{
- return fork ();
-}
-#endif
-
-/* ==========================================================================
- * execve()
- *
- * This function requires a sig_prevent()/sig_check_and_resume() if one
- * hasn't been done in the fork routine. Normally machdep_sys_execve()
- * should never return.
- */
-int execve(const char *name, char * const *argv, char * const *envp)
-{
- int ret;
-
- if (!fork_lock) {
- pthread_sched_prevent();
- fd_kern_exec(0);
- ret = machdep_sys_execve(name, argv, envp);
- pthread_sched_resume();
- } else {
- fd_kern_exec(1);
- ret = machdep_sys_execve(name, argv, envp);
- }
- return(ret);
-}
-
-/* Variants of execve. Define them here so that the system versions
- don't get used and drag in the system version of execve. */
-#include <sys/stat.h>
-#include <string.h>
-#include <sys/param.h>
-extern char **environ;
-
-static const char *find (const char *name, char *buf)
-{
- char *p1, *p2;
- extern char *getenv ();
- struct stat sb;
-
- if (strchr (name, '/'))
- return name;
- p1 = getenv ("PATH");
- if (p1 == 0)
- p1 = "/bin:/usr/bin:";
- while (*p1) {
- memset (buf, 0, MAXPATHLEN);
- p2 = strchr (p1, ':');
- if (p2 == 0)
- p2 = p1 + strlen (p1);
- strncpy (buf, p1, p2 - p1);
- buf[p2 - p1] = 0;
- strcat (buf, "/");
- strcat (buf, name);
- if (lstat (buf, &sb) == 0)
- return buf;
-
- if (*p2 == ':')
- p2++;
- p1 = p2;
- }
- return name;
-}
-
-int execl (const char *path, const char *arg, ...)
-{
-#ifdef SCO_3_5
- return execve (path, (char *const *) &arg, environ);
-#else
- char ** argv;
- va_list ap;
- int i;
-
- va_start(ap, arg);
- for (i = 1; va_arg(ap, char *) != NULL; i++);
- va_end(ap);
-
- argv = alloca (i * sizeof (char *));
-
- va_start(ap, arg);
- argv[0] = (char *) arg;
- for (i = 1; (argv[i] = (char *) va_arg(ap, char *)) != NULL; i++);
- va_end(ap);
-
- return execve (path, argv, environ);
-#endif
-}
-
-int execlp (const char *name, const char *arg, ...)
-{
-#ifdef SCO_3_5
- char buf[MAXPATHLEN];
- return execve (find (name, buf), (char *const *) &arg, environ);
-#else
- char buf[MAXPATHLEN];
- char ** argv;
- va_list ap;
- int i;
-
- va_start(ap, arg);
- for (i = 1; va_arg(ap, char *) != NULL; i++);
- va_end(ap);
-
- argv = alloca (i * sizeof (char *));
-
- va_start(ap, arg);
- argv[0] = (char *) arg;
- for (i = 1; (argv[i] = (char *) va_arg(ap, char *)) != NULL; i++);
- va_end(ap);
-
- return execve (find (name, buf), argv, environ);
-#endif
-}
-
-int execle (const char *name, const char *arg, ... /* , char *const envp[] */);
-
-/* This one turns on ptrace-style tracing? */
-int exect (const char *path, char *const argv[], char *const envp[]);
-
-int execv (const char *path, char *const argv[]) {
- return execve (path, argv, environ);
-}
-
-int execvp (const char *name, char *const argv[]) {
- char buf[MAXPATHLEN];
- return execve (find (name, buf), argv, environ);
-}
diff --git a/lib/libpthread/pthreads/pthread.c b/lib/libpthread/pthreads/pthread.c
deleted file mode 100644
index b16a14d67cb..00000000000
--- a/lib/libpthread/pthreads/pthread.c
+++ /dev/null
@@ -1,204 +0,0 @@
-/* ==== pthread.c ============================================================
- * Copyright (c) 1993, 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 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.
- *
- * Description : Pthread functions.
- *
- * 1.00 93/07/26 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: pthread.c,v 1.1 1995/10/18 08:43:05 deraadt Exp $ $provenid: pthread.c,v 1.16 1994/02/07 02:19:06 proven Exp $";
-#endif
-
-#include "pthread.h"
-#include <signal.h>
-#include <errno.h>
-
-/*
- * These first functions really should not be called by the user.
- */
-
-/* ==========================================================================
- * pthread_init()
- *
- * This function should be called in crt0.o before main() is called.
- * But on some systems It may not be possible to change crt0.o so currently
- * I'm requiring this function to be called first thing after main.
- * Actually I'm assuming it is, because I do no locking here.
- */
-void pthread_init(void)
-{
- struct machdep_pthread machdep_data = MACHDEP_PTHREAD_INIT;
-
- /* Initialize the first thread */
- if (pthread_initial = (pthread_t)malloc(sizeof(struct pthread))) {
- memcpy(&(pthread_initial->machdep_data), &machdep_data, sizeof(machdep_data));
- pthread_initial->state = PS_RUNNING;
- pthread_initial->queue = NULL;
- pthread_initial->next = NULL;
- pthread_initial->pll = NULL;
-
- pthread_initial->lock = SEMAPHORE_CLEAR;
- pthread_initial->error = 0;
-
- pthread_link_list = pthread_initial;
- pthread_run = pthread_initial;
-
- /* Initialize the signal handler. */
- sig_init();
-
- /* Initialize the fd table. */
- fd_init();
-
- return;
- }
- PANIC();
-}
-
-/* ==========================================================================
- * pthread_yield()
- */
-void pthread_yield()
-{
- sig_handler_fake(SIGVTALRM);
-}
-
-/* ======================================================================= */
-/* ==========================================================================
- * pthread_self()
- */
-pthread_t pthread_self()
-{
- return(pthread_run);
-}
-
-/* ==========================================================================
- * pthread_equal()
- */
-int pthread_equal(pthread_t t1, pthread_t t2)
-{
- return(t1 == t2);
-}
-
-/* ==========================================================================
- * pthread_exit()
- */
-void pthread_exit(void *status)
-{
- semaphore *lock, *plock;
- pthread_t pthread;
-
- lock = &pthread_run->lock;
- if (SEMAPHORE_TEST_AND_SET(lock)) {
- pthread_yield();
- }
-
- /* Save return value */
- pthread_run->ret = status;
-
- /* First execute all cleanup handlers */
-
-
- /*
- * Are there any threads joined to this one,
- * if so wake them and let them detach this thread.
- */
- if (pthread = pthread_queue_get(&(pthread_run->join_queue))) {
- /* The current thread pthread_run can't be detached */
- plock = &(pthread->lock);
- while (SEMAPHORE_TEST_AND_SET(plock)) {
- pthread_yield();
- }
- (void)pthread_queue_deq(&(pthread_run->join_queue));
- pthread->state = PS_RUNNING;
-
- /* Thread will unlock itself in pthread_join() */
- }
-
- /* This thread will never run again */
- reschedule(PS_DEAD);
- PANIC();
-}
-
-/* ==========================================================================
- * pthread_create()
- *
- * After the new thread structure is allocated and set up, it is added to
- * pthread_run_next_queue, which requires a sig_prevent(),
- * sig_check_and_resume()
- */
-int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
- void * (*start_routine)(void *), void *arg)
-{
- long nsec = 100000000;
- void *stack;
-
- if ((*thread) = (pthread_t)malloc(sizeof(struct pthread))) {
-
- if (! attr) { attr = &pthread_default_attr; }
-
- /* Get a stack, if necessary */
- if ((stack = attr->stackaddr_attr) ||
- (stack = (void *)malloc(attr->stacksize_attr))) {
-
- machdep_pthread_create(&((*thread)->machdep_data),
- start_routine, arg, 65536, stack, nsec);
-
- memcpy(&(*thread)->attr, attr, sizeof(pthread_attr_t));
-
- (*thread)->queue = NULL;
- (*thread)->next = NULL;
-
- (*thread)->lock = SEMAPHORE_CLEAR;
- (*thread)->error = 0;
-
- sig_prevent();
-
- /* Add to the link list of all threads. */
- (*thread)->pll = pthread_link_list;
- pthread_link_list = (*thread);
-
- (*thread)->state = PS_RUNNING;
- sig_check_and_resume();
-
- return(OK);
- }
- free((*thread));
- }
- return(ENOMEM);
-}
-
-/* ==========================================================================
- * pthread_cancel()
- *
- * This routine will also require a sig_prevent/sig_check_and_resume()
- */
diff --git a/lib/libpthread/pthreads/pthread_attr.c b/lib/libpthread/pthreads/pthread_attr.c
deleted file mode 100644
index 87ebfced7a0..00000000000
--- a/lib/libpthread/pthreads/pthread_attr.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/* ==== pthread_attr.c =======================================================
- * Copyright (c) 1993, 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 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.
- *
- * Description : Pthread attribute functions.
- *
- * 1.00 93/11/04 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: pthread_attr.c,v 1.1 1995/10/18 08:43:05 deraadt Exp $ $provenid: pthread_attr.c,v 1.16 1994/02/07 02:19:14 proven Exp $";
-#endif
-
-#include <pthread.h>
-#include <errno.h>
-
-/* Currently we do no locking, should we just to be safe? CAP */
-/* ==========================================================================
- * pthread_attr_init()
- */
-int pthread_attr_init(pthread_attr_t *attr)
-{
- memcpy(attr, &pthread_default_attr, sizeof(pthread_attr_t));
- return(OK);
-}
-
-/* ==========================================================================
- * pthread_attr_destroy()
- */
-int pthread_attr_destroy(pthread_attr_t *attr)
-{
- return(OK);
-}
-
-/* ==========================================================================
- * pthread_attr_getstacksize()
- */
-int pthread_attr_getstacksize(pthread_attr_t *attr, size_t * stacksize)
-{
- *stacksize = attr->stacksize_attr;
- return(OK);
-}
-
-/* ==========================================================================
- * pthread_attr_setstacksize()
- */
-int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
-{
- if (stacksize >= PTHREAD_STACK_MIN) {
- attr->stacksize_attr = stacksize;
- return(OK);
- }
- return(EINVAL);
-}
-
-/* ==========================================================================
- * pthread_attr_getstackaddr()
- */
-int pthread_attr_getstackaddr(pthread_attr_t *attr, void ** stackaddr)
-{
- *stackaddr = attr->stackaddr_attr;
- return(OK);
-}
-
-/* ==========================================================================
- * pthread_attr_setstackaddr()
- */
-int pthread_attr_setstackaddr(pthread_attr_t *attr, void * stackaddr)
-{
- attr->stackaddr_attr = stackaddr;
- return(OK);
-}
diff --git a/lib/libpthread/pthreads/pthread_cancel.c b/lib/libpthread/pthreads/pthread_cancel.c
deleted file mode 100644
index 4191a269027..00000000000
--- a/lib/libpthread/pthreads/pthread_cancel.c
+++ /dev/null
@@ -1,258 +0,0 @@
-/* ==== pthread_cancel.c ====================================================
- * Copyright (c) 1996 by Larry V. Streepy, Jr.
- * 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 Larry V. Streepy, Jr.
- * 4. The name of Larry V. Streepy, Jr. may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Larry V. Streepy, Jr. ``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 Larry V. Streepy, Jr. 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.
- *
- * Description : pthread_cancel operations
- *
- * 27 Sep 1996 - Larry V. Streepy, Jr.
- * - Initial coding
- */
-#ifndef lint
-static const char rcsid[] = "$Id:";
-#endif
-#include <pthread.h>
-#include <errno.h>
-static void possiblyMakeRunnable( pthread_t pthread );
-
-/*----------------------------------------------------------------------
- * Function: pthread_cancel
- * Purpose: Allows a thread to request that it or another thread
- * terminate execution
- * Args:
- * thread = thread to mark as cancelled
- * Returns:
- * int 0 = ok, -1 = some error (see errno)
- * Notes:
- * The thread is simply marked as CANCELLED, it is up to the cancelled
- * thread to decide how to handle it.
- *----------------------------------------------------------------------*/ int
-pthread_cancel( pthread_t pthread )
-{
- int rtn = 0; /* Assume all ok */
- pthread_sched_prevent();
- /* Ensure they gave us a legal pthread pointer */
- if( ! __pthread_is_valid( pthread ) ) {
- rtn = ESRCH; /* No such thread */
- } else if( pthread->state == PS_UNALLOCED || pthread->state == PS_DEAD ) {
- /* The standard doesn't call these out as errors, so return 0 */
- rtn = 0;
- } else {
- SET_PF_CANCELLED(pthread); /* Set the flag */
- /* If the thread is in the right state, then stick it on the
- * run queue so it will get a chance to process the cancel.
- */
- if( pthread != pthread_run ) {
- possiblyMakeRunnable( pthread );
- }
- }
- pthread_sched_resume();
- if( rtn == 0 )
- pthread_testcancel(); /* See if we cancelled ourself */
- return rtn;
-}
-
-/*----------------------------------------------------------------------
- * Function: pthread_setcancelstate
- * Purpose: Set the current thread's cancellability state
- * Args:
- * state = PTHREAD_CANCEL_DISABLE or PTHREAD_CANCEL_ENABLE
- * oldstate= pointer to holder for old state or NULL (*MODIFIED*)
- * Returns:
- * int 0 = ok
- * EINVAL = state is neither of the legal states
- * Notes:
- * This has to be async-cancel safe, so we prevent scheduling in
- * here
- *----------------------------------------------------------------------*/
-
-int
-pthread_setcancelstate( int newstate, int *oldstate )
-{
- int ostate = TEST_PF_CANCEL_STATE(pthread_run);
- int rtn = 0;
- pthread_sched_prevent();
- if( newstate == PTHREAD_CANCEL_ENABLE ||
- newstate == PTHREAD_CANCEL_DISABLE ) {
- SET_PF_CANCEL_STATE(pthread_run, newstate);
- if( oldstate != NULL )
- *oldstate = ostate;
- } else { /* Invalid new state */
- rtn = EINVAL;
- }
- pthread_sched_resume();
- if( rtn == 0 ) {
- /* Test to see if we have a pending cancel to handle */
- pthread_testcancel();
- }
- return rtn;
-}
-
-/*----------------------------------------------------------------------
- * Function: pthread_setcanceltype
- * Purpose: Set the current thread's cancellability type
- * Args:
- * type = PTHREAD_CANCEL_DEFERRED or PTHREAD_CANCEL_ASYNCHRONOUS
- * oldtype = pointer to holder for old type or NULL (*MODIFIED*)
- * Returns:
- * int 0 = ok
- * EINVAL = type is neither of the legal states
- * Notes:
- * This has to be async-cancel safe, so we prevent scheduling in
- * here
- *----------------------------------------------------------------------*/
-
-int
-pthread_setcanceltype( int newtype, int *oldtype )
-{
- int otype = TEST_PF_CANCEL_TYPE(pthread_run);
- int rtn = 0;
- pthread_sched_prevent();
- if( newtype == PTHREAD_CANCEL_DEFERRED ||
- newtype == PTHREAD_CANCEL_ASYNCHRONOUS) {
- SET_PF_CANCEL_TYPE(pthread_run, newtype);
- if( oldtype != NULL )
- *oldtype = otype;
- } else { /* Invalid new type */
- rtn = EINVAL;
- }
- pthread_sched_resume();
- if( rtn == 0 ) {
- /* Test to see if we have a pending cancel to handle */
- pthread_testcancel();
- }
- return rtn;
-}
-
-/*----------------------------------------------------------------------
- * Function: pthread_testcancel
- * Purpose: Requests delivery of a pending cancel to the current thread
- * Args: void
- * Returns: void
- * Notes:
- * If the current thread has been cancelled, this function will not
- * return and the threads exit processing will be initiated.
- *----------------------------------------------------------------------*/
-
-void
-pthread_testcancel( void )
-{
- if( TEST_PF_CANCEL_STATE(pthread_run) == PTHREAD_CANCEL_DISABLE ) {
- return; /* Can't be cancelled */
- }
- /* Ensure that we aren't in the process of exiting already */
- if( TEST_PF_RUNNING_TO_CANCEL(pthread_run) )
- return;
-
- /* See if we have been cancelled */
- if( TEST_PF_CANCELLED(pthread_run) ) {
- /* Set this flag to avoid recursively calling pthread_exit */
- SET_PF_RUNNING_TO_CANCEL(pthread_run);
- pthread_exit( PTHREAD_CANCELLED ); /* Easy - just call pthread_exit */
- }
- return; /* Not cancelled */
-}
-
-/*----------------------------------------------------------------------
- * Function: pthread_cancel_internal
- * Purpose: An internal routine to begin the cancel processing
- * Args: freelocks = do we need to free locks before exiting
- * Returns: void
- * Notes:
- * This routine is called from pthread_resched_resume
- * prior to a context switch, and after a thread has resumed.
- *
- * The kernel must *NOT* be locked on entry here
- *----------------------------------------------------------------------*/
-
-void
-pthread_cancel_internal( int freelocks )
-{
- pthread_sched_prevent(); /* gotta stay focused */
- /* Since we can be called from pthread_resched_resume(), our
- * state is currently not PS_RUNNING. Since we side stepped
- * the actually blocking, we need to be removed from the queue
- * and marked as running.
- */
- if( pthread_run->state != PS_RUNNING ) {
- if( pthread_run->queue == NULL ) {
- PANIC(); /* Must be on a queue */
- }
- /* We MUST NOT put the thread on the prio_queue here. It
- * is already running (although it's state has changed) and if we
- * put it on the run queue, it will get resumed after it is dead
- * and we end up with a nice panic.
- */
- pthread_queue_remove(pthread_run->queue, pthread_run);
- pthread_run->state = PS_RUNNING; /* we are running */
- }
- /* Set this flag to avoid recursively calling pthread_exit */
- SET_PF_RUNNING_TO_CANCEL(pthread_run);
- /* Free up any locks we hold if told to. */
- if( freelocks ) {
- fd_unlock_for_cancel();
- }
- pthread_sched_resume();
- pthread_exit( PTHREAD_CANCELLED ); /* Easy - just call pthread_exit */
-}
-
-/*----------------------------------------------------------------------
- * Function: possiblyMakeRunnable
- * Purpose: Make a thread runnable so it can be cancelled if state allows
- * Args:
- * pthread = thread to process
- * Returns:
- * Notes:
- *----------------------------------------------------------------------*/
-
-static void
-possiblyMakeRunnable( pthread_t pthread )
-{
- if( ! TEST_PTHREAD_IS_CANCELLABLE(pthread) )
- return; /* Not currently cancellable */
- /* If the thread is currently runnable, then we just let things
- * take their course when it is next resumed.
- */
- if( pthread->state == PS_RUNNING )
- return; /* will happen at context switch */
- /* If the thread is sleeping, the it isn't on a queue. */
- if( pthread->state == PS_SLEEP_WAIT ) {
- sleep_cancel( pthread ); /* Remove from sleep list */
- } else {
- /* Otherwise, we need to take it off the queue and make it runnable */
- if( pthread->queue == NULL ) {
- PANIC(); /* Must be on a queue */
- }
- pthread_queue_remove(pthread->queue, pthread);
- }
- /* And make it runnable */
- pthread_prio_queue_enq(pthread_current_prio_queue, pthread);
- pthread->old_state = pthread->state;
- pthread->state = PS_RUNNING;
-}
diff --git a/lib/libpthread/pthreads/pthread_detach.c b/lib/libpthread/pthreads/pthread_detach.c
deleted file mode 100644
index 37ac35de292..00000000000
--- a/lib/libpthread/pthreads/pthread_detach.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* ==== pthread_detach.c =======================================================
- * 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 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.
- *
- * Description : pthread_join function.
- *
- * 1.00 94/01/15 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: pthread_detach.c,v 1.1 1995/10/18 08:43:05 deraadt Exp $ $provenid: pthread_detach.c,v 1.16 1994/02/07 02:19:16 proven Exp $";
-#endif
-
-#include <pthread.h>
-
-/* ==========================================================================
- * pthread_detach()
- */
-int pthread_detach(pthread_t pthread)
-{
- semaphore *plock;
- int ret;
-
- plock = &(pthread->lock);
- while (SEMAPHORE_TEST_AND_SET(plock)) {
- pthread_yield();
- }
-
- /* Check that thread isn't detached already */
- if (!(pthread->flags & PF_DETACHED)) {
-
- pthread->flags |= PF_DETACHED;
-
- /* Wakeup first threads waiting on a join */
- {
- struct pthread * next_thread;
- semaphore * next_lock;
-
- if (next_thread = pthread_queue_get(&(pthread->join_queue))) {
- next_lock = &(next_thread->lock);
- while (SEMAPHORE_TEST_AND_SET(next_lock)) {
- pthread_yield();
- }
- pthread_queue_deq(&(pthread->join_queue));
- next_thread->state = PS_RUNNING;
- /*
- * Thread will wake up in pthread_join(), see the thread
- * it was joined to already detached and unlock itself
- * and pthread
- */
- } else {
- SEMAPHORE_RESET(plock);
- }
- }
- ret = OK;
-
- } else {
- SEMAPHORE_RESET(plock);
- ret = ESRCH;
- }
- return(ret);
-}
diff --git a/lib/libpthread/pthreads/pthread_init.c b/lib/libpthread/pthreads/pthread_init.c
deleted file mode 100644
index 110029290b5..00000000000
--- a/lib/libpthread/pthreads/pthread_init.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/* ==== pthread_init.c ========================================================
- * Copyright (c) 1993, 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 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.
- *
- * Description : Pthread_init routine.
- *
- * 1.00 94/09/20 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: pthread_init.c,v 1.1 1998/07/21 13:20:16 peter Exp $";
-#endif
-
-#include <pthread.h>
-#include <stdlib.h>
-#include <string.h>
-
-/*
- * errno is declared here to prevent the linker from pulling in errno
- * from the C library (and whatever else is in that file). I also use
- * errno as the default location for error numbers for the initial thread
- * giving some backwards compatibility.
- */
-#ifdef errno
-#undef errno
-#endif
-
-#if !defined(M_UNIX)
-int errno;
-#else
-extern int errno;
-#endif
-
-/* ==========================================================================
- * pthread_init()
- *
- * We use features of the C++ linker to make sure this function is called
- * before anything else is done in the program. See init.cc.
- */
-void pthread_init(void)
-{
- struct machdep_pthread machdep_data = MACHDEP_PTHREAD_INIT;
-
- /* Only call this once */
- if (pthread_initial) {
- return;
- }
-
- pthread_pagesize = getpagesize();
-
- /* Initialize the first thread */
- if ((pthread_initial = (pthread_t)malloc(sizeof(struct pthread))) &&
- (pthread_current_prio_queue = (struct pthread_prio_queue *)
- malloc(sizeof(struct pthread_prio_queue)))) {
- memcpy(&(pthread_initial->machdep_data), &machdep_data,
- sizeof(machdep_data));
- memcpy(&pthread_initial->attr, &pthread_attr_default,
- sizeof(pthread_attr_t));
-
- pthread_initial->pthread_priority = PTHREAD_DEFAULT_PRIORITY;
- pthread_initial->state = PS_RUNNING;
-
- pthread_queue_init(&(pthread_initial->join_queue));
- pthread_initial->specific_data = NULL;
- pthread_initial->specific_data_count = 0;
- pthread_initial->cleanup = NULL;
- pthread_initial->queue = NULL;
- pthread_initial->next = NULL;
- pthread_initial->flags = 0;
- pthread_initial->pll = NULL;
- pthread_initial->sll = NULL;
-
- /* PTHREADS spec says we start with cancellability on and deferred */
- SET_PF_CANCEL_STATE(pthread_initial, PTHREAD_CANCEL_ENABLE);
- SET_PF_CANCEL_TYPE(pthread_initial, PTHREAD_CANCEL_DEFERRED);
-
-
- /* Ugly errno hack */
- pthread_initial->error_p = &errno;
- pthread_initial->error = 0;
-
- pthread_prio_queue_init(pthread_current_prio_queue);
- pthread_link_list = pthread_initial;
- pthread_run = pthread_initial;
-
- uthread_sigmask = &(pthread_run->sigmask);
-
- /* XXX can I assume the mask and pending siganl sets are empty. */
- sigemptyset(&(pthread_initial->sigpending));
- sigemptyset(&(pthread_initial->sigmask));
- pthread_initial->sigcount = 0;
-
- /* Initialize the signal handler. */
- sig_init();
-
- /* Initialize the fd table. */
- fd_init();
-
- /* Start the scheduler */
- machdep_set_thread_timer(&(pthread_run->machdep_data));
-#ifdef M_UNIX
- machdep_sys_init();
-#endif
- return;
- }
- PANIC();
-}
diff --git a/lib/libpthread/pthreads/pthread_join.c b/lib/libpthread/pthreads/pthread_join.c
deleted file mode 100644
index b94ce3a70ea..00000000000
--- a/lib/libpthread/pthreads/pthread_join.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/* ==== pthread_join.c =======================================================
- * 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 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.
- *
- * Description : pthread_join function.
- *
- * 1.00 94/01/15 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: pthread_join.c,v 1.1 1995/10/18 08:43:05 deraadt Exp $ $provenid: pthread_join.c,v 1.16 1994/02/07 02:19:19 proven Exp $";
-#endif
-
-#include <pthread.h>
-
-/* ==========================================================================
- * pthread_join()
- */
-int pthread_join(pthread_t pthread, void **thread_return)
-{
- semaphore *lock, *plock;
- int ret;
-
-
- plock = &(pthread->lock);
- while (SEMAPHORE_TEST_AND_SET(plock)) {
- pthread_yield();
- }
-
- /* Check that thread isn't detached already */
- if (pthread->flags & PF_DETACHED) {
- SEMAPHORE_RESET(plock);
- return(ESRCH);
- }
-
- lock = &(pthread_run->lock);
- while (SEMAPHORE_TEST_AND_SET(lock)) {
- pthread_yield();
- }
-
- /* If OK then queue current thread. */
- pthread_queue(&(pthread->join_queue), pthread_run);
-
- SEMAPHORE_RESET(plock);
- reschedule(PS_JOIN);
-
- /*
- * At this point the thread is locked from the pthread_exit
- * and so are we, so no extra locking is required, but be sure
- * to unlock at least ourself.
- */
- if (!(pthread->flags & PF_DETACHED)) {
- if (thread_return) {
- *thread_return = pthread->ret;
- }
- pthread->flags |= PF_DETACHED;
- ret = OK;
- } else {
- ret = ESRCH;
- }
-
- /* Cant do a cleanup until queue is cleared */
- {
- struct pthread * next_thread;
- semaphore * next_lock;
-
- if (next_thread = pthread_queue_get(&(pthread->join_queue))) {
- next_lock = &(next_thread->lock);
- while (SEMAPHORE_TEST_AND_SET(next_lock)) {
- pthread_yield();
- }
- pthread_queue_deq(&(pthread->join_queue));
- next_thread->state = PS_RUNNING;
- /*
- * Thread will wake up in pthread_join(), see the thread
- * it was joined to already detached and unlock itself
- */
- } else {
- SEMAPHORE_RESET(lock);
- }
- }
-
- SEMAPHORE_RESET(plock);
- return(ret);
-}
diff --git a/lib/libpthread/pthreads/pthread_kill.c b/lib/libpthread/pthreads/pthread_kill.c
deleted file mode 100644
index 528874b992c..00000000000
--- a/lib/libpthread/pthreads/pthread_kill.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ==== pthread_kill.c =======================================================
- * 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 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.
- *
- * Description : pthread_kill function.
- *
- * 1.32 94/06/12 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: pthread_kill.c,v 1.1 1998/07/21 13:20:18 peter Exp $";
-#endif
-
-#include <pthread.h>
-
-/* Defined in sig.c, a linked list of threads currently
- * blocked in sigwait(): */
-extern struct pthread * pthread_sigwait;
-
-
-/* ==========================================================================
- * pthread_kill()
- */
-int pthread_kill(struct pthread * pthread, int sig)
-{
- struct pthread ** pthread_ptr;
-
- pthread_sched_prevent();
-
- /* Check who is the current owner of pthread */
-/* if (pthread->kthread != pthread_run->kthread) { */
- if (0) {
- } else {
- if (pthread->state == PS_SIGWAIT) {
- if(sigismember(pthread->data.sigwait, sig)) {
- for (pthread_ptr = &pthread_sigwait;
- (*pthread_ptr);
- pthread_ptr = &((*pthread_ptr)->next)) {
- if ((*pthread_ptr) == pthread) {
-
- /* Take the thread out of the
- * pthread_sigwait linked list: */
- *pthread_ptr=(*pthread_ptr)->next;
-
- *(int *)(pthread->ret) = sig;
- pthread_sched_other_resume(pthread);
- return(OK);
- }
- }
- /* A thread should not be in the state PS_SIGWAIT
- * without being in the pthread_sigwait linked
- * list: */
- PANIC();
- }
- }
- if (!sigismember(&pthread->sigpending,sig)) /* Added by monty */
- {
- sigaddset(&(pthread->sigpending), sig);
- pthread->sigcount++;
- }
- }
-
- pthread_sched_resume();
- return(OK);
-}
diff --git a/lib/libpthread/pthreads/pthread_once.c b/lib/libpthread/pthreads/pthread_once.c
deleted file mode 100644
index 26a530971b0..00000000000
--- a/lib/libpthread/pthreads/pthread_once.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* ==== pthread_once.c =======================================================
- * Copyright (c) 1993, 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 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.
- *
- * Description : pthread_once function.
- *
- * 1.00 93/12/12 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: pthread_once.c,v 1.1 1995/10/18 08:43:05 deraadt Exp $ $provenid: pthread_once.c,v 1.4 1994/02/07 02:19:22 proven Exp $";
-#endif
-
-#include <pthread.h>
-
-/* ==========================================================================
- * pthread_once()
- */
-static pthread_mutex_t __pthread_once_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-int pthread_once(pthread_once_t *once_control, void (*init_routine)(void))
-{
- /* Check first for speed */
- if (*once_control == PTHREAD_ONCE_INIT) {
- pthread_mutex_lock(&__pthread_once_mutex);
- if (*once_control == PTHREAD_ONCE_INIT) {
- init_routine();
- (*once_control)++;
- }
- pthread_mutex_unlock(&__pthread_once_mutex);
- }
- return(OK);
-}
diff --git a/lib/libpthread/pthreads/queue.c b/lib/libpthread/pthreads/queue.c
deleted file mode 100644
index dd662136c51..00000000000
--- a/lib/libpthread/pthreads/queue.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/* ==== queue.c ============================================================
- * Copyright (c) 1993, 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 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.
- *
- * Description : Queue functions.
- *
- * 1.00 93/07/15 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: queue.c,v 1.1 1995/10/18 08:43:05 deraadt Exp $ $provenid: queue.c,v 1.16 1994/02/07 02:19:24 proven Exp $";
-#endif
-
-#include <pthread.h>
-
-/*
- * All routines in this file assume that the queue has been appropriatly
- * locked.
- */
-
-/* ==========================================================================
- * pthread_queue_init()
- */
-void pthread_queue_init(struct pthread_queue *queue)
-{
- queue->q_next = NULL;
- queue->q_last = NULL;
- queue->q_data = NULL;
-}
-
-/* ==========================================================================
- * pthread_queue_enq()
- */
-void pthread_queue_enq(struct pthread_queue *queue, struct pthread *thread)
-{
- if (queue->q_last) {
- queue->q_last->next = thread;
- } else {
- queue->q_next = thread;
- }
- queue->q_last = thread;
- thread->queue = queue;
- thread->next = NULL;
-
-}
-
-/* ==========================================================================
- * pthread_queue_get()
- */
-struct pthread *pthread_queue_get(struct pthread_queue *queue)
-{
- return(queue->q_next);
-}
-
-/* ==========================================================================
- * pthread_queue_deq()
- */
-struct pthread *pthread_queue_deq(struct pthread_queue *queue)
-{
- struct pthread *thread = NULL;
-
- if (queue->q_next) {
- thread = queue->q_next;
- if (!(queue->q_next = queue->q_next->next)) {
- queue->q_last = NULL;
- }
- thread->queue = NULL;
- thread->next = NULL;
- }
- return(thread);
-}
-
-/* ==========================================================================
- * pthread_queue_remove()
- */
-void pthread_queue_remove(struct pthread_queue *queue, struct pthread *thread)
-{
- struct pthread **current = &(queue->q_next);
- struct pthread *prev = NULL;
-
- while (*current) {
- if (*current == thread) {
- if ((*current)->next) {
- *current = (*current)->next;
- } else {
- queue->q_last = prev;
- *current = NULL;
- }
- }
- prev = *current;
- current = &((*current)->next);
- }
- thread->queue = NULL;
- thread->next = NULL;
-}
diff --git a/lib/libpthread/pthreads/schedparam.c b/lib/libpthread/pthreads/schedparam.c
deleted file mode 100644
index 599306c0a74..00000000000
--- a/lib/libpthread/pthreads/schedparam.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/* ==== schedparam.c =======================================================
- * 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 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.
- *
- * Description : Pthread schedparam functions.
- *
- * 1.38 94/06/15 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: schedparam.c,v 1.1 1998/07/21 13:20:22 peter Exp $";
-#endif
-
-#include <pthread.h>
-#include <sched.h>
-#include <errno.h>
-
-/* ==========================================================================
- * sched_get_priority_max
- */
-int sched_get_priority_max(int policy)
-{
- return PTHREAD_MAX_PRIORITY;
-}
-
-/* ==========================================================================
- * sched_get_priority_min
- */
-int sched_get_priority_min(int policy)
-{
- return PTHREAD_MIN_PRIORITY;
-}
-
-/* Currently only policy is supported */
-/* ==========================================================================
- * pthread_setschedparam()
- */
-int pthread_setschedparam(pthread_t pthread, int policy,
- struct sched_param * param)
-{
- enum schedparam_policy new_policy, old_policy;
- int ret = OK;
- int prio;
-
- new_policy = policy;
- pthread_sched_prevent();
- old_policy = pthread->attr.schedparam_policy;
-
- if (param) {
- if ((param->sched_priority < PTHREAD_MIN_PRIORITY) ||
- (param->sched_priority > PTHREAD_MAX_PRIORITY)) {
- pthread_sched_resume();
- return(EINVAL);
- }
- prio = param->sched_priority;
- } else {
- prio = pthread->pthread_priority;
- }
-
- if (pthread == pthread_run) {
- switch(new_policy) {
- case SCHED_RR:
- pthread->attr.schedparam_policy = new_policy;
- switch (old_policy) {
- case SCHED_FIFO:
- machdep_unset_thread_timer(NULL);
- default:
- pthread->pthread_priority = prio;
- break;
- }
- break;
- case SCHED_FIFO:
- pthread->attr.schedparam_policy = new_policy;
- switch (old_policy) {
- case SCHED_IO:
- case SCHED_RR:
- if (pthread->pthread_priority < prio) {
- pthread->pthread_priority = prio;
- pthread_sched_resume();
- pthread_yield();
- return(OK);
- }
- default:
- pthread->pthread_priority = prio;
- break;
- }
- break;
- case SCHED_IO:
- pthread->attr.schedparam_policy = new_policy;
- switch (old_policy) {
- case SCHED_FIFO:
- machdep_unset_thread_timer(NULL);
- default:
- pthread->pthread_priority = prio;
- break;
- }
- break;
- default:
- SET_ERRNO(EINVAL);
- ret = EINVAL;
- break;
- }
- } else {
- switch(new_policy) {
- case SCHED_FIFO:
- case SCHED_IO:
- case SCHED_RR:
- if(pthread_prio_queue_remove(pthread_current_prio_queue,pthread) == OK) {
- pthread->attr.schedparam_policy = new_policy;
- pthread->pthread_priority = prio;
- pthread_sched_other_resume(pthread);
- } else {
- pthread->attr.schedparam_policy = new_policy;
- pthread->pthread_priority = prio;
- pthread_sched_resume();
- }
- return(OK);
- break;
- default:
- SET_ERRNO(EINVAL);
- ret = EINVAL;
- break;
- }
- }
-
- pthread_sched_resume();
- return(ret);
-}
-
-/* ==========================================================================
- * pthread_getschedparam()
- */
-int pthread_getschedparam(pthread_t pthread, int * policy,
- struct sched_param * param)
-{
- *policy = pthread->attr.schedparam_policy;
- if (param) {
- param->sched_priority = pthread->pthread_priority;
- }
- return(OK);
-}
-
diff --git a/lib/libpthread/pthreads/select.c b/lib/libpthread/pthreads/select.c
deleted file mode 100644
index 2b145d9ed16..00000000000
--- a/lib/libpthread/pthreads/select.c
+++ /dev/null
@@ -1,255 +0,0 @@
-/* ==== select.c ============================================================
- * 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 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.
- *
- * This code based on code contributed by
- * Peter Hofmann <peterh@prz.tu-berlin.d400.de>
- *
- * Description : Select.
- *
- * 1.23 94/04/26 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: select.c,v 1.1 1998/07/21 13:20:22 peter Exp $";
-#endif
-
-#include <string.h>
-#include <errno.h>
-#include <pthread.h>
-#include <sys/types.h>
-#include <sys/time.h>
-
-extern struct pthread_queue fd_wait_select;
-static struct timeval zero_timeout = { 0, 0 }; /* Moved by monty */
-
-/* ==========================================================================
- * select()
- */
-int select(int numfds, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds, struct timeval *timeout)
-{
- fd_set real_exceptfds, real_readfds, real_writefds; /* mapped fd_sets */
- fd_set * real_readfds_p, * real_writefds_p, * real_exceptfds_p;
- fd_set read_locks, write_locks, rdwr_locks;
- struct timespec timeout_time, current_time;
- int i, j, ret = 0, got_all_locks = 1;
- struct pthread_select_data data;
-
- if (numfds > dtablesize) {
- numfds = dtablesize;
- }
-
- data.nfds = 0;
- FD_ZERO(&data.readfds);
- FD_ZERO(&data.writefds);
- FD_ZERO(&data.exceptfds);
-
- /* Do this first */
- if (timeout) {
- machdep_gettimeofday(&current_time);
- timeout_time.tv_sec = current_time.tv_sec + timeout->tv_sec;
- if ((timeout_time.tv_nsec = current_time.tv_nsec +
- (timeout->tv_usec * 1000)) > 1000000000) {
- timeout_time.tv_nsec -= 1000000000;
- timeout_time.tv_sec++;
- }
- }
-
- FD_ZERO(&read_locks);
- FD_ZERO(&write_locks);
- FD_ZERO(&rdwr_locks);
- FD_ZERO(&real_readfds);
- FD_ZERO(&real_writefds);
- FD_ZERO(&real_exceptfds);
-
- /* lock readfds */
- if (readfds || writefds || exceptfds) {
- for (i = 0; i < numfds; i++) {
- if ((readfds && (FD_ISSET(i, readfds))) ||
- (exceptfds && FD_ISSET(i, exceptfds))) {
- if (writefds && FD_ISSET(i ,writefds)) {
- if ((ret = fd_lock(i, FD_RDWR, NULL)) != OK) {
- got_all_locks = 0;
- break;
- }
- FD_SET(i, &rdwr_locks);
- FD_SET(fd_table[i]->fd.i,&real_writefds);
- } else {
- if ((ret = fd_lock(i, FD_READ, NULL)) != OK) {
- got_all_locks = 0;
- break;
- }
- FD_SET(i, &read_locks);
- }
- if (readfds && FD_ISSET(i,readfds)) {
- FD_SET(fd_table[i]->fd.i, &real_readfds);
- }
- if (exceptfds && FD_ISSET(i,exceptfds)) {
- FD_SET(fd_table[i]->fd.i, &real_exceptfds);
- }
- if (fd_table[i]->fd.i >= data.nfds) {
- data.nfds = fd_table[i]->fd.i + 1;
- }
- } else {
- if (writefds && FD_ISSET(i, writefds)) {
- if ((ret = fd_lock(i, FD_WRITE, NULL)) != OK) {
- got_all_locks = 0;
- break;
- }
- FD_SET(i, &write_locks);
- FD_SET(fd_table[i]->fd.i,&real_writefds);
- if (fd_table[i]->fd.i >= data.nfds) {
- data.nfds = fd_table[i]->fd.i + 1;
- }
- }
- }
- }
- }
-
- if (got_all_locks)
- {
- memcpy(&data.readfds,&real_readfds,sizeof(fd_set));
- memcpy(&data.writefds,&real_writefds,sizeof(fd_set));
- memcpy(&data.exceptfds,&real_exceptfds,sizeof(fd_set));
-
- real_readfds_p = (readfds == NULL) ? NULL : &real_readfds;
- real_writefds_p = (writefds == NULL) ? NULL : &real_writefds;
- real_exceptfds_p = (exceptfds == NULL) ? NULL : &real_exceptfds;
-
- pthread_run->sighandled=0;
- if ((ret = machdep_sys_select(data.nfds, real_readfds_p,
- real_writefds_p, real_exceptfds_p,
- &zero_timeout)) == OK) {
- pthread_sched_prevent();
-
- real_exceptfds_p = (exceptfds == NULL) ? NULL : &data.exceptfds;
- real_writefds_p = (writefds == NULL) ? NULL : &data.writefds;
- real_readfds_p = (readfds == NULL) ? NULL : &data.readfds;
-
- pthread_queue_enq(&fd_wait_select, pthread_run);
- pthread_run->data.select_data = &data;
- SET_PF_WAIT_EVENT(pthread_run);
-
- if (timeout) {
- machdep_gettimeofday(&current_time);
- sleep_schedule(&current_time, &timeout_time);
-
- SET_PF_AT_CANCEL_POINT(pthread_run);
- pthread_resched_resume(PS_SELECT_WAIT);
- CLEAR_PF_AT_CANCEL_POINT(pthread_run);
-
- /* We're awake */
- if (sleep_cancel(pthread_run) == NOTOK) {
- ret = OK;
- }
- else
- {
- int count = 0;
- for (i = 0; i < numfds; i++)
- {
- if (real_readfds_p && (FD_ISSET(i, real_readfds_p)))
- count++;
- if (real_writefds_p && (FD_ISSET(i, real_writefds_p)))
- count++;
- if (real_exceptfds_p && (FD_ISSET(i, real_exceptfds_p)))
- count++;
- }
- ret = count;
- }
- /* Moving this after the sleep_cancel() seemed
- * to fix intermittent crashes during heavy
- * socket use. (mevans)
- */
- CLEAR_PF_DONE_EVENT(pthread_run);
- } else {
- int count = 0;
- SET_PF_AT_CANCEL_POINT(pthread_run);
- pthread_resched_resume(PS_SELECT_WAIT);
- CLEAR_PF_AT_CANCEL_POINT(pthread_run);
- CLEAR_PF_DONE_EVENT(pthread_run);
- for (i = 0; i < numfds; i++)
- {
- if (real_readfds_p && (FD_ISSET(i, real_readfds_p)))
- count++;
- if (real_writefds_p && (FD_ISSET(i, real_writefds_p)))
- count++;
- if (real_exceptfds_p && (FD_ISSET(i, real_exceptfds_p)))
- count++;
- }
- ret = count;
- }
- if (pthread_run->sighandled) /* Added by monty */
- { /* We where aborted */
- ret= NOTOK;
- SET_ERRNO(EINTR);
- }
- } else if (ret < 0) {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
- }
-
- /* clean up the locks */
- for (i = 0; i < numfds; i++)
- { /* Changed by monty */
- if (FD_ISSET(i,&read_locks)) fd_unlock(i,FD_READ);
- if (FD_ISSET(i,&rdwr_locks)) fd_unlock(i,FD_RDWR);
- if (FD_ISSET(i,&write_locks)) fd_unlock(i,FD_WRITE);
- }
- if (ret > 0) {
- if (readfds != NULL) {
- for (i = 0; i < numfds; i++) {
- if (! (FD_ISSET(i,readfds) &&
- FD_ISSET(fd_table[i]->fd.i,real_readfds_p)))
- FD_CLR(i,readfds);
- }
- }
- if (writefds != NULL) {
- for (i = 0; i < numfds; i++)
- if (! (FD_ISSET(i,writefds) &&
- FD_ISSET(fd_table[i]->fd.i,real_writefds_p)))
- FD_CLR(i,writefds);
- }
- if (exceptfds != NULL) {
- for (i = 0; i < numfds; i++)
- if (! (FD_ISSET(i,exceptfds) &&
- FD_ISSET(fd_table[i]->fd.i,real_exceptfds_p)))
- FD_CLR(i,exceptfds);
- }
- } else {
- if (exceptfds != NULL) FD_ZERO(exceptfds);
- if (writefds != NULL) FD_ZERO(writefds);
- if (readfds != NULL) FD_ZERO(readfds);
- }
-
- return(ret);
-}
diff --git a/lib/libpthread/pthreads/sig.c b/lib/libpthread/pthreads/sig.c
deleted file mode 100644
index 7883665d19c..00000000000
--- a/lib/libpthread/pthreads/sig.c
+++ /dev/null
@@ -1,452 +0,0 @@
-/* ==== sig.c =======================================================
- * 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 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.
- *
- * Description : All the thread signal functions.
- *
- * 1.32 94/06/12 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: sig.c,v 1.1 1998/07/21 13:20:22 peter Exp $";
-#endif
-
-#include <errno.h>
-#include <pthread.h>
-#include <signal.h>
-#include <string.h>
-
-#if defined(M_UNIX)
-#define signal(A,B) machdep_sys_signal((A),(B))
-#endif
-
-extern void sig_handler_real();
-
-struct pthread * pthread_sigwait;
-static sigset_t pending_signals;
-
-struct pthread_sigvec {
- void (*vector)();
- sigset_t mask;
- int flags;
-} pthread_sigvec[SIGMAX];
-
-/* ==========================================================================
- * pthread_sig_register()
- *
- * Assumes the kernel is locked.
- */
-int pthread_sig_register(int sig)
-{
- struct pthread ** pthread_ptr, * pthread;
- int ret;
-
- /*
- * If we have a siginfo structure and the signal is synchronous then
- * only deliver the signal to the current thread.
- */
-
- /* Check waiting threads for delivery */
- for (pthread_ptr = &pthread_sigwait; (*pthread_ptr);
- pthread_ptr = &((*pthread_ptr)->next)) {
- if (sigismember((*pthread_ptr)->data.sigwait, sig)) {
- pthread=*pthread_ptr;
- *pthread_ptr=(*pthread_ptr)->next;
-
- pthread_prio_queue_enq(pthread_current_prio_queue, pthread);
- ret = pthread->pthread_priority;
- *(int *)(pthread->ret) = sig;
- pthread->state = PS_RUNNING;
-
- return(ret);
- }
- }
-
- /* Check current running thread */
- if (pthread_run) {
- if (!sigismember(&pthread_run->sigmask, sig)) {
- sigaddset(&pthread_run->sigpending, sig);
- pthread_run->sigcount++;
- return(0);
- }
- }
-
- /* Check any running thread */
- for (pthread = pthread_current_prio_queue->next;
- pthread; pthread = pthread->next) {
- if (!sigismember(&pthread->sigmask, sig)) {
- sigaddset(&pthread->sigpending, sig);
- pthread->sigcount++;
- return(0);
- }
- }
-
- /* Check any thread */
- for (pthread = pthread_link_list; pthread; pthread = pthread->pll) {
- if (!sigismember(&pthread->sigmask, sig)) {
- sigaddset(&pthread->sigpending, sig);
- pthread->sigcount++;
- return(0);
- }
- }
-
- sigaddset(&pending_signals, sig);
- return(0);
-}
-
-/* ==========================================================================
- * pthread_sig_default()
- */
-void pthread_sig_default(int sig)
-{
- sigset_t mask, omask;
-
- if (pthread_sigvec[sig].vector == SIG_DFL) {
- /* Set the signal handler to default before issueing the kill */
- signal(sig, SIG_DFL);
- kill(getpid(), sig);
- sigemptyset(&mask);
- sigaddset(&mask, sig);
- machdep_sys_sigprocmask(SIG_UNBLOCK, &mask, &omask);
- signal(sig, sig_handler_real);
- }
-}
-
-/* ==========================================================================
- * pthread_sig_process()
- *
- * Assumes the kernel is locked.
- */
-void pthread_sig_process()
-{
- void (*vector)();
- int i, j;
-
- for (i = 1; i < SIGMAX; i++) {
- if (sigismember(&(pthread_run->sigpending), i)) {
- if (! sigismember(&(pthread_run->sigmask), i)) {
- sigdelset(&(pthread_run->sigpending), i);
- pthread_run->sigcount--;
-
- if (pthread_sigvec[i].vector == SIG_IGN) {
- continue;
- }
- if (pthread_sigvec[i].vector == SIG_DFL) {
- pthread_sig_default(i);
- continue;
- }
-
- {
- sigset_t omask;
-
- sigemptyset(&omask);
- /* Save old mask */
- for (j = 1; j < SIGMAX; j++) {
- if (sigismember(&(pthread_run->sigmask), j)) {
- if (sigismember(&(pthread_sigvec[i].mask), j))
- sigaddset(&(pthread_run->sigmask), j);
- sigaddset(&omask, j);
- }
- }
- /* The signal is masked while handling the signal */
- sigaddset(&(pthread_run->sigmask), i);
-
- /*
- * Allow interrupts during a signal,
- * but not a change in the vector
- */
- vector = pthread_sigvec[i].vector;
- if (--pthread_kernel_lock) {
- PANIC();
- }
- vector(i);
- pthread_run->sighandled=1; /* Mark for select; Monty */
- pthread_kernel_lock++;
-
- memcpy(&(pthread_run->sigmask), &omask, sizeof(omask));
- }
- }
- }
- }
-}
-
-/* ==========================================================================
- * pthread_sigmask()
- *
- * It is unclear wheather this call should be implemented as an atomic
- * operation. The resulting mask could be wrong if in the signal
- * handler the thread calls sigprocmask for any signal other than the
- * signal the handler is dealing with.
- */
-int pthread_sigmask(int how, const sigset_t *set, sigset_t * oset)
-{
- int i;
-
- if (oset) {
- sigemptyset(oset);
- for (i = 1; i < SIGMAX; i++) {
- if (sigismember(&(pthread_run->sigmask), i)) {
- sigaddset(oset, i);
- }
- }
- }
-
- if (set) {
- switch(how) {
- case SIG_BLOCK:
- for (i = 1; i < SIGMAX; i++) {
- if (sigismember(set, i)) {
- sigaddset(&(pthread_run->sigmask), i);
- }
- }
- break;
- case SIG_UNBLOCK:
- pthread_sched_prevent();
- for (i = 1; i < SIGMAX; i++) {
- if (sigismember(set, i)) {
- sigdelset(&(pthread_run->sigmask), i);
- if (sigismember(&pending_signals, i)) {
- sigaddset(&(pthread_run->sigpending), i);
- sigdelset(&pending_signals, i);
- pthread_run->sigcount++;
- }
- }
- }
- pthread_sched_resume();
- break;
- case SIG_SETMASK:
- sigfillset(&(pthread_run->sigmask));
- pthread_sched_prevent();
- for (i = 1; i < SIGMAX; i++) {
- if (! sigismember(set, i)) {
- sigdelset(&(pthread_run->sigmask), i);
- if (sigismember(&pending_signals, i)) {
- sigaddset(&(pthread_run->sigpending), i);
- sigdelset(&pending_signals, i);
- pthread_run->sigcount++;
- }
- }
- }
- pthread_sched_resume();
- break;
- default:
- SET_ERRNO(EINVAL);
- return(NOTOK);
- }
- }
- return(OK);
-}
-
-int sigprocmask(int how, const sigset_t *set, sigset_t * oset)
-{
- return(pthread_sigmask(how, set, oset));
-}
-
-/* ==========================================================================
- * sigwait()
- */
-int sigwait(const sigset_t * set, int * sig)
-{
- int i;
-
- /* Check that sig is valid */
- *sig = 0;
-
- pthread_sched_prevent();
- for (i = 1; i < SIGMAX; i++) {
- if (sigismember(set, i)) {
- /* Check personal signals */
- if (sigismember(&(pthread_run->sigpending), i)) {
- sigdelset(&(pthread_run->sigpending), i);
- pthread_sched_resume();
- *sig = i;
- return(OK);
- }
- /* Check kernel signals */
- if (sigismember(&pending_signals, i)) {
- sigdelset(&pending_signals, i);
- pthread_sched_resume();
- *sig = i;
- return(OK);
- }
- }
- }
-
- /* No pending signals, wait for one */
- pthread_run->next = pthread_sigwait;
- pthread_sigwait = pthread_run;
- pthread_run->data.sigwait = set;
- pthread_run->ret = sig;
-
- SET_PF_AT_CANCEL_POINT(pthread_run); /* This is a cancel point */
- pthread_resched_resume(PS_SIGWAIT);
- CLEAR_PF_AT_CANCEL_POINT(pthread_run); /* No longer at cancel point */
-
- return(OK);
-}
-
-/* ==========================================================================
- * raise()
- */
-int raise(int sig)
-{
- return(pthread_kill(pthread_self(), sig));
-}
-
-/* ==========================================================================
- * sigsuspend()
- */
-int sigsuspend(const sigset_t * mask)
-{
- int ret_sig, ret;
- sigset_t nm, om;
-
- sigfillset(&nm);
- for(ret_sig = 1; ret_sig < SIGMAX; ret_sig++) {
- if (sigismember(mask, ret_sig)) {
- sigdelset(&nm, ret_sig);
- }
- }
- pthread_sigmask(SIG_BLOCK, &nm, &om);
- if ((ret = sigwait(&nm, &ret_sig)) == OK) {
- sigemptyset(&nm);
- sigaddset(&nm, ret_sig);
- pthread_kill(pthread_self(), ret_sig);
- pthread_sigmask(SIG_UNBLOCK, &nm, NULL);
- /* There is a race condition here, it's not worth worring about */
- pthread_sigmask(SIG_BLOCK, &nm, NULL);
- SET_ERRNO(EINTR);
- ret = NOTOK;
- }
- pthread_sigmask(SIG_SETMASK, &om, NULL);
- return(ret);
-}
-
-/* ==========================================================================
- * pthread_signal()
- */
-void (*pthread_signal(int sig, void (*dispatch)(int)))()
-{
- void (*odispatch)(int);
-
- odispatch = pthread_sigvec[sig].vector;
- if ((sig > 0) && (sig < SIGMAX)) {
- pthread_sigvec[sig].vector = dispatch;
- sigemptyset(&(pthread_sigvec[sig].mask));
- pthread_sigvec[sig].flags = 0;
- }
- return(odispatch);
-}
-
-/* ==========================================================================
- * pthread_sigprocmask()
- */
-int pthread_sigaction(int sig, const struct sigaction * act,
- struct sigaction * oact)
-{
- if ((sig > 0) && (sig < SIGMAX)) {
- if (oact) {
- memcpy(&(oact->sa_mask), &(pthread_sigvec[sig].mask),
- sizeof(sigset_t));
- oact->sa_handler = pthread_sigvec[sig].vector;
- oact->sa_flags = pthread_sigvec[sig].flags;
- }
- if (act) {
- memcpy(&(pthread_sigvec[sig].mask), &(act->sa_mask),
- sizeof(sigset_t));
- pthread_sigvec[sig].vector = act->sa_handler;
- pthread_sigvec[sig].flags = act->sa_flags;
- }
- return(OK);
- }
- SET_ERRNO(EINVAL);
- return(NOTOK);
-}
-
-/*
- * The following here are stolen from BSD because I get mutiply defined
- * symbols between sig.o and posix_sig.o in Sun's libc.a under Sunos 4.1.3.
- * The problem is that sigprocmask() is defined in posix_sig.o, in the same
- * module that a lot of other sigset-primitives are defined, and we have
- * our definition of sigprocmask() here, but use those other primitives.
- */
-
-#undef sigemptyset
-#undef sigfillset
-#undef sigaddset
-#undef sigdelset
-#undef sigismember
-
-static const sigset_t __sigemptyset = __SIGEMPTYSET;
-int sigemptyset(sigset_t *set)
-{
- *set = __sigemptyset;
- return (0);
-}
-
-static const sigset_t __sigfillset = __SIGFILLSET;
-int sigfillset(sigset_t * set)
-{
- *set = __sigfillset;
- return (0);
-}
-
-#define _MAXIMUM_SIG NSIG
-
-int sigaddset(sigset_t *set, int signo)
-{
- if (signo <= 0 || signo >= _MAXIMUM_SIG) {
- errno = EINVAL;
- return -1;
- }
- __SIGADDSET(set, signo);
- return (0);
-}
-
-int sigdelset(sigset_t *set, int signo)
-{
- if (signo <= 0 || signo >= _MAXIMUM_SIG) {
- errno = EINVAL;
- return -1;
- }
- __SIGDELSET(set, signo);
- return (0);
-}
-
-int sigismember(const sigset_t *set, int signo)
-{
- if (signo <= 0 || signo >= _MAXIMUM_SIG) {
- errno = EINVAL;
- return -1;
- }
- return(__SIGISMEMBER(set, signo));
-}
-
diff --git a/lib/libpthread/pthreads/signal.c b/lib/libpthread/pthreads/signal.c
deleted file mode 100644
index df0cf153145..00000000000
--- a/lib/libpthread/pthreads/signal.c
+++ /dev/null
@@ -1,642 +0,0 @@
-/* ==== signal.c ============================================================
- * Copyright (c) 1993, 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 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.
- *
- * Description : Queue functions.
- *
- * 1.00 93/07/21 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: signal.c,v 1.3 1998/07/22 10:46:54 peter Exp $";
-#endif
-
-#include <pthread.h>
-#include <signal.h>
-
-/* This will force init.o to get dragged in; if you've got support for
- C++ initialization, that'll cause pthread_init to be called at
- program startup automatically, so the application won't need to
- call it explicitly. */
-
-extern char __pthread_init_hack;
-char *__pthread_init_hack_2 = &__pthread_init_hack;
-
-/*
- * Time which select in fd_kern_wait() will sleep.
- * If there are no threads to run we sleep for an hour or until
- * we get an interrupt or an fd thats awakens. To make sure we
- * don't miss an interrupt this variable gets reset too zero in
- * sig_handler_real().
- */
-struct timeval __fd_kern_wait_timeout = { 0, 0 };
-
-/*
- * Global for user-kernel lock, and blocked signals
- */
-
-static sig_atomic_t signum_to_process[SIGMAX + 1] = { 0, };
-volatile sig_atomic_t sig_to_process = 0;
-
-/* static volatile sigset_t sig_to_process; */
-static volatile int sig_count = 0;
-
-static void sig_handler(int signal);
-static void set_thread_timer();
-static void __cleanup_after_resume( void );
-void sig_prevent(void);
-void sig_resume(void);
-
-/* ==========================================================================
- * context_switch()
- *
- * This routine saves the current state of the running thread gets
- * the next thread to run and restores it's state. To allow different
- * processors to work with this routine, I allow the machdep_restore_state()
- * to either return or have it return from machdep_save_state with a value
- * other than 0, this is for implementations which use setjmp/longjmp.
- */
-static void context_switch()
-{
- struct pthread **current, *next, *last, **dead;
-
- if (pthread_run->state == PS_RUNNING) {
- /* Put current thread back on the queue */
- pthread_prio_queue_enq(pthread_current_prio_queue, pthread_run);
- }
-
- /* save floating point registers if necessary */
- if (!(pthread_run->attr.flags & PTHREAD_NOFLOAT)) {
- machdep_save_float_state(pthread_run);
- }
- /* save state of current thread */
- if (machdep_save_state()) {
- return;
- }
-
- last = pthread_run;
-
- /* Poll all fds */
- fd_kern_poll();
-
-context_switch_reschedule:;
- /* Are there any threads to run */
- if (pthread_run = pthread_prio_queue_deq(pthread_current_prio_queue)) {
- /* restore floating point registers if necessary */
- if (!(pthread_run->attr.flags & PTHREAD_NOFLOAT)) {
- machdep_restore_float_state();
- }
- uthread_sigmask = &(pthread_run->sigmask);
- /* restore state of new current thread */
- machdep_restore_state();
- return;
- }
-
- /* Are there any threads at all */
- for (next = pthread_link_list; next; next = next->pll) {
- if ((next->state != PS_UNALLOCED) && (next->state != PS_DEAD)) {
- sigset_t sig_to_block, oset;
-
- sigfillset(&sig_to_block);
-
- /*
- * Check sig_to_process before calling fd_kern_wait, to handle
- * things like zero timeouts to select() which would register
- * a signal with the sig_handler_fake() call.
- *
- * This case should ignore SIGVTALRM
- */
- machdep_sys_sigprocmask(SIG_BLOCK, &sig_to_block, &oset);
- signum_to_process[SIGVTALRM] = 0;
- if (sig_to_process) {
- /* Process interrupts */
- /*
- * XXX pthread_run should not be set!
- * Places where it dumps core should be fixed to
- * check for the existance of pthread_run --proven
- */
- sig_handler(0);
- } else {
- machdep_sys_sigprocmask(SIG_UNBLOCK, &sig_to_block, &oset);
- /*
- * Do a wait, timeout is set to a hour unless we get an
- * intr. before the select in wich case it polls.
- */
- fd_kern_wait();
- machdep_sys_sigprocmask(SIG_BLOCK, &sig_to_block, &oset);
- /* Check for interrupts, but ignore SIGVTALR */
- signum_to_process[SIGVTALRM] = 0;
- if (sig_to_process) {
- /* Process interrupts */
- sig_handler(0);
- }
- }
- machdep_sys_sigprocmask(SIG_UNBLOCK, &sig_to_block, &oset);
- goto context_switch_reschedule;
- }
- }
-
- /* There are no threads alive. */
- pthread_run = last;
- exit(0);
-}
-
-#if !defined(HAVE_SYSCALL_SIGSUSPEND) && defined(HAVE_SYSCALL_SIGPAUSE)
-
-/* ==========================================================================
- * machdep_sys_sigsuspend()
- */
-int machdep_sys_sigsuspend(sigset_t * set)
-{
- return(machdep_sys_sigpause(* set));
-}
-
-#endif
-
-/* ==========================================================================
- * sig_handler_pause()
- *
- * Wait until a signal is sent to the process.
- */
-void sig_handler_pause()
-{
- sigset_t sig_to_block, sig_to_pause, oset;
-
- sigfillset(&sig_to_block);
- sigemptyset(&sig_to_pause);
- machdep_sys_sigprocmask(SIG_BLOCK, &sig_to_block, &oset);
-/* if (!(SIG_ANY(sig_to_process))) { */
- if (!sig_to_process) {
- machdep_sys_sigsuspend(&sig_to_pause);
- }
- machdep_sys_sigprocmask(SIG_UNBLOCK, &sig_to_block, &oset);
-}
-
-/* ==========================================================================
- * context_switch_done()
- *
- * This routine does all the things that are necessary after a context_switch()
- * calls the machdep_restore_state(). DO NOT put this in the context_switch()
- * routine because sometimes the machdep_restore_state() doesn't return
- * to context_switch() but instead ends up in machdep_thread_start() or
- * some such routine, which will need to call this routine and
- * sig_check_and_resume().
- */
-void context_switch_done()
-{
- /* sigdelset((sigset_t *)&sig_to_process, SIGVTALRM); */
- signum_to_process[SIGVTALRM] = 0;
- set_thread_timer();
-}
-
-/* ==========================================================================
- * set_thread_timer()
- *
- * Assums kernel is locked.
- */
-static void set_thread_timer()
-{
- static int last_sched_attr = SCHED_RR;
-
- switch (pthread_run->attr.schedparam_policy) {
- case SCHED_RR:
- machdep_set_thread_timer(&(pthread_run->machdep_data));
- break;
- case SCHED_FIFO:
- if (last_sched_attr != SCHED_FIFO) {
- machdep_unset_thread_timer(NULL);
- }
- break;
- case SCHED_IO:
- if ((last_sched_attr != SCHED_IO) && (!sig_count)) {
- machdep_set_thread_timer(&(pthread_run->machdep_data));
- }
- break;
- default:
- machdep_set_thread_timer(&(pthread_run->machdep_data));
- break;
- }
- last_sched_attr = pthread_run->attr.schedparam_policy;
-}
-
-/* ==========================================================================
- * sigvtalrm()
- */
-static inline void sigvtalrm()
-{
- if (sig_count) {
- sigset_t sigall, oset;
-
- sig_count = 0;
-
- /* Unblock all signals */
- sigemptyset(&sigall);
- machdep_sys_sigprocmask(SIG_SETMASK, &sigall, &oset);
- }
- context_switch();
- context_switch_done();
-}
-
-/* ==========================================================================
- * sigdefault()
- */
-static inline void sigdefault(int sig)
-{
- int ret;
-
- ret = pthread_sig_register(sig);
- if (pthread_run && (ret > pthread_run->pthread_priority)) {
- sigvtalrm();
- }
-}
-
-/* ==========================================================================
- * sig_handler_switch()
- */
-static inline void sig_handler_switch(int sig)
-{
- int ret;
-
- switch(sig) {
- case 0:
- break;
- case SIGVTALRM:
- sigvtalrm();
- break;
- case SIGALRM:
-/* sigdelset((sigset_t *)&sig_to_process, SIGALRM); */
- signum_to_process[SIGALRM] = 0;
- switch (ret = sleep_wakeup()) {
- default:
- if (pthread_run && (ret > pthread_run->pthread_priority)) {
- sigvtalrm();
- }
- case 0:
- break;
- case NOTOK:
- /* Do the registered action, no threads were sleeping */
- /* There is a timing window that gets
- * here when no threads are on the
- * sleep queue. This is a quick fix.
- * The real problem is possibly related
- * to heavy use of condition variables
- * with time outs.
- * (mevans)
- *sigdefault(sig);
- */
- break;
- }
- break;
- case SIGCHLD:
-/* sigdelset((sigset_t *)&sig_to_process, SIGCHLD); */
- signum_to_process[SIGCHLD] = 0;
- switch (ret = wait_wakeup()) {
- default:
- if (pthread_run && (ret > pthread_run->pthread_priority)) {
- sigvtalrm();
- }
- case 0:
- break;
- case NOTOK:
- /* Do the registered action, no threads were waiting */
- sigdefault(sig);
- break;
- }
- break;
-
-#ifdef SIGINFO
- case SIGINFO:
- pthread_dump_info ();
- /* Then fall through, invoking the application's
- signal handler after printing our info out.
-
- I'm not convinced that this is right, but I'm not
- 100% convinced that it is wrong, and this is how
- Chris wants it done... */
-#endif
-
- default:
- /* Do the registered action */
- if (!sigismember(uthread_sigmask, sig)) {
- /*
- * If the signal isn't masked by the last running thread and
- * the signal behavior is default or ignore then we can
- * execute it immediatly. --proven
- */
- pthread_sig_default(sig);
- }
- signum_to_process[sig] = 0;
- sigdefault(sig);
- break;
- }
-
-}
-
-/* ==========================================================================
- * sig_handler()
- *
- * Process signal that just came in, plus any pending on the signal mask.
- * All of these must be resolved.
- *
- * Assumes the kernel is locked.
- */
-static void sig_handler(int sig)
-{
- if (pthread_kernel_lock != 1) {
- PANIC();
- }
-
- if (sig) {
- sig_handler_switch(sig);
- }
-
- while (sig_to_process) {
- for (sig_to_process = 0, sig = 1; sig <= SIGMAX; sig++) {
- if (signum_to_process[sig]) {
- sig_handler_switch(sig);
- }
- }
- }
-
-
-/*
- if (SIG_ANY(sig_to_process)) {
- for (sig = 1; sig <= SIGMAX; sig++) {
- if (sigismember((sigset_t *)&sig_to_process, sig)) {
- goto sig_handler_top;
- }
- }
- }
-*/
-}
-
-/* ==========================================================================
- * sig_handler_real()
- *
- * On a multi-processor this would need to use the test and set instruction
- * otherwise the following will work.
- */
-void sig_handler_real(int sig)
-{
- /*
- * Get around systems with BROKEN signal handlers.
- *
- * Some systems will reissue SIGCHLD if the handler explicitly
- * clear the signal pending by either doing a wait() or
- * ignoring the signal.
- */
-#if defined BROKEN_SIGNALS
- if (sig == SIGCHLD) {
- sigignore(SIGCHLD);
- signal(SIGCHLD, sig_handler_real);
- }
-#endif
-
- if (pthread_kernel_lock) {
- /* sigaddset((sigset_t *)&sig_to_process, sig); */
- __fd_kern_wait_timeout.tv_sec = 0;
- signum_to_process[sig] = 1;
- sig_to_process = 1;
- return;
- }
- pthread_kernel_lock++;
-
- sig_count++;
- sig_handler(sig);
-
- /* Handle any signals the current thread might have just gotten */
- if (pthread_run && pthread_run->sigcount) {
- pthread_sig_process();
- }
- pthread_kernel_lock--;
-}
-
-/* ==========================================================================
- * sig_handler_fake()
- */
-void sig_handler_fake(int sig)
-{
- if (pthread_kernel_lock) {
- /* sigaddset((sigset_t *)&sig_to_process, sig); */
- signum_to_process[sig] = 1;
- sig_to_process = 1;
- return;
- }
- pthread_kernel_lock++;
- sig_handler(sig);
- while (!(--pthread_kernel_lock)) {
- if (sig_to_process) {
- /* if (SIG_ANY(sig_to_process)) { */
- pthread_kernel_lock++;
- sig_handler(0);
- } else {
- break;
- }
- }
-}
-
-/* ==========================================================================
- * __pthread_signal_delete(int sig)
- *
- * Assumes the kernel is locked.
- */
-void __pthread_signal_delete(int sig)
-{
- signum_to_process[sig] = 0;
-}
-
-/* ==========================================================================
- * pthread_sched_other_resume()
- *
- * Check if thread to be resumed is of higher priority and if so
- * stop current thread and start new thread.
- */
-pthread_sched_other_resume(struct pthread * pthread)
-{
- pthread->state = PS_RUNNING;
- pthread_prio_queue_enq(pthread_current_prio_queue, pthread);
-
- if (pthread->pthread_priority > pthread_run->pthread_priority) {
- if (pthread_kernel_lock == 1) {
- sig_handler(SIGVTALRM);
- }
- }
-
- __cleanup_after_resume();
-}
-
-/* ==========================================================================
- * pthread_resched_resume()
- *
- * This routine assumes that the caller is the current pthread, pthread_run
- * and that it has a lock the kernel thread and it wants to reschedule itself.
- */
-void pthread_resched_resume(enum pthread_state state)
-{
- pthread_run->state = state;
-
- /* Since we are about to block this thread, lets see if we are
- * at a cancel point and if we've been cancelled.
- * Avoid cancelling dead or unalloced threads.
- */
- if( ! TEST_PF_RUNNING_TO_CANCEL(pthread_run) &&
- TEST_PTHREAD_IS_CANCELLABLE(pthread_run) &&
- state != PS_DEAD && state != PS_UNALLOCED ) {
-
- /* Set this flag to avoid recursively calling pthread_exit */
- /* We have to set this flag here because we will unlock the
- * kernel prior to calling pthread_cancel_internal.
- */
- SET_PF_RUNNING_TO_CANCEL(pthread_run);
-
- pthread_run->old_state = state; /* unlock needs this data */
- pthread_sched_resume(); /* Unlock kernel before cancel */
- pthread_cancel_internal( 1 ); /* free locks and exit */
- }
-
- sig_handler(SIGVTALRM);
-
- __cleanup_after_resume();
-}
-
-/* ==========================================================================
- * pthread_sched_resume()
- */
-void pthread_sched_resume()
-{
- __cleanup_after_resume();
-}
-
-/*----------------------------------------------------------------------
- * Function: __cleanup_after_resume
- * Purpose: cleanup kernel locks after a resume
- * Args: void
- * Returns: void
- * Notes:
- *----------------------------------------------------------------------*/
-static void
-__cleanup_after_resume( void )
-{
- /* Only bother if we are truely unlocking the kernel */
- while (!(--pthread_kernel_lock)) {
- /* if (SIG_ANY(sig_to_process)) { */
- if (sig_to_process) {
- pthread_kernel_lock++;
- sig_handler(0);
- continue;
- }
- if (pthread_run && pthread_run->sigcount) {
- pthread_kernel_lock++;
- pthread_sig_process();
- continue;
- }
- break;
- }
-
- if( pthread_run == NULL )
- return; /* Must be during init processing */
-
- /* Test for cancel that should be handled now */
-
- if( ! TEST_PF_RUNNING_TO_CANCEL(pthread_run) &&
- TEST_PTHREAD_IS_CANCELLABLE(pthread_run) ) {
- /* Kernel is already unlocked */
- pthread_cancel_internal( 1 ); /* free locks and exit */
- }
-}
-
-/* ==========================================================================
- * pthread_sched_prevent()
- */
-void pthread_sched_prevent(void)
-{
- pthread_kernel_lock++;
-}
-
-/* ==========================================================================
- * sig_init()
- *
- * SIGVTALRM (NOT POSIX) needed for thread timeslice timeouts.
- * Since it's not POSIX I will replace it with a
- * virtual timer for threads.
- * SIGALRM (IS POSIX) so some special handling will be
- * necessary to fake SIGALRM signals
- */
-#ifndef SIGINFO
-#define SIGINFO 0
-#endif
-void sig_init(void)
-{
- static const int signum_to_initialize[] =
- { SIGCHLD, SIGALRM, SIGVTALRM, SIGINFO, 0 };
- static const int signum_to_ignore[] = { SIGKILL, SIGSTOP, 0 };
- int i, j;
-
- struct sigaction act;
-
- act.sa_handler = sig_handler_real;
- sigemptyset(&(act.sa_mask));
- act.sa_flags = 0;
-
- /* Initialize the important signals */
- for (i = 0; signum_to_initialize[i]; i++) {
-
- if (sigaction(signum_to_initialize[i], &act, NULL)) {
- PANIC();
- }
- }
-
- /* Initialize the rest of the signals */
- for (j = 1; j < SIGMAX; j++) {
- for (i = 0; signum_to_initialize[i]; i++) {
- if (signum_to_initialize[i] == j) {
- goto sig_next;
- }
- }
- /* Because Solaris 2.4 can't deal -- proven */
- for (i = 0; signum_to_ignore[i]; i++) {
- if (signum_to_ignore[i] == j) {
- goto sig_next;
- }
- }
- pthread_signal(j, SIG_DFL);
-
- sigaction(j, &act, NULL);
-
- sig_next:;
- }
-
-#if defined BROKEN_SIGNALS
- signal(SIGCHLD, sig_handler_real);
-#endif
-
-}
-
diff --git a/lib/libpthread/pthreads/sleep.c b/lib/libpthread/pthreads/sleep.c
deleted file mode 100644
index 1b76f26391f..00000000000
--- a/lib/libpthread/pthreads/sleep.c
+++ /dev/null
@@ -1,256 +0,0 @@
-/* ==== sleep.c ============================================================
- * Copyright (c) 1993, 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 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.
- *
- * Description : Condition cariable functions.
- *
- * 1.00 93/12/28 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: sleep.c,v 1.1 1995/10/18 08:43:05 deraadt Exp $ $provenid: sleep.c,v 1.18 1994/02/07 02:19:31 proven Exp $";
-#endif
-
-#include <pthread.h>
-#include <unistd.h>
-
-struct pthread * pthread_sleep = NULL;
-semaphore sleep_semaphore = SEMAPHORE_CLEAR;
-
-
-#include <sys/time.h>
-#include <stdio.h>
-
-/* ==========================================================================
- * machdep_start_timer()
- */
-int machdep_start_timer(struct itimerval *start_time_val)
-{
- setitimer(ITIMER_REAL, start_time_val, NULL);
- return(OK);
-}
-
-/* ==========================================================================
- * machdep_stop_timer()
- */
-struct itimerval stop_time_val = { { 0, 0 }, { 0, 0 } };
-int machdep_stop_timer(struct itimerval * current)
-{
- setitimer(ITIMER_REAL, &stop_time_val, current);
- return(OK);
-}
-
-/* ==========================================================================
- * machdep_sub_timer()
- *
- * formula is: new -= current;
- */
-static inline void machdep_sub_timer(struct itimerval * new,
- struct itimerval * current)
-{
- new->it_value.tv_usec -= current->it_value.tv_usec;
- if (new->it_value.tv_usec < 0) {
- new->it_value.tv_usec += 1000000;
- new->it_value.tv_sec--;
- }
- new->it_value.tv_sec -= current->it_value.tv_sec;
-}
-
-
-/* ==========================================================================
- * sleep_basic_wakeup()
- *
- * The real work of sleep_wakeup is done here.
- */
-static inline int sleep_basic_wakeup()
-{
- struct pthread *pthread_sleep_next;
- struct itimerval current_time;
- semaphore *plock;
-
- machdep_stop_timer(&current_time);
- do {
- plock = &(pthread_sleep->lock);
- if (SEMAPHORE_TEST_AND_SET(plock)) {
- return(NOTOK);
- }
-
- /* return remaining time */
- pthread_sleep->time_sec = current_time.it_value.tv_sec;
- pthread_sleep->time_usec = current_time.it_value.tv_usec;
-
- if (pthread_sleep_next = pthread_sleep->sll) {
- pthread_sleep_next->time_usec += current_time.it_value.tv_usec;
- current_time.it_value.tv_usec = pthread_sleep_next->time_usec;
- pthread_sleep_next->time_sec += current_time.it_value.tv_sec;
- current_time.it_value.tv_sec = pthread_sleep_next->time_sec;
- }
-
- /* Clean up removed thread and start it runnng again. */
- pthread_sleep->state = PS_RUNNING;
- pthread_sleep->sll = NULL;
- SEMAPHORE_RESET(plock);
-
- /* Set top of queue to next queue item */
- pthread_sleep = pthread_sleep_next;
-
- if (current_time.it_value.tv_sec || current_time.it_value.tv_usec) {
- machdep_start_timer(&current_time);
- break;
- }
-
- } while(pthread_sleep);
- return(OK);
-}
-
-/* ==========================================================================
- * sleep_wakeup()
- *
- * This routine is called by the interrupt handler. It cannot call
- * pthread_yield() thenrfore it returns NOTOK to inform the handler
- * that it will have to be called at a later time.
- */
-int sleep_wakeup()
-{
- semaphore *lock, *plock;
- int ret;
-
- /* Lock sleep queue */
- lock = &(sleep_semaphore);
- if (SEMAPHORE_TEST_AND_SET(lock)) {
- return(NOTOK);
- }
-
- if (pthread_sleep) {
- ret = sleep_basic_wakeup();
- } else {
- ret = NOTOK;
- }
-
- SEMAPHORE_RESET(lock);
- return(ret);
-}
-
-/* ==========================================================================
- * sleep()
- */
-unsigned int sleep(unsigned int seconds)
-{
- struct pthread *pthread_sleep_current, *pthread_sleep_prev;
- struct itimerval current_time, new_time;
- semaphore *lock, *plock;
-
- if (seconds) {
- /* Lock current thread */
- plock = &(pthread_run->lock);
- while (SEMAPHORE_TEST_AND_SET(plock)) {
- pthread_yield();
- }
-
- /* Set new_time timer value */
- new_time.it_value.tv_usec = 0;
- new_time.it_value.tv_sec = seconds;
- new_time.it_interval.tv_usec = 0;
- new_time.it_interval.tv_sec = 0;
-
- /* Lock sleep queue */
- lock = &(sleep_semaphore);
- while (SEMAPHORE_TEST_AND_SET(lock)) {
- pthread_yield();
- }
-
- /* any threads? */
- if (pthread_sleep_current = pthread_sleep) {
-
- machdep_stop_timer(&current_time);
-
- /* Is remaining time left <= new thread time */
- if (current_time.it_value.tv_sec <= new_time.it_value.tv_sec) {
- machdep_sub_timer(&new_time, &current_time);
- machdep_start_timer(&current_time);
-
- while (pthread_sleep_current->sll) {
- pthread_sleep_prev = pthread_sleep_current;
- pthread_sleep_current = pthread_sleep_current->sll;
- current_time.it_value.tv_sec = pthread_sleep_current->time_sec;
-
- if ((current_time.it_value.tv_sec > new_time.it_value.tv_sec) ||
- ((current_time.it_value.tv_sec == new_time.it_value.tv_sec) &&
- (current_time.it_value.tv_usec > new_time.it_value.tv_usec))) {
- pthread_run->time_usec = new_time.it_value.tv_usec;
- pthread_run->time_sec = new_time.it_value.tv_sec;
- machdep_sub_timer(&current_time, &new_time);
- pthread_run->sll = pthread_sleep_current;
- pthread_sleep_prev->sll = pthread_run;
-
- /* Unlock sleep mutex */
- SEMAPHORE_RESET(lock);
-
- /* Reschedule thread */
- reschedule(PS_SLEEP_WAIT);
-
- return(pthread_run->time_sec);
- }
- machdep_sub_timer(&new_time, &current_time);
-
- }
-
- /* No more threads in queue, attach pthread_run to end of list */
- pthread_sleep_current->sll = pthread_run;
- pthread_run->sll = NULL;
-
- } else {
- /* Start timer and enqueue thread */
- machdep_start_timer(&new_time);
- machdep_sub_timer(&current_time, &new_time);
- pthread_run->sll = pthread_sleep_current;
- pthread_sleep = pthread_run;
- }
- } else {
- /* Start timer and enqueue thread */
- machdep_start_timer(&new_time);
- pthread_sleep = pthread_run;
- pthread_run->sll = NULL;
- }
-
- pthread_run->time_usec = new_time.it_value.tv_usec;
- pthread_run->time_sec = new_time.it_value.tv_sec;
-
- /* Unlock sleep mutex */
- SEMAPHORE_RESET(lock);
-
- /* Reschedule thread */
- reschedule(PS_SLEEP_WAIT);
-
- }
- return(pthread_run->time_sec);
-}
-
diff --git a/lib/libpthread/pthreads/specific.c b/lib/libpthread/pthreads/specific.c
deleted file mode 100644
index 95725bed59b..00000000000
--- a/lib/libpthread/pthreads/specific.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/* ==== specific.c =======================================================
- * 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 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.
- *
- * Description : Pthread thread specific data management.
- *
- * 1.20 94/03/30 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: specific.c,v 1.1 1998/07/21 13:20:26 peter Exp $";
-#endif
-
-#include <errno.h>
-#include <pthread.h>
-#include <stdlib.h>
-
-static struct pthread_key key_table[PTHREAD_DATAKEYS_MAX];
-static pthread_mutex_t key_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-/* ==========================================================================
- * pthread_key_create()
- */
-int pthread_key_create(pthread_key_t *key, void (*destructor)(void *))
-{
- pthread_mutex_lock(&key_mutex);
- for ((*key) = 0; (*key) < PTHREAD_DATAKEYS_MAX; (*key)++) {
- if (key_table[(*key)].count == 0) {
- key_table[(*key)].count++;
- key_table[(*key)].destructor = destructor;
- pthread_mutex_init(&(key_table[(*key)].mutex), NULL);
- pthread_mutex_unlock(&key_mutex);
- return(OK);
- }
- }
- pthread_mutex_unlock(&key_mutex);
- return(EAGAIN);
-}
-
-/* ==========================================================================
- * pthread_key_delete()
- */
-int pthread_key_delete(pthread_key_t key)
-{
- int ret;
-
- if (key < PTHREAD_DATAKEYS_MAX) {
- pthread_mutex_lock(&(key_table[key].mutex));
- switch (key_table[key].count) {
- case 1:
- pthread_mutex_destroy(&(key_table[key].mutex));
- key_table[key].destructor = NULL;
- key_table[key].count = 0;
- case 0:
- ret = OK;
- break;
- default:
- ret = EBUSY;
- }
- pthread_mutex_unlock(&(key_table[key].mutex));
- } else {
- ret = EINVAL;
- }
- return(ret);
-}
-
-/* ==========================================================================
- * pthread_cleanupspecific()
- */
-void pthread_cleanupspecific(void)
-{
- void * data;
- int key;
- int itr;
-
- pthread_mutex_lock(&key_mutex);
- for (itr = 0; itr < _POSIX_THREAD_DESTRUTOR_ITERATIONS; itr++) {
- for (key = 0; key < PTHREAD_DATAKEYS_MAX; key++) {
- if (pthread_run->specific_data_count) {
- if (pthread_run->specific_data[key]) {
- data = (void *)pthread_run->specific_data[key];
- pthread_run->specific_data[key] = NULL;
- pthread_run->specific_data_count--;
- if (key_table[key].destructor) {
- pthread_mutex_unlock(&key_mutex);
- key_table[key].destructor(data);
- pthread_mutex_lock(&key_mutex);
- }
- key_table[key].count--;
- }
- } else {
- free(pthread_run->specific_data);
- pthread_mutex_unlock(&key_mutex);
- return;
- }
- }
- }
- free(pthread_run->specific_data);
- pthread_mutex_unlock(&key_mutex);
-}
-
-static inline const void ** pthread_key_allocate_data(void)
-{
- const void ** new_data;
- if(new_data = (const void**)malloc(sizeof(void *) * PTHREAD_DATAKEYS_MAX)) {
- memset((void *)new_data, 0, sizeof(void *) * PTHREAD_DATAKEYS_MAX);
- }
- return(new_data);
-}
-
-/* ==========================================================================
- * pthread_setspecific()
- */
-int pthread_setspecific(pthread_key_t key, const void * value)
-{
- int ret;
-
- if ((pthread_run->specific_data) ||
- (pthread_run->specific_data = pthread_key_allocate_data())) {
- if ((key < PTHREAD_DATAKEYS_MAX) && (key_table)) {
- pthread_mutex_lock(&(key_table[key].mutex));
- if (key_table[key].count) {
- if (pthread_run->specific_data[key] == NULL) {
- if (value != NULL) {
- pthread_run->specific_data_count++;
- key_table[key].count++;
- }
- } else {
- if (value == NULL) {
- pthread_run->specific_data_count--;
- key_table[key].count--;
- }
- }
- pthread_run->specific_data[key] = value;
- ret = OK;
- } else {
- ret = EINVAL;
- }
- pthread_mutex_unlock(&(key_table[key].mutex));
- } else {
- ret = EINVAL;
- }
- } else {
- ret = ENOMEM;
- }
- return(ret);
-}
-
-/* ==========================================================================
- * pthread_getspecific()
- */
-void * pthread_getspecific(pthread_key_t key)
-{
- void *ret;
-
- if ((pthread_run->specific_data) && (key < PTHREAD_DATAKEYS_MAX)
- && (key_table)) {
- pthread_mutex_lock(&(key_table[key].mutex));
- if (key_table[key].count) {
- ret = (void *)pthread_run->specific_data[key];
- } else {
- ret = NULL;
- }
- pthread_mutex_unlock(&(key_table[key].mutex));
- } else {
- ret = NULL;
- }
- return(ret);
-}
diff --git a/lib/libpthread/pthreads/stat.c b/lib/libpthread/pthreads/stat.c
deleted file mode 100644
index 3d5872187bf..00000000000
--- a/lib/libpthread/pthreads/stat.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/* ==== stat.c ============================================================
- * Copyright (c) 1995 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 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.
- *
- * Description : All the syscalls dealing with fds.
- *
- * 1.00 93/05/27 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: stat.c,v 1.2 1998/07/22 10:46:55 peter Exp $";
-#endif
-
-#include <pthread.h>
-#include <errno.h>
-
-struct stat;
-struct statfs;
-
-/* ==========================================================================
- * fstat()
- *
- * Might want to indirect this.
- */
-int fstat(int fd, struct stat *buf)
-{
- int ret;
-
- if ((ret = fd_lock(fd, FD_READ, NULL)) == OK) {
- if ((ret = machdep_sys_fstat(fd_table[fd]->fd.i, buf)) < OK) {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
- fd_unlock(fd, FD_READ);
- }
- return(ret);
-}
-
-/* ==========================================================================
- * stat()
- */
-int stat(const char * path, struct stat * buf)
-{
- int ret;
-
- if ((ret = machdep_sys_stat(path, buf)) < OK) {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
- return(ret);
-
-}
-
-/* ==========================================================================
- * lstat()
- */
-int lstat(const char * path, struct stat * buf)
-{
- int ret;
-
- if ((ret = machdep_sys_lstat(path, buf)) < OK) {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
- return(ret);
-
-}
-
-/* ==========================================================================
- * fstatfs()
- *
- * Might want to indirect this.
- */
-int fstatfs(int fd, struct statfs *buf)
-{
- int ret;
-
- if ((ret = fd_lock(fd, FD_READ, NULL)) == OK) {
- if ((ret = machdep_sys_fstatfs(fd_table[fd]->fd.i, buf)) < OK) {
- SET_ERRNO(-ret);
- ret = NOTOK;
- }
- fd_unlock(fd, FD_READ);
- }
- return(ret);
-}
diff --git a/lib/libpthread/pthreads/wait.c b/lib/libpthread/pthreads/wait.c
deleted file mode 100644
index 7ff26b55847..00000000000
--- a/lib/libpthread/pthreads/wait.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/* ==== wait.c ============================================================
- * 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 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.
- *
- * Description : All the appropriate wait routines.
- *
- * 1.38 94/06/13 proven
- * -Started coding this file.
- *
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: wait.c,v 1.1 1998/07/21 13:20:26 peter Exp $";
-#endif
-
-#include <pthread.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <pthread/posix.h>
-#include <sys/compat.h>
-#include <sys/wait.h>
-
-/* This is an UGLY hack to get wait to compile, something better is needed. */
-/* #define _POSIX_SOURCE
-#undef _POSIX_SOURCE
-*/
-
-struct pthread_queue wait_queue = { NULL, NULL, NULL };
-extern void sig_handler_real();
-
-/* ==========================================================================
- * wait_wakeup()
- *
- * This routine is called by the interrupt handler which has locked
- * the current kthread semaphore. Since only threads owned by the
- * current kthread can be queue here, no additional locks are necessary.
- */
-int wait_wakeup()
-{
- struct pthread *pthread;
- int ret = 0;
-
- if (pthread = pthread_queue_deq(& wait_queue)) {
- /* Wakeup all threads, and enqueue them on the run queue */
- do {
- pthread->state = PS_RUNNING;
- if (pthread->pthread_priority > ret) {
- ret = pthread->pthread_priority;
- }
- pthread_prio_queue_enq(pthread_current_prio_queue, pthread);
- } while (pthread = pthread_queue_deq(&wait_queue));
- return(ret);
- }
- return(NOTOK);
-}
-
-/* ==========================================================================
- * For the wait calls, it is important that the current kthread is locked
- * before the apropriate wait syscall is preformed. This way we ensure
- * that there is never a case where a thread is waiting for a child but
- * missed the interrupt for that child.
- * Patched by William S. Lear 1997-02-02
- */
-
-/* ==========================================================================
- * waitpid()
- */
-pid_t waitpid(pid_t pid, int *status, int options)
-{
- pid_t ret;
-
- pthread_sched_prevent();
- ret = machdep_sys_waitpid(pid, status, options | WNOHANG);
- /* If we are not doing nohang, try again, else return immediately */
- if (!(options & WNOHANG)) {
- while (ret == OK) {
- /* Enqueue thread on wait queue */
- pthread_queue_enq(&wait_queue, pthread_run);
-
- /* reschedule unlocks scheduler */
- SET_PF_AT_CANCEL_POINT(pthread_run); /* This is a cancel point */
- pthread_resched_resume(PS_WAIT_WAIT);
- CLEAR_PF_AT_CANCEL_POINT(pthread_run); /* No longer at cancel point */
-
- pthread_sched_prevent();
-
- ret = machdep_sys_waitpid(pid, status, options | WNOHANG);
- }
- }
- pthread_sched_resume();
- return(ret);
-}
-
-/* ==========================================================================
- * wait3()
- * Patched by Monty 1997-02-02
- */
-pid_t wait3(__WAIT_STATUS status, int options, void * rusage)
-{
- semaphore * lock;
- pid_t ret;
-
- pthread_sched_prevent();
- ret = machdep_sys_wait3(status, options | WNOHANG, rusage);
- /* If we are not doing nohang, try again, else return immediately */
- if (!(options & WNOHANG)) {
- while (ret == OK) {
- /* Enqueue thread on wait queue */
- pthread_queue_enq(&wait_queue, pthread_run);
-
- /* reschedule unlocks scheduler */
- SET_PF_AT_CANCEL_POINT(pthread_run); /* This is a cancel point */
- pthread_resched_resume(PS_WAIT_WAIT);
- CLEAR_PF_AT_CANCEL_POINT(pthread_run); /* No longer at cancel point */
-
- pthread_sched_prevent();
-
- machdep_sys_wait3(status, options | WNOHANG, rusage);
- }
- }
- pthread_sched_resume();
- return(ret);
-}
-
-/* ==========================================================================
- * wait()
- */
-pid_t wait(__WAIT_STATUS status)
-{
- return(waitpid((pid_t)-1, (int *)status, 0));
-}
diff --git a/lib/libpthread/pthreads/wrapper.c b/lib/libpthread/pthreads/wrapper.c
deleted file mode 100644
index 7e986706046..00000000000
--- a/lib/libpthread/pthreads/wrapper.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/* ==== wrapper.c ============================================================
- * 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 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.
- *
- * Description : Wrapper functions for syscalls that only need errno redirected
- *
- * 1.4x 94/07/23 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: wrapper.c,v 1.1 1998/07/21 13:20:26 peter Exp $";
-#endif
-
-#include <pthread.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <pthread/posix.h>
-
-/* ==========================================================================
- * link()
- */
-int link(const char * name1, const char * name2)
-{
- int ret;
-
- if ((ret = machdep_sys_link(name1, name2)) < OK) {
- SET_ERRNO(-ret);
- }
- return(ret);
-
-}
-
-/* ==========================================================================
- * unlink()
- */
-int unlink(const char * path)
-{
- int ret;
-
- if ((ret = machdep_sys_unlink(path)) < OK) {
- SET_ERRNO(-ret);
- }
- return(ret);
-
-}
-
-/* ==========================================================================
- * chdir()
- */
-int chdir(const char * path)
-{
- int ret;
-
- if ((ret = machdep_sys_chdir(path)) < OK) {
- SET_ERRNO(-ret);
- }
- return(ret);
-
-}
-
-/* ==========================================================================
- * chmod()
- */
-int chmod(const char * path, mode_t mode)
-{
- int ret;
-
- if ((ret = machdep_sys_chmod(path, mode)) < OK) {
- SET_ERRNO(-ret);
- }
- return(ret);
-
-}
-
-/* ==========================================================================
- * chown()
- */
-int chown(const char * path, uid_t owner, gid_t group)
-{
- int ret;
-
- if ((ret = machdep_sys_chown(path, owner, group)) < OK) {
- SET_ERRNO(-ret);
- }
- return(ret);
-
-}
-
-/* ==========================================================================
- * rename()
- */
-int rename(const char * name1, const char * name2)
-{
- int ret;
-
- if ((ret = machdep_sys_rename(name1, name2)) < OK) {
- SET_ERRNO(-ret);
- }
- return(ret);
-
-}
diff --git a/lib/libpthread/scripts/Makefile.inc b/lib/libpthread/scripts/Makefile.inc
deleted file mode 100644
index 441f6b51d29..00000000000
--- a/lib/libpthread/scripts/Makefile.inc
+++ /dev/null
@@ -1,30 +0,0 @@
-.PATH : ${srcdir}/scripts
-SCRIPTS= pgcc pg++
-
-abspath != pwd
-
-all-bin: $(SCRIPTS)
-
-#
-# Objects go in the obj directory for both BSD and GNU make but these
-# scripts get put in the obj dir for BSD and the root dir for GNU.
-#
-pgcc: pgcc.sh
- sed -e 's!EXEC_PREFIX!$(exec_prefix)!g' \
- -e 's!BUILD_PREFIX!$(.CURDIR)!g' \
- -e 's!SRC_PREFIX!$(srcdir)!g' \
- -e 's!COMPILER!gcc!g' \
- < $(srcdir)/scripts/pgcc.sh > pgcc.new
- chmod a+x pgcc.new
- mv -f pgcc.new pgcc
- ln -fs obj/pgcc ../pgcc
-
-pg++: pgcc.sh
- sed -e 's!EXEC_PREFIX!$(exec_prefix)!g' \
- -e 's!BUILD_PREFIX!$(.CURDIR)!g' \
- -e 's!SRC_PREFIX!$(srcdir)!g' \
- -e 's!COMPILER!g++!g' \
- < $(srcdir)/scripts/pgcc.sh > pg++.new
- chmod a+x pg++.new
- mv -f pg++.new pg++
- ln -fs obj/pg++ ../pg++
diff --git a/lib/libpthread/scripts/pgcc.sh b/lib/libpthread/scripts/pgcc.sh
deleted file mode 100755
index 6bd6cbeccdb..00000000000
--- a/lib/libpthread/scripts/pgcc.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-
-pthreads_root=EXEC_PREFIX
-build_root=BUILD_PREFIX
-src_root=SRC_PREFIX
-
-include_dir='-I$pthreads_root/include'
-lib_dir='-L$pthreads_root/lib'
-libs='-lpthread -lm -lgcc -lpthread'
-
-# Might be a good idea to also provide a way to override pthreads_root
-# so that we can use this script in the build tree, before installation.
-if arg="$1" ; then
- case $arg in
- -notinstalled)
- include_dir='-I$build_root/include -I$src_root/include'
- lib_dir='-L$build_root/obj'
- shift
- ;;
- esac
-fi
-
-for arg in "$@" ; do
- case $arg in
- -nostdinc) include_dir= ;;
- -nostdlib | -c) libs= ;;
- esac
-done
-
-# Include the -L option in any case, just in case the user provided the
-# names of some libraries we've built threaded versions of.
-eval exec COMPILER '"$@"' $include_dir $lib_dir $libs
diff --git a/lib/libpthread/stdio/Makefile.inc b/lib/libpthread/stdio/Makefile.inc
deleted file mode 100644
index 9475a05208a..00000000000
--- a/lib/libpthread/stdio/Makefile.inc
+++ /dev/null
@@ -1,18 +0,0 @@
-# from: @(#)Makefile.inc 5.7 (Berkeley) 6/27/91
-# $Id: Makefile.inc,v 1.3 1998/07/22 11:33:37 peter Exp $
-
-.PATH: ${.CURDIR}/stdio
-
-# SRCS+= tempnam.c tmpfile.c tmpnam.c
-
-SRCS+= clrerr.c fclose.c fdopen.c feof.c ferror.c fflush.c fgetc.c \
- fgetline.c fgetpos.c fgets.c fileno.c findfp.c flags.c fopen.c \
- fpurge.c fputc.c fputs.c fread.c freopen.c fscanf.c \
- fseek.c fsetpos.c ftell.c funopen.c fvwrite.c fwalk.c fwrite.c \
- getc.c getchar.c gets.c getw.c makebuf.c perror.c putc.c \
- putchar.c puts.c putw.c refill.c remove.c rewind.c rget.c scanf.c \
- setbuf.c setbuffer.c setvbuf.c sscanf.c \
- stdio.c ungetc.c \
- vfscanf.c vscanf.c vsscanf.c \
- wsetup.c putc_unlocked.c putchar_unlocked.c getc_unlocked.c \
- getchar_unlocked.c strerror.c wbuf.c xprintf.c
diff --git a/lib/libpthread/stdio/README b/lib/libpthread/stdio/README
deleted file mode 100644
index 017f61f1b46..00000000000
--- a/lib/libpthread/stdio/README
+++ /dev/null
@@ -1,40 +0,0 @@
-This is a threadsafe stdio based on the BSD stdio written by Chris Torek.
-
-INCLUDE FILES AND PORTING
-To continue to make this package portable, some basic rules on includes
-files must be followed.
-
-pthread.h should be included first (if it is to be included).
-stdio.h should be included.
-
-INTERNAL LOCKING
-1. All functions that can be called by the user must have __flockfile at the
- begining and a __funlockfile at the end. __Flockfile is a counting mutex,
- The thread that owns the lock can call __flockfile as many times as
- it wants, but must call an equal number of __funlockfile before the
- lock will be released.
-2. All functions starting with __ shouldn't need addtional locking.
-3. Anything that writes the variable __sglue should lock __sfp_mutex,
- check __sfp_state, and do a condion wait if it is set.
-4. Anything that checks fp->_flag for valididity should also lock
- __sfp_mutex.
-5. Anything that reads the variable __sglue should lock __sfp_mutex, increment
- __sfp_state, and then unlock the mutex. At function return it should
- lock the mutex again decrement __sfp_state and check if zero. If so
- do a cond_signal, and unlock the mutex.
-6. The functions fopen, fdopen, and freopen are the only functions that
- will change a fp->_file
-7. fdopen and fopen both allocate the next fp by locking __sfp_mutex
- checking fp->_flags and then setting it if free.
-8. freopen tries to preserve fp->_file. It sets __sfp_mutex, then it
- tries to lock fp->_file and close it.
-9. __sinit is done with a pthread_once routine.
-
-Copyright (c) 1993 Chris Provenzano. All rights reserved.
-
-This product includes software developed by the Univeristy of California,
-Berkeley and its contributors.
-
-
-Things to do.
-Fix printf so it uses the ininf function.
diff --git a/lib/libpthread/stdio/clrerr.c b/lib/libpthread/stdio/clrerr.c
deleted file mode 100644
index 5989b6484b9..00000000000
--- a/lib/libpthread/stdio/clrerr.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)clrerr.c 5.3 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: clrerr.c,v 1.1 1995/10/18 08:43:06 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-
-void clearerr(FILE *fp)
-{
- flockfile(fp);
- fp->_flags &= ~(__SERR|__SEOF);
- funlockfile(fp);
-}
diff --git a/lib/libpthread/stdio/fclose.c b/lib/libpthread/stdio/fclose.c
deleted file mode 100644
index 538e0db8a35..00000000000
--- a/lib/libpthread/stdio/fclose.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)fclose.c 5.2 (Berkeley) 2/1/91";*/
-static char *rcsid = "$Id: fclose.c,v 1.1 1995/10/18 08:43:06 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "local.h"
-
-/* Do not reset the fd */
-fclose(fp)
- register FILE *fp;
-{
- register int r;
-
- if (fp->_flags) {
- flockfile(fp);
- r = fp->_flags & __SWR ? __sflush(fp) : 0;
- if (__sclose(fp) < 0)
- r = EOF;
- if (fp->_flags & __SMBF)
- free((char *)fp->_bf._base);
- if (HASUB(fp))
- FREEUB(fp);
- if (HASLB(fp))
- FREELB(fp);
- fp->_flags = 0; /* release this FILE for reuse, DO THIS LAST */
- funlockfile(fp);
- return(r);
- }
- errno = EBADF;
- return(EOF);
-}
diff --git a/lib/libpthread/stdio/fdopen.c b/lib/libpthread/stdio/fdopen.c
deleted file mode 100644
index 8d860bbeac2..00000000000
--- a/lib/libpthread/stdio/fdopen.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)fdopen.c 5.6 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: fdopen.c,v 1.1 1995/10/18 08:43:06 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <errno.h>
-#include "local.h"
-
-extern pthread_mutex_t __sfp_mutex;
-extern pthread_cond_t __sfp_cond;
-extern int __sfp_state;
-
-FILE *fdopen(int fd, const char *mode)
-{
- register FILE *fp;
- int flags, oflags, fdflags, tmp;
-
- if ((flags = __sflags(mode, &oflags)) == 0)
- return (NULL);
-
- /* Make sure the mode the user wants is a subset of the actual mode. */
- if ((fdflags = fcntl(fd, F_GETFL, 0)) < 0)
- return (NULL);
- tmp = fdflags & O_ACCMODE;
- if (tmp != O_RDWR && (tmp != (oflags & O_ACCMODE))) {
- errno = EINVAL;
- return (NULL);
- }
-
- pthread_once(&__sdidinit, __sinit);
- pthread_mutex_lock(&__sfp_mutex);
- while (__sfp_state) {
- pthread_cond_wait(&__sfp_cond, &__sfp_mutex);
- }
-
- if (fp = __sfp()) {
- fp->_flags = flags;
-
- /*
- * If opened for appending, but underlying descriptor does not have
- * O_APPEND bit set, assert __SAPP so that __swrite() will lseek to
- * end before each write.
- */
- if ((oflags & O_APPEND) && !(fdflags & O_APPEND))
- fp->_flags |= __SAPP;
- fp->_file = fd;
-
- }
- pthread_mutex_unlock(&__sfp_mutex);
- return (fp);
-}
diff --git a/lib/libpthread/stdio/feof.c b/lib/libpthread/stdio/feof.c
deleted file mode 100644
index 53e09f5ea50..00000000000
--- a/lib/libpthread/stdio/feof.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)feof.c 5.1 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: feof.c,v 1.1 1995/10/18 08:43:06 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-
-/*
- * A subroutine version of the macro feof.
- */
-#undef feof
-
-feof(fp)
- FILE *fp;
-{
- return (__sfeof(fp));
-}
diff --git a/lib/libpthread/stdio/ferror.c b/lib/libpthread/stdio/ferror.c
deleted file mode 100644
index 7e12f1d6a87..00000000000
--- a/lib/libpthread/stdio/ferror.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)ferror.c 5.1 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: ferror.c,v 1.1 1995/10/18 08:43:06 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-
-/*
- * A subroutine version of the macro ferror.
- */
-#undef ferror
-
-ferror(fp)
- FILE *fp;
-{
- return (__sferror(fp));
-}
diff --git a/lib/libpthread/stdio/fflush.c b/lib/libpthread/stdio/fflush.c
deleted file mode 100644
index 5e9f72c05ed..00000000000
--- a/lib/libpthread/stdio/fflush.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)fflush.c 5.1 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: fflush.c,v 1.1 1995/10/18 08:43:06 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/errno.h>
-#include <stdio.h>
-#include "local.h"
-
-/* Flush a single file, or (if fp is NULL) all files. */
-fflush(fp)
- register FILE *fp;
-{
- int retval;
-
- if (fp == NULL)
- return (__swalk_sflush);
- flockfile(fp);
-
- if ((fp->_flags & (__SWR | __SRW)) == 0) {
- errno = EBADF;
- retval = EOF;
- } else {
- retval = __sflush(fp);
- }
- funlockfile(fp);
- return(retval);
-}
-
-__sflush(fp)
- register FILE *fp;
-{
- register unsigned char *p;
- register int n, t;
-
- t = fp->_flags;
- if ((t & __SWR) == 0)
- return (0);
-
- if ((p = fp->_bf._base) == NULL)
- return (0);
-
- n = fp->_p - p; /* write this much */
-
- /*
- * Set these immediately to avoid problems with longjmp and to allow
- * exchange buffering (via setvbuf) in user write function.
- */
- fp->_p = p;
- fp->_w = t & (__SLBF|__SNBF) ? 0 : fp->_bf._size;
-
- for (; n > 0; n -= t, p += t) {
- t = __swrite(fp, (char *)p, n);
- if (t <= 0) {
- fp->_flags |= __SERR;
- return (EOF);
- }
- }
- return (0);
-}
diff --git a/lib/libpthread/stdio/fgetc.c b/lib/libpthread/stdio/fgetc.c
deleted file mode 100644
index 382aac0602f..00000000000
--- a/lib/libpthread/stdio/fgetc.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)fgetc.c 5.3 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: fgetc.c,v 1.1 1995/10/18 08:43:06 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-
-fgetc(fp)
- FILE *fp;
-{
- flockfile(fp);
- return (__sgetc(fp));
- funlockfile(fp);
-}
diff --git a/lib/libpthread/stdio/fgetline.c b/lib/libpthread/stdio/fgetline.c
deleted file mode 100644
index 320b306e745..00000000000
--- a/lib/libpthread/stdio/fgetline.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)fgetline.c 5.2 (Berkeley) 5/4/91";*/
-static char *rcsid = "$Id: fgetline.c,v 1.1 1995/10/18 08:43:06 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "local.h"
-
-/*
- * Expand the line buffer. Return -1 on error.
- * The `new size' does not account for a terminating '\0',
- * so we add 1 here.
- */
-__slbexpand(fp, newsize)
- FILE *fp;
- size_t newsize;
-{
- void *p;
-
- if (fp->_lb._size >= ++newsize)
- return (0);
- if ((p = realloc(fp->_lb._base, newsize)) == NULL)
- return (-1);
- fp->_lb._base = p;
- fp->_lb._size = newsize;
- return (0);
-}
-
-/*
- * Get an input line. The returned pointer often (but not always)
- * points into a stdio buffer. Fgetline smashes the newline (if any)
- * in the stdio buffer; callers must not use it on streams that
- * have `magic' setvbuf() games happening.
- */
-char *
-fgetline(fp, lenp)
- register FILE *fp;
- size_t *lenp;
-{
- register unsigned char *p;
- register size_t len;
- size_t off;
-
- flockfile(fp);
-
- /* make sure there is input */
- if (fp->_r <= 0 && __srefill(fp)) {
- if (lenp != NULL)
- *lenp = 0;
- funlockfile(fp);
- return (NULL);
- }
-
- /* look for a newline in the input */
- if ((p = memchr((void *)fp->_p, '\n', fp->_r)) != NULL) {
- register char *ret;
-
- /*
- * Found one. Flag buffer as modified to keep
- * fseek from `optimising' a backward seek, since
- * the newline is about to be trashed. (We should
- * be able to get away with doing this only if
- * p is not pointing into an ungetc buffer, since
- * fseek discards ungetc data, but this is the
- * usual case anyway.)
- */
- ret = (char *)fp->_p;
- len = p - fp->_p;
- fp->_flags |= __SMOD;
- *p = 0;
- fp->_r -= len + 1;
- fp->_p = p + 1;
- if (lenp != NULL)
- *lenp = len;
- funlockfile(fp);
- return (ret);
- }
-
- /*
- * We have to copy the current buffered data to the line buffer.
- *
- * OPTIMISTIC is length that we (optimistically)
- * expect will accomodate the `rest' of the string,
- * on each trip through the loop below.
- */
-#define OPTIMISTIC 80
-
- for (len = fp->_r, off = 0;; len += fp->_r) {
- register size_t diff;
-
- /*
- * Make sure there is room for more bytes.
- * Copy data from file buffer to line buffer,
- * refill file and look for newline. The
- * loop stops only when we find a newline.
- */
- if (__slbexpand(fp, len + OPTIMISTIC))
- goto error;
- (void) bcopy((void *)fp->_p, (void *)(fp->_lb._base + off),
- len - off);
- off = len;
- if (__srefill(fp))
- break; /* EOF or error: return partial line */
- if ((p = memchr((void *)fp->_p, '\n', fp->_r)) == NULL)
- continue;
-
- /* got it: finish up the line (like code above) */
- fp->_flags |= __SMOD; /* soon */
- diff = p - fp->_p;
- len += diff;
- if (__slbexpand(fp, len))
- goto error;
- (void) bcopy((void *)fp->_p, (void *)(fp->_lb._base + off), diff);
- fp->_r -= diff + 1;
- fp->_p = p + 1;
- break;
- }
- if (lenp != NULL)
- *lenp = len;
- fp->_lb._base[len] = 0;
-
- funlockfile(fp);
- return ((char *)fp->_lb._base);
-
-error:
- if (lenp != NULL)
- *lenp = 0; /* ??? */
- funlockfile(fp);
- return (NULL); /* ??? */
-}
diff --git a/lib/libpthread/stdio/fgetpos.c b/lib/libpthread/stdio/fgetpos.c
deleted file mode 100644
index 752db946cd8..00000000000
--- a/lib/libpthread/stdio/fgetpos.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)fgetpos.c 5.1 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: fgetpos.c,v 1.1 1995/10/18 08:43:06 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-
-/* Don't bother locking, ftell does it */
-fgetpos(fp, pos)
- FILE *fp;
- fpos_t *pos;
-{
- return ((*pos = ftell(fp)) == (fpos_t)-1);
-}
diff --git a/lib/libpthread/stdio/fgets.c b/lib/libpthread/stdio/fgets.c
deleted file mode 100644
index 7c00b6bdae8..00000000000
--- a/lib/libpthread/stdio/fgets.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)fgets.c 5.4 (Berkeley) 5/4/91";*/
-static char *rcsid = "$Id: fgets.c,v 1.1 1995/10/18 08:43:06 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-#include <string.h>
-
-/*
- * Read at most n-1 characters from the given file.
- * Stop when a newline has been read, or the count runs out.
- * Return first argument, or NULL if no characters were read.
- */
-char *
-fgets(buf, n, fp)
- char *buf;
- register size_t n;
- register FILE *fp;
-{
- register size_t len;
- register char *s;
- register unsigned char *p, *t;
-
- if (n < 2) /* sanity check */
- return (NULL);
-
- flockfile(fp);
- s = buf;
- n--; /* leave space for NUL */
- do {
- /*
- * If the buffer is empty, refill it.
- */
- if ((len = fp->_r) <= 0) {
- if (__srefill(fp)) {
- /* EOF/error: stop with partial or no line */
- if (s == buf)
- buf = NULL;
- break;
- }
- len = fp->_r;
- }
- p = fp->_p;
-
- /*
- * Scan through at most n bytes of the current buffer,
- * looking for '\n'. If found, copy up to and including
- * newline, and stop. Otherwise, copy entire chunk
- * and loop.
- */
- if (len > n)
- len = n;
- t = memchr((void *)p, '\n', len);
- if (t != NULL) {
- len = ++t - p;
- fp->_r -= len;
- fp->_p = t;
- (void) bcopy((void *)p, (void *)s, len);
- s += len;
- break;
- }
- fp->_r -= len;
- fp->_p += len;
- (void) bcopy((void *)p, (void *)s, len);
- s += len;
- } while ((n -= len) != 0);
-
- *s = 0;
- funlockfile(fp);
- return (buf);
-}
diff --git a/lib/libpthread/stdio/fileno.c b/lib/libpthread/stdio/fileno.c
deleted file mode 100644
index e4f08c105d8..00000000000
--- a/lib/libpthread/stdio/fileno.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)fileno.c 5.1 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: fileno.c,v 1.1 1995/10/18 08:43:06 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-
-/*
- * A subroutine version of the macro fileno.
- */
-#undef fileno
-
-fileno(fp)
- FILE *fp;
-{
- return (__sfileno(fp));
-}
diff --git a/lib/libpthread/stdio/findfp.c b/lib/libpthread/stdio/findfp.c
deleted file mode 100644
index dc1045bc3ff..00000000000
--- a/lib/libpthread/stdio/findfp.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)findfp.c 5.10 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: findfp.c,v 1.1 1995/10/18 08:43:06 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <posix.h>
-#include "local.h"
-#include "glue.h"
-
-
-#define NSTATIC 20 /* stdin + stdout + stderr + the usual */
-#define NDYNAMIC 10 /* add ten more whenever necessary */
-
-#define std(flags, file) \
- {0,0,0,flags,file,{0},0 }
-/* p r w flags file _bf z */
-
-static FILE usual[NSTATIC - 3]; /* the usual */
-static struct glue uglue = { 0, NSTATIC - 3, usual };
-
-FILE __sF[3] = {
- std(__SRD, 0), /* stdin */
- std(__SWR, 1), /* stdout */
- std(__SWR|__SNBF, 2) /* stderr */
-};
-struct glue __sglue = { &uglue, 3, __sF };
-
-pthread_mutex_t __sfp_mutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_cond_t __sfp_cond = PTHREAD_COND_INITIALIZER;
-pthread_once_t __sdidinit = PTHREAD_ONCE_INIT;
-/*
- * __sfp_state = 0, when free, > 0 when in _fwalk
- * This allows multiple readers in _fwalk, but only one writer __sfp,
- * or freopen() at a time.
- */
-int __sfp_state = 0;
-
-static struct glue *moreglue(register int n)
-{
- register struct glue *g;
- register FILE *p;
- static FILE empty;
-
- g = (struct glue *)malloc(sizeof(*g) + n * sizeof(FILE));
- if (g == NULL)
- return (NULL);
- p = (FILE *)(g + 1);
- g->next = NULL;
- g->niobs = n;
- g->iobs = p;
- while (--n >= 0)
- *p++ = empty;
- return (g);
-}
-
-/*
- * Find a free FILE for fopen et al.
- */
-FILE *__sfp()
-{
- register FILE *fp;
- register int n;
- register struct glue *g;
-
- for (g = &__sglue;; g = g->next) {
- for (fp = g->iobs, n = g->niobs; --n >= 0; fp++)
- if (fp->_flags == 0) {
- fp->_flags = 1; /* reserve this slot; caller sets real flags */
- fp->_p = NULL; /* no current pointer */
- fp->_w = 0; /* nothing to read or write */
- fp->_r = 0;
- fp->_bf._base = NULL; /* no buffer */
- fp->_bf._size = 0;
- fp->_lbfsize = 0; /* not line buffered */
- fp->_file = -1; /* no file */
- fp->_ub._base = NULL; /* no ungetc buffer */
- fp->_ub._size = 0;
- fp->_lb._base = NULL; /* no line buffer */
- fp->_lb._size = 0;
- goto __sfp_done;
- }
- if (g->next == NULL && (g->next = moreglue(NDYNAMIC)) == NULL) {
- fp = NULL;
- break;
- }
- }
-__sfp_done:;
- return (fp);
-}
-
-/*
- * exit() calls _cleanup() through *__cleanup, set whenever we
- * open or buffer a file. This chicanery is done so that programs
- * that do not use stdio need not link it all in.
- *
- * The name `_cleanup' is, alas, fairly well known outside stdio.
- */
-void _cleanup()
-{
- (void) __swalk_sflush;
-}
-
-/*
- * __sinit() is called whenever stdio's internal variables must be set up.
- */
-void __sinit()
-{
- /* make sure we clean up on exit */
- __cleanup = _cleanup;
- __sdidinit = 1;
-}
diff --git a/lib/libpthread/stdio/flags.c b/lib/libpthread/stdio/flags.c
deleted file mode 100644
index 7a0bfa71ab9..00000000000
--- a/lib/libpthread/stdio/flags.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)flags.c 5.1 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: flags.c,v 1.1 1995/10/18 08:43:06 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#include <sys/file.h>
-#include <stdio.h>
-#include <errno.h>
-
-/*
- * Return the (stdio) flags for a given mode. Store the flags
- * to be passed to an open() syscall through *optr.
- * Return 0 on error.
- */
-__sflags(mode, optr)
- register char *mode;
- int *optr;
-{
- register int ret, m, o;
-
- switch (*mode++) {
-
- case 'r': /* open for reading */
- ret = __SRD;
- m = O_RDONLY;
- o = 0;
- break;
-
- case 'w': /* open for writing */
- ret = __SWR;
- m = O_WRONLY;
- o = O_CREAT | O_TRUNC;
- break;
-
- case 'a': /* open for appending */
- ret = __SWR;
- m = O_WRONLY;
- o = O_CREAT | O_APPEND;
- break;
-
- default: /* illegal mode */
- errno = EINVAL;
- return (0);
- }
-
- /* [rwa]\+ or [rwa]b\+ means read and write */
- if (*mode == '+' || (*mode == 'b' && mode[1] == '+')) {
- ret = __SRW;
- m = O_RDWR;
- }
- *optr = m | o;
- return (ret);
-}
diff --git a/lib/libpthread/stdio/floatio.h b/lib/libpthread/stdio/floatio.h
deleted file mode 100644
index a5bfd1f59e4..00000000000
--- a/lib/libpthread/stdio/floatio.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * from: @(#)floatio.h 5.1 (Berkeley) 1/20/91
- * $Id: floatio.h,v 1.1 1995/10/18 08:43:06 deraadt Exp $
- */
-
-/*
- * Floating point scanf/printf (input/output) definitions.
- */
-
-/* 11-bit exponent (VAX G floating point) is 308 decimal digits */
-#define MAXEXP 308
-/* 128 bit fraction takes up 39 decimal digits; max reasonable precision */
-#define MAXFRACT 39
diff --git a/lib/libpthread/stdio/fopen.c b/lib/libpthread/stdio/fopen.c
deleted file mode 100644
index f12842e3bc5..00000000000
--- a/lib/libpthread/stdio/fopen.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)fopen.c 5.5 (Berkeley) 2/5/91";*/
-static char *rcsid = "$Id: fopen.c,v 1.1 1995/10/18 08:43:06 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <errno.h>
-#include "local.h"
-
-extern pthread_mutex_t __sfp_mutex;
-extern pthread_cond_t __sfp_cond;
-extern int __sfp_state;
-
-FILE *fopen(const char *file, const char *mode)
-{
- register FILE *fp;
- register int f;
- int flags, oflags;
-
- if ((flags = __sflags(mode, &oflags)) == 0)
- return (NULL);
- if ((f = open(file, oflags, 0666)) < 0) {
- return (NULL);
- }
-
- pthread_once(&__sdidinit, __sinit);
- pthread_mutex_lock(&__sfp_mutex);
- while (__sfp_state) {
- pthread_cond_wait(&__sfp_cond, &__sfp_mutex);
- }
-
- if (fp = __sfp()) {
- fp->_file = f;
- fp->_flags = flags;
-
- /*
- * When opening in append mode, even though we use O_APPEND,
- * we need to seek to the end so that ftell() gets the right
- * answer. If the user then alters the seek pointer, or
- * the file extends, this will fail, but there is not much
- * we can do about this. (We could set __SAPP and check in
- * fseek and ftell.)
- */
- if (oflags & O_APPEND)
- (void) __sseek((void *)fp, (fpos_t)0, SEEK_END);
- }
- pthread_mutex_unlock(&__sfp_mutex);
- return (fp);
-}
diff --git a/lib/libpthread/stdio/fprintf.c b/lib/libpthread/stdio/fprintf.c
deleted file mode 100644
index ab159072863..00000000000
--- a/lib/libpthread/stdio/fprintf.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * Copyright (c) 1993, 1994 Chris Provenzano.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)fprintf.c 5.6 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: fprintf.c,v 1.3 1998/07/21 13:53:53 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#ifdef __STDC__
-fprintf(FILE *fp, const char *fmt, ...)
-#else
-fprintf(fp, fmt, va_alist)
- FILE *fp;
- char *fmt;
- va_dcl
-#endif
-{
- int ret;
- va_list ap;
-
-#ifdef __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- ret = vfprintf(fp, fmt, ap);
- va_end(ap);
- return (ret);
-}
diff --git a/lib/libpthread/stdio/fpurge.c b/lib/libpthread/stdio/fpurge.c
deleted file mode 100644
index 65788204920..00000000000
--- a/lib/libpthread/stdio/fpurge.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)fpurge.c 5.2 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: fpurge.c,v 1.1 1995/10/18 08:43:06 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "local.h"
-
-/*
- * fpurge: like fflush, but without writing anything: leave the
- * given FILE's buffer empty.
- */
-int
-fpurge(fp)
- register FILE *fp;
-{
- int ret;
-
- flockfile(fp);
- if (fp->_flags) {
- if (HASUB(fp))
- FREEUB(fp);
- fp->_p = fp->_bf._base;
- fp->_r = 0;
- fp->_w = fp->_flags & (__SLBF|__SNBF) ? 0 : fp->_bf._size;
- ret = 0;
- } else {
- errno = EBADF;
- ret = EOF;
- }
- funlockfile(fp);
- return (ret);
-}
diff --git a/lib/libpthread/stdio/fputc.c b/lib/libpthread/stdio/fputc.c
deleted file mode 100644
index b1febc14515..00000000000
--- a/lib/libpthread/stdio/fputc.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)fputc.c 5.3 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: fputc.c,v 1.1 1995/10/18 08:43:06 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-
-fputc(c, fp)
- int c;
- register FILE *fp;
-{
- int ret;
- flockfile(fp);
- ret = __sputc(c, fp);
- funlockfile(fp);
- return(ret);
-}
diff --git a/lib/libpthread/stdio/fputs.c b/lib/libpthread/stdio/fputs.c
deleted file mode 100644
index 320477ca416..00000000000
--- a/lib/libpthread/stdio/fputs.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)fputs.c 5.6 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: fputs.c,v 1.1 1995/10/18 08:43:06 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-#include <string.h>
-#include "fvwrite.h"
-
-/*
- * Write the given string to the given file.
- */
-fputs(s, fp)
- const char *s;
- FILE *fp;
-{
- struct __suio uio;
- struct __siov iov;
- int ret;
-
- iov.iov_base = (void *)s;
- iov.iov_len = uio.uio_resid = strlen(s);
- uio.uio_iov = &iov;
- uio.uio_iovcnt = 1;
- flockfile(fp);
- ret = __sfvwrite(fp, &uio);
- funlockfile(fp);
- return(ret);
-}
diff --git a/lib/libpthread/stdio/fread.c b/lib/libpthread/stdio/fread.c
deleted file mode 100644
index 3df1689f2f0..00000000000
--- a/lib/libpthread/stdio/fread.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)fread.c 5.4 (Berkeley) 5/4/91";*/
-static char *rcsid = "$Id: fread.c,v 1.1 1995/10/18 08:43:06 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-#include <string.h>
-
-size_t
-fread(buf, size, count, fp)
- void *buf;
- size_t size, count;
- register FILE *fp;
-{
- register size_t resid;
- register char *p;
- register int r;
- size_t total;
-
- if ((resid = count * size) == 0)
- return (count);
-
- flockfile(fp);
- if (fp->_r < 0)
- fp->_r = 0;
- total = resid;
- p = buf;
- while (resid > (r = fp->_r)) {
- (void) bcopy((void *)fp->_p, (void *)p, (size_t)r);
- fp->_p += r;
- /* fp->_r = 0 ... done in __srefill */
- p += r;
- resid -= r;
- if (__srefill(fp)) {
- /* no more input: return partial result */
- count = (total - resid) / size;
- goto done_fread;
- }
- }
- (void) bcopy((void *)fp->_p, (void *)p, resid);
- fp->_r -= resid;
- fp->_p += resid;
-done_fread:;
- funlockfile(fp);
- return (count);
-}
diff --git a/lib/libpthread/stdio/freopen.c b/lib/libpthread/stdio/freopen.c
deleted file mode 100644
index c7ab61c061a..00000000000
--- a/lib/libpthread/stdio/freopen.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)freopen.c 5.6 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: freopen.c,v 1.1 1995/10/18 08:43:07 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "local.h"
-
-extern pthread_mutex_t __sfp_mutex;
-extern pthread_cond_t __sfp_cond;
-extern int __sfp_state;
-
-/*
- * Re-direct an existing, open (probably) file to some other file.
- * ANSI is written such that the original file gets closed if at
- * all possible, no matter what.
- */
-FILE *
-freopen(file, mode, fp)
- const char *file, *mode;
- register FILE *fp;
-{
- int f, flags, oflags;
- FILE *ret;
-
- if ((flags = __sflags(mode, &oflags)) == 0) {
- (void) fclose(fp);
- return (NULL);
- }
-
- pthread_once(&__sdidinit, __sinit);
-
- /*
- * There are actually programs that depend on being able to "freopen"
- * descriptors that weren't originally open. Keep this from breaking.
- * Remember whether the stream was open to begin with, and which file
- * descriptor (if any) was associated with it. If it was attached to
- * a descriptor, defer closing it; freopen("/dev/stdin", "r", stdin)
- * should work. This is unnecessary if it was not a Unix file.
- */
- /* while lock __sfp_mutex, to block out fopen, and other freopen calls */
- while (pthread_mutex_lock(&__sfp_mutex) == OK) {
- if (ftrylockfile(fp) == OK) {
- if (fp->_flags) {
- /* flush the stream; ANSI doesn't require this. */
- if (fp->_flags & __SWR)
- (void) __sflush(fp);
- __sclose(fp);
- /*
- * Finish closing fp. We cannot keep fp->_base:
- * it may be the wrong size. This loses the effect
- * of any setbuffer calls, but stdio has always done
- * this before.
- * NOTE: We do this even if __ftrylockfilr failed with
- * an error to avoid memory leaks.
- */
- if (fp->_flags & __SMBF)
- free((char *)fp->_bf._base);
- fp->_w = 0;
- fp->_r = 0;
- fp->_p = NULL;
- fp->_bf._base = NULL;
- fp->_bf._size = 0;
- fp->_lbfsize = 0;
- if (HASUB(fp))
- FREEUB(fp);
- fp->_ub._size = 0;
- if (HASLB(fp))
- FREELB(fp);
- fp->_lb._size = 0;
- }
- /* Get a new descriptor to refer to the new file. */
- if ((f = open(file, oflags, 0666)) < OK)
- ret = NULL;
- /*
- * If reopening something that was open before on a real file, try
- * to maintain the descriptor. Various C library routines (perror)
- * assume stderr is always fd STDERR_FILENO, even if being freopen'd.
- */
- /* Testing f == fp->_file may no longer be necessary */
- if (fp->_file >= 0 && f != fp->_file) {
- if (dup2(f, fp->_file) >= OK) {
- (void)close(f);
- f = fp->_file;
- }
- }
- fp->_flags = flags;
- fp->_file = f;
- ret = fp;
- break;
- } else {
- /* unlock __sfp_mutex, and try again later */
- pthread_mutex_unlock(&__sfp_mutex);
- pthread_yield();
- continue;
- }
- pthread_mutex_unlock(&__sfp_mutex);
- funlockfile(fp);
- return(ret);
- }
- (void)fclose(fp);
- return(NULL);
-}
diff --git a/lib/libpthread/stdio/fscanf.c b/lib/libpthread/stdio/fscanf.c
deleted file mode 100644
index 9a946124fbd..00000000000
--- a/lib/libpthread/stdio/fscanf.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * Copyright (c) 1993, 1994 Chris Provenzano.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)fscanf.c 5.1 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: fscanf.c,v 1.3 1998/07/21 13:53:54 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#ifdef __STDC__
-fscanf(FILE *fp, char const *fmt, ...) {
- int r;
- va_list ap;
-
- va_start(ap, fmt);
-#else
-fscanf(fp, fmt, va_alist)
- FILE *fp;
- char *fmt;
- va_dcl
-{
- int r;
- va_list ap;
-
- va_start(ap);
-#endif
- flockfile(fp);
- r = __svfscanf(fp, fmt, ap);
- funlockfile(fp);
- va_end(ap);
- return(r);
-}
diff --git a/lib/libpthread/stdio/fseek.c b/lib/libpthread/stdio/fseek.c
deleted file mode 100644
index 15176414f98..00000000000
--- a/lib/libpthread/stdio/fseek.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * Copyright (c) 1993, 1994 Chris Provenzano.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)fseek.c 5.7 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: fseek.c,v 1.3 1998/07/21 13:53:56 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include "local.h"
-
-#define POS_ERR (-(fpos_t)1)
-
-/*
- * Seek the given file to the given offset.
- * `Whence' must be one of the three SEEK_* macros.
- */
-fseek(fp, offset, whence)
- register FILE *fp;
- long offset;
- int whence;
-{
-#ifdef __STDC__
- register fpos_t (*seekfn)(void *, fpos_t, int);
-#else
- register fpos_t (*seekfn)();
-#endif
- fpos_t target, curoff;
- size_t n;
- struct stat st;
- int havepos;
-
- /* make sure stdio is set up */
- __sinit ();
-
- flockfile(fp);
-
- /*
- * Change any SEEK_CUR to SEEK_SET, and check `whence' argument.
- * After this, whence is either SEEK_SET or SEEK_END.
- */
- switch (whence) {
- case SEEK_CUR:
- /*
- * In order to seek relative to the current stream offset,
- * we have to first find the current stream offset a la
- * ftell (see ftell for details).
- */
- if (fp->_flags & __SOFF)
- curoff = fp->_offset;
- else {
- curoff = __sseek(fp, (off_t)0, SEEK_CUR);
- if (curoff == -1L) {
- funlockfile(fp);
- return (EOF);
- }
- }
- if (fp->_flags & __SRD) {
- curoff -= fp->_r;
- if (HASUB(fp))
- curoff -= fp->_ur;
- } else if (fp->_flags & __SWR && fp->_p != NULL)
- curoff += fp->_p - fp->_bf._base;
-
- offset += curoff;
- whence = SEEK_SET;
- havepos = 1;
- break;
-
- case SEEK_SET:
- case SEEK_END:
- curoff = 0; /* XXX just to keep gcc quiet */
- havepos = 0;
- break;
-
- default:
- errno = EINVAL;
- funlockfile(fp);
- return (EOF);
- }
-
- /*
- * Can only optimise if:
- * reading (and not reading-and-writing);
- * not unbuffered; and
- * this is a `regular' Unix file (and hence seekfn==__sseek).
- * We must check __NBF first, because it is possible to have __NBF
- * and __SOPT both set.
- */
- if (fp->_bf._base == NULL)
- __smakebuf(fp);
- if (fp->_flags & (__SWR | __SRW | __SNBF | __SNPT))
- goto dumb;
- if ((fp->_flags & __SOPT) == 0) {
- if (fp->_file < 0 || fstat(fp->_file, &st) ||
- (st.st_mode & S_IFMT) != S_IFREG) {
- fp->_flags |= __SNPT;
- goto dumb;
- }
- fp->_blksize = st.st_blksize;
- fp->_flags |= __SOPT;
- }
-
- /*
- * We are reading; we can try to optimise.
- * Figure out where we are going and where we are now.
- */
- if (whence == SEEK_SET)
- target = offset;
- else {
- if (fstat(fp->_file, &st))
- goto dumb;
- target = st.st_size + offset;
- }
-
- if (!havepos) {
- if (fp->_flags & __SOFF)
- curoff = fp->_offset;
- else {
- curoff = __sseek(fp, (off_t)0, SEEK_CUR);
- if (curoff == POS_ERR)
- goto dumb;
- }
- curoff -= fp->_r;
- if (HASUB(fp))
- curoff -= fp->_ur;
- }
-
- /*
- * Compute the number of bytes in the input buffer (pretending
- * that any ungetc() input has been discarded). Adjust current
- * offset backwards by this count so that it represents the
- * file offset for the first byte in the current input buffer.
- */
- if (HASUB(fp)) {
- n = fp->_up - fp->_bf._base;
- curoff -= n;
- n += fp->_ur;
- } else {
- n = fp->_p - fp->_bf._base;
- curoff -= n;
- n += fp->_r;
- }
-
- /*
- * If the target offset is within the current buffer,
- * simply adjust the pointers, clear EOF, undo ungetc(),
- * and return. (If the buffer was modified, we have to
- * skip this; see fgetline.c.)
- */
- if ((fp->_flags & __SMOD) == 0 &&
- target >= curoff && target < curoff + n) {
- register int o = target - curoff;
-
- fp->_p = fp->_bf._base + o;
- fp->_r = n - o;
- if (HASUB(fp))
- FREEUB(fp);
- fp->_flags &= ~__SEOF;
- funlockfile(fp);
- return (0);
- }
-
- /*
- * The place we want to get to is not within the current buffer,
- * but we can still be kind to the kernel copyout mechanism.
- * By aligning the file offset to a block boundary, we can let
- * the kernel use the VM hardware to map pages instead of
- * copying bytes laboriously. Using a block boundary also
- * ensures that we only read one block, rather than two.
- */
- curoff = target & ~(fp->_blksize - 1);
- if (__sseek(fp, (off_t)curoff, SEEK_SET) != POS_ERR) {
- fp->_r = 0;
- fp->_p = fp->_bf._base;
- if (HASUB(fp))
- FREEUB(fp);
- fp->_flags &= ~__SEOF;
- n = target - curoff;
- if (n) {
- if (__srefill(fp) || fp->_r < n)
- goto dumb;
- fp->_p += n;
- fp->_r -= n;
- }
- funlockfile(fp);
- return (0);
- }
-
- /*
- * We get here if we cannot optimise the seek ... just
- * do it. Allow the seek function to change fp->_bf._base.
- */
-dumb:
- if (__sflush(fp) || __sseek(fp, (off_t)offset, whence) == POS_ERR) {
- funlockfile(fp);
- return (EOF);
- }
- /* success: clear EOF indicator and discard ungetc() data */
- if (HASUB(fp))
- FREEUB(fp);
- fp->_p = fp->_bf._base;
- fp->_r = 0;
- /* fp->_w = 0; */ /* unnecessary (I think...) */
- fp->_flags &= ~__SEOF;
- funlockfile(fp);
- return (0);
-}
diff --git a/lib/libpthread/stdio/fsetpos.c b/lib/libpthread/stdio/fsetpos.c
deleted file mode 100644
index 69c9ddd0fcb..00000000000
--- a/lib/libpthread/stdio/fsetpos.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)fsetpos.c 5.2 (Berkeley) 2/5/91";*/
-static char *rcsid = "$Id: fsetpos.c,v 1.1 1995/10/18 08:43:07 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-
-/*
- * fsetpos: like fseek.
- * Don't bother locking, fseek does it.
- */
-fsetpos(iop, pos)
- FILE *iop;
- const fpos_t *pos;
-{
- return (fseek(iop, (long)*pos, SEEK_SET));
-}
diff --git a/lib/libpthread/stdio/ftell.c b/lib/libpthread/stdio/ftell.c
deleted file mode 100644
index 8d3f228bbd0..00000000000
--- a/lib/libpthread/stdio/ftell.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * Copyright (c) 1993, 1994 Chris Provenzano.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)ftell.c 5.4 (Berkeley) 2/5/91";*/
-static char *rcsid = "$Id: ftell.c,v 1.5 1998/07/21 13:53:57 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-#include <errno.h>
-#include "local.h"
-
-/*
- * ftell: return current offset.
- */
-long
-ftell(fp)
- register const FILE *fp;
-{
- long pos;
-
- flockfile((FILE *)fp);
-
- /*
- * Find offset of underlying I/O object, then
- * adjust for buffered bytes.
- */
- if (fp->_flags & __SOFF) {
- pos = fp->_offset;
- } else {
- pos = (long)__sseek((FILE *)fp, (off_t)0, SEEK_CUR);
- }
-
- if (pos != -1L) {
- if (fp->_flags & __SRD) {
- /*
- * Reading. Any unread characters (including
- * those from ungetc) cause the position to be
- * smaller than that in the underlying object.
- */
- pos -= fp->_r;
- if (HASUB(fp))
- pos -= fp->_ur;
- } else if (fp->_flags & __SWR && fp->_p != NULL) {
- /*
- * Writing. Any buffered characters cause the
- * position to be greater than that in the
- * underlying object.
- */
- pos += fp->_p - fp->_bf._base;
- }
- }
- funlockfile((FILE *)fp);
- return (pos);
-}
diff --git a/lib/libpthread/stdio/funopen.c b/lib/libpthread/stdio/funopen.c
deleted file mode 100644
index 8a0079871f1..00000000000
--- a/lib/libpthread/stdio/funopen.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * Copyright (c) 1993, 1994 Chris Provenzano.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)funopen.c 5.2 (Berkeley) 2/5/91";*/
-static char *rcsid = "$Id: funopen.c,v 1.3 1998/07/21 13:53:58 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <errno.h>
-#include "local.h"
-
-FILE *
-funopen(cookie, readfn, writefn, seekfn, closefn)
- const void *cookie;
- int (*readfn)(), (*writefn)();
-#ifdef __STDC__
- fpos_t (*seekfn)(void *cookie, fpos_t off, int whence);
-#else
- fpos_t (*seekfn)();
-#endif
- int (*closefn)();
-{
- struct fd_ops *fd_ops;
- char *flags;
- FILE *fp;
- int fd;
-
- if (readfn == NULL) {
- if (writefn == NULL) { /* illegal */
- errno = EINVAL;
- return (NULL);
- } else
- flags = "w"; /* write only */
- } else {
- if (writefn == NULL)
- flags = "r"; /* read only */
- else
- flags = "r+"; /* read-write */
- }
-
- if (fd_ops = (struct fd_ops*)malloc(sizeof(struct fd_ops))) {
- if ((fd = fd_allocate()) >= OK) {
-
- /* Set functions */
- fd_ops->seek = (off_t(*)())seekfn;
- fd_ops->read = (pthread_ssize_t(*)())readfn;
- fd_ops->write = (pthread_ssize_t(*)())writefn;
- fd_ops->close = closefn;
- fd_ops->use_kfds = 2;
-
- /* Alloc space for funtion pointer table */
- fd_table[fd]->type = FD_HALF_DUPLEX;
- fd_table[fd]->ops = fd_ops;
- fd_table[fd]->flags = O_RDWR;
-
- /* Save the cookie, it's important */
- fd_table[fd]->fd.ptr = (void *)cookie;
-
- if (fp = fdopen(fd, flags))
- return(fp);
-
- fd_free(fd);
- }
- free(fd_ops);
- }
- return(NULL);
-}
diff --git a/lib/libpthread/stdio/fvwrite.c b/lib/libpthread/stdio/fvwrite.c
deleted file mode 100644
index c4646099fde..00000000000
--- a/lib/libpthread/stdio/fvwrite.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)fvwrite.c 5.3 (Berkeley) 5/4/91";*/
-static char *rcsid = "$Id: fvwrite.c,v 1.1 1995/10/18 08:43:07 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <string.h>
-#include <stdio.h>
-#include "local.h"
-#include "fvwrite.h"
-
-/*
- * Write some memory regions. Return zero on success, EOF on error.
- *
- * This routine is large and unsightly, but most of the ugliness due
- * to the three different kinds of output buffering is handled here.
- */
-__sfvwrite(fp, uio)
- register FILE *fp;
- register struct __suio *uio;
-{
- register size_t len;
- register char *p;
- register struct __siov *iov;
- register int w, s;
- char *nl;
- int nlknown, nldist;
-
- if ((len = uio->uio_resid) == 0)
- return (0);
- /* make sure we can write */
- if (cantwrite(fp))
- return (EOF);
-
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-#define COPY(n) (void) bcopy((void *)p, (void *)fp->_p, (size_t)(n));
-
- iov = uio->uio_iov;
- p = iov->iov_base;
- len = iov->iov_len;
- iov++;
-#define GETIOV(extra_work) \
- while (len == 0) { \
- extra_work; \
- p = iov->iov_base; \
- len = iov->iov_len; \
- iov++; \
- }
- if (fp->_flags & __SNBF) {
- /*
- * Unbuffered: write up to BUFSIZ bytes at a time.
- */
- do {
- GETIOV(;);
- w = __swrite(fp, p, MIN(len, BUFSIZ));
- if (w <= 0)
- goto err;
- p += w;
- len -= w;
- } while ((uio->uio_resid -= w) != 0);
- } else if ((fp->_flags & __SLBF) == 0) {
- /*
- * Fully buffered: fill partially full buffer, if any,
- * and then flush. If there is no partial buffer, write
- * one _bf._size byte chunk directly (without copying).
- *
- * String output is a special case: write as many bytes
- * as fit, but pretend we wrote everything. This makes
- * snprintf() return the number of bytes needed, rather
- * than the number used, and avoids its write function
- * (so that the write function can be invalid).
- */
- do {
- GETIOV(;);
- w = fp->_w;
- if (fp->_flags & __SSTR) {
- if (len < w)
- w = len;
- COPY(w); /* copy MIN(fp->_w,len), */
- fp->_w -= w;
- fp->_p += w;
- w = len; /* but pretend copied all */
- } else if (fp->_p > fp->_bf._base && len > w) {
- /* fill and flush */
- COPY(w);
- /* fp->_w -= w; */ /* unneeded */
- fp->_p += w;
- if (fflush(fp))
- goto err;
- } else if (len >= (w = fp->_bf._size)) {
- if ((w = __swrite(fp, p, w)) <= 0)
- goto err;
- } else {
- /* fill and done */
- w = len;
- COPY(w);
- fp->_w -= w;
- fp->_p += w;
- }
- p += w;
- len -= w;
- } while ((uio->uio_resid -= w) != 0);
- } else {
- /*
- * Line buffered: like fully buffered, but we
- * must check for newlines. Compute the distance
- * to the first newline (including the newline),
- * or `infinity' if there is none, then pretend
- * that the amount to write is MIN(len,nldist).
- */
- nlknown = 0;
- nldist = 0; /* XXX just to keep gcc happy */
- do {
- GETIOV(nlknown = 0);
- if (!nlknown) {
- nl = memchr((void *)p, '\n', len);
- nldist = nl ? nl + 1 - p : len + 1;
- nlknown = 1;
- }
- s = MIN(len, nldist);
- w = fp->_w + fp->_bf._size;
- if (fp->_p > fp->_bf._base && s > w) {
- COPY(w);
- /* fp->_w -= w; */
- fp->_p += w;
- if (fflush(fp))
- goto err;
- } else if (s >= (w = fp->_bf._size)) {
- if ((w = __swrite(fp, p, w)) <= 0)
- goto err;
- } else {
- w = s;
- COPY(w);
- fp->_w -= w;
- fp->_p += w;
- }
- if ((nldist -= w) == 0) {
- /* copied the newline: flush and forget */
- if (fflush(fp))
- goto err;
- nlknown = 0;
- }
- p += w;
- len -= w;
- } while ((uio->uio_resid -= w) != 0);
- }
- return (0);
-
-err:
- fp->_flags |= __SERR;
- return (EOF);
-}
diff --git a/lib/libpthread/stdio/fvwrite.h b/lib/libpthread/stdio/fvwrite.h
deleted file mode 100644
index 8977a2bf49e..00000000000
--- a/lib/libpthread/stdio/fvwrite.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * from: @(#)fvwrite.h 5.1 (Berkeley) 1/20/91
- * $Id: fvwrite.h,v 1.1 1995/10/18 08:43:07 deraadt Exp $
- */
-
-/*
- * I/O descriptors for __sfvwrite().
- */
-struct __siov {
- void *iov_base;
- size_t iov_len;
-};
-
-struct __suio {
- struct __siov *uio_iov;
- int uio_iovcnt;
- int uio_resid;
-};
-
-extern int __sfvwrite __P(( FILE *, struct __suio *));
diff --git a/lib/libpthread/stdio/fwalk.c b/lib/libpthread/stdio/fwalk.c
deleted file mode 100644
index b4a81f083ba..00000000000
--- a/lib/libpthread/stdio/fwalk.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)fwalk.c 5.2 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: fwalk.c,v 1.1 1995/10/18 08:43:07 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <errno.h>
-#include <stdio.h>
-#include "local.h"
-#include "glue.h"
-
-extern pthread_mutex_t __sfp_mutex;
-extern pthread_cond_t __sfp_cond;
-extern int __sfp_state;
-
-/*
- * fwalk now can only be used for flushing the buffers.
- * This is all it was originally used for.
- * The function has also become much more complicated.
- * The first time through we flush everything we can.
- * If this fails to flush everything because we couldn't get a lock
- * we wait on the locksfor the second pass. Why this works ...
- *
- * This function must allow for multiple threads to flush everything.
- * This function cannot flush buffers locked by another thread.
- * So we flush everything we can the first pass. This includes all
- * buffers locked by this thread, and wait on buffers that are locked.
- * Eventually other threads willl unlock there buffers or flush them themselves
- * at which point this thread will notice that it's empty or be able to
- * flush the buffer. This is fine so long as no other thread tries to flush
- * all buffers. Here is the possible deadlock condition, but since this thread
- * has flushed all buffers it can, there are NO buffers locked by this thread
- * that need flushing so any other thread flushing won't block waiting on this
- * thread thereby eliminating the deadlock condition.
- */
-
-int __swalk_sflush()
-{
- register FILE *fp, *savefp;
- register int n, ret, saven;
- register struct glue *g, *saveg;
-
- /* Only allow other threads to read __sglue */
- pthread_mutex_lock(&__sfp_mutex);
- __sfp_state++;
- pthread_mutex_unlock(&__sfp_mutex);
-
- ret = 0;
- saven = 0;
- saveg = NULL;
- savefp = NULL;
- for (g = &__sglue; g != NULL; g = g->next) {
- for (fp = g->iobs, n = g->niobs; --n >= 0; fp++) {
- if (fp->_flags != 0) {
- /* Is there anything to flush? */
- if (fp->_bf._base && (fp->_bf._base - fp->_p)) {
- if (ftrylockfile(fp)) { /* Can we flush it */
- if (!saven) { /* No, save first fp we can't flush */
- saven;
- saveg = g;
- savefp = fp;
- continue;
- }
- ret |= __sflush(fp);
- }
- }
- }
- }
- }
- if (savefp) {
- for (g = saveg; g != NULL; g = g->next) {
- for (fp = savefp, n = saven + 1; --n >= 0; fp++) {
- if (fp->_flags != 0) {
- /* Anything to flush */
- while (fp->_bf._base && (fp->_bf._base - fp->_p)) {
- if (ftrylockfile(fp)) { /* Can we flush it */
- pthread_yield();
- continue;
- }
- ret |= __sflush(fp);
- }
- }
- }
- }
- }
-
- /* If no other readers wakeup a thread waiting to do __sfp */
- pthread_mutex_lock(&__sfp_mutex);
- if (! (--__sfp_state)) {
- pthread_cond_signal(&__sfp_cond);
- }
- pthread_mutex_unlock(&__sfp_mutex);
- return (ret);
-}
-
diff --git a/lib/libpthread/stdio/fwrite.c b/lib/libpthread/stdio/fwrite.c
deleted file mode 100644
index 35576013f62..00000000000
--- a/lib/libpthread/stdio/fwrite.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)fwrite.c 5.5 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: fwrite.c,v 1.1 1995/10/18 08:43:07 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-#include "local.h"
-#include "fvwrite.h"
-
-/*
- * Write `count' objects (each size `size') from memory to the given file.
- * Return the number of whole objects written.
- */
-size_t
-fwrite(buf, size, count, fp)
- const void *buf;
- size_t size, count;
- FILE *fp;
-{
- struct __suio uio;
- struct __siov iov;
- size_t n;
-
- iov.iov_base = (void *)buf;
- uio.uio_resid = iov.iov_len = n = count * size;
- uio.uio_iov = &iov;
- uio.uio_iovcnt = 1;
-
- flockfile(fp);
-
- /*
- * The usual case is success (__sfvwrite returns 0);
- * skip the divide if this happens, since divides are
- * generally slow and since this occurs whenever size==0.
- */
- if (__sfvwrite(fp, &uio) == 0)
- count = (n - uio.uio_resid) / size;
- funlockfile(fp);
- return(count);
-}
diff --git a/lib/libpthread/stdio/getc.c b/lib/libpthread/stdio/getc.c
deleted file mode 100644
index 2b487ce63c7..00000000000
--- a/lib/libpthread/stdio/getc.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)getc.c 5.1 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: getc.c,v 1.1 1995/10/18 08:43:07 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-
-/*
- * A subroutine version of the macro getc.
- */
-#undef getc
-
-getc(fp)
- register FILE *fp;
-{
- int ret;
- flockfile(fp);
- ret = __sgetc(fp);
- funlockfile(fp);
- return(ret);
-}
diff --git a/lib/libpthread/stdio/getc_unlocked.c b/lib/libpthread/stdio/getc_unlocked.c
deleted file mode 100644
index c60046cf34c..00000000000
--- a/lib/libpthread/stdio/getc_unlocked.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)getc.c 5.1 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: getc_unlocked.c,v 1.1 1995/10/18 08:43:07 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-
-/*
- * A subroutine version of the macro getc.
- */
-#undef getc_unlocked
-
-getc_unlocked(fp)
- register FILE *fp;
-{
- return (__sgetc(fp));
-}
diff --git a/lib/libpthread/stdio/getchar.c b/lib/libpthread/stdio/getchar.c
deleted file mode 100644
index 1e2d6ac92a9..00000000000
--- a/lib/libpthread/stdio/getchar.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)getchar.c 5.3 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: getchar.c,v 1.1 1995/10/18 08:43:07 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-/*
- * A subroutine version of the macro getchar.
- */
-#include <pthread.h>
-#include <stdio.h>
-
-#undef getchar
-
-getchar()
-{
- int ret;
- flockfile(stdin);
- ret = getc(stdin);
- funlockfile(stdin);
- return(ret);
-}
diff --git a/lib/libpthread/stdio/getchar_unlocked.c b/lib/libpthread/stdio/getchar_unlocked.c
deleted file mode 100644
index f2eefcb29e3..00000000000
--- a/lib/libpthread/stdio/getchar_unlocked.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)getchar.c 5.3 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: getchar_unlocked.c,v 1.1 1995/10/18 08:43:07 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-/*
- * A subroutine version of the macro getchar.
- */
-#include <pthread.h>
-#include <stdio.h>
-
-#undef getchar_unlocked
-
-getchar_unlocked()
-{
- return (getc(stdin));
-}
diff --git a/lib/libpthread/stdio/gets.c b/lib/libpthread/stdio/gets.c
deleted file mode 100644
index 9cc4916e7a1..00000000000
--- a/lib/libpthread/stdio/gets.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)gets.c 5.3 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: gets.c,v 1.1 1995/10/18 08:43:07 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <unistd.h>
-#include <stdio.h>
-
-char *
-gets(buf)
- char *buf;
-{
- register int c;
- register char *s;
- static int warned;
- static char w[] =
- "warning: this program uses gets(), which is unsafe.\r\n";
-
- if (!warned) {
- (void) write(STDERR_FILENO, w, sizeof(w) - 1);
- warned = 1;
- }
- for (s = buf; (c = getchar()) != '\n';)
- if (c == EOF)
- if (s == buf)
- return (NULL);
- else
- break;
- else
- *s++ = c;
- *s = 0;
- return (buf);
-}
diff --git a/lib/libpthread/stdio/getw.c b/lib/libpthread/stdio/getw.c
deleted file mode 100644
index ef6472a0940..00000000000
--- a/lib/libpthread/stdio/getw.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)getw.c 5.3 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: getw.c,v 1.1 1995/10/18 08:43:07 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-
-getw(fp)
- FILE *fp;
-{
- int x;
-
- return (fread((void *)&x, sizeof(x), 1, fp) == 1 ? x : EOF);
-}
diff --git a/lib/libpthread/stdio/glue.h b/lib/libpthread/stdio/glue.h
deleted file mode 100644
index 3467dd66b2f..00000000000
--- a/lib/libpthread/stdio/glue.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * from: @(#)glue.h 5.1 (Berkeley) 1/20/91
- * $Id: glue.h,v 1.1 1995/10/18 08:43:07 deraadt Exp $
- */
-
-/*
- * The first few FILEs are statically allocated; others are dynamically
- * allocated and linked in via this glue structure.
- */
-struct glue {
- struct glue *next;
- int niobs;
- FILE *iobs;
-} __sglue;
diff --git a/lib/libpthread/stdio/local.h b/lib/libpthread/stdio/local.h
deleted file mode 100644
index 248bb3d5e31..00000000000
--- a/lib/libpthread/stdio/local.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * from: @(#)local.h 5.3 (Berkeley) 5/6/93
- * $Id: local.h,v 1.1 1995/10/18 08:43:07 deraadt Exp $
- */
-
-/*
- * Information local to this implementation of stdio,
- * in particular, macros and private variables.
- */
-
-FILE *__sfp __P((void));
-int __sflush __P((FILE *));
-int __srefill __P((FILE *));
-int __swrite __P((FILE *, const char *, int));
-int __sread __P((FILE *, char *, int));
-fpos_t __sseek __P((FILE *, fpos_t, int));
-int __sclose __P((FILE *));
-void __sinit __P((void));
-void _cleanup __P((void));
-void (*__cleanup) __P((void));
-void __smakebuf __P((FILE *));
-int __swhatbuf __P((FILE *, size_t *, int *));
-int __swalk_sflush __P(());
-int __swsetup __P((FILE *));
-int __sflags __P((const char *, int *));
-
-extern int __sdidinit;
-
-/*
- * Return true iff the given FILE cannot be written now.
- */
-#define cantwrite(fp) \
- ((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \
- __swsetup(fp))
-
-/*
- * Test whether the given stdio file has an active ungetc buffer;
- * release such a buffer, without restoring ordinary unread data.
- */
-#define HASUB(fp) ((fp)->_ub._base != NULL)
-#define FREEUB(fp) { \
- if ((fp)->_ub._base != (fp)->_ubuf) \
- free((char *)(fp)->_ub._base); \
- (fp)->_ub._base = NULL; \
-}
-
-/*
- * test for an fgetline() buffer.
- */
-#define HASLB(fp) ((fp)->_lb._base != NULL)
-#define FREELB(fp) { \
- free((char *)(fp)->_lb._base); \
- (fp)->_lb._base = NULL; \
-}
diff --git a/lib/libpthread/stdio/makebuf.c b/lib/libpthread/stdio/makebuf.c
deleted file mode 100644
index e7b615437d8..00000000000
--- a/lib/libpthread/stdio/makebuf.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)makebuf.c 5.3 (Berkeley) 5/6/93";*/
-static char *rcsid = "$Id: makebuf.c,v 1.1 1995/10/18 08:43:08 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "local.h"
-
-/*
- * Allocate a file buffer, or switch to unbuffered I/O.
- * Per the ANSI C standard, ALL tty devices default to line buffered.
- *
- * As a side effect, we set __SOPT or __SNPT (en/dis-able fseek
- * optimisation) right after the fstat() that finds the buffer size.
- */
-void
-__smakebuf(fp)
- register FILE *fp;
-{
- register void *p;
- register int flags;
- size_t size;
- int couldbetty;
-
- if (fp->_flags & __SNBF) {
- fp->_bf._base = fp->_p = fp->_nbuf;
- fp->_bf._size = 1;
- return;
- }
- flags = __swhatbuf(fp, &size, &couldbetty);
- if ((p = malloc(size)) == NULL) {
- fp->_flags |= __SNBF;
- fp->_bf._base = fp->_p = fp->_nbuf;
- fp->_bf._size = 1;
- return;
- }
- __cleanup = _cleanup;
- flags |= __SMBF;
- fp->_bf._base = fp->_p = p;
- fp->_bf._size = size;
- if (couldbetty && isatty(fp->_file))
- flags |= __SLBF;
- fp->_flags |= flags;
-}
-
-/*
- * Internal routine to determine `proper' buffering for a file.
- */
-int
-__swhatbuf(fp, bufsize, couldbetty)
- register FILE *fp;
- size_t *bufsize;
- int *couldbetty;
-{
- struct stat st;
-
- if (fp->_file < 0 || fstat(fp->_file, &st) < 0) {
- *couldbetty = 0;
- *bufsize = BUFSIZ;
- return (__SNPT);
- }
-
- /* could be a tty iff it is a character device */
- *couldbetty = (st.st_mode & S_IFMT) == S_IFCHR;
- if (st.st_blksize <= 0) {
- *bufsize = BUFSIZ;
- return (__SNPT);
- }
-
- /*
- * Optimise fseek() only if it is a regular file. (The test for
- * __sseek is mainly paranoia.) It is safe to set _blksize
- * unconditionally; it will only be used if __SOPT is also set.
- */
- *bufsize = st.st_blksize;
- fp->_blksize = st.st_blksize;
- return ((st.st_mode & S_IFMT) == S_IFREG ? __SOPT : __SNPT);
-}
diff --git a/lib/libpthread/stdio/mktemp.c b/lib/libpthread/stdio/mktemp.c
deleted file mode 100644
index 4f41c63ff48..00000000000
--- a/lib/libpthread/stdio/mktemp.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (c) 1987 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)mktemp.c 5.10 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: mktemp.c,v 1.1 1995/10/18 08:43:08 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <stdio.h>
-
-static int _gettemp();
-
-mkstemp(path)
- char *path;
-{
- int fd;
-
- return (_gettemp(path, &fd) ? fd : -1);
-}
-
-char *
-mktemp(path)
- char *path;
-{
- return(_gettemp(path, (int *)NULL) ? path : (char *)NULL);
-}
-
-static
-_gettemp(path, doopen)
- char *path;
- register int *doopen;
-{
- extern int errno;
- register char *start, *trv;
- struct stat sbuf;
- u_int pid;
-
- pid = getpid();
- for (trv = path; *trv; ++trv); /* extra X's get set to 0's */
- while (*--trv == 'X') {
- *trv = (pid % 10) + '0';
- pid /= 10;
- }
-
- /*
- * check the target directory; if you have six X's and it
- * doesn't exist this runs for a *very* long time.
- */
- for (start = trv + 1;; --trv) {
- if (trv <= path)
- break;
- if (*trv == '/') {
- *trv = '\0';
- if (stat(path, &sbuf))
- return(0);
- if (!S_ISDIR(sbuf.st_mode)) {
- errno = ENOTDIR;
- return(0);
- }
- *trv = '/';
- break;
- }
- }
-
- for (;;) {
- if (doopen) {
- if ((*doopen =
- open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0)
- return(1);
- if (errno != EEXIST)
- return(0);
- }
- else if (stat(path, &sbuf))
- return(errno == ENOENT ? 1 : 0);
-
- /* tricky little algorithm for backward compatibility */
- for (trv = start;;) {
- if (!*trv)
- return(0);
- if (*trv == 'z')
- *trv++ = 'a';
- else {
- if (isdigit(*trv))
- *trv = 'a';
- else
- ++*trv;
- break;
- }
- }
- }
- /*NOTREACHED*/
-}
diff --git a/lib/libpthread/stdio/perror.c b/lib/libpthread/stdio/perror.c
deleted file mode 100644
index c4cb0154da2..00000000000
--- a/lib/libpthread/stdio/perror.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 1988 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)perror.c 5.11 (Berkeley) 2/24/91";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <unistd.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-
-void
-perror(s)
- const char *s;
-{
- register struct iovec *v;
- struct iovec iov[4];
-
- v = iov;
- if (s && *s) {
- v->iov_base = (char *)s;
- v->iov_len = strlen(s);
- v++;
- v->iov_base = ": ";
- v->iov_len = 2;
- v++;
- }
- v->iov_base = strerror(errno);
- v->iov_len = strlen(v->iov_base);
- v++;
- v->iov_base = "\n";
- v->iov_len = 1;
- (void)writev(STDERR_FILENO, iov, (v - iov) + 1);
-}
diff --git a/lib/libpthread/stdio/printf.c b/lib/libpthread/stdio/printf.c
deleted file mode 100644
index 4b546565d08..00000000000
--- a/lib/libpthread/stdio/printf.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)printf.c 5.6 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: printf.c,v 1.1 1995/10/18 08:43:08 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-
-printf(char const *fmt, ...)
-{
- int ret;
- va_list ap;
-
- va_start(ap, fmt);
- ret = vfprintf(stdout, fmt, ap);
- va_end(ap);
- return (ret);
-}
diff --git a/lib/libpthread/stdio/putc.c b/lib/libpthread/stdio/putc.c
deleted file mode 100644
index f98ace370ad..00000000000
--- a/lib/libpthread/stdio/putc.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)putc.c 5.1 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: putc.c,v 1.1 1995/10/18 08:43:08 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-
-/*
- * A subroutine version of the macro putc.
- */
-#undef putc
-
-putc(c, fp)
- int c;
- register FILE *fp;
-{
- int ret;
- flockfile(fp);
- ret = __sputc(c, fp);
- funlockfile(fp);
- return(ret);
-}
diff --git a/lib/libpthread/stdio/putc_unlocked.c b/lib/libpthread/stdio/putc_unlocked.c
deleted file mode 100644
index 3f3a6a9a14c..00000000000
--- a/lib/libpthread/stdio/putc_unlocked.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)putc.c 5.1 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: putc_unlocked.c,v 1.1 1995/10/18 08:43:08 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-
-/*
- * A subroutine version of the macro putc.
- */
-#undef putc_unlocked
-
-putc_unlocked(c, fp)
- int c;
- register FILE *fp;
-{
- return (__sputc(c, fp));
-}
diff --git a/lib/libpthread/stdio/putchar.c b/lib/libpthread/stdio/putchar.c
deleted file mode 100644
index d02c06beb33..00000000000
--- a/lib/libpthread/stdio/putchar.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)putchar.c 5.3 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: putchar.c,v 1.1 1995/10/18 08:43:08 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-
-#undef putchar
-
-/*
- * A subroutine version of the macro putchar
- */
-putchar(c)
- int c;
-{
- register FILE *so = stdout;
- int ret;
-
- flockfile(so);
- ret = __sputc(c, so);
- funlockfile(so);
- return(ret);
-}
diff --git a/lib/libpthread/stdio/putchar_unlocked.c b/lib/libpthread/stdio/putchar_unlocked.c
deleted file mode 100644
index c79dc7ed489..00000000000
--- a/lib/libpthread/stdio/putchar_unlocked.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)putchar.c 5.3 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: putchar_unlocked.c,v 1.1 1995/10/18 08:43:08 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-
-#undef putchar_unlocked
-/*
- * A subroutine version of the macro putchar
- */
-putchar_unlocked(c)
- int c;
-{
- register FILE *so = stdout;
-
- return (__sputc(c, so));
-}
diff --git a/lib/libpthread/stdio/puts.c b/lib/libpthread/stdio/puts.c
deleted file mode 100644
index bb7357b1cb4..00000000000
--- a/lib/libpthread/stdio/puts.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)puts.c 5.6 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: puts.c,v 1.1 1995/10/18 08:43:08 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-#include <string.h>
-#include "fvwrite.h"
-
-/*
- * Write the given string to stdout, appending a newline.
- */
-puts(s)
- char const *s;
-{
- size_t c = strlen(s);
- struct __suio uio;
- struct __siov iov[2];
- int r;
-
- iov[0].iov_base = (void *)s;
- iov[0].iov_len = c;
- iov[1].iov_base = "\n";
- iov[1].iov_len = 1;
- uio.uio_resid = c + 1;
- uio.uio_iov = &iov[0];
- uio.uio_iovcnt = 2;
-
- flockfile(stdout);
- r = (__sfvwrite(stdout, &uio) ? EOF : '\n');
- funlockfile(stdout);
- return(r);
-}
diff --git a/lib/libpthread/stdio/putw.c b/lib/libpthread/stdio/putw.c
deleted file mode 100644
index 0bb28601d4d..00000000000
--- a/lib/libpthread/stdio/putw.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)putw.c 5.3 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: putw.c,v 1.1 1995/10/18 08:43:08 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-#include "fvwrite.h"
-
-putw(w, fp)
- int w;
- FILE *fp;
-{
- struct __suio uio;
- struct __siov iov;
- int r;
-
- iov.iov_base = &w;
- iov.iov_len = uio.uio_resid = sizeof(w);
- uio.uio_iov = &iov;
- uio.uio_iovcnt = 1;
-
- flockfile(fp);
- r = (__sfvwrite(fp, &uio));
- funlockfile(fp);
- return(r);
-}
diff --git a/lib/libpthread/stdio/refill.c b/lib/libpthread/stdio/refill.c
deleted file mode 100644
index 8485159ad6c..00000000000
--- a/lib/libpthread/stdio/refill.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)refill.c 5.3 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: refill.c,v 1.1 1995/10/18 08:43:08 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "local.h"
-#include "glue.h"
-
-extern pthread_mutex_t __sfp_mutex;
-extern pthread_cond_t __sfp_cond;
-extern struct glue __sglue;
-extern int __sfp_state;
-
-/* This function is very similar to __swalk_sflush */
-static void __swalk_lflush()
-{
- register FILE *fp, *savefp;
- register int n, saven;
- register struct glue *g, *saveg;
-
- /* Only allow other threads to read __sglue */
- pthread_mutex_lock(&__sfp_mutex);
- __sfp_state++;
- pthread_mutex_unlock(&__sfp_mutex);
-
- saven = 0;
- saveg = NULL;
- savefp = NULL;
- for (g = &__sglue; g != NULL; g = g->next) {
- for (fp = g->iobs, n = g->niobs; --n >= 0; fp++) {
- if ((fp->_flags & (__SLBF|__SWR)) == __SLBF|__SWR) {
- /* Is there anything to flush? */
- if (fp->_bf._base && (fp->_bf._base - fp->_p)) {
- if (ftrylockfile(fp)) { /* Can we flush it */
- if (!saven) { /* No, save first fp we can't flush */
- saven;
- saveg = g;
- savefp = fp;
- continue;
- }
- (void) __sflush(fp);
- }
- }
- }
- }
- }
- if (savefp) {
- for (g = saveg; g != NULL; g = g->next) {
- for (fp = savefp, n = saven + 1; --n >= 0; fp++) {
- if ((fp->_flags & (__SLBF|__SWR)) == __SLBF|__SWR) {
- /* Anything to flush */
- while (fp->_bf._base && (fp->_bf._base - fp->_p)) {
- if (ftrylockfile(fp)) { /* Can we flush it */
- pthread_yield();
- continue;
- }
- (void) __sflush(fp);
- }
- }
- }
- }
- }
-
- /* If no other readers wakeup a thread waiting to do __sfp */
- pthread_mutex_lock(&__sfp_mutex);
- if (! (--__sfp_state)) {
- pthread_cond_signal(&__sfp_cond);
- }
- pthread_mutex_unlock(&__sfp_mutex);
-}
-
-/*
- * Refill a stdio buffer.
- * Return EOF on eof or error, 0 otherwise.
- */
-__srefill(fp)
- register FILE *fp;
-{
-
- /* make sure stdio is set up */
- pthread_once(&__sdidinit, __sinit);
-
- fp->_r = 0; /* largely a convenience for callers */
-
- /* SysV does not make this test; take it out for compatibility */
- if (fp->_flags & __SEOF)
- return (EOF);
-
- /* if not already reading, have to be reading and writing */
- if ((fp->_flags & __SRD) == 0) {
- if ((fp->_flags & __SRW) == 0) {
- errno = EBADF;
- return (EOF);
- }
- /* switch to reading */
- if (fp->_flags & __SWR) {
- if (__sflush(fp))
- return (EOF);
- fp->_flags &= ~__SWR;
- fp->_w = 0;
- fp->_lbfsize = 0;
- }
- fp->_flags |= __SRD;
- } else {
- /*
- * We were reading. If there is an ungetc buffer,
- * we must have been reading from that. Drop it,
- * restoring the previous buffer (if any). If there
- * is anything in that buffer, return.
- */
- if (HASUB(fp)) {
- FREEUB(fp);
- if ((fp->_r = fp->_ur) != 0) {
- fp->_p = fp->_up;
- return (0);
- }
- }
- }
-
- if (fp->_bf._base == NULL)
- __smakebuf(fp);
-
- /*
- * Before reading from a line buffered or unbuffered file,
- * flush all line buffered output files, per the ANSI C
- * standard.
- */
- if (fp->_flags & (__SLBF|__SNBF))
- __swalk_lflush();
- fp->_p = fp->_bf._base;
- fp->_r = __sread(fp, (char *)fp->_p, fp->_bf._size);
- fp->_flags &= ~__SMOD; /* buffer contents are again pristine */
- if (fp->_r <= 0) {
- if (fp->_r == 0)
- fp->_flags |= __SEOF;
- else {
- fp->_r = 0;
- fp->_flags |= __SERR;
- }
- return (EOF);
- }
- return (0);
-}
diff --git a/lib/libpthread/stdio/remove.c b/lib/libpthread/stdio/remove.c
deleted file mode 100644
index 3a09735f298..00000000000
--- a/lib/libpthread/stdio/remove.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)remove.c 5.3 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: remove.c,v 1.1 1995/10/18 08:43:08 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <unistd.h>
-
-remove(file)
- const char *file;
-{
- return (unlink(file));
-}
diff --git a/lib/libpthread/stdio/rewind.c b/lib/libpthread/stdio/rewind.c
deleted file mode 100644
index b5d1a9d8e67..00000000000
--- a/lib/libpthread/stdio/rewind.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)rewind.c 5.6 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: rewind.c,v 1.1 1995/10/18 08:43:08 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <errno.h>
-#include <stdio.h>
-
-void
-rewind(fp)
- register FILE *fp;
-{
- flockfile(fp);
- (void) fseek(fp, 0L, SEEK_SET);
- fp->_flags &= ~(__SERR|__SEOF); /* clearerr */
- funlockfile(fp);
- errno = 0; /* not required, but seems reasonable */
-}
diff --git a/lib/libpthread/stdio/rget.c b/lib/libpthread/stdio/rget.c
deleted file mode 100644
index f43747cda99..00000000000
--- a/lib/libpthread/stdio/rget.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)rget.c 5.1 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: rget.c,v 1.1 1995/10/18 08:43:08 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-
-/*
- * Handle getc() when the buffer ran out:
- * Refill, then return the first character
- * in the newly-filled buffer.
- */
-__srget(fp)
- register FILE *fp;
-{
- if (__srefill(fp) == 0) {
- fp->_r--;
- return (*fp->_p++);
- }
- return (EOF);
-}
diff --git a/lib/libpthread/stdio/scanf.c b/lib/libpthread/stdio/scanf.c
deleted file mode 100644
index 6d023a4bba2..00000000000
--- a/lib/libpthread/stdio/scanf.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * Copyright (c) 1993, 1994 Chris Provenzano.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)scanf.c 5.3 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: scanf.c,v 1.3 1998/07/21 13:53:59 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#ifdef __STDC__
-scanf(char const *fmt, ...)
-#else
-scanf(fmt, va_alist)
- char *fmt;
- va_dcl
-#endif
-{
- int ret;
- va_list ap;
-
-#ifdef __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- flockfile(stdin);
- ret = __svfscanf(stdin, fmt, ap);
- funlockfile(stdin);
- va_end(ap);
- return (ret);
-}
diff --git a/lib/libpthread/stdio/setbuf.c b/lib/libpthread/stdio/setbuf.c
deleted file mode 100644
index 94ae5d66d75..00000000000
--- a/lib/libpthread/stdio/setbuf.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)setbuf.c 5.3 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: setbuf.c,v 1.1 1995/10/18 08:43:08 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-#include "local.h"
-
-void
-setbuf(fp, buf)
- FILE *fp;
- char *buf;
-{
- (void) setvbuf(fp, buf, buf ? _IOFBF : _IONBF, BUFSIZ);
-}
diff --git a/lib/libpthread/stdio/setbuffer.c b/lib/libpthread/stdio/setbuffer.c
deleted file mode 100644
index e390674110b..00000000000
--- a/lib/libpthread/stdio/setbuffer.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)setbuffer.c 5.5 (Berkeley) 3/18/91";*/
-static char *rcsid = "$Id: setbuffer.c,v 1.1 1995/10/18 08:43:09 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-
-void
-setbuffer(fp, buf, size)
- register FILE *fp;
- char *buf;
- int size;
-{
-
- (void) setvbuf(fp, buf, buf ? _IOFBF : _IONBF, size);
-}
-
-/*
- * set line buffering
- */
-setlinebuf(fp)
- FILE *fp;
-{
-
- (void) setvbuf(fp, (char *)NULL, _IOLBF, (size_t)0);
- return (0); /* ??? */
-}
diff --git a/lib/libpthread/stdio/setvbuf.c b/lib/libpthread/stdio/setvbuf.c
deleted file mode 100644
index f0a195a5dcf..00000000000
--- a/lib/libpthread/stdio/setvbuf.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)setvbuf.c 5.5 (Berkeley) 5/6/93";*/
-static char *rcsid = "$Id: setvbuf.c,v 1.1 1995/10/18 08:43:09 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "local.h"
-
-/*
- * Set one of the three kinds of buffering, optionally including
- * a buffer.
- */
-setvbuf(fp, buf, mode, size)
- register FILE *fp;
- char *buf;
- register int mode;
- register size_t size;
-{
- register int ret, flags;
- size_t iosize;
- int ttyflag;
-
- /*
- * Verify arguments. The `int' limit on `size' is due to this
- * particular implementation. Note, buf and size are ignored
- * when setting _IONBF.
- */
- if (mode != _IONBF)
- if ((mode != _IOFBF && mode != _IOLBF) || (int)size < 0)
- return (EOF);
-
- flockfile(fp);
- /*
- * Write current buffer, if any. Discard unread input, cancel
- * line buffering, and free old buffer if malloc()ed.
- */
- ret = 0;
- (void)__sflush(fp);
- fp->_r = fp->_lbfsize = 0;
- flags = fp->_flags;
- if (flags & __SMBF)
- free((void *)fp->_bf._base);
- flags &= ~(__SLBF | __SNBF | __SMBF | __SOPT | __SNPT);
-
- /* If setting unbuffered mode, skip all the hard work. */
- if (mode == _IONBF)
- goto nbf;
-
- /*
- * Find optimal I/O size for seek optimization. This also returns
- * a `tty flag' to suggest that we check isatty(fd), but we do not
- * care since our caller told us how to buffer.
- */
- flags |= __swhatbuf(fp, &iosize, &ttyflag);
- if (size == 0) {
- buf = NULL; /* force local allocation */
- size = iosize;
- }
-
- /* Allocate buffer if needed. */
- if (buf == NULL) {
- if ((buf = malloc(size)) == NULL) {
- /*
- * Unable to honor user's request. We will return
- * failure, but try again with file system size.
- */
- ret = EOF;
- if (size != iosize) {
- size = iosize;
- buf = malloc(size);
- }
- }
- if (buf == NULL) {
- /* No luck; switch to unbuffered I/O. */
-nbf:
- fp->_flags = flags | __SNBF;
- fp->_w = 0;
- fp->_bf._base = fp->_p = fp->_nbuf;
- fp->_bf._size = 1;
- funlockfile(fp);
- return (ret);
- }
- flags |= __SMBF;
- }
-
- /*
- * Kill any seek optimization if the buffer is not the
- * right size.
- *
- * SHOULD WE ALLOW MULTIPLES HERE (i.e., ok iff (size % iosize) == 0)?
- */
- if (size != iosize)
- flags |= __SNPT;
-
- /*
- * Fix up the FILE fields, and set __cleanup for output flush on
- * exit (since we are buffered in some way). If in r/w mode, go
- * to the intermediate state, so that everyone has to call
- * __srefill or __swsetup on the first operation -- it is more
- * trouble than it is worth to set things up correctly here.
- */
- if (mode == _IOLBF)
- flags |= __SLBF;
- if (flags & __SRW)
- flags &= ~(__SRD | __SWR);
- fp->_w = 0;
- fp->_flags = flags;
- fp->_bf._base = fp->_p = (unsigned char *)buf;
- fp->_bf._size = size;
- fp->_lbfsize = 0;
- __cleanup = _cleanup;
-
- funlockfile(fp);
- return (ret);
-}
diff --git a/lib/libpthread/stdio/snprintf.c b/lib/libpthread/stdio/snprintf.c
deleted file mode 100644
index a009da8f3aa..00000000000
--- a/lib/libpthread/stdio/snprintf.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * Copyright (c) 1993, 1994 Chris Provenzano.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)snprintf.c 5.1 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: snprintf.c,v 1.3 1998/07/21 13:54:00 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#ifdef __STDC__
-snprintf(char *str, size_t n, char const *fmt, ...)
-#else
-snprintf(str, n, fmt, va_alist)
- char *str;
- size_t n;
- char *fmt;
- va_dcl
-#endif
-{
- int ret;
- va_list ap;
- FILE f;
-
- if ((int)n < 1)
- return (EOF);
-#ifdef __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- f._file = -1;
- f._flags = __SWR | __SSTR;
- f._bf._base = f._p = (unsigned char *)str;
- f._bf._size = f._w = n - 1;
- ret = vfprintf(&f, fmt, ap);
- *f._p = 0;
- va_end(ap);
- return (ret);
-}
diff --git a/lib/libpthread/stdio/sprintf.c b/lib/libpthread/stdio/sprintf.c
deleted file mode 100644
index 6d6906967fc..00000000000
--- a/lib/libpthread/stdio/sprintf.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * Copyright (c) 1993, 1994 Chris Provenzano.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)sprintf.c 5.7 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: sprintf.c,v 1.3 1998/07/21 13:54:01 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <limits.h>
-#include <stdio.h>
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-#include "local.h"
-
-#ifdef __STDC__
-sprintf(char *str, char const *fmt, ...)
-#else
-sprintf(str, fmt, va_alist)
- char *str;
- char *fmt;
- va_dcl
-#endif
-{
- int ret;
- va_list ap;
- FILE f;
-
- f._file = -1;
- f._flags = __SWR | __SSTR;
- f._bf._base = f._p = (unsigned char *)str;
- f._bf._size = f._w = INT_MAX;
-#ifdef __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- ret = vfprintf(&f, fmt, ap);
- va_end(ap);
- *f._p = 0;
- return (ret);
-}
diff --git a/lib/libpthread/stdio/sscanf.c b/lib/libpthread/stdio/sscanf.c
deleted file mode 100644
index cd3db6640a4..00000000000
--- a/lib/libpthread/stdio/sscanf.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * Copyright (c) 1993, 1994 Chris Provenzano.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)sscanf.c 5.1 (Berkeley) 1/20/91";*/
-static char *rcsid = "$Id: sscanf.c,v 1.3 1998/07/21 13:54:02 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-#include <string.h>
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-#include "local.h"
-
-#ifdef __STDC__
-sscanf(const char *str, char const *fmt, ...)
-#else
-sscanf(str, fmt, va_alist)
- const char *str;
- char *fmt;
- va_dcl
-#endif
-{
- int ret;
- va_list ap;
- FILE f;
-
- f._flags = __SRD;
- f._file = -1;
- f._bf._base = f._p = (unsigned char *)str;
- f._bf._size = f._r = strlen(str);
- f._ub._base = NULL;
- f._lb._base = NULL;
-#ifdef __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- ret = __svfscanf(&f, fmt, ap);
- va_end(ap);
- return (ret);
-}
diff --git a/lib/libpthread/stdio/stdio.c b/lib/libpthread/stdio/stdio.c
deleted file mode 100644
index d485da20fbb..00000000000
--- a/lib/libpthread/stdio/stdio.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)stdio.c 5.3 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: stdio.c,v 1.1 1995/10/18 08:43:09 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdio.h>
-#include "local.h"
-
-/*
- * Small standard I/O/seek/close functions.
- * These maintain the `known seek offset' for seek optimisation.
- */
-int __sread(FILE *fp, char *buf, int n)
-{
- register int ret;
-
- /* if the read succeeded, update the current offset */
- if ((ret = fd_table[fp->_file]->ops->read(fd_table[fp->_file]->fd,
- fd_table[fp->_file]->flags, buf, n)) >= 0) {
- fp->_offset += ret;
- } else {
- fp->_flags &= ~__SOFF; /* paranoia */
- }
- return (ret);
-}
-
-int __swrite(FILE *fp, const char *buf, int n)
-{
- if (fp->_flags & __SAPP)
- (void) lseek(fp->_file, (off_t)0, SEEK_END);
- fp->_flags &= ~__SOFF; /* in case FAPPEND mode is set */
- return(fd_table[fp->_file]->ops->write(fd_table[fp->_file]->fd,
- fd_table[fp->_file]->flags, buf, n));
-}
-
-fpos_t __sseek(FILE *fp, fpos_t offset, int whence)
-{
- register off_t ret;
-
- ret = lseek(fp->_file, (off_t)offset, whence);
- if (ret == -1L)
- fp->_flags &= ~__SOFF;
- else {
- fp->_flags |= __SOFF;
- fp->_offset = ret;
- }
- return (ret);
-}
-
-int __sclose(FILE *fp)
-{
- return (close(fp->_file));
-}
diff --git a/lib/libpthread/stdio/strerror.c b/lib/libpthread/stdio/strerror.c
deleted file mode 100644
index 5aea7e7a4fc..00000000000
--- a/lib/libpthread/stdio/strerror.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 1988 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strerror.c 5.6 (Berkeley) 5/4/91";
-#endif /* LIBC_SCCS and not lint */
-
-#include <string.h>
-
-char *
-strerror(num)
- int num;
-{
- extern int sys_nerr;
- extern char *sys_errlist[];
-#define UPREFIX "Unknown error: "
- static char ebuf[40] = UPREFIX; /* 64-bit number + slop */
- register unsigned int errnum;
- register char *p, *t;
- char tmp[40];
-
- errnum = num; /* convert to unsigned */
- if (errnum < sys_nerr)
- return(sys_errlist[errnum]);
-
- /* Do this by hand, so we don't include stdio(3). */
- t = tmp;
- do {
- *t++ = "0123456789"[errnum % 10];
- } while (errnum /= 10);
- for (p = ebuf + sizeof(UPREFIX) - 1;;) {
- *p++ = *--t;
- if (t <= tmp)
- break;
- }
- return(ebuf);
-}
diff --git a/lib/libpthread/stdio/tempnam.c b/lib/libpthread/stdio/tempnam.c
deleted file mode 100644
index 4a8107a05ff..00000000000
--- a/lib/libpthread/stdio/tempnam.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 1988 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)tempnam.c 5.1 (Berkeley) 2/22/91";*/
-static char *rcsid = "$Id: tempnam.c,v 1.4 1998/07/21 13:54:04 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/param.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-/* #include <paths.h> */
-
-char *
-tempnam(dir, pfx)
- const char *dir, *pfx;
-{
- int sverrno;
- char *f, *name;
-
- if (!(name = malloc(MAXPATHLEN)))
- return(NULL);
-
- if (!pfx)
- pfx = "tmp.";
-
- if ((issetugid() == 0) && (f = getenv("TMPDIR"))) {
- (void)snprintf(name, MAXPATHLEN, "%s%s%sXXXXXX", f,
- *(f + strlen(f) - 1) == '/'? "": "/", pfx);
- if (f = mktemp(name))
- return(f);
- }
-
- if (f = (char *)dir) {
- (void)snprintf(name, MAXPATHLEN, "%s%s%sXXXXXX", f,
- *(f + strlen(f) - 1) == '/'? "": "/", pfx);
- if (f = mktemp(name))
- return(f);
- }
-
- f = P_tmpdir;
- (void)snprintf(name, MAXPATHLEN, "%s%sXXXXXX", f, pfx);
- if (f = mktemp(name))
- return(f);
-
- f = _PATH_TMP;
- (void)snprintf(name, MAXPATHLEN, "%s%sXXXXXX", f, pfx);
- if (f = mktemp(name))
- return(f);
-
- sverrno = errno;
- free(name);
- errno = sverrno;
- return(NULL);
-}
diff --git a/lib/libpthread/stdio/tmpfile.c b/lib/libpthread/stdio/tmpfile.c
deleted file mode 100644
index 1e0fcfe60ce..00000000000
--- a/lib/libpthread/stdio/tmpfile.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)tmpfile.c 5.4 (Berkeley) 5/27/91";*/
-static char *rcsid = "$Id: tmpfile.c,v 1.1 1995/10/18 08:43:09 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#include <signal.h>
-#include <unistd.h>
-#include <errno.h>
-#include <stdio.h>
-#include <paths.h>
-
-FILE *
-tmpfile()
-{
- sigset_t set, oset;
- FILE *fp;
- int fd, sverrno;
-#define TRAILER "tmp.XXXXXX"
- char buf[sizeof(_PATH_TMP) + sizeof(TRAILER)];
-
- bcopy(_PATH_TMP, buf, sizeof(_PATH_TMP) - 1);
- bcopy(TRAILER, buf + sizeof(_PATH_TMP) - 1, sizeof(TRAILER));
-
- sigfillset(&set);
- (void)sigprocmask(SIG_BLOCK, &set, &oset);
-
- fd = mkstemp(buf);
- if (fd != -1)
- (void)unlink(buf);
-
- (void)sigprocmask(SIG_SETMASK, &oset, NULL);
-
- if (fd == -1)
- return (NULL);
-
- if (!(fp = fdopen(fd, "w+"))) {
- sverrno = errno;
- (void)close(fd);
- errno = sverrno;
- return (NULL);
- }
- return (fp);
-}
diff --git a/lib/libpthread/stdio/tmpnam.c b/lib/libpthread/stdio/tmpnam.c
deleted file mode 100644
index c5001e29c6f..00000000000
--- a/lib/libpthread/stdio/tmpnam.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)tmpnam.c 5.3 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: tmpnam.c,v 1.1 1995/10/18 08:43:09 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <unistd.h>
-#include <stdio.h>
-
-char *
-tmpnam(s)
- char *s;
-{
- static char buf[L_tmpnam];
-
- if (s == NULL)
- s = buf;
- (void)snprintf(s, L_tmpnam, "%stmp.XXXXXX", P_tmpdir);
- return(mktemp(s));
-}
diff --git a/lib/libpthread/stdio/ungetc.c b/lib/libpthread/stdio/ungetc.c
deleted file mode 100644
index 6366050da70..00000000000
--- a/lib/libpthread/stdio/ungetc.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)ungetc.c 5.6 (Berkeley) 5/4/91";*/
-static char *rcsid = "$Id: ungetc.c,v 1.1 1995/10/18 08:43:09 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "local.h"
-
-/*
- * Expand the ungetc buffer `in place'. That is, adjust fp->_p when
- * the buffer moves, so that it points the same distance from the end,
- * and move the bytes in the buffer around as necessary so that they
- * are all at the end (stack-style).
- */
-static
-__submore(fp)
- register FILE *fp;
-{
- register int i;
- register unsigned char *p;
-
- if (fp->_ub._base == fp->_ubuf) {
- /*
- * Get a new buffer (rather than expanding the old one).
- */
- if ((p = malloc((size_t)BUFSIZ)) == NULL)
- return (EOF);
- fp->_ub._base = p;
- fp->_ub._size = BUFSIZ;
- p += BUFSIZ - sizeof(fp->_ubuf);
- for (i = sizeof(fp->_ubuf); --i >= 0;)
- p[i] = fp->_ubuf[i];
- fp->_p = p;
- return (0);
- }
- i = fp->_ub._size;
- p = realloc(fp->_ub._base, i << 1);
- if (p == NULL)
- return (EOF);
- (void) bcopy((void *)p, (void *)(p + i), (size_t)i);
- fp->_p = p + i;
- fp->_ub._base = p;
- fp->_ub._size = i << 1;
- return (0);
-}
-
-ungetc(c, fp)
- int c;
- register FILE *fp;
-{
- if (c == EOF)
- return (EOF);
- pthread_once(&__sdidinit, __sinit);
-
- flockfile(fp);
- if ((fp->_flags & __SRD) == 0) {
- /*
- * Not already reading: no good unless reading-and-writing.
- * Otherwise, flush any current write stuff.
- */
- if ((fp->_flags & __SRW) == 0)
- c = EOF;
- goto ungetc_end;
- if (fp->_flags & __SWR) {
- if (__sflush(fp))
- c = EOF;
- goto ungetc_end;
- fp->_flags &= ~__SWR;
- fp->_w = 0;
- fp->_lbfsize = 0;
- }
- fp->_flags |= __SRD;
- }
- c = (unsigned char)c;
-
- /*
- * If we are in the middle of ungetc'ing, just continue.
- * This may require expanding the current ungetc buffer.
- */
- if (HASUB(fp)) {
- if (fp->_r >= fp->_ub._size && __submore(fp))
- return (EOF);
- *--fp->_p = c;
- fp->_r++;
- goto ungetc_end;
- }
-
- /*
- * If we can handle this by simply backing up, do so,
- * but never replace the original character.
- * (This makes sscanf() work when scanning `const' data.)
- */
- if (fp->_bf._base != NULL && fp->_p > fp->_bf._base &&
- fp->_p[-1] == c) {
- fp->_p--;
- fp->_r++;
- goto ungetc_end;
- }
-
- /*
- * Create an ungetc buffer.
- * Initially, we will use the `reserve' buffer.
- */
- fp->_ur = fp->_r;
- fp->_up = fp->_p;
- fp->_ub._base = fp->_ubuf;
- fp->_ub._size = sizeof(fp->_ubuf);
- fp->_ubuf[sizeof(fp->_ubuf) - 1] = c;
- fp->_p = &fp->_ubuf[sizeof(fp->_ubuf) - 1];
- fp->_r = 1;
-
-ungetc_end:;
- funlockfile(fp);
- return (c);
-}
diff --git a/lib/libpthread/stdio/vfprintf.c b/lib/libpthread/stdio/vfprintf.c
deleted file mode 100644
index c246e417980..00000000000
--- a/lib/libpthread/stdio/vfprintf.c
+++ /dev/null
@@ -1,774 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)vfprintf.c 5.50 (Berkeley) 12/16/92";*/
-static char *rcsid = "$Id: vfprintf.c,v 1.1 1995/10/18 08:43:09 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-/*
- * Actual printf innards.
- *
- * This code is large and complicated...
- */
-
-#include <pthread.h>
-#include <sys/types.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "local.h"
-#include "fvwrite.h"
-
-/* Define FLOATING_POINT to get floating point. */
-#define FLOATING_POINT
-
-/*
- * Flush out all the vectors defined by the given uio,
- * then reset it so that it can be reused.
- */
-static int
-__sprint(fp, uio)
- register FILE* fp;
- register struct __suio *uio;
-{
- register int err;
-
- if (uio->uio_resid == 0) {
- uio->uio_iovcnt = 0;
- return (0);
- }
- err = __sfvwrite(fp, uio);
- uio->uio_resid = 0;
- uio->uio_iovcnt = 0;
- return (err);
-}
-
-/*
- * Helper function for `fprintf to unbuffered unix file': creates a
- * temporary buffer. We only work on write-only files; this avoids
- * worries about ungetc buffers and so forth.
- */
-static int
-__sbprintf(fp, fmt, ap)
- FILE *fp;
- const char *fmt;
- va_list ap;
-{
- unsigned char buf[BUFSIZ];
- FILE fake;
- int ret;
-
- /* copy the important variables */
- fake._flags = fp->_flags & ~__SNBF;
- fake._file = fp->_file;
-
- /* set up the buffer */
- fake._bf._base = fake._p = buf;
- fake._bf._size = fake._w = sizeof(buf);
- fake._lbfsize = 0; /* not actually used, but Just In Case */
-
- /* do the work, then copy any error status */
- ret = vfprintf(&fake, fmt, ap);
- if (ret >= 0 && fflush(&fake))
- ret = EOF;
- if (fake._flags & __SERR)
- fp->_flags |= __SERR;
- return (ret);
-}
-
-
-#ifdef FLOATING_POINT
-#include <locale.h>
-#include <math.h>
-#include "floatio.h"
-
-#define BUF (MAXEXP+MAXFRACT+1) /* + decimal point */
-#define DEFPREC 6
-
-static char *cvt __P((double, int, int, char *, int *, int, int *));
-static int exponent __P((char *, int, int));
-
-#else /* no FLOATING_POINT */
-
-#define BUF 40
-
-#endif /* FLOATING_POINT */
-
-
-/*
- * Macros for converting digits to letters and vice versa
- */
-#define to_digit(c) ((c) - '0')
-#define is_digit(c) ((unsigned)to_digit(c) <= 9)
-#define to_char(n) ((n) + '0')
-
-/*
- * Flags used during conversion.
- */
-#define ALT 0x001 /* alternate form */
-#define HEXPREFIX 0x002 /* add 0x or 0X prefix */
-#define LADJUST 0x004 /* left adjustment */
-#define LONGDBL 0x008 /* long double; unimplemented */
-#define LONGINT 0x010 /* long integer */
-#define QUADINT 0x020 /* quad integer */
-#define SHORTINT 0x040 /* short integer */
-#define ZEROPAD 0x080 /* zero (as opposed to blank) pad */
-#define FPT 0x100 /* Floating point number */
-int
-vfprintf(fp, fmt0, ap)
- FILE *fp;
- const char *fmt0;
- va_list ap;
-{
- register char *fmt; /* format string */
- register int ch; /* character from fmt */
- register int n; /* handy integer (short term usage) */
- register char *cp; /* handy char pointer (short term usage) */
- register struct __siov *iovp;/* for PRINT macro */
- register int flags; /* flags as above */
- int ret; /* return value accumulator */
- int width; /* width from format (%8d), or 0 */
- int prec; /* precision from format (%.3d), or -1 */
- char sign; /* sign prefix (' ', '+', '-', or \0) */
-#ifdef FLOATING_POINT
- char softsign; /* temporary negative sign for floats */
- double _double; /* double precision arguments %[eEfgG] */
- int expt; /* integer value of exponent */
- int expsize; /* character count for expstr */
- int ndig; /* actual number of digits returned by cvt */
- char expstr[7]; /* buffer for exponent string */
-#endif
-
-#ifdef __GNUC__ /* gcc has builtin quad type (long long) SOS */
-#define quad_t long long
-#define u_quad_t unsigned long long
-#endif
-
- u_quad_t _uquad; /* integer arguments %[diouxX] */
- enum { OCT, DEC, HEX } base;/* base for [diouxX] conversion */
- int dprec; /* a copy of prec if [diouxX], 0 otherwise */
- int fieldsz; /* field size expanded by sign, etc */
- int realsz; /* field size expanded by dprec */
- int size; /* size of converted field or string */
- char *xdigs; /* digits for [xX] conversion */
-#define NIOV 8
- struct __suio uio; /* output information: summary */
- struct __siov iov[NIOV];/* ... and individual io vectors */
- char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */
- char ox[2]; /* space for 0x hex-prefix */
-
- /*
- * Choose PADSIZE to trade efficiency vs. size. If larger printf
- * fields occur frequently, increase PADSIZE and make the initialisers
- * below longer.
- */
-#define PADSIZE 16 /* pad chunk size */
- static char blanks[PADSIZE] =
- {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
- static char zeroes[PADSIZE] =
- {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'};
-
- /*
- * BEWARE, these `goto error' on error, and PAD uses `n'.
- */
-#define PRINT(ptr, len) { \
- iovp->iov_base = (ptr); \
- iovp->iov_len = (len); \
- uio.uio_resid += (len); \
- iovp++; \
- if (++uio.uio_iovcnt >= NIOV) { \
- if (__sprint(fp, &uio)) \
- goto error; \
- iovp = iov; \
- } \
-}
-#define PAD(howmany, with) { \
- if ((n = (howmany)) > 0) { \
- while (n > PADSIZE) { \
- PRINT(with, PADSIZE); \
- n -= PADSIZE; \
- } \
- PRINT(with, n); \
- } \
-}
-#define FLUSH() { \
- if (uio.uio_resid && __sprint(fp, &uio)) \
- goto error; \
- uio.uio_iovcnt = 0; \
- iovp = iov; \
-}
-
- /*
- * To extend shorts properly, we need both signed and unsigned
- * argument extraction methods.
- */
-#define SARG() \
- (flags&QUADINT ? va_arg(ap, quad_t) : \
- flags&LONGINT ? va_arg(ap, long) : \
- flags&SHORTINT ? (long)(short)va_arg(ap, int) : \
- (long)va_arg(ap, int))
-#define UARG() \
- (flags&QUADINT ? va_arg(ap, u_quad_t) : \
- flags&LONGINT ? va_arg(ap, u_long) : \
- flags&SHORTINT ? (u_long)(u_short)va_arg(ap, int) : \
- (u_long)va_arg(ap, u_int))
-
- flockfile(fp);
-
- /* sorry, fprintf(read_only_file, "") returns EOF, not 0 */
- if (cantwrite(fp))
- return (EOF);
-
- /* optimise fprintf(stderr) (and other unbuffered Unix files) */
- if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) &&
- fp->_file >= 0) {
- ret = (__sbprintf(fp, fmt0, ap));
- funlockfile(fp);
- return(ret);
- }
-
- fmt = (char *)fmt0;
- uio.uio_iov = iovp = iov;
- uio.uio_resid = 0;
- uio.uio_iovcnt = 0;
- ret = 0;
-
- /*
- * Scan the format for conversions (`%' character).
- */
- for (;;) {
- for (cp = fmt; (ch = *fmt) != '\0' && ch != '%'; fmt++)
- /* void */;
- if ((n = fmt - cp) != 0) {
- PRINT(cp, n);
- ret += n;
- }
- if (ch == '\0')
- goto done;
- fmt++; /* skip over '%' */
-
- flags = 0;
- dprec = 0;
- width = 0;
- prec = -1;
- sign = '\0';
-
-rflag: ch = *fmt++;
-reswitch: switch (ch) {
- case ' ':
- /*
- * ``If the space and + flags both appear, the space
- * flag will be ignored.''
- * -- ANSI X3J11
- */
- if (!sign)
- sign = ' ';
- goto rflag;
- case '#':
- flags |= ALT;
- goto rflag;
- case '*':
- /*
- * ``A negative field width argument is taken as a
- * - flag followed by a positive field width.''
- * -- ANSI X3J11
- * They don't exclude field widths read from args.
- */
- if ((width = va_arg(ap, int)) >= 0)
- goto rflag;
- width = -width;
- /* FALLTHROUGH */
- case '-':
- flags |= LADJUST;
- goto rflag;
- case '+':
- sign = '+';
- goto rflag;
- case '.':
- if ((ch = *fmt++) == '*') {
- n = va_arg(ap, int);
- prec = n < 0 ? -1 : n;
- goto rflag;
- }
- n = 0;
- while (is_digit(ch)) {
- n = 10 * n + to_digit(ch);
- ch = *fmt++;
- }
- prec = n < 0 ? -1 : n;
- goto reswitch;
- case '0':
- /*
- * ``Note that 0 is taken as a flag, not as the
- * beginning of a field width.''
- * -- ANSI X3J11
- */
- flags |= ZEROPAD;
- goto rflag;
- case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- n = 0;
- do {
- n = 10 * n + to_digit(ch);
- ch = *fmt++;
- } while (is_digit(ch));
- width = n;
- goto reswitch;
-#ifdef FLOATING_POINT
- case 'L':
- flags |= LONGDBL;
- goto rflag;
-#endif
- case 'h':
- flags |= SHORTINT;
- goto rflag;
- case 'l':
- flags |= LONGINT;
- goto rflag;
- case 'q':
- flags |= QUADINT;
- goto rflag;
- case 'c':
- *(cp = buf) = va_arg(ap, int);
- size = 1;
- sign = '\0';
- break;
- case 'D':
- flags |= LONGINT;
- /*FALLTHROUGH*/
- case 'd':
- case 'i':
- _uquad = SARG();
- if ((quad_t)_uquad < 0) {
- _uquad = -_uquad;
- sign = '-';
- }
- base = DEC;
- goto number;
-#ifdef FLOATING_POINT
- case 'e':
- case 'E':
- case 'f':
- case 'g':
- case 'G':
- if (prec == -1) {
- prec = DEFPREC;
- } else if ((ch == 'g' || ch == 'G') && prec == 0) {
- prec = 1;
- }
-
- if (flags & LONGDBL) {
- _double = (double) va_arg(ap, long double);
- } else {
- _double = va_arg(ap, double);
- }
-
- /* do this before tricky precision changes */
- /* if (isinf(_double)) {
- if (_double < 0)
- sign = '-';
- cp = "Inf";
- size = 3;
- break;
- } */
-/* if (isnan(_double)) {
- cp = "NaN";
- size = 3;
- break;
- } */
-
- flags |= FPT;
- cp = cvt(_double, prec, flags, &softsign,
- &expt, ch, &ndig);
- if (ch == 'g' || ch == 'G') {
- if (expt <= -4 || expt > prec)
- ch = (ch == 'g') ? 'e' : 'E';
- else
- ch = 'g';
- }
- if (ch <= 'e') { /* 'e' or 'E' fmt */
- --expt;
- expsize = exponent(expstr, expt, ch);
- size = expsize + ndig;
- if (ndig > 1 || flags & ALT)
- ++size;
- } else if (ch == 'f') { /* f fmt */
- if (expt > 0) {
- size = expt;
- if (prec || flags & ALT)
- size += prec + 1;
- } else /* "0.X" */
- size = prec + 2;
- } else if (expt >= ndig) { /* fixed g fmt */
- size = expt;
- if (flags & ALT)
- ++size;
- } else
- size = ndig + (expt > 0 ?
- 1 : 2 - expt);
-
- if (softsign)
- sign = '-';
- break;
-#endif /* FLOATING_POINT */
- case 'n':
- if (flags & QUADINT)
- *va_arg(ap, quad_t *) = ret;
- else if (flags & LONGINT)
- *va_arg(ap, long *) = ret;
- else if (flags & SHORTINT)
- *va_arg(ap, short *) = ret;
- else
- *va_arg(ap, int *) = ret;
- continue; /* no output */
- case 'O':
- flags |= LONGINT;
- /*FALLTHROUGH*/
- case 'o':
- _uquad = UARG();
- base = OCT;
- goto nosign;
- case 'p':
- /*
- * ``The argument shall be a pointer to void. The
- * value of the pointer is converted to a sequence
- * of printable characters, in an implementation-
- * defined manner.''
- * -- ANSI X3J11
- */
- /* NOSTRICT */
- _uquad = (u_quad_t)va_arg(ap, void *);
- base = HEX;
- xdigs = "0123456789abcdef";
- flags |= HEXPREFIX;
- ch = 'x';
- goto nosign;
- case 's':
- if ((cp = va_arg(ap, char *)) == NULL)
- cp = "(null)";
- if (prec >= 0) {
- /*
- * can't use strlen; can only look for the
- * NUL in the first `prec' characters, and
- * strlen() will go further.
- */
- char *p = memchr(cp, 0, prec);
-
- if (p != NULL) {
- size = p - cp;
- if (size > prec)
- size = prec;
- } else
- size = prec;
- } else
- size = strlen(cp);
- sign = '\0';
- break;
- case 'U':
- flags |= LONGINT;
- /*FALLTHROUGH*/
- case 'u':
- _uquad = UARG();
- base = DEC;
- goto nosign;
- case 'X':
- xdigs = "0123456789ABCDEF";
- goto hex;
- case 'x':
- xdigs = "0123456789abcdef";
-hex: _uquad = UARG();
- base = HEX;
- /* leading 0x/X only if non-zero */
- if (flags & ALT && _uquad != 0)
- flags |= HEXPREFIX;
-
- /* unsigned conversions */
-nosign: sign = '\0';
- /*
- * ``... diouXx conversions ... if a precision is
- * specified, the 0 flag will be ignored.''
- * -- ANSI X3J11
- */
-number: if ((dprec = prec) >= 0)
- flags &= ~ZEROPAD;
-
- /*
- * ``The result of converting a zero value with an
- * explicit precision of zero is no characters.''
- * -- ANSI X3J11
- */
- cp = buf + BUF;
- if (_uquad != 0 || prec != 0) {
- /*
- * Unsigned mod is hard, and unsigned mod
- * by a constant is easier than that by
- * a variable; hence this switch.
- */
- switch (base) {
- case OCT:
- do {
- *--cp = to_char(_uquad & 7);
- _uquad >>= 3;
- } while (_uquad);
- /* handle octal leading 0 */
- if (flags & ALT && *cp != '0')
- *--cp = '0';
- break;
-
- case DEC:
- /* many numbers are 1 digit */
- while (_uquad >= 10) {
- *--cp = to_char(_uquad % 10);
- _uquad /= 10;
- }
- *--cp = to_char(_uquad);
- break;
-
- case HEX:
- do {
- *--cp = xdigs[_uquad & 15];
- _uquad >>= 4;
- } while (_uquad);
- break;
-
- default:
- cp = "bug in vfprintf: bad base";
- size = strlen(cp);
- goto skipsize;
- }
- }
- size = buf + BUF - cp;
- skipsize:
- break;
- default: /* "%?" prints ?, unless ? is NUL */
- if (ch == '\0')
- goto done;
- /* pretend it was %c with argument ch */
- cp = buf;
- *cp = ch;
- size = 1;
- sign = '\0';
- break;
- }
-
- /*
- * All reasonable formats wind up here. At this point, `cp'
- * points to a string which (if not flags&LADJUST) should be
- * padded out to `width' places. If flags&ZEROPAD, it should
- * first be prefixed by any sign or other prefix; otherwise,
- * it should be blank padded before the prefix is emitted.
- * After any left-hand padding and prefixing, emit zeroes
- * required by a decimal [diouxX] precision, then print the
- * string proper, then emit zeroes required by any leftover
- * floating precision; finally, if LADJUST, pad with blanks.
- *
- * Compute actual size, so we know how much to pad.
- * fieldsz excludes decimal prec; realsz includes it.
- */
- fieldsz = size;
- if (sign)
- fieldsz++;
- else if (flags & HEXPREFIX)
- fieldsz += 2;
- realsz = dprec > fieldsz ? dprec : fieldsz;
-
- /* right-adjusting blank padding */
- if ((flags & (LADJUST|ZEROPAD)) == 0)
- PAD(width - realsz, blanks);
-
- /* prefix */
- if (sign) {
- PRINT(&sign, 1);
- } else if (flags & HEXPREFIX) {
- ox[0] = '0';
- ox[1] = ch;
- PRINT(ox, 2);
- }
-
- /* right-adjusting zero padding */
- if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD)
- PAD(width - realsz, zeroes);
-
- /* leading zeroes from decimal precision */
- PAD(dprec - fieldsz, zeroes);
-
- /* the string or number proper */
-#ifdef FLOATING_POINT
- if ((flags & FPT) == 0) {
- PRINT(cp, size);
- } else { /* glue together f_p fragments */
- if (ch >= 'f') { /* 'f' or 'g' */
- if (_double == 0) {
- /* kludge for __dtoa irregularity */
- if (expt >= ndig && (flags & ALT) == 0) {
- PRINT("0", 1);
- } else {
- PRINT("0.", 2);
- PAD(ndig - 1, zeroes);
- }
- } else if (expt <= 0) {
- PRINT("0.", 2);
- PAD(-expt, zeroes);
- PRINT(cp, ndig);
- } else if (expt >= ndig) {
- PRINT(cp, ndig);
- PAD(expt - ndig, zeroes);
- if (flags & ALT)
- PRINT(".", 1);
- } else {
- PRINT(cp, expt);
- cp += expt;
- PRINT(".", 1);
- PRINT(cp, ndig-expt);
- }
- } else { /* 'e' or 'E' */
- if (ndig > 1 || flags & ALT) {
- ox[0] = *cp++;
- ox[1] = '.';
- PRINT(ox, 2);
- if (_double || flags & ALT == 0) {
- PRINT(cp, ndig-1);
- } else /* 0.[0..] */
- /* __dtoa irregularity */
- PAD(ndig - 1, zeroes);
- } else /* XeYYY */
- PRINT(cp, 1);
- PRINT(expstr, expsize);
- }
- }
-#else
- PRINT(cp, size);
-#endif
- /* left-adjusting padding (always blank) */
- if (flags & LADJUST)
- PAD(width - realsz, blanks);
-
- /* finally, adjust ret */
- ret += width > realsz ? width : realsz;
-
- FLUSH(); /* copy out the I/O vectors */
- }
-done:
- FLUSH();
-error:
- if (__sferror(fp))
- ret = EOF;
- funlockfile(fp);
- return (ret);
-}
-
-#ifdef FLOATING_POINT
-
-extern char *__dtoa __P((double, int, int, int *, int *, char **));
-
-static char *
-cvt(value, ndigits, flags, sign, decpt, ch, length)
- double value;
- int ndigits, flags, *decpt, ch, *length;
- char *sign;
-{
- int mode, dsgn;
- char *digits, *bp, *rve;
-
- if (ch == 'f') {
- mode = 3; /* ndigits after the decimal point */
- } else {
- /* To obtain ndigits after the decimal point for the 'e'
- * and 'E' formats, round to ndigits + 1 significant
- * figures.
- */
- if (ch == 'e' || ch == 'E') {
- ndigits++;
- }
- mode = 2; /* ndigits significant digits */
- }
-
- if (value < 0) {
- value = -value;
- *sign = '-';
- } else
- *sign = '\000';
- digits = __dtoa(value, mode, ndigits, decpt, &dsgn, &rve);
- if ((ch != 'g' && ch != 'G') || flags & ALT) { /* Print trailing zeros */
- bp = digits + ndigits;
- if (ch == 'f') {
- if (*digits == '0' && value)
- *decpt = -ndigits + 1;
- bp += *decpt;
- }
- if (value == 0) /* kludge for __dtoa irregularity */
- rve = bp;
- while (rve < bp)
- *rve++ = '0';
- }
- *length = rve - digits;
- return (digits);
-}
-
-static int
-exponent(p0, exp, fmtch)
- char *p0;
- int exp, fmtch;
-{
- register char *p, *t;
- char expbuf[MAXEXP];
-
- p = p0;
- *p++ = fmtch;
- if (exp < 0) {
- exp = -exp;
- *p++ = '-';
- }
- else
- *p++ = '+';
- t = expbuf + MAXEXP;
- if (exp > 9) {
- do {
- *--t = to_char(exp % 10);
- } while ((exp /= 10) > 9);
- *--t = to_char(exp);
- for (; t < expbuf + MAXEXP; *p++ = *t++);
- }
- else {
- *p++ = '0';
- *p++ = to_char(exp);
- }
- return (p - p0);
-}
-#endif /* FLOATING_POINT */
diff --git a/lib/libpthread/stdio/vfscanf.c b/lib/libpthread/stdio/vfscanf.c
deleted file mode 100644
index 723e37c5a7a..00000000000
--- a/lib/libpthread/stdio/vfscanf.c
+++ /dev/null
@@ -1,750 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * Copyright (c) 1993, 1994 Chris Provenzano.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)vfscanf.c 5.7 (Berkeley) 12/14/92";*/
-static char *rcsid = "$Id: vfscanf.c,v 1.3 1998/07/21 13:54:05 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-#include "local.h"
-
-#define FLOATING_POINT
-
-#include "floatio.h"
-#define BUF 513 /* Maximum length of numeric string. */
-
-/*
- * Flags used during conversion.
- */
-#define LONG 0x01 /* l: long or double */
-#define LONGDBL 0x02 /* L: long double; unimplemented */
-#define SHORT 0x04 /* h: short */
-#define SUPPRESS 0x08 /* suppress assignment */
-#define POINTER 0x10 /* weird %p pointer (`fake hex') */
-#define NOSKIP 0x20 /* do not skip blanks */
-
-/*
- * The following are used in numeric conversions only:
- * SIGNOK, NDIGITS, DPTOK, and EXPOK are for floating point;
- * SIGNOK, NDIGITS, PFXOK, and NZDIGITS are for integral.
- */
-#define SIGNOK 0x40 /* +/- is (still) legal */
-#define NDIGITS 0x80 /* no digits detected */
-
-#define DPTOK 0x100 /* (float) decimal point is still legal */
-#define EXPOK 0x200 /* (float) exponent (e+3, etc) still legal */
-
-#define PFXOK 0x100 /* 0x prefix is (still) legal */
-#define NZDIGITS 0x200 /* no zero digits detected */
-
-/*
- * Conversion types.
- */
-#define CT_CHAR 0 /* %c conversion */
-#define CT_CCL 1 /* %[...] conversion */
-#define CT_STRING 2 /* %s conversion */
-#define CT_INT 3 /* integer, i.e., strtol or strtoul */
-#define CT_FLOAT 4 /* floating, i.e., strtod */
-
-#define u_char unsigned char
-#define u_long unsigned long
-
-static u_char *__sccl();
-
-/*
- * vfscanf
- */
-__svfscanf(fp, fmt0, ap)
- register FILE *fp;
- char const *fmt0;
- pthread_va_list ap;
-{
- register u_char *fmt = (u_char *)fmt0;
- register int c; /* character from format, or conversion */
- register size_t width; /* field width, or 0 */
- register char *p; /* points into all kinds of strings */
- register int n; /* handy integer */
- register int flags; /* flags as defined above */
- register char *p0; /* saves original value of p when necessary */
- int nassigned; /* number of fields assigned */
- int nread; /* number of characters consumed from fp */
- int base; /* base argument to strtol/strtoul */
- u_long (*ccfn)(); /* conversion function (strtol/strtoul) */
- char ccltab[256]; /* character class table for %[...] */
- char buf[BUF]; /* buffer for numeric conversions */
-
- /* `basefix' is used to avoid `if' tests in the integer scanner */
- static short basefix[17] =
- { 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
-
- nassigned = 0;
- nread = 0;
- base = 0; /* XXX just to keep gcc happy */
- ccfn = NULL; /* XXX just to keep gcc happy */
- for (;;) {
- c = *fmt++;
- if (c == 0)
- return (nassigned);
- if (isspace(c)) {
- for (;;) {
- if (fp->_r <= 0 && __srefill(fp))
- return (nassigned);
- if (!isspace(*fp->_p))
- break;
- nread++, fp->_r--, fp->_p++;
- }
- continue;
- }
- if (c != '%')
- goto literal;
- width = 0;
- flags = 0;
- /*
- * switch on the format. continue if done;
- * break once format type is derived.
- */
-again: c = *fmt++;
- switch (c) {
- case '%':
-literal:
- if (fp->_r <= 0 && __srefill(fp))
- goto input_failure;
- if (*fp->_p != c)
- goto match_failure;
- fp->_r--, fp->_p++;
- nread++;
- continue;
-
- case '*':
- flags |= SUPPRESS;
- goto again;
- case 'l':
- flags |= LONG;
- goto again;
- case 'L':
- flags |= LONGDBL;
- goto again;
- case 'h':
- flags |= SHORT;
- goto again;
-
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- width = width * 10 + c - '0';
- goto again;
-
- /*
- * Conversions.
- * Those marked `compat' are for 4.[123]BSD compatibility.
- *
- * (According to ANSI, E and X formats are supposed
- * to the same as e and x. Sorry about that.)
- */
- case 'D': /* compat */
- flags |= LONG;
- /* FALLTHROUGH */
- case 'd':
- c = CT_INT;
- ccfn = (u_long (*)())strtol;
- base = 10;
- break;
-
- case 'i':
- c = CT_INT;
- ccfn = (u_long (*)())strtol;
- base = 0;
- break;
-
- case 'O': /* compat */
- flags |= LONG;
- /* FALLTHROUGH */
- case 'o':
- c = CT_INT;
- ccfn = strtoul;
- base = 8;
- break;
-
- case 'u':
- c = CT_INT;
- ccfn = strtoul;
- base = 10;
- break;
-
- case 'X': /* compat XXX */
- flags |= LONG;
- /* FALLTHROUGH */
- case 'x':
- flags |= PFXOK; /* enable 0x prefixing */
- c = CT_INT;
- ccfn = strtoul;
- base = 16;
- break;
-
-#ifdef FLOATING_POINT
- case 'E': /* compat XXX */
- case 'F': /* compat */
- flags |= LONG;
- /* FALLTHROUGH */
- case 'e': case 'f': case 'g':
- c = CT_FLOAT;
- break;
-#endif
-
- case 's':
- c = CT_STRING;
- break;
-
- case '[':
- fmt = __sccl(ccltab, fmt);
- flags |= NOSKIP;
- c = CT_CCL;
- break;
-
- case 'c':
- flags |= NOSKIP;
- c = CT_CHAR;
- break;
-
- case 'p': /* pointer format is like hex */
- flags |= POINTER | PFXOK;
- c = CT_INT;
- ccfn = strtoul;
- base = 16;
- break;
-
- case 'n':
- if (flags & SUPPRESS) /* ??? */
- continue;
- if (flags & SHORT)
- *va_arg(ap, short *) = nread;
- else if (flags & LONG)
- *va_arg(ap, long *) = nread;
- else
- *va_arg(ap, int *) = nread;
- continue;
-
- /*
- * Disgusting backwards compatibility hacks. XXX
- */
- case '\0': /* compat */
- return (EOF);
-
- default: /* compat */
- if (isupper(c))
- flags |= LONG;
- c = CT_INT;
- ccfn = (u_long (*)())strtol;
- base = 10;
- break;
- }
-
- /*
- * We have a conversion that requires input.
- */
- if (fp->_r <= 0 && __srefill(fp))
- goto input_failure;
-
- /*
- * Consume leading white space, except for formats
- * that suppress this.
- */
- if ((flags & NOSKIP) == 0) {
- while (isspace(*fp->_p)) {
- nread++;
- if (--fp->_r > 0)
- fp->_p++;
- else if (__srefill(fp))
- goto input_failure;
- }
- /*
- * Note that there is at least one character in
- * the buffer, so conversions that do not set NOSKIP
- * ca no longer result in an input failure.
- */
- }
-
- /*
- * Do the conversion.
- */
- switch (c) {
-
- case CT_CHAR:
- /* scan arbitrary characters (sets NOSKIP) */
- if (width == 0)
- width = 1;
- if (flags & SUPPRESS) {
- size_t sum = 0;
- for (;;) {
- if ((n = fp->_r) < width) {
- sum += n;
- width -= n;
- fp->_p += n;
- if (__srefill(fp)) {
- if (sum == 0)
- goto input_failure;
- break;
- }
- } else {
- sum += width;
- fp->_r -= width;
- fp->_p += width;
- break;
- }
- }
- nread += sum;
- } else {
- size_t r = fread((void *)va_arg(ap, char *), 1,
- width, fp);
-
- if (r == 0)
- goto input_failure;
- nread += r;
- nassigned++;
- }
- break;
-
- case CT_CCL:
- /* scan a (nonempty) character class (sets NOSKIP) */
- if (width == 0)
- width = ~0; /* `infinity' */
- /* take only those things in the class */
- if (flags & SUPPRESS) {
- n = 0;
- while (ccltab[*fp->_p]) {
- n++, fp->_r--, fp->_p++;
- if (--width == 0)
- break;
- if (fp->_r <= 0 && __srefill(fp)) {
- if (n == 0)
- goto input_failure;
- break;
- }
- }
- if (n == 0)
- goto match_failure;
- } else {
- p0 = p = va_arg(ap, char *);
- while (ccltab[*fp->_p]) {
- fp->_r--;
- *p++ = *fp->_p++;
- if (--width == 0)
- break;
- if (fp->_r <= 0 && __srefill(fp)) {
- if (p == p0)
- goto input_failure;
- break;
- }
- }
- n = p - p0;
- if (n == 0)
- goto match_failure;
- *p = 0;
- nassigned++;
- }
- nread += n;
- break;
-
- case CT_STRING:
- /* like CCL, but zero-length string OK, & no NOSKIP */
- if (width == 0)
- width = ~0;
- if (flags & SUPPRESS) {
- n = 0;
- while (!isspace(*fp->_p)) {
- n++, fp->_r--, fp->_p++;
- if (--width == 0)
- break;
- if (fp->_r <= 0 && __srefill(fp))
- break;
- }
- nread += n;
- } else {
- p0 = p = va_arg(ap, char *);
- while (!isspace(*fp->_p)) {
- fp->_r--;
- *p++ = *fp->_p++;
- if (--width == 0)
- break;
- if (fp->_r <= 0 && __srefill(fp))
- break;
- }
- *p = 0;
- nread += p - p0;
- nassigned++;
- }
- continue;
-
- case CT_INT:
- /* scan an integer as if by strtol/strtoul */
-#ifdef hardway
- if (width == 0 || width > sizeof(buf) - 1)
- width = sizeof(buf) - 1;
-#else
- /* size_t is unsigned, hence this optimisation */
- if (--width > sizeof(buf) - 2)
- width = sizeof(buf) - 2;
- width++;
-#endif
- flags |= SIGNOK | NDIGITS | NZDIGITS;
- for (p = buf; width; width--) {
- c = *fp->_p;
- /*
- * Switch on the character; `goto ok'
- * if we accept it as a part of number.
- */
- switch (c) {
-
- /*
- * The digit 0 is always legal, but is
- * special. For %i conversions, if no
- * digits (zero or nonzero) have been
- * scanned (only signs), we will have
- * base==0. In that case, we should set
- * it to 8 and enable 0x prefixing.
- * Also, if we have not scanned zero digits
- * before this, do not turn off prefixing
- * (someone else will turn it off if we
- * have scanned any nonzero digits).
- */
- case '0':
- if (base == 0) {
- base = 8;
- flags |= PFXOK;
- }
- if (flags & NZDIGITS)
- flags &= ~(SIGNOK|NZDIGITS|NDIGITS);
- else
- flags &= ~(SIGNOK|PFXOK|NDIGITS);
- goto ok;
-
- /* 1 through 7 always legal */
- case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- base = basefix[base];
- flags &= ~(SIGNOK | PFXOK | NDIGITS);
- goto ok;
-
- /* digits 8 and 9 ok iff decimal or hex */
- case '8': case '9':
- base = basefix[base];
- if (base <= 8)
- break; /* not legal here */
- flags &= ~(SIGNOK | PFXOK | NDIGITS);
- goto ok;
-
- /* letters ok iff hex */
- case 'A': case 'B': case 'C':
- case 'D': case 'E': case 'F':
- case 'a': case 'b': case 'c':
- case 'd': case 'e': case 'f':
- /* no need to fix base here */
- if (base <= 10)
- break; /* not legal here */
- flags &= ~(SIGNOK | PFXOK | NDIGITS);
- goto ok;
-
- /* sign ok only as first character */
- case '+': case '-':
- if (flags & SIGNOK) {
- flags &= ~SIGNOK;
- goto ok;
- }
- break;
-
- /* x ok iff flag still set & 2nd char */
- case 'x': case 'X':
- if (flags & PFXOK && p == buf + 1) {
- base = 16; /* if %i */
- flags &= ~PFXOK;
- goto ok;
- }
- break;
- }
-
- /*
- * If we got here, c is not a legal character
- * for a number. Stop accumulating digits.
- */
- break;
- ok:
- /*
- * c is legal: store it and look at the next.
- */
- *p++ = c;
- if (--fp->_r > 0)
- fp->_p++;
- else if (__srefill(fp))
- break; /* EOF */
- }
- /*
- * If we had only a sign, it is no good; push
- * back the sign. If the number ends in `x',
- * it was [sign] '0' 'x', so push back the x
- * and treat it as [sign] '0'.
- */
- if (flags & NDIGITS) {
- if (p > buf)
- (void) ungetc(*(u_char *)--p, fp);
- goto match_failure;
- }
- c = ((u_char *)p)[-1];
- if (c == 'x' || c == 'X') {
- --p;
- (void) ungetc(c, fp);
- }
- if ((flags & SUPPRESS) == 0) {
- u_long res;
-
- *p = 0;
- res = (*ccfn)(buf, (char **)NULL, base);
- if (flags & POINTER)
- *va_arg(ap, void **) = (void *)res;
- else if (flags & SHORT)
- *va_arg(ap, short *) = res;
- else if (flags & LONG)
- *va_arg(ap, long *) = res;
- else
- *va_arg(ap, int *) = res;
- nassigned++;
- }
- nread += p - buf;
- break;
-
-#ifdef FLOATING_POINT
- case CT_FLOAT:
- /* scan a floating point number as if by strtod */
-#ifdef hardway
- if (width == 0 || width > sizeof(buf) - 1)
- width = sizeof(buf) - 1;
-#else
- /* size_t is unsigned, hence this optimisation */
- if (--width > sizeof(buf) - 2)
- width = sizeof(buf) - 2;
- width++;
-#endif
- flags |= SIGNOK | NDIGITS | DPTOK | EXPOK;
- for (p = buf; width; width--) {
- c = *fp->_p;
- /*
- * This code mimicks the integer conversion
- * code, but is much simpler.
- */
- switch (c) {
-
- case '0': case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- case '8': case '9':
- flags &= ~(SIGNOK | NDIGITS);
- goto fok;
-
- case '+': case '-':
- if (flags & SIGNOK) {
- flags &= ~SIGNOK;
- goto fok;
- }
- break;
- case '.':
- if (flags & DPTOK) {
- flags &= ~(SIGNOK | DPTOK);
- goto fok;
- }
- break;
- case 'e': case 'E':
- /* no exponent without some digits */
- if ((flags&(NDIGITS|EXPOK)) == EXPOK) {
- flags =
- (flags & ~(EXPOK|DPTOK)) |
- SIGNOK | NDIGITS;
- goto fok;
- }
- break;
- }
- break;
- fok:
- *p++ = c;
- if (--fp->_r > 0)
- fp->_p++;
- else if (__srefill(fp))
- break; /* EOF */
- }
- /*
- * If no digits, might be missing exponent digits
- * (just give back the exponent) or might be missing
- * regular digits, but had sign and/or decimal point.
- */
- if (flags & NDIGITS) {
- if (flags & EXPOK) {
- /* no digits at all */
- while (p > buf)
- ungetc(*(u_char *)--p, fp);
- goto match_failure;
- }
- /* just a bad exponent (e and maybe sign) */
- c = *(u_char *)--p;
- if (c != 'e' && c != 'E') {
- (void) ungetc(c, fp);/* sign */
- c = *(u_char *)--p;
- }
- (void) ungetc(c, fp);
- }
- if ((flags & SUPPRESS) == 0) {
- double res;
-
- *p = 0;
- res = strtod(buf, (char **) NULL);
- if (flags & LONG)
- *va_arg(ap, double *) = res;
- else
- *va_arg(ap, float *) = res;
- nassigned++;
- }
- nread += p - buf;
- break;
-#endif /* FLOATING_POINT */
- }
- }
-input_failure:
- return (nassigned ? nassigned : -1);
-match_failure:
- return (nassigned);
-}
-
-/*
- * Fill in the given table from the scanset at the given format
- * (just after `['). Return a pointer to the character past the
- * closing `]'. The table has a 1 wherever characters should be
- * considered part of the scanset.
- */
-static u_char *
-__sccl(tab, fmt)
- register char *tab;
- register u_char *fmt;
-{
- register int c, n, v;
-
- /* first `clear' the whole table */
- c = *fmt++; /* first char hat => negated scanset */
- if (c == '^') {
- v = 1; /* default => accept */
- c = *fmt++; /* get new first char */
- } else
- v = 0; /* default => reject */
- /* should probably use memset here */
- for (n = 0; n < 256; n++)
- tab[n] = v;
- if (c == 0)
- return (fmt - 1);/* format ended before closing ] */
-
- /*
- * Now set the entries corresponding to the actual scanset
- * to the opposite of the above.
- *
- * The first character may be ']' (or '-') without being special;
- * the last character may be '-'.
- */
- v = 1 - v;
- for (;;) {
- tab[c] = v; /* take character c */
-doswitch:
- n = *fmt++; /* and examine the next */
- switch (n) {
-
- case 0: /* format ended too soon */
- return (fmt - 1);
-
- case '-':
- /*
- * A scanset of the form
- * [01+-]
- * is defined as `the digit 0, the digit 1,
- * the character +, the character -', but
- * the effect of a scanset such as
- * [a-zA-Z0-9]
- * is implementation defined. The V7 Unix
- * scanf treats `a-z' as `the letters a through
- * z', but treats `a-a' as `the letter a, the
- * character -, and the letter a'.
- *
- * For compatibility, the `-' is not considerd
- * to define a range if the character following
- * it is either a close bracket (required by ANSI)
- * or is not numerically greater than the character
- * we just stored in the table (c).
- */
- n = *fmt;
- if (n == ']' || n < c) {
- c = '-';
- break; /* resume the for(;;) */
- }
- fmt++;
- do { /* fill in the range */
- tab[++c] = v;
- } while (c < n);
-#if 1 /* XXX another disgusting compatibility hack */
- /*
- * Alas, the V7 Unix scanf also treats formats
- * such as [a-c-e] as `the letters a through e'.
- * This too is permitted by the standard....
- */
- goto doswitch;
-#else
- c = *fmt++;
- if (c == 0)
- return (fmt - 1);
- if (c == ']')
- return (fmt);
-#endif
- break;
-
- case ']': /* end of scanset */
- return (fmt);
-
- default: /* just another character */
- c = n;
- break;
- }
- }
- /* NOTREACHED */
-}
diff --git a/lib/libpthread/stdio/vprintf.c b/lib/libpthread/stdio/vprintf.c
deleted file mode 100644
index 62655e0f438..00000000000
--- a/lib/libpthread/stdio/vprintf.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)vprintf.c 5.6 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: vprintf.c,v 1.1 1995/10/18 08:43:09 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-
-vprintf(fmt, ap)
- char const *fmt;
- va_list ap;
-{
- return (vfprintf(stdout, fmt, ap));
-}
diff --git a/lib/libpthread/stdio/vscanf.c b/lib/libpthread/stdio/vscanf.c
deleted file mode 100644
index c4c95901b47..00000000000
--- a/lib/libpthread/stdio/vscanf.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Donn Seeley at UUNET Technologies, Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)vscanf.c 5.1 (Berkeley) 4/15/91";*/
-static char *rcsid = "$Id: vscanf.c,v 1.1 1995/10/18 08:43:09 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-
-vscanf(fmt, ap)
- const char *fmt;
- va_list ap;
-{
- int r;
- flockfile(stdin);
- r = __svfscanf(stdin, fmt, ap);
- funlockfile(stdin);
- return(r);
-}
diff --git a/lib/libpthread/stdio/vsnprintf.c b/lib/libpthread/stdio/vsnprintf.c
deleted file mode 100644
index 672c86b2331..00000000000
--- a/lib/libpthread/stdio/vsnprintf.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)vsnprintf.c 5.2 (Berkeley) 2/5/91";*/
-static char *rcsid = "$Id: vsnprintf.c,v 1.1 1995/10/18 08:43:09 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-
-vsnprintf(str, n, fmt, ap)
- char *str;
- size_t n;
- const char *fmt;
- va_list ap;
-{
- int ret;
- FILE f;
-
- if ((int)n < 1)
- return (EOF);
- f._flags = __SWR | __SSTR;
- f._bf._base = f._p = (unsigned char *)str;
- f._bf._size = f._w = n - 1;
- ret = vfprintf(&f, fmt, ap);
- *f._p = 0;
- return (ret);
-}
diff --git a/lib/libpthread/stdio/vsprintf.c b/lib/libpthread/stdio/vsprintf.c
deleted file mode 100644
index d97f8b4723a..00000000000
--- a/lib/libpthread/stdio/vsprintf.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)vsprintf.c 5.5 (Berkeley) 2/5/91";*/
-static char *rcsid = "$Id: vsprintf.c,v 1.1 1995/10/18 08:43:09 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-#include <limits.h>
-
-vsprintf(str, fmt, ap)
- char *str;
- const char *fmt;
- va_list ap;
-{
- int ret;
- FILE f;
-
- f._flags = __SWR | __SSTR;
- f._bf._base = f._p = (unsigned char *)str;
- f._bf._size = f._w = INT_MAX;
- ret = vfprintf(&f, fmt, ap);
- *f._p = 0;
- return (ret);
-}
diff --git a/lib/libpthread/stdio/vsscanf.c b/lib/libpthread/stdio/vsscanf.c
deleted file mode 100644
index a639a787a7c..00000000000
--- a/lib/libpthread/stdio/vsscanf.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Donn Seeley at UUNET Technologies, Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)vsscanf.c 5.1 (Berkeley) 4/15/91";*/
-static char *rcsid = "$Id: vsscanf.c,v 1.1 1995/10/18 08:43:09 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-#include <string.h>
-
-vsscanf(str, fmt, ap)
- const char *str;
- const char *fmt;
- va_list ap;
-{
- int ret;
- FILE f;
-
- f._flags = __SRD;
- f._file = -1; /* This will do the right thing */
- f._bf._base = f._p = (unsigned char *)str;
- f._bf._size = f._r = strlen(str);
- f._ub._base = NULL;
- f._lb._base = NULL;
- return (__svfscanf(&f, fmt, ap));
-}
diff --git a/lib/libpthread/stdio/wbuf.c b/lib/libpthread/stdio/wbuf.c
deleted file mode 100644
index 63d8f9e3648..00000000000
--- a/lib/libpthread/stdio/wbuf.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)wbuf.c 5.6 (Berkeley) 1/20/91";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-#include "local.h"
-
-/*
- * Write the given character into the (probably full) buffer for
- * the given file. Flush the buffer out if it is or becomes full,
- * or if c=='\n' and the file is line buffered.
- */
-__swbuf(c, fp)
- register int c;
- register FILE *fp;
-{
- register int n;
-
- /*
- * In case we cannot write, or longjmp takes us out early,
- * make sure _w is 0 (if fully- or un-buffered) or -_bf._size
- * (if line buffered) so that we will get called again.
- * If we did not do this, a sufficient number of putc()
- * calls might wrap _w from negative to positive.
- */
- fp->_w = fp->_lbfsize;
- if (cantwrite(fp))
- return (EOF);
- c = (unsigned char)c;
-
- /*
- * If it is completely full, flush it out. Then, in any case,
- * stuff c into the buffer. If this causes the buffer to fill
- * completely, or if c is '\n' and the file is line buffered,
- * flush it (perhaps a second time). The second flush will always
- * happen on unbuffered streams, where _bf._size==1; fflush()
- * guarantees that putc() will always call wbuf() by setting _w
- * to 0, so we need not do anything else.
- */
- n = fp->_p - fp->_bf._base;
- if (n >= fp->_bf._size) {
- if (fflush(fp))
- return (EOF);
- n = 0;
- }
- fp->_w--;
- *fp->_p++ = c;
- if (++n == fp->_bf._size || (fp->_flags & __SLBF && c == '\n'))
- if (fflush(fp))
- return (EOF);
- return (c);
-}
diff --git a/lib/libpthread/stdio/wsetup.c b/lib/libpthread/stdio/wsetup.c
deleted file mode 100644
index 16941e113b2..00000000000
--- a/lib/libpthread/stdio/wsetup.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)wsetup.c 5.2 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: wsetup.c,v 1.1 1995/10/18 08:43:09 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "local.h"
-
-/*
- * Various output routines call wsetup to be sure it is safe to write,
- * because either _flags does not include __SWR, or _buf is NULL.
- * _wsetup returns 0 if OK to write, nonzero otherwise.
- */
-__swsetup(fp)
- register FILE *fp;
-{
- /* make sure stdio is set up */
- if (!__sdidinit)
- __sinit();
-
- /*
- * If we are not writing, we had better be reading and writing.
- */
- if ((fp->_flags & __SWR) == 0) {
- if ((fp->_flags & __SRW) == 0)
- return (EOF);
- if (fp->_flags & __SRD) {
- /* clobber any ungetc data */
- if (HASUB(fp))
- FREEUB(fp);
- fp->_flags &= ~(__SRD|__SEOF);
- fp->_r = 0;
- fp->_p = fp->_bf._base;
- }
- fp->_flags |= __SWR;
- }
-
- /*
- * Make a buffer if necessary, then set _w.
- */
- if (fp->_bf._base == NULL)
- __smakebuf(fp);
- if (fp->_flags & __SLBF) {
- /*
- * It is line buffered, so make _lbfsize be -_bufsize
- * for the putc() macro. We will change _lbfsize back
- * to 0 whenever we turn off __SWR.
- */
- fp->_w = 0;
- fp->_lbfsize = -fp->_bf._size;
- } else
- fp->_w = fp->_flags & __SNBF ? 0 : fp->_bf._size;
- return (0);
-}
diff --git a/lib/libpthread/stdio/xprintf.c b/lib/libpthread/stdio/xprintf.c
deleted file mode 100644
index 11c4860ac0b..00000000000
--- a/lib/libpthread/stdio/xprintf.c
+++ /dev/null
@@ -1,883 +0,0 @@
-/*
-** It turns out that the printf functions in the stock MIT pthread library
-** is busted. It isn't thread safe. If two threads try to do a printf
-** of a floating point value at the same time, a core-dump might result.
-** So this code is substituted.
-*/
-/*
-** NAME: $Source: /cvs/OpenBSD/src/lib/libpthread/stdio/Attic/xprintf.c,v $
-** VERSION: $Revision: 1.2 $
-** DATE: $Date: 1998/07/21 19:48:06 $
-**
-** ONELINER: A replacement for formatted printing programs.
-**
-** COPYRIGHT:
-** Copyright (c) 1990 by D. Richard Hipp. This code is an original
-** work and has been prepared without reference to any prior
-** implementations of similar functions. No part of this code is
-** subject to licensing restrictions of any telephone company or
-** university.
-**
-** This copyright was released and the code placed in the public domain
-** by the author, D. Richard Hipp, on October 3, 1996.
-**
-** DESCRIPTION:
-** This program is an enhanced replacement for the "printf" programs
-** found in the standard library. The following enhancements are
-** supported:
-**
-** + Additional functions. The standard set of "printf" functions
-** includes printf, fprintf, sprintf, vprintf, vfprintf, and
-** vsprintf. This module adds the following:
-**
-** * snprintf -- Works like sprintf, but has an extra argument
-** which is the size of the buffer written to.
-**
-** * mprintf -- Similar to sprintf. Writes output to memory
-** obtained from mem_alloc.
-**
-** * xprintf -- Calls a function to dispose of output.
-**
-** * nprintf -- No output, but returns the number of characters
-** that would have been output by printf.
-**
-** * A v- version (ex: vsnprintf) of every function is also
-** supplied.
-**
-** + A few extensions to the formatting notation are supported:
-**
-** * The "=" flag (similar to "-") causes the output to be
-** be centered in the appropriately sized field.
-**
-** * The %b field outputs an integer in binary notation.
-**
-** * The %c field now accepts a precision. The character output
-** is repeated by the number of times the precision specifies.
-**
-** * The %' field works like %c, but takes as its character the
-** next character of the format string, instead of the next
-** argument. For example, printf("%.78'-") prints 78 minus
-** signs, the same as printf("%.78c",'-').
-**
-** + When compiled using GCC on a SPARC, this version of printf is
-** faster than the library printf for SUN OS 4.1.
-**
-** + All functions are fully reentrant.
-**
-*/
-/*
-** Undefine COMPATIBILITY to make some slight changes in the way things
-** work. I think the changes are an improvement, but they are not
-** backwards compatible.
-*/
-/* #define COMPATIBILITY / * Compatible with SUN OS 4.1 */
-#include <stdio.h>
-#include <stdarg.h>
-#include <ctype.h>
-#include <math.h>
-#include <stdlib.h>
-#include <string.h>
-/*
-** The maximum number of digits of accuracy in a floating-point conversion.
-*/
-#define MAXDIG 20
-
-/*
-** Conversion types fall into various categories as defined by the
-** following enumeration.
-*/
-enum e_type { /* The type of the format field */
- RADIX, /* Integer types. %d, %x, %o, and so forth */
- FLOAT, /* Floating point. %f */
- EXP, /* Exponentional notation. %e and %E */
- GENERIC, /* Floating or exponential, depending on exponent. %g */
- SIZE, /* Return number of characters processed so far. %n */
- STRING, /* Strings. %s */
- PERCENT, /* Percent symbol. %% */
- CHAR, /* Characters. %c */
- ERROR, /* Used to indicate no such conversion type */
-/* The rest are extensions, not normally found in printf() */
- CHARLIT, /* Literal characters. %' */
- SEEIT, /* Strings with visible control characters. %S */
- MEM_STRING, /* A string which should be deleted after use. %z */
- ORDINAL, /* 1st, 2nd, 3rd and so forth */
-};
-
-/*
-** Each builtin conversion character (ex: the 'd' in "%d") is described
-** by an instance of the following structure
-*/
-typedef struct s_info { /* Information about each format field */
- int fmttype; /* The format field code letter */
- int base; /* The base for radix conversion */
- char *charset; /* The character set for conversion */
- int flag_signed; /* Is the quantity signed? */
- char *prefix; /* Prefix on non-zero values in alt format */
- enum e_type type; /* Conversion paradigm */
-} info;
-
-/*
-** The following table is searched linearly, so it is good to put the
-** most frequently used conversion types first.
-*/
-static info fmtinfo[] = {
- { 'd', 10, "0123456789", 1, 0, RADIX, },
- { 's', 0, 0, 0, 0, STRING, },
- { 'S', 0, 0, 0, 0, SEEIT, },
- { 'z', 0, 0, 0, 0, MEM_STRING, },
- { 'c', 0, 0, 0, 0, CHAR, },
- { 'o', 8, "01234567", 0, "0", RADIX, },
- { 'u', 10, "0123456789", 0, 0, RADIX, },
- { 'x', 16, "0123456789abcdef", 0, "x0", RADIX, },
- { 'X', 16, "0123456789ABCDEF", 0, "X0", RADIX, },
- { 'r', 10, "0123456789", 0, 0, ORDINAL, },
- { 'f', 0, 0, 1, 0, FLOAT, },
- { 'e', 0, "e", 1, 0, EXP, },
- { 'E', 0, "E", 1, 0, EXP, },
- { 'g', 0, "e", 1, 0, GENERIC, },
- { 'G', 0, "E", 1, 0, GENERIC, },
- { 'i', 10, "0123456789", 1, 0, RADIX, },
- { 'n', 0, 0, 0, 0, SIZE, },
- { 'S', 0, 0, 0, 0, SEEIT, },
- { '%', 0, 0, 0, 0, PERCENT, },
- { 'b', 2, "01", 0, "b0", RADIX, }, /* Binary notation */
- { 'p', 10, "0123456789", 0, 0, RADIX, }, /* Pointers */
- { '\'', 0, 0, 0, 0, CHARLIT, }, /* Literal char */
-};
-#define NINFO (sizeof(fmtinfo)/sizeof(info)) /* Size of the fmtinfo table */
-
-/*
-** If NOFLOATINGPOINT is defined, then none of the floating point
-** conversions will work.
-*/
-#ifndef NOFLOATINGPOINT
-/*
-** "*val" is a double such that 0.1 <= *val < 10.0
-** Return the ascii code for the leading digit of *val, then
-** multiply "*val" by 10.0 to renormalize.
-**
-** Example:
-** input: *val = 3.14159
-** output: *val = 1.4159 function return = '3'
-**
-** The counter *cnt is incremented each time. After counter exceeds
-** 16 (the number of significant digits in a 64-bit float) '0' is
-** always returned.
-*/
-static int getdigit(long double *val, int *cnt){
- int digit;
- long double d;
- if( (*cnt)++ >= MAXDIG ) return '0';
- digit = (int)*val;
- d = digit;
- digit += '0';
- *val = (*val - d)*10.0;
- return digit;
-}
-#endif
-
-/*
-** Setting the size of the BUFFER involves trade-offs. No %d or %f
-** conversion can have more than BUFSIZE characters. If the field
-** width is larger than BUFSIZE, it is silently shortened. On the
-** other hand, this routine consumes more stack space with larger
-** BUFSIZEs. If you have some threads for which you want to minimize
-** stack space, you should keep BUFSIZE small.
-*/
-#define BUFSIZE 100 /* Size of the output buffer */
-
-/*
-** The root program. All variations call this core.
-**
-** INPUTS:
-** func This is a pointer to a function taking three arguments
-** 1. A pointer to the list of characters to be output
-** (Note, this list is NOT null terminated.)
-** 2. An integer number of characters to be output.
-** (Note: This number might be zero.)
-** 3. A pointer to anything. Same as the "arg" parameter.
-**
-** arg This is the pointer to anything which will be passed as the
-** third argument to "func". Use it for whatever you like.
-**
-** fmt This is the format string, as in the usual print.
-**
-** ap This is a pointer to a list of arguments. Same as in
-** vfprint.
-**
-** OUTPUTS:
-** The return value is the total number of characters sent to
-** the function "func". Returns -1 on a error.
-**
-** Note that the order in which automatic variables are declared below
-** seems to make a big difference in determining how fast this beast
-** will run.
-*/
-static int vxprintf(func,arg,format,ap)
- void (*func)(char*,int,void*);
- void *arg;
- const char *format;
- va_list ap;
-{
- register const char *fmt; /* The format string. */
- register int c; /* Next character in the format string */
- register char *bufpt; /* Pointer to the conversion buffer */
- register int precision; /* Precision of the current field */
- register int length; /* Length of the field */
- register int idx; /* A general purpose loop counter */
- int count; /* Total number of characters output */
- int width; /* Width of the current field */
- int flag_leftjustify; /* True if "-" flag is present */
- int flag_plussign; /* True if "+" flag is present */
- int flag_blanksign; /* True if " " flag is present */
- int flag_alternateform; /* True if "#" flag is present */
- int flag_zeropad; /* True if field width constant starts with zero */
- int flag_long; /* True if "l" flag is present */
- int flag_center; /* True if "=" flag is present */
- unsigned long longvalue; /* Value for integer types */
- long double realvalue; /* Value for real types */
- info *infop; /* Pointer to the appropriate info structure */
- char buf[BUFSIZE]; /* Conversion buffer */
- char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */
- int errorflag = 0; /* True if an error is encountered */
- enum e_type xtype; /* Conversion paradigm */
- char *zMem; /* String to be freed */
- static char spaces[] =
- " ";
-#define SPACESIZE (sizeof(spaces)-1)
-#ifndef NOFLOATINGPOINT
- int exp; /* exponent of real numbers */
- long double rounder; /* Used for rounding floating point values */
- int flag_dp; /* True if decimal point should be shown */
- int flag_rtz; /* True if trailing zeros should be removed */
- int flag_exp; /* True to force display of the exponent */
- int nsd; /* Number of significant digits returned */
-#endif
-
- fmt = format; /* Put in a register for speed */
- count = length = 0;
- bufpt = 0;
- for(; (c=(*fmt))!=0; ++fmt){
- if( c!='%' ){
- register int amt;
- bufpt = (char *)fmt;
- amt = 1;
- while( (c=(*++fmt))!='%' && c!=0 ) amt++;
- (*func)(bufpt,amt,arg);
- count += amt;
- if( c==0 ) break;
- }
- if( (c=(*++fmt))==0 ){
- errorflag = 1;
- (*func)("%",1,arg);
- count++;
- break;
- }
- /* Find out what flags are present */
- flag_leftjustify = flag_plussign = flag_blanksign =
- flag_alternateform = flag_zeropad = flag_center = 0;
- do{
- switch( c ){
- case '-': flag_leftjustify = 1; c = 0; break;
- case '+': flag_plussign = 1; c = 0; break;
- case ' ': flag_blanksign = 1; c = 0; break;
- case '#': flag_alternateform = 1; c = 0; break;
- case '0': flag_zeropad = 1; c = 0; break;
- case '=': flag_center = 1; c = 0; break;
- default: break;
- }
- }while( c==0 && (c=(*++fmt))!=0 );
- if( flag_center ) flag_leftjustify = 0;
- /* Get the field width */
- width = 0;
- if( c=='*' ){
- width = va_arg(ap,int);
- if( width<0 ){
- flag_leftjustify = 1;
- width = -width;
- }
- c = *++fmt;
- }else{
- while( isdigit(c) ){
- width = width*10 + c - '0';
- c = *++fmt;
- }
- }
- if( width > BUFSIZE-10 ){
- width = BUFSIZE-10;
- }
- /* Get the precision */
- if( c=='.' ){
- precision = 0;
- c = *++fmt;
- if( c=='*' ){
- precision = va_arg(ap,int);
-#ifndef COMPATIBILITY
- /* This is sensible, but SUN OS 4.1 doesn't do it. */
- if( precision<0 ) precision = -precision;
-#endif
- c = *++fmt;
- }else{
- while( isdigit(c) ){
- precision = precision*10 + c - '0';
- c = *++fmt;
- }
- }
- /* Limit the precision to prevent overflowing buf[] during conversion */
- if( precision>BUFSIZE-40 ) precision = BUFSIZE-40;
- }else{
- precision = -1;
- }
- /* Get the conversion type modifier */
- if( c=='l' ){
- flag_long = 1;
- c = *++fmt;
- }else{
- flag_long = 0;
- }
- /* Fetch the info entry for the field */
- infop = 0;
- for(idx=0; idx<NINFO; idx++){
- if( c==fmtinfo[idx].fmttype ){
- infop = &fmtinfo[idx];
- break;
- }
- }
- /* No info entry found. It must be an error. */
- if( infop==0 ){
- xtype = ERROR;
- }else{
- xtype = infop->type;
- }
-
- /*
- ** At this point, variables are initialized as follows:
- **
- ** flag_alternateform TRUE if a '#' is present.
- ** flag_plussign TRUE if a '+' is present.
- ** flag_leftjustify TRUE if a '-' is present or if the
- ** field width was negative.
- ** flag_zeropad TRUE if the width began with 0.
- ** flag_long TRUE if the letter 'l' (ell) prefixed
- ** the conversion character.
- ** flag_blanksign TRUE if a ' ' is present.
- ** width The specified field width. This is
- ** always non-negative. Zero is the default.
- ** precision The specified precision. The default
- ** is -1.
- ** xtype The class of the conversion.
- ** infop Pointer to the appropriate info struct.
- */
- switch( xtype ){
- case ORDINAL:
- case RADIX:
- if( flag_long ) longvalue = va_arg(ap,long);
- else longvalue = va_arg(ap,int);
-#ifdef COMPATIBILITY
- /* For the format %#x, the value zero is printed "0" not "0x0".
- ** I think this is stupid. */
- if( longvalue==0 ) flag_alternateform = 0;
-#else
- /* More sensible: turn off the prefix for octal (to prevent "00"),
- ** but leave the prefix for hex. */
- if( longvalue==0 && infop->base==8 ) flag_alternateform = 0;
-#endif
- if( infop->flag_signed ){
- if( *(long*)&longvalue<0 ){
- longvalue = -*(long*)&longvalue;
- prefix = '-';
- }else if( flag_plussign ) prefix = '+';
- else if( flag_blanksign ) prefix = ' ';
- else prefix = 0;
- }else prefix = 0;
- if( flag_zeropad && precision<width-(prefix!=0) ){
- precision = width-(prefix!=0);
- }
- bufpt = &buf[BUFSIZE];
- if( xtype==ORDINAL ){
- long a,b;
- a = longvalue%10;
- b = longvalue%100;
- bufpt -= 2;
- if( a==0 || a>3 || (b>10 && b<14) ){
- bufpt[0] = 't';
- bufpt[1] = 'h';
- }else if( a==1 ){
- bufpt[0] = 's';
- bufpt[1] = 't';
- }else if( a==2 ){
- bufpt[0] = 'n';
- bufpt[1] = 'd';
- }else if( a==3 ){
- bufpt[0] = 'r';
- bufpt[1] = 'd';
- }
- }
- {
- register char *cset; /* Use registers for speed */
- register int base;
- cset = infop->charset;
- base = infop->base;
- do{ /* Convert to ascii */
- *(--bufpt) = cset[longvalue%base];
- longvalue = longvalue/base;
- }while( longvalue>0 );
- }
- length = (int)(&buf[BUFSIZE]-bufpt);
- for(idx=precision-length; idx>0; idx--){
- *(--bufpt) = '0'; /* Zero pad */
- }
- if( prefix ) *(--bufpt) = prefix; /* Add sign */
- if( flag_alternateform && infop->prefix ){ /* Add "0" or "0x" */
- char *pre, x;
- pre = infop->prefix;
- if( *bufpt!=pre[0] ){
- for(pre=infop->prefix; (x=(*pre))!=0; pre++) *(--bufpt) = x;
- }
- }
- length = (int)(&buf[BUFSIZE]-bufpt);
- break;
- case FLOAT:
- case EXP:
- case GENERIC:
- realvalue = va_arg(ap,double);
-#ifndef NOFLOATINGPOINT
- if( precision<0 ) precision = 6; /* Set default precision */
- if( precision>BUFSIZE-10 ) precision = BUFSIZE-10;
- if( realvalue<0.0 ){
- realvalue = -realvalue;
- prefix = '-';
- }else{
- if( flag_plussign ) prefix = '+';
- else if( flag_blanksign ) prefix = ' ';
- else prefix = 0;
- }
- if( infop->type==GENERIC && precision>0 ) precision--;
- rounder = 0.0;
-#ifdef COMPATIBILITY
- /* Rounding works like BSD when the constant 0.4999 is used. Wierd! */
- for(idx=precision, rounder=0.4999; idx>0; idx--, rounder*=0.1);
-#else
- /* It makes more sense to use 0.5 */
- if( precision>MAXDIG-1 ) idx = MAXDIG-1;
- else idx = precision;
- for(rounder=0.5; idx>0; idx--, rounder*=0.1);
-#endif
- if( infop->type==FLOAT ) realvalue += rounder;
- /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */
- exp = 0;
- if( realvalue>0.0 ){
- int k = 0;
- while( realvalue>=1e8 && k++<100 ){ realvalue *= 1e-8; exp+=8; }
- while( realvalue>=10.0 && k++<100 ){ realvalue *= 0.1; exp++; }
- while( realvalue<1e-8 && k++<100 ){ realvalue *= 1e8; exp-=8; }
- while( realvalue<1.0 && k++<100 ){ realvalue *= 10.0; exp--; }
- if( k>=100 ){
- bufpt = "NaN";
- length = 3;
- break;
- }
- }
- bufpt = buf;
- /*
- ** If the field type is GENERIC, then convert to either EXP
- ** or FLOAT, as appropriate.
- */
- flag_exp = xtype==EXP;
- if( xtype!=FLOAT ){
- realvalue += rounder;
- if( realvalue>=10.0 ){ realvalue *= 0.1; exp++; }
- }
- if( xtype==GENERIC ){
- flag_rtz = !flag_alternateform;
- if( exp<-4 || exp>precision ){
- xtype = EXP;
- }else{
- precision = precision - exp;
- xtype = FLOAT;
- }
- }else{
- flag_rtz = 0;
- }
- /*
- ** The "exp+precision" test causes output to be of type EXP if
- ** the precision is too large to fit in buf[].
- */
- nsd = 0;
- if( xtype==FLOAT && exp+precision<BUFSIZE-30 ){
- flag_dp = (precision>0 || flag_alternateform);
- if( prefix ) *(bufpt++) = prefix; /* Sign */
- if( exp<0 ) *(bufpt++) = '0'; /* Digits before "." */
- else for(; exp>=0; exp--) *(bufpt++) = getdigit(&realvalue,&nsd);
- if( flag_dp ) *(bufpt++) = '.'; /* The decimal point */
- for(exp++; exp<0 && precision>0; precision--, exp++){
- *(bufpt++) = '0';
- }
- while( (precision--)>0 ) *(bufpt++) = getdigit(&realvalue,&nsd);
- *(bufpt--) = 0; /* Null terminate */
- if( flag_rtz && flag_dp ){ /* Remove trailing zeros and "." */
- while( bufpt>=buf && *bufpt=='0' ) *(bufpt--) = 0;
- if( bufpt>=buf && *bufpt=='.' ) *(bufpt--) = 0;
- }
- bufpt++; /* point to next free slot */
- }else{ /* EXP or GENERIC */
- flag_dp = (precision>0 || flag_alternateform);
- if( prefix ) *(bufpt++) = prefix; /* Sign */
- *(bufpt++) = getdigit(&realvalue,&nsd); /* First digit */
- if( flag_dp ) *(bufpt++) = '.'; /* Decimal point */
- while( (precision--)>0 ) *(bufpt++) = getdigit(&realvalue,&nsd);
- bufpt--; /* point to last digit */
- if( flag_rtz && flag_dp ){ /* Remove tail zeros */
- while( bufpt>=buf && *bufpt=='0' ) *(bufpt--) = 0;
- if( bufpt>=buf && *bufpt=='.' ) *(bufpt--) = 0;
- }
- bufpt++; /* point to next free slot */
- if( exp || flag_exp ){
- *(bufpt++) = infop->charset[0];
- if( exp<0 ){ *(bufpt++) = '-'; exp = -exp; } /* sign of exp */
- else { *(bufpt++) = '+'; }
- if( exp>=100 ){
- *(bufpt++) = (exp/100)+'0'; /* 100's digit */
- exp %= 100;
- }
- *(bufpt++) = exp/10+'0'; /* 10's digit */
- *(bufpt++) = exp%10+'0'; /* 1's digit */
- }
- }
- /* The converted number is in buf[] and zero terminated. Output it.
- ** Note that the number is in the usual order, not reversed as with
- ** integer conversions. */
- length = (int)(bufpt-buf);
- bufpt = buf;
-
- /* Special case: Add leading zeros if the flag_zeropad flag is
- ** set and we are not left justified */
- if( flag_zeropad && !flag_leftjustify && length < width){
- int i;
- int nPad = width - length;
- for(i=width; i>=nPad; i--){
- bufpt[i] = bufpt[i-nPad];
- }
- i = prefix!=0;
- while( nPad-- ) bufpt[i++] = '0';
- length = width;
- }
-#endif
- break;
- case SIZE:
- *(va_arg(ap,int*)) = count;
- length = width = 0;
- break;
- case PERCENT:
- buf[0] = '%';
- bufpt = buf;
- length = 1;
- break;
- case CHARLIT:
- case CHAR:
- c = buf[0] = (xtype==CHAR ? va_arg(ap,int) : *++fmt);
- if( precision>=0 ){
- for(idx=1; idx<precision; idx++) buf[idx] = c;
- length = precision;
- }else{
- length =1;
- }
- bufpt = buf;
- break;
- case STRING:
- case MEM_STRING:
- zMem = bufpt = va_arg(ap,char*);
- if( bufpt==0 ) bufpt = "(null)";
- length = strlen(bufpt);
- if( precision>=0 && precision<length ) length = precision;
- break;
- case SEEIT:
- {
- int i;
- int c;
- char *arg = va_arg(ap,char*);
- for(i=0; i<BUFSIZE-1 && (c = *arg++)!=0; i++){
- if( c<0x20 || c>=0x7f ){
- buf[i++] = '^';
- buf[i] = (c&0x1f)+0x40;
- }else{
- buf[i] = c;
- }
- }
- bufpt = buf;
- length = i;
- if( precision>=0 && precision<length ) length = precision;
- }
- break;
- case ERROR:
- buf[0] = '%';
- buf[1] = c;
- errorflag = 0;
- idx = 1+(c!=0);
- (*func)("%",idx,arg);
- count += idx;
- if( c==0 ) fmt--;
- break;
- }/* End switch over the format type */
- /*
- ** The text of the conversion is pointed to by "bufpt" and is
- ** "length" characters long. The field width is "width". Do
- ** the output.
- */
- if( !flag_leftjustify ){
- register int nspace;
- nspace = width-length;
- if( nspace>0 ){
- if( flag_center ){
- nspace = nspace/2;
- width -= nspace;
- flag_leftjustify = 1;
- }
- count += nspace;
- while( nspace>=SPACESIZE ){
- (*func)(spaces,SPACESIZE,arg);
- nspace -= SPACESIZE;
- }
- if( nspace>0 ) (*func)(spaces,nspace,arg);
- }
- }
- if( length>0 ){
- (*func)(bufpt,length,arg);
- count += length;
- }
- if( xtype==MEM_STRING && zMem ){
- free(zMem);
- }
- if( flag_leftjustify ){
- register int nspace;
- nspace = width-length;
- if( nspace>0 ){
- count += nspace;
- while( nspace>=SPACESIZE ){
- (*func)(spaces,SPACESIZE,arg);
- nspace -= SPACESIZE;
- }
- if( nspace>0 ) (*func)(spaces,nspace,arg);
- }
- }
- }/* End for loop over the format string */
- return errorflag ? -1 : count;
-} /* End of function */
-
-/*
-** This non-standard function is still occasionally useful....
-*/
-int xprintf(
- void (*func)(char*,int,void*),
- void *arg,
- const char *format,
- ...
-){
- va_list ap;
- va_start(ap,format);
- return vxprintf(func,arg,format,ap);
-}
-
-/*
-** Now for string-print, also as found in any standard library.
-** Add to this the snprint function which stops added characters
-** to the string at a given length.
-**
-** Note that snprint returns the length of the string as it would
-** be if there were no limit on the output.
-*/
-struct s_strargument { /* Describes the string being written to */
- char *next; /* Next free slot in the string */
- char *last; /* Last available slot in the string */
-};
-
-static void sout(txt,amt,arg)
- char *txt;
- int amt;
- void *arg;
-{
- register char *head;
- register const char *t;
- register int a;
- register char *tail;
- a = amt;
- t = txt;
- head = ((struct s_strargument*)arg)->next;
- tail = ((struct s_strargument*)arg)->last;
- if( tail ){
- while( a-- >0 && head<tail ) *(head++) = *(t++);
- }else{
- while( a-- >0 ) *(head++) = *(t++);
- }
- *head = 0;
- ((struct s_strargument*)arg)->next = head;
-}
-
-int sprintf(char *buf, const char *fmt, ...){
- int rc;
- va_list ap;
- struct s_strargument arg;
-
- va_start(ap,fmt);
- arg.next = buf;
- arg.last = 0;
- *arg.next = 0;
- rc = vxprintf(sout,&arg,fmt,ap);
- va_end(ap);
-}
-int vsprintf(char *buf,const char *fmt,pthread_va_list ap){
- struct s_strargument arg;
- arg.next = buf;
- arg.last = 0;
- *buf = 0;
- return vxprintf(sout,&arg,fmt,ap);
-}
-int snprintf(char *buf, size_t n, const char *fmt, ...){
- int rc;
- va_list ap;
- struct s_strargument arg;
-
- va_start(ap,fmt);
- arg.next = buf;
- arg.last = &arg.next[n-1];
- *arg.next = 0;
- rc = vxprintf(sout,&arg,fmt,ap);
- va_end(ap);
-}
-int vsnprintf(char *buf, size_t n, const char *fmt, pthread_va_list ap){
- struct s_strargument arg;
- arg.next = buf;
- arg.last = &buf[n-1];
- *buf = 0;
- return vxprintf(sout,&arg,fmt,ap);
-}
-
-/*
-** The following section of code handles the mprintf routine, that
-** writes to memory obtained from malloc().
-*/
-
-/* This structure is used to store state information about the
-** write in progress
-*/
-struct sgMprintf {
- char *zBase; /* A base allocation */
- char *zText; /* The string collected so far */
- int nChar; /* Length of the string so far */
- int nAlloc; /* Amount of space allocated in zText */
-};
-
-/* The xprintf callback function. */
-static void mout(zNewText,nNewChar,arg)
- char *zNewText;
- int nNewChar;
- void *arg;
-{
- struct sgMprintf *pM = (struct sgMprintf*)arg;
- if( pM->nChar + nNewChar + 1 > pM->nAlloc ){
- pM->nAlloc = pM->nChar + nNewChar*2 + 1;
- if( pM->zText==pM->zBase ){
- pM->zText = malloc(pM->nAlloc);
- if( pM->zText && pM->nChar ) memcpy(pM->zText,pM->zBase,pM->nChar);
- }else{
- pM->zText = realloc(pM->zText, pM->nAlloc);
- }
- }
- if( pM->zText ){
- memcpy(&pM->zText[pM->nChar], zNewText, nNewChar);
- pM->nChar += nNewChar;
- pM->zText[pM->nChar] = 0;
- }
-}
-
-/*
-** mprintf() works like printf(), but allocations memory to hold the
-** resulting string and returns a pointer to the allocated memory.
-**
-** We changed the name to TclMPrint() to conform with the Tcl private
-** routine naming conventions.
-*/
-char *mprintf(const char *zFormat, ...){
- va_list ap;
- struct sgMprintf sMprintf;
- char *zNew;
- char zBuf[200];
-
- va_start(ap,zFormat);
- sMprintf.nChar = 0;
- sMprintf.nAlloc = sizeof(zBuf);
- sMprintf.zText = zBuf;
- sMprintf.zBase = zBuf;
- vxprintf(mout,&sMprintf,zFormat,ap);
- va_end(ap);
- if( sMprintf.zText==sMprintf.zBase ){
- zNew = malloc( sMprintf.nChar+1 );
- if( zNew ) strcpy(zNew,zBuf);
- }else{
- zNew = realloc(sMprintf.zText,sMprintf.nChar+1);
- }
-
- return zNew;
-}
-
-/* This is the varargs version of mprintf.
-**
-** The name is changed to TclVMPrintf() to conform with Tcl naming
-** conventions.
-*/
-char *vmprintf(const char *zFormat,pthread_va_list ap){
- struct sgMprintf sMprintf;
- char zBuf[200];
- sMprintf.nChar = 0;
- sMprintf.zText = zBuf;
- sMprintf.nAlloc = sizeof(zBuf);
- sMprintf.zBase = zBuf;
- vxprintf(mout,&sMprintf,zFormat,ap);
- if( sMprintf.zText==sMprintf.zBase ){
- sMprintf.zText = malloc( strlen(zBuf)+1 );
- if( sMprintf.zText ) strcpy(sMprintf.zText,zBuf);
- }else{
- sMprintf.zText = realloc(sMprintf.zText,sMprintf.nChar+1);
- }
- return sMprintf.zText;
-}
-
-/*
-** The following section of code handles the standard fprintf routines
-** for pthreads.
-*/
-
-/* The xprintf callback function. */
-static void fout(zNewText,nNewChar,arg)
- char *zNewText;
- int nNewChar;
- void *arg;
-{
- fwrite(zNewText,1,nNewChar,(FILE*)arg);
-}
-
-/* The public interface routines */
-int fprintf(FILE *pOut, const char *zFormat, ...){
- va_list ap;
- int retc;
-
- va_start(ap,zFormat);
- retc = vxprintf(fout,pOut,zFormat,ap);
- va_end(ap);
- return retc;
-}
-int vfprintf(FILE *pOut, const char *zFormat, pthread_va_list ap){
- return vxprintf(fout,pOut,zFormat,ap);
-}
-int printf(const char *zFormat, ...){
- va_list ap;
- int retc;
-
- va_start(ap,zFormat);
- retc = vxprintf(fout,stdout,zFormat,ap);
- va_end(ap);
- return retc;
-}
-int vprintf(const char *zFormat, pthread_va_list ap){
- return vxprintf(fout,stdout,zFormat,ap);
-}
diff --git a/lib/libpthread/stdlib/Makefile.inc b/lib/libpthread/stdlib/Makefile.inc
deleted file mode 100644
index 07e7eceaec6..00000000000
--- a/lib/libpthread/stdlib/Makefile.inc
+++ /dev/null
@@ -1,5 +0,0 @@
-# @(#)Makefile.inc 5.6 (Berkeley) 6/4/91
-
-.PATH: ${.CURDIR}/stdlib
-
-SRCS+= exit.c strtod.c getopt.c rand.c random.c strtol.c strtoul.c
diff --git a/lib/libpthread/stdlib/abort.c b/lib/libpthread/stdlib/abort.c
deleted file mode 100644
index e9892bc554c..00000000000
--- a/lib/libpthread/stdlib/abort.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 1985 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)abort.c 5.11 (Berkeley) 2/23/91";*/
-static char *rcsid = "$Id: abort.c,v 1.1 1998/07/21 13:22:19 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <unistd.h>
-
-void
-abort()
-{
- sigset_t mask;
-
- sigfillset(&mask);
- /*
- * don't block SIGABRT to give any handler a chance; we ignore
- * any errors -- X3J11 doesn't allow abort to return anyway.
- */
- sigdelset(&mask, SIGABRT);
- pthread_sigmask(SIG_SETMASK, &mask, NULL);
- kill(getpid(), SIGABRT);
-
- /*
- * if SIGABRT ignored, or caught and the handler returns, do
- * it again, only harder.
- */
- pthread_signal(SIGABRT, SIG_DFL);
- pthread_sigmask(SIG_SETMASK, &mask, NULL);
- kill(getpid(), SIGABRT);
- exit(1);
-}
diff --git a/lib/libpthread/stdlib/atexit.h b/lib/libpthread/stdlib/atexit.h
deleted file mode 100644
index 46675a2c9bf..00000000000
--- a/lib/libpthread/stdlib/atexit.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- *
- * from: @(#)atexit.h 5.1 (Berkeley) 5/15/90
- * $Id: atexit.h,v 1.1 1998/07/21 13:22:19 peter Exp $
- */
-
-/* must be at least 32 to guarantee ANSI conformance */
-#define ATEXIT_SIZE 32
-
-struct atexit {
- struct atexit *next; /* next in list */
- int ind; /* next index in this table */
- void (*fns[ATEXIT_SIZE])(); /* the table itself */
-};
-
-struct atexit *__atexit; /* points to head of LIFO stack */
diff --git a/lib/libpthread/stdlib/exit.c b/lib/libpthread/stdlib/exit.c
deleted file mode 100644
index 791e82748c5..00000000000
--- a/lib/libpthread/stdlib/exit.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)exit.c 5.4 (Berkeley) 2/23/91";*/
-static char *rcsid = "$Id: exit.c,v 1.1 1998/07/21 13:22:19 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/cdefs.h>
-#include <pthread/posix.h>
-#include "atexit.h"
-
-void (*__cleanup)();
-
-/*
- * Exit, flushing stdio buffers if necessary.
- */
-void __NORETURN exit(int status)
-{
- register struct atexit *p;
- register int n;
-
- for (p = __atexit; p; p = p->next)
- for (n = p->ind; --n >= 0;)
- (*p->fns[n])();
- if (__cleanup)
- (*__cleanup)();
- _exit(status);
-
- /* This is to shut up gcc, which complains about this function
- * returning even if _exit() is declared noreturn. */
- while (1);
-}
-
-
-/*
- * Register a function to be performed at exit.
- */
-int atexit(void (*fn)())
-{
- static struct atexit __atexit0; /* one guaranteed table */
- register struct atexit *p;
-
- if ((p = __atexit) == NULL)
- __atexit = p = &__atexit0;
- else if (p->ind >= ATEXIT_SIZE) {
- if ((p = malloc(sizeof(*p))) == NULL)
- return (-1);
- p->ind = 0;
- p->next = __atexit;
- __atexit = p;
- }
- p->fns[p->ind++] = fn;
- return (0);
-}
diff --git a/lib/libpthread/stdlib/getopt.c b/lib/libpthread/stdlib/getopt.c
deleted file mode 100644
index 20d2e7b8ea3..00000000000
--- a/lib/libpthread/stdlib/getopt.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (c) 1987 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getopt.c 4.13 (Berkeley) 2/23/91";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-/*
- * get option letter from argument vector
- */
-
-#ifndef LD_LINKS_STATIC_DATA
-/*
- * Under the Solaris ld, some data sections are linked in regaurdless of
- * whether or not the name has been resolved.
- */
-int opterr = 1, /* if error message should be printed */
- optind = 1, /* index into parent argv vector */
- optopt = 0; /* character checked for validity */
-char * optarg = NULL; /* argument associated with option */
-
-#else
-
-extern int opterr, optind, optopt;
-extern char *optarg;
-
-#endif
-
-#define BADCH (int)'?'
-#define EMSG ""
-
-int
-getopt(nargc, nargv, ostr)
- int nargc;
- char * const *nargv;
- const char *ostr;
-{
- static char *place = EMSG; /* option letter processing */
- register char *oli; /* option letter list index */
- char *p;
-
- if (!*place) { /* update scanning pointer */
- if (optind >= nargc || *(place = nargv[optind]) != '-') {
- place = EMSG;
- return(EOF);
- }
- if (place[1] && *++place == '-') { /* found "--" */
- ++optind;
- place = EMSG;
- return(EOF);
- }
- } /* option letter okay? */
- if ((optopt = (int)*place++) == (int)':' ||
- !(oli = strchr(ostr, optopt))) {
- /*
- * if the user didn't specify '-' as an option,
- * assume it means EOF.
- */
- if (optopt == (int)'-')
- return(EOF);
- if (!*place)
- ++optind;
- if (opterr) {
- if (!(p = strrchr(*nargv, '/')))
- p = *nargv;
- else
- ++p;
- (void)fprintf(stderr, "%s: illegal option -- %c\n",
- p, optopt);
- }
- return(BADCH);
- }
- if (*++oli != ':') { /* don't need argument */
- optarg = NULL;
- if (!*place)
- ++optind;
- }
- else { /* need an argument */
- if (*place) /* no white space */
- optarg = place;
- else if (nargc <= ++optind) { /* no arg */
- place = EMSG;
- if (!(p = strrchr(*nargv, '/')))
- p = *nargv;
- else
- ++p;
- if (opterr)
- (void)fprintf(stderr,
- "%s: option requires an argument -- %c\n",
- p, optopt);
- return(BADCH);
- }
- else /* white space */
- optarg = nargv[optind];
- place = EMSG;
- ++optind;
- }
- return(optopt); /* dump back option letter */
-}
diff --git a/lib/libpthread/stdlib/rand.c b/lib/libpthread/stdlib/rand.c
deleted file mode 100644
index 9367dceed25..00000000000
--- a/lib/libpthread/stdlib/rand.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * Copyright (c) 1994 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rand.c 5.6 (Berkeley) 6/24/91";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <sys/types.h>
-#include <stdlib.h>
-
-static u_long next = 1;
-
-int rand_r(u_int * next_r)
-{
- int ret;
-
- (*next_r) = (*next_r) * 1103515245 + 12345;
- ret = (*next_r) & RAND_MAX;
- return(ret);
-}
-
-#undef rand
-int rand(void)
-{
- return ((next = next * 1103515245 + 12345) & RAND_MAX);
-}
-
-#undef srand
-void srand(unsigned int seed)
-{
- next = seed;
-}
diff --git a/lib/libpthread/stdlib/random.c b/lib/libpthread/stdlib/random.c
deleted file mode 100644
index 8cba96e7534..00000000000
--- a/lib/libpthread/stdlib/random.c
+++ /dev/null
@@ -1,389 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * Copyright (c) 1994 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)random.c 5.9 (Berkeley) 2/23/91";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-/*
- * random.c:
- *
- * An improved random number generation package. In addition to the standard
- * rand()/srand() like interface, this package also has a special state info
- * interface. The initstate() routine is called with a seed, an array of
- * bytes, and a count of how many bytes are being passed in; this array is
- * then initialized to contain information for random number generation with
- * that much state information. Good sizes for the amount of state
- * information are 32, 64, 128, and 256 bytes. The state can be switched by
- * calling the setstate() routine with the same array as was initiallized
- * with initstate(). By default, the package runs with 128 bytes of state
- * information and generates far better random numbers than a linear
- * congruential generator. If the amount of state information is less than
- * 32 bytes, a simple linear congruential R.N.G. is used.
- *
- * Internally, the state information is treated as an array of longs; the
- * zeroeth element of the array is the type of R.N.G. being used (small
- * integer); the remainder of the array is the state information for the
- * R.N.G. Thus, 32 bytes of state information will give 7 longs worth of
- * state information, which will allow a degree seven polynomial. (Note:
- * the zeroeth word of state information also has some other information
- * stored in it -- see setstate() for details).
- *
- * The random number generation technique is a linear feedback shift register
- * approach, employing trinomials (since there are fewer terms to sum up that
- * way). In this approach, the least significant bit of all the numbers in
- * the state table will act as a linear feedback shift register, and will
- * have period 2^deg - 1 (where deg is the degree of the polynomial being
- * used, assuming that the polynomial is irreducible and primitive). The
- * higher order bits will have longer periods, since their values are also
- * influenced by pseudo-random carries out of the lower bits. The total
- * period of the generator is approximately deg*(2**deg - 1); thus doubling
- * the amount of state information has a vast influence on the period of the
- * generator. Note: the deg*(2**deg - 1) is an approximation only good for
- * large deg, when the period of the shift register is the dominant factor.
- * With deg equal to seven, the period is actually much longer than the
- * 7*(2**7 - 1) predicted by this formula.
- */
-
-/*
- * For each of the currently supported random number generators, we have a
- * break value on the amount of state information (you need at least this
- * many bytes of state info to support this random number generator), a degree
- * for the polynomial (actually a trinomial) that the R.N.G. is based on, and
- * the separation between the two lower order coefficients of the trinomial.
- */
-#define TYPE_0 0 /* linear congruential */
-#define BREAK_0 8
-#define DEG_0 0
-#define SEP_0 0
-
-#define TYPE_1 1 /* x**7 + x**3 + 1 */
-#define BREAK_1 32
-#define DEG_1 7
-#define SEP_1 3
-
-#define TYPE_2 2 /* x**15 + x + 1 */
-#define BREAK_2 64
-#define DEG_2 15
-#define SEP_2 1
-
-#define TYPE_3 3 /* x**31 + x**3 + 1 */
-#define BREAK_3 128
-#define DEG_3 31
-#define SEP_3 3
-
-#define TYPE_4 4 /* x**63 + x + 1 */
-#define BREAK_4 256
-#define DEG_4 63
-#define SEP_4 1
-
-/*
- * Array versions of the above information to make code run faster --
- * relies on fact that TYPE_i == i.
- */
-#define MAX_TYPES 5 /* max number of types above */
-
-static int degrees[MAX_TYPES] = { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 };
-static int seps [MAX_TYPES] = { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 };
-
-/*
- * Initially, everything is set up as if from:
- *
- * initstate(1, &randtbl, 128);
- *
- * Note that this initialization takes advantage of the fact that srandom()
- * advances the front and rear pointers 10*rand_deg times, and hence the
- * rear pointer which starts at 0 will also end up at zero; thus the zeroeth
- * element of the state information, which contains info about the current
- * position of the rear pointer is just
- *
- * MAX_TYPES * (rptr - state) + TYPE_3 == TYPE_3.
- */
-
-static long randtbl[DEG_3 + 1] = {
- TYPE_3,
- 0x9a319039, 0x32d9c024, 0x9b663182, 0x5da1f342, 0xde3b81e0, 0xdf0a6fb5,
- 0xf103bc02, 0x48f340fb, 0x7449e56b, 0xbeb1dbb0, 0xab5c5918, 0x946554fd,
- 0x8c2e680f, 0xeb3d799f, 0xb11ee0b7, 0x2d436b86, 0xda672e2a, 0x1588ca88,
- 0xe369735d, 0x904f35f7, 0xd7158fd6, 0x6fa6f051, 0x616e6b96, 0xac94efdc,
- 0x36413f93, 0xc622c298, 0xf5a42ab8, 0x8a88d77b, 0xf5ad9d0e, 0x8999220b,
- 0x27fb47b9,
-};
-
-/*
- * fptr and rptr are two pointers into the state info, a front and a rear
- * pointer. These two pointers are always rand_sep places aparts, as they
- * cycle cyclically through the state information. (Yes, this does mean we
- * could get away with just one pointer, but the code for random() is more
- * efficient this way). The pointers are left positioned as they would be
- * from the call
- *
- * initstate(1, randtbl, 128);
- *
- * (The position of the rear pointer, rptr, is really 0 (as explained above
- * in the initialization of randtbl) because the state table pointer is set
- * to point to randtbl[1] (as explained below).
- */
-static long *fptr = &randtbl[SEP_3 + 1];
-static long *rptr = &randtbl[1];
-
-/*
- * The following things are the pointer to the state information table, the
- * type of the current generator, the degree of the current polynomial being
- * used, and the separation between the two pointers. Note that for efficiency
- * of random(), we remember the first location of the state information, not
- * the zeroeth. Hence it is valid to access state[-1], which is used to
- * store the type of the R.N.G. Also, we remember the last location, since
- * this is more efficient than indexing every time to find the address of
- * the last element to see if the front and rear pointers have wrapped.
- */
-static long *state = &randtbl[1];
-static int rand_type = TYPE_3;
-static int rand_deg = DEG_3;
-static int rand_sep = SEP_3;
-static long *end_ptr = &randtbl[DEG_3 + 1];
-
-/*
- * State info won't be corrupted by multiple simultaneous calls,
- * but srandom(), initstate(), and setstate() affect all threads
- */
-static pthread_mutex_t random_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-/*
- * random:
- *
- * If we are using the trivial TYPE_0 R.N.G., just do the old linear
- * congruential bit. Otherwise, we do our fancy trinomial stuff, which is
- * the same in all the other cases due to all the global variables that have
- * been set up. The basic operation is to add the number at the rear pointer
- * into the one at the front pointer. Then both pointers are advanced to
- * the next location cyclically in the table. The value returned is the sum
- * generated, reduced to 31 bits by throwing away the "least random" low bit.
- *
- * Note: the code takes advantage of the fact that both the front and
- * rear pointers can't wrap on the same call by not testing the rear
- * pointer if the front one has wrapped.
- *
- * Returns a 31-bit random number.
- */
-static long random_basic()
-{
- long i;
-
- if (rand_type == TYPE_0)
- i = state[0] = (state[0] * 1103515245 + 12345) & 0x7fffffff;
- else {
- *fptr += *rptr;
- i = (*fptr >> 1) & 0x7fffffff; /* chucking least random bit */
- if (++fptr >= end_ptr) {
- fptr = state;
- ++rptr;
- } else if (++rptr >= end_ptr)
- rptr = state;
- }
- return(i);
-}
-
-long random()
-{
- long ret;
-
- pthread_mutex_lock(&random_mutex);
- ret = random_basic();
- pthread_mutex_unlock(&random_mutex);
- return(ret);
-}
-/*
- * srandom:
- *
- * Initialize the random number generator based on the given seed. If the
- * type is the trivial no-state-information type, just remember the seed.
- * Otherwise, initializes state[] based on the given "seed" via a linear
- * congruential generator. Then, the pointers are set to known locations
- * that are exactly rand_sep places apart. Lastly, it cycles the state
- * information a given number of times to get rid of any initial dependencies
- * introduced by the L.C.R.N.G. Note that the initialization of randtbl[]
- * for default usage relies on values produced by this routine.
- */
-static void srandom_basic(u_int x)
-{
- int i;
-
- state[0] = x;
- for (i = 1; i < rand_deg; i++)
- state[i] = 1103515245 * state[i - 1] + 12345;
- fptr = &state[rand_sep];
- rptr = &state[0];
-
- for (i = 0; i < 10 * rand_deg; i++)
- (void)random_basic();
-}
-
-void srandom(u_int x)
-{
- pthread_mutex_lock(&random_mutex);
- srandom_basic(x);
- pthread_mutex_unlock(&random_mutex);
-}
-
-/*
- * initstate:
- *
- * Initialize the state information in the given array of n bytes for future
- * random number generation. Based on the number of bytes we are given, and
- * the break values for the different R.N.G.'s, we choose the best (largest)
- * one we can and set things up for it. srandom() is then called to
- * initialize the state information.
- *
- * Note that on return from srandom(), we set state[-1] to be the type
- * multiplexed with the current value of the rear pointer; this is so
- * successive calls to initstate() won't lose this information and will be
- * able to restart with setstate().
- *
- * Note: the first thing we do is save the current state, if any, just like
- * setstate() so that it doesn't matter when initstate is called.
- *
- * Returns a pointer to the old state.
- */
-#ifdef initstate
-#undef initstate
-#endif
-char * initstate(u_int seed, char * arg_state, int n)
-{
- register char *ostate = (char *)(&state[-1]);
-
- pthread_mutex_lock(&random_mutex);
-
- if (rand_type == TYPE_0)
- state[-1] = rand_type;
- else
- state[-1] = MAX_TYPES * (rptr - state) + rand_type;
- if (n < BREAK_0) {
- (void)fprintf(stderr,
- "random: not enough state (%d bytes); ignored.\n", n);
- pthread_mutex_unlock(&random_mutex);
- return(0);
- }
- if (n < BREAK_1) {
- rand_type = TYPE_0;
- rand_deg = DEG_0;
- rand_sep = SEP_0;
- } else if (n < BREAK_2) {
- rand_type = TYPE_1;
- rand_deg = DEG_1;
- rand_sep = SEP_1;
- } else if (n < BREAK_3) {
- rand_type = TYPE_2;
- rand_deg = DEG_2;
- rand_sep = SEP_2;
- } else if (n < BREAK_4) {
- rand_type = TYPE_3;
- rand_deg = DEG_3;
- rand_sep = SEP_3;
- } else {
- rand_type = TYPE_4;
- rand_deg = DEG_4;
- rand_sep = SEP_4;
- }
- state = &(((long *)arg_state)[1]); /* first location */
- end_ptr = &state[rand_deg]; /* must set end_ptr before srandom */
- srandom_basic(seed);
- if (rand_type == TYPE_0)
- state[-1] = rand_type;
- else
- state[-1] = MAX_TYPES*(rptr - state) + rand_type;
- pthread_mutex_unlock(&random_mutex);
- return(ostate);
-}
-
-/*
- * setstate:
- *
- * Restore the state from the given state array.
- *
- * Note: it is important that we also remember the locations of the pointers
- * in the current state information, and restore the locations of the pointers
- * from the old state information. This is done by multiplexing the pointer
- * location into the zeroeth word of the state information.
- *
- * Note that due to the order in which things are done, it is OK to call
- * setstate() with the same state as the current state.
- *
- * Returns a pointer to the old state information.
- */
-#ifdef setstate
-#undef setstate
-#endif
-char * setstate(char * arg_state)
-{
- register long *new_state = (long *)arg_state;
- register int type = new_state[0] % MAX_TYPES;
- register int rear = new_state[0] / MAX_TYPES;
- char *ostate = (char *)(&state[-1]);
-
- pthread_mutex_lock(&random_mutex);
-
- if (rand_type == TYPE_0)
- state[-1] = rand_type;
- else
- state[-1] = MAX_TYPES * (rptr - state) + rand_type;
- switch(type) {
- case TYPE_0:
- case TYPE_1:
- case TYPE_2:
- case TYPE_3:
- case TYPE_4:
- rand_type = type;
- rand_deg = degrees[type];
- rand_sep = seps[type];
- break;
- default:
- (void)fprintf(stderr,
- "random: state info corrupted; not changed.\n");
- }
- state = &new_state[1];
- if (rand_type != TYPE_0) {
- rptr = &state[rear];
- fptr = &state[(rear + rand_sep) % rand_deg];
- }
- end_ptr = &state[rand_deg]; /* set end_ptr too */
-
- pthread_mutex_unlock(&random_mutex);
- return(ostate);
-}
-
diff --git a/lib/libpthread/stdlib/strtod.c b/lib/libpthread/stdlib/strtod.c
deleted file mode 100644
index 173ca1e4bdf..00000000000
--- a/lib/libpthread/stdlib/strtod.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
-** An alternative implemtation of "strtod()" that is both
-** simplier, and thread-safe.
-*/
-#include <pthread.h>
-#include <ctype.h>
-#include <math.h>
-
-#ifdef TEST
-# define strtod NewStrtod
-#include <stdio.h>
-#endif
-
-static double scaler10[] = {
- 1.0, 1e10, 1e20, 1e30, 1e40, 1e50, 1e60, 1e70, 1e80, 1e90
-};
-static double scaler1[] = {
- 1.0, 10.0, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9
-};
-static double pastpoint[] = {
- 1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6, 1e-7, 1e-8, 1e-9,
- 1e-10, 1e-11, 1e-12, 1e-13, 1e-14, 1e-15, 1e-16, 1e-17, 1e-18, 1e-19,
- 1e-20, 1e-21, 1e-22, 1e-23, 1e-24, 1e-25, 1e-26, 1e-27, 1e-28, 1e-29,
- 1e-30, 1e-31, 1e-32, 1e-33, 1e-34, 1e-35, 1e-36, 1e-37, 1e-38, 1e-39,
- 1e-40, 1e-41, 1e-42, 1e-43, 1e-44, 1e-45, 1e-46, 1e-47, 1e-48, 1e-49,
- 1e-50, 1e-51, 1e-52, 1e-53, 1e-54, 1e-55, 1e-56, 1e-57, 1e-58, 1e-59,
-};
-
-#ifndef DBL_MAX
-#define DBL_MAX 1.7976931348623157e+308
-#endif
-
-double strtod(const char *zNum, char **pzEnd){
- double rResult = 0.0;
- int isNegative = 0;
-
- while( isspace(*zNum) ){
- zNum++;
- }
- if( *zNum=='-' ){
- zNum++;
- isNegative = 1;
- }else if( *zNum=='+' ){
- zNum++;
- }
- while( isdigit(*zNum) ){
- rResult = rResult*10.0 + (*zNum - '0');
- zNum++;
- }
- if( *zNum=='.' ){
- int n = 0;
- zNum++;
- while( isdigit(*zNum) ){
- if( n<sizeof(pastpoint)/sizeof(pastpoint[0]) ){
- rResult += pastpoint[n] * (*zNum - '0');
- n++;
- }
- zNum++;
- }
- }
- if( *zNum=='e' || *zNum=='E' ){
- int expVal = 0;
- int isNegExp = 0;
- const char *zExpStart = zNum;
- zNum++;
- if( *zNum=='-' ){
- isNegExp = 1;
- zNum++;
- }else if( *zNum=='+' ){
- zNum++;
- }
- if( !isdigit(*zNum) ){
- zNum = zExpStart;
- }else{
- double scaler = 1.0;
- while( isdigit(*zNum) ){
- expVal = expVal*10 + *zNum - '0';
- zNum++;
- }
- if( expVal >= 1000 ){
- if( isNegExp ){
- rResult = 0.0;
- }else{
- rResult = DBL_MAX;
- }
- goto done;
- }
- while( expVal >= 100 ){
- scaler *= 1.0e100;
- expVal -= 100;
- }
- scaler *= scaler10[expVal/10]*scaler1[expVal%10];
- if( isNegExp ){
- scaler = 1.0/scaler;
- }
- rResult *= scaler;
- }
-
- }
-
-done:
- if( pzEnd ){
- *pzEnd = (char *)zNum;
- }
- if( isNegative && rResult!=0.0 ){
- rResult = -rResult;
- }
- return rResult;
-}
-
-double atof(const char *nptr)
-{
- return (strtod(nptr, 0));
-}
-
-#ifdef TEST
-#undef strtod
-
-double strtod(const char*,char**);
-double NewStrtod(const char*,char**);
-
-int main(int argc, char **argv){
- int nTest = 0;
- int nFail = 0;
- int nBigFail = 0;
- char zBuf[1000];
-
- while( fgets(zBuf,sizeof(zBuf),stdin) ){
- double old, new;
- char *zTailOld, *zTailNew;
- int i;
-
- for(i=0; zBuf[i] && zBuf[i]!='\n'; i++){}
- zBuf[i] = 0;
-
-#if TEST==1
- printf("Input line: [%s]\n",zBuf);
- old = strtod(zBuf,&zTailOld);
- printf("value=%g\n",old);
- printf("Old: 0x%08x%08x tail=[%s]\n",
- ((int*)&old)[1], ((int*)&old)[0], zTailOld);
- new = NewStrtod(zBuf,&zTailNew);
- printf("value=%g\n",new);
- printf("New: 0x%08x%08x tail=[%s]\n\n",
- ((int*)&new)[1], ((int*)&new)[0], zTailNew);
-#else
- old = strtod(zBuf,&zTailOld);
- new = NewStrtod(zBuf,&zTailNew);
- nTest++;
- if( strcmp(zTailOld,zTailNew)
- || ((int*)&old)[0]!=((int*)&new)[0]
- || ((int*)&old)[1]!=((int*)&new)[1]
- ){
- int olda, oldb, newa, newb;
-
- nFail++;
- olda = ((int*)&old)[1];
- oldb = ((int*)&old)[0];
- newa = ((int*)&new)[1];
- newb = ((int*)&new)[0];
-
- if( olda!=newa || abs(oldb-newb)>2 ){
- nBigFail++;
- printf("******* Big failure \n");
- }
- printf("Input = [%s]\n",zBuf);
- printf("old: val=%g 0x%08x%08x tail=[%s]\n",
- old, olda, oldb, zTailOld);
- printf("new: val=%g 0x%08x%08x tail=[%s]\n\n",
- new, newa, newb, zTailNew);
- }
-#endif
- }
-
- printf("Out of %d tests, %d failures and %d big failurs\n",
- nTest,nFail, nBigFail);
-}
-#endif
diff --git a/lib/libpthread/stdlib/strtol.c b/lib/libpthread/stdlib/strtol.c
deleted file mode 100644
index 7bb0cb9db18..00000000000
--- a/lib/libpthread/stdlib/strtol.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)strtol.c 5.4 (Berkeley) 2/23/91";*/
-static char *rcsid = "$Id: strtol.c,v 1.1 1998/07/21 13:22:19 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <limits.h>
-#include <ctype.h>
-#include <errno.h>
-#include <stdlib.h>
-
-
-/*
- * Convert a string to a long integer.
- *
- * Ignores `locale' stuff. Assumes that the upper and lower case
- * alphabets and digits are each contiguous.
- */
-long
-strtol(nptr, endptr, base)
- const char *nptr;
- char **endptr;
- register int base;
-{
- register const char *s = nptr;
- register unsigned long acc;
- register int c;
- register unsigned long cutoff;
- register int neg = 0, any, cutlim;
-
- /*
- * Skip white space and pick up leading +/- sign if any.
- * If base is 0, allow 0x for hex and 0 for octal, else
- * assume decimal; if base is already 16, allow 0x.
- */
- do {
- c = *s++;
- } while (isspace(c));
- if (c == '-') {
- neg = 1;
- c = *s++;
- } else if (c == '+')
- c = *s++;
- if ((base == 0 || base == 16) &&
- c == '0' && (*s == 'x' || *s == 'X')) {
- c = s[1];
- s += 2;
- base = 16;
- }
- if (base == 0)
- base = c == '0' ? 8 : 10;
-
- /*
- * Compute the cutoff value between legal numbers and illegal
- * numbers. That is the largest legal value, divided by the
- * base. An input number that is greater than this value, if
- * followed by a legal input character, is too big. One that
- * is equal to this value may be valid or not; the limit
- * between valid and invalid numbers is then based on the last
- * digit. For instance, if the range for longs is
- * [-2147483648..2147483647] and the input base is 10,
- * cutoff will be set to 214748364 and cutlim to either
- * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated
- * a value > 214748364, or equal but the next digit is > 7 (or 8),
- * the number is too big, and we will return a range error.
- *
- * Set any if any `digits' consumed; make it negative to indicate
- * overflow.
- */
- cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX;
- cutlim = cutoff % (unsigned long)base;
- cutoff /= (unsigned long)base;
- for (acc = 0, any = 0;; c = *s++) {
- if (isdigit(c))
- c -= '0';
- else if (isalpha(c))
- c -= isupper(c) ? 'A' - 10 : 'a' - 10;
- else
- break;
- if (c >= base)
- break;
- if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
- any = -1;
- else {
- any = 1;
- acc *= base;
- acc += c;
- }
- }
- if (any < 0) {
- acc = neg ? LONG_MIN : LONG_MAX;
- errno = ERANGE;
- } else if (neg)
- acc = -acc;
- if (endptr != 0)
- *endptr = (char *) (any ? s - 1 : nptr);
- return (acc);
-}
diff --git a/lib/libpthread/stdlib/strtoul.c b/lib/libpthread/stdlib/strtoul.c
deleted file mode 100644
index f59a0b04cf8..00000000000
--- a/lib/libpthread/stdlib/strtoul.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 1990 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)strtoul.c 5.3 (Berkeley) 2/23/91";*/
-static char *rcsid = "$Id: strtoul.c,v 1.1 1998/07/21 13:22:19 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <limits.h>
-#include <ctype.h>
-#include <errno.h>
-#include <stdlib.h>
-
-/*
- * Convert a string to an unsigned long integer.
- *
- * Ignores `locale' stuff. Assumes that the upper and lower case
- * alphabets and digits are each contiguous.
- */
-unsigned long
-strtoul(nptr, endptr, base)
- const char *nptr;
- char **endptr;
- register int base;
-{
- register const char *s = nptr;
- register unsigned long acc;
- register int c;
- register unsigned long cutoff;
- register int neg = 0, any, cutlim;
-
- /*
- * See strtol for comments as to the logic used.
- */
- do {
- c = *s++;
- } while (isspace(c));
- if (c == '-') {
- neg = 1;
- c = *s++;
- } else if (c == '+')
- c = *s++;
- if ((base == 0 || base == 16) &&
- c == '0' && (*s == 'x' || *s == 'X')) {
- c = s[1];
- s += 2;
- base = 16;
- }
- if (base == 0)
- base = c == '0' ? 8 : 10;
- cutoff = (unsigned long)ULONG_MAX / (unsigned long)base;
- cutlim = (unsigned long)ULONG_MAX % (unsigned long)base;
- for (acc = 0, any = 0;; c = *s++) {
- if (isdigit(c))
- c -= '0';
- else if (isalpha(c))
- c -= isupper(c) ? 'A' - 10 : 'a' - 10;
- else
- break;
- if (c >= base)
- break;
- if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
- any = -1;
- else {
- any = 1;
- acc *= base;
- acc += c;
- }
- }
- if (any < 0) {
- acc = ULONG_MAX;
- errno = ERANGE;
- } else if (neg)
- acc = -acc;
- if (endptr != 0)
- *endptr = (char *) (any ? s - 1 : nptr);
- return (acc);
-}
diff --git a/lib/libpthread/stdlib/system.c b/lib/libpthread/stdlib/system.c
deleted file mode 100644
index d43c5ce3d7c..00000000000
--- a/lib/libpthread/stdlib/system.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 1988 The Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)system.c 5.10 (Berkeley) 2/23/91";*/
-static char *rcsid = "$Id: system.c,v 1.1 1998/07/21 13:22:19 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <pthread/paths.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <unistd.h>
-
-extern char **environ;
-
-system(command)
- const char *command;
-{
- char *argp[] = {"sh", "-c", "*to be filled in*", NULL};
- void (*intsave)(), (*quitsave)(), (*signal())();
- sigset_t tmp_mask, old_mask;
- int pstat;
- pid_t pid;
-
- if (!command) /* just checking... */
- return(1);
-
- argp[2] = (char *) command;
- sigemptyset(&tmp_mask);
- sigaddset(&tmp_mask, SIGCHLD);
- pthread_sigmask(SIG_BLOCK, &tmp_mask, &old_mask);
- switch(pid = fork()) {
- case -1: /* error */
- (void)pthread_sigmask(SIG_SETMASK, &old_mask, NULL);
- return(-1);
- case 0: /* child */
- (void)pthread_sigmask(SIG_SETMASK, &old_mask, NULL);
- execve(_PATH_BSHELL, argp, environ);
- _exit(127);
- }
-
- intsave = pthread_signal(SIGINT, SIG_IGN);
- quitsave = pthread_signal(SIGQUIT, SIG_IGN);
- pid = waitpid(pid, (int *)&pstat, 0);
- (void)pthread_sigmask(SIG_SETMASK, &old_mask, NULL);
- (void)pthread_signal(SIGQUIT, quitsave);
- (void)pthread_signal(SIGINT, intsave);
- return(pid == -1 ? -1 : pstat);
-}
diff --git a/lib/libpthread/string/Makefile.inc b/lib/libpthread/string/Makefile.inc
deleted file mode 100644
index b76cb22565d..00000000000
--- a/lib/libpthread/string/Makefile.inc
+++ /dev/null
@@ -1,8 +0,0 @@
-# from: @(#)Makefile.inc 5.21 (Berkeley) 5/24/91
-# $Id: Makefile.inc,v 1.2 1998/07/21 16:28:48 peter Exp $
-
-# string sources
-.PATH: ${.CURDIR}/string
-
-SRCS+= strtok.c
-
diff --git a/lib/libpthread/string/strtok.c b/lib/libpthread/string/strtok.c
deleted file mode 100644
index e6c012aa71c..00000000000
--- a/lib/libpthread/string/strtok.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (c) 1988 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)strtok.c 5.8 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: strtok.c,v 1.1 1998/07/21 13:22:19 peter Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <pthread.h>
-#include <string.h>
-#include <stdlib.h>
-
-char *
-strtok(s, delim)
- register char *s;
- register const char *delim;
-{
- static pthread_mutex_t strtok_mutex = PTHREAD_MUTEX_INITIALIZER;
- static pthread_key_t strtok_key = -1;
- char **lasts;
-
- pthread_mutex_lock(&strtok_mutex);
- if (strtok_key < 0) {
- if (pthread_key_create(&strtok_key, free) < 0) {
- pthread_mutex_unlock(&strtok_mutex);
- return(NULL);
- }
- }
- pthread_mutex_unlock(&strtok_mutex);
- if ((lasts = pthread_getspecific(strtok_key)) == NULL) {
- if ((lasts = (char **)malloc(sizeof(char *))) == NULL) {
- return(NULL);
- }
- pthread_setspecific(strtok_key, lasts);
- }
-
- return(strtok_r(s, delim, lasts));
-}
-
-char *
-strtok_r(s, delim, lasts)
- register char *s;
- register const char *delim;
- register char **lasts;
-{
- register char *spanp;
- register int c, sc;
- char *tok;
-
-
- if (s == NULL && (s = *lasts) == NULL)
- return (NULL);
-
- /*
- * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
- */
-cont:
- c = *s++;
- for (spanp = (char *)delim; (sc = *spanp++) != 0;) {
- if (c == sc)
- goto cont;
- }
-
- if (c == 0) { /* no non-delimiter characters */
- *lasts = NULL;
- return (NULL);
- }
- tok = s - 1;
-
- /*
- * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
- * Note that delim must have one NUL; we stop if we see that, too.
- */
- for (;;) {
- c = *s++;
- spanp = (char *)delim;
- do {
- if ((sc = *spanp++) == c) {
- if (c == 0)
- s = NULL;
- else
- s[-1] = 0;
- *lasts = s;
- return (tok);
- }
- } while (sc != 0);
- }
- /* NOTREACHED */
-}
diff --git a/lib/libpthread/tests/Makefile b/lib/libpthread/tests/Makefile
deleted file mode 100644
index bff425a8155..00000000000
--- a/lib/libpthread/tests/Makefile
+++ /dev/null
@@ -1,124 +0,0 @@
-# Generated automatically from Makefile.in by configure.
-# === GNUmakefile ============================================================
-# Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
-#
-# Description: This file is for creating the test programs for libpthread.a
-#
-# 1.00 93/08/03 proven
-# -Initial cut for pthreads.
-#
-
-INCLUDES= -I/usr/include/pthread
-CFLAGS = -O2 -g -Werror $(INCLUDES) -DSRCDIR="\"${.CURDIR}\""
-LDFLAGS = -static -lm -lgcc -L../obj.${MACHINE}/ -lpthread
-
-# This list used to include test_select, but that test doesn't terminate.
-TESTS = test_create test_pthread_join test_switch test_sleep test_readdir \
- test_fork test_execve test_preemption test_preemption_float \
- test_sock_1 test_sock_2 test_stdio_1 test_pthread_mutex \
- test_pthread_cond_timedwait test_netdb test_pw test_cwd
-# This list used to include p_bench_semaphore, but the semaphore support isn't
-# defined for all targets (or used for any).
-BENCHMARKS = p_bench_read p_bench_mutex p_bench_yield \
- p_bench_getpid p_bench_pthread_create
-
-OBJS= ${TESTS:=.o}
-BOBJS= ${BENCHMARKS:=.o}
-
-all : $(TESTS) $(BENCHMARKS)
-
-${TESTS}: ${OBJS}
- ${CC} ${CFLAGS} -o ${.TARGET} ${.TARGET:=.o} ${LDFLAGS}
-
-${BENCHMARKS}: ${BOBJS}
- ${CC} ${CFLAGS} -o ${.TARGET} ${.TARGET:=.o} ${LDFLAGS}
-
-check : $(TESTS)
- set -e ; \
- for i in $(TESTS) ; do \
- echo Running test $$i ... ; \
- ./$$i ; \
- done
-
-clean:
- rm -f *.o $(TESTS) $(BENCHMARKS) a.out core maketmp makeout
-
-depend:
- sed '/\#\#\# Dependencies/q' < Makefile > maketmp
- (for i in $(CSRC);do $(CPP) -M $$i;done) >> maketmp
- cp maketmp Makefile
-
-#test_create : test_create.o ../libpthread.a
-# $(CC) $(CFLAGS) -o test_create test_create.o $(LIBS)
-#
-#test_pthread_join : test_pthread_join.o ../libpthread.a
-# $(CC) $(CFLAGS) -o test_pthread_join test_pthread_join.o $(LIBS)
-#
-#test_switch : test_switch.o ../libpthread.a
-# $(CC) $(CFLAGS) -o test_switch test_switch.o $(LIBS)
-#
-#test_sleep : test_sleep.o ../libpthread.a
-# $(CC) $(CFLAGS) -o test_sleep test_sleep.o $(LIBS)
-#
-#test_readdir : test_readdir.o ../libpthread.a
-# $(CC) $(CFLAGS) -o test_readdir test_readdir.o $(LIBS)
-#
-#test_fork : test_fork.o ../libpthread.a
-# $(CC) $(CFLAGS) -o test_fork test_fork.o $(LIBS)
-#
-#test_execve : test_execve.o ../libpthread.a
-# $(CC) $(CFLAGS) -o test_execve test_execve.o $(LIBS)
-#
-#test_preemption : test_preemption.o ../libpthread.a
-# $(CC) $(CFLAGS) -o test_preemption test_preemption.o $(LIBS)
-#
-#test_preemption_float : test_preemption_float.o ../libpthread.a
-# $(CC) $(CFLAGS) -o test_preemption_float test_preemption_float.o $(LIBS)
-#
-#test_stdio_1 : test_stdio_1.o ../libpthread.a
-# $(CC) $(CFLAGS) -o test_stdio_1 test_stdio_1.o $(LIBS)
-#
-#test_sock_1 : test_sock_1.o ../libpthread.a
-# $(CC) $(CFLAGS) -o test_sock_1 test_sock_1.o $(LIBS)
-#
-#test_sock_2 : test_sock_2a test_sock_2.o ../libpthread.a
-# $(CC) $(CFLAGS) -o test_sock_2 test_sock_2.o $(LIBS)
-#
-#test_sock_2a : test_sock_2a.o ../libpthread.a
-# $(CC) $(CFLAGS) -o test_sock_2a test_sock_2a.o $(LIBS)
-#
-#test_pthread_mutex : test_pthread_mutex.o ../libpthread.a
-# $(CC) $(CFLAGS) -o test_pthread_mutex test_pthread_mutex.o $(LIBS)
-#
-#test_pthread_cond_timedwait : test_pthread_cond_timedwait.o ../libpthread.a
-# $(CC) $(CFLAGS) -o test_pthread_cond_timedwait test_pthread_cond_timedwait.o $(LIBS)
-#
-#test_netdb : test_netdb.o ../libpthread.a
-# $(CC) $(CFLAGS) -o test_netdb test_netdb.o $(LIBS)
-#
-#test_select : test_select.o ../obj/libpthread.a
-# $(CC) $(CFLAGS) -o test_select test_select.o $(LIBS)
-#
-#test_pw : test_pw.o ../obj/libpthread.a
-# $(CC) $(CFLAGS) -o test_pw test_pw.o $(LIBS)
-#
-#test_cwd : test_cwd.o ../obj/libpthread.a
-# $(CC) $(CFLAGS) -o test_cwd test_cwd.o $(LIBS)
-#
-#p_bench_read : p_bench_read.o ../libpthread.a
-# $(CC) $(CFLAGS) -o p_bench_read p_bench_read.o $(LIBS)
-#
-#p_bench_semaphore : p_bench_semaphore.o ../libpthread.a
-# $(CC) $(CFLAGS) -o p_bench_semaphore p_bench_semaphore.o $(LIBS)
-#
-#p_bench_mutex : p_bench_mutex.o ../libpthread.a
-# $(CC) $(CFLAGS) -o p_bench_mutex p_bench_mutex.o $(LIBS)
-#
-#p_bench_yield : p_bench_yield.o ../libpthread.a
-# $(CC) $(CFLAGS) -o p_bench_yield p_bench_yield.o $(LIBS)
-#
-#p_bench_getpid : p_bench_getpid.o ../libpthread.a
-# $(CC) $(CFLAGS) -o p_bench_getpid p_bench_getpid.o $(LIBS)
-#
-#p_bench_pthread_create : p_bench_pthread_create.o ../libpthread.a
-# $(CC) $(CFLAGS) -o p_bench_pthread_create p_bench_pthread_create.o $(LIBS)
diff --git a/lib/libpthread/tests/Makefile.in b/lib/libpthread/tests/Makefile.in
deleted file mode 100644
index 6e01b6bffc3..00000000000
--- a/lib/libpthread/tests/Makefile.in
+++ /dev/null
@@ -1,164 +0,0 @@
-# === GNUmakefile ============================================================
-# Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
-#
-# Description: This file is for creating the test programs for libpthread.a
-#
-# 1.00 93/08/03 proven
-# -Initial cut for pthreads.
-#
-
-CC = ../pgcc -notinstalled
-CPP = @CPP@
-srctop = @srctop@
-srcdir = @srctop@/tests
-VPATH = @srctop@/tests
-CDEBUGFLAGS = @CFLAGS@
-
-INCLUDES= -I../include -I.. -I$(srctop)/include
-CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(ADDL_CFLAGS) -DSRCDIR=\"$(srcdir)\"
-LIBS = -lm -lgcc -L../obj/ -lpthread
-#LIBS = -static
-
-# This list used to include test_select, but that test doesn't terminate.
-TESTS = test_create test_pthread_join test_switch test_sleep test_readdir \
- test_fork test_execve test_preemption test_preemption_float \
- test_sock_1 test_sock_2 test_stdio_1 test_pthread_mutex \
- test_pthread_cond_timedwait test_netdb test_pw test_cwd
-# This list used to include p_bench_semaphore, but the semaphore support isn't
-# defined for all targets (or used for any).
-BENCHMARKS = p_bench_read p_bench_mutex p_bench_yield \
- p_bench_getpid p_bench_pthread_create
-
-all : $(TESTS) $(BENCHMARKS)
-
-check : $(TESTS)
- set -e ; \
- for i in $(TESTS) ; do \
- echo Running test $$i ... ; \
- ./$$i ; \
- done
-
-# More flags
-ADDITIONALFLAGS = -DPTHREAD_INITIAL_PORT
-################################################################################
-#
-
-clean:
- rm -f *.o $(TESTS) $(BENCHMARKS) a.out core maketmp makeout
-
-depend:
- sed '/\#\#\# Dependencies/q' < Makefile > maketmp
- (for i in $(CSRC);do $(CPP) -M $$i;done) >> maketmp
- cp maketmp Makefile
-
-install:
-
-realclean: clean
- rm -f Makefile
-
-.c.o:
- $(CC) $(CFLAGS) -c $<
-
-Makefile: Makefile.in
- (cd .. ; sh config.status)
-
-test_create : test_create.o ../libpthread.a
- $(CC) $(CFLAGS) -o test_create test_create.o $(LIBS)
-
-test_pthread_join : test_pthread_join.o ../libpthread.a
- $(CC) $(CFLAGS) -o test_pthread_join test_pthread_join.o $(LIBS)
-
-test_switch : test_switch.o ../libpthread.a
- $(CC) $(CFLAGS) -o test_switch test_switch.o $(LIBS)
-
-test_sleep : test_sleep.o ../libpthread.a
- $(CC) $(CFLAGS) -o test_sleep test_sleep.o $(LIBS)
-
-test_readdir : test_readdir.o ../libpthread.a
- $(CC) $(CFLAGS) -o test_readdir test_readdir.o $(LIBS)
-
-test_fork : test_fork.o ../libpthread.a
- $(CC) $(CFLAGS) -o test_fork test_fork.o $(LIBS)
-
-test_execve : test_execve.o ../libpthread.a
- $(CC) $(CFLAGS) -o test_execve test_execve.o $(LIBS)
-
-test_preemption : test_preemption.o ../libpthread.a
- $(CC) $(CFLAGS) -o test_preemption test_preemption.o $(LIBS)
-
-test_preemption_float : test_preemption_float.o ../libpthread.a
- $(CC) $(CFLAGS) -o test_preemption_float test_preemption_float.o $(LIBS)
-
-test_stdio_1 : test_stdio_1.o ../libpthread.a
- $(CC) $(CFLAGS) -o test_stdio_1 test_stdio_1.o $(LIBS)
-
-test_sock_1 : test_sock_1.o ../libpthread.a
- $(CC) $(CFLAGS) -o test_sock_1 test_sock_1.o $(LIBS)
-
-test_sock_2 : test_sock_2a test_sock_2.o ../libpthread.a
- $(CC) $(CFLAGS) -o test_sock_2 test_sock_2.o $(LIBS)
-
-test_sock_2a : test_sock_2a.o ../libpthread.a
- $(CC) $(CFLAGS) -o test_sock_2a test_sock_2a.o $(LIBS)
-
-test_pthread_mutex : test_pthread_mutex.o ../libpthread.a
- $(CC) $(CFLAGS) -o test_pthread_mutex test_pthread_mutex.o $(LIBS)
-
-test_pthread_cond_timedwait : test_pthread_cond_timedwait.o ../libpthread.a
- $(CC) $(CFLAGS) -o test_pthread_cond_timedwait test_pthread_cond_timedwait.o $(LIBS)
-
-test_netdb : test_netdb.o ../libpthread.a
- $(CC) $(CFLAGS) -o test_netdb test_netdb.o $(LIBS)
-
-test_select : test_select.o ../obj/libpthread.a
- $(CC) $(CFLAGS) -o test_select test_select.o $(LIBS)
-
-test_pw : test_pw.o ../obj/libpthread.a
- $(CC) $(CFLAGS) -o test_pw test_pw.o $(LIBS)
-
-test_cwd : test_cwd.o ../obj/libpthread.a
- $(CC) $(CFLAGS) -o test_cwd test_cwd.o $(LIBS)
-
-p_bench_read : p_bench_read.o ../libpthread.a
- $(CC) $(CFLAGS) -o p_bench_read p_bench_read.o $(LIBS)
-
-p_bench_semaphore : p_bench_semaphore.o ../libpthread.a
- $(CC) $(CFLAGS) -o p_bench_semaphore p_bench_semaphore.o $(LIBS)
-
-p_bench_mutex : p_bench_mutex.o ../libpthread.a
- $(CC) $(CFLAGS) -o p_bench_mutex p_bench_mutex.o $(LIBS)
-
-p_bench_yield : p_bench_yield.o ../libpthread.a
- $(CC) $(CFLAGS) -o p_bench_yield p_bench_yield.o $(LIBS)
-
-p_bench_getpid : p_bench_getpid.o ../libpthread.a
- $(CC) $(CFLAGS) -o p_bench_getpid p_bench_getpid.o $(LIBS)
-
-p_bench_pthread_create : p_bench_pthread_create.o ../libpthread.a
- $(CC) $(CFLAGS) -o p_bench_pthread_create p_bench_pthread_create.o $(LIBS)
-
-test_create.o : test_create.c
-test_pthread_join.o : test_pthread_join.c
-test_switch.o : test_switch.c
-test_sleep.o : test_sleep.c
-test_readdir.o : test_readdir.c
-test_fork.o : test_fork.c
-test_execve.o : test_execve.c
-test_preemption.o : test_preemption.c
-test_preemption_float.o : test_preemption_float.c
-test_sock_1.o : test_sock_1.c
-test_sock_2.o : test_sock_2.c
-test_sock_3.o : test_sock_3.c
-test_stdio_1.o : test_stdio_1.c
-test_pthread_mutex.o : test_pthread_mutex.c
-test_pthread_cond_timedwait.o : test_pthread_cond_timedwait.c
-p_bench_read.o : p_bench_read.c
-p_bench_semaphore.o : p_bench_semaphore.c
-p_bench_mutex.o : p_bench_mutex.c
-p_bench_yield.o : p_bench_yield.c
-p_bench_getpid.o : p_bench_getpid.c
-p_bench_pthread_create.o : p_bench_pthread_create.c
-
-################################################################################
-### Do not remove the following line. It is for depend #########################
-### Dependencies:
diff --git a/lib/libpthread/tests/README b/lib/libpthread/tests/README
deleted file mode 100755
index bb4a3e7ce01..00000000000
--- a/lib/libpthread/tests/README
+++ /dev/null
@@ -1,26 +0,0 @@
-This directory contains a few test and benchmark programs that I've
-developed to help me test the consistancy of the libpthread.a.
-
-TEST
-----------------------
-test_create Tests the pthread_create() routine. The stack addresses
- should be very different (ie the upper values of the
- address should be different) and the arg should be
- 0xdeadbeaf.
-
-test_switch A nondeterministic test. It should show context switching,
- by displaying different letters.
-
-test_sleep Timing this test should result in a time of about 20 seconds.
- It should sleep for 10 seconds and then print ba 10 times
- at the rate of about once a second.
-
-p_bench_* Benchmarks for various routines.
-
-------------------------------------------------------------------------------
-Copyright (c) 1994 Chris Provenzano. All rights reserved.
-This product includes software developed by the Univeristy of California,
-Berkeley and its contributors.
-
-For further licencing and distribution restrictions see the file COPYRIGHT
-included in the parent directory.
diff --git a/lib/libpthread/tests/bench_fcntl.c b/lib/libpthread/tests/bench_fcntl.c
deleted file mode 100644
index 046046adda4..00000000000
--- a/lib/libpthread/tests/bench_fcntl.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* ==== bench_read.c ============================================================
- * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Benchmark reads of /dev/null. Gives a good aprox. of
- * syscall times.
- *
- * 1.00 93/08/01 proven
- * -Started coding this file.
- */
-
-#include <sys/types.h>
-#include <sys/time.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#define OK 0
-#define NOTOK -1
-/* ==========================================================================
- * usage();
- */
-void usage(void)
-{
- printf("getopt [-d?] [-c count]\n");
- errno = 0;
-}
-
-main(int argc, char **argv)
-{
- struct timeval starttime, endtime;
- int count = 1000000;
- int debug = 0;
- int flags;
- int fd;
- int i;
-
- char word[8192];
-
- /* Getopt variables. */
- extern int optind, opterr;
- extern char *optarg;
-
- while ((word[0] = getopt(argc, argv, "c:d?")) != (char)EOF) {
- switch (word[0]) {
- case 'd':
- debug++;
- break;
- case 'c':
- count = atoi(optarg);
- break;
- case '?':
- usage();
- return(OK);
- default:
- usage();
- return(NOTOK);
- }
- }
-
- if ((fd = open("/dev/zero", O_RDONLY)) < OK) {
- printf("Error: open\n");
- exit(0);
- }
-
- if (gettimeofday(&starttime, NULL)) {
- printf("Error: gettimeofday\n");
- exit(0);
- }
- for (i = 0; i < count; i++) {
- if ((flags = fcntl(0, F_GETFL)) < 0) {
- perror("fcntl 1st GETFL");
- }
- }
- if (gettimeofday(&endtime, NULL)) {
- printf("Error: gettimeofday\n");
- exit(0);
- }
-
- printf("%d fcntls of /dev/null took %d usecs.\n", count,
- (endtime.tv_sec - starttime.tv_sec) * 1000000 +
- (endtime.tv_usec - starttime.tv_usec));
-}
diff --git a/lib/libpthread/tests/bench_pipe.c b/lib/libpthread/tests/bench_pipe.c
deleted file mode 100644
index 8555cf37f67..00000000000
--- a/lib/libpthread/tests/bench_pipe.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/* ==== bench_pipe.c ============================================================
- * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Benchmark reads of /dev/null. Gives a good aprox. of
- * syscall times.
- *
- * 1.00 93/08/01 proven
- * -Started coding this file.
- */
-
-#include <sys/types.h>
-#include <sys/time.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#define OK 0
-#define NOTOK -1
-
-/* ==========================================================================
- * usage();
- */
-void usage(void)
-{
- printf("bench_pipe [-d?] [-c count]\n");
- errno = 0;
-}
-
-main(int argc, char **argv)
-{
- struct timeval starttime, endtime;
- char buf[1];
- int count = 1000;
- int debug = 0;
- int fd0[2];
- int fd1[2];
- int i;
-
- char word[256];
-
- /* Getopt variables. */
- extern int optind, opterr;
- extern char *optarg;
-
- while ((word[0] = getopt(argc, argv, "c:d?")) != (char)EOF) {
- switch (word[0]) {
- case 'd':
- debug++;
- break;
- case 'c':
- count = atoi(optarg);
- break;
- case '?':
- usage();
- return(OK);
- default:
- usage();
- return(NOTOK);
- }
- }
-
- if ((pipe(fd0) < OK) || (pipe(fd1) < OK)) {
- printf("Error: pipe\n");
- exit(0);
- }
-
- switch (fork()) {
- case NOTOK:
- printf("Error: fork\n");
- exit(0);
- case OK: /* Child */
- for (i = 0; i < count; i++) {
- if (read(fd1[0], buf, 1) < OK) {
- printf("Error: child read\n");
- exit(0);
- }
- if (write(fd0[1], buf, 1) < OK) {
- printf("Error: child write\n");
- exit(0);
- }
- }
- exit(0);
- break;
- default:
- break;
- }
-
- if (gettimeofday(&starttime, NULL)) {
- printf("Error: gettimeofday\n");
- exit(0);
- }
- count --;
- if (write(fd1[1], buf, 1) < OK) {
- perror("first parent write");
- exit(0);
- }
- for (i = 0; i < count; i++) {
- if (read(fd0[0], buf, 1) < OK) {
- printf("Error: parent read\n");
- exit(0);
- }
- if (write(fd1[1], buf, 1) < OK) {
- printf("Error: parent write\n");
- exit(0);
- }
- }
- if (gettimeofday(&endtime, NULL)) {
- printf("Error: gettimeofday\n");
- exit(0);
- }
-
- printf("%d ping pong tests took %d usecs.\n", count,
- (endtime.tv_sec - starttime.tv_sec) * 1000000 +
- (endtime.tv_usec - starttime.tv_usec));
-}
diff --git a/lib/libpthread/tests/bench_read.c b/lib/libpthread/tests/bench_read.c
deleted file mode 100644
index 28c8469e270..00000000000
--- a/lib/libpthread/tests/bench_read.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ==== bench_read.c ============================================================
- * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Benchmark reads of /dev/null. Gives a good aprox. of
- * syscall times.
- *
- * 1.00 93/08/01 proven
- * -Started coding this file.
- */
-
-#include <sys/types.h>
-#include <sys/time.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#define OK 0
-#define NOTOK -1
-/* ==========================================================================
- * usage();
- */
-void usage(void)
-{
- printf("getopt [-d?] [-c count] [-s size]\n");
- errno = 0;
-}
-
-main(int argc, char **argv)
-{
- struct timeval starttime, endtime;
- int count = 1000000;
- int debug = 0;
- int size = 1;
- int fd;
- int i;
-
- char word[8192];
-
- /* Getopt variables. */
- extern int optind, opterr;
- extern char *optarg;
-
- while ((word[0] = getopt(argc, argv, "s:c:d?")) != (char)EOF) {
- switch (word[0]) {
- case 'd':
- debug++;
- break;
- case 'c':
- count = atoi(optarg);
- break;
- case 's':
- if ((size = atoi(optarg)) > 8192) {
- size = 8192;
- }
- break;
- case '?':
- usage();
- return(OK);
- default:
- usage();
- return(NOTOK);
- }
- }
-
- if ((fd = open("/netbsd", O_RDONLY)) < OK) {
- printf("Error: open\n");
- exit(0);
- }
-
- if (gettimeofday(&starttime, NULL)) {
- printf("Error: gettimeofday\n");
- exit(0);
- }
- for (i = 0; i < count; i++) {
- if (read(fd, word, size) < OK) {
- printf("Error: read\n");
- exit(0);
- }
- }
- if (gettimeofday(&endtime, NULL)) {
- printf("Error: gettimeofday\n");
- exit(0);
- }
-
- printf("%d reads of /netbsd took %d usecs.\n", count,
- (endtime.tv_sec - starttime.tv_sec) * 1000000 +
- (endtime.tv_usec - starttime.tv_usec));
-}
diff --git a/lib/libpthread/tests/p_bench_getpid.c b/lib/libpthread/tests/p_bench_getpid.c
deleted file mode 100644
index d972d075c1d..00000000000
--- a/lib/libpthread/tests/p_bench_getpid.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/* ==== p_bench_getpid.c =================================================
- * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Benchmark mutex lock and unlock times
- *
- * 1.00 93/11/08 proven
- * -Started coding this file.
- */
-
-#include <errno.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <stdio.h>
-
-#define OK 0
-#define NOTOK -1
-
-/* ==========================================================================
- * usage();
- */
-void usage(void)
-{
- printf("p_bench_getpid [-d?] [-c count]\n");
- errno = 0;
-}
-
-main(int argc, char **argv)
-{
- struct timeval starttime, endtime;
- pthread_mutex_t lock;
- pid_t process_id;
- int count = 1000000;
- int debug = 0;
- int i;
-
- char word[256];
-
- /* Getopt variables. */
- extern int optind, opterr;
- extern char *optarg;
-
- pthread_init();
-
- while ((word[0] = getopt(argc, argv, "c:d?")) != (char)EOF) {
- switch (word[0]) {
- case 'd':
- debug++;
- break;
- case 'c':
- count = atoi(optarg);
- break;
- case '?':
- usage();
- return(OK);
- default:
- usage();
- return(NOTOK);
- }
- }
-
- if (gettimeofday(&starttime, NULL)) {
- perror ("gettimeofday");
- return 1;
- }
- for (i = 0; i < count; i++) {
- process_id = getpid();
- }
- if (gettimeofday(&endtime, NULL)) {
- perror ("gettimeofday");
- return 1;
- }
-
- printf("%d getpid calls took %d usecs.\n", count,
- (endtime.tv_sec - starttime.tv_sec) * 1000000 +
- (endtime.tv_usec - starttime.tv_usec));
-
- return 0;
-}
diff --git a/lib/libpthread/tests/p_bench_mutex.c b/lib/libpthread/tests/p_bench_mutex.c
deleted file mode 100644
index e3179f08072..00000000000
--- a/lib/libpthread/tests/p_bench_mutex.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/* ==== p_bench_mutex.c =================================================
- * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Benchmark mutex lock and unlock times
- *
- * 1.00 93/11/08 proven
- * -Started coding this file.
- */
-
-#include <errno.h>
-#include <pthread.h>
-#include <stdio.h>
-
-#define OK 0
-#define NOTOK -1
-
-/* ==========================================================================
- * usage();
- */
-void usage(void)
-{
- printf("getopt [-d?] [-c count]\n");
- errno = 0;
-}
-
-main(int argc, char **argv)
-{
- struct timeval starttime, endtime;
- pthread_mutex_t lock;
- int count = 1000000;
- int debug = 0;
- int i;
-
- char word[256];
-
- /* Getopt variables. */
- extern int optind, opterr;
- extern char *optarg;
-
- pthread_init();
-
- while ((word[0] = getopt(argc, argv, "c:d?")) != (char)EOF) {
- switch (word[0]) {
- case 'd':
- debug++;
- break;
- case 'c':
- count = atoi(optarg);
- break;
- case '?':
- usage();
- return(OK);
- default:
- usage();
- return(NOTOK);
- }
- }
-
- pthread_mutex_init(&lock, NULL);
- if (gettimeofday(&starttime, NULL)) {
- perror ("gettimeofday");
- return 1;
- }
- for (i = 0; i < count; i++) {
- pthread_mutex_lock(&lock);
- pthread_mutex_unlock(&lock);
- }
- if (gettimeofday(&endtime, NULL)) {
- perror ("gettimeofday");
- return 1;
- }
-
- printf("%d mutex locks/unlocks no contention took %d usecs.\n", count,
- (endtime.tv_sec - starttime.tv_sec) * 1000000 +
- (endtime.tv_usec - starttime.tv_usec));
-
- return 0;
-}
diff --git a/lib/libpthread/tests/p_bench_pthread_create.c b/lib/libpthread/tests/p_bench_pthread_create.c
deleted file mode 100644
index b31b680c665..00000000000
--- a/lib/libpthread/tests/p_bench_pthread_create.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/* ==== p_bench_pthread_create.c =============================================
- * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Benchmark mutex lock and unlock times
- *
- * 1.00 93/11/08 proven
- * -Started coding this file.
- */
-
-#define PTHREAD_KERNEL
-
-#include <errno.h>
-#include <pthread.h>
-#include <stdio.h>
-
-extern pthread_attr_t pthread_attr_default;
-
-/* ==========================================================================
- * new_thread();
- */
-void * new_thread(void * arg)
-{
- PANIC();
-}
-
-/* ==========================================================================
- * usage();
- */
-void usage(void)
-{
- printf("p_bench_getpid [-d?] [-c count]\n");
- errno = 0;
-}
-
-main(int argc, char **argv)
-{
- struct timeval starttime, endtime;
- pthread_mutex_t lock;
- pthread_t thread_id;
- int count = 10000;
- int debug = 0;
- int i;
-
- char word[256];
-
- /* Getopt variables. */
- extern int optind, opterr;
- extern char *optarg;
-
- pthread_init();
- /* Shut timer off */
- machdep_unset_thread_timer(NULL);
- pthread_attr_default.stackaddr_attr = &word;
-
- while ((word[0] = getopt(argc, argv, "c:d?")) != (char)EOF) {
- switch (word[0]) {
- case 'd':
- debug++;
- break;
- case 'c':
- count = atoi(optarg);
- break;
- case '?':
- usage();
- return(OK);
- default:
- usage();
- return(NOTOK);
- }
- }
-
- if (gettimeofday(&starttime, NULL)) {
- perror ("gettimeofday");
- return 1;
- }
- for (i = 0; i < count; i++) {
- if (pthread_create(&thread_id, & pthread_attr_default, new_thread, NULL)) {
- printf("Bad pthread create routine\n");
- exit(1);
- }
- }
- if (gettimeofday(&endtime, NULL)) {
- perror ("gettimeofday");
- return 1;
- }
-
- printf("%d getpid calls took %d usecs.\n", count,
- (endtime.tv_sec - starttime.tv_sec) * 1000000 +
- (endtime.tv_usec - starttime.tv_usec));
-
- return 0;
-}
diff --git a/lib/libpthread/tests/p_bench_read.c b/lib/libpthread/tests/p_bench_read.c
deleted file mode 100644
index 52a6aca7706..00000000000
--- a/lib/libpthread/tests/p_bench_read.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/* ==== p_bench_read.c ============================================================
- * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Benchmark reads of /dev/null. Gives a good aprox. of
- * syscall times.
- *
- * 1.00 93/08/01 proven
- * -Started coding this file.
- */
-
-#include <pthread.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#define OK 0
-#define NOTOK -1
-
-/* ==========================================================================
- * usage();
- */
-void usage(void)
-{
- printf("p_bench_read [-d?] [-c count] [-s size] [-f file]\n");
- errno = 0;
-}
-
-main(int argc, char **argv)
-{
- struct timeval starttime, endtime;
- char *infile = "/dev/null";
- int count = 1000000;
- int debug = 0;
- int size = 1;
- int fd;
- int i;
-
- char word[16384], *word_ptr;
-
- /* Getopt variables. */
- extern int optind, opterr;
- extern char *optarg;
-
- pthread_init();
-
- while ((word[0] = getopt(argc, argv, "c:df:s:?")) != (char)EOF) {
- switch (word[0]) {
- case 'c':
- count = atoi(optarg);
- break;
- case 'd':
- debug++;
- break;
- case 'f':
- infile = optarg;
- break;
- case 's':
- if ((size = atoi(optarg)) > 8192) {
- size = 8192;
- }
- break;
- case '?':
- usage();
- return(OK);
- default:
- usage();
- return(NOTOK);
- }
- }
-
- /* Align buffer boundary to a page boundary */
- word_ptr = (char *)(((size_t) word + 4095) & ~4095);
-
- if ((fd = open(infile, O_RDONLY)) < OK) {
- perror ("open");
- return 1;
- }
-
- if (gettimeofday(&starttime, NULL)) {
- perror ("gettimeofday");
- return 1;
- }
-
- for (i = 0; i < count; i++) {
- if (read(fd, word_ptr, size) < OK) {
- printf("Error: read\n");
- exit(0);
- }
- }
-
- if (gettimeofday(&endtime, NULL)) {
- perror ("gettimeofday");
- return 1;
- }
-
- printf("%d reads of %s took %d usecs.\n", count, infile,
- (endtime.tv_sec - starttime.tv_sec) * 1000000 +
- (endtime.tv_usec - starttime.tv_usec));
-
- return 0;
-}
diff --git a/lib/libpthread/tests/p_bench_semaphore.c b/lib/libpthread/tests/p_bench_semaphore.c
deleted file mode 100644
index b3bce340b95..00000000000
--- a/lib/libpthread/tests/p_bench_semaphore.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* ==== p_bench_semaphore.c =================================================
- * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Benchmark semaphore Test and Set/ CLear times
- *
- * 1.00 93/11/08 proven
- * -Started coding this file.
- */
-
-#include <errno.h>
-#include <pthread.h>
-#include <stdio.h>
-
-#define OK 0
-#define NOTOK -1
-
-/* ==========================================================================
- * usage();
- */
-void usage(void)
-{
- printf("getopt [-d?] [-c count]\n");
- errno = 0;
-}
-
-main(int argc, char **argv)
-{
- struct timeval starttime, endtime;
- semaphore lock = SEMAPHORE_CLEAR;
- semaphore *lock_addr;
- int count = 1000000;
- int debug = 0;
- int i;
-
- char word[256];
-
- /* Getopt variables. */
- extern int optind, opterr;
- extern char *optarg;
-
- pthread_init();
-
- while ((word[0] = getopt(argc, argv, "c:d?")) != (char)EOF) {
- switch (word[0]) {
- case 'd':
- debug++;
- break;
- case 'c':
- count = atoi(optarg);
- break;
- case '?':
- usage();
- return(OK);
- default:
- usage();
- return(NOTOK);
- }
- }
-
- lock_addr = &lock;
- if (gettimeofday(&starttime, NULL)) {
- perror ("gettimeofday");
- return 1;
- }
- for (i = 0; i < count; i++) {
- if (SEMAPHORE_TEST_AND_SET(lock_addr)) {
- printf("Semaphore already locked error\n");
- return 1;
- }
- SEMAPHORE_RESET(lock_addr);
- }
- if (gettimeofday(&endtime, NULL)) {
- perror ("gettimeofday");
- return 1;
- }
-
- printf("%d locks/unlocks of a semaphore took %d usecs.\n", count,
- (endtime.tv_sec - starttime.tv_sec) * 1000000 +
- (endtime.tv_usec - starttime.tv_usec));
-
- return 0;
-}
diff --git a/lib/libpthread/tests/p_bench_yield.c b/lib/libpthread/tests/p_bench_yield.c
deleted file mode 100644
index bb6d86be09e..00000000000
--- a/lib/libpthread/tests/p_bench_yield.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/* ==== p_bench_mutex.c =================================================
- * Copyright (c) 1993-1995 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Benchmark mutex lock and unlock times
- *
- * 1.00 93/11/08 proven
- * -Started coding this file.
- */
-
-#include <errno.h>
-#include <pthread.h>
-#include <stdio.h>
-
-#define OK 0
-#define NOTOK -1
-
-/* ==========================================================================
- * usage();
- */
-void usage(void)
-{
- printf("p_bench_yield [-d?] \\\n");
- printf("\t[-c count] \\\n");
- printf("\t[-C thread count] \\\n");
- printf("\t[-O optimization level]\n");
- errno = 0;
-}
-
-void *yield(void * arg)
-{
- int i, * count;
-
- count = (int *)arg;
- for (i = 0; i < *count; i++) {
- pthread_yield();
- }
- return(NULL);
-}
-
-main(int argc, char **argv)
-{
- struct timeval starttime, endtime;
- pthread_mutex_t lock;
- pthread_attr_t attr;
- pthread_t thread_id;
- int thread_count = 1;
- int optimization = 0;
- int count = 1000000;
- int i, debug = 0;
-
- char word[256];
-
- /* Getopt variables. */
- extern int optind, opterr;
- extern char *optarg;
-
- pthread_init();
-
- while ((word[0] = getopt(argc, argv, "C:O:c:d?")) != (char)EOF) {
- switch (word[0]) {
- case 'C':
- thread_count = atoi(optarg);
- break;
- case 'O':
- optimization = atoi(optarg);
- break;
- case 'c':
- count = atoi(optarg);
- break;
- case 'd':
- debug++;
- break;
- case '?':
- usage();
- return(OK);
- default:
- usage();
- return(NOTOK);
- }
- }
-
- pthread_attr_init(&attr);
- if (optimization > 0) {
- pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
- }
- if (optimization > 1) {
- pthread_attr_setfloatstate(&attr, PTHREAD_NOFLOAT);
- }
-
- pthread_mutex_init(&lock, NULL);
- if (gettimeofday(&starttime, NULL)) {
- perror ("gettimeofday");
- return 1;
- }
- for (i = 1; i < thread_count; i++) {
- if (pthread_create(&thread_id, &attr, yield, &count)) {
- perror ("pthread_create");
- return 1;
- }
- if (pthread_detach(thread_id)) {
- perror ("pthread_detach");
- return 1;
- }
- }
- if (pthread_create(&thread_id, &attr, yield, &count)) {
- perror ("pthread_create");
- return 1;
- }
- if (pthread_join(thread_id, NULL)) {
- perror ("pthread_join");
- return 1;
- }
- if (gettimeofday(&endtime, NULL)) {
- perror ("gettimeofday");
- return 1;
- }
-
- printf("%d pthread_yields took %d usecs.\n", count,
- (endtime.tv_sec - starttime.tv_sec) * 1000000 +
- (endtime.tv_usec - starttime.tv_usec));
-
- return 0;
-}
diff --git a/lib/libpthread/tests/test_create.c b/lib/libpthread/tests/test_create.c
deleted file mode 100644
index 2d82db07c5f..00000000000
--- a/lib/libpthread/tests/test_create.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* ==== test_create.c ============================================================
- * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Test pthread_create() and pthread_exit() calls.
- *
- * 1.00 93/08/03 proven
- * -Started coding this file.
- */
-
-#define PTHREAD_KERNEL
-#include <pthread.h>
-#include <stdio.h>
-
-void* new_thread(void* arg)
-{
- int i;
-
- printf("New thread was passed arg address %x\n", arg);
- printf("New thread stack at %x\n", &i);
- return(NULL);
- PANIC();
-}
-
-main()
-{
- pthread_t thread;
- int i;
-
- printf("Original thread stack at %x\n", &i);
- if (pthread_create(&thread, NULL, new_thread, (void *)0xdeadbeef)) {
- printf("Error: creating new thread\n");
- }
- pthread_exit(NULL);
- PANIC();
-}
diff --git a/lib/libpthread/tests/test_cwd.c b/lib/libpthread/tests/test_cwd.c
deleted file mode 100644
index 979c173d5fc..00000000000
--- a/lib/libpthread/tests/test_cwd.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <stdio.h>
-
-main(int argc, char **argv)
-{
- char wd[1024], *getcwd(), *getwd();
-
- pthread_init();
- printf("getcwd => %s\n", getcwd(wd, 1024));
- printf("getwd => %s\n", getwd(wd));
- exit(0);
-}
diff --git a/lib/libpthread/tests/test_execve.c b/lib/libpthread/tests/test_execve.c
deleted file mode 100644
index f7988457df9..00000000000
--- a/lib/libpthread/tests/test_execve.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/* ==== test_execve.c ============================================================
- * Copyright (c) 1994 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Test execve() and dup2() calls.
- *
- * 1.00 94/04/29 proven
- * -Started coding this file.
- */
-
-#define PTHREAD_KERNEL
-#include <pthread.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdio.h>
-
-extern char **environ;
-char *argv[] = {
- "/bin/echo",
- "This message should be displayed after the execve system call",
- NULL
-};
-
-char * should_succeed = "This line should be displayed\n";
-char * should_fail = "Error: This line should NOT be displayed\n";
-
-main()
-{
- pthread_t thread;
- int fd;
-
- pthread_init();
-
- printf("This is the first message\n");
- if (isatty(1)) {
- if ((fd = open(ttyname(1), O_RDWR)) < OK) {
- printf("Error: opening tty\n");
- exit(1);
- }
- } else {
- printf("Error: stdout not a tty\n");
- exit(1);
- }
-
- printf("This output is necessary to set the stdout fd to NONBLOCKING\n");
-
- /* do a dup2 */
- dup2(fd, 1);
- write(1, should_succeed, (size_t)strlen(should_succeed));
- machdep_sys_write(1, should_fail, strlen(should_fail));
-
- if (execve(argv[0], argv, environ) < OK) {
- printf("Error: execve\n");
- exit(1);
- }
- PANIC();
-}
diff --git a/lib/libpthread/tests/test_fcntl.c b/lib/libpthread/tests/test_fcntl.c
deleted file mode 100644
index 60bc77ce464..00000000000
--- a/lib/libpthread/tests/test_fcntl.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <stdio.h>
-#include <fcntl.h>
-
-main()
-{
- int flags, child;
-
- if ((flags = fcntl(0, F_GETFL)) < 0) {
- perror("fcntl 1st GETFL");
- }
- printf ("flags = %x\n", flags);
-
- switch(child = fork()) {
- case -1:
- printf("error during fork\n");
- break;
- case 0: /* child */
- execlp("test_create", "test_create", NULL);
- break;
- default: /* parent */
- wait(NULL);
- break;
- }
-
- while(1){
- if ((flags = fcntl(0, F_GETFL)) < 0) {
- perror("fcntl parent GETFL");
- }
- printf ("parent %d flags = %x\n", child, flags);
- sleep(1);
- }
-}
diff --git a/lib/libpthread/tests/test_fork.c b/lib/libpthread/tests/test_fork.c
deleted file mode 100644
index 4c2125e678a..00000000000
--- a/lib/libpthread/tests/test_fork.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/* ==== test_fork.c ============================================================
- * Copyright (c) 1994 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Test fork() and dup2() calls.
- *
- * 1.00 94/04/29 proven
- * -Started coding this file.
- */
-
-#define PTHREAD_KERNEL
-#include <pthread.h>
-#include <stdio.h>
-#include <fcntl.h>
-
-main()
-{
- pthread_t thread;
- int flags, pid;
-
- pthread_init();
-
- if (((flags = machdep_sys_fcntl(1, F_GETFL, NULL)) >= OK) &&
- (flags & __FD_NONBLOCK | O_NDELAY)) {
- machdep_sys_fcntl(1, F_SETFL, flags & (~__FD_NONBLOCK | O_NDELAY));
- }
- printf("parent process %d\n", getpid());
-
- switch(pid = fork()) {
- case OK:
- exit(OK);
- break;
- case NOTOK:
- printf("fork() FAILED\n");
- exit(2);
- break;
- default:
- if ((flags = machdep_sys_fcntl(1, F_GETFL, NULL)) >= OK) {
- if (flags & (__FD_NONBLOCK | O_NDELAY)) {
- printf("fd flags not set to BLOCKING ERROR\n");
- printf("test_fork FAILED\n");
- exit(1);
- break;
- }
- printf("The stdout fd was set to BLOCKING\n");
- printf("child process %d\n", pid);
- flags = machdep_sys_fcntl(1, F_GETFL, NULL);
- if (flags & (__FD_NONBLOCK | O_NDELAY)) {
- printf("The stdout fd was reset to O_NDELAY\n");
- } else {
- printf("Error: the stdout fd was not reset\n");
- printf("test_fork FAILED\n");
- exit(1);
- }
- }
- break;
- }
-
- printf("test_fork PASSED\n");
- pthread_exit(NULL);
-}
diff --git a/lib/libpthread/tests/test_netdb.c b/lib/libpthread/tests/test_netdb.c
deleted file mode 100644
index a944579237f..00000000000
--- a/lib/libpthread/tests/test_netdb.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/* ==== test_netdb.c =========================================================
- * Copyright (c) 1995 by Greg Hudson, ghudson@.mit.edu
- *
- * Description : Test netdb calls.
- *
- * 1.00 95/01/05 ghudson
- * -Started coding this file.
- */
-
-#define PTHREAD_KERNEL /* Needed for OK and NOTOK defines */
-#include <pthread.h>
-#include <string.h>
-#include <stdio.h>
-#include <netdb.h>
-#include <errno.h>
-
-int debug = 0;
-
-static int test_serv()
-{
- struct servent *serv;
- char answer[1024];
-
- if (serv = getservbyname("telnet", "tcp"))
- printf("getservbyname -> port %d\n", ntohs(serv->s_port));
- else
- printf("getservbyname -> NULL (bad)\n");
-
- if (serv = getservbyname_r("telnet", "tcp", serv, answer, 1024))
- printf("getservbyname_r -> port %d\n", ntohs(serv->s_port));
- else
- printf("getservbyname_r -> NULL (bad)\n");
- return(OK);
-}
-
-static int test_host()
-{
- struct hostent *host;
- struct in_addr addr;
- char answer[1024];
- int error;
-
- if (host = gethostbyname("maze.mit.edu")) {
- memcpy(&addr, host->h_addr, sizeof(addr));
- printf("gethostbyname -> %s\n", inet_ntoa(addr));
- } else {
- printf("gethostbyname -> NULL (bad)\n");
- host = (struct hostent *)answer;
- }
-
- if (host = gethostbyname_r("maze.mit.edu", host, answer, 1024, &error)) {
- memcpy(&addr, host->h_addr, sizeof(addr));
- printf("gethostbyname_r -> %s\n", inet_ntoa(addr));
- } else {
- printf("gethostbyname_r -> NULL (bad)\n");
- }
- return(OK);
-}
-
-static int test_localhost()
-{
- struct hostent *host;
-
- if (host = gethostbyname("127.0.0.1")) {
- return(OK);
- }
- return(NOTOK);
-}
-
-/* ==========================================================================
- * usage();
- */
-void usage(void)
-{
- printf("test_netdb [-d?]\n");
- errno = 0;
-}
-
-main(int argc, char **argv)
-{
-
- /* Getopt variables. */
- extern int optind, opterr;
- extern char *optarg;
- char ch;
-
- while ((ch = getopt(argc, argv, "d?")) != (char)EOF) {
- switch (ch) {
- case 'd':
- debug++;
- break;
- case '?':
- usage();
- return(OK);
- default:
- usage();
- return(NOTOK);
- }
- }
-
- printf("test_netdb START\n");
-
- if (test_serv() || test_localhost() || test_host()) {
- printf("test_netdb FAILED\n");
- exit(1);
- }
-
- printf("test_netdb PASSED\n");
- exit(0);
-}
diff --git a/lib/libpthread/tests/test_pause.c b/lib/libpthread/tests/test_pause.c
deleted file mode 100644
index 46c5080e43e..00000000000
--- a/lib/libpthread/tests/test_pause.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <stdio.h>
-#include <signal.h>
-
-foo(int sig)
-{
- return;
-}
-
-main()
-{
- sigset_t all;
-
- signal (1, foo);
- sigfillset(&all);
- sigprocmask(SIG_BLOCK, &all, NULL);
- printf("Begin pause\n");
- pause();
- printf("Done pause\n");
-}
diff --git a/lib/libpthread/tests/test_preemption.c b/lib/libpthread/tests/test_preemption.c
deleted file mode 100644
index 9181c127fe4..00000000000
--- a/lib/libpthread/tests/test_preemption.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* ==== test_pthread_cond.c =========================================
- * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Test pthread_cond(). Run this after test_create()
- *
- * 1.23 94/05/04 proven
- * -Started coding this file.
- */
-
-#include <pthread.h>
-#include <stdio.h>
-
-void* new_thread(void * new_buf)
-{
- int i;
-
- for (i = 0; i < 10; i++) {
- pthread_yield();
- }
- printf("test_preemption PASSED\n");
- exit(0);
-}
-
-main()
-{
- pthread_t thread;
- int error;
-
- printf("test_preemption START\n");
-
- if (pthread_create(&thread, NULL, new_thread, NULL)) {
- printf("pthread_create failed\n");
- exit(2);
- }
-
- while(1);
- exit(1);
-}
diff --git a/lib/libpthread/tests/test_preemption_float.c b/lib/libpthread/tests/test_preemption_float.c
deleted file mode 100644
index e12192044c6..00000000000
--- a/lib/libpthread/tests/test_preemption_float.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Test to see if floating point state is being properly maintained
- for each thread. Different threads doing floating point operations
- simultaneously should not interfere with one another. This
- includes operations that might change some FPU flags, such as
- rounding modes, at least implicitly. */
-
-#include <pthread.h>
-#include <math.h>
-#include <stdio.h>
-
-int limit = 2;
-int float_passed = 0;
-int float_failed = 1;
-
-void *log_loop (void *x) {
- int i;
- double d, d1, d2;
- /* sleep (1); */
- for (i = 0; i < limit; i++) {
- d = 42.0;
- d = log (exp (d));
- d = (d + 39.0) / d;
- if (i == 0)
- d1 = d;
- else {
- d2 = d;
- d = sin(d);
- /* if (d2 != d1) { */
- if (memcmp (&d2, &d1, 8)) {
- pthread_exit(&float_failed);
- }
- }
- }
- pthread_exit(&float_passed);
-}
-
-void *trig_loop (void *x) {
- int i;
- double d, d1, d2;
- /* sleep (1); */
- for (i = 0; i < limit; i++) {
- d = 35.0;
- d *= M_PI;
- d /= M_LN2;
- d = sin (d);
- d = cos (1 / d);
- if (i == 0)
- d1 = d;
- else {
- d2 = d;
- d = sin(d);
- /* if (d2 != d1) { */
- if (memcmp (&d2, &d1, 8)) {
- pthread_exit(&float_failed);
- }
- }
- }
- pthread_exit(&float_passed);
-}
-
-#define N 10
-int main () {
- int i;
- pthread_t thread[2];
- pthread_attr_t attr;
- int *x, *y;
-
- pthread_init ();
- pthread_attr_init(&attr);
- pthread_attr_setfloatstate(&attr, PTHREAD_NOFLOAT);
-
- while(limit < 100000) {
- pthread_create (&thread[0], &attr, trig_loop, 0);
- pthread_create (&thread[1], &attr, log_loop, 0);
- pthread_join(thread[0], (void **) &x);
- pthread_join(thread[1], (void **) &y);
- if ((*x == float_failed) || (*y == float_failed)) {
- limit *= 4;
- break;
- }
- limit *= 4;
- }
- if ((*x == float_passed) && (*y == float_passed)) {
- printf("test_preemption_float INDETERMINATE\n");
- return(0);
- }
- pthread_create (&thread[0], NULL, trig_loop, 0);
- pthread_create (&thread[1], NULL, log_loop, 0);
- pthread_join(thread[0], (void **) &x);
- pthread_join(thread[1], (void **) &y);
-
- if ((*x == float_failed) || (*y == float_failed)) {
- printf("test_preemption_float FAILED\n");
- return(1);
- }
- printf("test_preemption_float PASSED\n");
- return(0);
-}
diff --git a/lib/libpthread/tests/test_pthread_cond_timedwait.c b/lib/libpthread/tests/test_pthread_cond_timedwait.c
deleted file mode 100644
index fe21408f11e..00000000000
--- a/lib/libpthread/tests/test_pthread_cond_timedwait.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ==== test_pthread_cond.c =========================================
- * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Test pthread_cond(). Run this after test_create()
- *
- * 1.23 94/05/04 proven
- * -Started coding this file.
- */
-
-#include <pthread.h>
-#include <stdio.h>
-#include <errno.h>
-
-#ifndef ETIME
-#define ETIME ETIMEDOUT
-#endif
-
-pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
-
-void* thread_1(void * new_buf)
-{
- pthread_mutex_lock(&mutex);
- pthread_cond_signal(&cond);
- pthread_mutex_unlock(&mutex);
- pthread_exit(NULL);
-}
-
-void* thread_2(void * new_buf)
-{
- sleep(1);
- pthread_mutex_lock(&mutex);
- pthread_cond_signal(&cond);
- pthread_mutex_unlock(&mutex);
- pthread_exit(NULL);
-}
-
-main()
-{
- struct timespec abstime = { 0, 0 };
- struct timeval curtime;
- pthread_t thread;
- int error;
-
- pthread_init();
- printf("pthread_cond_timedwait START\n");
-
- pthread_mutex_lock(&mutex);
- gettimeofday(&curtime, NULL);
- abstime.tv_sec = curtime.tv_sec + 5;
-
- /* Test a condition timeout */
- if (pthread_cond_timedwait(&cond, &mutex, &abstime) != ETIME) {
- printf("pthread_cond_timedwait failed to timeout\n");
- printf("pthread_cond_timedwait FAILED\n");
- pthread_mutex_unlock(&mutex);
- exit(1);
- }
- printf("Got first timeout ok\n"); /* Added by monty */
- /* Test a normal condition signal */
- if (pthread_create(&thread, NULL, thread_1, NULL)) {
- printf("pthread_create failed\n");
- exit(2);
- }
-
- abstime.tv_sec = curtime.tv_sec + 10;
- if (pthread_cond_timedwait(&cond, &mutex, &abstime)) {
- printf("pthread_cond_timedwait #1 timedout\n");
- printf("pthread_cond_timedwait FAILED\n");
- pthread_mutex_unlock(&mutex);
- exit(1);
- }
-
- /* Test a normal condition signal after a sleep */
- if (pthread_create(&thread, NULL, thread_2, NULL)) {
- printf("pthread_create failed\n");
- exit(2);
- }
-
- pthread_yield();
-
- abstime.tv_sec = curtime.tv_sec + 10;
- if (pthread_cond_timedwait(&cond, &mutex, &abstime)) {
- printf("pthread_cond_timedwait #2 timedout\n");
- printf("pthread_cond_timedwait FAILED\n");
- pthread_mutex_unlock(&mutex);
- exit(1);
- }
-
- printf("pthread_cond_timedwait PASSED\n");
- pthread_mutex_unlock(&mutex);
- exit(0);
-}
diff --git a/lib/libpthread/tests/test_pthread_join.c b/lib/libpthread/tests/test_pthread_join.c
deleted file mode 100644
index fd2ec6a78b2..00000000000
--- a/lib/libpthread/tests/test_pthread_join.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/* ==== test_pthread_join.c =================================================
- * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Test pthread_join(). Run this after test_create()
- *
- * 1.23 94/05/04 proven
- * -Started coding this file.
- */
-
-#define PTHREAD_KERNEL
-#include <pthread.h>
-#include <stdio.h>
-
-/* This thread yields so the creator has a live thread to wait on */
-void* new_thread_1(void * new_buf)
-{
- int i;
-
- sprintf((char *)new_buf, "New thread %%d stack at %x\n", &i);
- pthread_yield();
- return(new_buf);
- PANIC();
-}
-
-/* This thread doesn't yield so the creator has a dead thread to wait on */
-void* new_thread_2(void * new_buf)
-{
- int i;
-
- sprintf((char *)new_buf, "New thread %%d stack at %x\n", &i);
- return(new_buf);
- PANIC();
-}
-
-main()
-{
- char buf[256], *status;
- pthread_t thread;
- int debug = 1;
- int i = 0;
-
- pthread_init();
-
- printf("Original thread stack at %x\n", &i);
- if (pthread_create(&thread, NULL, new_thread_1, (void *)buf) == OK) {
- if (pthread_join(thread, (void **)(&status)) == OK) {
- if (debug) { printf(status, ++i); }
- } else {
- printf("ERROR: Joining with new thread #1.\n");
- printf("FAILED: test_pthread_join\n");
- exit(1);
- }
- } else {
- printf("ERROR: Creating new thread #1\n");
- printf("FAILED: test_pthread_join\n");
- exit(2);
- }
-
-
- /* Now have the created thread finishing before the join. */
- if (pthread_create(&thread, NULL, new_thread_2, (void *)buf) == OK){
- pthread_yield();
- if (pthread_join(thread, (void **)(&status)) == OK) {
- if (debug) { printf(status, ++i); }
- } else {
- printf("ERROR: Joining with new thread #2.\n");
- printf("FAILED: test_pthread_join\n");
- exit(1);
- }
- } else {
- printf("ERROR: Creating new thread #2\n");
- printf("FAILED: test_pthread_join\n");
- exit(2);
- }
- printf("test_pthread_join PASSED\n");
- pthread_exit(NULL);
-}
-
diff --git a/lib/libpthread/tests/test_pthread_mutex.c b/lib/libpthread/tests/test_pthread_mutex.c
deleted file mode 100644
index 2fb0574f5cb..00000000000
--- a/lib/libpthread/tests/test_pthread_mutex.c
+++ /dev/null
@@ -1,221 +0,0 @@
-/* ==== test_pthread_cond.c =========================================
- * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Test pthread_cond(). Run this after test_create()
- *
- * 1.23 94/05/04 proven
- * -Started coding this file.
- */
-
-#include <errno.h>
-#include <pthread.h>
-#include <stdio.h>
-
-#define OK 0
-#define NOTOK -1
-
-int contention_variable;
-
-void * thread_contention(void * arg)
-{
- pthread_mutex_t * mutex = arg;
-
- if (pthread_mutex_lock(mutex)) {
- printf("pthread_mutex_lock() ERROR\n");
- pthread_exit(NULL);
- }
-
- if (contention_variable != 1) {
- printf("contention_variable != 1 ERROR\n");
- pthread_exit(NULL);
- }
- contention_variable = 2;
-
- if (pthread_mutex_unlock(mutex)) {
- printf("pthread_mutex_unlock() ERROR\n");
- pthread_exit(NULL);
- }
- pthread_exit(NULL);
-}
-
-int test_contention_lock(pthread_mutex_t * mutex)
-{
- pthread_t thread;
-
- printf("test_contention_lock()\n");
-
- if (pthread_mutex_lock(mutex)) {
- printf("pthread_mutex_lock() ERROR\n");
- return(NOTOK);
- }
- contention_variable = 0;
-
- if (pthread_create(&thread, NULL, thread_contention, mutex)) {
- printf("pthread_create() FAILED\n");
- exit(2);
- }
-
- pthread_yield();
-
- contention_variable = 1;
-
- if (pthread_mutex_unlock(mutex)) {
- printf("pthread_mutex_unlock() ERROR\n");
- return(NOTOK);
- }
-
- if (pthread_mutex_lock(mutex)) {
- printf("pthread_mutex_lock() ERROR\n");
- return(NOTOK);
- }
-
- if (contention_variable != 2) {
- printf("contention_variable != 2 ERROR\n");
- return(NOTOK);
- }
-
- if (pthread_mutex_unlock(mutex)) {
- printf("pthread_mutex_unlock() ERROR\n");
- return(NOTOK);
- }
-
- return(OK);
-}
-
-int test_nocontention_lock(pthread_mutex_t * mutex)
-{
- printf("test_nocontention_lock()\n");
- if (pthread_mutex_lock(mutex)) {
- printf("pthread_mutex_lock() ERROR\n");
- return(NOTOK);
- }
- if (pthread_mutex_unlock(mutex)) {
- printf("pthread_mutex_unlock() ERROR\n");
- return(NOTOK);
- }
- return(OK);
-}
-
-int test_debug_double_lock(pthread_mutex_t * mutex)
-{
- printf("test_debug_double_lock()\n");
- if (pthread_mutex_lock(mutex)) {
- printf("pthread_mutex_lock() ERROR\n");
- return(NOTOK);
- }
- if (pthread_mutex_lock(mutex) != EDEADLK) {
- printf("double lock error not detected ERROR\n");
- return(NOTOK);
- }
- if (pthread_mutex_unlock(mutex)) {
- printf("pthread_mutex_unlock() ERROR\n");
- return(NOTOK);
- }
- return(OK);
-}
-
-int test_debug_double_unlock(pthread_mutex_t * mutex)
-{
- printf("test_debug_double_unlock()\n");
- if (pthread_mutex_lock(mutex)) {
- printf("pthread_mutex_lock() ERROR\n");
- return(NOTOK);
- }
- if (pthread_mutex_unlock(mutex)) {
- printf("pthread_mutex_unlock() ERROR\n");
- return(NOTOK);
- }
- if (pthread_mutex_unlock(mutex) != EPERM) {
- printf("double unlock error not detected ERROR\n");
- return(NOTOK);
- }
- return(OK);
-}
-
-int test_nocontention_trylock(pthread_mutex_t * mutex)
-{
- printf("test_nocontention_trylock()\n");
- if (pthread_mutex_trylock(mutex)) {
- printf("pthread_mutex_trylock() ERROR\n");
- return(NOTOK);
- }
- if (pthread_mutex_unlock(mutex)) {
- printf("pthread_mutex_unlock() ERROR\n");
- return(NOTOK);
- }
- return(OK);
-}
-
-int test_mutex_static(void)
-{
- pthread_mutex_t mutex_static = PTHREAD_MUTEX_INITIALIZER;
-
- printf("test_mutex_static()\n");
- if (test_nocontention_lock(&mutex_static) ||
- test_contention_lock(&mutex_static)) {
- return(NOTOK);
- }
- return(OK);
-}
-
-int test_mutex_fast(void)
-{
- pthread_mutex_t mutex_fast;
-
- printf("test_mutex_fast()\n");
- if (pthread_mutex_init(&mutex_fast, NULL)) {
- printf("pthread_mutex_init() ERROR\n");
- return(NOTOK);
- }
- if (test_nocontention_lock(&mutex_fast) ||
- test_contention_lock(&mutex_fast)) {
- return(NOTOK);
- }
- if (pthread_mutex_destroy(&mutex_fast)) {
- printf("pthread_mutex_destroy() ERROR\n");
- return(NOTOK);
- }
- return(OK);
-}
-
-int test_mutex_debug()
-{
- pthread_mutexattr_t mutex_debug_attr;
- pthread_mutex_t mutex_debug;
-
- printf("test_mutex_debug()\n");
- pthread_mutexattr_init(&mutex_debug_attr);
- pthread_mutexattr_settype(&mutex_debug_attr, PTHREAD_MUTEXTYPE_DEBUG);
-
- if (pthread_mutex_init(&mutex_debug, &mutex_debug_attr)) {
- printf("pthread_mutex_init() ERROR\n");
- return(NOTOK);
- }
- if (test_nocontention_lock(&mutex_debug) ||
- test_contention_lock(&mutex_debug) ||
- test_debug_double_lock(&mutex_debug) ||
- test_debug_double_unlock(&mutex_debug)) {
- return(NOTOK);
- }
- if (pthread_mutex_destroy(&mutex_debug)) {
- printf("pthread_mutex_destroy() ERROR\n");
- return(NOTOK);
- }
- return(OK);
-}
-
-main()
-{
- pthread_init();
-
- printf("test_pthread_mutex START\n");
-
- if (test_mutex_static() || test_mutex_fast() || test_mutex_debug()) {
- printf("test_pthread_mutex FAILED\n");
- exit(1);
- }
-
- printf("test_pthread_mutex PASSED\n");
- exit(0);
-}
-
diff --git a/lib/libpthread/tests/test_pw.c b/lib/libpthread/tests/test_pw.c
deleted file mode 100644
index 0ef6d428180..00000000000
--- a/lib/libpthread/tests/test_pw.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <stdio.h>
-#include <sys/types.h>
-#include <pwd.h>
-
-main()
-{
- struct passwd *pw;
-
- pthread_init();
- pw = getpwuid(getuid());
- if (!pw) {
- printf("getpwuid(%d) died!\n", getuid());
- exit(1);
- }
- printf("getpwuid(%d) => %lx\n", getuid(), pw);
- printf(" you are: %s\n uid: %d\n gid: %d\n class: %s\n gecos: %s\n dir: %s\n shell: %s\n",
- pw->pw_name, pw->pw_uid, pw->pw_gid, pw->pw_class, pw->pw_gecos, pw->pw_dir,
- pw->pw_shell);
- exit(0);
-}
diff --git a/lib/libpthread/tests/test_readdir.c b/lib/libpthread/tests/test_readdir.c
deleted file mode 100644
index 6de1841bdbc..00000000000
--- a/lib/libpthread/tests/test_readdir.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* ==== test_readdir.c ========================================================
- * Copyright (c) 1993, 1994 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Test pthread_create() and pthread_exit() calls.
- *
- * 1.00 94/05/19 proven
- * -Started coding this file.
- */
-
-#include <pthread.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <stdio.h>
-
-main()
-{
- struct dirent * file;
- DIR * dot_dir;
- int i, found = 0;
-
- pthread_init();
-
- if (dot_dir = opendir(".")) {
- while (file = readdir(dot_dir)) {
- if (!strcmp("test_readdir", file->d_name)) {
- found = 1;
- }
- }
- closedir(dot_dir);
- if (found) {
- printf("test_readdir PASSED\n");
- exit(0);
- } else {
- printf("Couldn't find file test_readdir ERROR\n");
- }
- } else {
- printf("opendir() ERROR\n");
- }
- printf("test_readdir FAILED\n");
- exit(1);
-}
-
diff --git a/lib/libpthread/tests/test_select.c b/lib/libpthread/tests/test_select.c
deleted file mode 100644
index 0401d77a666..00000000000
--- a/lib/libpthread/tests/test_select.c
+++ /dev/null
@@ -1,115 +0,0 @@
-#include <pthread.h>
-#include <stdio.h>
-#ifndef ultrix
-#include <sys/fcntl.h>
-#else /* ultrix */
-#include <fcntl.h>
-#endif /* !ultrix */
-#include <sys/types.h>
-#include <sys/time.h>
-#ifdef hpux
-#include <sys/file.h>
-#endif /* hpux */
-#include <errno.h>
-#define NLOOPS 1000
-
-int ntouts = 0;
-
-void *
-bg_routine(void *arg)
-{
- write(1,"bg routine running\n",19);
- /*pthread_dump_state();*/
- while (1) {
- int n;
- char dot;
-
- dot = '.';
- pthread_yield();
- write(1,&dot,1);
- pthread_yield();
- n = NLOOPS;
- while (n-- > 0)
- pthread_yield();
- }
-}
-
-void *
-fg_routine(void *arg)
-{
- int flags, stat, nonblock_flag;
- static struct timeval tout = { 0, 500000 };
-
-#if 0
-#if defined(hpux) || defined(__alpha)
- nonblock_flag = O_NONBLOCK;
-#else
- nonblock_flag = FNDELAY;
-#endif
- printf("fg_routine running\n");
- flags = fcntl(0, F_GETFL, 0);
- printf("stdin flags b4 anything = %x\n", flags);
- stat = fcntl(0, F_SETFL, flags | nonblock_flag);
- if (stat < 0) {
- printf("fcntl(%x) => %d\n", nonblock_flag, errno);
- printf("could not set nonblocking i/o on stdin [oldf %x, stat %d]\n",
- flags, stat);
- exit(1);
- }
- printf("stdin flags = 0x%x after turning on %x\n", flags, nonblock_flag);
-#endif
- while (1) {
- int n;
- fd_set r;
-
- FD_ZERO(&r);
- FD_SET(0,&r);
- printf("select>");
- n = select(1, &r, (fd_set*)0, (fd_set*)0, (struct timeval *)0);
- if (n < 0) {
- perror ("select");
- exit(1);
- } else if (n > 0) {
- int nb;
- char buf[128];
-
- printf("=> select returned: %d\n", n);
- while ((nb = read(0, buf, sizeof(buf)-1)) >= 0) {
- buf[nb] = '\0';
- printf("read %d: |%s|\n", nb, buf);
- }
- printf("=> out of read loop: %d / %d\n", nb, errno);
- if (nb < 0) {
- if (errno != EWOULDBLOCK && errno != EAGAIN) {
- perror ("read");
- exit(1);
- }
- }
- } else
- ntouts++;
- }
-}
-
-main(int argc, char **argv)
-{
- pthread_t bg_thread, fg_thread;
- int junk;
-
- pthread_init();
- setbuf(stdout,NULL);
- setbuf(stderr,NULL);
- if (argc > 1) {
- if (pthread_create(&bg_thread, NULL, bg_routine, 0) < 0) {
- printf("error: could not create bg thread\n");
- exit(1);
- }
- }
- if (pthread_create(&fg_thread, NULL, fg_routine, 0) < 0) {
- printf("error: could not create fg thread\n");
- exit(1);
- }
- printf("threads forked: bg=%lx fg=%lx\n", bg_thread, fg_thread);
- /*pthread_dump_state();*/
- printf("initial thread %lx joining fg...\n", pthread_self());
- pthread_join(fg_thread, (void **)&junk);
-}
diff --git a/lib/libpthread/tests/test_setjmp.c b/lib/libpthread/tests/test_setjmp.c
deleted file mode 100644
index ea24ecd63bc..00000000000
--- a/lib/libpthread/tests/test_setjmp.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <setjmp.h>
-
-main()
-{
-jmp_buf foo;
-
-if (setjmp(foo)) {
- exit(0);
-}
-printf("Hi mom\n");
-longjmp(foo, 1);
-printf("Should never reach here\n");
-}
diff --git a/lib/libpthread/tests/test_sleep.c b/lib/libpthread/tests/test_sleep.c
deleted file mode 100644
index f228d08a2ca..00000000000
--- a/lib/libpthread/tests/test_sleep.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* ==== test_switch.c ============================================================
- * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Test context switch functionality.
- *
- * 1.00 93/08/04 proven
- * -Started coding this file.
- */
-
-#include <pthread.h>
-#include <stdio.h>
-
-const char buf[] = "abcdefghijklimnopqrstuvwxyz";
-int fd = 1;
-
-void* new_thread(void* arg)
-{
- int i;
-
- for (i = 0; i < 10; i++) {
- write(fd, buf + (long) arg, 1);
- sleep(1);
- }
-}
-
-main()
-{
- pthread_t thread;
- int count = 2;
- long i;
-
- pthread_init();
-
- printf("Going to sleep\n");
- sleep(10);
- printf("Done sleeping\n");
-
- for(i = 0; i < count; i++) {
- if (pthread_create(&thread, NULL, new_thread, (void *) i)) {
- printf("error creating new thread %d\n", i);
- }
- }
- pthread_exit(NULL);
- fprintf(stderr, "pthread_exit returned\n");
- exit(1);
-}
diff --git a/lib/libpthread/tests/test_sock_1.c b/lib/libpthread/tests/test_sock_1.c
deleted file mode 100644
index a7fd0c0d454..00000000000
--- a/lib/libpthread/tests/test_sock_1.c
+++ /dev/null
@@ -1,204 +0,0 @@
-/* ==== test_sock_1.c =========================================================
- * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Test pthread_create() and pthread_exit() calls.
- *
- * 1.00 93/08/03 proven
- * -Started coding this file.
- */
-
-#include <pthread.h>
-#include <errno.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-struct sockaddr_in a_sout;
-pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_attr_t attr;
-
-#define MESSAGE5 "This should be message #5"
-#define MESSAGE6 "This should be message #6"
-
-void * sock_connect(void* arg)
-{
- char buf[1024];
- int fd, tmp;
-
- /* Ensure sock_read runs first */
- if (pthread_mutex_lock(&mutex)) {
- printf("Error: sock_connect:pthread_mutex_lock()\n");
- exit(1);
- }
-
- a_sout.sin_addr.s_addr = htonl(0x7f000001); /* loopback */
-
- if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- printf("Error: sock_connect:socket()\n");
- exit(1);
- }
-
- printf("This should be message #2\n");
- if (connect(fd, (struct sockaddr *) &a_sout, sizeof(a_sout)) < 0) {
- printf("Error: sock_connect:connect()\n");
- exit(1);
- }
- close(fd);
-
- if (pthread_mutex_unlock(&mutex)) {
- printf("Error: sock_connect:pthread_mutex_lock()\n");
- exit(1);
- }
-
- if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- printf("Error: sock_connect:socket()\n");
- exit(1);
- }
-
- printf("This should be message #3\n");
-
- if (connect(fd, (struct sockaddr *) &a_sout, sizeof(a_sout)) < 0) {
- printf("Error: sock_connect:connect()\n");
- exit(1);
- }
-
- /* Ensure sock_read runs again */
- pthread_yield();
- pthread_yield();
- pthread_yield();
- pthread_yield();
- if (pthread_mutex_lock(&mutex)) {
- printf("Error: sock_connect:pthread_mutex_lock()\n");
- exit(1);
- }
-
- if ((tmp = read(fd, buf, 1024)) <= 0) {
- printf("Error: sock_connect:read() == %d\n", tmp);
- exit(1);
- }
- write(fd, MESSAGE6, sizeof(MESSAGE6));
- printf("%s\n", buf);
- close(fd);
-}
-
-extern struct fd_table_entry ** fd_table;
-void * sock_write(void* arg)
-{
- int fd = *(int *)arg;
-
- write(fd, MESSAGE5, sizeof(MESSAGE5));
- return(NULL);
-}
-
-void * sock_accept(void* arg)
-{
- pthread_t thread;
- struct sockaddr a_sin;
- int a_sin_size, a_fd, fd, tmp;
- short port;
- char buf[1024];
-
- if (pthread_mutex_unlock(&mutex)) {
- printf("Error: sock_accept:pthread_mutex_lock()\n");
- exit(1);
- }
-
- port = 3276;
- a_sout.sin_family = AF_INET;
- a_sout.sin_port = htons(port);
- a_sout.sin_addr.s_addr = INADDR_ANY;
-
- if ((a_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- printf("Error: sock_accept:socket()\n");
- exit(1);
- }
-
- while (bind(a_fd, (struct sockaddr *) &a_sout, sizeof(a_sout)) < 0) {
- if (errno == EADDRINUSE) {
- a_sout.sin_port = htons((++port));
- continue;
- }
- printf("Error: sock_accept:bind()\n");
- exit(1);
- }
-
- if (listen(a_fd, 2)) {
- printf("Error: sock_accept:listen()\n");
- exit(1);
- }
-
- a_sin_size = sizeof(a_sin);
- printf("This should be message #1\n");
- if ((fd = accept(a_fd, &a_sin, &a_sin_size)) < 0) {
- perror("Error: sock_accept:accept()");
- exit(1);
- }
-
- if (pthread_mutex_lock(&mutex)) {
- printf("Error: sock_accept:pthread_mutex_lock()\n");
- exit(1);
- }
- close(fd);
-
- a_sin_size = sizeof(a_sin);
- printf("This should be message #4\n");
- if ((fd = accept(a_fd, &a_sin, &a_sin_size)) < 0) {
- printf("Error: sock_accept:accept()\n");
- exit(1);
- }
-
- if (pthread_mutex_unlock(&mutex)) {
- printf("Error: sock_accept:pthread_mutex_lock()\n");
- exit(1);
- }
-
- /* Setup a write thread */
- if (pthread_create(&thread, &attr, sock_write, &fd)) {
- printf("Error: sock_accept:pthread_create(sock_write)\n");
- exit(1);
- }
- if ((tmp = read(fd, buf, 1024)) <= 0) {
- printf("Error: sock_accept:read() == %d\n", tmp);
- exit(1);
- }
- printf("%s\n", buf);
- close(fd);
-}
-
-main()
-{
- pthread_t thread;
- int i;
-
- pthread_init();
- setbuf(stdout, NULL);
- setbuf(stderr, NULL);
-
- /* Ensure sock_read runs first */
- if (pthread_mutex_lock(&mutex)) {
- printf("Error: main:pthread_mutex_lock()\n");
- exit(1);
- }
-
- if (pthread_attr_init(&attr)) {
- printf("Error: main:pthread_attr_init()\n");
- exit(1);
- }
- if (pthread_attr_setschedpolicy(&attr, SCHED_FIFO)) {
- printf("Error: main:pthread_attr_setschedpolicy()\n");
- exit(1);
- }
- if (pthread_create(&thread, &attr, sock_accept, (void *)0xdeadbeaf)) {
- printf("Error: main:pthread_create(sock_accept)\n");
- exit(1);
- }
- if (pthread_create(&thread, &attr, sock_connect, (void *)0xdeadbeaf)) {
- printf("Error: main:pthread_create(sock_connect)\n");
- exit(1);
- }
- printf("initial thread %lx going to sleep\n", pthread_self());
- sleep(10);
- printf("done sleeping\n");
- return 0;
-}
diff --git a/lib/libpthread/tests/test_sock_2.c b/lib/libpthread/tests/test_sock_2.c
deleted file mode 100644
index 8f60c0b66fa..00000000000
--- a/lib/libpthread/tests/test_sock_2.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/* ==== test_sock_1.c =========================================================
- * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Test pthread_create() and pthread_exit() calls.
- *
- * 1.00 93/08/03 proven
- * -Started coding this file.
- */
-
-#include <pthread.h>
-#include <errno.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-struct sockaddr_in a_sout;
-
-#define MESSAGE5 "This should be message #5"
-#define MESSAGE6 "This should be message #6"
-
-void * sock_write(void* arg)
-{
- int fd = *(int *)arg;
-
- write(fd, MESSAGE5, sizeof(MESSAGE5));
- return(NULL);
-}
-
-void * sock_accept(void* arg)
-{
- pthread_t thread;
- struct sockaddr a_sin;
- int a_sin_size, a_fd, fd, tmp;
- short port;
- char buf[1024];
-
- port = 3276;
- a_sout.sin_family = AF_INET;
- a_sout.sin_port = htons(port);
- a_sout.sin_addr.s_addr = INADDR_ANY;
-
- if ((a_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- perror("Error: sock_accept:socket()");
- exit(1);
- }
-
- while (bind(a_fd, (struct sockaddr *) &a_sout, sizeof(a_sout)) < 0) {
- if (errno == EADDRINUSE) {
- a_sout.sin_port = htons((++port));
- continue;
- }
- perror("Error: sock_accept:bind()");
- exit(1);
- }
-
- if (listen(a_fd, 2)) {
- perror("Error: sock_accept:listen()");
- exit(1);
- }
-
- a_sin_size = sizeof(a_sin);
- printf("This should be message #1\n");
- if ((fd = accept(a_fd, &a_sin, &a_sin_size)) < 0) {
- perror("Error: sock_accept:accept()");
- exit(1);
- }
- close(fd);
- sleep(1);
-
- a_sin_size = sizeof(a_sin);
- memset(&a_sin, 0, sizeof(a_sin));
- printf("This should be message #4\n");
- if ((fd = accept(a_fd, &a_sin, &a_sin_size)) < 0) {
- perror("Error: sock_accept:accept()");
- exit(1);
- }
-
- /* Setup a write thread */
- if (pthread_create(&thread, NULL, sock_write, &fd)) {
- perror("Error: sock_accept:pthread_create(sock_write)");
- exit(1);
- }
- if ((tmp = read(fd, buf, 1024)) <= 0) {
- tmp = read(fd, buf, 1024);
- printf("Error: sock_accept:read() == %d %s\n", tmp, strerror(errno));
- exit(1);
- }
- printf("%s\n", buf);
- close(fd);
-}
-
-main()
-{
- pthread_t thread;
- int i;
-
- switch(fork()) {
- case -1:
- perror("Error: main:fork()");
- break;
- case 0:
- execl("test_sock_2a", "test_sock_2a", "fork okay", NULL);
- default:
- break;
- }
-
- setbuf(stdout, NULL);
- setbuf(stderr, NULL);
-
- if (pthread_create(&thread, NULL, sock_accept, (void *)0xdeadbeaf)) {
- perror("Error: main:pthread_create(sock_accept)");
- exit(1);
- }
- pthread_exit(NULL);
-}
diff --git a/lib/libpthread/tests/test_sock_2a.c b/lib/libpthread/tests/test_sock_2a.c
deleted file mode 100644
index 7ff73bcfc76..00000000000
--- a/lib/libpthread/tests/test_sock_2a.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ==== test_sock_1.c =========================================================
- * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Test pthread_create() and pthread_exit() calls.
- *
- * 1.00 93/08/03 proven
- * -Started coding this file.
- */
-
-#include <pthread.h>
-#include <errno.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-struct sockaddr_in a_sout;
-
-#define MESSAGE5 "This should be message #5"
-#define MESSAGE6 "This should be message #6"
-
-void * sock_connect(void* arg)
-{
- char buf[1024];
- int fd, tmp;
- short port;
-
- port = 3276;
- a_sout.sin_family = AF_INET;
- a_sout.sin_port = htons(port);
- a_sout.sin_addr.s_addr = htonl(0x7f000001); /* loopback */
-
- if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- perror("Error: sock_connect:socket()");
- exit(1);
- }
-
- printf("This should be message #2\n");
- if (connect(fd, (struct sockaddr *) &a_sout, sizeof(a_sout)) < 0) {
- perror("Error: sock_connect:connect()");
- exit(1);
- }
- close(fd);
-
- if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- perror("Error: sock_connect:socket()");
- exit(1);
- }
-
- printf("This should be message #3\n");
-
- if (connect(fd, (struct sockaddr *) &a_sout, sizeof(a_sout)) < 0) {
- perror("Error: sock_connect:connect()");
- exit(1);
- }
-
- /* Ensure sock_read runs again */
-
- if ((tmp = read(fd, buf, 1024)) <= 0) {
- printf("Error: sock_connect:read() == %d %s\n", tmp, strerror(errno));
- exit(1);
- }
- write(fd, MESSAGE6, sizeof(MESSAGE6));
- printf("%s\n", buf);
- close(fd);
-}
-
-main(int argc, char **argv)
-{
- pthread_t thread;
- int i;
-
- if (argv[1] && (!strcmp(argv[1], "fork okay"))) {
- sleep(1);
- setbuf(stdout, NULL);
- setbuf(stderr, NULL);
-
- if (pthread_create(&thread, NULL, sock_connect, (void *)0xdeadbeaf)) {
- perror("Error: main:pthread_create(sock_connect)");
- exit(1);
- }
- pthread_exit(NULL);
- }
- printf("test_sock_2a needs to be execed from test_sock_2.\n");
- printf("It is not a stand alone test.\n");
- exit(1);
-}
diff --git a/lib/libpthread/tests/test_stdio_1.c b/lib/libpthread/tests/test_stdio_1.c
deleted file mode 100644
index 648343a2c9d..00000000000
--- a/lib/libpthread/tests/test_stdio_1.c
+++ /dev/null
@@ -1,124 +0,0 @@
-#include <pthread.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-char * base_name = "test_stdio_1.c";
-char * dir_name = SRCDIR;
-char * fullname;
-
-#define OK 0
-#define NOTOK -1
-
-/* Test fopen()/ftell()/getc() */
-int test_1(void)
-{
- struct stat statbuf;
- FILE * fp;
- int i;
-
- if (stat(fullname, &statbuf) < OK) {
- printf("ERROR: Couldn't stat %s\n", fullname);
- return(NOTOK);
- }
-
- if ((fp = fopen(fullname, "r")) == NULL) {
- printf("ERROR: Couldn't open %s\n", fullname);
- return(NOTOK);
- }
-
- /* Get the entire file */
- while ((i = getc(fp)) != EOF);
-
- if (ftell(fp) != statbuf.st_size) {
- printf("ERROR: ftell() and stat() don't agree.");
- return(NOTOK);
- }
-
- if (fclose(fp) < OK) {
- printf("ERROR: fclose() failed.");
- return(NOTOK);
- }
- return(OK);
-}
-
-/* Test fopen()/fclose() */
-int test_2(void)
-{
- FILE *fp1, *fp2;
-
- if ((fp1 = fopen(fullname, "r")) == NULL) {
- printf("ERROR: Couldn't fopen %s\n", fullname);
- return(NOTOK);
- }
-
- if (fclose(fp1) < OK) {
- printf("ERROR: fclose() failed.");
- return(NOTOK);
- }
-
- if ((fp2 = fopen(fullname, "r")) == NULL) {
- printf("ERROR: Couldn't fopen %s\n", fullname);
- return(NOTOK);
- }
-
- if (fclose(fp2) < OK) {
- printf("ERROR: fclose() failed.");
- return(NOTOK);
- }
-
- if (fp1 != fp2) {
- printf("ERROR: FILE table leak.\n");
- return(NOTOK);
- }
-
- return(OK);
-}
-
-/* Test sscanf()/sprintf() */
-int test_3(void)
-{
- char * str = "10 4.53";
- char buf[64];
- double d;
- int i;
-
- if (sscanf(str, "%d %lf", &i, &d) != 2) {
- printf("ERROR: sscanf didn't parse input string correctly\n");
- return(NOTOK);
- }
-
- /* Should have a check */
- sprintf(buf, "%d %2.2lf", i, d);
-
- if (strcmp(buf, str)) {
- printf("ERROR: sscanf()/sprintf() didn't parse unparse correctly\n");
- return(NOTOK);
- }
- return(OK);
-}
-
-main()
-{
-
- printf("test_stdio_1 START\n");
-
- if (fullname = malloc (strlen (dir_name) + strlen (base_name) + 2)) {
- sprintf (fullname, "%s/%s", dir_name, base_name);
- } else {
- perror ("malloc");
- exit(1);
- }
-
- if (test_1() || test_2() || test_3()) {
- printf("test_stdio_1 FAILED\n");
- exit(1);
- }
-
- printf("test_stdio_1 PASSED\n");
- exit(0);
-}
-
-
diff --git a/lib/libpthread/tests/test_switch.c b/lib/libpthread/tests/test_switch.c
deleted file mode 100644
index 4c184158fb8..00000000000
--- a/lib/libpthread/tests/test_switch.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ==== test_switch.c ============================================================
- * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Test context switch functionality.
- *
- * 1.00 93/08/04 proven
- * -Started coding this file.
- */
-
-#include <pthread.h>
-#include <stdio.h>
-#include <errno.h>
-
-#define OK 0
-#define NOTOK -1
-
-const char buf[] = "abcdefghijklmnopqrstuvwxyz";
-char x[sizeof(buf)];
-int fd = 1;
-
-/* ==========================================================================
- * usage();
- */
-void usage(void)
-{
- printf("test_switch [-d?] [-c count]\n");
- printf("count must be between 2 and 26\n");
- errno = 0;
-}
-
-void* new_thread(void* arg)
-{
- while(1) {
- write (fd, (char *) arg, 1);
- x[(char *)arg - buf] = 1;
- }
- fprintf(stderr, "Compiler error\n");
- exit(1);
-}
-
-main(int argc, char **argv)
-{
- pthread_t thread;
- int count = 2;
- int debug = 0;
- int eof = 0;
- long i;
-
- /* Getopt variables. */
- extern int optind, opterr;
- extern char *optarg;
-
- while (!eof)
- switch (getopt (argc, argv, "c:d?"))
- {
- case EOF:
- eof = 1;
- break;
- case 'd':
- debug++;
- break;
- case 'c':
- count = atoi(optarg);
- if ((count > 26) || (count < 2)) {
- count = 2;
- }
- break;
- case '?':
- usage();
- return(OK);
- default:
- usage();
- return(NOTOK);
- }
-
- for (i = 0; i < count; i++) {
- if (pthread_create(&thread, NULL, new_thread, (void*)(buf+i))) {
- fprintf (stderr, "error creating new thread %d\n", i);
- exit (1);
- }
- }
-#if 0 /* This would cause the program to loop forever, and "make
- check" would never complete. */
- pthread_exit (NULL);
- fprintf(stderr, "pthread_exit returned\n");
- exit(1);
-#else
- sleep (10);
- for (i = 0; i < count; i++)
- if (x[i] == 0) {
- fprintf (stderr, "thread %d never ran\n", i);
- return 1;
- }
- printf ("\n%s PASSED\n", argv[0]);
- return 0;
-#endif
-}