summaryrefslogtreecommitdiff
path: root/mit-pthreads
diff options
context:
space:
mode:
authorbk@work.mysql.com <>2000-07-31 21:29:14 +0200
committerbk@work.mysql.com <>2000-07-31 21:29:14 +0200
commitf4c589ff6c653d1d2a09c26e46ead3c8a15655d8 (patch)
treed253a359142dfc1ed247d5d4365d86972ea31109 /mit-pthreads
parent7eec25e393727b16bb916b50d82b0aa3084e065c (diff)
downloadmariadb-git-f4c589ff6c653d1d2a09c26e46ead3c8a15655d8.tar.gz
Import changeset
Diffstat (limited to 'mit-pthreads')
-rw-r--r--mit-pthreads/.cvsignore6
-rw-r--r--mit-pthreads/COPYRIGHT31
-rw-r--r--mit-pthreads/Changes-mysql194
-rw-r--r--mit-pthreads/FAQ122
-rw-r--r--mit-pthreads/GNUmakefile129
-rw-r--r--mit-pthreads/NOTES59
-rw-r--r--mit-pthreads/NOTES_OSR5_BUILD_SKUNKWARE9745
-rw-r--r--mit-pthreads/README40
-rw-r--r--mit-pthreads/TODO-mysql4
-rw-r--r--mit-pthreads/Whats_New198
-rw-r--r--mit-pthreads/bin/.cvsignore1
-rw-r--r--mit-pthreads/bin/Makefile.in48
-rw-r--r--mit-pthreads/bin/finger/.cvsignore1
-rwxr-xr-xmit-pthreads/bin/finger/Makefile.in60
-rwxr-xr-xmit-pthreads/bin/finger/finger.c231
-rwxr-xr-xmit-pthreads/bin/finger/net.c189
-rwxr-xr-xmit-pthreads/config/COPYING.GNU339
-rwxr-xr-xmit-pthreads/config/COPYRIGHT4
-rwxr-xr-xmit-pthreads/config/GNUmakefile.in129
-rw-r--r--mit-pthreads/config/Makefile.in56
-rw-r--r--mit-pthreads/config/acconfig.h73
-rwxr-xr-xmit-pthreads/config/aclocal.m494
-rwxr-xr-xmit-pthreads/config/config.flags.in80
-rwxr-xr-xmit-pthreads/config/config.guess504
-rwxr-xr-xmit-pthreads/config/config.h.in324
-rwxr-xr-xmit-pthreads/config/config.sub794
-rwxr-xr-xmit-pthreads/config/configure3330
-rwxr-xr-xmit-pthreads/config/configure.in739
-rwxr-xr-xmit-pthreads/config/configure.org2874
-rwxr-xr-xmit-pthreads/config/install-sh238
-rwxr-xr-xmit-pthreads/configure19
-rwxr-xr-xmit-pthreads/gen/GNUmakefile.inc9
-rw-r--r--mit-pthreads/gen/Makefile.inc24
-rw-r--r--mit-pthreads/gen/ctime.c1315
-rw-r--r--mit-pthreads/gen/difftime.c46
-rw-r--r--mit-pthreads/gen/directory.c322
-rw-r--r--mit-pthreads/gen/eprintf.c18
-rw-r--r--mit-pthreads/gen/getcwd.c248
-rw-r--r--mit-pthreads/gen/getpwent.c109
-rw-r--r--mit-pthreads/gen/getpwnamuid.c138
-rw-r--r--mit-pthreads/gen/getwd.c57
-rw-r--r--mit-pthreads/gen/isatty.c95
-rw-r--r--mit-pthreads/gen/popen.c117
-rw-r--r--mit-pthreads/gen/pwd_internal.c97
-rw-r--r--mit-pthreads/gen/pwd_internal.h29
-rw-r--r--mit-pthreads/gen/syslog.c216
-rw-r--r--mit-pthreads/gen/time.c51
-rw-r--r--mit-pthreads/gen/ttyname.c147
-rw-r--r--mit-pthreads/include/Makefile.inc30
-rwxr-xr-xmit-pthreads/include/arpa/inet.h61
-rwxr-xr-xmit-pthreads/include/arpa/nameser.h279
-rw-r--r--mit-pthreads/include/dirent.h97
-rw-r--r--mit-pthreads/include/endian.h95
-rw-r--r--mit-pthreads/include/errno.h52
-rw-r--r--mit-pthreads/include/math.h85
-rw-r--r--mit-pthreads/include/netdb.h146
-rw-r--r--mit-pthreads/include/pthread.h371
-rw-r--r--mit-pthreads/include/pthread/ac-types.h11
-rwxr-xr-xmit-pthreads/include/pthread/cleanup.h59
-rwxr-xr-xmit-pthreads/include/pthread/cond.h102
-rw-r--r--mit-pthreads/include/pthread/config.h5
-rwxr-xr-xmit-pthreads/include/pthread/debug_out.h44
-rwxr-xr-xmit-pthreads/include/pthread/fd.h122
-rwxr-xr-xmit-pthreads/include/pthread/fd_pipe.h54
-rwxr-xr-xmit-pthreads/include/pthread/kernel.h71
-rwxr-xr-xmit-pthreads/include/pthread/kthread.h67
-rwxr-xr-xmit-pthreads/include/pthread/mutex.h102
-rw-r--r--mit-pthreads/include/pthread/paths.h12
-rwxr-xr-xmit-pthreads/include/pthread/prio_queue.h78
-rwxr-xr-xmit-pthreads/include/pthread/pthread_attr.h122
-rwxr-xr-xmit-pthreads/include/pthread/pthread_once.h58
-rwxr-xr-xmit-pthreads/include/pthread/queue.h67
-rwxr-xr-xmit-pthreads/include/pthread/sleep.h63
-rwxr-xr-xmit-pthreads/include/pthread/specific.h66
-rwxr-xr-xmit-pthreads/include/pthread/state.def64
-rwxr-xr-xmit-pthreads/include/pthread/types.h46
-rwxr-xr-xmit-pthreads/include/pthread/unistd.h159
-rwxr-xr-xmit-pthreads/include/pthread/util.h89
-rwxr-xr-xmit-pthreads/include/pthread/version.h43
-rwxr-xr-xmit-pthreads/include/pthread/xtypes.h13
-rw-r--r--mit-pthreads/include/pwd.h93
-rw-r--r--mit-pthreads/include/resolv.h179
-rw-r--r--mit-pthreads/include/sched.h57
-rw-r--r--mit-pthreads/include/signal.h81
-rw-r--r--mit-pthreads/include/stdio.h371
-rw-r--r--mit-pthreads/include/stdlib.h127
-rw-r--r--mit-pthreads/include/string.h85
-rw-r--r--mit-pthreads/include/syslog.h101
-rw-r--r--mit-pthreads/include/time.h102
-rw-r--r--mit-pthreads/include/timers.h45
-rw-r--r--mit-pthreads/include/tzfile.h154
-rw-r--r--mit-pthreads/include/unistd.h183
-rw-r--r--mit-pthreads/lib/.cvsignore1
-rw-r--r--mit-pthreads/lib/Makefile.in48
-rw-r--r--mit-pthreads/lib/libpthreadutil/.cvsignore1
-rwxr-xr-xmit-pthreads/lib/libpthreadutil/Makefile.in65
-rwxr-xr-xmit-pthreads/lib/libpthreadutil/pthread_atexit.c135
-rwxr-xr-xmit-pthreads/lib/libpthreadutil/pthread_tad.c170
-rwxr-xr-xmit-pthreads/lib/libpthreadutil/pthreadutil.h75
-rwxr-xr-xmit-pthreads/machdep/alpha-osf1/__math.h16
-rwxr-xr-xmit-pthreads/machdep/alpha-osf1/__signal.h106
-rwxr-xr-xmit-pthreads/machdep/alpha-osf1/__stdio.h13
-rwxr-xr-xmit-pthreads/machdep/alpha-osf1/__stdlib.h3
-rwxr-xr-xmit-pthreads/machdep/alpha-osf1/__string.h19
-rwxr-xr-xmit-pthreads/machdep/alpha-osf1/__time.h21
-rwxr-xr-xmit-pthreads/machdep/alpha-osf1/__unistd.h6
-rwxr-xr-xmit-pthreads/machdep/alpha-osf1/cdefs.h62
-rwxr-xr-xmit-pthreads/machdep/alpha-osf1/compat.h1
-rwxr-xr-xmit-pthreads/machdep/alpha-osf1/dirent.h7
-rwxr-xr-xmit-pthreads/machdep/alpha-osf1/signal.h3
-rwxr-xr-xmit-pthreads/machdep/alpha-osf1/socket.h296
-rwxr-xr-xmit-pthreads/machdep/alpha-osf1/timers.h60
-rwxr-xr-xmit-pthreads/machdep/alpha-osf1/uio.h12
-rwxr-xr-xmit-pthreads/machdep/bsdi-1.1/compat.h43
-rwxr-xr-xmit-pthreads/machdep/bsdi-1.1/dirent.h73
-rwxr-xr-xmit-pthreads/machdep/bsdi-1.1/errno.h160
-rwxr-xr-xmit-pthreads/machdep/bsdi-1.1/socket.h277
-rwxr-xr-xmit-pthreads/machdep/bsdi-1.1/timers.h59
-rwxr-xr-xmit-pthreads/machdep/bsdi-2.0/__math.h6
-rwxr-xr-xmit-pthreads/machdep/bsdi-2.0/__path.h13
-rwxr-xr-xmit-pthreads/machdep/bsdi-2.0/__signal.h7
-rwxr-xr-xmit-pthreads/machdep/bsdi-2.0/__stdio.h7
-rwxr-xr-xmit-pthreads/machdep/bsdi-2.0/__stdlib.h60
-rwxr-xr-xmit-pthreads/machdep/bsdi-2.0/__string.h19
-rwxr-xr-xmit-pthreads/machdep/bsdi-2.0/__time.h63
-rwxr-xr-xmit-pthreads/machdep/bsdi-2.0/__unistd.h109
-rwxr-xr-xmit-pthreads/machdep/bsdi-2.0/compat.h65
-rwxr-xr-xmit-pthreads/machdep/bsdi-2.0/dirent.h65
-rwxr-xr-xmit-pthreads/machdep/bsdi-2.0/errno.h162
-rwxr-xr-xmit-pthreads/machdep/bsdi-2.0/time.h6
-rwxr-xr-xmit-pthreads/machdep/bsdi-2.0/timers.h45
-rwxr-xr-xmit-pthreads/machdep/bsdi-2.0/wait.h159
-rw-r--r--mit-pthreads/machdep/engine-alpha-netbsd-1.1.c196
-rw-r--r--mit-pthreads/machdep/engine-alpha-netbsd-1.1.h111
-rw-r--r--mit-pthreads/machdep/engine-alpha-netbsd-1.3.c204
-rw-r--r--mit-pthreads/machdep/engine-alpha-netbsd-1.3.h114
-rw-r--r--mit-pthreads/machdep/engine-alpha-osf1.c207
-rw-r--r--mit-pthreads/machdep/engine-alpha-osf1.h110
-rw-r--r--mit-pthreads/machdep/engine-arm32-netbsd-1.3.c203
-rw-r--r--mit-pthreads/machdep/engine-arm32-netbsd-1.3.h102
-rw-r--r--mit-pthreads/machdep/engine-hppa-hpux-10.20.c169
-rw-r--r--mit-pthreads/machdep/engine-hppa-hpux-10.20.h143
-rw-r--r--mit-pthreads/machdep/engine-hppa-hpux-9.03.c153
-rw-r--r--mit-pthreads/machdep/engine-hppa-hpux-9.03.h141
-rw-r--r--mit-pthreads/machdep/engine-i386-bsdi-1.1.c180
-rw-r--r--mit-pthreads/machdep/engine-i386-bsdi-1.1.h84
-rw-r--r--mit-pthreads/machdep/engine-i386-bsdi-2.0.c210
-rw-r--r--mit-pthreads/machdep/engine-i386-bsdi-2.0.h98
-rw-r--r--mit-pthreads/machdep/engine-i386-freebsd-1.1.c179
-rw-r--r--mit-pthreads/machdep/engine-i386-freebsd-1.1.h83
-rw-r--r--mit-pthreads/machdep/engine-i386-freebsd-2.0.c208
-rw-r--r--mit-pthreads/machdep/engine-i386-freebsd-2.0.h97
-rw-r--r--mit-pthreads/machdep/engine-i386-linux-1.0.c503
-rw-r--r--mit-pthreads/machdep/engine-i386-linux-1.0.h98
-rw-r--r--mit-pthreads/machdep/engine-i386-linux-2.0.c504
-rw-r--r--mit-pthreads/machdep/engine-i386-linux-2.0.h98
-rw-r--r--mit-pthreads/machdep/engine-i386-netbsd-0.9.c155
-rw-r--r--mit-pthreads/machdep/engine-i386-netbsd-0.9.h83
-rw-r--r--mit-pthreads/machdep/engine-i386-netbsd-1.0.c218
-rw-r--r--mit-pthreads/machdep/engine-i386-netbsd-1.0.h97
-rw-r--r--mit-pthreads/machdep/engine-i386-netbsd-1.3.c225
-rw-r--r--mit-pthreads/machdep/engine-i386-netbsd-1.3.h98
-rw-r--r--mit-pthreads/machdep/engine-i386-openbsd-2.0.c215
-rw-r--r--mit-pthreads/machdep/engine-i386-openbsd-2.0.h97
-rwxr-xr-xmit-pthreads/machdep/engine-i386-sco-3.2v5.c1072
-rw-r--r--mit-pthreads/machdep/engine-i386-sco-3.2v5.h104
-rw-r--r--mit-pthreads/machdep/engine-ip22-irix-5.2.c225
-rw-r--r--mit-pthreads/machdep/engine-ip22-irix-5.2.h108
-rw-r--r--mit-pthreads/machdep/engine-m68000-netbsd.c256
-rw-r--r--mit-pthreads/machdep/engine-m68000-netbsd.h107
-rw-r--r--mit-pthreads/machdep/engine-r2000-ultrix-4.2.c209
-rw-r--r--mit-pthreads/machdep/engine-r2000-ultrix-4.2.h107
-rw-r--r--mit-pthreads/machdep/engine-romp-bsd.c99
-rw-r--r--mit-pthreads/machdep/engine-romp-bsd.h100
-rw-r--r--mit-pthreads/machdep/engine-sparc-netbsd-1.3.c232
-rw-r--r--mit-pthreads/machdep/engine-sparc-netbsd-1.3.h106
-rw-r--r--mit-pthreads/machdep/engine-sparc-sunos-4.1.3.c227
-rw-r--r--mit-pthreads/machdep/engine-sparc-sunos-4.1.3.h105
-rw-r--r--mit-pthreads/machdep/engine-sparc-sunos-5.3.c308
-rw-r--r--mit-pthreads/machdep/engine-sparc-sunos-5.3.h129
-rwxr-xr-xmit-pthreads/machdep/freebsd-1.1/compat.h43
-rwxr-xr-xmit-pthreads/machdep/freebsd-1.1/dirent.h64
-rwxr-xr-xmit-pthreads/machdep/freebsd-1.1/socket.h267
-rwxr-xr-xmit-pthreads/machdep/freebsd-1.1/timers.h68
-rwxr-xr-xmit-pthreads/machdep/freebsd-2.0/__math.h6
-rwxr-xr-xmit-pthreads/machdep/freebsd-2.0/__path.h14
-rwxr-xr-xmit-pthreads/machdep/freebsd-2.0/__signal.h8
-rwxr-xr-xmit-pthreads/machdep/freebsd-2.0/__stdio.h8
-rwxr-xr-xmit-pthreads/machdep/freebsd-2.0/__stdlib.h66
-rwxr-xr-xmit-pthreads/machdep/freebsd-2.0/__string.h21
-rwxr-xr-xmit-pthreads/machdep/freebsd-2.0/__time.h70
-rwxr-xr-xmit-pthreads/machdep/freebsd-2.0/__unistd.h113
-rwxr-xr-xmit-pthreads/machdep/freebsd-2.0/compat.h43
-rwxr-xr-xmit-pthreads/machdep/freebsd-2.0/dirent.h64
-rwxr-xr-xmit-pthreads/machdep/freebsd-2.0/errno.h160
-rwxr-xr-xmit-pthreads/machdep/freebsd-2.0/timers.h45
-rwxr-xr-xmit-pthreads/machdep/freebsd-2.0/wait.h162
-rwxr-xr-xmit-pthreads/machdep/hpux-10.20/__math.h3
-rwxr-xr-xmit-pthreads/machdep/hpux-10.20/__signal.h28
-rwxr-xr-xmit-pthreads/machdep/hpux-10.20/__stdio.h11
-rwxr-xr-xmit-pthreads/machdep/hpux-10.20/__stdlib.h24
-rwxr-xr-xmit-pthreads/machdep/hpux-10.20/__string.h20
-rwxr-xr-xmit-pthreads/machdep/hpux-10.20/__time.h31
-rwxr-xr-xmit-pthreads/machdep/hpux-10.20/__unistd.h68
-rwxr-xr-xmit-pthreads/machdep/hpux-10.20/cdefs.h67
-rwxr-xr-xmit-pthreads/machdep/hpux-10.20/compat.h45
-rwxr-xr-xmit-pthreads/machdep/hpux-10.20/dirent.h61
-rwxr-xr-xmit-pthreads/machdep/hpux-10.20/socket.h171
-rwxr-xr-xmit-pthreads/machdep/hpux-10.20/stdtypes.h74
-rwxr-xr-xmit-pthreads/machdep/hpux-10.20/time.h228
-rwxr-xr-xmit-pthreads/machdep/hpux-10.20/timers.h71
-rwxr-xr-xmit-pthreads/machdep/hpux-10.20/uio.h25
-rwxr-xr-xmit-pthreads/machdep/hpux-10.20/wait.h92
-rwxr-xr-xmit-pthreads/machdep/hpux-9.03/__math.h3
-rwxr-xr-xmit-pthreads/machdep/hpux-9.03/__signal.h28
-rwxr-xr-xmit-pthreads/machdep/hpux-9.03/__stdio.h8
-rwxr-xr-xmit-pthreads/machdep/hpux-9.03/__stdlib.h24
-rwxr-xr-xmit-pthreads/machdep/hpux-9.03/__string.h20
-rwxr-xr-xmit-pthreads/machdep/hpux-9.03/__time.h31
-rwxr-xr-xmit-pthreads/machdep/hpux-9.03/__unistd.h66
-rwxr-xr-xmit-pthreads/machdep/hpux-9.03/cdefs.h61
-rwxr-xr-xmit-pthreads/machdep/hpux-9.03/compat.h45
-rwxr-xr-xmit-pthreads/machdep/hpux-9.03/dirent.h61
-rwxr-xr-xmit-pthreads/machdep/hpux-9.03/socket.h171
-rwxr-xr-xmit-pthreads/machdep/hpux-9.03/stdtypes.h74
-rwxr-xr-xmit-pthreads/machdep/hpux-9.03/time.h228
-rwxr-xr-xmit-pthreads/machdep/hpux-9.03/timers.h68
-rwxr-xr-xmit-pthreads/machdep/hpux-9.03/uio.h25
-rwxr-xr-xmit-pthreads/machdep/hpux-9.03/wait.h92
-rwxr-xr-xmit-pthreads/machdep/i386-sco-3.2v5/__math.h219
-rwxr-xr-xmit-pthreads/machdep/i386-sco-3.2v5/__signal.h109
-rwxr-xr-xmit-pthreads/machdep/i386-sco-3.2v5/__stdio.h113
-rwxr-xr-xmit-pthreads/machdep/i386-sco-3.2v5/__stdlib.h137
-rwxr-xr-xmit-pthreads/machdep/i386-sco-3.2v5/__string.h125
-rwxr-xr-xmit-pthreads/machdep/i386-sco-3.2v5/__time.h141
-rwxr-xr-xmit-pthreads/machdep/i386-sco-3.2v5/__unistd.h48
-rwxr-xr-xmit-pthreads/machdep/i386-sco-3.2v5/compat.h46
-rwxr-xr-xmit-pthreads/machdep/i386-sco-3.2v5/dirent.h145
-rwxr-xr-xmit-pthreads/machdep/i386-sco-3.2v5/posix/__signal.h69
-rwxr-xr-xmit-pthreads/machdep/i386-sco-3.2v5/socket.h490
-rwxr-xr-xmit-pthreads/machdep/i386-sco-3.2v5/syscall.h175
-rwxr-xr-xmit-pthreads/machdep/i386-sco-3.2v5/timers.h68
-rwxr-xr-xmit-pthreads/machdep/i386-sco-3.2v5/trash.can1
-rwxr-xr-xmit-pthreads/machdep/irix-5.2/__math.h4
-rwxr-xr-xmit-pthreads/machdep/irix-5.2/__signal.h15
-rwxr-xr-xmit-pthreads/machdep/irix-5.2/__stdio.h6
-rwxr-xr-xmit-pthreads/machdep/irix-5.2/__stdlib.h30
-rwxr-xr-xmit-pthreads/machdep/irix-5.2/__string.h5
-rwxr-xr-xmit-pthreads/machdep/irix-5.2/__time.h21
-rwxr-xr-xmit-pthreads/machdep/irix-5.2/__unistd.h8
-rwxr-xr-xmit-pthreads/machdep/irix-5.2/compat.h45
-rwxr-xr-xmit-pthreads/machdep/irix-5.2/dirent.h21
-rwxr-xr-xmit-pthreads/machdep/irix-5.2/socket.h304
-rwxr-xr-xmit-pthreads/machdep/irix-5.2/timers.h18
-rwxr-xr-xmit-pthreads/machdep/irix-5.2/wait.h104
-rwxr-xr-xmit-pthreads/machdep/linux-1.0/__math.h4
-rwxr-xr-xmit-pthreads/machdep/linux-1.0/__path.h14
-rwxr-xr-xmit-pthreads/machdep/linux-1.0/__signal.h24
-rwxr-xr-xmit-pthreads/machdep/linux-1.0/__stdio.h7
-rwxr-xr-xmit-pthreads/machdep/linux-1.0/__stdlib.h20
-rwxr-xr-xmit-pthreads/machdep/linux-1.0/__string.h18
-rwxr-xr-xmit-pthreads/machdep/linux-1.0/__time.h72
-rwxr-xr-xmit-pthreads/machdep/linux-1.0/__unistd.h56
-rwxr-xr-xmit-pthreads/machdep/linux-1.0/cdefs.h23
-rwxr-xr-xmit-pthreads/machdep/linux-1.0/compat.h47
-rwxr-xr-xmit-pthreads/machdep/linux-1.0/dirent.h27
-rwxr-xr-xmit-pthreads/machdep/linux-1.0/errno.h12
-rwxr-xr-xmit-pthreads/machdep/linux-1.0/socket.h193
-rwxr-xr-xmit-pthreads/machdep/linux-1.0/timers.h71
-rwxr-xr-xmit-pthreads/machdep/linux-1.0/uio.h15
-rwxr-xr-xmit-pthreads/machdep/linux-1.0/wait.h98
-rwxr-xr-xmit-pthreads/machdep/linux-2.0/__math.h4
-rwxr-xr-xmit-pthreads/machdep/linux-2.0/__path.h14
-rwxr-xr-xmit-pthreads/machdep/linux-2.0/__signal.h24
-rwxr-xr-xmit-pthreads/machdep/linux-2.0/__stdio.h7
-rwxr-xr-xmit-pthreads/machdep/linux-2.0/__stdlib.h20
-rwxr-xr-xmit-pthreads/machdep/linux-2.0/__string.h18
-rwxr-xr-xmit-pthreads/machdep/linux-2.0/__time.h78
-rwxr-xr-xmit-pthreads/machdep/linux-2.0/__unistd.h62
-rwxr-xr-xmit-pthreads/machdep/linux-2.0/cdefs.h36
-rwxr-xr-xmit-pthreads/machdep/linux-2.0/compat.h47
-rwxr-xr-xmit-pthreads/machdep/linux-2.0/dirent.h27
-rwxr-xr-xmit-pthreads/machdep/linux-2.0/errno.h12
-rw-r--r--mit-pthreads/machdep/linux-2.0/extra/bits/local_lim.h15
-rwxr-xr-xmit-pthreads/machdep/linux-2.0/extra/bits/socket.h193
-rwxr-xr-xmit-pthreads/machdep/linux-2.0/socket.h196
-rw-r--r--mit-pthreads/machdep/linux-2.0/socketcall.h0
-rwxr-xr-xmit-pthreads/machdep/linux-2.0/timers.h71
-rwxr-xr-xmit-pthreads/machdep/linux-2.0/uio.h15
-rwxr-xr-xmit-pthreads/machdep/linux-2.0/wait.h98
-rwxr-xr-xmit-pthreads/machdep/netbsd-0.9/dirent.h64
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.0/__math.h6
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.0/__path.h14
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.0/__signal.h8
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.0/__stdio.h8
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.0/__stdlib.h60
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.0/__string.h20
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.0/__time.h69
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.0/__unistd.h107
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.0/compat.h43
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.0/dirent.h64
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.0/errno.h160
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.0/time.h125
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.0/timers.h45
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.0/wait.h158
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.1/__math.h6
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.1/__path.h14
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.1/__signal.h20
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.1/__stdio.h8
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.1/__stdlib.h60
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.1/__string.h20
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.1/__time.h69
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.1/__unistd.h107
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.1/compat.h43
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.1/dirent.h95
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.1/errno.h170
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.1/time.h153
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.1/timers.h45
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.1/wait.h163
-rwxr-xr-xmit-pthreads/machdep/openbsd-2.0/__math.h6
-rwxr-xr-xmit-pthreads/machdep/openbsd-2.0/__path.h14
-rwxr-xr-xmit-pthreads/machdep/openbsd-2.0/__signal.h8
-rwxr-xr-xmit-pthreads/machdep/openbsd-2.0/__stdio.h8
-rwxr-xr-xmit-pthreads/machdep/openbsd-2.0/__stdlib.h66
-rwxr-xr-xmit-pthreads/machdep/openbsd-2.0/__string.h21
-rwxr-xr-xmit-pthreads/machdep/openbsd-2.0/__time.h70
-rwxr-xr-xmit-pthreads/machdep/openbsd-2.0/__unistd.h109
-rwxr-xr-xmit-pthreads/machdep/openbsd-2.0/compat.h43
-rwxr-xr-xmit-pthreads/machdep/openbsd-2.0/dirent.h64
-rwxr-xr-xmit-pthreads/machdep/openbsd-2.0/errno.h160
-rwxr-xr-xmit-pthreads/machdep/openbsd-2.0/timers.h45
-rwxr-xr-xmit-pthreads/machdep/openbsd-2.0/wait.h162
-rw-r--r--mit-pthreads/machdep/posix-alpha-osf1.h7
-rw-r--r--mit-pthreads/machdep/posix-bsdi-1.1.h34
-rw-r--r--mit-pthreads/machdep/posix-bsdi-2.0.h34
-rw-r--r--mit-pthreads/machdep/posix-freebsd-1.1.h33
-rw-r--r--mit-pthreads/machdep/posix-freebsd-2.0.h31
-rw-r--r--mit-pthreads/machdep/posix-hpux-10.20.h23
-rw-r--r--mit-pthreads/machdep/posix-hpux-9.03.h23
-rw-r--r--mit-pthreads/machdep/posix-i386-sco-3.2v5.h35
-rw-r--r--mit-pthreads/machdep/posix-irix-5.2.h31
-rw-r--r--mit-pthreads/machdep/posix-linux-1.0.h31
-rw-r--r--mit-pthreads/machdep/posix-linux-2.0.h31
-rw-r--r--mit-pthreads/machdep/posix-netbsd-0.9.h22
-rw-r--r--mit-pthreads/machdep/posix-netbsd-1.0.h31
-rw-r--r--mit-pthreads/machdep/posix-netbsd-1.1.h31
-rw-r--r--mit-pthreads/machdep/posix-openbsd-2.0.h31
-rw-r--r--mit-pthreads/machdep/posix-romp-bsd.h33
-rw-r--r--mit-pthreads/machdep/posix-sco-3.2v5.h35
-rw-r--r--mit-pthreads/machdep/posix-sunos-4.1.3.h27
-rw-r--r--mit-pthreads/machdep/posix-sunos-5.3.h22
-rw-r--r--mit-pthreads/machdep/posix-sunos-5.5.h22
-rw-r--r--mit-pthreads/machdep/posix-ultrix-4.2.h24
-rwxr-xr-xmit-pthreads/machdep/sco-3.2v5/__math.h219
-rwxr-xr-xmit-pthreads/machdep/sco-3.2v5/__signal.h109
-rwxr-xr-xmit-pthreads/machdep/sco-3.2v5/__stdio.h113
-rwxr-xr-xmit-pthreads/machdep/sco-3.2v5/__stdlib.h137
-rwxr-xr-xmit-pthreads/machdep/sco-3.2v5/__string.h125
-rwxr-xr-xmit-pthreads/machdep/sco-3.2v5/__time.h141
-rwxr-xr-xmit-pthreads/machdep/sco-3.2v5/__unistd.h48
-rwxr-xr-xmit-pthreads/machdep/sco-3.2v5/compat.h46
-rwxr-xr-xmit-pthreads/machdep/sco-3.2v5/dirent.h145
-rwxr-xr-xmit-pthreads/machdep/sco-3.2v5/posix/__signal.h69
-rwxr-xr-xmit-pthreads/machdep/sco-3.2v5/socket.h490
-rwxr-xr-xmit-pthreads/machdep/sco-3.2v5/syscall.h175
-rwxr-xr-xmit-pthreads/machdep/sco-3.2v5/timers.h68
-rwxr-xr-xmit-pthreads/machdep/sco-3.2v5/trash.can1
-rwxr-xr-xmit-pthreads/machdep/sunos-4.1.3/__math.h5
-rwxr-xr-xmit-pthreads/machdep/sunos-4.1.3/__path.h12
-rwxr-xr-xmit-pthreads/machdep/sunos-4.1.3/__signal.h11
-rwxr-xr-xmit-pthreads/machdep/sunos-4.1.3/__stdio.h4
-rwxr-xr-xmit-pthreads/machdep/sunos-4.1.3/__stdlib.h28
-rwxr-xr-xmit-pthreads/machdep/sunos-4.1.3/__string.h14
-rwxr-xr-xmit-pthreads/machdep/sunos-4.1.3/__time.h2
-rwxr-xr-xmit-pthreads/machdep/sunos-4.1.3/__unistd.h73
-rwxr-xr-xmit-pthreads/machdep/sunos-4.1.3/cdefs.h61
-rwxr-xr-xmit-pthreads/machdep/sunos-4.1.3/compat.h45
-rwxr-xr-xmit-pthreads/machdep/sunos-4.1.3/dirent.h64
-rwxr-xr-xmit-pthreads/machdep/sunos-4.1.3/fcntlcom.h163
-rwxr-xr-xmit-pthreads/machdep/sunos-4.1.3/signal.h98
-rwxr-xr-xmit-pthreads/machdep/sunos-4.1.3/stat.h94
-rwxr-xr-xmit-pthreads/machdep/sunos-4.1.3/time.h69
-rwxr-xr-xmit-pthreads/machdep/sunos-4.1.3/timers.h68
-rwxr-xr-xmit-pthreads/machdep/sunos-4.1.3/wait.h22
-rwxr-xr-xmit-pthreads/machdep/sunos-5.3/__math.h16
-rwxr-xr-xmit-pthreads/machdep/sunos-5.3/__signal.h19
-rwxr-xr-xmit-pthreads/machdep/sunos-5.3/__stdio.h6
-rwxr-xr-xmit-pthreads/machdep/sunos-5.3/__stdlib.h27
-rwxr-xr-xmit-pthreads/machdep/sunos-5.3/__string.h12
-rwxr-xr-xmit-pthreads/machdep/sunos-5.3/__time.h69
-rwxr-xr-xmit-pthreads/machdep/sunos-5.3/__unistd.h47
-rwxr-xr-xmit-pthreads/machdep/sunos-5.3/cdefs.h59
-rwxr-xr-xmit-pthreads/machdep/sunos-5.3/compat.h45
-rwxr-xr-xmit-pthreads/machdep/sunos-5.3/dirent.h64
-rwxr-xr-xmit-pthreads/machdep/sunos-5.3/socket.h180
-rwxr-xr-xmit-pthreads/machdep/sunos-5.3/timers.h72
-rwxr-xr-xmit-pthreads/machdep/sunos-5.3/uio.h40
-rwxr-xr-xmit-pthreads/machdep/sunos-5.5/__math.h16
-rwxr-xr-xmit-pthreads/machdep/sunos-5.5/__signal.h19
-rwxr-xr-xmit-pthreads/machdep/sunos-5.5/__stdio.h6
-rwxr-xr-xmit-pthreads/machdep/sunos-5.5/__stdlib.h27
-rwxr-xr-xmit-pthreads/machdep/sunos-5.5/__string.h12
-rwxr-xr-xmit-pthreads/machdep/sunos-5.5/__time.h69
-rwxr-xr-xmit-pthreads/machdep/sunos-5.5/__unistd.h47
-rwxr-xr-xmit-pthreads/machdep/sunos-5.5/cdefs.h59
-rwxr-xr-xmit-pthreads/machdep/sunos-5.5/compat.h45
-rwxr-xr-xmit-pthreads/machdep/sunos-5.5/dirent.h64
-rwxr-xr-xmit-pthreads/machdep/sunos-5.5/socket.h180
-rwxr-xr-xmit-pthreads/machdep/sunos-5.5/timers.h70
-rwxr-xr-xmit-pthreads/machdep/sunos-5.5/uio.h40
-rw-r--r--mit-pthreads/machdep/syscall-alpha-netbsd-1.1.S206
-rw-r--r--mit-pthreads/machdep/syscall-alpha-netbsd-1.3.S228
-rw-r--r--mit-pthreads/machdep/syscall-alpha-osf1.S97
-rw-r--r--mit-pthreads/machdep/syscall-arm32-netbsd-1.3.S193
-rw-r--r--mit-pthreads/machdep/syscall-hppa-hpux-10.20.S23
-rw-r--r--mit-pthreads/machdep/syscall-hppa-hpux-9.03.S23
-rw-r--r--mit-pthreads/machdep/syscall-i386-bsdi-1.1.S288
-rw-r--r--mit-pthreads/machdep/syscall-i386-bsdi-2.0.S294
-rw-r--r--mit-pthreads/machdep/syscall-i386-freebsd-1.1.S293
-rw-r--r--mit-pthreads/machdep/syscall-i386-freebsd-2.0.S240
-rw-r--r--mit-pthreads/machdep/syscall-i386-linux-1.0.S406
-rw-r--r--mit-pthreads/machdep/syscall-i386-linux-2.0.S389
-rw-r--r--mit-pthreads/machdep/syscall-i386-netbsd-0.9.S229
-rw-r--r--mit-pthreads/machdep/syscall-i386-netbsd-1.0.S158
-rw-r--r--mit-pthreads/machdep/syscall-i386-netbsd-1.1.S181
-rw-r--r--mit-pthreads/machdep/syscall-i386-netbsd-1.3.S200
-rw-r--r--mit-pthreads/machdep/syscall-i386-openbsd-2.0.S237
-rw-r--r--mit-pthreads/machdep/syscall-i386-sco-3.2v5.S442
-rw-r--r--mit-pthreads/machdep/syscall-ip22-irix-5.2.S106
-rw-r--r--mit-pthreads/machdep/syscall-m68000-netbsd.S83
-rw-r--r--mit-pthreads/machdep/syscall-r2000-ultrix-4.2.S166
-rw-r--r--mit-pthreads/machdep/syscall-romp-bsd.S327
-rw-r--r--mit-pthreads/machdep/syscall-sparc-netbsd-1.1.S102
-rw-r--r--mit-pthreads/machdep/syscall-sparc-netbsd-1.3.S172
-rw-r--r--mit-pthreads/machdep/syscall-sparc-sunos-4.1.3.S113
-rw-r--r--mit-pthreads/machdep/syscall-sparc-sunos-5.3.S65
-rw-r--r--mit-pthreads/machdep/syscall-sparc-sunos4.S113
-rw-r--r--mit-pthreads/machdep/syscall-template-alpha-netbsd-1.1.S46
-rw-r--r--mit-pthreads/machdep/syscall-template-alpha-netbsd-1.3.S53
-rw-r--r--mit-pthreads/machdep/syscall-template-alpha-osf1.S46
-rw-r--r--mit-pthreads/machdep/syscall-template-arm32-netbsd-1.3.S55
-rw-r--r--mit-pthreads/machdep/syscall-template-hppa-hpux-10.20.S27
-rw-r--r--mit-pthreads/machdep/syscall-template-hppa-hpux-9.03.S27
-rw-r--r--mit-pthreads/machdep/syscall-template-i386-bsdi-2.0.S48
-rw-r--r--mit-pthreads/machdep/syscall-template-i386-freebsd-2.0.S59
-rw-r--r--mit-pthreads/machdep/syscall-template-i386-netbsd-1.1.S49
-rw-r--r--mit-pthreads/machdep/syscall-template-i386-netbsd-1.3.S56
-rw-r--r--mit-pthreads/machdep/syscall-template-i386-netbsd1.0.S49
-rw-r--r--mit-pthreads/machdep/syscall-template-i386-openbsd-2.0.S48
-rw-r--r--mit-pthreads/machdep/syscall-template-i386-sco-3.2v5.S67
-rw-r--r--mit-pthreads/machdep/syscall-template-ip22-irix-5.2.S51
-rw-r--r--mit-pthreads/machdep/syscall-template-m68000-netbsd.S43
-rw-r--r--mit-pthreads/machdep/syscall-template-r2000-ultrix-4.2.S77
-rw-r--r--mit-pthreads/machdep/syscall-template-sparc-netbsd-1.1.S40
-rw-r--r--mit-pthreads/machdep/syscall-template-sparc-netbsd-1.3.S48
-rw-r--r--mit-pthreads/machdep/syscall-template-sparc-sunos-5.3.S45
-rw-r--r--mit-pthreads/machdep/syscall-template-sparc-sunos4.S40
-rwxr-xr-xmit-pthreads/machdep/ultrix-4.2/__math.h2
-rwxr-xr-xmit-pthreads/machdep/ultrix-4.2/__signal.h66
-rwxr-xr-xmit-pthreads/machdep/ultrix-4.2/__stdio.h7
-rwxr-xr-xmit-pthreads/machdep/ultrix-4.2/__stdlib.h21
-rwxr-xr-xmit-pthreads/machdep/ultrix-4.2/__string.h17
-rwxr-xr-xmit-pthreads/machdep/ultrix-4.2/__time.h69
-rwxr-xr-xmit-pthreads/machdep/ultrix-4.2/__unistd.h51
-rwxr-xr-xmit-pthreads/machdep/ultrix-4.2/cdefs.h66
-rwxr-xr-xmit-pthreads/machdep/ultrix-4.2/compat.h45
-rwxr-xr-xmit-pthreads/machdep/ultrix-4.2/dirent.h61
-rwxr-xr-xmit-pthreads/machdep/ultrix-4.2/errno.h180
-rwxr-xr-xmit-pthreads/machdep/ultrix-4.2/time.h83
-rwxr-xr-xmit-pthreads/machdep/ultrix-4.2/timers.h68
-rwxr-xr-xmit-pthreads/machdep/ultrix-4.2/wait.h121
-rw-r--r--mit-pthreads/machdep/unistd-i386-freebsd-1.1.h178
-rw-r--r--mit-pthreads/machdep/unistd-i386-linux-1.0.h59
-rw-r--r--mit-pthreads/machdep/unistd-i386-linux-2.0.h59
-rw-r--r--mit-pthreads/machdep/unistd-sparc-sunos-4.1.3.h215
-rw-r--r--mit-pthreads/net/GNUmakefile.inc14
-rw-r--r--mit-pthreads/net/Makefile.inc13
-rw-r--r--mit-pthreads/net/gethostbyaddr.c161
-rw-r--r--mit-pthreads/net/gethostbyname.c167
-rw-r--r--mit-pthreads/net/gethostent.c162
-rw-r--r--mit-pthreads/net/gethostname.c22
-rw-r--r--mit-pthreads/net/getnetbyaddr.c65
-rw-r--r--mit-pthreads/net/getnetbyname.c72
-rw-r--r--mit-pthreads/net/getnetent.c145
-rw-r--r--mit-pthreads/net/getproto.c65
-rw-r--r--mit-pthreads/net/getprotoent.c143
-rw-r--r--mit-pthreads/net/getprotoname.c73
-rw-r--r--mit-pthreads/net/getservbyname.c76
-rw-r--r--mit-pthreads/net/getservbyport.c68
-rw-r--r--mit-pthreads/net/getservent.c146
-rw-r--r--mit-pthreads/net/herror.c92
-rw-r--r--mit-pthreads/net/inet_addr.c156
-rw-r--r--mit-pthreads/net/inet_lnaof.c61
-rw-r--r--mit-pthreads/net/inet_makeaddr.c64
-rw-r--r--mit-pthreads/net/inet_netof.c60
-rw-r--r--mit-pthreads/net/inet_network.c98
-rw-r--r--mit-pthreads/net/inet_ntoa.c85
-rw-r--r--mit-pthreads/net/net_internal.c78
-rw-r--r--mit-pthreads/net/net_internal.h57
-rw-r--r--mit-pthreads/net/proto_internal.c78
-rw-r--r--mit-pthreads/net/proto_internal.h57
-rw-r--r--mit-pthreads/net/res_comp.c340
-rw-r--r--mit-pthreads/net/res_debug.c749
-rw-r--r--mit-pthreads/net/res_init.c55
-rw-r--r--mit-pthreads/net/res_internal.c576
-rw-r--r--mit-pthreads/net/res_internal.h84
-rw-r--r--mit-pthreads/net/res_mkquery.c212
-rw-r--r--mit-pthreads/net/res_query.c97
-rw-r--r--mit-pthreads/net/res_querydomain.c66
-rw-r--r--mit-pthreads/net/res_search.c168
-rw-r--r--mit-pthreads/net/res_send.c313
-rw-r--r--mit-pthreads/net/serv_internal.c80
-rw-r--r--mit-pthreads/net/serv_internal.h57
-rwxr-xr-xmit-pthreads/patches/Streepy.html2873
-rwxr-xr-xmit-pthreads/patches/Streepy2.html93
-rwxr-xr-xmit-pthreads/patches/bill_lear70
-rwxr-xr-xmit-pthreads/patches/chris_demetriou149
-rwxr-xr-xmit-pthreads/patches/mevans642
-rwxr-xr-xmit-pthreads/patches/p15390
-rwxr-xr-xmit-pthreads/patches/p15596
-rwxr-xr-xmit-pthreads/pg++32
-rwxr-xr-xmit-pthreads/pgcc32
-rw-r--r--mit-pthreads/pthreads/GNUmakefile.inc46
-rw-r--r--mit-pthreads/pthreads/Makefile.inc75
-rw-r--r--mit-pthreads/pthreads/_exit.c80
-rw-r--r--mit-pthreads/pthreads/cleanup.c84
-rw-r--r--mit-pthreads/pthreads/cond.c437
-rw-r--r--mit-pthreads/pthreads/condattr.c90
-rw-r--r--mit-pthreads/pthreads/dump_state.c88
-rw-r--r--mit-pthreads/pthreads/errno.c53
-rw-r--r--mit-pthreads/pthreads/fd.c1083
-rw-r--r--mit-pthreads/pthreads/fd_kern.c1950
-rw-r--r--mit-pthreads/pthreads/fd_pipe.c257
-rw-r--r--mit-pthreads/pthreads/fd_sysv.c897
-rw-r--r--mit-pthreads/pthreads/file.c129
-rw-r--r--mit-pthreads/pthreads/globals.c85
-rw-r--r--mit-pthreads/pthreads/info.c77
-rw-r--r--mit-pthreads/pthreads/init.cc9
-rw-r--r--mit-pthreads/pthreads/malloc.c383
-rw-r--r--mit-pthreads/pthreads/mutex.c371
-rw-r--r--mit-pthreads/pthreads/mutexattr.c90
-rw-r--r--mit-pthreads/pthreads/panic.c58
-rw-r--r--mit-pthreads/pthreads/prio_queue.c176
-rw-r--r--mit-pthreads/pthreads/process.c208
-rw-r--r--mit-pthreads/pthreads/pthread.c293
-rw-r--r--mit-pthreads/pthreads/pthread_attr.c255
-rw-r--r--mit-pthreads/pthreads/pthread_cancel.c258
-rw-r--r--mit-pthreads/pthreads/pthread_detach.c92
-rw-r--r--mit-pthreads/pthreads/pthread_init.c135
-rw-r--r--mit-pthreads/pthreads/pthread_join.c139
-rw-r--r--mit-pthreads/pthreads/pthread_kill.c93
-rw-r--r--mit-pthreads/pthreads/pthread_once.c59
-rw-r--r--mit-pthreads/pthreads/queue.c143
-rw-r--r--mit-pthreads/pthreads/readv.c85
-rw-r--r--mit-pthreads/pthreads/schedparam.c170
-rw-r--r--mit-pthreads/pthreads/select.c255
-rw-r--r--mit-pthreads/pthreads/sig.c452
-rw-r--r--mit-pthreads/pthreads/signal.c653
-rw-r--r--mit-pthreads/pthreads/sleep.c367
-rw-r--r--mit-pthreads/pthreads/specific.c198
-rw-r--r--mit-pthreads/pthreads/stat.c116
-rw-r--r--mit-pthreads/pthreads/wait.c159
-rw-r--r--mit-pthreads/pthreads/wrapper.c149
-rw-r--r--mit-pthreads/pthreads/writev.c89
-rwxr-xr-xmit-pthreads/scripts/GNUmakefile.inc24
-rw-r--r--mit-pthreads/scripts/Makefile.inc30
-rwxr-xr-xmit-pthreads/scripts/pgcc.sh32
-rwxr-xr-xmit-pthreads/stdio/GNUmakefile.inc26
-rw-r--r--mit-pthreads/stdio/Makefile.inc20
-rwxr-xr-xmit-pthreads/stdio/README41
-rw-r--r--mit-pthreads/stdio/clrerr.c51
-rw-r--r--mit-pthreads/stdio/fclose.c73
-rw-r--r--mit-pthreads/stdio/fdopen.c93
-rw-r--r--mit-pthreads/stdio/feof.c55
-rw-r--r--mit-pthreads/stdio/ferror.c55
-rw-r--r--mit-pthreads/stdio/fflush.c98
-rw-r--r--mit-pthreads/stdio/fgetc.c65
-rw-r--r--mit-pthreads/stdio/fgetline.c170
-rw-r--r--mit-pthreads/stdio/fgetpos.c85
-rw-r--r--mit-pthreads/stdio/fgets.c110
-rw-r--r--mit-pthreads/stdio/fileno.c55
-rw-r--r--mit-pthreads/stdio/findfp.c161
-rw-r--r--mit-pthreads/stdio/flags.c93
-rw-r--r--mit-pthreads/stdio/floatio.h47
-rw-r--r--mit-pthreads/stdio/fopen.c90
-rw-r--r--mit-pthreads/stdio/fprintf.c71
-rw-r--r--mit-pthreads/stdio/fpurge.c73
-rw-r--r--mit-pthreads/stdio/fputc.c73
-rw-r--r--mit-pthreads/stdio/fputs.c67
-rw-r--r--mit-pthreads/stdio/fread.c84
-rw-r--r--mit-pthreads/stdio/freopen.c149
-rw-r--r--mit-pthreads/stdio/fscanf.c73
-rw-r--r--mit-pthreads/stdio/fseek.c248
-rw-r--r--mit-pthreads/stdio/fsetpos.c54
-rw-r--r--mit-pthreads/stdio/ftell.c90
-rw-r--r--mit-pthreads/stdio/funopen.c105
-rw-r--r--mit-pthreads/stdio/fvwrite.c190
-rw-r--r--mit-pthreads/stdio/fvwrite.h54
-rw-r--r--mit-pthreads/stdio/fwalk.c132
-rw-r--r--mit-pthreads/stdio/fwrite.c80
-rw-r--r--mit-pthreads/stdio/getc.c58
-rw-r--r--mit-pthreads/stdio/getc_unlocked.c55
-rw-r--r--mit-pthreads/stdio/getchar.c58
-rw-r--r--mit-pthreads/stdio/getchar_unlocked.c54
-rw-r--r--mit-pthreads/stdio/gets.c71
-rw-r--r--mit-pthreads/stdio/getw.c51
-rw-r--r--mit-pthreads/stdio/glue.h49
-rw-r--r--mit-pthreads/stdio/local.h90
-rw-r--r--mit-pthreads/stdio/makebuf.c122
-rw-r--r--mit-pthreads/stdio/mktemp.c126
-rw-r--r--mit-pthreads/stdio/perror.c67
-rw-r--r--mit-pthreads/stdio/printf.c56
-rw-r--r--mit-pthreads/stdio/putc.c60
-rw-r--r--mit-pthreads/stdio/putc_unlocked.c56
-rw-r--r--mit-pthreads/stdio/putchar.c60
-rw-r--r--mit-pthreads/stdio/putchar_unlocked.c56
-rw-r--r--mit-pthreads/stdio/puts.c71
-rw-r--r--mit-pthreads/stdio/putw.c64
-rw-r--r--mit-pthreads/stdio/refill.c189
-rw-r--r--mit-pthreads/stdio/remove.c50
-rw-r--r--mit-pthreads/stdio/rewind.c55
-rw-r--r--mit-pthreads/stdio/rget.c58
-rw-r--r--mit-pthreads/stdio/scanf.c72
-rw-r--r--mit-pthreads/stdio/setbuf.c52
-rw-r--r--mit-pthreads/stdio/setbuffer.c64
-rw-r--r--mit-pthreads/stdio/setvbuf.c154
-rw-r--r--mit-pthreads/stdio/snprintf.c79
-rw-r--r--mit-pthreads/stdio/sprintf.c78
-rw-r--r--mit-pthreads/stdio/sscanf.c79
-rw-r--r--mit-pthreads/stdio/stdio.c104
-rw-r--r--mit-pthreads/stdio/strerror.c67
-rw-r--r--mit-pthreads/stdio/tempnam.c87
-rw-r--r--mit-pthreads/stdio/tmpfile.c80
-rw-r--r--mit-pthreads/stdio/tmpnam.c55
-rw-r--r--mit-pthreads/stdio/ungetc.c155
-rw-r--r--mit-pthreads/stdio/vfprintf.c788
-rw-r--r--mit-pthreads/stdio/vfscanf.c750
-rw-r--r--mit-pthreads/stdio/vprintf.c51
-rw-r--r--mit-pthreads/stdio/vscanf.c55
-rw-r--r--mit-pthreads/stdio/vsnprintf.c65
-rw-r--r--mit-pthreads/stdio/vsprintf.c62
-rw-r--r--mit-pthreads/stdio/vsscanf.c62
-rw-r--r--mit-pthreads/stdio/wbuf.c89
-rw-r--r--mit-pthreads/stdio/wsetup.c91
-rw-r--r--mit-pthreads/stdio/xprintf.c883
-rwxr-xr-xmit-pthreads/stdlib/GNUmakefile.inc7
-rw-r--r--mit-pthreads/stdlib/Makefile.inc10
-rw-r--r--mit-pthreads/stdlib/abort.c67
-rw-r--r--mit-pthreads/stdlib/atexit.h46
-rw-r--r--mit-pthreads/stdlib/exit.c89
-rw-r--r--mit-pthreads/stdlib/getopt.c135
-rw-r--r--mit-pthreads/stdlib/rand.c64
-rw-r--r--mit-pthreads/stdlib/random.c389
-rw-r--r--mit-pthreads/stdlib/strtod.c178
-rw-r--r--mit-pthreads/stdlib/strtol.c131
-rw-r--r--mit-pthreads/stdlib/strtoul.c109
-rw-r--r--mit-pthreads/stdlib/system.c83
-rwxr-xr-xmit-pthreads/string/GNUmakefile.inc7
-rw-r--r--mit-pthreads/string/Makefile.inc8
-rw-r--r--mit-pthreads/string/strtok.c119
-rw-r--r--mit-pthreads/tests/.cvsignore1
-rw-r--r--mit-pthreads/tests/Makefile.in164
-rwxr-xr-xmit-pthreads/tests/README26
-rw-r--r--mit-pthreads/tests/bench_fcntl.c82
-rw-r--r--mit-pthreads/tests/bench_pipe.c115
-rw-r--r--mit-pthreads/tests/bench_read.c88
-rw-r--r--mit-pthreads/tests/p_bench_getpid.c78
-rw-r--r--mit-pthreads/tests/p_bench_mutex.c78
-rw-r--r--mit-pthreads/tests/p_bench_pthread_create.c92
-rw-r--r--mit-pthreads/tests/p_bench_read.c103
-rw-r--r--mit-pthreads/tests/p_bench_semaphore.c82
-rw-r--r--mit-pthreads/tests/p_bench_yield.c123
-rw-r--r--mit-pthreads/tests/test_create.c35
-rw-r--r--mit-pthreads/tests/test_cwd.c11
-rw-r--r--mit-pthreads/tests/test_execve.c57
-rw-r--r--mit-pthreads/tests/test_fcntl.c32
-rw-r--r--mit-pthreads/tests/test_fork.c60
-rw-r--r--mit-pthreads/tests/test_netdb.c110
-rw-r--r--mit-pthreads/tests/test_pause.c19
-rw-r--r--mit-pthreads/tests/test_preemption.c38
-rw-r--r--mit-pthreads/tests/test_preemption_float.c98
-rw-r--r--mit-pthreads/tests/test_pthread_cond_timedwait.c93
-rw-r--r--mit-pthreads/tests/test_pthread_join.c78
-rw-r--r--mit-pthreads/tests/test_pthread_mutex.c221
-rw-r--r--mit-pthreads/tests/test_pw.c20
-rw-r--r--mit-pthreads/tests/test_readdir.c42
-rw-r--r--mit-pthreads/tests/test_select.c115
-rw-r--r--mit-pthreads/tests/test_setjmp.c13
-rw-r--r--mit-pthreads/tests/test_sleep.c46
-rw-r--r--mit-pthreads/tests/test_sock_1.c204
-rw-r--r--mit-pthreads/tests/test_sock_2.c116
-rw-r--r--mit-pthreads/tests/test_sock_2a.c87
-rw-r--r--mit-pthreads/tests/test_stdio_1.c124
-rw-r--r--mit-pthreads/tests/test_switch.c97
694 files changed, 84929 insertions, 0 deletions
diff --git a/mit-pthreads/.cvsignore b/mit-pthreads/.cvsignore
new file mode 100644
index 00000000000..6b051949557
--- /dev/null
+++ b/mit-pthreads/.cvsignore
@@ -0,0 +1,6 @@
+Makefile
+config.cache
+config.h
+config.log
+config.status
+obj
diff --git a/mit-pthreads/COPYRIGHT b/mit-pthreads/COPYRIGHT
new file mode 100644
index 00000000000..1b727cd8dac
--- /dev/null
+++ b/mit-pthreads/COPYRIGHT
@@ -0,0 +1,31 @@
+Copyright (c) 1993, 1994, 1995, 1996 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/mit-pthreads/Changes-mysql b/mit-pthreads/Changes-mysql
new file mode 100644
index 00000000000..8895144206d
--- /dev/null
+++ b/mit-pthreads/Changes-mysql
@@ -0,0 +1,194 @@
+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.
+
+99.06.07 by Monty (monty@mysql.com)
+- Added patches from the NETBSD site. Should fix the following platforms:
+ alpha-netbsd-1.3, sparc-netbsd-1.3, i386-netbsd, arm32-netbsd
+
+99.09.09 by Monty (monty@mysql.com)
+- Added patches from Christoph Badura <bad@oreilly.de> for NetBSD
+
+99.09.13 by Monty (monty@mysql.com)
+- Added patches from Dirk Froemberg <dirk@FreeBSD.org> for FreeBSD
+
+99.10.18 by Monty (monty@mysql.com)
+- Added patch for machdep_sys_lseek() for netbsd.
+
+99.12.30 by Monty (monty@mysql.com)
+- Added patch by Christoph Badura <bad@oreilly.de> to update mit-pthreads
+ to the same version as in the NetBSD pkgsrc.
+
+00.02.24 by Monty (monty@mysql.com)
+- Added configure files to make mit-pthreads to compile and link during
+ newer linux systems (needed because of the MySQL configure system).
+ The resulting library has however not been verified under Linux.
+
+00.03.30 by Monty (monty@mysql.com)
+- Added chroot() and gethostname().
diff --git a/mit-pthreads/FAQ b/mit-pthreads/FAQ
new file mode 100644
index 00000000000..e4fd3cfc6d8
--- /dev/null
+++ b/mit-pthreads/FAQ
@@ -0,0 +1,122 @@
+
+ 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/mit-pthreads/GNUmakefile b/mit-pthreads/GNUmakefile
new file mode 100644
index 00000000000..a36f425c7a7
--- /dev/null
+++ b/mit-pthreads/GNUmakefile
@@ -0,0 +1,129 @@
+# === GNUmakefile =============================================================
+# Copyright (c) 1991, 1992, 1993 Chris Provenzano, proven@athena.mit.edu
+#
+# Description: This file is for creating libpthread.a
+#
+# 1.00 93/11/17 proven
+# -Put all the .o files into one file libpthread.a
+# -Initial cut for pthreads.
+#
+
+INSTALL_PATH = $(exec_prefix)
+
+ BINDIR = $(INSTALL_PATH)/bin
+ LIBDIR = $(INSTALL_PATH)/lib
+ MANDIR = $(INSTALL_PATH)/man
+ INCDIR = $(INSTALL_PATH)/include
+ SUBINCDIR = $(INCDIR)/pthread
+
+ AR = ar
+ AS = gas
+ CFLAGS = -I. -Iinclude -I$(srcdir)/include -DPTHREAD_KERNEL \
+ -O6 -DDBUG_OFF -Werror
+ CXXFLAGS = -I. -Iinclude -I$(srcdir)/include -DPTHREAD_KERNEL \
+ -g -O2
+ LD = gld
+
+ CSRC =
+
+ PTHREAD_DIR = pthreads stdlib stdio gen
+ DIRS = $(PTHREAD_DIR)
+
+ HEADERS =
+
+ LIBRARIES = libpthread.a
+
+ .CURDIR = .
+
+# force correct default target
+all:
+
+###############################################################################
+#
+# Read in any special flags that config knows about
+include config.flags
+
+# What the heck. Convert srcdir to absolute form so it looks prettier.
+srcdir := $(shell cd $(srcfoo) && pwd)
+
+################################################################################
+#
+# Here starts the nitty grity part of the Makefile.
+
+all-lib : libpthread.a
+
+include ${srcdir}/pthreads/GNUmakefile.inc
+include ${srcdir}/stdlib/GNUmakefile.inc
+include ${srcdir}/stdio/GNUmakefile.inc
+include ${srcdir}/string/GNUmakefile.inc
+include ${srcdir}/gen/GNUmakefile.inc
+include ${srcdir}/net/GNUmakefile.inc
+include ${srcdir}/scripts/GNUmakefile.inc
+
+REGULAR_OBJS= $(subst .cc,.o,$(SRCS))
+REGULAR_OBJS:= $(subst .c,.o,$(REGULAR_OBJS))
+REGULAR_OBJS:= $(subst .S,.o,$(REGULAR_OBJS))
+OBJS= $(REGULAR_OBJS) $(EXTRA_OBJS)
+REALOBJS = $(addprefix obj/, $(OBJS))
+
+$(REALOBJS) : $(config) $(types) $(paths)
+
+# Since we do not have a list of the relevant files we do a make clean
+# before copying everyting to the distribution directory.
+distdir:
+ $(MAKE) clean
+ cp -a . $(distdir)
+ # Remove symlinks that the distribution should not have.
+ rm -f $(distdir)/config.cache \
+ $(distdir)/include/pthread/machdep.h \
+ $(distdir)/include/pthread/posix.h \
+ $(distdir)/include/sys \
+ $(distdir)/machdep.c \
+ $(distdir)/syscall.S \
+ $(distdir)/syscall-template.S
+
+clean:
+ rm -f a.out core maketmp makeout $(LIBRARIES) $(BINARIES) libpthread.*
+ rm -rf obj
+ cd tests && $(MAKE) clean && cd ..
+
+install-lib: $(LIBRARIES) install-dirs
+ for x in $(LIBRARIES); \
+ do install $$x $(DESTDIR)$(LIBDIR); \
+ done
+
+# Removed make install since mysql uses this in place.
+# install-lib install-include install-bin
+install:
+
+libpthread.a: obj/libpthread.a
+ rm -f libpthread.a
+ ln -s obj/libpthread.a .
+
+obj/libpthread.a: ${REALOBJS}
+ rm -f libpthread.a obj/new.a obj/libpthread.a
+ cd obj && \
+ ar r new.a ${OBJS} && \
+ $(RANLIB) new.a && \
+ mv -f new.a libpthread.a && \
+ cd ..
+
+# For examining a combined symbol table, sizes, &c.
+libpthread.o: ${REALOBJS}
+ cd obj && ld -r -o ../libpthread.o ${OBJS} && cd ..
+
+obj/x:
+ if [ -d obj ]; then true; else mkdir obj; fi
+ cp /dev/null obj/x
+
+GNUmakefile: config.status ${srcdir}/config/GNUmakefile.in
+ $(SHELL) config.status
+
+obj/%.o: %.c obj/x
+ $(CC) $(CFLAGS) -c $< -o $@
+
+obj/%.o: %.cc obj/x
+ $(CXX) $(CXXFLAGS) $(CFLAGS) -c $< -o $@
+
+obj/%.o: %.S obj/x
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/mit-pthreads/NOTES b/mit-pthreads/NOTES
new file mode 100644
index 00000000000..cebdc6a396c
--- /dev/null
+++ b/mit-pthreads/NOTES
@@ -0,0 +1,59 @@
+
+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/mit-pthreads/NOTES_OSR5_BUILD_SKUNKWARE97 b/mit-pthreads/NOTES_OSR5_BUILD_SKUNKWARE97
new file mode 100644
index 00000000000..fd2e00c9860
--- /dev/null
+++ b/mit-pthreads/NOTES_OSR5_BUILD_SKUNKWARE97
@@ -0,0 +1,45 @@
+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/mit-pthreads/README b/mit-pthreads/README
new file mode 100644
index 00000000000..0a55bcd94bb
--- /dev/null
+++ b/mit-pthreads/README
@@ -0,0 +1,40 @@
+This pthread package is/will be based on the POSIX1003.1c Draft 10 pthread
+standard, and Frank Muellers paper on signal handeling 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 proven@mit.edu,
+or pthreads@mit.edu.
+
+PLEASE, don't send questions, bugs or patches to any of the *BSD*, Linux
+or GNU mailing lists.
+
+Thanks goes to Ken Raeburn for his help on the Sparc port, the configurator,
+and his many suggestions, Greg Hudson for the thread safe net routines and
+all the testing he's done.
+
+More thanks to Mark Eichin and all the others for the testing they have done.
+
+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.
+
+You will need to create a machdep.h, machdep.c and syscall.S for the
+new architecture. The first two are necessary to get the context switch
+section of the pthread package running, the third is for all the syscalls.
+
+INCLUDE FILES AND PORTING
+In addition to the above three files you need to create a slew of .h files.
+Take a look at an existing port to determine what is in each, and then
+take a look at your system header files to determine what to put in them.
+
+------------------------------------------------------------------------------
+Copyright (c) 1993, 1994, 1995, 1996 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/mit-pthreads/TODO-mysql b/mit-pthreads/TODO-mysql
new file mode 100644
index 00000000000..a19b1bd51d6
--- /dev/null
+++ b/mit-pthreads/TODO-mysql
@@ -0,0 +1,4 @@
+This what should be done to get more functionally for mysqld.
+
+- open should be interruptable.
+- fcntl lock should be interruptable.
diff --git a/mit-pthreads/Whats_New b/mit-pthreads/Whats_New
new file mode 100644
index 00000000000..556d9f63268
--- /dev/null
+++ b/mit-pthreads/Whats_New
@@ -0,0 +1,198 @@
+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/mit-pthreads/bin/.cvsignore b/mit-pthreads/bin/.cvsignore
new file mode 100644
index 00000000000..f3c7a7c5da6
--- /dev/null
+++ b/mit-pthreads/bin/.cvsignore
@@ -0,0 +1 @@
+Makefile
diff --git a/mit-pthreads/bin/Makefile.in b/mit-pthreads/bin/Makefile.in
new file mode 100644
index 00000000000..979ad2db2ea
--- /dev/null
+++ b/mit-pthreads/bin/Makefile.in
@@ -0,0 +1,48 @@
+# === 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/mit-pthreads/bin/finger/.cvsignore b/mit-pthreads/bin/finger/.cvsignore
new file mode 100644
index 00000000000..f3c7a7c5da6
--- /dev/null
+++ b/mit-pthreads/bin/finger/.cvsignore
@@ -0,0 +1 @@
+Makefile
diff --git a/mit-pthreads/bin/finger/Makefile.in b/mit-pthreads/bin/finger/Makefile.in
new file mode 100755
index 00000000000..ee20f47443d
--- /dev/null
+++ b/mit-pthreads/bin/finger/Makefile.in
@@ -0,0 +1,60 @@
+# === 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/mit-pthreads/bin/finger/finger.c b/mit-pthreads/bin/finger/finger.c
new file mode 100755
index 00000000000..33b3011e8bb
--- /dev/null
+++ b/mit-pthreads/bin/finger/finger.c
@@ -0,0 +1,231 @@
+/* ==== 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/mit-pthreads/bin/finger/net.c b/mit-pthreads/bin/finger/net.c
new file mode 100755
index 00000000000..77ccd92ee8c
--- /dev/null
+++ b/mit-pthreads/bin/finger/net.c
@@ -0,0 +1,189 @@
+/* ==== 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/mit-pthreads/config/COPYING.GNU b/mit-pthreads/config/COPYING.GNU
new file mode 100755
index 00000000000..a43ea2126fb
--- /dev/null
+++ b/mit-pthreads/config/COPYING.GNU
@@ -0,0 +1,339 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 675 Mass Ave, Cambridge, MA 02139, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ Appendix: How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 19yy <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19yy name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/mit-pthreads/config/COPYRIGHT b/mit-pthreads/config/COPYRIGHT
new file mode 100755
index 00000000000..ba3ac43c589
--- /dev/null
+++ b/mit-pthreads/config/COPYRIGHT
@@ -0,0 +1,4 @@
+The files config.guess and config.sub in this directory come from the GNU
+autoconf distribution, and are covered by the GNU Public License, which may
+be found in the file COPYING.GNU. They are the only files covered by the
+GPL.
diff --git a/mit-pthreads/config/GNUmakefile.in b/mit-pthreads/config/GNUmakefile.in
new file mode 100755
index 00000000000..7c06ee367e6
--- /dev/null
+++ b/mit-pthreads/config/GNUmakefile.in
@@ -0,0 +1,129 @@
+# === GNUmakefile =============================================================
+# Copyright (c) 1991, 1992, 1993 Chris Provenzano, proven@athena.mit.edu
+#
+# Description: This file is for creating libpthread.a
+#
+# 1.00 93/11/17 proven
+# -Put all the .o files into one file libpthread.a
+# -Initial cut for pthreads.
+#
+
+INSTALL_PATH = $(exec_prefix)
+
+ BINDIR = $(INSTALL_PATH)/bin
+ LIBDIR = $(INSTALL_PATH)/lib
+ MANDIR = $(INSTALL_PATH)/man
+ INCDIR = $(INSTALL_PATH)/include
+ SUBINCDIR = $(INCDIR)/pthread
+
+ AR = ar
+ AS = gas
+ CFLAGS = -I. -Iinclude -I$(srcdir)/include -DPTHREAD_KERNEL \
+ @CFLAGS@
+ CXXFLAGS = -I. -Iinclude -I$(srcdir)/include -DPTHREAD_KERNEL \
+ @CXXFLAGS@
+ LD = gld
+
+ CSRC =
+
+ PTHREAD_DIR = pthreads stdlib stdio gen
+ DIRS = $(PTHREAD_DIR)
+
+ HEADERS =
+
+ LIBRARIES = libpthread.a
+
+ .CURDIR = .
+
+# force correct default target
+all:
+
+###############################################################################
+#
+# Read in any special flags that config knows about
+include config.flags
+
+# What the heck. Convert srcdir to absolute form so it looks prettier.
+srcdir := $(shell cd $(srcfoo) && pwd)
+
+################################################################################
+#
+# Here starts the nitty grity part of the Makefile.
+
+all-lib : libpthread.a
+
+include ${srcdir}/pthreads/GNUmakefile.inc
+include ${srcdir}/stdlib/GNUmakefile.inc
+include ${srcdir}/stdio/GNUmakefile.inc
+include ${srcdir}/string/GNUmakefile.inc
+include ${srcdir}/gen/GNUmakefile.inc
+include ${srcdir}/net/GNUmakefile.inc
+include ${srcdir}/scripts/GNUmakefile.inc
+
+REGULAR_OBJS= $(subst .cc,.o,$(SRCS))
+REGULAR_OBJS:= $(subst .c,.o,$(REGULAR_OBJS))
+REGULAR_OBJS:= $(subst .S,.o,$(REGULAR_OBJS))
+OBJS= $(REGULAR_OBJS) $(EXTRA_OBJS)
+REALOBJS = $(addprefix obj/, $(OBJS))
+
+$(REALOBJS) : $(config) $(types) $(paths)
+
+# Since we do not have a list of the relevant files we do a make clean
+# before copying everyting to the distribution directory.
+distdir:
+ $(MAKE) clean
+ cp -a . $(distdir)
+ # Remove symlinks that the distribution should not have.
+ rm -f $(distdir)/config.cache \
+ $(distdir)/include/pthread/machdep.h \
+ $(distdir)/include/pthread/posix.h \
+ $(distdir)/include/sys \
+ $(distdir)/machdep.c \
+ $(distdir)/syscall.S \
+ $(distdir)/syscall-template.S
+
+clean:
+ rm -f a.out core maketmp makeout $(LIBRARIES) $(BINARIES) libpthread.*
+ rm -rf obj
+ cd tests && $(MAKE) clean && cd ..
+
+install-lib: $(LIBRARIES) install-dirs
+ for x in $(LIBRARIES); \
+ do install $$x $(DESTDIR)$(LIBDIR); \
+ done
+
+# Removed make install since mysql uses this in place.
+# install-lib install-include install-bin
+install:
+
+libpthread.a: obj/libpthread.a
+ rm -f libpthread.a
+ ln -s obj/libpthread.a .
+
+obj/libpthread.a: ${REALOBJS}
+ rm -f libpthread.a obj/new.a obj/libpthread.a
+ cd obj && \
+ ar r new.a ${OBJS} && \
+ $(RANLIB) new.a && \
+ mv -f new.a libpthread.a && \
+ cd ..
+
+# For examining a combined symbol table, sizes, &c.
+libpthread.o: ${REALOBJS}
+ cd obj && ld -r -o ../libpthread.o ${OBJS} && cd ..
+
+obj/x:
+ if [ -d obj ]; then true; else mkdir obj; fi
+ cp /dev/null obj/x
+
+GNUmakefile: config.status ${srcdir}/config/GNUmakefile.in
+ $(SHELL) config.status
+
+obj/%.o: %.c obj/x
+ $(CC) $(CFLAGS) -c $< -o $@
+
+obj/%.o: %.cc obj/x
+ $(CXX) $(CXXFLAGS) $(CFLAGS) -c $< -o $@
+
+obj/%.o: %.S obj/x
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/mit-pthreads/config/Makefile.in b/mit-pthreads/config/Makefile.in
new file mode 100644
index 00000000000..3fa388d740b
--- /dev/null
+++ b/mit-pthreads/config/Makefile.in
@@ -0,0 +1,56 @@
+# @(#)Makefile 5.2 (Berkeley) 3/5/91
+#
+
+LIB=pthread
+NOPIC=1
+NOPROFILE=1
+NOLINT=1
+MKPIC=no
+MKPROFILE=no
+MKLINT=no
+CPPFLAGS+= -I${.CURDIR} -I${.CURDIR}/include -I${srcdir}/include -DPTHREAD_KERNEL
+CDEBUGFLAGS= @CFLAGS@
+CFLAGS+= ${CDEBUGFLAGS}
+# CFLAGS+= ${CPPFLAGS} <- done by bsd.lib.mk
+CFLAGS+= ${CPPFLAGS}
+LIBDIR= $(exec_prefix)/lib
+BINDIR= $(exec_prefix)/bin
+INCDIR= $(exec_prefix)/include
+MANDIR= $(exec_prefix)/man
+
+.OBJDIR != if test -d ${.CURDIR}/obj ; then true ; else mkdir ${.CURDIR}/obj || exit 1 ; fi ; echo ${.CURDIR}/obj
+
+# Standard bsd install rules look for the "install" program, rather than
+# using some variable. So, hack things so that that install rule works.
+BINGRP != echo " " `groups` " " | sed 's/ [0-9][0-9]* / /g' | awk '{print $$1}'
+BINOWN != echo $${USER}
+LIBMODE = 644 # so ranlib can run!
+
+.include "config.flags"
+
+# %!$@ pmake seems to automagically cd into the obj directory, so relative
+# srcdir references are completely botched. Try to figure out an absolute
+# pathname for srcdir here, and live with it.
+srcdir = $(srctop)
+
+beforeinstall: install-dirs
+
+.include "${srcdir}/pthreads/Makefile.inc"
+.include "${srcdir}/stdlib/Makefile.inc"
+.include "${srcdir}/stdio/Makefile.inc"
+.include "${srcdir}/string/Makefile.inc"
+.include "${srcdir}/gen/Makefile.inc"
+.include "${srcdir}/net/Makefile.inc"
+.include "${srcdir}/scripts/Makefile.inc"
+
+$(OBJS) : $(config) $(types) $(paths)
+
+Makefile: ${srcdir}/config/Makefile.in
+ cd ${.CURDIR} && sh config.status
+
+all-lib : libpthread.a
+# Removed make install since mysql uses this in place.
+#install : install-bin install-include
+install:
+
+.include <bsd.lib.mk>
diff --git a/mit-pthreads/config/acconfig.h b/mit-pthreads/config/acconfig.h
new file mode 100644
index 00000000000..14552b0d851
--- /dev/null
+++ b/mit-pthreads/config/acconfig.h
@@ -0,0 +1,73 @@
+/* Does the OS already support struct timespec */
+#undef _OS_HAS_TIMESPEC
+
+/* For networking code: an integral type the size of an IP address (4
+ octets). Determined by examining return values from certain
+ functions. */
+#undef pthread_ipaddr_type
+
+/* For networking code: an integral type the size of an IP port number
+ (2 octets). Determined by examining return values from certain
+ functions. */
+#undef pthread_ipport_type
+
+/* type of clock_t, from system header files */
+#undef pthread_clock_t
+
+/* Specially named so grep processing will find it and put it into the
+ generated ac-types.h. */
+#undef pthread_have_va_list_h
+
+/* type of size_t, from system header files */
+#undef pthread_size_t
+
+/* type of ssize_t, from system header files */
+#undef pthread_ssize_t
+
+/* type of time_t, from system header files */
+#undef pthread_time_t
+
+/* type of fpos_t, from system header files */
+#undef pthread_fpos_t
+
+/* type of off_t, from system header files */
+#undef pthread_off_t
+
+/* type of va_list, from system header files */
+#undef pthread_va_list
+
+/* type of sigset_t, from system header files */
+#undef pthread_sigset_t
+
+/* I don't know why the native compiler definitions aren't sufficient
+ for this. */
+#undef sunos4
+
+/* define if the linker hauls in certain static data from libc even when
+ you don't want it to. yes, this description is bogus, but chris added
+ the need for this, without describing the problem. */
+#undef LD_LINKS_STATIC_DATA
+
+/* define if the system reissues the SIGCHLD if the handler reinstalls
+ * itself before calling wait()
+ */
+#undef BROKEN_SIGNALS
+
+/* where are terminal devices to be found? */
+#undef _PATH_PTY
+
+/* what directory holds the time zone info on this system? */
+#undef _PATH_TZDIR
+
+/* what file indicates the local time zone? */
+#undef _PATH_TZFILE
+
+/* Paths for various networking support files. */
+#undef _PATH_RESCONF
+#undef _PATH_HOSTS
+#undef _PATH_NETWORKS
+#undef _PATH_PROTOCOLS
+#undef _PATH_SERVICES
+
+/* Path for Bourne shell. */
+#undef _PATH_BSHELL
diff --git a/mit-pthreads/config/aclocal.m4 b/mit-pthreads/config/aclocal.m4
new file mode 100755
index 00000000000..2a5cd3e9cbf
--- /dev/null
+++ b/mit-pthreads/config/aclocal.m4
@@ -0,0 +1,94 @@
+dnl Autoconf extensions for pthreads package.
+dnl
+ifelse(regexp(AC_DEFINE(xxxxx),.*@@@.*),-1,,[define(IS_AUTOHEADER)])])dnl
+dnl
+dnl Now, the real stuff needed by the pthreads package.
+dnl
+AC_DEFUN([PTHREADS_CHECK_ONE_SYSCALL],
+[AC_MSG_CHECKING(for syscall $1)
+AC_CACHE_VAL(pthreads_cv_syscall_$1,
+AC_TRY_LINK([
+/* FIXME: This list should be generated from info in configure.in. */
+#ifdef HAVE_SYSCALL_H
+#include <syscall.h>
+#else
+#ifdef HAVE_SYS_SYSCALL_H
+#include <sys/syscall.h>
+#else
+where is your syscall header file??
+#endif
+#endif
+],[
+int x;
+x = SYS_$1 ;
+],
+eval pthreads_cv_syscall_$1=yes,
+eval pthreads_cv_syscall_$1=no))
+if eval test \$pthreads_cv_syscall_$1 = yes ; then
+ pthreads_syscall_present=yes
+ available_syscalls="$available_syscalls $1"
+dnl Can't just do the obvious substitution here or autoheader gets
+dnl sorta confused. (Sigh.) Getting the requoting of the brackets right
+dnl would be a pain too.
+ macroname=HAVE_SYSCALL_`echo $1 | tr '[[[a-z]]]' '[[[A-Z]]]'`
+ AC_DEFINE_UNQUOTED($macroname)
+else
+ pthreads_syscall_present=no
+ missing_syscalls="$missing_syscalls $1"
+fi
+AC_MSG_RESULT($pthreads_syscall_present)
+])dnl
+dnl
+AC_DEFUN(PTHREADS_CHECK_SYSCALLS,dnl
+ifdef([IS_AUTOHEADER],[#
+dnl Need to fake out autoheader, since there's no way to add a new class
+dnl of features to generate config.h.in entries for.
+@@@syscalls="$1"@@@
+@@@funcs="$funcs syscall_`echo $syscalls | sed 's/ / syscall_/g'`"@@@
+],
+[pthreads_syscall_list="$1"
+for pthreads_syscallname in $pthreads_syscall_list ; do
+ PTHREADS_CHECK_ONE_SYSCALL([$]pthreads_syscallname)
+done
+]))dnl
+dnl
+dnl Requote each argument.
+define([requote], [ifelse($#, 0, , $#, 1, "$1",
+ "$1" [requote(builtin(shift,$@))])])dnl
+dnl
+dnl Determine proper typedef value for a typedef name, and define a
+dnl C macro to expand to that type. (A shell variable with that value
+dnl is also created.) If none of the specified types to try match, the
+dnl macro is left undefined, and the shell variable empty. If the
+dnl typedef name cannot be found in the specified header files, this
+dnl test errors out; perhaps it should be changed to simply leave the
+dnl macro undefined...
+dnl
+dnl PTHREADS_FIND_TYPE(typedefname,varname,includes,possible values...)
+dnl
+AC_DEFUN(PTHREADS_FIND_TYPE,
+ifdef([IS_AUTOHEADER],[#
+@@@syms="$syms $2"@@@
+],[dnl
+AC_MSG_CHECKING(type of $1)
+AC_CACHE_VAL(pthreads_cv_type_$1,
+[AC_TRY_COMPILE([$3],[ extern $1 foo; ],
+[ for try_type in [requote(builtin(shift,builtin(shift,builtin(shift,$@))))] ; do
+ AC_TRY_COMPILE([$3],[ extern $1 foo; extern $try_type foo; ],
+ [ pthreads_cv_type_$1="$try_type" ; break ])
+ done],
+ AC_MSG_ERROR(Can't find system typedef for $1.))])
+if test -n "$pthreads_cv_type_$1" ; then
+ AC_DEFINE_UNQUOTED($2,$pthreads_cv_type_$1)
+fi
+$2=$pthreads_cv_type_$1
+AC_MSG_RESULT($pthreads_cv_type_$1)]))dnl
+dnl
+dnl
+dnl Like above, but the list of types to try is pre-specified.
+dnl
+AC_DEFUN(PTHREADS_FIND_INTEGRAL_TYPE,[
+PTHREADS_FIND_TYPE([$1], [$2], [$3],
+ int, unsigned int, long, unsigned long,
+ short, unsigned short, char, unsigned char,
+ long long, unsigned long long)])dnl
diff --git a/mit-pthreads/config/config.flags.in b/mit-pthreads/config/config.flags.in
new file mode 100755
index 00000000000..3d16423a045
--- /dev/null
+++ b/mit-pthreads/config/config.flags.in
@@ -0,0 +1,80 @@
+# Since the real configure script runs from the config subdirectory,
+# compensate here...
+srctop= @srctop@
+srcfoo= $(srctop)
+
+prefix= @prefix@
+exec_prefix= @exec_prefix@
+
+cpu = @target_cpu@
+os = @target_os@
+
+MISSING_SYSCALLS = @missing_syscalls@
+AVAILABLE_SYSCALLS = @available_syscalls@
+SYSCALL_EXCEPTIONS = @SYSCALL_EXCEPTIONS@
+HAVE_SYSCALL_TEMPLATE = @HAVE_SYSCALL_TEMPLATE@
+
+CC = @CC@
+CXX = @CXX@
+CPP = @CPP@
+SHELL = /bin/sh
+RANLIB = @RANLIB@
+# Should use autoconf to find these. Currently our makefiles are inconsistent.
+#AR = ar
+#AS = gas
+#LD = gld
+
+install-dirs:
+ for d in $(INSTALL_PATH) $(BINDIR) $(LIBDIR) $(INCDIR) ; do \
+ test -d $(DESTDIR)$$d || mkdir $(DESTDIR)$$d || exit 1 ; \
+ done
+
+config.status: @srcdir@/configure
+ cd ${.CURDIR} && $(SHELL) config.status --recheck
+config.flags: config.status @srcdir@/config.flags.in
+ cd ${.CURDIR} && $(SHELL) config.status
+
+realclean: clean
+ cd tests && $(MAKE) realclean && cd ..
+ rm -f $(LINKS) config.status config.flags config.cache \
+ Makefile GNUmakefile
+
+types=$(.CURDIR)/include/pthread/ac-types.h
+$(types) : config.h
+ echo '#ifndef pthread_size_t' > $(types).new
+ egrep '^#define pthread_' $(.CURDIR)/config.h >> $(types).new
+ echo '#endif' >> $(types).new
+ mv -f $(types).new $(types)
+
+config=$(.CURDIR)/include/pthread/config.h
+$(config) : config.h
+ echo '#ifndef _SYS___CONFIG_H_' > $(config).new
+ echo '#define _SYS___CONFIG_H_' >> $(config).new
+ -egrep '^#define _OS_HAS' $(.CURDIR)/config.h >> $(config).new
+ echo '#endif' >> $(config).new
+ mv -f $(config).new $(config)
+
+paths=$(.CURDIR)/include/pthread/paths.h
+$(paths) : config.h
+ echo '#ifndef _SYS___PATHS_H_' > $(paths).new
+ echo '#define _SYS___PATHS_H_' >> $(paths).new
+ egrep '^#define _PATH' $(.CURDIR)/config.h >> $(paths).new
+ echo '#endif' >> $(paths).new
+ mv -f $(paths).new $(paths)
+
+all-tests: all-lib
+ cd ${.CURDIR}/tests && $(MAKE) all
+check: all-lib
+ cd ${.CURDIR}/tests && $(MAKE) check
+all : all-lib all-bin
+
+install-bin: all-bin install-dirs
+ for x in $(SCRIPTS) ; do \
+ install $$x $(DESTDIR)$(BINDIR); \
+ done
+
+install-include: install-dirs
+ (cd ${srcdir}/include && tar chf - .)|(cd $(DESTDIR)$(INCDIR) && tar xf -)
+ if [ -d config ]; then true; else \
+ (cd ${.CURDIR}/include && tar chf - .)|(cd $(DESTDIR)$(INCDIR) && tar xf -); fi
+ (cd $(DESTDIR)$(INCDIR) && find . \( -name CVS -o -name \*~ \) -print | xargs rm -rf)
diff --git a/mit-pthreads/config/config.guess b/mit-pthreads/config/config.guess
new file mode 100755
index 00000000000..36fb26d3998
--- /dev/null
+++ b/mit-pthreads/config/config.guess
@@ -0,0 +1,504 @@
+#!/bin/sh
+# Attempt to guess a canonical system name.
+# Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
+#
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Written by Per Bothner <bothner@cygnus.com>.
+# The master version of this file is at the FSF in /home/gd/gnu/lib.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub. If it succeeds, it prints the system name on stdout, and
+# exits with 0. Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit system type (host/target name).
+#
+# Only a few systems have been added to this list; please add others
+# (but try to keep the structure clean).
+#
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 8/24/94.)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+ PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ alpha:OSF1:V*:*)
+ # After 1.2, OSF1 uses "V1.3" for uname -r.
+ echo alpha-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^V//'`
+ exit 0 ;;
+ alpha:OSF1:*:*)
+ # 1.2 uses "1.2" for uname -r.
+ echo alpha-dec-osf${UNAME_RELEASE}
+ exit 0 ;;
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ echo arm-acorn-riscix${UNAME_RELEASE}
+ exit 0;;
+ Pyramid*:OSx*:*:*)
+ if test "`(/bin/universe) 2>/dev/null`" = att ; then
+ echo pyramid-pyramid-sysv3
+ else
+ echo pyramid-pyramid-bsd
+ fi
+ exit 0 ;;
+ sun4*:SunOS:5.*:*)
+ echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:6*:*)
+ # According to config.sub, this is the proper way to canonicalize
+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but
+ # it's likely to be more like Solaris than SunOS4.
+ echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:*:*)
+ # Japanese Language versions have a version number like `4.1.3-JL'.
+ echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+ exit 0 ;;
+ sun3*:SunOS:*:*)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ exit 0 ;;
+ RISC*:ULTRIX:*:*)
+ echo mips-dec-ultrix${UNAME_RELEASE}
+ exit 0 ;;
+ VAX*:ULTRIX*:*:*)
+ echo vax-dec-ultrix${UNAME_RELEASE}
+ exit 0 ;;
+ mips:*:5*:RISCos)
+ echo mips-mips-riscos${UNAME_RELEASE}
+ exit 0 ;;
+ m88k:CX/UX:7*:*)
+ echo m88k-harris-cxux7
+ exit 0 ;;
+ m88k:*:4*:R4*)
+ echo m88k-motorola-sysv4
+ exit 0 ;;
+ m88k:*:3*:R3*)
+ echo m88k-motorola-sysv3
+ exit 0 ;;
+ AViiON:dgux:*:*)
+ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \
+ -o ${TARGET_BINARY_INTERFACE}x = x ] ; then
+ echo m88k-dg-dgux${UNAME_RELEASE}
+ else
+ echo m88k-dg-dguxbcs${UNAME_RELEASE}
+ fi
+ exit 0 ;;
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
+ echo m88k-dolphin-sysv3
+ exit 0 ;;
+ M88*:*:R3*:*)
+ # Delta 88k system running SVR3
+ echo m88k-motorola-sysv3
+ exit 0 ;;
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+ echo m88k-tektronix-sysv3
+ exit 0 ;;
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+ echo m68k-tektronix-bsd
+ exit 0 ;;
+ *:IRIX:*:*)
+ echo mips-sgi-irix${UNAME_RELEASE}
+ exit 0 ;;
+ i[34]86:AIX:*:*)
+ echo i386-ibm-aix
+ exit 0 ;;
+ *:AIX:2:3)
+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ sed 's/^ //' << EOF >dummy.c
+ #include <sys/systemcfg.h>
+
+ main()
+ {
+ if (!__power_pc())
+ exit(1);
+ puts("powerpc-ibm-aix3.2.5");
+ exit(0);
+ }
+EOF
+ ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
+ rm -f dummy.c dummy
+ echo rs6000-ibm-aix3.2.5
+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+ echo rs6000-ibm-aix3.2.4
+ else
+ echo rs6000-ibm-aix3.2
+ fi
+ exit 0 ;;
+ *:AIX:*:4)
+ if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then
+ IBM_ARCH=rs6000
+ else
+ IBM_ARCH=powerpc
+ fi
+ if grep bos410 /usr/include/stdio.h >/dev/null 2>&1; then
+ IBM_REV=4.1
+ elif grep bos411 /usr/include/stdio.h >/dev/null 2>&1; then
+ IBM_REV=4.1.1
+ else
+ IBM_REV=4.${UNAME_RELEASE}
+ fi
+ echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+ exit 0 ;;
+ *:AIX:*:*)
+ echo rs6000-ibm-aix
+ exit 0 ;;
+ *:BOSX:*:*)
+ echo rs6000-bull-bosx
+ exit 0 ;;
+ DPX/2?00:B.O.S.:*:*)
+ echo m68k-bull-sysv3
+ exit 0 ;;
+ 9000/[34]??:4.3bsd:1.*:*)
+ echo m68k-hp-bsd
+ exit 0 ;;
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+ echo m68k-hp-bsd4.4
+ exit 0 ;;
+ 9000/[3478]??:HP-UX:*:*)
+ case "${UNAME_MACHINE}" in
+ 9000/31? ) HP_ARCH=m68000 ;;
+ 9000/[34]?? ) HP_ARCH=m68k ;;
+ 9000/7?? | 9000/8?7 ) HP_ARCH=hppa1.1 ;;
+ 9000/8?? ) HP_ARCH=hppa1.0 ;;
+ esac
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+ exit 0 ;;
+ 3050*:HI-UX:*:*)
+ sed 's/^ //' << EOF >dummy.c
+ #include <unistd.h>
+ int
+ main ()
+ {
+ long cpu = sysconf (_SC_CPU_VERSION);
+ /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
+ results, however. */
+ if (CPU_IS_PA_RISC (cpu))
+ {
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+ default: puts ("hppa-hitachi-hiuxwe2"); break;
+ }
+ }
+ else if (CPU_IS_HP_MC68K (cpu))
+ puts ("m68k-hitachi-hiuxwe2");
+ else puts ("unknown-hitachi-hiuxwe2");
+ exit (0);
+ }
+EOF
+ ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
+ rm -f dummy.c dummy
+ echo unknown-hitachi-hiuxwe2
+ exit 0 ;;
+ 9000/7??:4.3bsd:*:* | 9000/8?7:4.3bsd:*:* )
+ echo hppa1.1-hp-bsd
+ exit 0 ;;
+ 9000/8??:4.3bsd:*:*)
+ echo hppa1.0-hp-bsd
+ exit 0 ;;
+ hp7??:OSF1:*:* | hp8?7:OSF1:*:* )
+ echo hppa1.1-hp-osf
+ exit 0 ;;
+ hp8??:OSF1:*:*)
+ echo hppa1.0-hp-osf
+ exit 0 ;;
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+ echo c1-convex-bsd
+ exit 0 ;;
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit 0 ;;
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+ echo c34-convex-bsd
+ exit 0 ;;
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+ echo c38-convex-bsd
+ exit 0 ;;
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+ echo c4-convex-bsd
+ exit 0 ;;
+ CRAY*X-MP:UNICOS:*:*)
+ echo xmp-cray-unicos
+ exit 0 ;;
+ CRAY*Y-MP:UNICOS:*:*)
+ echo ymp-cray-unicos
+ exit 0 ;;
+ CRAY-2:UNICOS:*:*)
+ echo cray2-cray-unicos
+ exit 0 ;;
+ amiga:NetBSD:*:*)
+ echo m68k-amiga-netbsd${UNAME_RELEASE}
+ exit 0 ;;
+ atari:NetBSD:*:*)
+ echo m68k-atari-netbsd${UNAME_RELEASE}
+ exit 0 ;;
+ hp3[0-9][05]:NetBSD:*:*)
+ echo m68k-hp-netbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mac68k:NetBSD:*:*)
+ echo m68k-apple-netbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme68:NetBSD:*:*)
+ echo m68k-motorola-netbsd${UNAME_RELEASE}
+ exit 0 ;;
+ next68k:NetBSD:*:*)
+ echo m68k-next-netbsd${UNAME_RELEASE}
+ exit 0 ;;
+ news68k:NetBSD:*:*)
+ echo m68k-sony-netbsd${UNAME_RELEASE}
+ exit 0 ;;
+ sun3:NetBSD:*:*)
+ echo m68k-sun-netbsd${UNAME_RELEASE}
+ exit 0 ;;
+ x68k:NetBSD:*:*)
+ echo m68k-sharp-netbsd${UNAME_RELEASE}
+ exit 0 ;;
+ i[34]86:BSD/386:*:* | *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ exit 0 ;;
+ *:FreeBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ exit 0 ;;
+ *:NetBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ exit 0 ;;
+ *:OpenBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ exit 0 ;;
+ *:GNU:*:*)
+ echo `echo ${UNAME_MACHINE}|sed -e 's,/.*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ exit 0 ;;
+ *:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux
+ exit 0 ;;
+# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions
+# are messed up and put the nodename in both sysname and nodename.
+ i[34]86:DYNIX/ptx:4*:*)
+ echo i386-sequent-sysv4
+ exit 0 ;;
+ i[34]86:*:4.*:* | i[34]86:SYSTEM_V:4.*:*)
+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+ echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE}
+ else
+ echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}
+ fi
+ exit 0 ;;
+ i[34]86:*:3.2:*)
+ if /bin/uname -X 2>/dev/null >/dev/null ; then
+ UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
+ echo ${UNAME_MACHINE}-unknown-sco$UNAME_REL
+ elif test -f /usr/options/cb.name; then
+ UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+ echo ${UNAME_MACHINE}-unknown-isc$UNAME_REL
+ else
+ echo ${UNAME_MACHINE}-unknown-sysv32
+ fi
+ exit 0 ;;
+ i?86:*:5:7)
+ UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
+ && UNAME_MACHINE=i586
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}${UNAME_VERSION}-sysv${UNAME_RELEASE}
+ exit 0 ;;
+ Intel:Mach:3*:*)
+ echo i386-unknown-mach3
+ exit 0 ;;
+ i860:*:4.*:*) # i860-SVR4
+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+ echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+ else # Add other i860-SVR4 vendors below as they are discovered.
+ echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
+ fi
+ exit 0 ;;
+ mini*:CTIX:SYS*5:*)
+ # "miniframe"
+ echo m68010-convergent-sysv
+ exit 0 ;;
+ M680[234]0:*:R3V[567]*:*)
+ test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
+ 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0)
+ uname -p 2>/dev/null | grep 86 >/dev/null \
+ && echo i486-ncr-sysv4.3 && exit 0 ;;
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+ uname -p 2>/dev/null | grep 86 >/dev/null \
+ && echo i486-ncr-sysv4 && exit 0 ;;
+ m680[234]0:LynxOS:2.2*:*)
+ echo m68k-lynx-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ mc68030:UNIX_System_V:4.*:*)
+ echo m68k-atari-sysv4
+ exit 0 ;;
+ i[34]86:LynxOS:2.2*:*)
+ echo i386-lynx-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ TSUNAMI:LynxOS:2.2*:*)
+ echo sparc-lynx-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ rs6000:LynxOS:2.2*:*)
+ echo rs6000-lynx-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ RM*:SINIX-*:*:*)
+ echo mips-sni-sysv4
+ exit 0 ;;
+ *:SINIX-*:*:*)
+ if uname -p 2>/dev/null >/dev/null ; then
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ echo ${UNAME_MACHINE}-sni-sysv4
+ else
+ echo ns32k-sni-sysv
+ fi
+ exit 0 ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+cat >dummy.c <<EOF
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+ /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
+ I don't know.... */
+ printf ("mips-sony-bsd\n"); exit (0);
+#else
+ printf ("m68k-sony-newsos\n"); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+ printf ("arm-acorn-riscix"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+ printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+ int version;
+ version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+ printf ("%s-next-nextstep%s\n", __ARCHITECTURE__, version==2 ? "2" : "3");
+ exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+ printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+ printf ("ns32k-encore-mach\n"); exit (0);
+#else
+ printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+ printf ("i386-unknown-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+ printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+ printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+ printf ("i386-sequent-ptx\n"); exit (0);
+#endif
+
+#if defined (vax)
+#if !defined (ultrix)
+ printf ("vax-dec-bsd\n"); exit (0);
+#else
+ printf ("vax-dec-ultrix\n"); exit (0);
+#endif
+#endif
+
+#if defined (alliant) && defined (i860)
+ printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+ exit (1);
+}
+EOF
+
+${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0
+rm -f dummy.c dummy
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+ case `getsysinfo -f cpu_type` in
+ c1*)
+ echo c1-convex-bsd
+ exit 0 ;;
+ c2*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit 0 ;;
+ c34*)
+ echo c34-convex-bsd
+ exit 0 ;;
+ c38*)
+ echo c38-convex-bsd
+ exit 0 ;;
+ c4*)
+ echo c4-convex-bsd
+ exit 0 ;;
+ esac
+fi
+
+#echo '(Unable to guess system type)' 1>&2
+
+exit 1
diff --git a/mit-pthreads/config/config.h.in b/mit-pthreads/config/config.h.in
new file mode 100755
index 00000000000..b5e25404a67
--- /dev/null
+++ b/mit-pthreads/config/config.h.in
@@ -0,0 +1,324 @@
+/* config.h.in. Generated automatically from configure.in by autoheader. */
+
+/* Define to `long' if <sys/types.h> doesn't define. */
+#undef off_t
+
+/* Define as the return type of signal handlers (int or void). */
+#undef RETSIGTYPE
+
+/* Define to `unsigned' if <sys/types.h> doesn't define. */
+#undef size_t
+
+/* Define if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define if you can safely include both <sys/time.h> and <time.h>. */
+#undef TIME_WITH_SYS_TIME
+
+/* Does the OS already support struct timespec */
+#undef _OS_HAS_TIMESPEC
+
+/* Does the OS need socklen_t for the socket syscalls? */
+#undef _OS_HAS_SOCKLEN_T
+
+/* For networking code: an integral type the size of an IP address (4
+ octets). Determined by examining return values from certain
+ functions. */
+#undef pthread_ipaddr_type
+
+/* For networking code: an integral type the size of an IP port number
+ (2 octets). Determined by examining return values from certain
+ functions. */
+#undef pthread_ipport_type
+
+/* type of clock_t, from system header files */
+#undef pthread_clock_t
+
+/* Specially named so grep processing will find it and put it into the
+ generated ac-types.h. */
+#undef pthread_have_va_list_h
+
+/* type of size_t, from system header files */
+#undef pthread_size_t
+
+/* type of ssize_t, from system header files */
+#undef pthread_ssize_t
+
+/* type of time_t, from system header files */
+#undef pthread_time_t
+
+/* type of fpos_t, from system header files */
+#undef pthread_fpos_t
+
+/* type of off_t, from system header files */
+#undef pthread_off_t
+
+/* type of va_list, from system header files */
+#undef pthread_va_list
+
+/* I don't know why the native compiler definitions aren't sufficient
+ for this. */
+#undef sunos4
+
+/* define if the linker hauls in certain static data from libc even when
+ you don't want it to. yes, this description is bogus, but chris added
+ the need for this, without describing the problem. */
+#undef LD_LINKS_STATIC_DATA
+
+/* define if the system reissues the SIGCHLD if the handler reinstalls
+ * itself before calling wait()
+ */
+#undef BROKEN_SIGNALS
+
+/* where are terminal devices to be found? */
+#undef _PATH_PTY
+
+/* what directory holds the time zone info on this system? */
+#undef _PATH_TZDIR
+
+/* what file indicates the local time zone? */
+#undef _PATH_TZFILE
+
+/* Paths for various networking support files. */
+#undef _PATH_RESCONF
+#undef _PATH_HOSTS
+#undef _PATH_NETWORKS
+#undef _PATH_PROTOCOLS
+#undef _PATH_SERVICES
+
+/* Path for Bourne shell. */
+#undef _PATH_BSHELL
+
+/* Define if you have the syscall_accept function. */
+#undef HAVE_SYSCALL_ACCEPT
+
+/* Define if you have the syscall_bind function. */
+#undef HAVE_SYSCALL_BIND
+
+/* Define if you have the syscall_chdir function. */
+#undef HAVE_SYSCALL_CHDIR
+
+/* Define if you have the syscall_chmod function. */
+#undef HAVE_SYSCALL_CHMOD
+
+/* Define if you have the syscall_chown function. */
+#undef HAVE_SYSCALL_CHOWN
+
+/* Define if you have the syscall_chroot function. */
+#undef HAVE_SYSCALL_CHROOT
+
+/* Define if you have the syscall_close function. */
+#undef HAVE_SYSCALL_CLOSE
+
+/* Define if you have the syscall_connect function. */
+#undef HAVE_SYSCALL_CONNECT
+
+/* Define if you have the syscall_creat function. */
+#undef HAVE_SYSCALL_CREAT
+
+/* Define if you have the syscall_dup function. */
+#undef HAVE_SYSCALL_DUP
+
+/* Define if you have the syscall_dup2 function. */
+#undef HAVE_SYSCALL_DUP2
+
+/* Define if you have the syscall_execve function. */
+#undef HAVE_SYSCALL_EXECVE
+
+/* Define if you have the syscall_exit function. */
+#undef HAVE_SYSCALL_EXIT
+
+/* Define if you have the syscall_fchmod function. */
+#undef HAVE_SYSCALL_FCHMOD
+
+/* Define if you have the syscall_fchown function. */
+#undef HAVE_SYSCALL_FCHOWN
+
+/* Define if you have the syscall_fcntl function. */
+#undef HAVE_SYSCALL_FCNTL
+
+/* Define if you have the syscall_flock function. */
+#undef HAVE_SYSCALL_FLOCK
+
+/* Define if you have the syscall_fork function. */
+#undef HAVE_SYSCALL_FORK
+
+/* Define if you have the syscall_fstat function. */
+#undef HAVE_SYSCALL_FSTAT
+
+/* Define if you have the syscall_fstatfs function. */
+#undef HAVE_SYSCALL_FSTATFS
+
+/* Define if you have the syscall_ftruncate function. */
+#undef HAVE_SYSCALL_FTRUNCATE
+
+/* Define if you have the syscall_getdents function. */
+#undef HAVE_SYSCALL_GETDENTS
+
+/* Define if you have the syscall_getdirentries function. */
+#undef HAVE_SYSCALL_GETDIRENTRIES
+
+/* Define if you have the syscall_getdtablesize function. */
+#undef HAVE_SYSCALL_GETDTABLESIZE
+
+/* Define if you have the syscall_getmsg function. */
+#undef HAVE_SYSCALL_GETMSG
+
+/* Define if you have the syscall_getpeername function. */
+#undef HAVE_SYSCALL_GETPEERNAME
+
+/* Define if you have the syscall_getpgrp function. */
+#undef HAVE_SYSCALL_GETPGRP
+
+/* Define if you have the syscall_getsockname function. */
+#undef HAVE_SYSCALL_GETSOCKNAME
+
+/* Define if you have the syscall_getsockopt function. */
+#undef HAVE_SYSCALL_GETSOCKOPT
+
+/* Define if you have the syscall_ioctl function. */
+#undef HAVE_SYSCALL_IOCTL
+
+/* Define if you have the syscall_ksigaction function. */
+#undef HAVE_SYSCALL_KSIGACTION
+
+/* Define if you have the syscall_link function. */
+#undef HAVE_SYSCALL_LINK
+
+/* Define if you have the syscall_listen function. */
+#undef HAVE_SYSCALL_LISTEN
+
+/* Define if you have the syscall_lseek function. */
+#undef HAVE_SYSCALL_LSEEK
+
+/* Define if you have the syscall_lstat function. */
+#undef HAVE_SYSCALL_LSTAT
+
+/* Define if you have the syscall_open function. */
+#undef HAVE_SYSCALL_OPEN
+
+/* Define if you have the syscall_pgrpsys function. */
+#undef HAVE_SYSCALL_PGRPSYS
+
+/* Define if you have the syscall_pipe function. */
+#undef HAVE_SYSCALL_PIPE
+
+/* Define if you have the syscall_poll function. */
+#undef HAVE_SYSCALL_POLL
+
+/* Define if you have the syscall_putmsg function. */
+#undef HAVE_SYSCALL_PUTMSG
+
+/* Define if you have the syscall_read function. */
+#undef HAVE_SYSCALL_READ
+
+/* Define if you have the syscall_readdir function. */
+#undef HAVE_SYSCALL_READDIR
+
+/* Define if you have the syscall_readv function. */
+#undef HAVE_SYSCALL_READV
+
+/* Define if you have the syscall_recv function. */
+#undef HAVE_SYSCALL_RECV
+
+/* Define if you have the syscall_recvfrom function. */
+#undef HAVE_SYSCALL_RECVFROM
+
+/* Define if you have the syscall_recvmsg function. */
+#undef HAVE_SYSCALL_RECVMSG
+
+/* Define if you have the syscall_rename function. */
+#undef HAVE_SYSCALL_RENAME
+
+/* Define if you have the syscall_select function. */
+#undef HAVE_SYSCALL_SELECT
+
+/* Define if you have the syscall_send function. */
+#undef HAVE_SYSCALL_SEND
+
+/* Define if you have the syscall_sendmsg function. */
+#undef HAVE_SYSCALL_SENDMSG
+
+/* Define if you have the syscall_sendto function. */
+#undef HAVE_SYSCALL_SENDTO
+
+/* Define if you have the syscall_setsockopt function. */
+#undef HAVE_SYSCALL_SETSOCKOPT
+
+/* Define if you have the syscall_shutdown function. */
+#undef HAVE_SYSCALL_SHUTDOWN
+
+/* Define if you have the syscall_sigaction function. */
+#undef HAVE_SYSCALL_SIGACTION
+
+/* Define if you have the syscall_sigpause function. */
+#undef HAVE_SYSCALL_SIGPAUSE
+
+/* Define if you have the syscall_sigprocmask function. */
+#undef HAVE_SYSCALL_SIGPROCMASK
+
+/* Define if you have the syscall_sigsuspend function. */
+#undef HAVE_SYSCALL_SIGSUSPEND
+
+/* Define if you have the syscall_socket function. */
+#undef HAVE_SYSCALL_SOCKET
+
+/* Define if you have the syscall_socketcall function. */
+#undef HAVE_SYSCALL_SOCKETCALL
+
+/* Define if you have the syscall_socketpair function. */
+#undef HAVE_SYSCALL_SOCKETPAIR
+
+/* Define if you have the syscall_stat function. */
+#undef HAVE_SYSCALL_STAT
+
+/* Define if you have the syscall_uname function. */
+#undef HAVE_SYSCALL_UNAME
+
+/* Define if you have the syscall_unlink function. */
+#undef HAVE_SYSCALL_UNLINK
+
+/* Define if you have the syscall_wait3 function. */
+#undef HAVE_SYSCALL_WAIT3
+
+/* Define if you have the syscall_wait4 function. */
+#undef HAVE_SYSCALL_WAIT4
+
+/* Define if you have the syscall_waitpid function. */
+#undef HAVE_SYSCALL_WAITPID
+
+/* Define if you have the syscall_waitsys function. */
+#undef HAVE_SYSCALL_WAITSYS
+
+/* Define if you have the syscall_write function. */
+#undef HAVE_SYSCALL_WRITE
+
+/* Define if you have the syscall_writev function. */
+#undef HAVE_SYSCALL_WRITEV
+
+/* Define if you have the vfork function. */
+#undef HAVE_VFORK
+
+/* Define if you have the <alloc.h> header file. */
+#undef HAVE_ALLOC_H
+
+/* Define if you have the <sys/filio.h> header file. */
+#undef HAVE_SYS_FILIO_H
+
+/* Define if you have the <sys/syscall.h> header file. */
+#undef HAVE_SYS_SYSCALL_H
+
+/* Define if you have the <sys/termio.h> header file. */
+#undef HAVE_SYS_TERMIO_H
+
+/* Define if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define if you have the <syscall.h> header file. */
+#undef HAVE_SYSCALL_H
+
+/* Define if you have the <termio.h> header file. */
+#undef HAVE_TERMIO_H
+
+/* Define if you have the <termios.h> header file. */
+#undef HAVE_TERMIOS_H
diff --git a/mit-pthreads/config/config.sub b/mit-pthreads/config/config.sub
new file mode 100755
index 00000000000..7a0c7855a2a
--- /dev/null
+++ b/mit-pthreads/config/config.sub
@@ -0,0 +1,794 @@
+#!/bin/sh
+# Configuration validation subroutine script, version 1.1.
+# Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine. It does not imply ALL GNU software can.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support. The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+# First pass through any local machine types.
+case $1 in
+ *local*)
+ echo $1
+ exit 0
+ ;;
+ *)
+ ;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS (if any).
+basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+if [ $basic_machine != $1 ]
+then os=`echo $1 | sed 's/.*-/-/'`
+else os=; fi
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work. We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+ -sun*os*)
+ # Prevent following clause from handling this invalid input.
+ ;;
+ -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp )
+ os=
+ basic_machine=$1
+ ;;
+ -hiux*)
+ os=-hiuxwe2
+ ;;
+ -sco4)
+ os=-sco3.2v4
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'`
+ ;;
+ -sco3.2.[4-9]*)
+ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'`
+ ;;
+ -sco3.2v[4-9]*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'`
+ ;;
+ -sco*)
+ os=-sco3.2v2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'`
+ ;;
+ -isc)
+ os=-isc2.2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'`
+ ;;
+ -clix*)
+ basic_machine=clipper-intergraph
+ ;;
+ -isc*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'`
+ ;;
+ -lynx)
+ os=-lynxos
+ ;;
+ -ptx*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+ ;;
+ -windowsnt*)
+ os=`echo $os | sed -e 's/windowsnt/winnt/'`
+ ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+ # Recognize the basic CPU types without company name.
+ # Some are omitted here because they have special meanings below.
+ tahoe | i[3456]86 | i860 | m68k | m68000 | m88k | ns32k | arm | arm32 | pyramid \
+ | tron | a29k | 580 | i960 | h8300 | hppa1.0 | hppa1.1 \
+ | alpha | we32k | ns16k | clipper | sparclite | i370 | sh \
+ | powerpc | sparc64 | 1750a | dsp16xx | mips64 | mipsel \
+ | pdp11 | mips64el | mips64orion | mips64orionel )
+ basic_machine=$basic_machine-unknown
+ ;;
+ # Object if more than one company name word.
+ *-*-*)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+ # Recognize the basic CPU types with company name.
+ vax-* | tahoe-* | i[3456]86-* | i860-* | m68k-* | m68000-* | m88k-* \
+ | sparc-* | ns32k-* | fx80-* | arm-* | arm32-* | c[123]* \
+ | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
+ | none-* | 580-* | cray2-* | h8300-* | i960-* | xmp-* | ymp-* \
+ | hppa1.0-* | hppa1.1-* | alpha-* | we32k-* | cydra-* | ns16k-* \
+ | pn-* | np1-* | xps100-* | clipper-* | orion-* | sparclite-* \
+ | pdp11-* | sh-* | powerpc-* | sparc64-* | mips64-* | mipsel-* \
+ | mips64el-* | mips64orion-* | mips64orionel-* )
+ ;;
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+ basic_machine=m68000-att
+ ;;
+ 3b*)
+ basic_machine=we32k-att
+ ;;
+ alliant | fx80)
+ basic_machine=fx80-alliant
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ os=-bsd
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ os=-sysv
+ ;;
+ amiga | amiga-*)
+ basic_machine=m68k-cbm
+ ;;
+ amigados)
+ basic_machine=m68k-cbm
+ os=-amigados
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-cbm
+ os=-sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ os=-sysv
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ os=-dynix
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ os=-bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ os=-bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ os=-bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ os=-bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ os=-bsd
+ ;;
+ cray | ymp)
+ basic_machine=ymp-cray
+ os=-unicos
+ ;;
+ cray2)
+ basic_machine=cray2-cray
+ os=-unicos
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
+ da30 | da30-*)
+ basic_machine=m68k-da30
+ ;;
+ decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ ;;
+ delta | 3300 | motorola-3300 | motorola-delta \
+ | 3300-motorola | delta-motorola)
+ basic_machine=m68k-motorola
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ os=-sysv3
+ ;;
+ dpx20 | dpx20-*)
+ basic_machine=rs6000-bull
+ os=-bosx
+ ;;
+ dpx2* | dpx2*-bull)
+ basic_machine=m68k-bull
+ os=-sysv3
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ os=-ebmon
+ ;;
+ elxsi)
+ basic_machine=elxsi-elxsi
+ os=-bsd
+ ;;
+ encore | umax | mmax)
+ basic_machine=ns32k-encore
+ ;;
+ fx2800)
+ basic_machine=i860-alliant
+ ;;
+ genix)
+ basic_machine=ns32k-ns
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ os=-sysv
+ ;;
+ h3050r* | hiux*)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ os=-hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ os=-sysv3
+ ;;
+ hp300-*)
+ basic_machine=m68k-hp
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ os=-bsd
+ ;;
+ hp300hpux)
+ basic_machine=m68k-hp
+ os=-hpux
+ ;;
+ hp9k2[0-9][0-9] | hp9k31[0-9])
+ basic_machine=m68000-hp
+ ;;
+ hp9k3[2-9][0-9])
+ basic_machine=m68k-hp
+ ;;
+ hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7)
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ i370-ibm* | ibm*)
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
+# I'm not sure what "Sysv32" means. Should this be sysv3.2?
+ i[3456]86v32)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'`
+ os=-sysv32
+ ;;
+ i[3456]86v4*)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'`
+ os=-sysv4
+ ;;
+ i[3456]86v)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'`
+ os=-sysv
+ ;;
+ i[3456]86sol2)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'`
+ os=-solaris2
+ ;;
+ iris | iris4d)
+ basic_machine=mips-sgi
+ case $os in
+ -irix*)
+ ;;
+ *)
+ os=-irix4
+ ;;
+ esac
+ ;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ os=-sysv
+ ;;
+ m88k-omron*)
+ basic_machine=m88k-omron
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ os=-sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ os=-sysv
+ ;;
+ miniframe)
+ basic_machine=m68000-convergent
+ ;;
+ mips3*-*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+ ;;
+ mips3*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ os=-sysv4
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ os=-newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ os=-newsos
+ ;;
+ news-3600 | risc-news)
+ basic_machine=mips-sony
+ os=-newsos
+ ;;
+ next | m*-next )
+ basic_machine=m68k-next
+ case $os in
+ -nextstep* )
+ ;;
+ -ns2*)
+ os=-nextstep2
+ ;;
+ *)
+ os=-nextstep3
+ ;;
+ esac
+ ;;
+ nh3000)
+ basic_machine=m68k-harris
+ os=-cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ os=-cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ os=-nindy
+ ;;
+ np1)
+ basic_machine=np1-gould
+ ;;
+ pa-hitachi)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ os=-osf
+ ;;
+ pbd)
+ basic_machine=sparc-tti
+ ;;
+ pbb)
+ basic_machine=m68k-tti
+ ;;
+ pc532 | pc532-*)
+ basic_machine=ns32k-pc532
+ ;;
+ pentium-*)
+ # We will change tis to say i586 once there has been
+ # time for various packages to start to recognize that.
+ basic_machine=i486-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pn)
+ basic_machine=pn-gould
+ ;;
+ ps2)
+ basic_machine=i386-ibm
+ ;;
+ rtpc | rtpc-*)
+ basic_machine=romp-ibm
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ ;;
+ sh)
+ basic_machine=sh-hitachi
+ os=-hms
+ ;;
+ sps7)
+ basic_machine=m68k-bull
+ os=-sysv2
+ ;;
+ spur)
+ basic_machine=spur-unknown
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ ;;
+ sun2os3)
+ basic_machine=m68000-sun
+ os=-sunos3
+ ;;
+ sun2os4)
+ basic_machine=m68000-sun
+ os=-sunos4
+ ;;
+ sun3os3)
+ basic_machine=m68k-sun
+ os=-sunos3
+ ;;
+ sun3os4)
+ basic_machine=m68k-sun
+ os=-sunos4
+ ;;
+ sun4os3)
+ basic_machine=sparc-sun
+ os=-sunos3
+ ;;
+ sun4os4)
+ basic_machine=sparc-sun
+ os=-sunos4
+ ;;
+ sun3 | sun3-*)
+ basic_machine=m68k-sun
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ ;;
+ symmetry)
+ basic_machine=i386-sequent
+ os=-dynix
+ ;;
+ tower | tower-32)
+ basic_machine=m68k-ncr
+ ;;
+ ultra3)
+ basic_machine=a29k-nyu
+ os=-sym1
+ ;;
+ vaxv)
+ basic_machine=vax-dec
+ os=-sysv
+ ;;
+ vms)
+ basic_machine=vax-dec
+ os=-vms
+ ;;
+ vxworks960)
+ basic_machine=i960-wrs
+ os=-vxworks
+ ;;
+ vxworks68)
+ basic_machine=m68k-wrs
+ os=-vxworks
+ ;;
+ xmp)
+ basic_machine=xmp-cray
+ os=-unicos
+ ;;
+ xps | xps100)
+ basic_machine=xps100-honeywell
+ ;;
+ none)
+ basic_machine=none-none
+ os=-none
+ ;;
+
+# Here we handle the default manufacturer of certain CPU types. It is in
+# some cases the only manufacturer, in others, it is the most popular.
+ mips)
+ basic_machine=mips-mips
+ ;;
+ romp)
+ basic_machine=romp-ibm
+ ;;
+ rs6000)
+ basic_machine=rs6000-ibm
+ ;;
+ vax)
+ basic_machine=vax-dec
+ ;;
+ pdp11)
+ basic_machine=pdp11-dec
+ ;;
+ we32k)
+ basic_machine=we32k-att
+ ;;
+ sparc)
+ basic_machine=sparc-sun
+ ;;
+ cydra)
+ basic_machine=cydra-cydrome
+ ;;
+ orion)
+ basic_machine=orion-highlevel
+ ;;
+ orion105)
+ basic_machine=clipper-highlevel
+ ;;
+ *)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+ *-digital*)
+ basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+ ;;
+ *-commodore*)
+ basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+ ;;
+ *)
+ ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+ # -solaris* is a basic system type, with this one exception.
+ -solaris1 | -solaris1.*)
+ os=`echo $os | sed -e 's|solaris1|sunos4|'`
+ ;;
+ -solaris)
+ os=-solaris2
+ ;;
+ -gnu/linux*)
+ os=`echo $os | sed -e 's|gnu/linux|linux|'`
+ ;;
+ # First accept the basic system types.
+ # The portable systems comes first.
+ # Each alternative must end in a *, to match a version number.
+ # -sysv* is not here because it comes later, after sysvr4.
+ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+ | -vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[3456]* \
+ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+ | -amigados* | -msdos* | -newsos* | -unicos* | -aos* \
+ | -nindy* | -vxworks* | -ebmon* | -hms* | -mvs* | -clix* \
+ | -riscos* | -linux* | -uniplus* | -iris* | -rtu* | -xenix* \
+ | -hiux* | -386bsd* | -netbsd* | -freebsd* | -openbsd* \
+ |-riscix* \
+ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \
+ | -ptx* | -coff* | -winnt*)
+ ;;
+ -sunos5*)
+ os=`echo $os | sed -e 's|sunos5|solaris2|'`
+ ;;
+ -sunos6*)
+ os=`echo $os | sed -e 's|sunos6|solaris3|'`
+ ;;
+ -osfrose*)
+ os=-osfrose
+ ;;
+ -osf*)
+ os=-osf
+ ;;
+ -utek*)
+ os=-bsd
+ ;;
+ -dynix*)
+ os=-bsd
+ ;;
+ -acis*)
+ os=-aos
+ ;;
+ -ctix* | -uts*)
+ os=-sysv
+ ;;
+ -triton*)
+ os=-sysv3
+ ;;
+ -oss*)
+ os=-sysv3
+ ;;
+ -svr4)
+ os=-sysv4
+ ;;
+ -svr3)
+ os=-sysv3
+ ;;
+ -sysvr4)
+ os=-sysv4
+ ;;
+ # This must come after -sysvr4.
+ -sysv*)
+ ;;
+ -xenix)
+ os=-xenix
+ ;;
+ -none)
+ ;;
+ *)
+ # Get rid of the `-' at the beginning of $os.
+ os=`echo $os | sed 's/[^-]*-//'`
+ echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system. Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+ *-acorn)
+ os=-riscix1.2
+ ;;
+ pdp11-*)
+ os=-none
+ ;;
+ *-dec | vax-*)
+ os=-ultrix4.2
+ ;;
+ i386-sun)
+ os=-sunos4.0.2
+ ;;
+ m68000-sun)
+ os=-sunos3
+ # This also exists in the configure program, but was not the
+ # default.
+ # os=-sunos4
+ ;;
+ *-tti) # must be before sparc entry or we get the wrong os.
+ os=-sysv3
+ ;;
+ sparc-* | *-sun)
+ os=-sunos4.1.1
+ ;;
+ *-ibm)
+ os=-aix
+ ;;
+ *-hp)
+ os=-hpux
+ ;;
+ *-hitachi)
+ os=-hiux
+ ;;
+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+ os=-sysv
+ ;;
+ *-cbm)
+ os=-amigados
+ ;;
+ *-dg)
+ os=-dgux
+ ;;
+ *-dolphin)
+ os=-sysv3
+ ;;
+ m68k-ccur)
+ os=-rtu
+ ;;
+ m88k-omron*)
+ os=-luna
+ ;;
+ *-sequent)
+ os=-ptx
+ ;;
+ *-crds)
+ os=-unos
+ ;;
+ *-ns)
+ os=-genix
+ ;;
+ i370-*)
+ os=-mvs
+ ;;
+ *-next)
+ os=-nextstep3
+ ;;
+ *-gould)
+ os=-sysv
+ ;;
+ *-highlevel)
+ os=-bsd
+ ;;
+ *-encore)
+ os=-bsd
+ ;;
+ *-sgi)
+ os=-irix
+ ;;
+ *-masscomp)
+ os=-rtu
+ ;;
+ *)
+ os=-none
+ ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer. We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+ *-unknown)
+ case $os in
+ -riscix*)
+ vendor=acorn
+ ;;
+ -sunos*)
+ vendor=sun
+ ;;
+ -lynxos*)
+ vendor=lynx
+ ;;
+ -aix*)
+ vendor=ibm
+ ;;
+ -hpux*)
+ vendor=hp
+ ;;
+ -hiux*)
+ vendor=hitachi
+ ;;
+ -unos*)
+ vendor=crds
+ ;;
+ -dgux*)
+ vendor=dg
+ ;;
+ -luna*)
+ vendor=omron
+ ;;
+ -genix*)
+ vendor=ns
+ ;;
+ -mvs*)
+ vendor=ibm
+ ;;
+ -ptx*)
+ vendor=sequent
+ ;;
+ esac
+ basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+ ;;
+esac
+
+echo $basic_machine$os
diff --git a/mit-pthreads/config/configure b/mit-pthreads/config/configure
new file mode 100755
index 00000000000..ab781193cae
--- /dev/null
+++ b/mit-pthreads/config/configure
@@ -0,0 +1,3330 @@
+#! /bin/sh
+
+# Guess values for system-dependent variables and create Makefiles.
+# Generated automatically using autoconf version 2.13
+# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+
+# Defaults:
+ac_help=
+ac_default_prefix=/usr/local
+# Any additions from configure.in:
+ac_help="$ac_help
+--enable-dce-compat DCE compatibility"
+ac_default_prefix=/usr/local/pthreads
+
+# Initialize some variables set by options.
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+build=NONE
+cache_file=./config.cache
+exec_prefix=NONE
+host=NONE
+no_create=
+nonopt=NONE
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+target=NONE
+verbose=
+x_includes=NONE
+x_libraries=NONE
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+# Initialize some other variables.
+subdirs=
+MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+# Maximum number of lines to put in a shell here document.
+ac_max_here_lines=12
+
+ac_prev=
+for ac_option
+do
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+ ac_prev=
+ continue
+ fi
+
+ case "$ac_option" in
+ -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) ac_optarg= ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case "$ac_option" in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir="$ac_optarg" ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build="$ac_optarg" ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file="$ac_optarg" ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+ datadir="$ac_optarg" ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ eval "enable_${ac_feature}=no" ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "enable_${ac_feature}='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix="$ac_optarg" ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he)
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat << EOF
+Usage: configure [options] [host]
+Options: [defaults in brackets after descriptions]
+Configuration:
+ --cache-file=FILE cache test results in FILE
+ --help print this message
+ --no-create do not create output files
+ --quiet, --silent do not print \`checking...' messages
+ --version print the version of autoconf that created configure
+Directory and file names:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [same as prefix]
+ --bindir=DIR user executables in DIR [EPREFIX/bin]
+ --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
+ --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
+ --datadir=DIR read-only architecture-independent data in DIR
+ [PREFIX/share]
+ --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data in DIR
+ [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
+ --libdir=DIR object code libraries in DIR [EPREFIX/lib]
+ --includedir=DIR C header files in DIR [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
+ --infodir=DIR info documentation in DIR [PREFIX/info]
+ --mandir=DIR man documentation in DIR [PREFIX/man]
+ --srcdir=DIR find the sources in DIR [configure dir or ..]
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM
+ run sed PROGRAM on installed program names
+EOF
+ cat << EOF
+Host type:
+ --build=BUILD configure for building on BUILD [BUILD=HOST]
+ --host=HOST configure for HOST [guessed]
+ --target=TARGET configure for TARGET [TARGET=HOST]
+Features and packages:
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --x-includes=DIR X include files are in DIR
+ --x-libraries=DIR X library files are in DIR
+EOF
+ if test -n "$ac_help"; then
+ echo "--enable and --with options recognized:$ac_help"
+ fi
+ exit 0 ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host="$ac_optarg" ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir="$ac_optarg" ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir="$ac_optarg" ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir="$ac_optarg" ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir="$ac_optarg" ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+ | --locals | --local | --loca | --loc | --lo)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+ localstatedir="$ac_optarg" ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir="$ac_optarg" ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir="$ac_optarg" ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix="$ac_optarg" ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix="$ac_optarg" ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix="$ac_optarg" ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name="$ac_optarg" ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir="$ac_optarg" ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir="$ac_optarg" ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site="$ac_optarg" ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir="$ac_optarg" ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir="$ac_optarg" ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target="$ac_optarg" ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers)
+ echo "configure generated by autoconf version 2.13"
+ exit 0 ;;
+
+ -with-* | --with-*)
+ ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "with_${ac_package}='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+ ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ eval "with_${ac_package}=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes="$ac_optarg" ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries="$ac_optarg" ;;
+
+ -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
+ ;;
+
+ *)
+ if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+ echo "configure: warning: $ac_option: invalid host type" 1>&2
+ fi
+ if test "x$nonopt" != xNONE; then
+ { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
+ fi
+ nonopt="$ac_option"
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
+fi
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+# File descriptor usage:
+# 0 standard input
+# 1 file creation
+# 2 errors and warnings
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 6 checking for... messages and results
+# 5 compiler messages saved in config.log
+if test "$silent" = yes; then
+ exec 6>/dev/null
+else
+ exec 6>&1
+fi
+exec 5>./config.log
+
+echo "\
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+" 1>&5
+
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Also quote any args containing shell metacharacters.
+ac_configure_args=
+for ac_arg
+do
+ case "$ac_arg" in
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c) ;;
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+ ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ *) ac_configure_args="$ac_configure_args $ac_arg" ;;
+ esac
+done
+
+# NLS nuisances.
+# Only set these to C if already set. These must not be set unconditionally
+# because not all systems understand e.g. LANG=C (notably SCO).
+# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
+# Non-C LC_CTYPE values break the ctype check.
+if test "${LANG+set}" = set; then LANG=C; export LANG; fi
+if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
+if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo > confdefs.h
+
+# A filename unique to this package, relative to the directory that
+# configure is in, which we can look for to find out if srcdir is correct.
+ac_unique_file=config.flags.in
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+ ac_prog=$0
+ ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+ test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+ { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
+ else
+ { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
+ fi
+fi
+srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
+
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+ else
+ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+ fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+ echo "loading site script $ac_site_file"
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ echo "loading cache $cache_file"
+ . $cache_file
+else
+ echo "creating cache $cache_file"
+ > $cache_file
+fi
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+ac_exeext=
+ac_objext=o
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+ # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+ if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+ ac_n= ac_c='
+' ac_t=' '
+ else
+ ac_n=-n ac_c= ac_t=
+ fi
+else
+ ac_n= ac_c='\c' ac_t=
+fi
+
+
+# Check whether --enable-dce-compat or --disable-dce-compat was given.
+if test "${enable_dce_compat+set}" = set; then
+ enableval="$enable_dce_compat"
+ { echo "configure: error: Actually, DCE compatibility doesn't work yet..." 1>&2; exit 1; }
+
+else
+ true
+
+fi
+
+
+# Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:542: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="gcc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:572: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_prog_rejected=no
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# -gt 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ set dummy "$ac_dir/$ac_word" "$@"
+ shift
+ ac_cv_prog_CC="$@"
+ fi
+fi
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ if test -z "$CC"; then
+ case "`uname -s`" in
+ *win32* | *WIN32*)
+ # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:623: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="cl"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+ ;;
+ esac
+ fi
+ test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+echo "configure:655: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+cat > conftest.$ac_ext << EOF
+
+#line 666 "configure"
+#include "confdefs.h"
+
+main(){return(0);}
+EOF
+if { (eval echo configure:671: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ ac_cv_prog_cc_works=yes
+ # If we can't run a trivial program, we are probably using a cross compiler.
+ if (./conftest; exit) 2>/dev/null; then
+ ac_cv_prog_cc_cross=no
+ else
+ ac_cv_prog_cc_cross=yes
+ fi
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ ac_cv_prog_cc_works=no
+fi
+rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
+if test $ac_cv_prog_cc_works = no; then
+ { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
+fi
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+echo "configure:697: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+echo "configure:702: checking whether we are using GNU C" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.c <<EOF
+#ifdef __GNUC__
+ yes;
+#endif
+EOF
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:711: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+ ac_cv_prog_gcc=yes
+else
+ ac_cv_prog_gcc=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gcc" 1>&6
+
+if test $ac_cv_prog_gcc = yes; then
+ GCC=yes
+else
+ GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:730: checking whether ${CC-cc} accepts -g" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ echo 'void f(){}' > conftest.c
+if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
+ ac_cv_prog_cc_g=yes
+else
+ ac_cv_prog_cc_g=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+
+for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl
+do
+# Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:766: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CXX"; then
+ ac_cv_prog_CXX="$CXX" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CXX="$ac_prog"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CXX="$ac_cv_prog_CXX"
+if test -n "$CXX"; then
+ echo "$ac_t""$CXX" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+test -n "$CXX" && break
+done
+test -n "$CXX" || CXX="gcc"
+
+
+echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+echo "configure:798: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
+
+ac_ext=C
+# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cxx_cross
+
+cat > conftest.$ac_ext << EOF
+
+#line 809 "configure"
+#include "confdefs.h"
+
+int main(){return(0);}
+EOF
+if { (eval echo configure:814: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ ac_cv_prog_cxx_works=yes
+ # If we can't run a trivial program, we are probably using a cross compiler.
+ if (./conftest; exit) 2>/dev/null; then
+ ac_cv_prog_cxx_cross=no
+ else
+ ac_cv_prog_cxx_cross=yes
+ fi
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ ac_cv_prog_cxx_works=no
+fi
+rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo "$ac_t""$ac_cv_prog_cxx_works" 1>&6
+if test $ac_cv_prog_cxx_works = no; then
+ { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; }
+fi
+echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+echo "configure:840: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6
+cross_compiling=$ac_cv_prog_cxx_cross
+
+echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6
+echo "configure:845: checking whether we are using GNU C++" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.C <<EOF
+#ifdef __GNUC__
+ yes;
+#endif
+EOF
+if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:854: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+ ac_cv_prog_gxx=yes
+else
+ ac_cv_prog_gxx=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gxx" 1>&6
+
+if test $ac_cv_prog_gxx = yes; then
+ GXX=yes
+else
+ GXX=
+fi
+
+ac_test_CXXFLAGS="${CXXFLAGS+set}"
+ac_save_CXXFLAGS="$CXXFLAGS"
+CXXFLAGS=
+echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6
+echo "configure:873: checking whether ${CXX-g++} accepts -g" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ echo 'void f(){}' > conftest.cc
+if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then
+ ac_cv_prog_cxx_g=yes
+else
+ ac_cv_prog_cxx_g=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_prog_cxx_g" 1>&6
+if test "$ac_test_CXXFLAGS" = set; then
+ CXXFLAGS="$ac_save_CXXFLAGS"
+elif test $ac_cv_prog_cxx_g = yes; then
+ if test "$GXX" = yes; then
+ CXXFLAGS="-g -O2"
+ else
+ CXXFLAGS="-g"
+ fi
+else
+ if test "$GXX" = yes; then
+ CXXFLAGS="-O2"
+ else
+ CXXFLAGS=
+ fi
+fi
+
+echo $ac_n "checking compiler availability and simple error detection""... $ac_c" 1>&6
+echo "configure:905: checking compiler availability and simple error detection" >&5
+cat > conftest.$ac_ext <<EOF
+#line 907 "configure"
+#include "confdefs.h"
+
+int main() {
+ exit(0);
+; return 0; }
+EOF
+if { (eval echo configure:914: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+
+ cat > conftest.$ac_ext <<EOF
+#line 918 "configure"
+#include "confdefs.h"
+
+int main() {
+ syntax errors galore!
+; return 0; }
+EOF
+if { (eval echo configure:925: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ { echo "configure: error: Can't detect syntax errors! Is CC set right?" 1>&2; exit 1; }
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ true
+fi
+rm -f conftest*
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ { echo "configure: error: Can't compile test program! Is CC set right?" 1>&2; exit 1; }
+fi
+rm -f conftest*
+
+cat > conftest.$ac_ext <<EOF
+#line 944 "configure"
+#include "confdefs.h"
+
+int main() {
+
+ typedef int Integer;
+ extern int i;
+ extern Integer i;
+
+; return 0; }
+EOF
+if { (eval echo configure:955: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ :
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ { echo "configure: error: Can't redeclare variables with this compiler??" 1>&2; exit 1; }
+fi
+rm -f conftest*
+cat > conftest.$ac_ext <<EOF
+#line 965 "configure"
+#include "confdefs.h"
+
+int main() {
+
+ typedef long Long;
+ extern int i;
+ extern Long i;
+
+; return 0; }
+EOF
+if { (eval echo configure:976: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ { echo "configure: error: Compiler doesn't detect conflicting declarations." 1>&2; exit 1; }
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+echo "$ac_t""ok" 1>&6
+
+if test $ac_cv_prog_gcc = yes ; then
+ CFLAGS="$CFLAGS -Werror"
+fi
+
+echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+echo "configure:991: checking how to run the C preprocessor" >&5
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ # This must be in double quotes, not single quotes, because CPP may get
+ # substituted into the Makefile and "${CC-cc}" will confuse make.
+ CPP="${CC-cc} -E"
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp.
+ cat > conftest.$ac_ext <<EOF
+#line 1006 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1012: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -E -traditional-cpp"
+ cat > conftest.$ac_ext <<EOF
+#line 1023 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1029: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -nologo -E"
+ cat > conftest.$ac_ext <<EOF
+#line 1040 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1046: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP=/lib/cpp
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+ ac_cv_prog_CPP="$CPP"
+fi
+ CPP="$ac_cv_prog_CPP"
+else
+ ac_cv_prog_CPP="$CPP"
+fi
+echo "$ac_t""$CPP" 1>&6
+
+
+# Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1074: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_RANLIB="ranlib"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
+fi
+fi
+RANLIB="$ac_cv_prog_RANLIB"
+if test -n "$RANLIB"; then
+ echo "$ac_t""$RANLIB" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+
+
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+ if test -f $ac_dir/install-sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f $ac_dir/install.sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
+fi
+ac_config_guess=$ac_aux_dir/config.guess
+ac_config_sub=$ac_aux_dir/config.sub
+ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+
+
+# Do some error checking and defaulting for the host and target type.
+# The inputs are:
+# configure --host=HOST --target=TARGET --build=BUILD NONOPT
+#
+# The rules are:
+# 1. You are not allowed to specify --host, --target, and nonopt at the
+# same time.
+# 2. Host defaults to nonopt.
+# 3. If nonopt is not specified, then host defaults to the current host,
+# as determined by config.guess.
+# 4. Target and build default to nonopt.
+# 5. If nonopt is not specified, then target and build default to host.
+
+# The aliases save the names the user supplied, while $host etc.
+# will get canonicalized.
+case $host---$target---$nonopt in
+NONE---*---* | *---NONE---* | *---*---NONE) ;;
+*) { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } ;;
+esac
+
+
+# Make sure we can run config.sub.
+if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
+else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking host system type""... $ac_c" 1>&6
+echo "configure:1151: checking host system type" >&5
+
+host_alias=$host
+case "$host_alias" in
+NONE)
+ case $nonopt in
+ NONE)
+ if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then :
+ else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
+ fi ;;
+ *) host_alias=$nonopt ;;
+ esac ;;
+esac
+
+host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias`
+host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+echo "$ac_t""$host" 1>&6
+
+echo $ac_n "checking target system type""... $ac_c" 1>&6
+echo "configure:1172: checking target system type" >&5
+
+target_alias=$target
+case "$target_alias" in
+NONE)
+ case $nonopt in
+ NONE) target_alias=$host_alias ;;
+ *) target_alias=$nonopt ;;
+ esac ;;
+esac
+
+target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias`
+target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+echo "$ac_t""$target" 1>&6
+
+echo $ac_n "checking build system type""... $ac_c" 1>&6
+echo "configure:1190: checking build system type" >&5
+
+build_alias=$build
+case "$build_alias" in
+NONE)
+ case $nonopt in
+ NONE) build_alias=$host_alias ;;
+ *) build_alias=$nonopt ;;
+ esac ;;
+esac
+
+build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias`
+build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+echo "$ac_t""$build" 1>&6
+
+test "$host_alias" != "$target_alias" &&
+ test "$program_prefix$program_suffix$program_transform_name" = \
+ NONENONEs,x,x, &&
+ program_prefix=${target_alias}-
+
+
+syscall=NONE
+sysincludes=NONE
+extraincludes=NONE
+
+# Treat all x86 machines the same.
+# (Yet below, we pretend we can distinguish between the MIPS r2000 and r4000?)
+# (What about 680x0 machines?)
+case $host in
+ i[456]86-*)
+ host=`echo $host | sed 's/^i[456]86/i386/'`
+ host_cpu=i386
+ ;;
+esac
+
+# Here, you should set the following variables:
+# name
+# The "name" of this configuration. Used for "engine-*.c" file name,
+# default for syscall file names. Chris seems to have a thing for
+# putting "-" between OS and version number, but the configure script
+# will already have $host_cpu and $host_os available for you to use
+# in constructing a name.
+# sysincludes
+# Name of machdep directory with "sys" include file
+# replacements, if any. This directory is optional;
+# if you don't provide it, don't set this variable.
+# except
+# Names of any syscalls that shouldn't be generated
+# from the template, if any.
+# syscall
+# Base name of the syscall template files, if not the
+# same as <name>. If they're the same, omit this.
+#
+# Also, you may define random symbols and update CFLAGS if
+# necessary. However, for ease of porting to new machines,
+# it's best if you can create portable autoconf tests for
+# whatever you're trying to do, rather than hard-coding it
+# here based on the OS name. So please, try to keep this
+# section as minimal as possible.
+
+except=""
+name=$host_cpu-$host_os
+
+case $host in
+ alpha-*-netbsd1.3[H-Z]|alpha-*-netbsd1.4*)
+ name=alpha-netbsd-1.3
+ sysincludes=netbsd-1.1
+ except="fork lseek pipe fstat"
+ available_syscalls="sigsuspend sigprocmask"
+ ;;
+ alpha-*-netbsd1.3*)
+ name=alpha-netbsd-1.3
+ sysincludes=netbsd-1.1
+ except="fork lseek pipe sigsuspend sigprocmask fstat"
+ ;;
+ alpha-*-netbsd1.1* | alpha-*-netbsd1.2*)
+ name=alpha-netbsd-1.1
+ sysincludes=netbsd-1.1
+ except="fork lseek pipe sigsuspend sigprocmask"
+ ;;
+ alpha-*-osf*)
+ name=alpha-osf1
+ sysincludes=alpha-osf1
+ except="fork sigsuspend"
+ if test $ac_cv_prog_gcc = no ; then
+ CFLAGS="$CFLAGS -std"
+ fi
+ ;;
+ arm32-*-netbsd1.3[H-Z]|arm32-*-netbsd1.4*)
+ name=arm32-netbsd-1.3
+ sysincludes=netbsd-1.1
+ except="fork pipe lseek ftruncate fstat"
+ available_syscalls="sigsuspend sigprocmask"
+ ;;
+ arm32-*-netbsd1.3*)
+ name=arm32-netbsd-1.3
+ sysincludes=netbsd-1.1
+ except="fork pipe lseek ftruncate sigsuspend sigprocmask fstat"
+ ;;
+ hppa1.0-*-hpux10.20 | hppa1.1-*-hpux10.20)
+ name=hppa-hpux-10.20
+ sysincludes=hpux-10.20
+ except="fork"
+ ;;
+ hppa1.1-*-hpux*9.*)
+ name=hppa-hpux-9.03
+ sysincludes=hpux-9.03
+ # hpux-9.03.mk seems to be missing; what should this be?
+ except="fork"
+ ;;
+ sparc-*-sunos4.1.3* | sparc-*-sunos4.1.4*)
+ name=sparc-sunos-4.1.3
+ sysincludes=sunos-4.1.3
+ syscall=sparc-sunos4
+ except="fork pipe getpgrp getdirentries"
+ cat >> confdefs.h <<\EOF
+#define sunos4 1
+EOF
+ # is this really needed??
+ ;;
+ sparc-*-solaris2.3* | sparc-*-solaris2.4*)
+ name=sparc-sunos-5.3
+ sysincludes=sunos-5.3
+ except="fork sigaction"
+ # Should really come up with a test for this...
+ cat >> confdefs.h <<\EOF
+#define LD_LINKS_STATIC_DATA 1
+EOF
+
+ cat >> confdefs.h <<\EOF
+#define BROKEN_SIGNALS 1
+EOF
+
+ ;;
+ sparc-*-solaris2*)
+ name=sparc-sunos-5.3
+ sysincludes=sunos-5.5
+ except="fork sigaction"
+ # Should really come up with a test for this...
+ cat >> confdefs.h <<\EOF
+#define LD_LINKS_STATIC_DATA 1
+EOF
+
+ cat >> confdefs.h <<\EOF
+#define BROKEN_SIGNALS 1
+EOF
+
+ ;;
+ sparc-*-netbsd1.3[H-Z]|sparc-*-netbsd1.4*)
+ name=sparc-netbsd-1.3
+ sysincludes=netbsd-1.1
+ except="pipe fork lseek ftruncate fstat"
+ available_syscalls="sigprocmask sigsuspend"
+ ;;
+ sparc-*-netbsd1.3*)
+ name=sparc-netbsd-1.3
+ sysincludes=netbsd-1.1
+ except="pipe fork lseek ftruncate sigprocmask sigsuspend fstat"
+ ;;
+ sparc-*-netbsd1.0A | sparc-*-netbsd1.1* | sparc-*-netbsd1.2*)
+ name=sparc-sunos-4.1.3
+ sysincludes=netbsd-1.0
+ syscall=sparc-netbsd-1.1
+ except="pipe fork sigprocmask sigsuspend"
+ ;;
+ i386-*-openbsd2.*)
+ name=i386-openbsd-2.0
+ sysincludes=openbsd-2.0
+ except="fork lseek ftruncate sigsuspend sigprocmask"
+ ;;
+ i386-*-linux*)
+ #name=i386-linux-1.0
+ #sysincludes=linux-1.0
+ name=i386-linux-2.0
+ sysincludes=linux-2.0
+ extraincludes="bits"
+ ;;
+ i386-*-bsdi1.1)
+ name=i386-bsdi-1.1
+ sysincludes=bsdi-1.1
+ ;;
+ i386-*-bsdi2.0* | i386-*-bsdi2.1*)
+ name=i386-bsdi-2.0
+ sysincludes=bsdi-2.0
+ syscall=i386-bsdi-2.0
+ except="fork lseek ftruncate sigsuspend"
+ ;;
+ i386-*-netbsd1.3[H-Z]|i386-*-netbsd1.4*)
+ name=i386-netbsd-1.3
+ sysincludes=netbsd-1.1
+ except="fork lseek ftruncate pipe fstat"
+ available_syscalls="sigsuspend sigprocmask"
+ ;;
+ i386-*-netbsd1.3*)
+ name=i386-netbsd-1.3
+ sysincludes=netbsd-1.1
+ except="fork lseek ftruncate pipe sigsuspend sigprocmask fstat"
+ ;;
+ i386-*-netbsd1.1* | i386-*-netbsd1.2*)
+ name=i386-netbsd-1.0
+ sysincludes=netbsd-1.1
+ syscall=i386-netbsd-1.1
+ except="fork lseek ftruncate pipe sigsuspend sigprocmask"
+ ;;
+ i386-*-netbsd1.0*)
+ name=i386-netbsd-1.0
+ sysincludes=netbsd-1.0
+ except="fork lseek ftruncate sigsuspend"
+ ;;
+ i386-*-netbsd0.9*)
+ name=i386-netbsd-0.9
+ sysincludes=netbsd-0.9
+ ;;
+ m68*-*-netbsd*)
+ name=m68000-netbsd
+ sysincludes=netbsd-1.1
+ except="lseek ftruncate pipe fstat"
+ available_syscalls="sigsuspend sigprocmask"
+ ;;
+ i386-*-freebsd*)
+ name=i386-freebsd-2.0
+ sysincludes=freebsd-2.0
+ except="fork lseek ftruncate sigsuspend sigprocmask"
+ ;;
+ romp-*-bsd*)
+ name=romp-bsd
+ ;;
+ mips-dec-ultrix*)
+ name=r2000-ultrix-4.2
+ sysincludes=ultrix-4.2
+ except="fork pipe"
+ ;;
+ mips-sgi-irix*)
+ name=ip22-irix-5.2
+ sysincludes=irix-5.2
+ except="fstat stat"
+ cat >> confdefs.h <<\EOF
+#define BROKEN_SIGNALS 1
+EOF
+
+ ;;
+ i386-*-sco3.2v5*)
+ name=i386-sco3.2.5
+ sysincludes=i386-sco3.2.5
+ syscall=i386-sco3.2.5
+ except="select socketcall accept bind connect getpeername getsockname getsockopt setsockopt listen recv recvfrom recvmsg send sendmsg sendto shutdown socket socketpair fork fcntl dup2 fstat fchmod fchown ftruncate pipe getdirentries sigaction sigpause wait3 waitpid getdtablesize"
+ ;;
+ *)
+ { echo "configure: error: System type $host not recognized or not supported.
+See $srcdir/configure.in for supported systems." 1>&2; exit 1; }
+ exit 1
+ ;;
+esac
+
+SYSCALL_EXCEPTIONS=$except
+
+
+for ac_hdr in sys/termio.h termios.h termio.h alloc.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1453: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1458 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1463: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+ac_safe=`echo "va_list.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for va_list.h""... $ac_c" 1>&6
+echo "configure:1492: checking for va_list.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1497 "configure"
+#include "confdefs.h"
+#include <va_list.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1502: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ cat >> confdefs.h <<\EOF
+#define pthread_have_va_list_h 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+for ac_hdr in syscall.h sys/syscall.h sys/filio.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1531: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1536 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1541: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+pthreads_syscall_list="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 fstatfs chroot uname
+ sigsuspend sigaction sigpause sigprocmask ksigaction
+ getdents readdir getdirentries
+ wait4 wait3 waitpid waitsys
+ socket bind connect accept listen getsockopt setsockopt socketpair
+ poll putmsg getmsg
+ socketcall
+
+ pgrpsys
+
+ exit
+ readv writev send sendto sendmsg recv recvfrom recvmsg
+ getpeername getsockname
+ shutdown
+ getpgrp fork"
+for pthreads_syscallname in $pthreads_syscall_list ; do
+ echo $ac_n "checking for syscall $pthreads_syscallname""... $ac_c" 1>&6
+echo "configure:1587: checking for syscall $pthreads_syscallname" >&5
+if eval "test \"`echo '$''{'pthreads_cv_syscall_$pthreads_syscallname'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1592 "configure"
+#include "confdefs.h"
+
+/* FIXME: This list should be generated from info in configure.in. */
+#ifdef HAVE_SYSCALL_H
+#include <syscall.h>
+#else
+#ifdef HAVE_SYS_SYSCALL_H
+#include <sys/syscall.h>
+#else
+where is your syscall header file??
+#endif
+#endif
+
+int main() {
+
+int x;
+x = SYS_$pthreads_syscallname ;
+
+; return 0; }
+EOF
+if { (eval echo configure:1613: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval pthreads_cv_syscall_$pthreads_syscallname=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval pthreads_cv_syscall_$pthreads_syscallname=no
+fi
+rm -f conftest*
+fi
+
+if eval test \$pthreads_cv_syscall_$pthreads_syscallname = yes ; then
+ pthreads_syscall_present=yes
+ available_syscalls="$available_syscalls $pthreads_syscallname"
+ macroname=HAVE_SYSCALL_`echo $pthreads_syscallname | tr '[a-z]' '[A-Z]'`
+ cat >> confdefs.h <<EOF
+#define $macroname 1
+EOF
+
+else
+ pthreads_syscall_present=no
+ missing_syscalls="$missing_syscalls $pthreads_syscallname"
+fi
+echo "$ac_t""$pthreads_syscall_present" 1>&6
+
+done
+
+
+
+
+
+
+## Determine some typedef values from the system header files.
+echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
+echo "configure:1648: checking for ANSI C header files" >&5
+if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1653 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1661: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ ac_cv_header_stdc=yes
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 1678 "configure"
+#include "confdefs.h"
+#include <string.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "memchr" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 1696 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "free" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+if test "$cross_compiling" = yes; then
+ :
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1717 "configure"
+#include "confdefs.h"
+#include <ctype.h>
+#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int main () { int i; for (i = 0; i < 256; i++)
+if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
+exit (0); }
+
+EOF
+if { (eval echo configure:1728: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ :
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_header_stdc=no
+fi
+rm -fr conftest*
+fi
+
+fi
+fi
+
+echo "$ac_t""$ac_cv_header_stdc" 1>&6
+if test $ac_cv_header_stdc = yes; then
+ cat >> confdefs.h <<\EOF
+#define STDC_HEADERS 1
+EOF
+
+fi
+
+echo $ac_n "checking for off_t""... $ac_c" 1>&6
+echo "configure:1752: checking for off_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1757 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "(^|[^a-zA-Z_0-9])off_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_off_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_off_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_off_t" 1>&6
+if test $ac_cv_type_off_t = no; then
+ cat >> confdefs.h <<\EOF
+#define off_t long
+EOF
+
+fi
+
+echo $ac_n "checking for size_t""... $ac_c" 1>&6
+echo "configure:1785: checking for size_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1790 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_size_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_size_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_size_t" 1>&6
+if test $ac_cv_type_size_t = no; then
+ cat >> confdefs.h <<\EOF
+#define size_t unsigned
+EOF
+
+fi
+
+echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
+echo "configure:1818: checking return type of signal handlers" >&5
+if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1823 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <signal.h>
+#ifdef signal
+#undef signal
+#endif
+#ifdef __cplusplus
+extern "C" void (*signal (int, void (*)(int)))(int);
+#else
+void (*signal ()) ();
+#endif
+
+int main() {
+int i;
+; return 0; }
+EOF
+if { (eval echo configure:1840: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_type_signal=void
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_type_signal=int
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_type_signal" 1>&6
+cat >> confdefs.h <<EOF
+#define RETSIGTYPE $ac_cv_type_signal
+EOF
+
+
+echo $ac_n "checking for ssize_t""... $ac_c" 1>&6
+echo "configure:1859: checking for ssize_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_ssize_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1864 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "(^|[^a-zA-Z_0-9])ssize_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_ssize_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_ssize_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_ssize_t" 1>&6
+if test $ac_cv_type_ssize_t = no; then
+ cat >> confdefs.h <<\EOF
+#define ssize_t int
+EOF
+
+fi
+
+echo $ac_n "checking for time_t""... $ac_c" 1>&6
+echo "configure:1892: checking for time_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_time_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1897 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "(^|[^a-zA-Z_0-9])time_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_time_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_time_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_time_t" 1>&6
+if test $ac_cv_type_time_t = no; then
+ cat >> confdefs.h <<\EOF
+#define time_t long
+EOF
+
+fi
+
+for ac_hdr in sys/time.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1928: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1933 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1938: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
+echo "configure:1965: checking whether time.h and sys/time.h may both be included" >&5
+if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1970 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
+int main() {
+struct tm *tp;
+; return 0; }
+EOF
+if { (eval echo configure:1979: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_header_time=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_header_time=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_header_time" 1>&6
+if test $ac_cv_header_time = yes; then
+ cat >> confdefs.h <<\EOF
+#define TIME_WITH_SYS_TIME 1
+EOF
+
+fi
+
+
+echo $ac_n "checking for struct timespec in sys/time.h""... $ac_c" 1>&6
+echo "configure:2001: checking for struct timespec in sys/time.h" >&5
+if eval "test \"`echo '$''{'pthreads_cv_timespec_in_time'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2006 "configure"
+#include "confdefs.h"
+#include <sys/time.h>
+int main() {
+struct timespec foo;
+; return 0; }
+EOF
+if { (eval echo configure:2013: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ pthreads_cv_timespec_in_time=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ pthreads_cv_timespec_in_time=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$pthreads_cv_timespec_in_time" 1>&6
+if test $pthreads_cv_timespec_in_time = yes ; then
+ cat >> confdefs.h <<\EOF
+#define _OS_HAS_TIMESPEC 1
+EOF
+
+fi
+
+if eval "test \"`echo '$''{'pthreads_cv_socklen_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2037 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+int main() {
+socklen_t foo;
+; return 0; }
+EOF
+if { (eval echo configure:2045: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ pthreads_cv_socklen_t=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ pthreads_cv_socklen_t=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$pthreads_cv_socklen_t" 1>&6
+if test $pthreads_cv_socklen_t = yes ; then
+ cat >> confdefs.h <<\EOF
+#define _OS_HAS_SOCKLEN_T 1
+EOF
+
+fi
+
+
+
+echo $ac_n "checking type of size_t""... $ac_c" 1>&6
+echo "configure:2068: checking type of size_t" >&5
+if eval "test \"`echo '$''{'pthreads_cv_type_size_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2073 "configure"
+#include "confdefs.h"
+
+#include <stddef.h>
+#include <sys/types.h>
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif
+
+int main() {
+ extern size_t foo;
+; return 0; }
+EOF
+if { (eval echo configure:2086: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ for try_type in "int" "unsigned int" "long" "unsigned long" "short" "unsigned short" "char" "unsigned char" "long long" "unsigned long long" ; do
+ cat > conftest.$ac_ext <<EOF
+#line 2090 "configure"
+#include "confdefs.h"
+
+#include <stddef.h>
+#include <sys/types.h>
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif
+
+int main() {
+ extern size_t foo; extern $try_type foo;
+; return 0; }
+EOF
+if { (eval echo configure:2103: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ pthreads_cv_type_size_t="$try_type" ; break
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+ done
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ { echo "configure: error: Can't find system typedef for size_t." 1>&2; exit 1; }
+fi
+rm -f conftest*
+fi
+
+if test -n "$pthreads_cv_type_size_t" ; then
+ cat >> confdefs.h <<EOF
+#define pthread_size_t $pthreads_cv_type_size_t
+EOF
+
+fi
+pthread_size_t=$pthreads_cv_type_size_t
+echo "$ac_t""$pthreads_cv_type_size_t" 1>&6
+
+echo $ac_n "checking type of ssize_t""... $ac_c" 1>&6
+echo "configure:2131: checking type of ssize_t" >&5
+if eval "test \"`echo '$''{'pthreads_cv_type_ssize_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2136 "configure"
+#include "confdefs.h"
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int main() {
+ extern ssize_t foo;
+; return 0; }
+EOF
+if { (eval echo configure:2147: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ for try_type in "int" "unsigned int" "long" "unsigned long" "short" "unsigned short" "char" "unsigned char" "long long" "unsigned long long" ; do
+ cat > conftest.$ac_ext <<EOF
+#line 2151 "configure"
+#include "confdefs.h"
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int main() {
+ extern ssize_t foo; extern $try_type foo;
+; return 0; }
+EOF
+if { (eval echo configure:2162: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ pthreads_cv_type_ssize_t="$try_type" ; break
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+ done
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ { echo "configure: error: Can't find system typedef for ssize_t." 1>&2; exit 1; }
+fi
+rm -f conftest*
+fi
+
+if test -n "$pthreads_cv_type_ssize_t" ; then
+ cat >> confdefs.h <<EOF
+#define pthread_ssize_t $pthreads_cv_type_ssize_t
+EOF
+
+fi
+pthread_ssize_t=$pthreads_cv_type_ssize_t
+echo "$ac_t""$pthreads_cv_type_ssize_t" 1>&6
+
+echo $ac_n "checking type of clock_t""... $ac_c" 1>&6
+echo "configure:2190: checking type of clock_t" >&5
+if eval "test \"`echo '$''{'pthreads_cv_type_clock_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2195 "configure"
+#include "confdefs.h"
+
+#include <stddef.h>
+#if TIME_WITH_SYS_TIME
+# include <time.h>
+# include <sys/time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+int main() {
+ extern clock_t foo;
+; return 0; }
+EOF
+if { (eval echo configure:2214: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ for try_type in "int" "unsigned int" "long" "unsigned long" "short" "unsigned short" "char" "unsigned char" "long long" "unsigned long long" ; do
+ cat > conftest.$ac_ext <<EOF
+#line 2218 "configure"
+#include "confdefs.h"
+
+#include <stddef.h>
+#if TIME_WITH_SYS_TIME
+# include <time.h>
+# include <sys/time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+int main() {
+ extern clock_t foo; extern $try_type foo;
+; return 0; }
+EOF
+if { (eval echo configure:2237: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ pthreads_cv_type_clock_t="$try_type" ; break
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+ done
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ { echo "configure: error: Can't find system typedef for clock_t." 1>&2; exit 1; }
+fi
+rm -f conftest*
+fi
+
+if test -n "$pthreads_cv_type_clock_t" ; then
+ cat >> confdefs.h <<EOF
+#define pthread_clock_t $pthreads_cv_type_clock_t
+EOF
+
+fi
+pthread_clock_t=$pthreads_cv_type_clock_t
+echo "$ac_t""$pthreads_cv_type_clock_t" 1>&6
+
+echo $ac_n "checking type of time_t""... $ac_c" 1>&6
+echo "configure:2265: checking type of time_t" >&5
+if eval "test \"`echo '$''{'pthreads_cv_type_time_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2270 "configure"
+#include "confdefs.h"
+
+#include <stddef.h>
+#if TIME_WITH_SYS_TIME
+# include <time.h>
+# include <sys/time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+int main() {
+ extern time_t foo;
+; return 0; }
+EOF
+if { (eval echo configure:2289: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ for try_type in "int" "unsigned int" "long" "unsigned long" "short" "unsigned short" "char" "unsigned char" "long long" "unsigned long long" ; do
+ cat > conftest.$ac_ext <<EOF
+#line 2293 "configure"
+#include "confdefs.h"
+
+#include <stddef.h>
+#if TIME_WITH_SYS_TIME
+# include <time.h>
+# include <sys/time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+int main() {
+ extern time_t foo; extern $try_type foo;
+; return 0; }
+EOF
+if { (eval echo configure:2312: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ pthreads_cv_type_time_t="$try_type" ; break
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+ done
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ { echo "configure: error: Can't find system typedef for time_t." 1>&2; exit 1; }
+fi
+rm -f conftest*
+fi
+
+if test -n "$pthreads_cv_type_time_t" ; then
+ cat >> confdefs.h <<EOF
+#define pthread_time_t $pthreads_cv_type_time_t
+EOF
+
+fi
+pthread_time_t=$pthreads_cv_type_time_t
+echo "$ac_t""$pthreads_cv_type_time_t" 1>&6
+echo $ac_n "checking for fpos_t in stdio.h""... $ac_c" 1>&6
+echo "configure:2339: checking for fpos_t in stdio.h" >&5
+if eval "test \"`echo '$''{'pthreads_cv_fpos_t_in_stdio'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2344 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+int main() {
+fpos_t position;
+; return 0; }
+EOF
+if { (eval echo configure:2351: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ pthreads_cv_fpos_t_in_stdio=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ pthreads_cv_fpos_t_in_stdio=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$pthreads_cv_fpos_t_in_stdio" 1>&6
+if test $pthreads_cv_fpos_t_in_stdio = yes ; then
+
+echo $ac_n "checking type of fpos_t""... $ac_c" 1>&6
+echo "configure:2367: checking type of fpos_t" >&5
+if eval "test \"`echo '$''{'pthreads_cv_type_fpos_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2372 "configure"
+#include "confdefs.h"
+
+#include <stdio.h>
+#include <sys/types.h>
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif
+
+int main() {
+ extern fpos_t foo;
+; return 0; }
+EOF
+if { (eval echo configure:2385: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ for try_type in "int" "unsigned int" "long" "unsigned long" "short" "unsigned short" "char" "unsigned char" "long long" "unsigned long long" ; do
+ cat > conftest.$ac_ext <<EOF
+#line 2389 "configure"
+#include "confdefs.h"
+
+#include <stdio.h>
+#include <sys/types.h>
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif
+
+int main() {
+ extern fpos_t foo; extern $try_type foo;
+; return 0; }
+EOF
+if { (eval echo configure:2402: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ pthreads_cv_type_fpos_t="$try_type" ; break
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+ done
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ { echo "configure: error: Can't find system typedef for fpos_t." 1>&2; exit 1; }
+fi
+rm -f conftest*
+fi
+
+if test -n "$pthreads_cv_type_fpos_t" ; then
+ cat >> confdefs.h <<EOF
+#define pthread_fpos_t $pthreads_cv_type_fpos_t
+EOF
+
+fi
+pthread_fpos_t=$pthreads_cv_type_fpos_t
+echo "$ac_t""$pthreads_cv_type_fpos_t" 1>&6
+else
+ cat >> confdefs.h <<\EOF
+#define fpos_t off_t
+EOF
+
+ cat >> confdefs.h <<\EOF
+#define pthread_fpos_t pthread_off_t
+EOF
+
+fi
+
+echo $ac_n "checking type of off_t""... $ac_c" 1>&6
+echo "configure:2440: checking type of off_t" >&5
+if eval "test \"`echo '$''{'pthreads_cv_type_off_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2445 "configure"
+#include "confdefs.h"
+
+#include <stdio.h>
+#include <sys/types.h>
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif
+
+int main() {
+ extern off_t foo;
+; return 0; }
+EOF
+if { (eval echo configure:2458: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ for try_type in "int" "unsigned int" "long" "unsigned long" "short" "unsigned short" "char" "unsigned char" "long long" "unsigned long long" ; do
+ cat > conftest.$ac_ext <<EOF
+#line 2462 "configure"
+#include "confdefs.h"
+
+#include <stdio.h>
+#include <sys/types.h>
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif
+
+int main() {
+ extern off_t foo; extern $try_type foo;
+; return 0; }
+EOF
+if { (eval echo configure:2475: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ pthreads_cv_type_off_t="$try_type" ; break
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+ done
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ { echo "configure: error: Can't find system typedef for off_t." 1>&2; exit 1; }
+fi
+rm -f conftest*
+fi
+
+if test -n "$pthreads_cv_type_off_t" ; then
+ cat >> confdefs.h <<EOF
+#define pthread_off_t $pthreads_cv_type_off_t
+EOF
+
+fi
+pthread_off_t=$pthreads_cv_type_off_t
+echo "$ac_t""$pthreads_cv_type_off_t" 1>&6
+echo $ac_n "checking type of va_list""... $ac_c" 1>&6
+echo "configure:2502: checking type of va_list" >&5
+if eval "test \"`echo '$''{'pthreads_cv_type_va_list'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2507 "configure"
+#include "confdefs.h"
+#include <stdarg.h>
+int main() {
+ extern va_list foo;
+; return 0; }
+EOF
+if { (eval echo configure:2514: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ for try_type in "char *" "char **" "void *" "void **" "int *" "long *" ; do
+ cat > conftest.$ac_ext <<EOF
+#line 2518 "configure"
+#include "confdefs.h"
+#include <stdarg.h>
+int main() {
+ extern va_list foo; extern $try_type foo;
+; return 0; }
+EOF
+if { (eval echo configure:2525: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ pthreads_cv_type_va_list="$try_type" ; break
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+ done
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ { echo "configure: error: Can't find system typedef for va_list." 1>&2; exit 1; }
+fi
+rm -f conftest*
+fi
+
+if test -n "$pthreads_cv_type_va_list" ; then
+ cat >> confdefs.h <<EOF
+#define pthread_va_list $pthreads_cv_type_va_list
+EOF
+
+fi
+pthread_va_list=$pthreads_cv_type_va_list
+echo "$ac_t""$pthreads_cv_type_va_list" 1>&6
+
+arpa_headers="#include <sys/types.h>
+#include <arpa/nameser.h>"
+
+echo $ac_n "checking IP address type""... $ac_c" 1>&6
+echo "configure:2556: checking IP address type" >&5
+if eval "test \"`echo '$''{'pthread_cv_type_ipaddr'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2561 "configure"
+#include "confdefs.h"
+$arpa_headers
+int main() {
+ &_getlong;
+; return 0; }
+EOF
+if { (eval echo configure:2568: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+
+ for type in "unsigned long" "unsigned int" ; do
+ cat > conftest.$ac_ext <<EOF
+#line 2573 "configure"
+#include "confdefs.h"
+$arpa_headers
+int main() {
+extern $type _getlong ();
+; return 0; }
+EOF
+if { (eval echo configure:2580: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+
+ pthread_cv_type_ipaddr="$type"
+ break
+
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+ done
+
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "configure: warning: Can't compile _getlong reference." 1>&2
+fi
+rm -f conftest*
+ if test "$pthread_cv_type_ipaddr" = "" ; then
+ echo "configure: warning: Can't determine _getlong return type." 1>&2
+ echo "configure: warning: Defaulting to unsigned long." 1>&2
+ pthread_cv_type_ipaddr="unsigned long"
+ fi
+
+fi
+
+echo "$ac_t""$pthread_cv_type_ipaddr" 1>&6
+cat >> confdefs.h <<EOF
+#define pthread_ipaddr_type $pthread_cv_type_ipaddr
+EOF
+
+
+echo $ac_n "checking IP port type""... $ac_c" 1>&6
+echo "configure:2615: checking IP port type" >&5
+if eval "test \"`echo '$''{'pthread_cv_type_ipport'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2620 "configure"
+#include "confdefs.h"
+$arpa_headers
+int main() {
+ &_getshort;
+; return 0; }
+EOF
+if { (eval echo configure:2627: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+
+ for type in "unsigned short" "unsigned int" ; do
+ cat > conftest.$ac_ext <<EOF
+#line 2632 "configure"
+#include "confdefs.h"
+$arpa_headers
+int main() {
+extern $type _getshort ();
+; return 0; }
+EOF
+if { (eval echo configure:2639: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+
+ pthread_cv_type_ipport="$type"
+ break
+
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+ done
+
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "configure: warning: Can't compile _getshort reference." 1>&2
+fi
+rm -f conftest*
+ if test "$pthread_cv_type_ipport" = "" ; then
+ echo "configure: warning: Can't determine _getshort return type." 1>&2
+ echo "configure: warning: Defaulting to unsigned short." 1>&2
+ pthread_cv_type_ipport="unsigned short"
+ fi
+
+fi
+
+echo "$ac_t""$pthread_cv_type_ipport" 1>&6
+cat >> confdefs.h <<EOF
+#define pthread_ipport_type $pthread_cv_type_ipport
+EOF
+
+
+echo $ac_n "checking pathname for terminal devices directory""... $ac_c" 1>&6
+echo "configure:2674: checking pathname for terminal devices directory" >&5
+if eval "test \"`echo '$''{'pthread_cv_pty_path'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -d /devices/pseudo ; then
+ pty_path=/devices/pseudo/
+ else
+ pty_path=/dev/
+ fi
+ pthread_cv_pty_path=$pty_path
+
+fi
+
+cat >> confdefs.h <<EOF
+#define _PATH_PTY "$pthread_cv_pty_path"
+EOF
+
+echo "$ac_t""$pthread_cv_pty_path" 1>&6
+
+echo $ac_n "checking directory name for time zone info""... $ac_c" 1>&6
+echo "configure:2694: checking directory name for time zone info" >&5
+tzdir=NONE
+for f in /usr/lib/zoneinfo /usr/share/zoneinfo /usr/share/lib/zoneinfo /etc/zoneinfo /usr/local/lib/zoneinfo
+do
+ if test -d $f ; then
+ tzdir=$f
+ break
+ fi
+done
+case $tzdir in
+NONE)
+ echo "configure: warning: Can't find zoneinfo directory." 1>&2
+ echo "configure: warning: Defaulting zoneinfo directory to NULL." 1>&2
+ tzdir=NULL
+ ;;
+esac
+cat >> confdefs.h <<EOF
+#define _PATH_TZDIR "$tzdir"
+EOF
+
+echo "$ac_t""$tzdir" 1>&6
+
+echo $ac_n "checking filename for local time zone""... $ac_c" 1>&6
+echo "configure:2717: checking filename for local time zone" >&5
+tzfile=NONE
+for f in $tzdir/localtime /etc/localtime
+do
+ if test -f $f ; then
+ tzfile=$f
+ break
+ fi
+done
+case $tzfile in
+NONE) # Should this default to tzdir/localtime?
+ echo "configure: warning: Can't find local time zone file." 1>&2
+ if test tzdir = NULL ; then
+ echo "configure: warning: Defaulting local time zone file to NULL" 1>&2
+ tzfile=NULL
+ else
+ echo "configure: warning: Defaulting local time zone file to $tzdir/localtime." 1>&2
+ tzfile=$tzdir/localtime
+ fi
+ ;;
+esac
+cat >> confdefs.h <<EOF
+#define _PATH_TZFILE "$tzfile"
+EOF
+
+echo "$ac_t""$tzfile" 1>&6
+
+cat >> confdefs.h <<\EOF
+#define _PATH_RESCONF "/etc/resolv.conf"
+EOF
+
+cat >> confdefs.h <<\EOF
+#define _PATH_HOSTS "/etc/hosts"
+EOF
+
+cat >> confdefs.h <<\EOF
+#define _PATH_NETWORKS "/etc/networks"
+EOF
+
+cat >> confdefs.h <<\EOF
+#define _PATH_PROTOCOLS "/etc/protocols"
+EOF
+
+cat >> confdefs.h <<\EOF
+#define _PATH_SERVICES "/etc/services"
+EOF
+
+
+cat >> confdefs.h <<\EOF
+#define _PATH_BSHELL "/bin/sh"
+EOF
+
+
+for ac_func in vfork
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:2773: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2778 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:2801: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+srctop=`cd ${srcdir}/..;pwd`
+
+
+# Now we deal with symlinks &c.
+
+test -d include || mkdir include || \
+ { echo "configure: error: Can't create include directory." 1>&2; exit 1; }
+
+test -d include/pthread || mkdir include/pthread || \
+ { echo "configure: error: Can't create include/pthread directory." 1>&2; exit 1; }
+
+test -d lib || mkdir lib || \
+ { echo "configure: error: Can't create lib directory." 1>&2; exit 1; }
+
+test -d lib/libpthreadutil || mkdir lib/libpthreadutil || \
+ { echo "configure: error: Can't create lib/libpthreadutil directory." 1>&2; exit 1; }
+
+test -d bin || mkdir bin || \
+ { echo "configure: error: Can't create bin directory." 1>&2; exit 1; }
+
+test -d bin/finger || mkdir bin/finger || \
+ { echo "configure: error: Can't create bin directory." 1>&2; exit 1; }
+
+test -d tests || mkdir tests || \
+ { echo "configure: error: Can't create tests directory." 1>&2; exit 1; }
+
+if test x$syscall = xNONE ; then
+ syscall=$name
+fi
+
+links="include/pthread/machdep.h include/pthread/posix.h \
+ machdep.c syscall.S"
+targets="../machdep/engine-$name.h ../machdep/posix-$sysincludes.h \
+ ../machdep/engine-$name.c ../machdep/syscall-$syscall.S"
+
+# Both these targets are optional. (Autoconf-generated configure scripts
+# will require the existence of link targets, so check before adding them
+# to the list.)
+if test x$sysincludes != xNONE ; then
+ links="$links include/sys"
+ targets="$targets ../machdep/$sysincludes"
+fi
+
+if test x$extraincludes != xNONE ; then
+ for tmp in $extraincludes
+ do
+ links="$links include/$tmp"
+ targets="$targets ../machdep/$sysincludes/extra/$tmp"
+ done
+fi
+
+syscall_file=../machdep/syscall-template-$syscall.S
+if test -r $srcdir/$syscall_file ; then
+ links="$links syscall-template.S"
+ targets="$targets $syscall_file"
+ HAVE_SYSCALL_TEMPLATE=yes
+else
+ # This really isn't a fatal problem. In fact, it's expected, initially,
+ # for some targets. This is just to persuade people to fix the targets
+ # they deal with to provide some sort of template.
+ #
+ # Eventually this file probably will be required...
+ echo "configure: warning: No syscall template file syscall-template-$syscall.S found." 1>&2
+ HAVE_SYSCALL_TEMPLATE=no
+fi
+
+
+
+
+if test x$makefile_frag != x ; then
+ makefile_frag=${srcdir}/$makefile_frag
+else
+ makefile_frag=/dev/null
+fi
+
+
+
+
+
+trap '' 1 2 15
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs. It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already. You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote substitution
+ # turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ -e "s/'/'\\\\''/g" \
+ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+ ;;
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+ ;;
+ esac >> confcache
+if cmp -s $cache_file confcache; then
+ :
+else
+ if test -w $cache_file; then
+ echo "updating cache $cache_file"
+ cat confcache > $cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Any assignment to VPATH causes Sun make to only execute
+# the first set of double-colon rules, so remove it if not needed.
+# If there is a colon in the path, we need to keep it.
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
+fi
+
+trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
+
+DEFS=-DHAVE_CONFIG_H
+
+# Without the "./", some shells look in PATH for config.status.
+: ${CONFIG_STATUS=./config.status}
+
+echo creating $CONFIG_STATUS
+rm -f $CONFIG_STATUS
+cat > $CONFIG_STATUS <<EOF
+#! /bin/sh
+# Generated automatically by configure.
+# Run this file to recreate the current configuration.
+# This directory was configured as follows,
+# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+#
+# $0 $ac_configure_args
+#
+# Compiler output produced by configure, useful for debugging
+# configure, is in ./config.log if it exists.
+
+ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
+for ac_option
+do
+ case "\$ac_option" in
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
+ exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
+ -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+ echo "$CONFIG_STATUS generated by autoconf version 2.13"
+ exit 0 ;;
+ -help | --help | --hel | --he | --h)
+ echo "\$ac_cs_usage"; exit 0 ;;
+ *) echo "\$ac_cs_usage"; exit 1 ;;
+ esac
+done
+
+ac_given_srcdir=$srcdir
+
+trap 'rm -fr `echo "config.flags GNUmakefile Makefile \
+ lib/Makefile:../lib/Makefile.in \
+ lib/libpthreadutil/Makefile:../lib/libpthreadutil/Makefile.in \
+ bin/Makefile:../bin/Makefile.in \
+ bin/finger/Makefile:../bin/finger/Makefile.in \
+ tests/Makefile:../tests/Makefile.in config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+# Protect against being on the right side of a sed subst in config.status.
+sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
+ s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
+$ac_vpsub
+$extrasub
+s%@SHELL@%$SHELL%g
+s%@CFLAGS@%$CFLAGS%g
+s%@CPPFLAGS@%$CPPFLAGS%g
+s%@CXXFLAGS@%$CXXFLAGS%g
+s%@FFLAGS@%$FFLAGS%g
+s%@DEFS@%$DEFS%g
+s%@LDFLAGS@%$LDFLAGS%g
+s%@LIBS@%$LIBS%g
+s%@exec_prefix@%$exec_prefix%g
+s%@prefix@%$prefix%g
+s%@program_transform_name@%$program_transform_name%g
+s%@bindir@%$bindir%g
+s%@sbindir@%$sbindir%g
+s%@libexecdir@%$libexecdir%g
+s%@datadir@%$datadir%g
+s%@sysconfdir@%$sysconfdir%g
+s%@sharedstatedir@%$sharedstatedir%g
+s%@localstatedir@%$localstatedir%g
+s%@libdir@%$libdir%g
+s%@includedir@%$includedir%g
+s%@oldincludedir@%$oldincludedir%g
+s%@infodir@%$infodir%g
+s%@mandir@%$mandir%g
+s%@CC@%$CC%g
+s%@CXX@%$CXX%g
+s%@CPP@%$CPP%g
+s%@RANLIB@%$RANLIB%g
+s%@host@%$host%g
+s%@host_alias@%$host_alias%g
+s%@host_cpu@%$host_cpu%g
+s%@host_vendor@%$host_vendor%g
+s%@host_os@%$host_os%g
+s%@target@%$target%g
+s%@target_alias@%$target_alias%g
+s%@target_cpu@%$target_cpu%g
+s%@target_vendor@%$target_vendor%g
+s%@target_os@%$target_os%g
+s%@build@%$build%g
+s%@build_alias@%$build_alias%g
+s%@build_cpu@%$build_cpu%g
+s%@build_vendor@%$build_vendor%g
+s%@build_os@%$build_os%g
+s%@SYSCALL_EXCEPTIONS@%$SYSCALL_EXCEPTIONS%g
+s%@available_syscalls@%$available_syscalls%g
+s%@missing_syscalls@%$missing_syscalls%g
+s%@srctop@%$srctop%g
+s%@HAVE_SYSCALL_TEMPLATE@%$HAVE_SYSCALL_TEMPLATE%g
+/@makefile_frag@/r $makefile_frag
+s%@makefile_frag@%%g
+
+CEOF
+EOF
+
+cat >> $CONFIG_STATUS <<\EOF
+
+# Split the substitutions into bite-sized pieces for seds with
+# small command number limits, like on Digital OSF/1 and HP-UX.
+ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
+ac_file=1 # Number of current file.
+ac_beg=1 # First line for current file.
+ac_end=$ac_max_sed_cmds # Line after last line for current file.
+ac_more_lines=:
+ac_sed_cmds=""
+while $ac_more_lines; do
+ if test $ac_beg -gt 1; then
+ sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
+ else
+ sed "${ac_end}q" conftest.subs > conftest.s$ac_file
+ fi
+ if test ! -s conftest.s$ac_file; then
+ ac_more_lines=false
+ rm -f conftest.s$ac_file
+ else
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds="sed -f conftest.s$ac_file"
+ else
+ ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
+ fi
+ ac_file=`expr $ac_file + 1`
+ ac_beg=$ac_end
+ ac_end=`expr $ac_end + $ac_max_sed_cmds`
+ fi
+done
+if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds=cat
+fi
+EOF
+
+cat >> $CONFIG_STATUS <<EOF
+
+CONFIG_FILES=\${CONFIG_FILES-"config.flags GNUmakefile Makefile \
+ lib/Makefile:../lib/Makefile.in \
+ lib/libpthreadutil/Makefile:../lib/libpthreadutil/Makefile.in \
+ bin/Makefile:../bin/Makefile.in \
+ bin/finger/Makefile:../bin/finger/Makefile.in \
+ tests/Makefile:../tests/Makefile.in"}
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
+
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
+ else
+ ac_dir_suffix= ac_dots=
+ fi
+
+ case "$ac_given_srcdir" in
+ .) srcdir=.
+ if test -z "$ac_dots"; then top_srcdir=.
+ else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
+ /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
+ *) # Relative path.
+ srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
+ top_srcdir="$ac_dots$ac_given_srcdir" ;;
+ esac
+
+
+ echo creating "$ac_file"
+ rm -f "$ac_file"
+ configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
+ case "$ac_file" in
+ *Makefile*) ac_comsub="1i\\
+# $configure_input" ;;
+ *) ac_comsub= ;;
+ esac
+
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+ sed -e "$ac_comsub
+s%@configure_input@%$configure_input%g
+s%@srcdir@%$srcdir%g
+s%@top_srcdir@%$top_srcdir%g
+" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
+fi; done
+rm -f conftest.s*
+
+# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+# NAME is the cpp macro being defined and VALUE is the value it is being given.
+#
+# ac_d sets the value in "#define NAME VALUE" lines.
+ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
+ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
+ac_dC='\3'
+ac_dD='%g'
+# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
+ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_uB='\([ ]\)%\1#\2define\3'
+ac_uC=' '
+ac_uD='\4%g'
+# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_eB='$%\1#\2define\3'
+ac_eC=' '
+ac_eD='%g'
+
+if test "${CONFIG_HEADERS+set}" != set; then
+EOF
+cat >> $CONFIG_STATUS <<EOF
+ CONFIG_HEADERS="config.h"
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+fi
+for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ echo creating $ac_file
+
+ rm -f conftest.frag conftest.in conftest.out
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+ cat $ac_file_inputs > conftest.in
+
+EOF
+
+# Transform confdefs.h into a sed script conftest.vals that substitutes
+# the proper values into config.h.in to produce config.h. And first:
+# Protect against being on the right side of a sed subst in config.status.
+# Protect against being in an unquoted here document in config.status.
+rm -f conftest.vals
+cat > conftest.hdr <<\EOF
+s/[\\&%]/\\&/g
+s%[\\$`]%\\&%g
+s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
+s%ac_d%ac_u%gp
+s%ac_u%ac_e%gp
+EOF
+sed -n -f conftest.hdr confdefs.h > conftest.vals
+rm -f conftest.hdr
+
+# This sed command replaces #undef with comments. This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+cat >> conftest.vals <<\EOF
+s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
+EOF
+
+# Break up conftest.vals because some shells have a limit on
+# the size of here documents, and old seds have small limits too.
+
+rm -f conftest.tail
+while :
+do
+ ac_lines=`grep -c . conftest.vals`
+ # grep -c gives empty output for an empty file on some AIX systems.
+ if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
+ # Write a limited-size here document to conftest.frag.
+ echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
+ sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
+ echo 'CEOF
+ sed -f conftest.frag conftest.in > conftest.out
+ rm -f conftest.in
+ mv conftest.out conftest.in
+' >> $CONFIG_STATUS
+ sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
+ rm -f conftest.vals
+ mv conftest.tail conftest.vals
+done
+rm -f conftest.vals
+
+cat >> $CONFIG_STATUS <<\EOF
+ rm -f conftest.frag conftest.h
+ echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
+ cat conftest.in >> conftest.h
+ rm -f conftest.in
+ if cmp -s $ac_file conftest.h 2>/dev/null; then
+ echo "$ac_file is unchanged"
+ rm -f conftest.h
+ else
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ fi
+ rm -f $ac_file
+ mv conftest.h $ac_file
+ fi
+fi; done
+
+EOF
+
+cat >> $CONFIG_STATUS <<EOF
+ac_sources="$targets"
+ac_dests="$links"
+EOF
+
+cat >> $CONFIG_STATUS <<\EOF
+srcdir=$ac_given_srcdir
+while test -n "$ac_sources"; do
+ set $ac_dests; ac_dest=$1; shift; ac_dests=$*
+ set $ac_sources; ac_source=$1; shift; ac_sources=$*
+
+ echo "linking $srcdir/$ac_source to $ac_dest"
+
+ if test ! -r $srcdir/$ac_source; then
+ { echo "configure: error: $srcdir/$ac_source: File not found" 1>&2; exit 1; }
+ fi
+ rm -f $ac_dest
+
+ # Make relative symlinks.
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dest_dir=`echo $ac_dest|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dest_dir" != "$ac_dest" && test "$ac_dest_dir" != .; then
+ # The dest file is in a subdirectory.
+ test ! -d "$ac_dest_dir" && mkdir "$ac_dest_dir"
+ ac_dest_dir_suffix="/`echo $ac_dest_dir|sed 's%^\./%%'`"
+ # A "../" for each directory in $ac_dest_dir_suffix.
+ ac_dots=`echo $ac_dest_dir_suffix|sed 's%/[^/]*%../%g'`
+ else
+ ac_dest_dir_suffix= ac_dots=
+ fi
+
+ case "$srcdir" in
+ [/$]*) ac_rel_source="$srcdir/$ac_source" ;;
+ *) ac_rel_source="$ac_dots$srcdir/$ac_source" ;;
+ esac
+
+ # Make a symlink if possible; otherwise try a hard link.
+ if ln -s $ac_rel_source $ac_dest 2>/dev/null ||
+ ln $srcdir/$ac_source $ac_dest; then :
+ else
+ { echo "configure: error: can not link $ac_dest to $srcdir/$ac_source" 1>&2; exit 1; }
+ fi
+done
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+
+exit 0
+EOF
+chmod +x $CONFIG_STATUS
+rm -fr confdefs* $ac_clean_files
+test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+
diff --git a/mit-pthreads/config/configure.in b/mit-pthreads/config/configure.in
new file mode 100755
index 00000000000..c623ddc4343
--- /dev/null
+++ b/mit-pthreads/config/configure.in
@@ -0,0 +1,739 @@
+dnl Some reminders:
+dnl "dnl" is a "delete to newline" command for m4 - the remainder of the
+dnl line it's on, including the newline, will be discarded
+dnl "#" comments will usually be copied through
+dnl "[]" are quoting characters; use changequote around code that really
+dnl needs to use them, but try not to invoke autoconf macros
+dnl within such code
+dnl
+dnl When you change this file, re-run "autoreconf" -- that'll automatically
+dnl re-run both autoconf and autoheader.
+dnl
+dnl
+dnl To do:
+dnl CLOCKS_PER_SEC (default 100, Ultrix differs)
+dnl CLK_TCK (default 100, Ultrix differs)
+dnl clockid_t (not on all systems)
+dnl timer_t (not on all systems)
+dnl
+dnl
+dnl Now, the real stuff.
+dnl
+dnl This must be first.
+AC_INIT(config.flags.in)
+dnl
+dnl This file does require autoconf 2.0 or better...
+dnl
+AC_PREREQ(2.0)dnl
+dnl
+dnl Hook for the "--enable-dce-compat" option, when Chris actually
+dnl implements it.
+dnl
+AC_ARG_ENABLE(dce-compat,
+ --enable-dce-compat DCE compatibility,
+[dnl "true" action
+ AC_MSG_ERROR([Actually, DCE compatibility doesn't work yet...])
+],
+[dnl "false" action
+ true
+])
+
+dnl What C compiler?
+AC_PROG_CC
+AC_PROG_CXX
+dnl Apparently autoconf doesn't test to see if the C compiler it locates
+dnl actually works... oops!
+AC_MSG_CHECKING(compiler availability and simple error detection)
+AC_TRY_COMPILE(,[ exit(0); ],[
+ dnl true
+ AC_TRY_COMPILE(,[ syntax errors galore! ],
+ dnl true
+ AC_MSG_ERROR(Can't detect syntax errors! Is CC set right?),
+ dnl false
+ true)],
+ dnl false
+ AC_MSG_ERROR(Can't compile test program! Is CC set right?))
+
+AC_TRY_COMPILE(,[
+ typedef int Integer;
+ extern int i;
+ extern Integer i;
+], , AC_MSG_ERROR(Can't redeclare variables with this compiler??))
+AC_TRY_COMPILE(,[
+ typedef long Long;
+ extern int i;
+ extern Long i;
+], AC_MSG_ERROR(Compiler doesn't detect conflicting declarations.))
+AC_MSG_RESULT(ok)
+
+if test $ac_cv_prog_gcc = yes ; then
+ CFLAGS="$CFLAGS -Werror"
+fi
+
+AC_PROG_CPP
+
+AC_PROG_RANLIB
+
+dnl Default value of prefix should be /usr/local/pthreads, not /usr/local.
+AC_PREFIX_DEFAULT(/usr/local/pthreads)
+
+dnl Determine $host, by guessing if necessary.
+AC_CANONICAL_SYSTEM
+
+syscall=NONE
+sysincludes=NONE
+extraincludes=NONE
+
+# Treat all x86 machines the same.
+# (Yet below, we pretend we can distinguish between the MIPS r2000 and r4000?)
+# (What about 680x0 machines?)
+changequote(,)dnl
+case $host in
+ i[456]86-*)
+ host=`echo $host | sed 's/^i[456]86/i386/'`
+ host_cpu=i386
+ ;;
+esac
+changequote([,])dnl
+
+# Here, you should set the following variables:
+# name
+# The "name" of this configuration. Used for "engine-*.c" file name,
+# default for syscall file names. Chris seems to have a thing for
+# putting "-" between OS and version number, but the configure script
+# will already have $host_cpu and $host_os available for you to use
+# in constructing a name.
+# sysincludes
+# Name of machdep directory with "sys" include file
+# replacements, if any. This directory is optional;
+# if you don't provide it, don't set this variable.
+# except
+# Names of any syscalls that shouldn't be generated
+# from the template, if any.
+# syscall
+# Base name of the syscall template files, if not the
+# same as <name>. If they're the same, omit this.
+#
+# Also, you may define random symbols and update CFLAGS if
+# necessary. However, for ease of porting to new machines,
+# it's best if you can create portable autoconf tests for
+# whatever you're trying to do, rather than hard-coding it
+# here based on the OS name. So please, try to keep this
+# section as minimal as possible.
+
+except=""
+name=$host_cpu-$host_os
+
+case $host in
+changequote(,)dnl
+ alpha-*-netbsd1.3[H-Z]|alpha-*-netbsd1.4*)
+ name=alpha-netbsd-1.3
+ sysincludes=netbsd-1.1
+ except="fork lseek pipe fstat"
+ available_syscalls="sigsuspend sigprocmask"
+ ;;
+changequote([,])dnl
+ alpha-*-netbsd1.3*)
+ name=alpha-netbsd-1.3
+ sysincludes=netbsd-1.1
+ except="fork lseek pipe sigsuspend sigprocmask fstat"
+ ;;
+ alpha-*-netbsd1.1* | alpha-*-netbsd1.2*)
+ name=alpha-netbsd-1.1
+ sysincludes=netbsd-1.1
+ except="fork lseek pipe sigsuspend sigprocmask"
+ ;;
+ alpha-*-osf*)
+ name=alpha-osf1
+ sysincludes=alpha-osf1
+ except="fork sigsuspend"
+ if test $ac_cv_prog_gcc = no ; then
+ CFLAGS="$CFLAGS -std"
+ fi
+ ;;
+changequote(,)dnl
+ arm32-*-netbsd1.3[H-Z]|arm32-*-netbsd1.4*)
+ name=arm32-netbsd-1.3
+ sysincludes=netbsd-1.1
+ except="fork pipe lseek ftruncate fstat"
+ available_syscalls="sigsuspend sigprocmask"
+ ;;
+changequote([,])dnl
+ arm32-*-netbsd1.3*)
+ name=arm32-netbsd-1.3
+ sysincludes=netbsd-1.1
+ except="fork pipe lseek ftruncate sigsuspend sigprocmask fstat"
+ ;;
+ hppa1.0-*-hpux10.20 | hppa1.1-*-hpux10.20)
+ name=hppa-hpux-10.20
+ sysincludes=hpux-10.20
+ except="fork"
+ ;;
+ hppa1.1-*-hpux*9.*)
+ name=hppa-hpux-9.03
+ sysincludes=hpux-9.03
+ # hpux-9.03.mk seems to be missing; what should this be?
+ except="fork"
+ ;;
+ sparc-*-sunos4.1.3* | sparc-*-sunos4.1.4*)
+ name=sparc-sunos-4.1.3
+ sysincludes=sunos-4.1.3
+ syscall=sparc-sunos4
+ except="fork pipe getpgrp getdirentries"
+ AC_DEFINE(sunos4) # is this really needed??
+ ;;
+ sparc-*-solaris2.3* | sparc-*-solaris2.4*)
+ name=sparc-sunos-5.3
+ sysincludes=sunos-5.3
+ except="fork sigaction"
+ # Should really come up with a test for this...
+ AC_DEFINE(LD_LINKS_STATIC_DATA)
+ AC_DEFINE(BROKEN_SIGNALS)
+ ;;
+ sparc-*-solaris2*)
+ name=sparc-sunos-5.3
+ sysincludes=sunos-5.5
+ except="fork sigaction"
+ # Should really come up with a test for this...
+ AC_DEFINE(LD_LINKS_STATIC_DATA)
+ AC_DEFINE(BROKEN_SIGNALS)
+ ;;
+changequote(,)dnl
+ sparc-*-netbsd1.3[H-Z]|sparc-*-netbsd1.4*)
+ name=sparc-netbsd-1.3
+ sysincludes=netbsd-1.1
+ except="pipe fork lseek ftruncate fstat"
+ available_syscalls="sigprocmask sigsuspend"
+ ;;
+changequote([,])dnl
+ sparc-*-netbsd1.3*)
+ name=sparc-netbsd-1.3
+ sysincludes=netbsd-1.1
+ except="pipe fork lseek ftruncate sigprocmask sigsuspend fstat"
+ ;;
+ sparc-*-netbsd1.0A | sparc-*-netbsd1.1* | sparc-*-netbsd1.2*)
+ name=sparc-sunos-4.1.3
+ sysincludes=netbsd-1.0
+ syscall=sparc-netbsd-1.1
+ except="pipe fork sigprocmask sigsuspend"
+ ;;
+ i386-*-openbsd2.*)
+ name=i386-openbsd-2.0
+ sysincludes=openbsd-2.0
+ except="fork lseek ftruncate sigsuspend sigprocmask"
+ ;;
+ i386-*-linux*)
+ #name=i386-linux-1.0
+ #sysincludes=linux-1.0
+ name=i386-linux-2.0
+ sysincludes=linux-2.0
+ extraincludes="bits"
+ ;;
+ i386-*-bsdi1.1)
+ name=i386-bsdi-1.1
+ sysincludes=bsdi-1.1
+ ;;
+ i386-*-bsdi2.0* | i386-*-bsdi2.1*)
+ name=i386-bsdi-2.0
+ sysincludes=bsdi-2.0
+ syscall=i386-bsdi-2.0
+ except="fork lseek ftruncate sigsuspend"
+ ;;
+changequote(,)dnl
+ i386-*-netbsd1.3[H-Z]|i386-*-netbsd1.4*)
+ name=i386-netbsd-1.3
+ sysincludes=netbsd-1.1
+ except="fork lseek ftruncate pipe fstat"
+ available_syscalls="sigsuspend sigprocmask"
+ ;;
+changequote([,])dnl
+ i386-*-netbsd1.3*)
+ name=i386-netbsd-1.3
+ sysincludes=netbsd-1.1
+ except="fork lseek ftruncate pipe sigsuspend sigprocmask fstat"
+ ;;
+ i386-*-netbsd1.1* | i386-*-netbsd1.2*)
+ name=i386-netbsd-1.0
+ sysincludes=netbsd-1.1
+ syscall=i386-netbsd-1.1
+ except="fork lseek ftruncate pipe sigsuspend sigprocmask"
+ ;;
+ i386-*-netbsd1.0*)
+ name=i386-netbsd-1.0
+ sysincludes=netbsd-1.0
+ except="fork lseek ftruncate sigsuspend"
+ ;;
+ i386-*-netbsd0.9*)
+ name=i386-netbsd-0.9
+ sysincludes=netbsd-0.9
+ ;;
+ m68*-*-netbsd*)
+ name=m68000-netbsd
+ sysincludes=netbsd-1.1
+ except="lseek ftruncate pipe fstat"
+ available_syscalls="sigsuspend sigprocmask"
+ ;;
+ i386-*-freebsd*)
+ name=i386-freebsd-2.0
+ sysincludes=freebsd-2.0
+ except="fork lseek ftruncate sigsuspend sigprocmask"
+ ;;
+ romp-*-bsd*)
+ name=romp-bsd
+ ;;
+ mips-dec-ultrix*)
+ name=r2000-ultrix-4.2
+ sysincludes=ultrix-4.2
+ except="fork pipe"
+ ;;
+ mips-sgi-irix*)
+ name=ip22-irix-5.2
+ sysincludes=irix-5.2
+ except="fstat stat"
+ AC_DEFINE(BROKEN_SIGNALS)
+ ;;
+ i386-*-sco3.2v5*)
+ name=i386-sco3.2.5
+ sysincludes=i386-sco3.2.5
+ syscall=i386-sco3.2.5
+ except="select socketcall accept bind connect getpeername getsockname getsockopt setsockopt listen recv recvfrom recvmsg send sendmsg sendto shutdown socket socketpair fork fcntl dup2 fstat fchmod fchown ftruncate pipe getdirentries sigaction sigpause wait3 waitpid getdtablesize"
+ ;;
+ *)
+ AC_MSG_ERROR(System type $host not recognized or not supported.
+See $srcdir/configure.in for supported systems.)
+ exit 1
+ ;;
+esac
+
+SYSCALL_EXCEPTIONS=$except
+AC_SUBST(SYSCALL_EXCEPTIONS)
+
+AC_CHECK_HEADERS(sys/termio.h termios.h termio.h alloc.h)
+
+dnl Don't use AC_CHECK_HEADERS for this one, we want to define a special
+dnl symbol name starting with pthread_ if it's found.
+AC_CHECK_HEADER(va_list.h, AC_DEFINE(pthread_have_va_list_h))
+
+dnl Generate a list of system calls that we could generate. We later use
+dnl a syscall template .S file to produce a .o file for each syscall. This
+dnl is a bit better for porting and development purposes than having every
+dnl syscall listed for every target system; this way we only need the
+dnl template, and special hanlding for only those syscalls that can't be
+dnl handled by the templates.
+AC_CHECK_HEADERS(syscall.h sys/syscall.h sys/filio.h)
+
+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 fstatfs chroot uname
+ dnl - signals
+ sigsuspend sigaction sigpause sigprocmask ksigaction
+ dnl - directory reading
+ getdents readdir getdirentries
+ dnl - variants of `wait' syscalls
+ wait4 wait3 waitpid waitsys
+ dnl - BSD socket calls
+ socket bind connect accept listen getsockopt setsockopt socketpair
+ dnl - SYSV stream calls
+ poll putmsg getmsg
+ dnl - Linux version uses one syscall
+ socketcall
+
+ dnl - Process info
+ pgrpsys
+
+ exit
+ readv writev send sendto sendmsg recv recvfrom recvmsg
+ getpeername getsockname
+ shutdown
+ getpgrp fork)
+
+AC_SUBST(available_syscalls)
+AC_SUBST(missing_syscalls)
+
+dnl Disabled for now -- generates warnings from autoconf.
+dnl ## Check some type sizes.
+dnl AC_CHECK_SIZEOF(int)
+dnl AC_CHECK_SIZEOF(long)
+dnl AC_CHECK_SIZEOF(char *)
+
+## Determine some typedef values from the system header files.
+dnl
+dnl Autoconf provides these automatically. They provide reasonable
+dnl fallbacks if the standard header files don't define the typedef names.
+dnl
+dnl AC_TYPE_MODE_T
+AC_TYPE_OFF_T
+dnl AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+dnl AC_TYPE_UID_T
+AC_TYPE_SIGNAL
+dnl
+dnl Default these types if their definitions can't be found.
+dnl
+AC_CHECK_TYPE(ssize_t,int)
+AC_CHECK_TYPE(time_t,long)
+dnl
+AC_CHECK_HEADERS(sys/time.h)
+AC_HEADER_TIME
+
+dnl
+dnl Check for the existence of these types
+dnl
+dnl struct timespec
+dnl
+AC_MSG_CHECKING(for struct timespec in sys/time.h)
+AC_CACHE_VAL(pthreads_cv_timespec_in_time,
+ AC_TRY_COMPILE([#include <sys/time.h>], [struct timespec foo;],
+ pthreads_cv_timespec_in_time=yes, pthreads_cv_timespec_in_time=no))
+AC_MSG_RESULT($pthreads_cv_timespec_in_time)
+if test $pthreads_cv_timespec_in_time = yes ; then
+ AC_DEFINE(_OS_HAS_TIMESPEC)
+fi
+
+dnl socklen_t
+AC_CACHE_VAL(pthreads_cv_socklen_t,
+ AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/socket.h>], [socklen_t foo;],
+ pthreads_cv_socklen_t=yes, pthreads_cv_socklen_t=no))
+AC_MSG_RESULT($pthreads_cv_socklen_t)
+if test $pthreads_cv_socklen_t = yes ; then
+ AC_DEFINE(_OS_HAS_SOCKLEN_T)
+fi
+
+
+dnl
+dnl Usage: PTHREADS_FIND_TYPE(system-typedef-name, new-macro-name,
+dnl list-of-includes-in-square-brackets,
+dnl comma-separated-list-of-types-to-try)
+dnl
+dnl PTHREADS_FIND_INTEGRAL_TYPE automatically provides a set of integral
+dnl types, and does not permit specification of additional types.
+dnl
+dnl The specified types must all be able to work as prefixes -- i.e., no
+dnl direct specification of array or function types. If you need such
+dnl types, add typedefs for them to include/pthread/xtypes.h, and include
+dnl that in the set of header files. For simple struct types, you can
+dnl try including the definition directly here, but it had better not
+dnl contain any commas or square brackets.
+dnl
+dnl If necessary, you can include other preprocessing commands and such
+dnl in the `includes' portion.
+dnl
+dnl Note: For now, each of these needs a corresponding entry
+dnl in acconfig.h.
+dnl
+dnl size_t
+dnl
+PTHREADS_FIND_INTEGRAL_TYPE(size_t, pthread_size_t, [
+#include <stddef.h>
+#include <sys/types.h>
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif
+])
+dnl
+dnl ssize_t
+dnl
+PTHREADS_FIND_INTEGRAL_TYPE(ssize_t, pthread_ssize_t, [
+#include <stddef.h>
+#include <stdlib.h>
+#include <unistd.h>
+])
+dnl
+dnl clock_t ---FIXME I don't know if this is the right set of header files. KR
+dnl
+PTHREADS_FIND_INTEGRAL_TYPE(clock_t, pthread_clock_t, [
+#include <stddef.h>
+#if TIME_WITH_SYS_TIME
+# include <time.h>
+# include <sys/time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+])
+dnl
+dnl time_t
+dnl
+PTHREADS_FIND_INTEGRAL_TYPE(time_t, pthread_time_t, [
+#include <stddef.h>
+#if TIME_WITH_SYS_TIME
+# include <time.h>
+# include <sys/time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+])
+dnl
+dnl fpos_t
+dnl
+dnl If fpos_t isn't defined in stdio.h, define it to be off_t. It
+dnl looks like AC_CHECK_TYPE won't work for this, because it doesn't
+dnl include stdio.h.
+dnl
+AC_MSG_CHECKING(for fpos_t in stdio.h)
+AC_CACHE_VAL(pthreads_cv_fpos_t_in_stdio,
+ AC_TRY_COMPILE([#include <stdio.h>], [fpos_t position;],
+ pthreads_cv_fpos_t_in_stdio=yes, pthreads_cv_fpos_t_in_stdio=no))
+AC_MSG_RESULT($pthreads_cv_fpos_t_in_stdio)
+if test $pthreads_cv_fpos_t_in_stdio = yes ; then
+ PTHREADS_FIND_INTEGRAL_TYPE(fpos_t, pthread_fpos_t, [
+#include <stdio.h>
+#include <sys/types.h>
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif
+])
+else
+ AC_DEFINE(fpos_t,off_t)
+ AC_DEFINE(pthread_fpos_t,pthread_off_t)
+fi
+dnl
+dnl off_t
+dnl
+PTHREADS_FIND_INTEGRAL_TYPE(off_t, pthread_off_t, [
+#include <stdio.h>
+#include <sys/types.h>
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif
+])
+dnl
+dnl va_list -- This one could be tricky. Fortunately, on some systems,
+dnl we can just include the gcc stdarg.h header file if we can't determine
+dnl the type here. Won't work for non-gcc configurations though.
+dnl
+PTHREADS_FIND_TYPE(va_list, pthread_va_list, [#include <stdarg.h>],
+ char *, char **, void *, void **, int *, long *)
+dnl
+dnl
+
+arpa_headers="#include <sys/types.h>
+#include <arpa/nameser.h>"
+
+dnl
+dnl Type for network (IP) addresses, 32 bits.
+dnl For now, I'm assuming that the return type from _getlong is it.
+dnl
+AC_MSG_CHECKING(IP address type)
+AC_CACHE_VAL(pthread_cv_type_ipaddr,
+ AC_TRY_COMPILE($arpa_headers,[ &_getlong; ],[
+ for type in "unsigned long" "unsigned int" ; do
+ AC_TRY_COMPILE($arpa_headers, extern $type _getlong ();,[
+ pthread_cv_type_ipaddr="$type"
+ break
+ ])
+ done
+ ],[ AC_MSG_WARN(Can't compile _getlong reference.) ])
+ if test "$pthread_cv_type_ipaddr" = "" ; then
+ AC_MSG_WARN(Can't determine _getlong return type.)
+ AC_MSG_WARN(Defaulting to unsigned long.)
+ pthread_cv_type_ipaddr="unsigned long"
+ fi
+)
+AC_MSG_RESULT($pthread_cv_type_ipaddr)
+AC_DEFINE_UNQUOTED(pthread_ipaddr_type,$pthread_cv_type_ipaddr)
+
+dnl
+dnl Type for network (IP) ports, 16 bits.
+dnl For now, I'm assuming that the return type from _getshort is it.
+dnl
+AC_MSG_CHECKING(IP port type)
+AC_CACHE_VAL(pthread_cv_type_ipport,
+ AC_TRY_COMPILE($arpa_headers,[ &_getshort; ],[
+ for type in "unsigned short" "unsigned int" ; do
+ AC_TRY_COMPILE($arpa_headers, extern $type _getshort ();,[
+ pthread_cv_type_ipport="$type"
+ break
+ ])
+ done
+ ],[ AC_MSG_WARN(Can't compile _getshort reference.) ])
+ if test "$pthread_cv_type_ipport" = "" ; then
+ AC_MSG_WARN(Can't determine _getshort return type.)
+ AC_MSG_WARN(Defaulting to unsigned short.)
+ pthread_cv_type_ipport="unsigned short"
+ fi
+)
+AC_MSG_RESULT($pthread_cv_type_ipport)
+AC_DEFINE_UNQUOTED(pthread_ipport_type,$pthread_cv_type_ipport)
+
+dnl
+dnl Guess where terminal devices are stored. This is for use in the
+dnl ttyname() implementation provided here.
+dnl
+AC_MSG_CHECKING(pathname for terminal devices directory)
+AC_CACHE_VAL(pthread_cv_pty_path,
+ if test -d /devices/pseudo ; then
+ pty_path=/devices/pseudo/
+ else
+ pty_path=/dev/
+ fi
+ pthread_cv_pty_path=$pty_path
+)
+AC_DEFINE_UNQUOTED(_PATH_PTY,"$pthread_cv_pty_path")
+AC_MSG_RESULT($pthread_cv_pty_path)
+
+dnl
+dnl Look for timezone info, for use in ctime.
+dnl
+AC_MSG_CHECKING(directory name for time zone info)
+tzdir=NONE
+for f in /usr/lib/zoneinfo /usr/share/zoneinfo /usr/share/lib/zoneinfo /etc/zoneinfo /usr/local/lib/zoneinfo
+do
+ if test -d $f ; then
+ tzdir=$f
+ break
+ fi
+done
+case $tzdir in
+NONE)
+ AC_MSG_WARN(Can't find zoneinfo directory.)
+ AC_MSG_WARN(Defaulting zoneinfo directory to NULL.)
+ tzdir=NULL
+ ;;
+esac
+AC_DEFINE_UNQUOTED(_PATH_TZDIR,"$tzdir")
+AC_MSG_RESULT($tzdir)
+
+AC_MSG_CHECKING(filename for local time zone)
+tzfile=NONE
+for f in $tzdir/localtime /etc/localtime
+do
+ if test -f $f ; then
+ tzfile=$f
+ break
+ fi
+done
+case $tzfile in
+NONE) # Should this default to tzdir/localtime?
+ AC_MSG_WARN(Can't find local time zone file.)
+ if test tzdir = NULL ; then
+ AC_MSG_WARN(Defaulting local time zone file to NULL)
+ tzfile=NULL
+ else
+ AC_MSG_WARN(Defaulting local time zone file to $tzdir/localtime.)
+ tzfile=$tzdir/localtime
+ fi
+ ;;
+esac
+AC_DEFINE_UNQUOTED(_PATH_TZFILE,"$tzfile")
+AC_MSG_RESULT($tzfile)
+
+dnl
+dnl Network stuff. At the moment, I don't think there are any other
+dnl values we should expect. If we find a system that does store these
+dnl files elsewhere -- or doesn't have them all -- then run some tests.
+dnl
+AC_DEFINE(_PATH_RESCONF, "/etc/resolv.conf")
+AC_DEFINE(_PATH_HOSTS, "/etc/hosts")
+AC_DEFINE(_PATH_NETWORKS, "/etc/networks")
+AC_DEFINE(_PATH_PROTOCOLS, "/etc/protocols")
+AC_DEFINE(_PATH_SERVICES, "/etc/services")
+
+dnl
+dnl Other stuff
+dnl
+AC_DEFINE(_PATH_BSHELL, "/bin/sh")
+
+dnl If the system provides vfork, autoconf scripts will detect it.
+dnl So we should hide it.
+AC_CHECK_FUNCS(vfork)
+
+srctop=`cd ${srcdir}/..;pwd`
+AC_SUBST(srctop)
+
+# Now we deal with symlinks &c.
+
+test -d include || mkdir include || \
+ AC_MSG_ERROR(Can't create include directory.)
+
+test -d include/pthread || mkdir include/pthread || \
+ AC_MSG_ERROR(Can't create include/pthread directory.)
+
+test -d lib || mkdir lib || \
+ AC_MSG_ERROR(Can't create lib directory.)
+
+test -d lib/libpthreadutil || mkdir lib/libpthreadutil || \
+ AC_MSG_ERROR(Can't create lib/libpthreadutil directory.)
+
+test -d bin || mkdir bin || \
+ AC_MSG_ERROR(Can't create bin directory.)
+
+test -d bin/finger || mkdir bin/finger || \
+ AC_MSG_ERROR(Can't create bin directory.)
+
+test -d tests || mkdir tests || \
+ AC_MSG_ERROR(Can't create tests directory.)
+
+if test x$syscall = xNONE ; then
+ syscall=$name
+fi
+
+links="include/pthread/machdep.h include/pthread/posix.h \
+ machdep.c syscall.S"
+targets="../machdep/engine-$name.h ../machdep/posix-$sysincludes.h \
+ ../machdep/engine-$name.c ../machdep/syscall-$syscall.S"
+
+# Both these targets are optional. (Autoconf-generated configure scripts
+# will require the existence of link targets, so check before adding them
+# to the list.)
+if test x$sysincludes != xNONE ; then
+ links="$links include/sys"
+ targets="$targets ../machdep/$sysincludes"
+fi
+
+if test x$extraincludes != xNONE ; then
+ for tmp in $extraincludes
+ do
+ links="$links include/$tmp"
+ targets="$targets ../machdep/$sysincludes/extra/$tmp"
+ done
+fi
+
+syscall_file=../machdep/syscall-template-$syscall.S
+if test -r $srcdir/$syscall_file ; then
+ links="$links syscall-template.S"
+ targets="$targets $syscall_file"
+ HAVE_SYSCALL_TEMPLATE=yes
+else
+ # This really isn't a fatal problem. In fact, it's expected, initially,
+ # for some targets. This is just to persuade people to fix the targets
+ # they deal with to provide some sort of template.
+ #
+ # Eventually this file probably will be required...
+ AC_MSG_WARN(No syscall template file syscall-template-$syscall.S found.)
+ HAVE_SYSCALL_TEMPLATE=no
+fi
+AC_SUBST(HAVE_SYSCALL_TEMPLATE)
+
+dnl Now tell it to make the links.
+dnl (The links are actually made by config.status.)
+AC_LINK_FILES($targets, $links)
+
+if test x$makefile_frag != x ; then
+ makefile_frag=${srcdir}/$makefile_frag
+else
+ makefile_frag=/dev/null
+fi
+dnl Drop in file indicated by $makefile_frag on *the line after* the
+dnl magic @makefile_frag@ sequence.
+AC_SUBST_FILE(makefile_frag)
+
+
+dnl Generate output files...
+AC_CONFIG_HEADER(config.h)
+
+dnl This must be last.
+AC_OUTPUT(config.flags GNUmakefile Makefile \
+ lib/Makefile:../lib/Makefile.in \
+ lib/libpthreadutil/Makefile:../lib/libpthreadutil/Makefile.in \
+ bin/Makefile:../bin/Makefile.in \
+ bin/finger/Makefile:../bin/finger/Makefile.in \
+ tests/Makefile:../tests/Makefile.in)
diff --git a/mit-pthreads/config/configure.org b/mit-pthreads/config/configure.org
new file mode 100755
index 00000000000..f8526844a24
--- /dev/null
+++ b/mit-pthreads/config/configure.org
@@ -0,0 +1,2874 @@
+#! /bin/sh
+
+# Guess values for system-dependent variables and create Makefiles.
+# Generated automatically using autoconf version 2.10
+# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+
+# Defaults:
+ac_help=
+ac_default_prefix=/usr/local
+# Any additions from configure.in:
+ac_help="$ac_help
+--enable-dce-compat DCE compatibility"
+ac_default_prefix=/usr/local/pthreads
+
+# Initialize some variables set by options.
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+build=NONE
+cache_file=./config.cache
+exec_prefix=NONE
+host=NONE
+no_create=
+nonopt=NONE
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+target=NONE
+verbose=
+x_includes=NONE
+x_libraries=NONE
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+# Initialize some other variables.
+subdirs=
+MFLAGS= MAKEFLAGS=
+
+ac_prev=
+for ac_option
+do
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+ ac_prev=
+ continue
+ fi
+
+ case "$ac_option" in
+ -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) ac_optarg= ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case "$ac_option" in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir="$ac_optarg" ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build="$ac_optarg" ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file="$ac_optarg" ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+ datadir="$ac_optarg" ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ eval "enable_${ac_feature}=no" ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "enable_${ac_feature}='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix="$ac_optarg" ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he)
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat << EOF
+Usage: configure [options] [host]
+Options: [defaults in brackets after descriptions]
+Configuration:
+ --cache-file=FILE cache test results in FILE
+ --help print this message
+ --no-create do not create output files
+ --quiet, --silent do not print \`checking...' messages
+ --version print the version of autoconf that created configure
+Directory and file names:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [same as prefix]
+ --bindir=DIR user executables in DIR [EPREFIX/bin]
+ --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
+ --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
+ --datadir=DIR read-only architecture-independent data in DIR
+ [PREFIX/share]
+ --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data in DIR
+ [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
+ --libdir=DIR object code libraries in DIR [EPREFIX/lib]
+ --includedir=DIR C header files in DIR [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
+ --infodir=DIR info documentation in DIR [PREFIX/info]
+ --mandir=DIR man documentation in DIR [PREFIX/man]
+ --srcdir=DIR find the sources in DIR [configure dir or ..]
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM
+ run sed PROGRAM on installed program names
+EOF
+ cat << EOF
+Host type:
+ --build=BUILD configure for building on BUILD [BUILD=HOST]
+ --host=HOST configure for HOST [guessed]
+ --target=TARGET configure for TARGET [TARGET=HOST]
+Features and packages:
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --x-includes=DIR X include files are in DIR
+ --x-libraries=DIR X library files are in DIR
+EOF
+ if test -n "$ac_help"; then
+ echo "--enable and --with options recognized:$ac_help"
+ fi
+ exit 0 ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host="$ac_optarg" ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir="$ac_optarg" ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir="$ac_optarg" ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir="$ac_optarg" ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir="$ac_optarg" ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+ | --locals | --local | --loca | --loc | --lo)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+ localstatedir="$ac_optarg" ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir="$ac_optarg" ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir="$ac_optarg" ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix="$ac_optarg" ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix="$ac_optarg" ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix="$ac_optarg" ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name="$ac_optarg" ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir="$ac_optarg" ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir="$ac_optarg" ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site="$ac_optarg" ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir="$ac_optarg" ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir="$ac_optarg" ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target="$ac_optarg" ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers)
+ echo "configure generated by autoconf version 2.10"
+ exit 0 ;;
+
+ -with-* | --with-*)
+ ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "with_${ac_package}='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+ ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ eval "with_${ac_package}=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes="$ac_optarg" ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries="$ac_optarg" ;;
+
+ -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
+ ;;
+
+ *)
+ if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+ echo "configure: warning: $ac_option: invalid host type" 1>&2
+ fi
+ if test "x$nonopt" != xNONE; then
+ { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
+ fi
+ nonopt="$ac_option"
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
+fi
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+# File descriptor usage:
+# 0 standard input
+# 1 file creation
+# 2 errors and warnings
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 6 checking for... messages and results
+# 5 compiler messages saved in config.log
+if test "$silent" = yes; then
+ exec 6>/dev/null
+else
+ exec 6>&1
+fi
+exec 5>./config.log
+
+echo "\
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+" 1>&5
+
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Also quote any args containing shell metacharacters.
+ac_configure_args=
+for ac_arg
+do
+ case "$ac_arg" in
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c) ;;
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+ ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ *) ac_configure_args="$ac_configure_args $ac_arg" ;;
+ esac
+done
+
+# NLS nuisances.
+# Only set LANG and LC_ALL to C if already set.
+# These must not be set unconditionally because not all systems understand
+# e.g. LANG=C (notably SCO).
+if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+if test "${LANG+set}" = set; then LANG=C; export LANG; fi
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo > confdefs.h
+
+# A filename unique to this package, relative to the directory that
+# configure is in, which we can look for to find out if srcdir is correct.
+ac_unique_file=config.flags.in
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+ ac_prog=$0
+ ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+ test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+ { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
+ else
+ { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
+ fi
+fi
+srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
+
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+ else
+ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+ fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+ echo "loading site script $ac_site_file"
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ echo "loading cache $cache_file"
+ . $cache_file
+else
+ echo "creating cache $cache_file"
+ > $cache_file
+fi
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+ # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+ if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+ ac_n= ac_c='
+' ac_t=' '
+ else
+ ac_n=-n ac_c= ac_t=
+ fi
+else
+ ac_n= ac_c='\c' ac_t=
+fi
+
+
+# Check whether --enable-dce-compat or --disable-dce-compat was given.
+if test "${enable_dce_compat+set}" = set; then
+ enableval="$enable_dce_compat"
+ { echo "configure: error: Actually, DCE compatibility doesn't work yet..." 1>&2; exit 1; }
+
+else
+ true
+
+fi
+
+
+# Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="gcc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ ac_prog_rejected=no
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# -gt 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ set dummy "$ac_dir/$ac_word" "$@"
+ shift
+ ac_cv_prog_CC="$@"
+ fi
+fi
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.c <<EOF
+#ifdef __GNUC__
+ yes;
+#endif
+EOF
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:616: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+ ac_cv_prog_gcc=yes
+else
+ ac_cv_prog_gcc=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gcc" 1>&6
+if test $ac_cv_prog_gcc = yes; then
+ GCC=yes
+ if test "${CFLAGS+set}" != set; then
+ echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_prog_gcc_g'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ echo 'void f(){}' > conftest.c
+if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
+ ac_cv_prog_gcc_g=yes
+else
+ ac_cv_prog_gcc_g=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_prog_gcc_g" 1>&6
+ if test $ac_cv_prog_gcc_g = yes; then
+ CFLAGS="-g -O"
+ else
+ CFLAGS="-O"
+ fi
+ fi
+else
+ GCC=
+ test "${CFLAGS+set}" = set || CFLAGS="-g"
+fi
+
+for ac_prog in $CCC c++ g++ gcc CC cxx
+do
+# Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CXX"; then
+ ac_cv_prog_CXX="$CXX" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CXX="$ac_prog"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CXX="$ac_cv_prog_CXX"
+if test -n "$CXX"; then
+ echo "$ac_t""$CXX" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+test -n "$CXX" && break
+done
+test -n "$CXX" || CXX="gcc"
+
+
+echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.C <<EOF
+#ifdef __GNUC__
+ yes;
+#endif
+EOF
+if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:696: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+ ac_cv_prog_gxx=yes
+else
+ ac_cv_prog_gxx=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gxx" 1>&6
+if test $ac_cv_prog_gxx = yes; then
+ GXX=yes
+ if test "${CXXFLAGS+set}" != set; then
+ echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_prog_gxx_g'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ echo 'void f(){}' > conftest.cc
+if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then
+ ac_cv_prog_gxx_g=yes
+else
+ ac_cv_prog_gxx_g=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_prog_gxx_g" 1>&6
+ if test $ac_cv_prog_gxx_g = yes; then
+ CXXFLAGS="-g -O"
+ else
+ CXXFLAGS="-O"
+ fi
+ fi
+else
+ GXX=
+ test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
+fi
+
+echo $ac_n "checking compiler availability and simple error detection""... $ac_c" 1>&6
+cat > conftest.$ac_ext <<EOF
+#line 735 "configure"
+#include "confdefs.h"
+
+int main() { return 0; }
+int t() {
+ exit(0);
+; return 0; }
+EOF
+if { (eval echo configure:743: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+
+ cat > conftest.$ac_ext <<EOF
+#line 747 "configure"
+#include "confdefs.h"
+
+int main() { return 0; }
+int t() {
+ syntax errors galore!
+; return 0; }
+EOF
+if { (eval echo configure:755: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ { echo "configure: error: Can't detect syntax errors! Is CC set right?" 1>&2; exit 1; }
+else
+ rm -rf conftest*
+ true
+fi
+rm -f conftest*
+
+else
+ rm -rf conftest*
+ { echo "configure: error: Can't compile test program! Is CC set right?" 1>&2; exit 1; }
+fi
+rm -f conftest*
+
+
+cat > conftest.$ac_ext <<EOF
+#line 772 "configure"
+#include "confdefs.h"
+
+int main() { return 0; }
+int t() {
+
+ typedef int Integer;
+ extern int i;
+ extern Integer i;
+
+; return 0; }
+EOF
+if { (eval echo configure:784: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ :
+else
+ rm -rf conftest*
+ { echo "configure: error: Can't redeclare variables with this compiler??" 1>&2; exit 1; }
+fi
+rm -f conftest*
+
+cat > conftest.$ac_ext <<EOF
+#line 793 "configure"
+#include "confdefs.h"
+
+int main() { return 0; }
+int t() {
+
+ typedef long Long;
+ extern int i;
+ extern Long i;
+
+; return 0; }
+EOF
+if { (eval echo configure:805: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ { echo "configure: error: Compiler doesn't detect conflicting declarations." 1>&2; exit 1; }
+fi
+rm -f conftest*
+
+echo "$ac_t""ok" 1>&6
+
+if test $ac_cv_prog_gcc = yes ; then
+ CFLAGS="$CFLAGS -Werror"
+fi
+
+echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ # This must be in double quotes, not single quotes, because CPP may get
+ # substituted into the Makefile and "${CC-cc}" will confuse make.
+ CPP="${CC-cc} -E"
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp.
+ cat > conftest.$ac_ext <<EOF
+#line 832 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:838: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -E -traditional-cpp"
+ cat > conftest.$ac_ext <<EOF
+#line 847 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:853: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ rm -rf conftest*
+ CPP=/lib/cpp
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+ ac_cv_prog_CPP="$CPP"
+fi
+ CPP="$ac_cv_prog_CPP"
+else
+ ac_cv_prog_CPP="$CPP"
+fi
+echo "$ac_t""$CPP" 1>&6
+
+
+# Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_RANLIB="ranlib"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
+fi
+fi
+RANLIB="$ac_cv_prog_RANLIB"
+if test -n "$RANLIB"; then
+ echo "$ac_t""$RANLIB" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+
+
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+ if test -f $ac_dir/install-sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f $ac_dir/install.sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
+fi
+ac_config_guess=$ac_aux_dir/config.guess
+ac_config_sub=$ac_aux_dir/config.sub
+ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+
+
+# Do some error checking and defaulting for the host and target type.
+# The inputs are:
+# configure --host=HOST --target=TARGET --build=BUILD NONOPT
+#
+# The rules are:
+# 1. You are not allowed to specify --host, --target, and nonopt at the
+# same time.
+# 2. Host defaults to nonopt.
+# 3. If nonopt is not specified, then host defaults to the current host,
+# as determined by config.guess.
+# 4. Target and build default to nonopt.
+# 5. If nonopt is not specified, then target and build default to host.
+
+# The aliases save the names the user supplied, while $host etc.
+# will get canonicalized.
+case $host---$target---$nonopt in
+NONE---*---* | *---NONE---* | *---*---NONE) ;;
+*) { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } ;;
+esac
+
+
+# Make sure we can run config.sub.
+if $ac_config_sub sun4 >/dev/null 2>&1; then :
+else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking host system type""... $ac_c" 1>&6
+
+host_alias=$host
+case "$host_alias" in
+NONE)
+ case $nonopt in
+ NONE)
+ if host_alias=`$ac_config_guess`; then :
+ else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
+ fi ;;
+ *) host_alias=$nonopt ;;
+ esac ;;
+esac
+
+host=`$ac_config_sub $host_alias`
+host_cpu=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
+host_vendor=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
+host_os=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
+echo "$ac_t""$host" 1>&6
+
+echo $ac_n "checking target system type""... $ac_c" 1>&6
+
+target_alias=$target
+case "$target_alias" in
+NONE)
+ case $nonopt in
+ NONE) target_alias=$host_alias ;;
+ *) target_alias=$nonopt ;;
+ esac ;;
+esac
+
+target=`$ac_config_sub $target_alias`
+target_cpu=`echo $target | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
+target_vendor=`echo $target | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
+target_os=`echo $target | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
+echo "$ac_t""$target" 1>&6
+
+echo $ac_n "checking build system type""... $ac_c" 1>&6
+
+build_alias=$build
+case "$build_alias" in
+NONE)
+ case $nonopt in
+ NONE) build_alias=$host_alias ;;
+ *) build_alias=$nonopt ;;
+ esac ;;
+esac
+
+build=`$ac_config_sub $build_alias`
+build_cpu=`echo $build | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
+build_vendor=`echo $build | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
+build_os=`echo $build | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
+echo "$ac_t""$build" 1>&6
+
+test "$host_alias" != "$target_alias" &&
+ test "$program_prefix$program_suffix$program_transform_name" = \
+ NONENONEs,x,x, &&
+ program_prefix=${target_alias}-
+
+
+syscall=NONE
+sysincludes=NONE
+
+# Treat all x86 machines the same.
+# (Yet below, we pretend we can distinguish between the MIPS r2000 and r4000?)
+# (What about 680x0 machines?)
+case $host in
+ i[456]86-*)
+ host=`echo $host | sed 's/^i[456]86/i386/'`
+ host_cpu=i386
+ ;;
+esac
+
+# Here, you should set the following variables:
+# name
+# The "name" of this configuration. Used for "engine-*.c" file name,
+# default for syscall file names. Chris seems to have a thing for
+# putting "-" between OS and version number, but the configure script
+# will already have $host_cpu and $host_os available for you to use
+# in constructing a name.
+# sysincludes
+# Name of machdep directory with "sys" include file
+# replacements, if any. This directory is optional;
+# if you don't provide it, don't set this variable.
+# except
+# Names of any syscalls that shouldn't be generated
+# from the template, if any.
+# syscall
+# Base name of the syscall template files, if not the
+# same as <name>. If they're the same, omit this.
+#
+# Also, you may define random symbols and update CFLAGS if
+# necessary. However, for ease of porting to new machines,
+# it's best if you can create portable autoconf tests for
+# whatever you're trying to do, rather than hard-coding it
+# here based on the OS name. So please, try to keep this
+# section as minimal as possible.
+
+except=""
+name=$host_cpu-$host_os
+
+case $host in
+ alpha-*-netbsd1.1* | alpha-*-netbsd1.2*)
+ name=alpha-netbsd-1.1
+ sysincludes=netbsd-1.1
+ except="fork lseek pipe sigsuspend sigprocmask"
+ ;;
+ alpha-*-osf*)
+ name=alpha-osf1
+ sysincludes=alpha-osf1
+ except="fork sigsuspend"
+ if test $ac_cv_prog_gcc = no ; then
+ CFLAGS="$CFLAGS -std"
+ fi
+ ;;
+ hppa1.1-*-hpux*)
+ name=hppa-hpux-9.03
+ sysincludes=hpux-9.03
+ # hpux-9.03.mk seems to be missing; what should this be?
+ except="fork"
+ ;;
+ sparc-*-sunos4.1.3* | sparc-*-sunos4.1.4*)
+ name=sparc-sunos-4.1.3
+ sysincludes=sunos-4.1.3
+ syscall=sparc-sunos4
+ except="fork pipe getpgrp getdirentries"
+ cat >> confdefs.h <<\EOF
+#define sunos4 1
+EOF
+ # is this really needed??
+ ;;
+ sparc-*-solaris2*)
+ name=sparc-sunos-5.3
+ sysincludes=sunos-5.3
+ except="fork sigaction"
+ # Should really come up with a test for this...
+ cat >> confdefs.h <<\EOF
+#define LD_LINKS_STATIC_DATA 1
+EOF
+
+ cat >> confdefs.h <<\EOF
+#define BROKEN_SIGNALS 1
+EOF
+
+ ;;
+ sparc-*-netbsd1.0A | sparc-*-netbsd1.1* | sparc-*-netbsd1.2*)
+ name=sparc-sunos-4.1.3
+ sysincludes=netbsd-1.0
+ syscall=sparc-netbsd-1.1
+ except="pipe fork sigprocmask sigsuspend"
+ ;;
+ i386-*-linux*)
+ name=i386-linux-1.0
+ sysincludes=linux-1.0
+ ;;
+ i386-*-bsdi1.1)
+ name=i386-bsdi-1.1
+ sysincludes=bsdi-1.1
+ ;;
+ i386-*-bsdi2.0* | i386-*-bsdi2.1*)
+ name=i386-bsdi-2.0
+ sysincludes=bsdi-2.0
+ syscall=i386-bsdi-2.0
+ except="fork lseek sigsuspend"
+ ;;
+ i386-*-netbsd1.1* | i386-*-netbsd1.2*)
+ name=i386-netbsd-1.0
+ sysincludes=netbsd-1.1
+ syscall=i386-netbsd-1.1
+ except="fork lseek pipe sigsuspend sigprocmask"
+ ;;
+ i386-*-netbsd1.0*)
+ name=i386-netbsd-1.0
+ sysincludes=netbsd-1.0
+ except="fork lseek sigsuspend"
+ ;;
+ i386-*-netbsd0.9*)
+ name=i386-netbsd-0.9
+ sysincludes=netbsd-0.9
+ ;;
+ m68*-*-netbsd*)
+ name=m68000-netbsd
+ ;;
+ i386-*-freebsd2.*)
+ name=i386-freebsd-2.0
+ sysincludes=freebsd-2.0
+ except="fork lseek sigsuspend sigprocmask"
+ ;;
+ romp-*-bsd*)
+ name=romp-bsd
+ ;;
+ mips-dec-ultrix*)
+ name=r2000-ultrix-4.2
+ sysincludes=ultrix-4.2
+ except="fork pipe"
+ ;;
+ mips-sgi-irix*)
+ name=ip22-irix-5.2
+ sysincludes=irix-5.2
+ except="fstat stat"
+ cat >> confdefs.h <<\EOF
+#define BROKEN_SIGNALS 1
+EOF
+
+ ;;
+ *)
+ { echo "configure: error: System type $host not recognized or not supported.
+See $srcdir/configure.in for supported systems." 1>&2; exit 1; }
+ exit 1
+ ;;
+esac
+
+SYSCALL_EXCEPTIONS=$except
+
+
+for ac_hdr in sys/termio.h termios.h termio.h
+do
+ac_safe=`echo "$ac_hdr" | tr './\055' '___'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1174 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1179: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | tr 'abcdefghijklmnopqrstuvwxyz./\055' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ___'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+ac_safe=`echo "va_list.h" | tr './\055' '___'`
+echo $ac_n "checking for va_list.h""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1210 "configure"
+#include "confdefs.h"
+#include <va_list.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1215: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ cat >> confdefs.h <<\EOF
+#define pthread_have_va_list_h 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+for ac_hdr in syscall.h sys/syscall.h
+do
+ac_safe=`echo "$ac_hdr" | tr './\055' '___'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1246 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1251: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | tr 'abcdefghijklmnopqrstuvwxyz./\055' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ___'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+pthreads_syscall_list="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
+ sigsuspend sigaction sigpause sigprocmask ksigaction
+ getdents readdir getdirentries
+ wait4 wait3 waitpid waitsys
+ socket bind connect accept listen getsockopt setsockopt socketpair
+ poll putmsg getmsg
+ socketcall
+
+ pgrpsys
+
+ exit
+ readv writev send sendto sendmsg recv recvfrom recvmsg
+ getpeername getsockname
+ shutdown
+ getpgrp fork"
+for pthreads_syscallname in $pthreads_syscall_list ; do
+ echo $ac_n "checking for syscall $pthreads_syscallname""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'pthreads_cv_syscall_$pthreads_syscallname'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1299 "configure"
+#include "confdefs.h"
+
+/* FIXME: This list should be generated from info in configure.in. */
+#ifdef HAVE_SYSCALL_H
+#include <syscall.h>
+#else
+#ifdef HAVE_SYS_SYSCALL_H
+#include <sys/syscall.h>
+#else
+where is your syscall header file??
+#endif
+#endif
+
+int main() { return 0; }
+int t() {
+
+int x;
+x = SYS_$pthreads_syscallname ;
+
+; return 0; }
+EOF
+if { (eval echo configure:1321: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+ rm -rf conftest*
+ eval pthreads_cv_syscall_$pthreads_syscallname=yes
+else
+ rm -rf conftest*
+ eval pthreads_cv_syscall_$pthreads_syscallname=no
+fi
+rm -f conftest*
+
+fi
+
+if eval test \$pthreads_cv_syscall_$pthreads_syscallname = yes ; then
+ pthreads_syscall_present=yes
+ available_syscalls="$available_syscalls $pthreads_syscallname"
+ macroname=HAVE_SYSCALL_`echo $pthreads_syscallname | tr '[a-z]' '[A-Z]'`
+ cat >> confdefs.h <<EOF
+#define $macroname 1
+EOF
+
+else
+ pthreads_syscall_present=no
+ missing_syscalls="$missing_syscalls $pthreads_syscallname"
+fi
+echo "$ac_t""$pthreads_syscall_present" 1>&6
+
+done
+
+
+
+
+
+
+## Determine some typedef values from the system header files.
+# If we cannot run a trivial program, we must be cross compiling.
+echo $ac_n "checking whether cross-compiling""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_c_cross'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ ac_cv_c_cross=yes
+else
+cat > conftest.$ac_ext <<EOF
+#line 1363 "configure"
+#include "confdefs.h"
+main(){return(0);}
+EOF
+{ (eval echo configure:1367: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
+if test -s conftest && (./conftest; exit) 2>/dev/null; then
+ ac_cv_c_cross=no
+else
+ ac_cv_c_cross=yes
+fi
+fi
+rm -fr conftest*
+fi
+
+echo "$ac_t""$ac_cv_c_cross" 1>&6
+cross_compiling=$ac_cv_c_cross
+
+echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1385 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1393: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ ac_cv_header_stdc=yes
+else
+ echo "$ac_err" >&5
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 1408 "configure"
+#include "confdefs.h"
+#include <string.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "memchr" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 1426 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "free" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+if test "$cross_compiling" = yes; then
+ :
+else
+cat > conftest.$ac_ext <<EOF
+#line 1447 "configure"
+#include "confdefs.h"
+#include <ctype.h>
+#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int main () { int i; for (i = 0; i < 256; i++)
+if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
+exit (0); }
+
+EOF
+{ (eval echo configure:1458: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
+if test -s conftest && (./conftest; exit) 2>/dev/null; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+fi
+rm -fr conftest*
+fi
+fi
+
+echo "$ac_t""$ac_cv_header_stdc" 1>&6
+if test $ac_cv_header_stdc = yes; then
+ cat >> confdefs.h <<\EOF
+#define STDC_HEADERS 1
+EOF
+
+fi
+
+echo $ac_n "checking for off_t""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1482 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "off_t" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_off_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_off_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_off_t" 1>&6
+if test $ac_cv_type_off_t = no; then
+ cat >> confdefs.h <<\EOF
+#define off_t long
+EOF
+
+fi
+
+echo $ac_n "checking for size_t""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1513 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "size_t" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_size_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_size_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_size_t" 1>&6
+if test $ac_cv_type_size_t = no; then
+ cat >> confdefs.h <<\EOF
+#define size_t unsigned
+EOF
+
+fi
+
+echo $ac_n "checking for ssize_t""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_type_ssize_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1544 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "ssize_t" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_ssize_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_ssize_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_ssize_t" 1>&6
+if test $ac_cv_type_ssize_t = no; then
+ cat >> confdefs.h <<\EOF
+#define ssize_t int
+EOF
+
+fi
+
+echo $ac_n "checking for time_t""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_type_time_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1575 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "time_t" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_time_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_time_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_time_t" 1>&6
+if test $ac_cv_type_time_t = no; then
+ cat >> confdefs.h <<\EOF
+#define time_t long
+EOF
+
+fi
+
+for ac_hdr in sys/time.h
+do
+ac_safe=`echo "$ac_hdr" | tr './\055' '___'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1609 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1614: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | tr 'abcdefghijklmnopqrstuvwxyz./\055' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ___'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1643 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
+int main() { return 0; }
+int t() {
+struct tm *tp;
+; return 0; }
+EOF
+if { (eval echo configure:1653: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_header_time=yes
+else
+ rm -rf conftest*
+ ac_cv_header_time=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_header_time" 1>&6
+if test $ac_cv_header_time = yes; then
+ cat >> confdefs.h <<\EOF
+#define TIME_WITH_SYS_TIME 1
+EOF
+
+fi
+
+
+echo $ac_n "checking for struct timespec in sys/time.h""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'pthreads_cv_timespec_in_time'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1678 "configure"
+#include "confdefs.h"
+#include <sys/time.h>
+int main() { return 0; }
+int t() {
+struct timespec foo;
+; return 0; }
+EOF
+if { (eval echo configure:1686: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ pthreads_cv_timespec_in_time=yes
+else
+ rm -rf conftest*
+ pthreads_cv_timespec_in_time=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$pthreads_cv_timespec_in_time" 1>&6
+if test $pthreads_cv_timespec_in_time = yes ; then
+ cat >> confdefs.h <<\EOF
+#define _OS_HAS_TIMESPEC 1
+EOF
+
+fi
+
+
+
+echo $ac_n "checking type of size_t""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'pthreads_cv_type_size_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1712 "configure"
+#include "confdefs.h"
+
+#include <stddef.h>
+#include <sys/types.h>
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif
+
+int main() { return 0; }
+int t() {
+ extern size_t foo;
+; return 0; }
+EOF
+if { (eval echo configure:1726: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ for try_type in "int" "unsigned int" "long" "unsigned long" "short" "unsigned short" "char" "unsigned char" "long long" "unsigned long long" ; do
+ cat > conftest.$ac_ext <<EOF
+#line 1730 "configure"
+#include "confdefs.h"
+
+#include <stddef.h>
+#include <sys/types.h>
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif
+
+int main() { return 0; }
+int t() {
+ extern size_t foo; extern $try_type foo;
+; return 0; }
+EOF
+if { (eval echo configure:1744: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ pthreads_cv_type_size_t="$try_type" ; break
+fi
+rm -f conftest*
+
+ done
+else
+ rm -rf conftest*
+ { echo "configure: error: Can't find system typedef for size_t." 1>&2; exit 1; }
+fi
+rm -f conftest*
+
+fi
+
+if test -n "$pthreads_cv_type_size_t" ; then
+ cat >> confdefs.h <<EOF
+#define pthread_size_t $pthreads_cv_type_size_t
+EOF
+
+fi
+pthread_size_t=$pthreads_cv_type_size_t
+echo "$ac_t""$pthreads_cv_type_size_t" 1>&6
+
+echo $ac_n "checking type of ssize_t""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'pthreads_cv_type_ssize_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1773 "configure"
+#include "confdefs.h"
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int main() { return 0; }
+int t() {
+ extern ssize_t foo;
+; return 0; }
+EOF
+if { (eval echo configure:1785: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ for try_type in "int" "unsigned int" "long" "unsigned long" "short" "unsigned short" "char" "unsigned char" "long long" "unsigned long long" ; do
+ cat > conftest.$ac_ext <<EOF
+#line 1789 "configure"
+#include "confdefs.h"
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int main() { return 0; }
+int t() {
+ extern ssize_t foo; extern $try_type foo;
+; return 0; }
+EOF
+if { (eval echo configure:1801: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ pthreads_cv_type_ssize_t="$try_type" ; break
+fi
+rm -f conftest*
+
+ done
+else
+ rm -rf conftest*
+ { echo "configure: error: Can't find system typedef for ssize_t." 1>&2; exit 1; }
+fi
+rm -f conftest*
+
+fi
+
+if test -n "$pthreads_cv_type_ssize_t" ; then
+ cat >> confdefs.h <<EOF
+#define pthread_ssize_t $pthreads_cv_type_ssize_t
+EOF
+
+fi
+pthread_ssize_t=$pthreads_cv_type_ssize_t
+echo "$ac_t""$pthreads_cv_type_ssize_t" 1>&6
+
+echo $ac_n "checking type of clock_t""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'pthreads_cv_type_clock_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1830 "configure"
+#include "confdefs.h"
+
+#include <stddef.h>
+#if TIME_WITH_SYS_TIME
+# include <time.h>
+# include <sys/time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+int main() { return 0; }
+int t() {
+ extern clock_t foo;
+; return 0; }
+EOF
+if { (eval echo configure:1850: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ for try_type in "int" "unsigned int" "long" "unsigned long" "short" "unsigned short" "char" "unsigned char" "long long" "unsigned long long" ; do
+ cat > conftest.$ac_ext <<EOF
+#line 1854 "configure"
+#include "confdefs.h"
+
+#include <stddef.h>
+#if TIME_WITH_SYS_TIME
+# include <time.h>
+# include <sys/time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+int main() { return 0; }
+int t() {
+ extern clock_t foo; extern $try_type foo;
+; return 0; }
+EOF
+if { (eval echo configure:1874: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ pthreads_cv_type_clock_t="$try_type" ; break
+fi
+rm -f conftest*
+
+ done
+else
+ rm -rf conftest*
+ { echo "configure: error: Can't find system typedef for clock_t." 1>&2; exit 1; }
+fi
+rm -f conftest*
+
+fi
+
+if test -n "$pthreads_cv_type_clock_t" ; then
+ cat >> confdefs.h <<EOF
+#define pthread_clock_t $pthreads_cv_type_clock_t
+EOF
+
+fi
+pthread_clock_t=$pthreads_cv_type_clock_t
+echo "$ac_t""$pthreads_cv_type_clock_t" 1>&6
+
+echo $ac_n "checking type of time_t""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'pthreads_cv_type_time_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1903 "configure"
+#include "confdefs.h"
+
+#include <stddef.h>
+#if TIME_WITH_SYS_TIME
+# include <time.h>
+# include <sys/time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+int main() { return 0; }
+int t() {
+ extern time_t foo;
+; return 0; }
+EOF
+if { (eval echo configure:1923: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ for try_type in "int" "unsigned int" "long" "unsigned long" "short" "unsigned short" "char" "unsigned char" "long long" "unsigned long long" ; do
+ cat > conftest.$ac_ext <<EOF
+#line 1927 "configure"
+#include "confdefs.h"
+
+#include <stddef.h>
+#if TIME_WITH_SYS_TIME
+# include <time.h>
+# include <sys/time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+int main() { return 0; }
+int t() {
+ extern time_t foo; extern $try_type foo;
+; return 0; }
+EOF
+if { (eval echo configure:1947: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ pthreads_cv_type_time_t="$try_type" ; break
+fi
+rm -f conftest*
+
+ done
+else
+ rm -rf conftest*
+ { echo "configure: error: Can't find system typedef for time_t." 1>&2; exit 1; }
+fi
+rm -f conftest*
+
+fi
+
+if test -n "$pthreads_cv_type_time_t" ; then
+ cat >> confdefs.h <<EOF
+#define pthread_time_t $pthreads_cv_type_time_t
+EOF
+
+fi
+pthread_time_t=$pthreads_cv_type_time_t
+echo "$ac_t""$pthreads_cv_type_time_t" 1>&6
+echo $ac_n "checking for fpos_t in stdio.h""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'pthreads_cv_fpos_t_in_stdio'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1975 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+int main() { return 0; }
+int t() {
+fpos_t position;
+; return 0; }
+EOF
+if { (eval echo configure:1983: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ pthreads_cv_fpos_t_in_stdio=yes
+else
+ rm -rf conftest*
+ pthreads_cv_fpos_t_in_stdio=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$pthreads_cv_fpos_t_in_stdio" 1>&6
+if test $pthreads_cv_fpos_t_in_stdio = yes ; then
+
+echo $ac_n "checking type of fpos_t""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'pthreads_cv_type_fpos_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2002 "configure"
+#include "confdefs.h"
+
+#include <stdio.h>
+#include <sys/types.h>
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif
+
+int main() { return 0; }
+int t() {
+ extern fpos_t foo;
+; return 0; }
+EOF
+if { (eval echo configure:2016: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ for try_type in "int" "unsigned int" "long" "unsigned long" "short" "unsigned short" "char" "unsigned char" "long long" "unsigned long long" ; do
+ cat > conftest.$ac_ext <<EOF
+#line 2020 "configure"
+#include "confdefs.h"
+
+#include <stdio.h>
+#include <sys/types.h>
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif
+
+int main() { return 0; }
+int t() {
+ extern fpos_t foo; extern $try_type foo;
+; return 0; }
+EOF
+if { (eval echo configure:2034: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ pthreads_cv_type_fpos_t="$try_type" ; break
+fi
+rm -f conftest*
+
+ done
+else
+ rm -rf conftest*
+ { echo "configure: error: Can't find system typedef for fpos_t." 1>&2; exit 1; }
+fi
+rm -f conftest*
+
+fi
+
+if test -n "$pthreads_cv_type_fpos_t" ; then
+ cat >> confdefs.h <<EOF
+#define pthread_fpos_t $pthreads_cv_type_fpos_t
+EOF
+
+fi
+pthread_fpos_t=$pthreads_cv_type_fpos_t
+echo "$ac_t""$pthreads_cv_type_fpos_t" 1>&6
+else
+ cat >> confdefs.h <<\EOF
+#define fpos_t off_t
+EOF
+
+ cat >> confdefs.h <<\EOF
+#define pthread_fpos_t pthread_off_t
+EOF
+
+fi
+
+echo $ac_n "checking type of off_t""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'pthreads_cv_type_off_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2073 "configure"
+#include "confdefs.h"
+
+#include <stdio.h>
+#include <sys/types.h>
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif
+
+int main() { return 0; }
+int t() {
+ extern off_t foo;
+; return 0; }
+EOF
+if { (eval echo configure:2087: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ for try_type in "int" "unsigned int" "long" "unsigned long" "short" "unsigned short" "char" "unsigned char" "long long" "unsigned long long" ; do
+ cat > conftest.$ac_ext <<EOF
+#line 2091 "configure"
+#include "confdefs.h"
+
+#include <stdio.h>
+#include <sys/types.h>
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif
+
+int main() { return 0; }
+int t() {
+ extern off_t foo; extern $try_type foo;
+; return 0; }
+EOF
+if { (eval echo configure:2105: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ pthreads_cv_type_off_t="$try_type" ; break
+fi
+rm -f conftest*
+
+ done
+else
+ rm -rf conftest*
+ { echo "configure: error: Can't find system typedef for off_t." 1>&2; exit 1; }
+fi
+rm -f conftest*
+
+fi
+
+if test -n "$pthreads_cv_type_off_t" ; then
+ cat >> confdefs.h <<EOF
+#define pthread_off_t $pthreads_cv_type_off_t
+EOF
+
+fi
+pthread_off_t=$pthreads_cv_type_off_t
+echo "$ac_t""$pthreads_cv_type_off_t" 1>&6
+echo $ac_n "checking type of va_list""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'pthreads_cv_type_va_list'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2133 "configure"
+#include "confdefs.h"
+#include <stdarg.h>
+int main() { return 0; }
+int t() {
+ extern va_list foo;
+; return 0; }
+EOF
+if { (eval echo configure:2141: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ for try_type in "char *" "char **" "void *" "void **" "int *" "long *" ; do
+ cat > conftest.$ac_ext <<EOF
+#line 2145 "configure"
+#include "confdefs.h"
+#include <stdarg.h>
+int main() { return 0; }
+int t() {
+ extern va_list foo; extern $try_type foo;
+; return 0; }
+EOF
+if { (eval echo configure:2153: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ pthreads_cv_type_va_list="$try_type" ; break
+fi
+rm -f conftest*
+
+ done
+else
+ rm -rf conftest*
+ { echo "configure: error: Can't find system typedef for va_list." 1>&2; exit 1; }
+fi
+rm -f conftest*
+
+fi
+
+if test -n "$pthreads_cv_type_va_list" ; then
+ cat >> confdefs.h <<EOF
+#define pthread_va_list $pthreads_cv_type_va_list
+EOF
+
+fi
+pthread_va_list=$pthreads_cv_type_va_list
+echo "$ac_t""$pthreads_cv_type_va_list" 1>&6
+
+arpa_headers="#include <sys/types.h>
+#include <arpa/nameser.h>"
+
+echo $ac_n "checking IP address type""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'pthread_cv_type_ipaddr'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2185 "configure"
+#include "confdefs.h"
+$arpa_headers
+int main() { return 0; }
+int t() {
+ &_getlong;
+; return 0; }
+EOF
+if { (eval echo configure:2193: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+
+ for type in "unsigned long" "unsigned int" ; do
+ cat > conftest.$ac_ext <<EOF
+#line 2198 "configure"
+#include "confdefs.h"
+$arpa_headers
+int main() { return 0; }
+int t() {
+extern $type _getlong ();
+; return 0; }
+EOF
+if { (eval echo configure:2206: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+
+ pthread_cv_type_ipaddr="$type"
+ break
+
+fi
+rm -f conftest*
+
+ done
+
+else
+ rm -rf conftest*
+ echo "configure: warning: Can't compile _getlong reference." 1>&2
+fi
+rm -f conftest*
+
+ if test "$pthread_cv_type_ipaddr" = "" ; then
+ echo "configure: warning: Can't determine _getlong return type." 1>&2
+ echo "configure: warning: Defaulting to unsigned long." 1>&2
+ pthread_cv_type_ipaddr="unsigned long"
+ fi
+
+fi
+
+echo "$ac_t""$pthread_cv_type_ipaddr" 1>&6
+cat >> confdefs.h <<EOF
+#define pthread_ipaddr_type $pthread_cv_type_ipaddr
+EOF
+
+
+echo $ac_n "checking IP port type""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'pthread_cv_type_ipport'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2242 "configure"
+#include "confdefs.h"
+$arpa_headers
+int main() { return 0; }
+int t() {
+ &_getshort;
+; return 0; }
+EOF
+if { (eval echo configure:2250: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+
+ for type in "unsigned short" "unsigned int" ; do
+ cat > conftest.$ac_ext <<EOF
+#line 2255 "configure"
+#include "confdefs.h"
+$arpa_headers
+int main() { return 0; }
+int t() {
+extern $type _getshort ();
+; return 0; }
+EOF
+if { (eval echo configure:2263: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+
+ pthread_cv_type_ipport="$type"
+ break
+
+fi
+rm -f conftest*
+
+ done
+
+else
+ rm -rf conftest*
+ echo "configure: warning: Can't compile _getshort reference." 1>&2
+fi
+rm -f conftest*
+
+ if test "$pthread_cv_type_ipport" = "" ; then
+ echo "configure: warning: Can't determine _getshort return type." 1>&2
+ echo "configure: warning: Defaulting to unsigned short." 1>&2
+ pthread_cv_type_ipport="unsigned short"
+ fi
+
+fi
+
+echo "$ac_t""$pthread_cv_type_ipport" 1>&6
+cat >> confdefs.h <<EOF
+#define pthread_ipport_type $pthread_cv_type_ipport
+EOF
+
+
+echo $ac_n "checking pathname for terminal devices directory""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'pthread_cv_pty_path'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -d /devices/pseudo ; then
+ pty_path=/devices/pseudo/
+ else
+ pty_path=/dev/
+ fi
+ pthread_cv_pty_path=$pty_path
+
+fi
+
+cat >> confdefs.h <<EOF
+#define _PATH_PTY "$pthread_cv_pty_path"
+EOF
+
+echo "$ac_t""$pthread_cv_pty_path" 1>&6
+
+echo $ac_n "checking directory name for time zone info""... $ac_c" 1>&6
+tzdir=NONE
+for f in /usr/lib/zoneinfo /usr/share/zoneinfo /usr/share/lib/zoneinfo /etc/zoneinfo /usr/local/lib/zoneinfo
+do
+ if test -d $f ; then
+ tzdir=$f
+ break
+ fi
+done
+case $tzdir in
+NONE)
+ echo "configure: warning: Can't find zoneinfo directory." 1>&2
+ echo "configure: warning: Defaulting zoneinfo directory to NULL." 1>&2
+ tzdir=NULL
+ ;;
+esac
+cat >> confdefs.h <<EOF
+#define _PATH_TZDIR "$tzdir"
+EOF
+
+echo "$ac_t""$tzdir" 1>&6
+
+echo $ac_n "checking filename for local time zone""... $ac_c" 1>&6
+tzfile=NONE
+for f in $tzdir/localtime /etc/localtime
+do
+ if test -f $f ; then
+ tzfile=$f
+ break
+ fi
+done
+case $tzfile in
+NONE) # Should this default to tzdir/localtime?
+ echo "configure: warning: Can't find local time zone file." 1>&2
+ if test tzdir = NULL ; then
+ echo "configure: warning: Defaulting local time zone file to NULL" 1>&2
+ tzfile=NULL
+ else
+ echo "configure: warning: Defaulting local time zone file to $tzdir/localtime." 1>&2
+ tzfile=$tzdir/localtime
+ fi
+ ;;
+esac
+cat >> confdefs.h <<EOF
+#define _PATH_TZFILE "$tzfile"
+EOF
+
+echo "$ac_t""$tzfile" 1>&6
+
+cat >> confdefs.h <<\EOF
+#define _PATH_RESCONF "/etc/resolv.conf"
+EOF
+
+cat >> confdefs.h <<\EOF
+#define _PATH_HOSTS "/etc/hosts"
+EOF
+
+cat >> confdefs.h <<\EOF
+#define _PATH_NETWORKS "/etc/networks"
+EOF
+
+cat >> confdefs.h <<\EOF
+#define _PATH_PROTOCOLS "/etc/protocols"
+EOF
+
+cat >> confdefs.h <<\EOF
+#define _PATH_SERVICES "/etc/services"
+EOF
+
+
+cat >> confdefs.h <<\EOF
+#define _PATH_BSHELL "/bin/sh"
+EOF
+
+
+for ac_func in vfork
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2395 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() { return 0; }
+int t() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:2419: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+
+fi
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+srctop=`cd ${srcdir}/..;pwd`
+
+
+# Now we deal with symlinks &c.
+
+test -d include || mkdir include || \
+ { echo "configure: error: Can't create include directory." 1>&2; exit 1; }
+
+test -d include/pthread || mkdir include/pthread || \
+ { echo "configure: error: Can't create include/pthread directory." 1>&2; exit 1; }
+
+test -d lib || mkdir lib || \
+ { echo "configure: error: Can't create lib directory." 1>&2; exit 1; }
+
+test -d lib/libpthreadutil || mkdir lib/libpthreadutil || \
+ { echo "configure: error: Can't create lib/libpthreadutil directory." 1>&2; exit 1; }
+
+test -d bin || mkdir bin || \
+ { echo "configure: error: Can't create bin directory." 1>&2; exit 1; }
+
+test -d bin/finger || mkdir bin/finger || \
+ { echo "configure: error: Can't create bin directory." 1>&2; exit 1; }
+
+test -d tests || mkdir tests || \
+ { echo "configure: error: Can't create tests directory." 1>&2; exit 1; }
+
+if test x$syscall = xNONE ; then
+ syscall=$name
+fi
+
+links="include/pthread/machdep.h include/pthread/posix.h \
+ machdep.c syscall.S"
+targets="../machdep/engine-$name.h ../machdep/posix-$sysincludes.h \
+ ../machdep/engine-$name.c ../machdep/syscall-$syscall.S"
+
+# Both these targets are optional. (Autoconf-generated configure scripts
+# will require the existence of link targets, so check before adding them
+# to the list.)
+if test x$sysincludes != xNONE ; then
+ links="$links include/sys"
+ targets="$targets ../machdep/$sysincludes"
+fi
+
+syscall_file=../machdep/syscall-template-$syscall.S
+if test -r $srcdir/$syscall_file ; then
+ links="$links syscall-template.S"
+ targets="$targets $syscall_file"
+ HAVE_SYSCALL_TEMPLATE=yes
+else
+ # This really isn't a fatal problem. In fact, it's expected, initially,
+ # for some targets. This is just to persuade people to fix the targets
+ # they deal with to provide some sort of template.
+ #
+ # Eventually this file probably will be required...
+ echo "configure: warning: No syscall template file syscall-template-$syscall.S found." 1>&2
+ HAVE_SYSCALL_TEMPLATE=no
+fi
+
+
+
+
+if test x$makefile_frag != x ; then
+ makefile_frag=${srcdir}/$makefile_frag
+else
+ makefile_frag=/dev/null
+fi
+
+
+
+
+
+trap '' 1 2 15
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs. It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already. You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+ sed -n "s/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=\${\1='\2'}/p" \
+ >> confcache
+if cmp -s $cache_file confcache; then
+ :
+else
+ if test -w $cache_file; then
+ echo "updating cache $cache_file"
+ cat confcache > $cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Any assignment to VPATH causes Sun make to only execute
+# the first set of double-colon rules, so remove it if not needed.
+# If there is a colon in the path, we need to keep it.
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
+fi
+
+trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
+
+DEFS=-DHAVE_CONFIG_H
+
+# Without the "./", some shells look in PATH for config.status.
+: ${CONFIG_STATUS=./config.status}
+
+echo creating $CONFIG_STATUS
+rm -f $CONFIG_STATUS
+cat > $CONFIG_STATUS <<EOF
+#! /bin/sh
+# Generated automatically by configure.
+# Run this file to recreate the current configuration.
+# This directory was configured as follows,
+# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+#
+# $0 $ac_configure_args
+#
+# Compiler output produced by configure, useful for debugging
+# configure, is in ./config.log if it exists.
+
+ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
+for ac_option
+do
+ case "\$ac_option" in
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
+ exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
+ -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+ echo "$CONFIG_STATUS generated by autoconf version 2.10"
+ exit 0 ;;
+ -help | --help | --hel | --he | --h)
+ echo "\$ac_cs_usage"; exit 0 ;;
+ *) echo "\$ac_cs_usage"; exit 1 ;;
+ esac
+done
+
+ac_given_srcdir=$srcdir
+
+trap 'rm -fr `echo "config.flags GNUmakefile Makefile \
+ lib/Makefile:../lib/Makefile.in \
+ lib/libpthreadutil/Makefile:../lib/libpthreadutil/Makefile.in \
+ bin/Makefile:../bin/Makefile.in \
+ bin/finger/Makefile:../bin/finger/Makefile.in \
+ tests/Makefile:../tests/Makefile.in config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+# Protect against being on the right side of a sed subst in config.status.
+sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
+ s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
+$ac_vpsub
+$extrasub
+s%@CFLAGS@%$CFLAGS%g
+s%@CPPFLAGS@%$CPPFLAGS%g
+s%@CXXFLAGS@%$CXXFLAGS%g
+s%@DEFS@%$DEFS%g
+s%@LDFLAGS@%$LDFLAGS%g
+s%@LIBS@%$LIBS%g
+s%@exec_prefix@%$exec_prefix%g
+s%@prefix@%$prefix%g
+s%@program_transform_name@%$program_transform_name%g
+s%@bindir@%$bindir%g
+s%@sbindir@%$sbindir%g
+s%@libexecdir@%$libexecdir%g
+s%@datadir@%$datadir%g
+s%@sysconfdir@%$sysconfdir%g
+s%@sharedstatedir@%$sharedstatedir%g
+s%@localstatedir@%$localstatedir%g
+s%@libdir@%$libdir%g
+s%@includedir@%$includedir%g
+s%@oldincludedir@%$oldincludedir%g
+s%@infodir@%$infodir%g
+s%@mandir@%$mandir%g
+s%@CC@%$CC%g
+s%@CXX@%$CXX%g
+s%@CPP@%$CPP%g
+s%@RANLIB@%$RANLIB%g
+s%@host@%$host%g
+s%@host_alias@%$host_alias%g
+s%@host_cpu@%$host_cpu%g
+s%@host_vendor@%$host_vendor%g
+s%@host_os@%$host_os%g
+s%@target@%$target%g
+s%@target_alias@%$target_alias%g
+s%@target_cpu@%$target_cpu%g
+s%@target_vendor@%$target_vendor%g
+s%@target_os@%$target_os%g
+s%@build@%$build%g
+s%@build_alias@%$build_alias%g
+s%@build_cpu@%$build_cpu%g
+s%@build_vendor@%$build_vendor%g
+s%@build_os@%$build_os%g
+s%@SYSCALL_EXCEPTIONS@%$SYSCALL_EXCEPTIONS%g
+s%@available_syscalls@%$available_syscalls%g
+s%@missing_syscalls@%$missing_syscalls%g
+s%@srctop@%$srctop%g
+s%@HAVE_SYSCALL_TEMPLATE@%$HAVE_SYSCALL_TEMPLATE%g
+/@makefile_frag@/r $makefile_frag
+s%@makefile_frag@%%g
+
+CEOF
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+CONFIG_FILES=\${CONFIG_FILES-"config.flags GNUmakefile Makefile \
+ lib/Makefile:../lib/Makefile.in \
+ lib/libpthreadutil/Makefile:../lib/libpthreadutil/Makefile.in \
+ bin/Makefile:../bin/Makefile.in \
+ bin/finger/Makefile:../bin/finger/Makefile.in \
+ tests/Makefile:../tests/Makefile.in"}
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ # Adjust relative srcdir, etc. for subdirectories.
+
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
+ else
+ ac_dir_suffix= ac_dots=
+ fi
+
+ case "$ac_given_srcdir" in
+ .) srcdir=.
+ if test -z "$ac_dots"; then top_srcdir=.
+ else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
+ /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
+ *) # Relative path.
+ srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
+ top_srcdir="$ac_dots$ac_given_srcdir" ;;
+ esac
+
+ echo creating "$ac_file"
+ rm -f "$ac_file"
+ configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
+ case "$ac_file" in
+ *Makefile*) ac_comsub="1i\\
+# $configure_input" ;;
+ *) ac_comsub= ;;
+ esac
+ sed -e "$ac_comsub
+s%@configure_input@%$configure_input%g
+s%@srcdir@%$srcdir%g
+s%@top_srcdir@%$top_srcdir%g
+" -f conftest.subs $ac_given_srcdir/$ac_file_in > $ac_file
+fi; done
+rm -f conftest.subs
+
+# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+# NAME is the cpp macro being defined and VALUE is the value it is being given.
+#
+# ac_d sets the value in "#define NAME VALUE" lines.
+ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
+ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
+ac_dC='\3'
+ac_dD='%g'
+# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
+ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_uB='\([ ]\)%\1#\2define\3'
+ac_uC=' '
+ac_uD='\4%g'
+# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_eB='$%\1#\2define\3'
+ac_eC=' '
+ac_eD='%g'
+
+CONFIG_HEADERS=${CONFIG_HEADERS-"config.h"}
+for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ echo creating $ac_file
+
+ rm -f conftest.frag conftest.in conftest.out
+ cp $ac_given_srcdir/$ac_file_in conftest.in
+
+EOF
+
+# Transform confdefs.h into a sed script conftest.vals that substitutes
+# the proper values into config.h.in to produce config.h. And first:
+# Protect against being on the right side of a sed subst in config.status.
+# Protect against being in an unquoted here document in config.status.
+rm -f conftest.vals
+cat > conftest.hdr <<\EOF
+s/[\\&%]/\\&/g
+s%[\\$`]%\\&%g
+s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
+s%ac_d%ac_u%gp
+s%ac_u%ac_e%gp
+EOF
+sed -n -f conftest.hdr confdefs.h > conftest.vals
+rm -f conftest.hdr
+
+# This sed command replaces #undef with comments. This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+cat >> conftest.vals <<\EOF
+s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
+EOF
+
+# Break up conftest.vals because some shells have a limit on
+# the size of here documents, and old seds have small limits too.
+# Maximum number of lines to put in a single here document.
+ac_max_here_lines=12
+
+rm -f conftest.tail
+while :
+do
+ ac_lines=`grep -c . conftest.vals`
+ # grep -c gives empty output for an empty file on some AIX systems.
+ if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
+ # Write a limited-size here document to conftest.frag.
+ echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
+ sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
+ echo 'CEOF
+ sed -f conftest.frag conftest.in > conftest.out
+ rm -f conftest.in
+ mv conftest.out conftest.in
+' >> $CONFIG_STATUS
+ sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
+ rm -f conftest.vals
+ mv conftest.tail conftest.vals
+done
+rm -f conftest.vals
+
+cat >> $CONFIG_STATUS <<\EOF
+ rm -f conftest.frag conftest.h
+ echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
+ cat conftest.in >> conftest.h
+ rm -f conftest.in
+ if cmp -s $ac_file conftest.h 2>/dev/null; then
+ echo "$ac_file is unchanged"
+ rm -f conftest.h
+ else
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ fi
+ rm -f $ac_file
+ mv conftest.h $ac_file
+ fi
+fi; done
+
+EOF
+
+cat >> $CONFIG_STATUS <<EOF
+ac_sources="$targets"
+ac_dests="$links"
+EOF
+
+cat >> $CONFIG_STATUS <<\EOF
+srcdir=$ac_given_srcdir
+while test -n "$ac_sources"; do
+ set $ac_dests; ac_dest=$1; shift; ac_dests=$*
+ set $ac_sources; ac_source=$1; shift; ac_sources=$*
+
+ echo "linking $srcdir/$ac_source to $ac_dest"
+
+ if test ! -r $srcdir/$ac_source; then
+ { echo "configure: error: $srcdir/$ac_source: File not found" 1>&2; exit 1; }
+ fi
+ rm -f $ac_dest
+
+ # Make relative symlinks.
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dest_dir=`echo $ac_dest|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dest_dir" != "$ac_dest" && test "$ac_dest_dir" != .; then
+ # The dest file is in a subdirectory.
+ test ! -d "$ac_dest_dir" && mkdir "$ac_dest_dir"
+ ac_dest_dir_suffix="/`echo $ac_dest_dir|sed 's%^\./%%'`"
+ # A "../" for each directory in $ac_dest_dir_suffix.
+ ac_dots=`echo $ac_dest_dir_suffix|sed 's%/[^/]*%../%g'`
+ else
+ ac_dest_dir_suffix= ac_dots=
+ fi
+
+ case "$srcdir" in
+ [/$]*) ac_rel_source="$srcdir/$ac_source" ;;
+ *) ac_rel_source="$ac_dots$srcdir/$ac_source" ;;
+ esac
+
+ # Make a symlink if possible; otherwise try a hard link.
+ if ln -s $ac_rel_source $ac_dest 2>/dev/null ||
+ ln $srcdir/$ac_source $ac_dest; then :
+ else
+ { echo "configure: error: can not link $ac_dest to $srcdir/$ac_source" 1>&2; exit 1; }
+ fi
+done
+
+
+exit 0
+EOF
+chmod +x $CONFIG_STATUS
+rm -fr confdefs* $ac_clean_files
+test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+
diff --git a/mit-pthreads/config/install-sh b/mit-pthreads/config/install-sh
new file mode 100755
index 00000000000..ab74c882e92
--- /dev/null
+++ b/mit-pthreads/config/install-sh
@@ -0,0 +1,238 @@
+#!/bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+#
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+tranformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+ case $1 in
+ -c) instcmd="$cpprog"
+ shift
+ continue;;
+
+ -d) dir_arg=true
+ shift
+ continue;;
+
+ -m) chmodcmd="$chmodprog $2"
+ shift
+ shift
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd="$stripprog"
+ shift
+ continue;;
+
+ -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+ shift
+ continue;;
+
+ -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+ shift
+ continue;;
+
+ *) if [ x"$src" = x ]
+ then
+ src=$1
+ else
+ # this colon is to work around a 386BSD /bin/sh bug
+ :
+ dst=$1
+ fi
+ shift
+ continue;;
+ esac
+done
+
+if [ x"$src" = x ]
+then
+ echo "install: no input file specified"
+ exit 1
+else
+ true
+fi
+
+if [ x"$dir_arg" != x ]; then
+ dst=$src
+ src=""
+
+ if [ -d $dst ]; then
+ instcmd=:
+ else
+ instcmd=mkdir
+ fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad
+# if $src (and thus $dsttmp) contains '*'.
+
+ if [ -f $src -o -d $src ]
+ then
+ true
+ else
+ echo "install: $src does not exist"
+ exit 1
+ fi
+
+ if [ x"$dst" = x ]
+ then
+ echo "install: no destination specified"
+ exit 1
+ else
+ true
+ fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+ if [ -d $dst ]
+ then
+ dst="$dst"/`basename $src`
+ else
+ true
+ fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+# this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+'
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+ pathcomp="${pathcomp}${1}"
+ shift
+
+ if [ ! -d "${pathcomp}" ] ;
+ then
+ $mkdirprog "${pathcomp}"
+ else
+ true
+ fi
+
+ pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+ $doit $instcmd $dst &&
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+ if [ x"$transformarg" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ dstfile=`basename $dst $transformbasename |
+ sed $transformarg`$transformbasename
+ fi
+
+# don't allow the sed command to completely eliminate the filename
+
+ if [ x"$dstfile" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ true
+ fi
+
+# Make a temp file name in the proper directory.
+
+ dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+ $doit $instcmd $src $dsttmp &&
+
+ trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing. If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+
+# Now rename the file to the real destination.
+
+ $doit $rmcmd -f $dstdir/$dstfile &&
+ $doit $mvcmd $dsttmp $dstdir/$dstfile
+
+fi &&
+
+
+exit 0
diff --git a/mit-pthreads/configure b/mit-pthreads/configure
new file mode 100755
index 00000000000..9411483a31d
--- /dev/null
+++ b/mit-pthreads/configure
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# This silliness is because Chris wants the autoconf-related files
+# and makefiles not to appear in the top-level directory. Fine by
+# me, I don't much care. This script just needs to invoke the real
+# configure script...
+
+config=`echo $0 | sed -e 's,configure$,config/configure,'`
+
+if test ! -d obj ; then
+ mkdir obj
+fi
+
+if test -n "$1" ; then
+ exec $config "$@"
+else
+ exec $config
+fi
+
diff --git a/mit-pthreads/gen/GNUmakefile.inc b/mit-pthreads/gen/GNUmakefile.inc
new file mode 100755
index 00000000000..a5025860b85
--- /dev/null
+++ b/mit-pthreads/gen/GNUmakefile.inc
@@ -0,0 +1,9 @@
+# from: @(#)Makefile.inc 5.21 (Berkeley) 5/24/91
+# $Id$
+
+# gen sources
+VPATH:= ${VPATH}:${srcdir}/gen
+
+SRCS:= ttyname.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 isatty.c $(SRCS)
diff --git a/mit-pthreads/gen/Makefile.inc b/mit-pthreads/gen/Makefile.inc
new file mode 100644
index 00000000000..6e2c3d44f43
--- /dev/null
+++ b/mit-pthreads/gen/Makefile.inc
@@ -0,0 +1,24 @@
+# from: @(#)Makefile.inc 5.21 (Berkeley) 5/24/91
+# $Id$
+
+# gen sources
+.PATH: ${srcdir}/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
+
+#SRCS+= alarm.c assert.c clock.c crypt.c ctermid.c ctype_.c \
+# disklabel.c err.c errlst.c exec.c fnmatch.c frexp.c \
+# fstab.c fts.c getcap.c getcwd.c getgrent.c getlogin.c getmntinfo.c \
+# getpass.c getpwent.c getsubopt.c getttyent.c getusershell.c glob.c \
+# infinity.c initgroups.c isatty.c isctype.c isinf.c mktemp.c nice.c \
+# nlist.c pause.c psignal.c raise.c \
+# scandir.c setjmperr.c \
+# setmode.c setrgid.c setruid.c siginterrupt.c \
+# siglist.c signal.c sigsetops.c syslog.c \
+# termios.c time.c times.c timezone.c ttyslot.c \
+# ualarm.c unvis.c utime.c valloc.c vis.c
+#
+# gen/regexp sources
+#SRCS+= regerror.c regexp.c regsub.c
+
diff --git a/mit-pthreads/gen/ctime.c b/mit-pthreads/gen/ctime.c
new file mode 100644
index 00000000000..e7980296e50
--- /dev/null
+++ b/mit-pthreads/gen/ctime.c
@@ -0,0 +1,1315 @@
+/*
+ * 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 "config.h"
+#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/mit-pthreads/gen/difftime.c b/mit-pthreads/gen/difftime.c
new file mode 100644
index 00000000000..cddd896e04a
--- /dev/null
+++ b/mit-pthreads/gen/difftime.c
@@ -0,0 +1,46 @@
+/*
+ * 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/mit-pthreads/gen/directory.c b/mit-pthreads/gen/directory.c
new file mode 100644
index 00000000000..d189280fc1f
--- /dev/null
+++ b/mit-pthreads/gen/directory.c
@@ -0,0 +1,322 @@
+/*
+ * 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/mit-pthreads/gen/eprintf.c b/mit-pthreads/gen/eprintf.c
new file mode 100644
index 00000000000..bcc65757bd4
--- /dev/null
+++ b/mit-pthreads/gen/eprintf.c
@@ -0,0 +1,18 @@
+/* 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/mit-pthreads/gen/getcwd.c b/mit-pthreads/gen/getcwd.c
new file mode 100644
index 00000000000..9c1b089f26e
--- /dev/null
+++ b/mit-pthreads/gen/getcwd.c
@@ -0,0 +1,248 @@
+/*
+ * 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$";
+#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/mit-pthreads/gen/getpwent.c b/mit-pthreads/gen/getpwent.c
new file mode 100644
index 00000000000..7bcb2cbd610
--- /dev/null
+++ b/mit-pthreads/gen/getpwent.c
@@ -0,0 +1,109 @@
+/*
+ * 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/mit-pthreads/gen/getpwnamuid.c b/mit-pthreads/gen/getpwnamuid.c
new file mode 100644
index 00000000000..0e87081b7a9
--- /dev/null
+++ b/mit-pthreads/gen/getpwnamuid.c
@@ -0,0 +1,138 @@
+/*
+ * 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/mit-pthreads/gen/getwd.c b/mit-pthreads/gen/getwd.c
new file mode 100644
index 00000000000..7fdceda0f45
--- /dev/null
+++ b/mit-pthreads/gen/getwd.c
@@ -0,0 +1,57 @@
+/*-
+ * 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$";
+#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/mit-pthreads/gen/isatty.c b/mit-pthreads/gen/isatty.c
new file mode 100644
index 00000000000..a22f13015d9
--- /dev/null
+++ b/mit-pthreads/gen/isatty.c
@@ -0,0 +1,95 @@
+/*
+ * 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$";
+#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/mit-pthreads/gen/popen.c b/mit-pthreads/gen/popen.c
new file mode 100644
index 00000000000..c15fbdce1fe
--- /dev/null
+++ b/mit-pthreads/gen/popen.c
@@ -0,0 +1,117 @@
+#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/mit-pthreads/gen/pwd_internal.c b/mit-pthreads/gen/pwd_internal.c
new file mode 100644
index 00000000000..b0ebc27b5c6
--- /dev/null
+++ b/mit-pthreads/gen/pwd_internal.c
@@ -0,0 +1,97 @@
+/* ==== 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/mit-pthreads/gen/pwd_internal.h b/mit-pthreads/gen/pwd_internal.h
new file mode 100644
index 00000000000..10fdab6cc4e
--- /dev/null
+++ b/mit-pthreads/gen/pwd_internal.h
@@ -0,0 +1,29 @@
+#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/mit-pthreads/gen/syslog.c b/mit-pthreads/gen/syslog.c
new file mode 100644
index 00000000000..e49795ecb69
--- /dev/null
+++ b/mit-pthreads/gen/syslog.c
@@ -0,0 +1,216 @@
+/*
+ * 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/mit-pthreads/gen/time.c b/mit-pthreads/gen/time.c
new file mode 100644
index 00000000000..82eec7edc1e
--- /dev/null
+++ b/mit-pthreads/gen/time.c
@@ -0,0 +1,51 @@
+/*
+ * 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/mit-pthreads/gen/ttyname.c b/mit-pthreads/gen/ttyname.c
new file mode 100644
index 00000000000..b7a04485f79
--- /dev/null
+++ b/mit-pthreads/gen/ttyname.c
@@ -0,0 +1,147 @@
+/*
+ * 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 "config.h"
+#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>
+
+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/mit-pthreads/include/Makefile.inc b/mit-pthreads/include/Makefile.inc
new file mode 100644
index 00000000000..b7fe59d5f0d
--- /dev/null
+++ b/mit-pthreads/include/Makefile.inc
@@ -0,0 +1,30 @@
+# from: @(#)Makefile 5.45.1.1 (Berkeley) 5/6/91
+
+# Doing a make install builds /usr/include/pthread
+#
+# The ``rm -rf''s used below are safe because rm doesn't follow symbolic
+# links.
+
+
+FILES= cond.h copyright.h fd.h fd_pipe.h kernel.h mutex.h posix.h \
+ pthread.h pthread_attr.h queue.h util.h
+
+# Machine dependent header file
+MFILE= ${.CURDIR}/arch/${MACHINE}/machdep.h
+
+realinstall:
+ if [ ! -d ${DESTDIR}/usr/include/pthread ]; then \
+ mkdir ${DESTDIR}/usr/include/pthread; \
+ fi
+ @echo installing ${FILES}
+ @-for i in ${FILES}; do \
+ cmp -s $$i ${DESTDIR}/usr/include/pthread/$$i || \
+ install -c -m 644 $$i ${DESTDIR}/usr/include/$$i; \
+ done
+ cmp -s ${MFILE} ${DESTDIR}/usr/include/pthread/machdep.h || \
+ install -c -m 644 ${MFILE} ${DESTDIR}/usr/include/pthread/machdep.h
+ rm -rf ${DESTDIR}/usr/include/pthread.h
+ ln -s /usr/include/pthread/pthread.h ${DESTDIR}/usr/include/pthread.h
+ @chown -R ${BINOWN}:${BINGRP} ${DESTDIR}/usr/include/pthread
+ @chmod -R a-w ${DESTDIR}/usr/include/pthread
+
diff --git a/mit-pthreads/include/arpa/inet.h b/mit-pthreads/include/arpa/inet.h
new file mode 100755
index 00000000000..d6ad76f4eb5
--- /dev/null
+++ b/mit-pthreads/include/arpa/inet.h
@@ -0,0 +1,61 @@
+/*
+ * 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$
+ */
+
+#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/mit-pthreads/include/arpa/nameser.h b/mit-pthreads/include/arpa/nameser.h
new file mode 100755
index 00000000000..350d67538bd
--- /dev/null
+++ b/mit-pthreads/include/arpa/nameser.h
@@ -0,0 +1,279 @@
+/*
+ * 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/mit-pthreads/include/dirent.h b/mit-pthreads/include/dirent.h
new file mode 100644
index 00000000000..c3e86cb9da1
--- /dev/null
+++ b/mit-pthreads/include/dirent.h
@@ -0,0 +1,97 @@
+/*-
+ * 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/mit-pthreads/include/endian.h b/mit-pthreads/include/endian.h
new file mode 100644
index 00000000000..8fb947dbd33
--- /dev/null
+++ b/mit-pthreads/include/endian.h
@@ -0,0 +1,95 @@
+/*
+ * 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/mit-pthreads/include/errno.h b/mit-pthreads/include/errno.h
new file mode 100644
index 00000000000..24b005e9369
--- /dev/null
+++ b/mit-pthreads/include/errno.h
@@ -0,0 +1,52 @@
+/*
+ * 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/mit-pthreads/include/math.h b/mit-pthreads/include/math.h
new file mode 100644
index 00000000000..d5963ce6023
--- /dev/null
+++ b/mit-pthreads/include/math.h
@@ -0,0 +1,85 @@
+#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/mit-pthreads/include/netdb.h b/mit-pthreads/include/netdb.h
new file mode 100644
index 00000000000..54d85e5a3ed
--- /dev/null
+++ b/mit-pthreads/include/netdb.h
@@ -0,0 +1,146 @@
+/*-
+ * 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$
+ */
+
+#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/mit-pthreads/include/pthread.h b/mit-pthreads/include/pthread.h
new file mode 100644
index 00000000000..e8a44050215
--- /dev/null
+++ b/mit-pthreads/include/pthread.h
@@ -0,0 +1,371 @@
+/* ==== pthread.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$
+ *
+ * Description : Basic pthread header.
+ *
+ * 1.00 93/07/20 proven
+ * -Started coding this file.
+ *
+ * 93/9/28 streepy - Added support for pthread cancel
+ *
+ */
+
+#ifndef _PTHREAD_H_
+#define _PTHREAD_H_
+
+#include <pthread/types.h>
+
+#include <pthread/version.h>
+#include <pthread/machdep.h>
+#include <pthread/cleanup.h>
+#include <pthread/kernel.h>
+#include <pthread/prio_queue.h>
+#include <pthread/queue.h>
+#include <pthread/sleep.h>
+#include <pthread/mutex.h>
+#include <pthread/cond.h>
+#include <pthread/fd.h>
+#include <pthread/debug_out.h>
+
+/* Requires mutex.h */
+#include <pthread/specific.h>
+
+#include <pthread/util.h>
+
+/* More includes */
+#include <pthread/pthread_once.h>
+
+/* More includes, that need size_t */
+#include <pthread/pthread_attr.h>
+
+#include <signal.h> /* for sigset_t */ /* Moved by monty */
+
+/* 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
+
+enum pthread_state {
+#define __pthread_defstate(S,NAME) S,
+#include "pthread/state.def"
+#undef __pthread_defstate
+
+ /* enum lists aren't supposed to end with a comma, sigh */
+ 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;
+};
+
+#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 */
+ int sighandled; /* Set when signal has been handled */
+ /* 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
+ * It is possible for a thread to be on multiple, or even all the
+ * queues at once, much care must be taken during queue manipulation.
+ *
+ * The pthread structure must be locked before you can even look at
+ * the link lists.
+ */
+
+ /*
+ * 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;
+
+ /*
+ * Actual queue state and priority of thread.
+ * (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 */
+
+struct pthread;
+
+#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
+
+/*
+ * New functions
+ */
+
+__BEGIN_DECLS
+
+#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));
+void (*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 ));
+
+int pthread_sigmask __P_((int how, const sigset_t *set,
+ sigset_t * oset)); /* added by Monty */
+int sigwait __P_((const sigset_t * set, int * sig));
+int sigsetwait __P_((const sigset_t * set, int * sig));
+#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
+
+__END_DECLS
+
+/*
+ * Static constructors
+ */
+#ifdef __cplusplus
+
+extern struct pthread * pthread_initial;
+
+class __pthread_init_t {
+/* struct __pthread_init_t { */
+ public:
+ __pthread_init_t() {
+ if (pthread_initial == NULL) {
+ pthread_init();
+ }
+ }
+};
+
+static __pthread_init_t __pthread_init_this_file;
+
+#endif /* __cplusplus */
+
+#endif
diff --git a/mit-pthreads/include/pthread/ac-types.h b/mit-pthreads/include/pthread/ac-types.h
new file mode 100644
index 00000000000..c9dc938f6e8
--- /dev/null
+++ b/mit-pthreads/include/pthread/ac-types.h
@@ -0,0 +1,11 @@
+#ifndef pthread_size_t
+#define pthread_ipaddr_type unsigned int
+#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 long
+#define pthread_off_t long long
+#define pthread_va_list void *
+#endif
diff --git a/mit-pthreads/include/pthread/cleanup.h b/mit-pthreads/include/pthread/cleanup.h
new file mode 100755
index 00000000000..cd995ceddcf
--- /dev/null
+++ b/mit-pthreads/include/pthread/cleanup.h
@@ -0,0 +1,59 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/include/pthread/cond.h b/mit-pthreads/include/pthread/cond.h
new file mode 100755
index 00000000000..ec9f7cf0016
--- /dev/null
+++ b/mit-pthreads/include/pthread/cond.h
@@ -0,0 +1,102 @@
+/* ==== 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$
+ *
+ * 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
+
+struct timespec;
+
+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/mit-pthreads/include/pthread/config.h b/mit-pthreads/include/pthread/config.h
new file mode 100644
index 00000000000..251948c3874
--- /dev/null
+++ b/mit-pthreads/include/pthread/config.h
@@ -0,0 +1,5 @@
+#ifndef _SYS___CONFIG_H_
+#define _SYS___CONFIG_H_
+#define _OS_HAS_TIMESPEC 1
+#define _OS_HAS_SOCKLEN_T 1
+#endif
diff --git a/mit-pthreads/include/pthread/debug_out.h b/mit-pthreads/include/pthread/debug_out.h
new file mode 100755
index 00000000000..6968c5ea90e
--- /dev/null
+++ b/mit-pthreads/include/pthread/debug_out.h
@@ -0,0 +1,44 @@
+/* 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/mit-pthreads/include/pthread/fd.h b/mit-pthreads/include/pthread/fd.h
new file mode 100755
index 00000000000..d27a5066936
--- /dev/null
+++ b/mit-pthreads/include/pthread/fd.h
@@ -0,0 +1,122 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/include/pthread/fd_pipe.h b/mit-pthreads/include/pthread/fd_pipe.h
new file mode 100755
index 00000000000..cc5670dbb7d
--- /dev/null
+++ b/mit-pthreads/include/pthread/fd_pipe.h
@@ -0,0 +1,54 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/include/pthread/kernel.h b/mit-pthreads/include/pthread/kernel.h
new file mode 100755
index 00000000000..c474d789681
--- /dev/null
+++ b/mit-pthreads/include/pthread/kernel.h
@@ -0,0 +1,71 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/include/pthread/kthread.h b/mit-pthreads/include/pthread/kthread.h
new file mode 100755
index 00000000000..a2e73361d8c
--- /dev/null
+++ b/mit-pthreads/include/pthread/kthread.h
@@ -0,0 +1,67 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/include/pthread/mutex.h b/mit-pthreads/include/pthread/mutex.h
new file mode 100755
index 00000000000..e6f1fe58c0f
--- /dev/null
+++ b/mit-pthreads/include/pthread/mutex.h
@@ -0,0 +1,102 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/include/pthread/paths.h b/mit-pthreads/include/pthread/paths.h
new file mode 100644
index 00000000000..8af9233a67c
--- /dev/null
+++ b/mit-pthreads/include/pthread/paths.h
@@ -0,0 +1,12 @@
+#ifndef _SYS___PATHS_H_
+#define _SYS___PATHS_H_
+#define _PATH_PTY "/dev/"
+#define _PATH_TZDIR "/usr/share/zoneinfo"
+#define _PATH_TZFILE "/etc/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/mit-pthreads/include/pthread/prio_queue.h b/mit-pthreads/include/pthread/prio_queue.h
new file mode 100755
index 00000000000..e29a0170548
--- /dev/null
+++ b/mit-pthreads/include/pthread/prio_queue.h
@@ -0,0 +1,78 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/include/pthread/pthread_attr.h b/mit-pthreads/include/pthread/pthread_attr.h
new file mode 100755
index 00000000000..8cad262bad2
--- /dev/null
+++ b/mit-pthreads/include/pthread/pthread_attr.h
@@ -0,0 +1,122 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/include/pthread/pthread_once.h b/mit-pthreads/include/pthread/pthread_once.h
new file mode 100755
index 00000000000..ac53d5f9b2c
--- /dev/null
+++ b/mit-pthreads/include/pthread/pthread_once.h
@@ -0,0 +1,58 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/include/pthread/queue.h b/mit-pthreads/include/pthread/queue.h
new file mode 100755
index 00000000000..eca7699e95a
--- /dev/null
+++ b/mit-pthreads/include/pthread/queue.h
@@ -0,0 +1,67 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/include/pthread/sleep.h b/mit-pthreads/include/pthread/sleep.h
new file mode 100755
index 00000000000..8bf471a24aa
--- /dev/null
+++ b/mit-pthreads/include/pthread/sleep.h
@@ -0,0 +1,63 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/include/pthread/specific.h b/mit-pthreads/include/pthread/specific.h
new file mode 100755
index 00000000000..9c66a695556
--- /dev/null
+++ b/mit-pthreads/include/pthread/specific.h
@@ -0,0 +1,66 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/include/pthread/state.def b/mit-pthreads/include/pthread/state.def
new file mode 100755
index 00000000000..c62d102a9f0
--- /dev/null
+++ b/mit-pthreads/include/pthread/state.def
@@ -0,0 +1,64 @@
+/* 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/mit-pthreads/include/pthread/types.h b/mit-pthreads/include/pthread/types.h
new file mode 100755
index 00000000000..7fdf001a0bc
--- /dev/null
+++ b/mit-pthreads/include/pthread/types.h
@@ -0,0 +1,46 @@
+#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/mit-pthreads/include/pthread/unistd.h b/mit-pthreads/include/pthread/unistd.h
new file mode 100755
index 00000000000..3cb07533114
--- /dev/null
+++ b/mit-pthreads/include/pthread/unistd.h
@@ -0,0 +1,159 @@
+/*-
+ * 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/mit-pthreads/include/pthread/util.h b/mit-pthreads/include/pthread/util.h
new file mode 100755
index 00000000000..aaa33a6318d
--- /dev/null
+++ b/mit-pthreads/include/pthread/util.h
@@ -0,0 +1,89 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/include/pthread/version.h b/mit-pthreads/include/pthread/version.h
new file mode 100755
index 00000000000..fda3af284d0
--- /dev/null
+++ b/mit-pthreads/include/pthread/version.h
@@ -0,0 +1,43 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/include/pthread/xtypes.h b/mit-pthreads/include/pthread/xtypes.h
new file mode 100755
index 00000000000..4dcc4f04f8c
--- /dev/null
+++ b/mit-pthreads/include/pthread/xtypes.h
@@ -0,0 +1,13 @@
+/* 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/mit-pthreads/include/pwd.h b/mit-pthreads/include/pwd.h
new file mode 100644
index 00000000000..af945a2b8db
--- /dev/null
+++ b/mit-pthreads/include/pwd.h
@@ -0,0 +1,93 @@
+/*-
+ * 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$
+ */
+
+#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/mit-pthreads/include/resolv.h b/mit-pthreads/include/resolv.h
new file mode 100644
index 00000000000..f6313a7229e
--- /dev/null
+++ b/mit-pthreads/include/resolv.h
@@ -0,0 +1,179 @@
+/*
+ * 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$
+ */
+
+#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/mit-pthreads/include/sched.h b/mit-pthreads/include/sched.h
new file mode 100644
index 00000000000..dcd9d4e3600
--- /dev/null
+++ b/mit-pthreads/include/sched.h
@@ -0,0 +1,57 @@
+/* ==== pthread.h ============================================================
+ * 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.
+ *
+ * $Id$
+ *
+ * Description : Basic pthread header.
+ *
+ * 1.00 93/08/29 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SCHED_H_
+#define _SCHED_H_
+
+#include <pthread/prio_queue.h>
+
+/*
+ * New functions
+ */
+
+__BEGIN_DECLS
+
+int sched_yield __P_((void));
+int sched_get_priority_max __P_((int));
+int sched_get_priority_min __P_((int));
+
+__END_DECLS
+
+#endif
diff --git a/mit-pthreads/include/signal.h b/mit-pthreads/include/signal.h
new file mode 100644
index 00000000000..9fb1ec6e2c8
--- /dev/null
+++ b/mit-pthreads/include/signal.h
@@ -0,0 +1,81 @@
+/*-
+ * 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/mit-pthreads/include/stdio.h b/mit-pthreads/include/stdio.h
new file mode 100644
index 00000000000..538d4685f3f
--- /dev/null
+++ b/mit-pthreads/include/stdio.h
@@ -0,0 +1,371 @@
+/* ==== 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$
+ */
+
+#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/mit-pthreads/include/stdlib.h b/mit-pthreads/include/stdlib.h
new file mode 100644
index 00000000000..77f84ffa0bb
--- /dev/null
+++ b/mit-pthreads/include/stdlib.h
@@ -0,0 +1,127 @@
+/*
+ * 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$
+ */
+
+#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/mit-pthreads/include/string.h b/mit-pthreads/include/string.h
new file mode 100644
index 00000000000..4143a1cfec7
--- /dev/null
+++ b/mit-pthreads/include/string.h
@@ -0,0 +1,85 @@
+/* $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/mit-pthreads/include/syslog.h b/mit-pthreads/include/syslog.h
new file mode 100644
index 00000000000..31b42285fc1
--- /dev/null
+++ b/mit-pthreads/include/syslog.h
@@ -0,0 +1,101 @@
+/*
+ * 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/mit-pthreads/include/time.h b/mit-pthreads/include/time.h
new file mode 100644
index 00000000000..614bbeb2a59
--- /dev/null
+++ b/mit-pthreads/include/time.h
@@ -0,0 +1,102 @@
+/*
+ * 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$
+ */
+
+#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/mit-pthreads/include/timers.h b/mit-pthreads/include/timers.h
new file mode 100644
index 00000000000..9a0196a3631
--- /dev/null
+++ b/mit-pthreads/include/timers.h
@@ -0,0 +1,45 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/include/tzfile.h b/mit-pthreads/include/tzfile.h
new file mode 100644
index 00000000000..7a486302e10
--- /dev/null
+++ b/mit-pthreads/include/tzfile.h
@@ -0,0 +1,154 @@
+/*
+ * 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$
+ */
+
+#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/mit-pthreads/include/unistd.h b/mit-pthreads/include/unistd.h
new file mode 100644
index 00000000000..213aa983172
--- /dev/null
+++ b/mit-pthreads/include/unistd.h
@@ -0,0 +1,183 @@
+/*-
+ * 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/mit-pthreads/lib/.cvsignore b/mit-pthreads/lib/.cvsignore
new file mode 100644
index 00000000000..f3c7a7c5da6
--- /dev/null
+++ b/mit-pthreads/lib/.cvsignore
@@ -0,0 +1 @@
+Makefile
diff --git a/mit-pthreads/lib/Makefile.in b/mit-pthreads/lib/Makefile.in
new file mode 100644
index 00000000000..821d293d896
--- /dev/null
+++ b/mit-pthreads/lib/Makefile.in
@@ -0,0 +1,48 @@
+# === 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/mit-pthreads/lib/libpthreadutil/.cvsignore b/mit-pthreads/lib/libpthreadutil/.cvsignore
new file mode 100644
index 00000000000..f3c7a7c5da6
--- /dev/null
+++ b/mit-pthreads/lib/libpthreadutil/.cvsignore
@@ -0,0 +1 @@
+Makefile
diff --git a/mit-pthreads/lib/libpthreadutil/Makefile.in b/mit-pthreads/lib/libpthreadutil/Makefile.in
new file mode 100755
index 00000000000..94034f426b3
--- /dev/null
+++ b/mit-pthreads/lib/libpthreadutil/Makefile.in
@@ -0,0 +1,65 @@
+# === 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/mit-pthreads/lib/libpthreadutil/pthread_atexit.c b/mit-pthreads/lib/libpthreadutil/pthread_atexit.c
new file mode 100755
index 00000000000..f244fbfb0c8
--- /dev/null
+++ b/mit-pthreads/lib/libpthreadutil/pthread_atexit.c
@@ -0,0 +1,135 @@
+/* ==== 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$";
+#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/mit-pthreads/lib/libpthreadutil/pthread_tad.c b/mit-pthreads/lib/libpthreadutil/pthread_tad.c
new file mode 100755
index 00000000000..a59fd9b87bf
--- /dev/null
+++ b/mit-pthreads/lib/libpthreadutil/pthread_tad.c
@@ -0,0 +1,170 @@
+/* ==== 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/mit-pthreads/lib/libpthreadutil/pthreadutil.h b/mit-pthreads/lib/libpthreadutil/pthreadutil.h
new file mode 100755
index 00000000000..0d8e6a6ef5f
--- /dev/null
+++ b/mit-pthreads/lib/libpthreadutil/pthreadutil.h
@@ -0,0 +1,75 @@
+/* ==== 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/mit-pthreads/machdep/alpha-osf1/__math.h b/mit-pthreads/machdep/alpha-osf1/__math.h
new file mode 100755
index 00000000000..12fdc85678c
--- /dev/null
+++ b/mit-pthreads/machdep/alpha-osf1/__math.h
@@ -0,0 +1,16 @@
+/*
+ * ANSI required entries in math.h
+ *
+ */
+#ifdef _ANSI_C_SOURCE
+
+#if defined(_IEEE_FP)
+# define HUGE_VAL 1.8e308
+#else
+# define HUGE_VAL 1.797693134862315708e308
+#endif
+
+#endif /*_ANSI_C_SOURCE */
+
+
+
diff --git a/mit-pthreads/machdep/alpha-osf1/__signal.h b/mit-pthreads/machdep/alpha-osf1/__signal.h
new file mode 100755
index 00000000000..2bb13380314
--- /dev/null
+++ b/mit-pthreads/machdep/alpha-osf1/__signal.h
@@ -0,0 +1,106 @@
+#include <standards.h>
+
+typedef int sig_atomic_t; /* accessable as an atomic entity (ANSI) */
+
+/*
+ * valid signal values: all undefined values are reserved for future use
+ * note: POSIX requires a value of 0 to be used as the null signal in kill()
+ */
+#define SIGHUP 1 /* hangup, generated when terminal disconnects */
+#define SIGINT 2 /* interrupt, generated from terminal special char */
+#define SIGQUIT 3 /* (*) quit, generated from terminal special char */
+#define SIGILL 4 /* (*) illegal instruction (not reset when caught)*/
+#define SIGTRAP 5 /* (*) trace trap (not reset when caught) */
+#define SIGABRT 6 /* (*) abort process */
+#define SIGEMT 7 /* EMT instruction */
+#define SIGFPE 8 /* (*) floating point exception */
+#define SIGKILL 9 /* kill (cannot be caught or ignored) */
+#define SIGBUS 10 /* (*) bus error (specification exception) */
+#define SIGSEGV 11 /* (*) segmentation violation */
+#define SIGSYS 12 /* (*) bad argument to system call */
+#define SIGPIPE 13 /* write on a pipe with no one to read it */
+#define SIGALRM 14 /* alarm clock timeout */
+#define SIGTERM 15 /* software termination signal */
+#define SIGURG 16 /* (+) urgent contition on I/O channel */
+#define SIGSTOP 17 /* (@) stop (cannot be caught or ignored) */
+#define SIGTSTP 18 /* (@) interactive stop */
+#define SIGCONT 19 /* (!) continue (cannot be caught or ignored) */
+#define SIGCHLD 20 /* (+) sent to parent on child stop or exit */
+#define SIGTTIN 21 /* (@) background read attempted from control terminal*/
+#define SIGTTOU 22 /* (@) background write attempted to control terminal */
+#define SIGIO 23 /* (+) I/O possible, or completed */
+#define SIGXCPU 24 /* cpu time limit exceeded (see setrlimit()) */
+#define SIGXFSZ 25 /* file size limit exceeded (see setrlimit()) */
+#define SIGVTALRM 26 /* virtual time alarm (see setitimer) */
+#define SIGPROF 27 /* profiling time alarm (see setitimer) */
+#define SIGWINCH 28 /* (+) window size changed */
+#define SIGINFO 29 /* information request */
+#define SIGUSR1 30 /* user defined signal 1 */
+#define SIGUSR2 31 /* user defined signal 2 */
+#define SIGMAX 31
+#define NSIG 31
+
+/*
+ * additional signal names supplied for compatibility, only
+ */
+#define SIGIOINT SIGURG /* printer to backend error signal */
+#define SIGAIO SIGIO /* base lan i/o */
+#define SIGPTY SIGIO /* pty i/o */
+#define SIGPOLL SIGIO /* STREAMS version of this signal */
+#define SIGIOT SIGABRT /* abort (terminate) process */
+#define SIGLOST SIGIOT /* old BSD signal ?? */
+#define SIGPWR SIGINFO /* Power Fail/Restart -- SVID3/SVR4 */
+#define SIGCLD SIGCHLD
+
+/*
+ * valid signal action values; other values => pointer to handler function
+ */
+#define SIG_DFL (void (*)())0
+#define SIG_IGN (void (*)())1
+
+/*
+ * values of "how" argument to sigprocmask() call
+ */
+#define SIG_BLOCK 1
+#define SIG_UNBLOCK 2
+#define SIG_SETMASK 3
+
+/*
+ * sigaction structure used in sigaction() system call
+ * The order of the fields in this structure must match those in
+ * the sigvec structure (below).
+ */
+struct sigaction {
+ void (*sa_handler)(); /* signal handler, or action value */
+ sigset_t sa_mask; /* signals to block while in handler */
+ int sa_flags; /* signal action flags */
+};
+
+#define __SIGEMPTYSET 0
+#define __SIGFILLSET 0xffffffff
+#define __SIGADDSET(s, n) ( *(s) |= 1L << ((n) - 1), 0)
+#define __SIGDELSET(s, n) ( *(s) &= ~(1L << ((n) - 1)), 0)
+#define __SIGISMEMBER(s, n) ( (*(s) & (1L << ((n) - 1))) != (sigset_t)0)
+
+
+#define SIGSTKSZ (16384)
+#define MINSIGSTKSZ (4096)
+
+/*
+ * valid flags define for sa_flag field of sigaction structure
+ */
+#define SA_ONSTACK 0x00000001 /* run on special signal stack */
+#define SA_RESTART 0x00000002 /* restart system calls on sigs */
+#define SA_NOCLDSTOP 0x00000004 /* do not set SIGCHLD for child stops*/
+#define SA_NODEFER 0x00000008 /* don't block while handling */
+#define SA_RESETHAND 0x00000010 /* old sys5 style behavior */
+#define SA_NOCLDWAIT 0x00000020 /* no zombies */
+#define SA_SIGINFO 0x00000040 /* deliver siginfo to handler */
+
+/* This is for sys/time.h */
+/* Removed for OSF1 V3.2
+typedef union sigval {
+ int sival_int;
+ void *sival_ptr;
+} sigval_t;
+*/
diff --git a/mit-pthreads/machdep/alpha-osf1/__stdio.h b/mit-pthreads/machdep/alpha-osf1/__stdio.h
new file mode 100755
index 00000000000..39801b125c8
--- /dev/null
+++ b/mit-pthreads/machdep/alpha-osf1/__stdio.h
@@ -0,0 +1,13 @@
+
+#ifndef _FPOS_T
+#define _FPOS_T
+typedef pthread_fpos_t fpos_t; /* Must match off_t <sys/types.h> */
+#endif
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef pthread_size_t size_t;
+#endif
+
+#define HAVE_SYS_ERRLIST_WITHOUT_CONST
+
diff --git a/mit-pthreads/machdep/alpha-osf1/__stdlib.h b/mit-pthreads/machdep/alpha-osf1/__stdlib.h
new file mode 100755
index 00000000000..79ca737e0c8
--- /dev/null
+++ b/mit-pthreads/machdep/alpha-osf1/__stdlib.h
@@ -0,0 +1,3 @@
+/* bleah */
+
+#include <stddef.h>
diff --git a/mit-pthreads/machdep/alpha-osf1/__string.h b/mit-pthreads/machdep/alpha-osf1/__string.h
new file mode 100755
index 00000000000..6558102a282
--- /dev/null
+++ b/mit-pthreads/machdep/alpha-osf1/__string.h
@@ -0,0 +1,19 @@
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef pthread_size_t size_t;
+#endif
+
+__BEGIN_DECLS
+
+/*
+void * memchr __P_((const void *, int , size_t ));
+void * memcpy __P_((void *, const void *, size_t ));
+void * memset __P_((void *, int , size_t ));
+size_t strcspn __P_((const char *, const char *));
+size_t strlen __P_((const char *));
+size_t strspn __P_((const char *, const char *));
+*/
+
+__END_DECLS
+
diff --git a/mit-pthreads/machdep/alpha-osf1/__time.h b/mit-pthreads/machdep/alpha-osf1/__time.h
new file mode 100755
index 00000000000..b4ce1ead2bf
--- /dev/null
+++ b/mit-pthreads/machdep/alpha-osf1/__time.h
@@ -0,0 +1,21 @@
+#include <pthread/types.h>
+#include <machine/machtime.h> /* CLOCKS_PER_SEC is defined here */
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef pthread_size_t size_t;
+#endif
+
+#ifndef _CLOCK_T
+#define _CLOCK_T
+typedef pthread_clock_t clock_t;
+#endif
+
+#ifndef _TIME_T
+#define _TIME_T
+typedef pthread_time_t time_t;
+#endif
+
+#ifndef CLK_TCK
+#define CLK_TCK 60
+#endif
diff --git a/mit-pthreads/machdep/alpha-osf1/__unistd.h b/mit-pthreads/machdep/alpha-osf1/__unistd.h
new file mode 100755
index 00000000000..2a7fbe9389b
--- /dev/null
+++ b/mit-pthreads/machdep/alpha-osf1/__unistd.h
@@ -0,0 +1,6 @@
+#include <sys/types.h>
+
+#ifndef _SSIZE_T
+#define _SSIZE_T
+typedef long ssize_t; /* Added by monty */
+#endif
diff --git a/mit-pthreads/machdep/alpha-osf1/cdefs.h b/mit-pthreads/machdep/alpha-osf1/cdefs.h
new file mode 100755
index 00000000000..c9b54f033ec
--- /dev/null
+++ b/mit-pthreads/machdep/alpha-osf1/cdefs.h
@@ -0,0 +1,62 @@
+/* ==== cdefs.h ============================================================
+ * Copyright (c) 1994 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Similar to the BSD cdefs.h file.
+ *
+ * 1.00 94/01/26 proven
+ * -Started coding this file.
+ */
+
+#ifndef _PTHREAD_SYS_CDEFS_H_
+#define _PTHREAD_SYS_CDEFS_H_
+
+/* Stuff for compiling */
+#if defined(__GNUC__)
+#if defined(__cplusplus)
+#define __INLINE static inline
+#define __BEGIN_DECLS extern "C" {
+#define __END_DECLS };
+#else
+#define __INLINE extern inline
+#define __CAN_DO_EXTERN_INLINE
+#define __BEGIN_DECLS
+#define __END_DECLS
+#if !defined(__STDC__)
+#define const __const
+#define inline __inline
+#define signed __signed
+#define volatile __volatile
+#endif
+#endif
+#else /* !__GNUC__ */
+#define __BEGIN_DECLS
+#define __END_DECLS
+#define __INLINE static
+#define inline
+#endif
+
+#ifndef __NORETURN
+#define __NORETURN
+#endif /* __NORETURN not defined. */
+
+#ifndef _U_INT32_T_
+#define _U_INT32_T_
+typedef unsigned int u_int32_t;
+#endif
+
+#ifndef _U_INT16_T_
+#define _U_INT16_T_
+typedef unsigned short u_int16_t;
+#endif
+
+#ifndef _INT32_T_
+#define _INT32_T_
+typedef int int32_t;
+#endif
+
+#ifndef _INT16_T_
+#define _INT16_T_
+typedef short int16_t;
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/alpha-osf1/compat.h b/mit-pthreads/machdep/alpha-osf1/compat.h
new file mode 100755
index 00000000000..4c2801e05de
--- /dev/null
+++ b/mit-pthreads/machdep/alpha-osf1/compat.h
@@ -0,0 +1 @@
+#define omsghdr msghdr
diff --git a/mit-pthreads/machdep/alpha-osf1/dirent.h b/mit-pthreads/machdep/alpha-osf1/dirent.h
new file mode 100755
index 00000000000..697ef7b8a8c
--- /dev/null
+++ b/mit-pthreads/machdep/alpha-osf1/dirent.h
@@ -0,0 +1,7 @@
+struct dirent {
+ ino_t d_ino;
+ ushort_t d_reclen, d_namlen;
+ char d_name[256];
+};
+#define d_fileno d_ino
+#define MAXNAMLEN 256
diff --git a/mit-pthreads/machdep/alpha-osf1/signal.h b/mit-pthreads/machdep/alpha-osf1/signal.h
new file mode 100755
index 00000000000..c387f9f31ad
--- /dev/null
+++ b/mit-pthreads/machdep/alpha-osf1/signal.h
@@ -0,0 +1,3 @@
+
+
+#include <signal.h>
diff --git a/mit-pthreads/machdep/alpha-osf1/socket.h b/mit-pthreads/machdep/alpha-osf1/socket.h
new file mode 100755
index 00000000000..28e17ca463d
--- /dev/null
+++ b/mit-pthreads/machdep/alpha-osf1/socket.h
@@ -0,0 +1,296 @@
+/*
+ * Copyright (c) 1982,1985,1986,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.
+ *
+ * @(#)socket.h 7.13 (Berkeley) 4/20/91
+ */
+
+#ifndef _SOCKET_H_
+#define _SOCKET_H_
+
+/*
+ * Definitions related to sockets: types, address families, options.
+ */
+
+/*
+ * Types
+ */
+#define SOCK_STREAM 1 /* stream socket */
+#define SOCK_DGRAM 2 /* datagram socket */
+#define SOCK_RAW 4 /* raw-protocol interface */
+#define SOCK_RDM 5 /* reliably-delivered message */
+#define SOCK_SEQPACKET 6 /* sequenced packet stream */
+
+/*
+ * Option flags per-socket.
+ */
+#define SO_DEBUG 0x0001 /* turn on debugging info recording */
+#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
+#define SO_REUSEADDR 0x0004 /* allow local address reuse */
+#define SO_KEEPALIVE 0x0008 /* keep connections alive */
+#define SO_DONTROUTE 0x0010 /* just use interface addresses */
+#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
+#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
+#define SO_LINGER 0x0080 /* linger on close if data present */
+#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
+
+/*
+ * Additional options, not kept in so_options.
+ */
+#define SO_SNDBUF 0x1001 /* send buffer size */
+#define SO_RCVBUF 0x1002 /* receive buffer size */
+#define SO_SNDLOWAT 0x1003 /* send low-water mark */
+#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
+#define SO_SNDTIMEO 0x1005 /* send timeout */
+#define SO_RCVTIMEO 0x1006 /* receive timeout */
+#define SO_ERROR 0x1007 /* get error status and clear */
+#define SO_TYPE 0x1008 /* get socket type */
+#define SO_PROTOTYPE 0x1009 /* get/set protocol type */
+
+/*
+ * Structure used for manipulating linger option.
+ */
+struct linger {
+ int l_onoff; /* option on/off */
+ int l_linger; /* linger time */
+};
+
+/*
+ * Level number for (get/set)sockopt() to apply to socket itself.
+ */
+#define SOL_SOCKET 0xffff /* options for socket level */
+
+/*
+ * Address families.
+ */
+#define AF_UNSPEC 0 /* unspecified */
+#define AF_UNIX 1 /* local to host (pipes, portals) */
+#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
+#define AF_IMPLINK 3 /* arpanet imp addresses */
+#define AF_PUP 4 /* pup protocols: e.g. BSP */
+#define AF_CHAOS 5 /* mit CHAOS protocols */
+#define AF_NS 6 /* XEROX NS protocols */
+#define AF_NBS 7 /* nbs protocols */
+#define AF_ECMA 8 /* european computer manufacturers */
+#define AF_DATAKIT 9 /* datakit protocols */
+#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
+#define AF_SNA 11 /* IBM SNA */
+#define AF_DECnet 12 /* DECnet */
+#define AF_DLI 13 /* DEC Direct data link interface */
+#define AF_LAT 14 /* LAT */
+#define AF_HYLINK 15 /* NSC Hyperchannel */
+#define AF_APPLETALK 16 /* Apple Talk */
+#define AF_NIT 17 /* Network Interface Tap */
+#define AF_802 18 /* IEEE 802.2, also ISO 8802 */
+#define AF_ISO 19 /* ISO protocols */
+#define AF_OSI AF_ISO
+#define AF_X25 20 /* CCITT X.25 in particular */
+#define AF_OSINET 21
+#define AF_GOSIP 22
+#define AF_MAX 22
+
+/* Not supported by solaris */
+/* #define AF_ROUTE 17 /* Internal Routing Protocol */
+/* #define AF_LINK 18 /* Link layer interface */
+/* #define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */
+
+
+/*
+ * Structure used by kernel to store most
+ * addresses.
+ */
+struct sockaddr {
+ u_short sa_family; /* address family */
+ char sa_data[14]; /* actually longer; address value */
+};
+
+/*
+ * Structure used by kernel to pass protocol
+ * information in raw sockets.
+ */
+struct sockproto {
+ u_short sp_family; /* address family */
+ u_short sp_protocol; /* protocol */
+};
+
+/*
+ * Protocol families, same as address families for now.
+ */
+#define PF_UNSPEC AF_UNSPEC
+#define PF_UNIX AF_UNIX
+#define PF_INET AF_INET
+#define PF_IMPLINK AF_IMPLINK
+#define PF_PUP AF_PUP
+#define PF_CHAOS AF_CHAOS
+#define PF_NS AF_NS
+#define PF_NBS AF_NBS
+#define PF_ECMA AF_ECMA
+#define PF_DATAKIT AF_DATAKIT
+#define PF_CCITT AF_CCITT
+#define PF_SNA AF_SNA
+#define PF_DECnet AF_DECnet
+#define PF_DLI AF_DLI
+#define PF_LAT AF_LAT
+#define PF_HYLINK AF_HYLINK
+#define PF_APPLETALK AF_APPLETALK
+#define PF_NIT AF_NIT
+#define PF_802 AF_802
+#define PF_ISO AF_ISO
+#define PF_OSI AF_ISO
+#define PF_X25 AF_X25
+#define PF_OSINET AF_OSINET
+#define PF_GOSIP AF_GOSIP
+#define PF_MAX AF_MAX
+
+/* #define PF_ROUTE AF_ROUTE */
+/* #define PF_LINK AF_LINK */
+/* #define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */
+
+/*
+ * Maximum queue length specifiable by listen.
+ */
+#define SOMAXCONN 5
+
+/*
+ * Message header for recvmsg and sendmsg calls.
+ * Used value-result for recvmsg, value only for sendmsg.
+ */
+struct msghdr {
+ caddr_t msg_name; /* optional address */
+ u_int msg_namelen; /* size of address */
+ struct iovec *msg_iov; /* scatter/gather array */
+ u_int msg_iovlen; /* # elements in msg_iov */
+ caddr_t msg_accrights; /* access rights sent/received */
+ int msg_accrightslen;
+};
+
+#define MSG_MAXIOVLEN 16
+
+#define MSG_OOB 0x1 /* process out-of-band data */
+#define MSG_PEEK 0x2 /* peek at incoming message */
+#define MSG_DONTROUTE 0x4 /* send without using routing tables */
+
+/* #define MSG_EOR 0x8 data completes record */
+/* #define MSG_TRUNC 0x10 data discarded before delivery */
+/* #define MSG_CTRUNC 0x20 control data lost before delivery */
+/* #define MSG_WAITALL 0x40 wait for full request or error */
+
+/*
+ * Header for ancillary data objects in msg_control buffer.
+ * Used for additional information with/about a datagram
+ * not expressible by flags. The format is a sequence
+ * of message elements headed by cmsghdr structures.
+ */
+struct cmsghdr {
+ u_int cmsg_len; /* data byte count, including hdr */
+ int cmsg_level; /* originating protocol */
+ int cmsg_type; /* protocol-specific type */
+/* followed by u_char cmsg_data[]; */
+};
+
+/* given pointer to struct adatahdr, return pointer to data */
+#define CMSG_DATA(cmsg) ((u_char *)((cmsg) + 1))
+
+/* given pointer to struct adatahdr, return pointer to next adatahdr */
+#define CMSG_NXTHDR(mhdr, cmsg) \
+ (((caddr_t)(cmsg) + (cmsg)->cmsg_len + sizeof(struct cmsghdr) > \
+ (mhdr)->msg_control + (mhdr)->msg_controllen) ? \
+ (struct cmsghdr *)NULL : \
+ (struct cmsghdr *)((caddr_t)(cmsg) + ALIGN((cmsg)->cmsg_len)))
+
+#define CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control)
+
+/* "Socket"-level control message types: */
+#define SCM_RIGHTS 0x01 /* access rights (array of int) */
+
+/*
+ * 4.3 compat sockaddr, move to compat file later
+ */
+struct osockaddr {
+ u_short sa_family; /* address family */
+ char sa_data[14]; /* up to 14 bytes of direct address */
+};
+
+#define SYS_socketcall 83
+
+#define SO_ACCEPT 1
+#define SO_BIND 2
+#define SO_CONNECT 3
+#define SO_GETPEERNAME 4
+#define SO_GETSOCKNAME 5
+#define SO_GETSOCKOPT 6
+#define SO_LISTEN 7
+#define SO_RECV 8
+#define SO_RECVFROM 9
+#define SO_SEND 10
+#define SO_SENDTO 11
+#define SO_SETSOCKOPT 12
+#define SO_SHUTDOWN 13
+#define SO_SOCKET 14
+#define SO_SOCKPOLL 15
+#define SO_GETIPDOMAIN 16
+#define SO_SETIPDOMAIN 17
+#define SO_ADJTIME 18
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int accept __P_((int, struct sockaddr *, int *));
+int bind __P_((int, const struct sockaddr *, int));
+int connect __P_((int, const struct sockaddr *, int));
+int getpeername __P_((int, struct sockaddr *, int *));
+int getsockname __P_((int, struct sockaddr *, int *));
+int getsockopt __P_((int, int, int, void *, int *));
+int listen __P_((int, int));
+/* original definitions
+int recv __P_((int, void *, int, int));
+int recvfrom __P_((int, void *, int, int,
+ struct sockaddr *, int *));
+int recvmsg __P_((int, struct msghdr *, int));
+int send __P_((int, const void *, int, int));
+int sendto __P_((int, const void *, int, int, const struct sockaddr *, int));
+int sendmsg __P_((int, const struct msghdr *, int));
+*/
+ssize_t recv __P_((int, void *, size_t, int));
+ssize_t recvfrom __P_((int, void *, size_t, int,
+ struct sockaddr *, int *));
+ssize_t recvmsg __P_((int, struct msghdr *, int));
+ssize_t send __P_((int, const void *, size_t, int));
+ssize_t sendto __P_((int, const void *, size_t, int,
+ const struct sockaddr *, int));
+ssize_t sendmsg __P_((int, const struct msghdr *, int));
+int setsockopt __P_((int, int, int, const void *, int));
+int shutdown __P_((int, int));
+int socket __P_((int, int, int));
+int socketpair __P_((int, int, int, int *));
+__END_DECLS
+
+#endif /* !_SOCKET_H_ */
diff --git a/mit-pthreads/machdep/alpha-osf1/timers.h b/mit-pthreads/machdep/alpha-osf1/timers.h
new file mode 100755
index 00000000000..36317d083f0
--- /dev/null
+++ b/mit-pthreads/machdep/alpha-osf1/timers.h
@@ -0,0 +1,60 @@
+/* ==== 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$
+ *
+ * Description : Basic timers header.
+ *
+ * 1.00 94/06/13 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS_TIMERS_H_
+#define _SYS_TIMERS_H_
+
+#include <sys/types.h>
+#include <time.h>
+
+struct timespec {
+ time_t tv_sec;
+ long tv_nsec;
+};
+
+#define TIMEVAL_TO_TIMESPEC(tv, ts) { \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000; \
+}
+#define TIMESPEC_TO_TIMEVAL(tv, ts) { \
+ (tv)->tv_sec = (ts)->tv_sec; \
+ (tv)->tv_usec = (ts)->tv_nsec / 1000; \
+}
+
+#endif
diff --git a/mit-pthreads/machdep/alpha-osf1/uio.h b/mit-pthreads/machdep/alpha-osf1/uio.h
new file mode 100755
index 00000000000..8d494672ee4
--- /dev/null
+++ b/mit-pthreads/machdep/alpha-osf1/uio.h
@@ -0,0 +1,12 @@
+/* N.B.: The Alpha, under OSF/1, does *not* use size_t for the length,
+ or for the returned values from readv and writev. */
+
+struct iovec {
+ void *iov_base;
+ int iov_len;
+};
+
+/* I'm assuming the iovec structures are const. I haven't verified
+ it. */
+extern ssize_t readv (int, const struct iovec *, int);
+extern ssize_t writev (int, const struct iovec *, int);
diff --git a/mit-pthreads/machdep/bsdi-1.1/compat.h b/mit-pthreads/machdep/bsdi-1.1/compat.h
new file mode 100755
index 00000000000..e6f60c372c7
--- /dev/null
+++ b/mit-pthreads/machdep/bsdi-1.1/compat.h
@@ -0,0 +1,43 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/machdep/bsdi-1.1/dirent.h b/mit-pthreads/machdep/bsdi-1.1/dirent.h
new file mode 100755
index 00000000000..d0272a4ee38
--- /dev/null
+++ b/mit-pthreads/machdep/bsdi-1.1/dirent.h
@@ -0,0 +1,73 @@
+/* BSDI $Id$ */
+
+/*-
+ * 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 {
+ unsigned long
+ d_fileno; /* file number of entry */
+ unsigned short
+ d_reclen; /* length of this record */
+ unsigned 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
+};
+
+/*
+ * There should probably be no need for this. In the BSDI sources,
+ * it is excluded if _POSIX_SOURCE is defined, and pthreads are supposed
+ * to be posix. Sources that use d_ino should really be using d_fileno.
+ * mbd
+ */
+#define d_ino d_fileno /* backward compatibility */
+
+#endif /* !_SYS_DIRENT_H_ */
+
diff --git a/mit-pthreads/machdep/bsdi-1.1/errno.h b/mit-pthreads/machdep/bsdi-1.1/errno.h
new file mode 100755
index 00000000000..3da61d692a3
--- /dev/null
+++ b/mit-pthreads/machdep/bsdi-1.1/errno.h
@@ -0,0 +1,160 @@
+/* $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/mit-pthreads/machdep/bsdi-1.1/socket.h b/mit-pthreads/machdep/bsdi-1.1/socket.h
new file mode 100755
index 00000000000..39d7c1cce26
--- /dev/null
+++ b/mit-pthreads/machdep/bsdi-1.1/socket.h
@@ -0,0 +1,277 @@
+/* BSDI $Id$ */
+
+/*
+ * Copyright (c) 1982,1985,1986,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.
+ *
+ * @(#)socket.h 7.13 (Berkeley) 4/20/91
+ */
+
+#ifndef _SOCKET_H_
+#define _SOCKET_H_
+
+/*
+ * Definitions related to sockets: types, address families, options.
+ */
+
+/*
+ * Types
+ */
+#define SOCK_STREAM 1 /* stream socket */
+#define SOCK_DGRAM 2 /* datagram socket */
+#define SOCK_RAW 3 /* raw-protocol interface */
+#define SOCK_RDM 4 /* reliably-delivered message */
+#define SOCK_SEQPACKET 5 /* sequenced packet stream */
+
+/*
+ * Option flags per-socket.
+ */
+#define SO_DEBUG 0x0001 /* turn on debugging info recording */
+#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
+#define SO_REUSEADDR 0x0004 /* allow local address reuse */
+#define SO_KEEPALIVE 0x0008 /* keep connections alive */
+#define SO_DONTROUTE 0x0010 /* just use interface addresses */
+#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
+#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
+#define SO_LINGER 0x0080 /* linger on close if data present */
+#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
+
+/*
+ * Additional options, not kept in so_options.
+ */
+#define SO_SNDBUF 0x1001 /* send buffer size */
+#define SO_RCVBUF 0x1002 /* receive buffer size */
+#define SO_SNDLOWAT 0x1003 /* send low-water mark */
+#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
+#define SO_SNDTIMEO 0x1005 /* send timeout */
+#define SO_RCVTIMEO 0x1006 /* receive timeout */
+#define SO_ERROR 0x1007 /* get error status and clear */
+#define SO_TYPE 0x1008 /* get socket type */
+
+/*
+ * Structure used for manipulating linger option.
+ */
+struct linger {
+ int l_onoff; /* option on/off */
+ int l_linger; /* linger time */
+};
+
+/*
+ * Level number for (get/set)sockopt() to apply to socket itself.
+ */
+#define SOL_SOCKET 0xffff /* options for socket level */
+
+/*
+ * Address families.
+ */
+#define AF_UNSPEC 0 /* unspecified */
+#define AF_UNIX 1 /* local to host (pipes, portals) */
+#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
+#define AF_IMPLINK 3 /* arpanet imp addresses */
+#define AF_PUP 4 /* pup protocols: e.g. BSP */
+#define AF_CHAOS 5 /* mit CHAOS protocols */
+#define AF_NS 6 /* XEROX NS protocols */
+#define AF_ISO 7 /* ISO protocols */
+#define AF_OSI AF_ISO
+#define AF_ECMA 8 /* european computer manufacturers */
+#define AF_DATAKIT 9 /* datakit protocols */
+#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
+#define AF_SNA 11 /* IBM SNA */
+#define AF_DECnet 12 /* DECnet */
+#define AF_DLI 13 /* DEC Direct data link interface */
+#define AF_LAT 14 /* LAT */
+#define AF_HYLINK 15 /* NSC Hyperchannel */
+#define AF_APPLETALK 16 /* Apple Talk */
+#define AF_ROUTE 17 /* Internal Routing Protocol */
+#define AF_LINK 18 /* Link layer interface */
+#define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */
+
+#define AF_MAX 20
+
+/*
+ * Structure used by kernel to store most
+ * addresses.
+ */
+struct sockaddr {
+ u_char sa_len; /* total length */
+ u_char sa_family; /* address family */
+ char sa_data[14]; /* actually longer; address value */
+};
+
+/*
+ * Structure used by kernel to pass protocol
+ * information in raw sockets.
+ */
+struct sockproto {
+ u_short sp_family; /* address family */
+ u_short sp_protocol; /* protocol */
+};
+
+/*
+ * Protocol families, same as address families for now.
+ */
+#define PF_UNSPEC AF_UNSPEC
+#define PF_UNIX AF_UNIX
+#define PF_INET AF_INET
+#define PF_IMPLINK AF_IMPLINK
+#define PF_PUP AF_PUP
+#define PF_CHAOS AF_CHAOS
+#define PF_NS AF_NS
+#define PF_ISO AF_ISO
+#define PF_OSI AF_ISO
+#define PF_ECMA AF_ECMA
+#define PF_DATAKIT AF_DATAKIT
+#define PF_CCITT AF_CCITT
+#define PF_SNA AF_SNA
+#define PF_DECnet AF_DECnet
+#define PF_DLI AF_DLI
+#define PF_LAT AF_LAT
+#define PF_HYLINK AF_HYLINK
+#define PF_APPLETALK AF_APPLETALK
+#define PF_ROUTE AF_ROUTE
+#define PF_LINK AF_LINK
+#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */
+
+#define PF_MAX AF_MAX
+
+/*
+ * Maximum queue length specifiable by listen.
+ */
+#define SOMAXCONN 5
+
+/*
+ * Message header for recvmsg and sendmsg calls.
+ * Used value-result for recvmsg, value only for sendmsg.
+ */
+struct msghdr {
+ caddr_t msg_name; /* optional address */
+ u_int msg_namelen; /* size of address */
+ struct iovec *msg_iov; /* scatter/gather array */
+ u_int msg_iovlen; /* # elements in msg_iov */
+ caddr_t msg_control; /* ancillary data, see below */
+ u_int msg_controllen; /* ancillary data buffer len */
+ int msg_flags; /* flags on received message */
+};
+
+#define MSG_OOB 0x1 /* process out-of-band data */
+#define MSG_PEEK 0x2 /* peek at incoming message */
+#define MSG_DONTROUTE 0x4 /* send without using routing tables */
+#define MSG_EOR 0x8 /* data completes record */
+#define MSG_TRUNC 0x10 /* data discarded before delivery */
+#define MSG_CTRUNC 0x20 /* control data lost before delivery */
+#define MSG_WAITALL 0x40 /* wait for full request or error */
+
+/*
+ * Header for ancillary data objects in msg_control buffer.
+ * Used for additional information with/about a datagram
+ * not expressible by flags. The format is a sequence
+ * of message elements headed by cmsghdr structures.
+ */
+struct cmsghdr {
+ u_int cmsg_len; /* data byte count, including hdr */
+ int cmsg_level; /* originating protocol */
+ int cmsg_type; /* protocol-specific type */
+/* followed by u_char cmsg_data[]; */
+};
+
+/* given pointer to struct adatahdr, return pointer to data */
+#define CMSG_DATA(cmsg) ((u_char *)((cmsg) + 1))
+
+/* given pointer to struct adatahdr, return pointer to next adatahdr */
+#define CMSG_NXTHDR(mhdr, cmsg) \
+ (((caddr_t)(cmsg) + (cmsg)->cmsg_len + sizeof(struct cmsghdr) > \
+ (mhdr)->msg_control + (mhdr)->msg_controllen) ? \
+ (struct cmsghdr *)NULL : \
+ (struct cmsghdr *)((caddr_t)(cmsg) + ALIGN((cmsg)->cmsg_len)))
+
+#define CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control)
+
+/* "Socket"-level control message types: */
+#define SCM_RIGHTS 0x01 /* access rights (array of int) */
+
+/*
+ * 4.3 compat sockaddr, move to compat file later
+ */
+struct osockaddr {
+ u_short sa_family; /* address family */
+ char sa_data[14]; /* up to 14 bytes of direct address */
+};
+
+/*
+ * 4.3-compat message header (move to compat file later).
+ */
+struct omsghdr {
+ caddr_t msg_name; /* optional address */
+ int msg_namelen; /* size of address */
+ struct iovec *msg_iov; /* scatter/gather array */
+ int msg_iovlen; /* # elements in msg_iov */
+ caddr_t msg_accrights; /* access rights sent/received */
+ int msg_accrightslen;
+};
+
+#ifndef KERNEL
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int accept __P_((int, struct sockaddr *, int *));
+int bind __P_((int, const struct sockaddr *, int));
+int connect __P_((int, const struct sockaddr *, int));
+int getpeername __P_((int, struct sockaddr *, int *));
+int getsockname __P_((int, struct sockaddr *, int *));
+int getsockopt __P_((int, int, int, void *, int *));
+int listen __P_((int, int));
+/* original definitions
+int recv __P_((int, void *, int, int));
+int recvfrom __P_((int, void *, int, int,
+ struct sockaddr *, int *));
+int recvmsg __P_((int, struct msghdr *, int));
+int send __P_((int, const void *, int, int));
+int sendto __P_((int, const void *, int, int, const struct sockaddr *, int));
+int sendmsg __P_((int, const struct msghdr *, int));
+*/
+ssize_t recv __P_((int, void *, size_t, int));
+ssize_t recvfrom __P_((int, void *, size_t, int,
+ struct sockaddr *, int *));
+ssize_t recvmsg __P_((int, struct msghdr *, int));
+ssize_t send __P_((int, const void *, size_t, int));
+ssize_t sendto __P_((int, const void *, size_t, int,
+ const struct sockaddr *, int));
+ssize_t sendmsg __P_((int, const struct msghdr *, int));
+int setsockopt __P_((int, int, int, const void *, int));
+int shutdown __P_((int, int));
+int socket __P_((int, int, int));
+int socketpair __P_((int, int, int, int *));
+__END_DECLS
+
+#endif /* !KERNEL */
+
+#endif /* !_SOCKET_H_ */
diff --git a/mit-pthreads/machdep/bsdi-1.1/timers.h b/mit-pthreads/machdep/bsdi-1.1/timers.h
new file mode 100755
index 00000000000..7101ab99106
--- /dev/null
+++ b/mit-pthreads/machdep/bsdi-1.1/timers.h
@@ -0,0 +1,59 @@
+/* ==== 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$
+ *
+ * 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>
+
+struct timespec {
+ time_t tv_sec;
+ long tv_nsec;
+};
+
+#define TIMEVAL_TO_TIMESPEC(tv, ts) { \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000; \
+}
+#define TIMESPEC_TO_TIMEVAL(tv, ts) { \
+ (tv)->tv_sec = (ts)->tv_sec; \
+ (tv)->tv_usec = (ts)->tv_nsec / 1000; \
+}
+
+#endif
diff --git a/mit-pthreads/machdep/bsdi-2.0/__math.h b/mit-pthreads/machdep/bsdi-2.0/__math.h
new file mode 100755
index 00000000000..2c919472f33
--- /dev/null
+++ b/mit-pthreads/machdep/bsdi-2.0/__math.h
@@ -0,0 +1,6 @@
+/*
+ * ANSI/POSIX
+ */
+/* Generate an overflow to create +Inf; the multiply shuts up gcc 1 */
+#define HUGE_VAL (1e250*1e250) /* IEEE: positive infinity */
+
diff --git a/mit-pthreads/machdep/bsdi-2.0/__path.h b/mit-pthreads/machdep/bsdi-2.0/__path.h
new file mode 100755
index 00000000000..9c347016f5f
--- /dev/null
+++ b/mit-pthreads/machdep/bsdi-2.0/__path.h
@@ -0,0 +1,13 @@
+/*
+ * from: @(#)time.h 5.12 (Berkeley) 3/9/91
+ * __path.h,v 1.1 1995/01/03 12:53:32 proven 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/mit-pthreads/machdep/bsdi-2.0/__signal.h b/mit-pthreads/machdep/bsdi-2.0/__signal.h
new file mode 100755
index 00000000000..d3deecf15e2
--- /dev/null
+++ b/mit-pthreads/machdep/bsdi-2.0/__signal.h
@@ -0,0 +1,7 @@
+#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/mit-pthreads/machdep/bsdi-2.0/__stdio.h b/mit-pthreads/machdep/bsdi-2.0/__stdio.h
new file mode 100755
index 00000000000..d4d37c2017c
--- /dev/null
+++ b/mit-pthreads/machdep/bsdi-2.0/__stdio.h
@@ -0,0 +1,7 @@
+#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/mit-pthreads/machdep/bsdi-2.0/__stdlib.h b/mit-pthreads/machdep/bsdi-2.0/__stdlib.h
new file mode 100755
index 00000000000..189bb5e8799
--- /dev/null
+++ b/mit-pthreads/machdep/bsdi-2.0/__stdlib.h
@@ -0,0 +1,60 @@
+/*-
+ * 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
+ * __stdlib.h,v 1.1 1995/01/03 12:53:34 proven 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;
+#undef _BSD_WCHAR_T_
+#endif
+
+#ifndef __NORETURN
+#define __NORETURN
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#endif /* _STDLIB_H_ */
diff --git a/mit-pthreads/machdep/bsdi-2.0/__string.h b/mit-pthreads/machdep/bsdi-2.0/__string.h
new file mode 100755
index 00000000000..275032946ea
--- /dev/null
+++ b/mit-pthreads/machdep/bsdi-2.0/__string.h
@@ -0,0 +1,19 @@
+#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/mit-pthreads/machdep/bsdi-2.0/__time.h b/mit-pthreads/machdep/bsdi-2.0/__time.h
new file mode 100755
index 00000000000..bc4d956486d
--- /dev/null
+++ b/mit-pthreads/machdep/bsdi-2.0/__time.h
@@ -0,0 +1,63 @@
+/*
+ * 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
+ * __time.h,v 1.1 1994/12/13 07:18:55 proven Exp
+ */
+
+#ifndef _SYS__TIME_H_
+#define _SYS__TIME_H_
+
+#include <machine/ansi.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
+
+#endif /* !_SYS__TIME_H_ */
diff --git a/mit-pthreads/machdep/bsdi-2.0/__unistd.h b/mit-pthreads/machdep/bsdi-2.0/__unistd.h
new file mode 100755
index 00000000000..4a5ee6a245e
--- /dev/null
+++ b/mit-pthreads/machdep/bsdi-2.0/__unistd.h
@@ -0,0 +1,109 @@
+/*-
+ * 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
+ * __unistd.h,v 1.1 1995/01/03 12:53:35 proven 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 ((unsigned char)'\377')
+
+/* 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/mit-pthreads/machdep/bsdi-2.0/compat.h b/mit-pthreads/machdep/bsdi-2.0/compat.h
new file mode 100755
index 00000000000..0dfdc27f9e8
--- /dev/null
+++ b/mit-pthreads/machdep/bsdi-2.0/compat.h
@@ -0,0 +1,65 @@
+/*-
+ * 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/mit-pthreads/machdep/bsdi-2.0/dirent.h b/mit-pthreads/machdep/bsdi-2.0/dirent.h
new file mode 100755
index 00000000000..0dfdc27f9e8
--- /dev/null
+++ b/mit-pthreads/machdep/bsdi-2.0/dirent.h
@@ -0,0 +1,65 @@
+/*-
+ * 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/mit-pthreads/machdep/bsdi-2.0/errno.h b/mit-pthreads/machdep/bsdi-2.0/errno.h
new file mode 100755
index 00000000000..1a3c37d0147
--- /dev/null
+++ b/mit-pthreads/machdep/bsdi-2.0/errno.h
@@ -0,0 +1,162 @@
+
+/* $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/mit-pthreads/machdep/bsdi-2.0/time.h b/mit-pthreads/machdep/bsdi-2.0/time.h
new file mode 100755
index 00000000000..a8bf0ff8f82
--- /dev/null
+++ b/mit-pthreads/machdep/bsdi-2.0/time.h
@@ -0,0 +1,6 @@
+#ifndef ts_sec
+#define ts_sec tv_sec
+#define ts_nsec tv_nsec
+#endif
+#include "/usr/include/sys/time.h"
+
diff --git a/mit-pthreads/machdep/bsdi-2.0/timers.h b/mit-pthreads/machdep/bsdi-2.0/timers.h
new file mode 100755
index 00000000000..b603b78e6b2
--- /dev/null
+++ b/mit-pthreads/machdep/bsdi-2.0/timers.h
@@ -0,0 +1,45 @@
+/* ==== 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.
+ *
+ * timers.h,v 1.50 1994/08/08 03:44:09 proven 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/mit-pthreads/machdep/bsdi-2.0/wait.h b/mit-pthreads/machdep/bsdi-2.0/wait.h
new file mode 100755
index 00000000000..5f7635a73a7
--- /dev/null
+++ b/mit-pthreads/machdep/bsdi-2.0/wait.h
@@ -0,0 +1,159 @@
+/* $NetBSD: wait.h,v 1.7 1994/06/29 06:46:23 cgd Exp $ */
+
+/*
+ * 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
+ */
+
+/*
+ * 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
+
diff --git a/mit-pthreads/machdep/engine-alpha-netbsd-1.1.c b/mit-pthreads/machdep/engine-alpha-netbsd-1.1.c
new file mode 100644
index 00000000000..c1ff04db16d
--- /dev/null
+++ b/mit-pthreads/machdep/engine-alpha-netbsd-1.1.c
@@ -0,0 +1,196 @@
+/* ==== 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));
+}
diff --git a/mit-pthreads/machdep/engine-alpha-netbsd-1.1.h b/mit-pthreads/machdep/engine-alpha-netbsd-1.1.h
new file mode 100644
index 00000000000..50c872da7b6
--- /dev/null
+++ b/mit-pthreads/machdep/engine-alpha-netbsd-1.1.h
@@ -0,0 +1,111 @@
+/* ==== 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/mit-pthreads/machdep/engine-alpha-netbsd-1.3.c b/mit-pthreads/machdep/engine-alpha-netbsd-1.3.c
new file mode 100644
index 00000000000..0932c421ea2
--- /dev/null
+++ b/mit-pthreads/machdep/engine-alpha-netbsd-1.3.c
@@ -0,0 +1,204 @@
+/* ==== 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/mit-pthreads/machdep/engine-alpha-netbsd-1.3.h b/mit-pthreads/machdep/engine-alpha-netbsd-1.3.h
new file mode 100644
index 00000000000..bc4178d3c41
--- /dev/null
+++ b/mit-pthreads/machdep/engine-alpha-netbsd-1.3.h
@@ -0,0 +1,114 @@
+/* ==== 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>
+#include <sys/signal.h> /* for _NSIG */
+
+/* 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 (_NSIG-1)
+
+/*
+ * 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 *));
+
+extern off_t machdep_sys_lseek(int, off_t, int);
+
+#endif
+
+__END_DECLS
diff --git a/mit-pthreads/machdep/engine-alpha-osf1.c b/mit-pthreads/machdep/engine-alpha-osf1.c
new file mode 100644
index 00000000000..9b563a56c28
--- /dev/null
+++ b/mit-pthreads/machdep/engine-alpha-osf1.c
@@ -0,0 +1,207 @@
+/* ==== machdep.c ============================================================
+ * Copyright (c) 1993, 1994 Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Machine dependent functions for SunOS-4.1.3 on sparc
+ *
+ * 1.00 93/08/04 proven
+ * -Started coding this file.
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#endif
+
+#include <pthread.h>
+#include <stdlib.h>
+
+/* These would be defined in setjmp.h, if _POSIX_SOURCE and _XOPEN_SOURCE
+ were both undefined. But we've already included it, and lost the
+ opportunity. */
+#define JB_PC 2
+#define JB_RA 30
+#define JB_PV 31
+#define JB_SP 34
+
+/* ==========================================================================
+ * machdep_save_state()
+ */
+int machdep_save_state(void)
+{
+ return setjmp (pthread_run->machdep_data.machdep_state);
+}
+
+/* ==========================================================================
+ * machdep_restore_state()
+ */
+extern void machdep_restore_from_setjmp (jmp_buf, long);
+void machdep_restore_state(void)
+{
+ machdep_restore_from_setjmp (pthread_run->machdep_data.machdep_state, 1);
+}
+
+void machdep_save_float_state (void) { }
+void machdep_restore_float_state (void) { }
+
+/* ==========================================================================
+ * 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;
+
+ 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(). */
+ machdep_pthread->machdep_state[JB_RA] = 0;
+ machdep_pthread->machdep_state[JB_PC] = (long)machdep_pthread_start;
+ machdep_pthread->machdep_state[JB_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_state[JB_SP] = stk_addr;
+ }
+}
+
+/* ==========================================================================
+ * 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 pid, int * statusp, int options)
+{
+ return machdep_sys_wait4 (pid, statusp, options, NULL);
+}
+
+/* These are found in flsbuf.o in the Alpha libc. I don't know what
+ they're for, precisely. */
+static xxx;
+_bufsync (p)
+ char *p;
+{
+ long a1 = *(long *)(p+48);
+ long t0 = *(long *)(p+8);
+ long v0 = a1 - t0;
+ long t1, t2;
+
+ abort ();
+
+ v0 += xxx;
+ if (v0 < 0)
+ {
+ *(char**)(p + 8) = p;
+ return v0;
+ }
+ t1 = *(int*)p;
+ t2 = v0 - t1;
+ if (t2 < 0)
+ *(int*)p = (int) v0;
+ return v0;
+}
+
+_findbuf () { abort (); }
+_wrtchk () { abort (); }
+_xflsbuf () { abort (); }
+_flsbuf () { abort (); }
+
+void __xxx_never_called () {
+ /* Force other stuff to get dragged in. */
+ _cleanup ();
+ fflush (NULL);
+ fclose (NULL);
+}
+
+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;
+}
diff --git a/mit-pthreads/machdep/engine-alpha-osf1.h b/mit-pthreads/machdep/engine-alpha-osf1.h
new file mode 100644
index 00000000000..fdf374ccc44
--- /dev/null
+++ b/mit-pthreads/machdep/engine-alpha-osf1.h
@@ -0,0 +1,110 @@
+/* ==== machdep.h ============================================================
+ * Copyright (c) 1994 Chris Provenzano (proven@athena.mit.edu) and
+ * Ken Raeburn (raeburn@mit.edu).
+ *
+ * $Id$
+ *
+ */
+
+#ifndef sigwait
+#define sigwait __bogus_osf1_sigwait
+#endif
+
+#include <unistd.h>
+#include <setjmp.h>
+#include <sys/time.h>
+#include <sys/cdefs.h>
+
+#undef sigwait
+
+/* 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)
+
+/*
+ * New Strutures
+ */
+struct machdep_pthread {
+ void *(*start_routine)(void *);
+ void *start_argument;
+ void *machdep_stack;
+ struct itimerval machdep_timer;
+ jmp_buf machdep_state;
+};
+
+/*
+ * 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));
+
+#endif
+
+__END_DECLS
diff --git a/mit-pthreads/machdep/engine-arm32-netbsd-1.3.c b/mit-pthreads/machdep/engine-arm32-netbsd-1.3.c
new file mode 100644
index 00000000000..510b35fdb0e
--- /dev/null
+++ b/mit-pthreads/machdep/engine-arm32-netbsd-1.3.c
@@ -0,0 +1,203 @@
+/* ==== machdep.c ============================================================
+ * Copyright (c) 1993, 1994 Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Machine dependent functions for NetBSD on arm32
+ *
+ * 1.00 93/08/04 proven
+ * -Started coding this file.
+ *
+ * 98/10/22 bad
+ * -adapt from i386 version
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#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>
+
+#if defined(_JB_REG_R13)
+#define REG_LR _JB_REG_R14
+#define REG_SP _JB_REG_R13
+#else
+#define REG_LR JMPBUF_REG_R14
+#define REG_SP JMPBUF_REG_R13
+#endif
+
+/* ==========================================================================
+ * machdep_save_state()
+ */
+int machdep_save_state(void)
+{
+ return(_setjmp(pthread_run->machdep_data.machdep_state));
+}
+
+/* ==========================================================================
+ * machdep_save_state()
+ */
+int machdep_save_float_state(struct pthread * pthread)
+{
+ return;
+}
+
+/* ==========================================================================
+ * machdep_restore_state()
+ */
+void machdep_restore_state(void)
+{
+ _longjmp(pthread_run->machdep_data.machdep_state, 1);
+}
+
+/* ==========================================================================
+ * machdep_restore_float_state()
+ */
+int machdep_restore_float_state(void)
+{
+ return;
+}
+
+/* ==========================================================================
+ * 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;
+
+ _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[REG_LR] = (int)machdep_pthread_start;
+
+ /* Stack starts high and builds down. */
+ machdep_pthread->machdep_state[REG_SP] =
+ (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));
+}
+
+/* ==========================================================================
+ * machdep_sys_getdirentries()
+ */
+machdep_sys_getdirentries(int fd, char * buf, int len, int * seek)
+{
+ return(machdep_sys_getdents(fd, buf, len));
+}
diff --git a/mit-pthreads/machdep/engine-arm32-netbsd-1.3.h b/mit-pthreads/machdep/engine-arm32-netbsd-1.3.h
new file mode 100644
index 00000000000..c8a4e79386a
--- /dev/null
+++ b/mit-pthreads/machdep/engine-arm32-netbsd-1.3.h
@@ -0,0 +1,102 @@
+/* ==== machdep.h ============================================================
+ * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
+ *
+ * Id: engine-i386-netbsd-1.3.h,v 1.1 1998/02/28 04:53:15 cjs Exp
+ *
+ */
+
+#include <unistd.h>
+#include <setjmp.h>
+#include <sys/time.h>
+#include <sys/signal.h> /* for _NSIG */
+
+/*
+ * The first machine dependent functions are the SEMAPHORES
+ * needing the test and set instruction.
+ */
+#define SEMAPHORE_CLEAR 0
+#define SEMAPHORE_SET 1
+
+#if 0
+#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
+#endif
+
+/*
+ * New types
+ */
+typedef long semaphore;
+
+/*
+ * sigset_t macros
+ */
+#define SIG_ANY(sig) (sig)
+#define SIGMAX (_NSIG-1)
+
+/*
+ * New Strutures
+ */
+struct machdep_pthread {
+ void *(*start_routine)(void *);
+ void *start_argument;
+ void *machdep_stack;
+ struct itimerval machdep_timer;
+ jmp_buf machdep_state;
+#if 0
+ char machdep_float_state[108];
+#endif
+};
+
+/*
+ * 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/mit-pthreads/machdep/engine-hppa-hpux-10.20.c b/mit-pthreads/machdep/engine-hppa-hpux-10.20.c
new file mode 100644
index 00000000000..f6f0b2e0f1d
--- /dev/null
+++ b/mit-pthreads/machdep/engine-hppa-hpux-10.20.c
@@ -0,0 +1,169 @@
+/* ==== machdep.c ============================================================
+ * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Machine dependent functions for HP-UX 9.03 on hppa
+ *
+ * 1.00 93/12/14 proven
+ * -Started coding this file.
+ */
+
+#include <pthread.h>
+#include <setjmp.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+volatile int setupStack = 0;
+
+/* ==========================================================================
+ * 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_save_float_state()
+ */
+void machdep_save_float_state(struct pthread * pthread)
+{
+ return;
+}
+
+/* ==========================================================================
+ * machdep_restore_float_state()
+ */
+void machdep_restore_float_state()
+{
+ return;
+}
+
+/* ==========================================================================
+ * 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(jmp_buf j)
+{
+ setjmp(j);
+ if( setupStack )
+ return;
+
+ 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)
+{
+ jmp_buf tmp_jmp_buf;
+
+ 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().
+ */
+ setjmp(machdep_pthread->machdep_state);
+
+ /* get the stack frame from the real machdep_pthread_start */
+ setupStack = 1;
+/* machdep_pthread_start(machdep_pthread->machdep_state); */
+ machdep_pthread_start(tmp_jmp_buf);
+ setupStack = 0;
+
+ /* copy over the interesting part of the frame */
+ ((int *)machdep_pthread->machdep_state)[44] = ((int *)tmp_jmp_buf)[44];
+
+ /* Stack starts low and builds up, but needs two start frames */
+ ((int *)machdep_pthread->machdep_state)[1] =
+ (int)machdep_pthread->machdep_stack + (64 * 2);
+}
+
+int machdep_sys_getdtablesize()
+{
+ return sysconf(_SC_OPEN_MAX);
+}
+
+void sig_check_and_resume()
+{
+ return;
+}
+
+void ___exit(int status)
+{
+ exit(status);
+ PANIC();
+}
diff --git a/mit-pthreads/machdep/engine-hppa-hpux-10.20.h b/mit-pthreads/machdep/engine-hppa-hpux-10.20.h
new file mode 100644
index 00000000000..9cbe3349a3d
--- /dev/null
+++ b/mit-pthreads/machdep/engine-hppa-hpux-10.20.h
@@ -0,0 +1,143 @@
+/* ==== machdep.h ============================================================
+ * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
+ *
+ */
+
+#include <unistd.h>
+#include <setjmp.h>
+#include <sys/time.h>
+
+/*
+ * Stuff for compiling
+ */
+#if defined(__GNUC__)
+#if defined(__cplusplus)
+#define __BEGIN_DECLS extern "C" {
+#define __END_DECLS };
+#else
+#define __BEGIN_DECLS
+#define __END_DECLS
+#if !defined(__STDC__)
+#define const __const
+#define inline __inline
+#define signed __signed
+#define volatile __volatile
+#endif
+#endif
+#else /* !__GNUC__ */
+#define __BEGIN_DECLS
+#define __END_DECLS
+#if !defined(__STDC__)
+#define const
+#endif
+#define inline
+#define signed
+#define volatile
+#endif
+
+/*
+ * The first machine dependent functions are the SEMAPHORES
+ * needing the test and set instruction.
+ *
+ * Note: The set and clear defines are backwards.
+ */
+#define SEMAPHORE_CLEAR { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }
+#define SEMAPHORE_SET 0
+
+#define SEMAPHORE_TEST_AND_SET(lock) \
+({ \
+long real_addr; \
+long temp; \
+ \
+real_addr = ((long)((*lock) + 15) & ~15); \
+ \
+__asm__ volatile("ldcwx %%r0(%2),%0" \
+ :"=r" (temp) \
+ :"0" (temp),"r" (real_addr)); \
+temp ? 0 : 1; \
+})
+
+#define SEMAPHORE_RESET(lock) \
+({ \
+char *real_addr; \
+ \
+real_addr = (char*)((long)((*lock) + 15) & ~15); \
+*real_addr = 0xff; \
+})
+
+/*
+ * New types
+ * The semaphore is really 16 bytes but must be aligened on a 16 byte
+ * boundary. By specifing 31 bytes the macros can frob it correctly.
+ */
+typedef char semaphore[31];
+
+/*
+ * Macros for sigset_t
+ */
+#define SIGMAX 30
+/* see hpux-9.03/__signal.h for SIG_ANY */
+
+/*
+ * New Strutures
+ */
+struct machdep_pthread {
+ void *(*start_routine)(void *);
+ void *start_argument;
+ void *machdep_stack;
+ struct itimerval machdep_timer;
+ jmp_buf machdep_state;
+ /* long machdep_state[_JBLEN]; */
+};
+
+/*
+ * 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 4096
+
+/*
+ * Some fd flag defines that are necessary to distinguish between posix
+ * behavior and bsd4.3 behavior.
+ */
+#define __FD_NONBLOCK O_NONBLOCK
+
+/*
+ * page size
+ */
+#define getpagesize() 4096
+
+/*
+ * 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/mit-pthreads/machdep/engine-hppa-hpux-9.03.c b/mit-pthreads/machdep/engine-hppa-hpux-9.03.c
new file mode 100644
index 00000000000..3770a2e106a
--- /dev/null
+++ b/mit-pthreads/machdep/engine-hppa-hpux-9.03.c
@@ -0,0 +1,153 @@
+/* ==== machdep.c ============================================================
+ * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Machine dependent functions for HP-UX 9.03 on hppa
+ *
+ * 1.00 93/12/14 proven
+ * -Started coding this file.
+ */
+
+#include <pthread.h>
+#include <setjmp.h>
+#include <stdlib.h>
+#include <unistd.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_save_float_state()
+ */
+void machdep_save_float_state(struct pthread * pthread)
+{
+ return;
+}
+
+/* ==========================================================================
+ * machdep_restore_float_state()
+ */
+void machdep_restore_float_state()
+{
+ return;
+}
+
+/* ==========================================================================
+ * 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;
+
+ 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().
+ */
+ ((int *)machdep_pthread->machdep_state)[0] = (int)machdep_pthread_start;
+
+ /* Stack starts low and builds up, but needs two start frames */
+ ((int *)machdep_pthread->machdep_state)[1] =
+ (int)machdep_pthread->machdep_stack + (64 * 2);
+}
+
+int machdep_sys_getdtablesize()
+{
+ return sysconf(_SC_OPEN_MAX);
+}
+
+void sig_check_and_resume()
+{
+ return;
+}
+
+void ___exit(int status)
+{
+ exit(status);
+ PANIC();
+}
diff --git a/mit-pthreads/machdep/engine-hppa-hpux-9.03.h b/mit-pthreads/machdep/engine-hppa-hpux-9.03.h
new file mode 100644
index 00000000000..7c599400e3e
--- /dev/null
+++ b/mit-pthreads/machdep/engine-hppa-hpux-9.03.h
@@ -0,0 +1,141 @@
+/* ==== machdep.h ============================================================
+ * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
+ *
+ */
+
+#include <unistd.h>
+#include <setjmp.h>
+#include <sys/time.h>
+
+/*
+ * Stuff for compiling
+ */
+#if defined(__GNUC__)
+#if defined(__cplusplus)
+#define __BEGIN_DECLS extern "C" {
+#define __END_DECLS };
+#else
+#define __BEGIN_DECLS
+#define __END_DECLS
+#if !defined(__STDC__)
+#define const __const
+#define inline __inline
+#define signed __signed
+#define volatile __volatile
+#endif
+#endif
+#else /* !__GNUC__ */
+#define __BEGIN_DECLS
+#define __END_DECLS
+#define const
+#define inline
+#define signed
+#define volatile
+#endif
+
+/*
+ * The first machine dependent functions are the SEMAPHORES
+ * needing the test and set instruction.
+ *
+ * Note: The set and clear defines are backwards.
+ */
+#define SEMAPHORE_CLEAR { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }
+#define SEMAPHORE_SET 0
+
+#define SEMAPHORE_TEST_AND_SET(lock) \
+({ \
+long real_addr; \
+long temp; \
+ \
+real_addr = ((long)((*lock) + 15) & ~15); \
+ \
+__asm__ volatile("ldcwx %%r0(%2),%0" \
+ :"=r" (temp) \
+ :"0" (temp),"r" (real_addr)); \
+temp ? 0 : 1; \
+})
+
+#define SEMAPHORE_RESET(lock) \
+({ \
+char *real_addr; \
+ \
+real_addr = (char*)((long)((*lock) + 15) & ~15); \
+*real_addr = 0xff; \
+})
+
+/*
+ * New types
+ * The semaphore is really 16 bytes but must be aligened on a 16 byte
+ * boundary. By specifing 31 bytes the macros can frob it correctly.
+ */
+typedef char semaphore[31];
+
+/*
+ * Macros for sigset_t
+ */
+#define SIGMAX 30
+/* see hpux-9.03/__signal.h for SIG_ANY */
+
+/*
+ * New Strutures
+ */
+struct machdep_pthread {
+ void *(*start_routine)(void *);
+ void *start_argument;
+ void *machdep_stack;
+ struct itimerval machdep_timer;
+ jmp_buf machdep_state;
+ /* long machdep_state[_JBLEN]; */
+};
+
+/*
+ * 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 4096
+
+/*
+ * Some fd flag defines that are necessary to distinguish between posix
+ * behavior and bsd4.3 behavior.
+ */
+#define __FD_NONBLOCK O_NONBLOCK
+
+/*
+ * page size
+ */
+#define getpagesize() 4096
+
+/*
+ * 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/mit-pthreads/machdep/engine-i386-bsdi-1.1.c b/mit-pthreads/machdep/engine-i386-bsdi-1.1.c
new file mode 100644
index 00000000000..da78bef393e
--- /dev/null
+++ b/mit-pthreads/machdep/engine-i386-bsdi-1.1.c
@@ -0,0 +1,180 @@
+/* ==== 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.
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#endif
+
+#include <pthread.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <fcntl.h>
+#include <stdio.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 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_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 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_send()
+ */
+machdep_sys_send(int s, const void *buf, int len, int flags)
+{
+ return(machdep_sys_sendto(s, buf, len, flags, (struct sockaddr*)NULL, 0));
+}
+
+/* ==========================================================================
+ * machdep_sys_recv()
+ */
+machdep_sys_recv(int s, void *buf, int len, int flags)
+{
+ return(machdep_sys_recvfrom(s, buf, len, flags, (struct sockaddr*)NULL, 0));
+}
diff --git a/mit-pthreads/machdep/engine-i386-bsdi-1.1.h b/mit-pthreads/machdep/engine-i386-bsdi-1.1.h
new file mode 100644
index 00000000000..7f7b8a62d06
--- /dev/null
+++ b/mit-pthreads/machdep/engine-i386-bsdi-1.1.h
@@ -0,0 +1,84 @@
+/* ==== machdep.h ============================================================
+ * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
+ *
+ * $Id$
+ *
+ */
+
+#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;
+};
+
+/*
+ * 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)
+
+int machdep_save_state __P_((void));
+
+#endif
+
+__END_DECLS
+
diff --git a/mit-pthreads/machdep/engine-i386-bsdi-2.0.c b/mit-pthreads/machdep/engine-i386-bsdi-2.0.c
new file mode 100644
index 00000000000..63a6de1b092
--- /dev/null
+++ b/mit-pthreads/machdep/engine-i386-bsdi-2.0.c
@@ -0,0 +1,210 @@
+/* ==== 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.
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#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(_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)
+{
+ _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;
+
+ _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));
+}
+
diff --git a/mit-pthreads/machdep/engine-i386-bsdi-2.0.h b/mit-pthreads/machdep/engine-i386-bsdi-2.0.h
new file mode 100644
index 00000000000..3be254b4090
--- /dev/null
+++ b/mit-pthreads/machdep/engine-i386-bsdi-2.0.h
@@ -0,0 +1,98 @@
+/* ==== machdep.h ============================================================
+ * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
+ *
+ * engine-i386-netbsd-1.0.h,v 1.53 1994/12/13 07:17:23 proven 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|O_NDELAY)
+
+/*
+ * 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/mit-pthreads/machdep/engine-i386-freebsd-1.1.c b/mit-pthreads/machdep/engine-i386-freebsd-1.1.c
new file mode 100644
index 00000000000..422193e77e3
--- /dev/null
+++ b/mit-pthreads/machdep/engine-i386-freebsd-1.1.c
@@ -0,0 +1,179 @@
+/* ==== 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.
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#endif
+
+#include <pthread.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <stdio.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 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_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 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_send()
+ */
+machdep_sys_send(int s, const void *buf, int len, int flags)
+{
+ return(machdep_sys_sendto(s, buf, len, flags, NULL, 0));
+}
+
+/* ==========================================================================
+ * machdep_sys_recv()
+ */
+machdep_sys_recv(int s, void *buf, int len, int flags)
+{
+ return(machdep_sys_recvfrom(s, buf, len, flags, NULL, 0));
+}
diff --git a/mit-pthreads/machdep/engine-i386-freebsd-1.1.h b/mit-pthreads/machdep/engine-i386-freebsd-1.1.h
new file mode 100644
index 00000000000..0e8e93bdbfb
--- /dev/null
+++ b/mit-pthreads/machdep/engine-i386-freebsd-1.1.h
@@ -0,0 +1,83 @@
+/* ==== machdep.h ============================================================
+ * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
+ *
+ * $Id$
+ *
+ */
+
+#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;
+};
+
+/*
+ * 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)
+
+int machdep_save_state __P_((void));
+
+#endif
+
+__END_DECLS
diff --git a/mit-pthreads/machdep/engine-i386-freebsd-2.0.c b/mit-pthreads/machdep/engine-i386-freebsd-2.0.c
new file mode 100644
index 00000000000..3b6b8f31ae0
--- /dev/null
+++ b/mit-pthreads/machdep/engine-i386-freebsd-2.0.c
@@ -0,0 +1,208 @@
+/* ==== 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->_jb[0] = (int)machdep_pthread_start;
+
+ /* Stack starts high and builds down. */
+ machdep_pthread->machdep_state->_jb[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));
+}
+
diff --git a/mit-pthreads/machdep/engine-i386-freebsd-2.0.h b/mit-pthreads/machdep/engine-i386-freebsd-2.0.h
new file mode 100644
index 00000000000..87ef21389ce
--- /dev/null
+++ b/mit-pthreads/machdep/engine-i386-freebsd-2.0.h
@@ -0,0 +1,97 @@
+/* ==== machdep.h ============================================================
+ * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
+ *
+ * $Id$
+ *
+ */
+
+#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/mit-pthreads/machdep/engine-i386-linux-1.0.c b/mit-pthreads/machdep/engine-i386-linux-1.0.c
new file mode 100644
index 00000000000..fac044fe47c
--- /dev/null
+++ b/mit-pthreads/machdep/engine-i386-linux-1.0.c
@@ -0,0 +1,503 @@
+/* ==== machdep.c ============================================================
+ * Copyright (c) 1993, 1994 Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Machine dependent functions for Linux-1.0 on i386
+ *
+ * 1.00 93/08/04 proven
+ * -Started coding this file.
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <sys/uio.h>
+#include <sys/types.h>
+#include <sys/param.h> /* for OPEN_MAX */
+#include <sys/socket.h>
+#include <sys/socketcall.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_save_float_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_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} };
+
+ 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 flag)
+{
+ 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 stact frame so that it looks like it
+ * returned from a longjmp() to the beginning of
+ * 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 =
+ (char *)machdep_pthread->machdep_stack + stack_size;
+}
+
+
+/* ==========================================================================
+ * Linux Socket calls are a bit different
+ * ==========================================================================
+ * machdep_sys_socket()
+ */
+int machdep_sys_socket(int a, int b, int c)
+{
+ int array[3];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+
+ return(machdep_sys_socketcall(SYS_SOCKET, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_accept()
+ */
+int machdep_sys_accept(int a, struct sockaddr * b, int * c)
+{
+ int array[3];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+
+ return(machdep_sys_socketcall(SYS_ACCEPT, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_bind()
+ */
+int machdep_sys_bind(int a, const struct sockaddr * b, int c)
+{
+ int array[3];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+
+ return(machdep_sys_socketcall(SYS_BIND, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_connect()
+ */
+int machdep_sys_connect(int a, const struct sockaddr * b, int c)
+{
+ int array[3];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+
+ return(machdep_sys_socketcall(SYS_CONNECT, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_listen()
+ */
+int machdep_sys_listen(int a, const struct sockaddr * b, int c)
+{
+ int array[3];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+
+ return(machdep_sys_socketcall(SYS_LISTEN, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_shutdown()
+ */
+int machdep_sys_shutdown(int a, int b)
+{
+ int array[2];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+
+ return(machdep_sys_socketcall(SYS_SHUTDOWN, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_getsockopt()
+ */
+int machdep_sys_getsockopt(int a, int b, int c, char *d, int *e)
+{
+ int array[5];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+ array[3] = (int)d;
+ array[4] = (int)e;
+
+ return(machdep_sys_socketcall(SYS_GETSOCKOPT, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_setsockopt()
+ */
+int machdep_sys_setsockopt(int a, int b, int c, char *d, int e)
+{
+ int array[5];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+ array[3] = (int)d;
+ array[4] = (int)e;
+
+ return(machdep_sys_socketcall(SYS_SETSOCKOPT, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_getpeername()
+ */
+int machdep_sys_getpeername(int a, struct sockaddr *b, int *c)
+{
+ int array[3];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+
+ return(machdep_sys_socketcall(SYS_GETPEERNAME, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_send()
+ */
+int machdep_sys_send(int a, char *b, int c, int d)
+{
+ int array[4];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+ array[3] = (int)d;
+
+ return(machdep_sys_socketcall(SYS_SEND, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_sendto()
+ */
+int machdep_sys_sendto(int a, char *b, int c, int d,
+ struct sockaddr *e, int f)
+{
+ int array[6];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+ array[3] = (int)d;
+ array[4] = (int)e;
+ array[5] = (int)f;
+
+ return(machdep_sys_socketcall(SYS_SENDTO, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_recv()
+ */
+int machdep_sys_recv(int a, char *b, int c, int d)
+{
+ int array[4];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+ array[3] = (int)d;
+
+ return(machdep_sys_socketcall(SYS_RECV, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_recvfrom()
+ */
+int machdep_sys_recvfrom(int a, char *b, int c, int d,
+ struct sockaddr *e, int *f)
+{
+ int array[6];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+ array[3] = (int)d;
+ array[4] = (int)e;
+ array[5] = (int)f;
+
+ return(machdep_sys_socketcall(SYS_RECVFROM, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_socketpair()
+ */
+int machdep_sys_socketpair(int a, int b, int c, int d[2])
+{
+ int array[4];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+ array[3] = (int)d;
+
+ return(machdep_sys_socketcall(SYS_SOCKETPAIR, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_getsockname()
+ */
+int machdep_sys_getsockname(int a, char * b, int * c)
+{
+ int array[3];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+
+ return(machdep_sys_socketcall(SYS_GETSOCKNAME, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_sendmsg()
+ */
+int machdep_sys_sendmsg(int a, char * b, int c)
+{
+#ifdef SYS_SENDMSG
+ int array[3];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+
+ return(machdep_sys_socketcall(SYS_SENDMSG, array));
+#else
+ return(-ENOSYS);
+#endif
+}
+
+/* ==========================================================================
+ * machdep_sys_recvmsg()
+ */
+int machdep_sys_recvmsg(int a, char * b, int c)
+{
+#ifdef SYS_RECVMSG
+ int array[3];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+
+ return(machdep_sys_socketcall(SYS_RECVMSG, array));
+#else
+ return(-ENOSYS);
+#endif
+}
+
+/* ==========================================================================
+ * machdep_sys_getdirentries()
+ */
+int machdep_sys_getdirentries(int fd, char * buf, int len, int * seek)
+{
+ int ret;
+
+ if ((ret = machdep_sys_readdir(fd, buf, 1)) > 0) {
+ return(1);
+ }
+ return(ret);
+}
+
+/* ==========================================================================
+ * 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));
+}
+
+/* getdtablesize */
+machdep_sys_getdtablesize ()
+{
+ return OPEN_MAX;
+}
+
+struct stat;
+
+/* ==========================================================================
+ * _fxstat()
+ */
+int _fxstat(int __ver, int fd, struct stat *buf)
+{
+ int ret;
+
+ if ((ret = fd_lock(fd, FD_READ, NULL)) == OK) {
+ ret = machdep_sys_fstat(fd_table[fd]->fd.i, buf);
+ fd_unlock(fd, FD_READ);
+ }
+ return(ret);
+}
+
+/* ==========================================================================
+ * _lxstat()
+ */
+int _lxstat(int __ver, const char * path, struct stat * buf)
+{
+ int ret;
+
+ if ((ret = machdep_sys_lstat(path, buf)) < OK) {
+ SET_ERRNO(-ret);
+ }
+ return(ret);
+
+}
+
+/* ==========================================================================
+ * _xstat()
+ */
+int _xstat(int __ver, const char * path, struct stat * buf)
+{
+ int ret;
+
+ if ((ret = machdep_sys_stat(path, buf)) < OK) {
+ SET_ERRNO(-ret);
+ }
+ return(ret);
+
+}
+
+/* ==========================================================================
+ * strtol()
+ */
+__strtol_internal(char * a, char ** b, int c)
+{
+ return(strtol(a, b, c));
+}
+
+
diff --git a/mit-pthreads/machdep/engine-i386-linux-1.0.h b/mit-pthreads/machdep/engine-i386-linux-1.0.h
new file mode 100644
index 00000000000..721618a6f19
--- /dev/null
+++ b/mit-pthreads/machdep/engine-i386-linux-1.0.h
@@ -0,0 +1,98 @@
+/* ==== machdep.h ============================================================
+ * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
+ *
+ * $Id$
+ */
+
+
+#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) \
+({ \
+volatile long temp = SEMAPHORE_SET; \
+ \
+__asm__("xchgl %0,(%2)" \
+ :"=r" (temp) \
+ :"0" (temp),"r" (lock)); \
+temp; \
+})
+
+#define SEMAPHORE_RESET(lock) *lock = SEMAPHORE_CLEAR
+
+/*
+ * New types
+ */
+typedef long semaphore;
+
+#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
+
+/*
+ * sigset_t macros
+ */
+#define SIG_ANY(sig) (sig)
+
+/*
+ * 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/mit-pthreads/machdep/engine-i386-linux-2.0.c b/mit-pthreads/machdep/engine-i386-linux-2.0.c
new file mode 100644
index 00000000000..72c757fe08a
--- /dev/null
+++ b/mit-pthreads/machdep/engine-i386-linux-2.0.c
@@ -0,0 +1,504 @@
+/* ==== machdep.c ============================================================
+ * Copyright (c) 1993, 1994 Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Machine dependent functions for Linux-1.0 on i386
+ *
+ * 1.00 93/08/04 proven
+ * -Started coding this file.
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <sys/uio.h>
+#include <sys/types.h>
+#include <sys/param.h> /* for OPEN_MAX */
+#include <sys/socket.h>
+#include <sys/socketcall.h>
+#include <linux/net.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_save_float_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_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} };
+
+ 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 flag)
+{
+ 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 stact frame so that it looks like it
+ * returned from a longjmp() to the beginning of
+ * machdep_pthread_start().
+ */
+ machdep_pthread->machdep_state->__jmpbuf[JB_PC]= (int) (char *)machdep_pthread_start;
+ /* Fix so that the backtrace * is sensible (mevans) */
+ machdep_pthread->machdep_state->__jmpbuf[JB_BP] = (int) (char *) 0;
+
+ /* Stack starts high and builds down. */
+ machdep_pthread->machdep_state->__jmpbuf[JB_SP]=
+ (int) (char *) machdep_pthread->machdep_stack + stack_size;
+}
+
+
+/* ==========================================================================
+ * Linux Socket calls are a bit different
+ * ==========================================================================
+ * machdep_sys_socket()
+ */
+int machdep_sys_socket(int a, int b, int c)
+{
+ int array[3];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+
+ return(machdep_sys_socketcall(SYS_SOCKET, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_accept()
+ */
+int machdep_sys_accept(int a, struct sockaddr * b, int * c)
+{
+ int array[3];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+
+ return(machdep_sys_socketcall(SYS_ACCEPT, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_bind()
+ */
+int machdep_sys_bind(int a, const struct sockaddr * b, int c)
+{
+ int array[3];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+
+ return(machdep_sys_socketcall(SYS_BIND, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_connect()
+ */
+int machdep_sys_connect(int a, const struct sockaddr * b, int c)
+{
+ int array[3];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+
+ return(machdep_sys_socketcall(SYS_CONNECT, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_listen()
+ */
+int machdep_sys_listen(int a, const struct sockaddr * b, int c)
+{
+ int array[3];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+
+ return(machdep_sys_socketcall(SYS_LISTEN, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_shutdown()
+ */
+int machdep_sys_shutdown(int a, int b)
+{
+ int array[2];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+
+ return(machdep_sys_socketcall(SYS_SHUTDOWN, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_getsockopt()
+ */
+int machdep_sys_getsockopt(int a, int b, int c, char *d, int *e)
+{
+ int array[5];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+ array[3] = (int)d;
+ array[4] = (int)e;
+
+ return(machdep_sys_socketcall(SYS_GETSOCKOPT, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_setsockopt()
+ */
+int machdep_sys_setsockopt(int a, int b, int c, char *d, int e)
+{
+ int array[5];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+ array[3] = (int)d;
+ array[4] = (int)e;
+
+ return(machdep_sys_socketcall(SYS_SETSOCKOPT, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_getpeername()
+ */
+int machdep_sys_getpeername(int a, struct sockaddr *b, int *c)
+{
+ int array[3];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+
+ return(machdep_sys_socketcall(SYS_GETPEERNAME, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_send()
+ */
+int machdep_sys_send(int a, char *b, int c, int d)
+{
+ int array[4];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+ array[3] = (int)d;
+
+ return(machdep_sys_socketcall(SYS_SEND, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_sendto()
+ */
+int machdep_sys_sendto(int a, char *b, int c, int d,
+ struct sockaddr *e, int f)
+{
+ int array[6];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+ array[3] = (int)d;
+ array[4] = (int)e;
+ array[5] = (int)f;
+
+ return(machdep_sys_socketcall(SYS_SENDTO, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_recv()
+ */
+int machdep_sys_recv(int a, char *b, int c, int d)
+{
+ int array[4];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+ array[3] = (int)d;
+
+ return(machdep_sys_socketcall(SYS_RECV, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_recvfrom()
+ */
+int machdep_sys_recvfrom(int a, char *b, int c, int d,
+ struct sockaddr *e, int *f)
+{
+ int array[6];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+ array[3] = (int)d;
+ array[4] = (int)e;
+ array[5] = (int)f;
+
+ return(machdep_sys_socketcall(SYS_RECVFROM, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_socketpair()
+ */
+int machdep_sys_socketpair(int a, int b, int c, int d[2])
+{
+ int array[4];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+ array[3] = (int)d;
+
+ return(machdep_sys_socketcall(SYS_SOCKETPAIR, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_getsockname()
+ */
+int machdep_sys_getsockname(int a, char * b, int * c)
+{
+ int array[3];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+
+ return(machdep_sys_socketcall(SYS_GETSOCKNAME, array));
+}
+
+/* ==========================================================================
+ * machdep_sys_sendmsg()
+ */
+int machdep_sys_sendmsg(int a, char * b, int c)
+{
+#ifdef SYS_SENDMSG
+ int array[3];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+
+ return(machdep_sys_socketcall(SYS_SENDMSG, array));
+#else
+ return(-ENOSYS);
+#endif
+}
+
+/* ==========================================================================
+ * machdep_sys_recvmsg()
+ */
+int machdep_sys_recvmsg(int a, char * b, int c)
+{
+#ifdef SYS_RECVMSG
+ int array[3];
+
+ array[0] = (int)a;
+ array[1] = (int)b;
+ array[2] = (int)c;
+
+ return(machdep_sys_socketcall(SYS_RECVMSG, array));
+#else
+ return(-ENOSYS);
+#endif
+}
+
+/* ==========================================================================
+ * machdep_sys_getdirentries()
+ */
+int machdep_sys_getdirentries(int fd, char * buf, int len, int * seek)
+{
+ int ret;
+
+ if ((ret = machdep_sys_readdir(fd, buf, 1)) > 0) {
+ return(1);
+ }
+ return(ret);
+}
+
+/* ==========================================================================
+ * 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));
+}
+
+/* getdtablesize */
+machdep_sys_getdtablesize ()
+{
+ return OPEN_MAX;
+}
+
+struct stat;
+
+/* ==========================================================================
+ * _fxstat()
+ */
+int _fxstat(int __ver, int fd, struct stat *buf)
+{
+ int ret;
+
+ if ((ret = fd_lock(fd, FD_READ, NULL)) == OK) {
+ ret = machdep_sys_fstat(fd_table[fd]->fd.i, buf);
+ fd_unlock(fd, FD_READ);
+ }
+ return(ret);
+}
+
+/* ==========================================================================
+ * _lxstat()
+ */
+int _lxstat(int __ver, const char * path, struct stat * buf)
+{
+ int ret;
+
+ if ((ret = machdep_sys_lstat(path, buf)) < OK) {
+ SET_ERRNO(-ret);
+ }
+ return(ret);
+
+}
+
+/* ==========================================================================
+ * _xstat()
+ */
+int _xstat(int __ver, const char * path, struct stat * buf)
+{
+ int ret;
+
+ if ((ret = machdep_sys_stat(path, buf)) < OK) {
+ SET_ERRNO(-ret);
+ }
+ return(ret);
+
+}
+
+/* ==========================================================================
+ * strtol()
+ */
+__strtol_internal(char * a, char ** b, int c)
+{
+ return(strtol(a, b, c));
+}
+
+
diff --git a/mit-pthreads/machdep/engine-i386-linux-2.0.h b/mit-pthreads/machdep/engine-i386-linux-2.0.h
new file mode 100644
index 00000000000..721618a6f19
--- /dev/null
+++ b/mit-pthreads/machdep/engine-i386-linux-2.0.h
@@ -0,0 +1,98 @@
+/* ==== machdep.h ============================================================
+ * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
+ *
+ * $Id$
+ */
+
+
+#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) \
+({ \
+volatile long temp = SEMAPHORE_SET; \
+ \
+__asm__("xchgl %0,(%2)" \
+ :"=r" (temp) \
+ :"0" (temp),"r" (lock)); \
+temp; \
+})
+
+#define SEMAPHORE_RESET(lock) *lock = SEMAPHORE_CLEAR
+
+/*
+ * New types
+ */
+typedef long semaphore;
+
+#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
+
+/*
+ * sigset_t macros
+ */
+#define SIG_ANY(sig) (sig)
+
+/*
+ * 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/mit-pthreads/machdep/engine-i386-netbsd-0.9.c b/mit-pthreads/machdep/engine-i386-netbsd-0.9.c
new file mode 100644
index 00000000000..c42363fdeda
--- /dev/null
+++ b/mit-pthreads/machdep/engine-i386-netbsd-0.9.c
@@ -0,0 +1,155 @@
+/* ==== 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.
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#endif
+
+#include <pthread.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdio.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 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_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 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_send()
+ */
+machdep_sys_send(int s, const void *buf, int len, int flags)
+{
+ return(machdep_sys_sendto(s, buf, len, flags, (struct sockaddr*)NULL, 0));
+}
+
+/* ==========================================================================
+ * machdep_sys_recv()
+ */
+machdep_sys_recv(int s, void *buf, int len, int flags)
+{
+ return(machdep_sys_recvfrom(s, buf, len, flags, (struct sockaddr*)NULL, 0));
+}
diff --git a/mit-pthreads/machdep/engine-i386-netbsd-0.9.h b/mit-pthreads/machdep/engine-i386-netbsd-0.9.h
new file mode 100644
index 00000000000..0e8e93bdbfb
--- /dev/null
+++ b/mit-pthreads/machdep/engine-i386-netbsd-0.9.h
@@ -0,0 +1,83 @@
+/* ==== machdep.h ============================================================
+ * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
+ *
+ * $Id$
+ *
+ */
+
+#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;
+};
+
+/*
+ * 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)
+
+int machdep_save_state __P_((void));
+
+#endif
+
+__END_DECLS
diff --git a/mit-pthreads/machdep/engine-i386-netbsd-1.0.c b/mit-pthreads/machdep/engine-i386-netbsd-1.0.c
new file mode 100644
index 00000000000..7f31cb0305d
--- /dev/null
+++ b/mit-pthreads/machdep/engine-i386-netbsd-1.0.c
@@ -0,0 +1,218 @@
+/* ==== 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.
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#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(_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)
+{
+ _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;
+
+ _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/mit-pthreads/machdep/engine-i386-netbsd-1.0.h b/mit-pthreads/machdep/engine-i386-netbsd-1.0.h
new file mode 100644
index 00000000000..80e17fef368
--- /dev/null
+++ b/mit-pthreads/machdep/engine-i386-netbsd-1.0.h
@@ -0,0 +1,97 @@
+/* ==== machdep.h ============================================================
+ * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
+ *
+ * $Id$
+ *
+ */
+
+#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/mit-pthreads/machdep/engine-i386-netbsd-1.3.c b/mit-pthreads/machdep/engine-i386-netbsd-1.3.c
new file mode 100644
index 00000000000..f86a9e5ba56
--- /dev/null
+++ b/mit-pthreads/machdep/engine-i386-netbsd-1.3.c
@@ -0,0 +1,225 @@
+/* ==== 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.
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#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(_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)
+{
+ _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;
+
+ _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));
+}
+
+/* ==========================================================================
+ * machdep_sys_getdirentries()
+ */
+machdep_sys_getdirentries(int fd, char * buf, int len, int * seek)
+{
+ return(machdep_sys_getdents(fd, buf, len));
+}
diff --git a/mit-pthreads/machdep/engine-i386-netbsd-1.3.h b/mit-pthreads/machdep/engine-i386-netbsd-1.3.h
new file mode 100644
index 00000000000..f399c4b34b6
--- /dev/null
+++ b/mit-pthreads/machdep/engine-i386-netbsd-1.3.h
@@ -0,0 +1,98 @@
+/* ==== machdep.h ============================================================
+ * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
+ *
+ * $Id$
+ *
+ */
+
+#include <unistd.h>
+#include <setjmp.h>
+#include <sys/time.h>
+#include <sys/signal.h> /* for _NSIG */
+
+/*
+ * 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 (_NSIG-1)
+
+/*
+ * 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/mit-pthreads/machdep/engine-i386-openbsd-2.0.c b/mit-pthreads/machdep/engine-i386-openbsd-2.0.c
new file mode 100644
index 00000000000..09ff0072fdc
--- /dev/null
+++ b/mit-pthreads/machdep/engine-i386-openbsd-2.0.c
@@ -0,0 +1,215 @@
+/* ==== 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/mit-pthreads/machdep/engine-i386-openbsd-2.0.h b/mit-pthreads/machdep/engine-i386-openbsd-2.0.h
new file mode 100644
index 00000000000..87ef21389ce
--- /dev/null
+++ b/mit-pthreads/machdep/engine-i386-openbsd-2.0.h
@@ -0,0 +1,97 @@
+/* ==== machdep.h ============================================================
+ * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
+ *
+ * $Id$
+ *
+ */
+
+#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/mit-pthreads/machdep/engine-i386-sco-3.2v5.c b/mit-pthreads/machdep/engine-i386-sco-3.2v5.c
new file mode 100755
index 00000000000..95f0d757585
--- /dev/null
+++ b/mit-pthreads/machdep/engine-i386-sco-3.2v5.c
@@ -0,0 +1,1072 @@
+
+/* ==== 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 SCO3.2v5 on i386
+ *
+ * 1.00 96/11/21 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/timeb.h>
+#include <sys/stat.h>
+#include <stropts.h>
+#include <sys/socket.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sys/unistd.h>
+#include <sys/utsname.h>
+#include <sys/sysi86.h>
+
+void machdep_sys_abort(char*fname,int lineno)
+
+{
+ char buf[128];
+
+ sprintf(buf,"panic: %s => %d\n", fname, lineno);
+ machdep_sys_write(1, buf, strlen(buf));
+ abort();
+}
+
+#if 0
+int setitimer(int which, struct itimerval* value, struct itimerval* ovalue)
+
+{
+ register int ret;
+ if ((ret = machdep_sys_setitimer(which,value,ovalue))<0) {
+ errno = -ret;
+ return -1;
+ }
+ else {
+ return 0;
+ }
+}
+#endif
+
+/* ==========================================================================
+ * machdep_save_state()
+ */
+int machdep_save_state(void)
+{
+ return(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)
+{
+ 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 (machdep_sys_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 = machdep_sys_setitimer(ITIMER_VIRTUAL, &zeroval,
+ &(machdep_pthread->machdep_timer));
+ } else {
+ ret = machdep_sys_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;
+
+ 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[JB_PC] = (int)machdep_pthread_start;
+
+ /* Stack starts high and builds down. */
+ machdep_pthread->machdep_state[JB_SP] =
+ (int)machdep_pthread->machdep_stack + stack_size;
+}
+
+/* ==========================================================================
+ * machdep_sys_wait3()
+ */
+machdep_sys_wait3(int * b, int c, int * d)
+{
+#if 0
+ return(machdep_sys_wait4(0, b, c, d));
+#else
+ return -ENOSYS;
+#endif
+}
+
+/* ==========================================================================
+ * machdep_sys_fstat()
+ */
+machdep_sys_fstat(int f, struct stat* b)
+{
+ return machdep_sys_fxstat(0x33, f, b);
+}
+
+/* ==========================================================================
+ * machdep_sys_dup2()
+ */
+machdep_sys_dup2(int a, int b)
+{
+ machdep_sys_close(b);
+ return machdep_sys_fcntl(a, F_DUPFD, b);
+}
+
+/* ==========================================================================
+ * machdep_sys_getdtablesize()
+ */
+machdep_sys_getdtablesize()
+
+{
+ register int ret;
+ if ((ret = machdep_sys_sysconf(_SC_OPEN_MAX))<0)
+ PANIC();
+ return ret;
+}
+
+/* ==========================================================================
+ * machdep_sys_fchown()
+ */
+machdep_sys_fchown(int fd,uid_t owner,gid_t group)
+
+{
+ return -ENOSYS;
+}
+
+/* ==========================================================================
+ * machdep_sys_fchmod()
+ */
+machdep_sys_fchmod(int fd,mode_t mode)
+
+{
+ return -ENOSYS;
+}
+
+/* ==========================================================================
+ * machdep_sys_getdirentries()
+ */
+int machdep_sys_getdirentries(int fd, char * buf, int len, int * seek)
+{
+ return(machdep_sys_getdents(fd, buf, len));
+}
+
+/* ==========================================================================
+ * SCO Socket calls are a bit different
+ * ==========================================================================
+ * machdep_sys_socket()
+ */
+int machdep_sys_socket(int domain, int type, int protocol)
+{
+ register int s, fd, ret;
+ struct socksysreq req;
+
+ if ((s = machdep_sys_open("/dev/socksys", 0))<0)
+ return s;
+
+ req.args[0] = SO_SOCKET;
+ req.args[1] = (int)domain;
+ req.args[2] = (int)type;
+ req.args[3] = (int)protocol;
+ if ((fd = machdep_sys_ioctl(s, SIOCSOCKSYS, &req))<0) {
+ machdep_sys_close(s);
+ return fd;
+ }
+
+ if ((ret=machdep_sys_dup2(fd, s))<0) {
+ machdep_sys_close(fd);
+ return ret;
+ }
+
+ machdep_sys_close(fd);
+ return s;
+
+}
+
+/* ==========================================================================
+ * machdep_sys_accept()
+ */
+int machdep_sys_accept(int s, struct sockaddr * b, int * c)
+{
+ struct socksysreq req;
+
+ req.args[0] = SO_ACCEPT;
+ req.args[1] = (int)s;
+ req.args[2] = (int)b;
+ req.args[3] = (int)c;
+
+ return(machdep_sys_ioctl(s, SIOCSOCKSYS, &req));
+}
+
+/* ==========================================================================
+ * machdep_sys_bind()
+ */
+int machdep_sys_bind(int s, const struct sockaddr * b, int c)
+{
+ struct socksysreq req;
+
+ req.args[0] = SO_BIND;
+ req.args[1] = (int)s;
+ req.args[2] = (int)b;
+ req.args[3] = (int)c;
+
+ return(machdep_sys_ioctl(s, SIOCSOCKSYS, &req));
+}
+
+/* ==========================================================================
+ * machdep_sys_connect()
+ */
+int machdep_sys_connect(int s, const struct sockaddr * b, int c)
+{
+ struct socksysreq req;
+
+ req.args[0] = SO_CONNECT;
+ req.args[1] = (int)s;
+ req.args[2] = (int)b;
+ req.args[3] = (int)c;
+
+ return(machdep_sys_ioctl(s, SIOCSOCKSYS, &req));
+}
+
+/* ==========================================================================
+ * machdep_sys_listen()
+ */
+int machdep_sys_listen(int s, int backlog)
+{
+ struct socksysreq req;
+
+ req.args[0] = SO_LISTEN;
+ req.args[1] = (int)s;
+ req.args[2] = (int)backlog;
+
+ return(machdep_sys_ioctl(s, SIOCSOCKSYS, &req));
+}
+
+/* ==========================================================================
+ * machdep_sys_shutdown()
+ */
+int machdep_sys_shutdown(int s, int b)
+{
+ struct socksysreq req;
+
+ req.args[0] = SO_SHUTDOWN;
+ req.args[1] = (int)s;
+ req.args[2] = (int)b;
+
+ return(machdep_sys_ioctl(s, SIOCSOCKSYS, &req));
+}
+
+/* ==========================================================================
+ * machdep_sys_getsockopt()
+ */
+int machdep_sys_getsockopt(int s, int b, int c, char *d, int *e)
+{
+ struct socksysreq req;
+
+ req.args[0] = SO_GETSOCKOPT;
+ req.args[1] = (int)s;
+ req.args[2] = (int)b;
+ req.args[3] = (int)c;
+ req.args[4] = (int)d;
+ req.args[5] = (int)e;
+
+ return(machdep_sys_ioctl(s, SIOCSOCKSYS, &req));
+}
+
+/* ==========================================================================
+ * machdep_sys_setsockopt()
+ */
+int machdep_sys_setsockopt(int s, int b, int c, char *d, int e)
+{
+ struct socksysreq req;
+
+ req.args[0] = SO_SETSOCKOPT;
+ req.args[1] = (int)s;
+ req.args[2] = (int)b;
+ req.args[3] = (int)c;
+ req.args[4] = (int)d;
+ req.args[5] = (int)e;
+
+ return(machdep_sys_ioctl(s, SIOCSOCKSYS, &req));
+}
+
+/* ==========================================================================
+ * machdep_sys_getpeername()
+ */
+int machdep_sys_getpeername(int s, struct sockaddr *b, int *c)
+{
+ struct socksysreq req;
+
+ req.args[0] = SO_GETPEERNAME;
+ req.args[1] = (int)s;
+ req.args[2] = (int)b;
+ req.args[3] = (int)c;
+
+ return(machdep_sys_ioctl(s, SIOCSOCKSYS, &req));
+}
+
+/* ==========================================================================
+ * machdep_sys_send()
+ */
+int machdep_sys_send(int s, char *b, int c, int d)
+{
+ struct socksysreq req;
+
+ req.args[0] = SO_SEND;
+ req.args[1] = (int)s;
+ req.args[2] = (int)b;
+ req.args[3] = (int)c;
+ req.args[4] = (int)d;
+
+ return(machdep_sys_ioctl(s, SIOCSOCKSYS, &req));
+}
+
+/* ==========================================================================
+ * machdep_sys_sendto()
+ */
+int machdep_sys_sendto(int s, char *b, int c, int d,
+ struct sockaddr *e, int f)
+{
+ struct socksysreq req;
+
+ req.args[0] = SO_SENDTO;
+ req.args[1] = (int)s;
+ req.args[2] = (int)b;
+ req.args[3] = (int)c;
+ req.args[4] = (int)d;
+ req.args[5] = (int)e;
+ req.args[6] = (int)f;
+
+ return(machdep_sys_ioctl(s, SIOCSOCKSYS, &req));
+}
+
+/* ==========================================================================
+ * machdep_sys_recv()
+ */
+int machdep_sys_recv(int s, char *b, int c, int d)
+{
+ struct socksysreq req;
+
+ req.args[0] = SO_RECV;
+ req.args[1] = (int)s;
+ req.args[2] = (int)b;
+ req.args[3] = (int)c;
+ req.args[4] = (int)d;
+
+ return(machdep_sys_ioctl(s, SIOCSOCKSYS, &req));
+}
+
+/* ==========================================================================
+ * machdep_sys_recvfrom()
+ */
+int machdep_sys_recvfrom(int s, char *buf, int len, int flags,
+ struct sockaddr *from, int *fromlen)
+{
+ struct socksysreq req;
+
+ req.args[0] = SO_RECVFROM;
+ req.args[1] = (int)s;
+ req.args[2] = (int)buf;
+ req.args[3] = (int)len;
+ req.args[4] = (int)flags;
+ req.args[5] = (int)from;
+ req.args[6] = (int)fromlen;
+
+ return(machdep_sys_ioctl(s, SIOCSOCKSYS, &req));
+}
+
+/* ==========================================================================
+ * machdep_sys_socketpair()
+ */
+int machdep_sys_socketpair(int d, int type, int protocol, int sv[2])
+
+{
+ register int s1, s2;
+ register int ret;
+ struct socksysreq req;
+
+ if (d != AF_UNIX)
+ return -EPROTONOSUPPORT;
+ if ((s1=machdep_sys_socket(d,type,protocol))<0) {
+ return s1;
+ }
+ if ((s2=machdep_sys_socket(d,type,protocol))<0) {
+ machdep_sys_close(s1);
+ return s2;
+ }
+ req.args[0] = SO_SOCKPAIR;
+ req.args[1] = s1;
+ req.args[2] = s2;
+ if ((ret=machdep_sys_ioctl(s1,SIOCSOCKSYS,&req))<0) {
+ machdep_sys_close(s1);
+ machdep_sys_close(s2);
+ return ret;
+ }
+ sv[0] = s1;
+ sv[1] = s2;
+ return 0;
+}
+
+/* ==========================================================================
+ * machdep_sys_getsockname()
+ */
+int machdep_sys_getsockname(int s, char * b, int * c)
+{
+ struct socksysreq req;
+
+ req.args[0] = SO_GETSOCKNAME;
+ req.args[1] = (int)s;
+ req.args[2] = (int)b;
+ req.args[3] = (int)c;
+
+ return(machdep_sys_ioctl(s, SIOCSOCKSYS, &req));
+}
+
+int machdep_sys_sendmsg(int s, const struct msghdr *msg, int flags)
+
+{
+ struct socksysreq req;
+
+ req.args[0] = SO_SENDMSG;
+ req.args[1] = (int)s;
+ req.args[2] = (int)msg;
+ req.args[3] = (int)flags;
+
+ return(machdep_sys_ioctl(s, SIOCSOCKSYS, &req));
+}
+
+int machdep_sys_recvmsg(int s, struct msghdr *msg, int flags)
+
+{
+ struct socksysreq req;
+
+ req.args[0] = SO_RECVMSG;
+ req.args[1] = (int)s;
+ req.args[2] = (int)msg;
+ req.args[3] = (int)flags;
+
+ return(machdep_sys_ioctl(s, SIOCSOCKSYS, &req));
+}
+
+u_short ntohs(u_short n)
+
+{
+ union {
+ unsigned char u_nc[4];
+ u_short u_ns;
+ } ns;
+ register unsigned char* p = &ns.u_nc[0];
+
+ ns.u_ns = n;
+ return (p[0]<<8)|p[1];
+}
+
+u_short htons(u_short h)
+
+{
+ union {
+ unsigned char u_nc[2];
+ u_short u_ns;
+ } ns;
+ register unsigned char* p = &ns.u_nc[0];
+ p[0] = (h>>8)&0xFF;
+ p[1] = (h&0xFF);
+ return ns.u_ns;
+}
+
+
+u_long ntohl(u_long n)
+
+{
+ union {
+ unsigned char u_nc[4];
+ u_long u_nl;
+ } nl;
+ register unsigned char* p = &nl.u_nc[0];
+
+ nl.u_nl = n;
+ return (p[0]<<24)|(p[1]<<16)|(p[2]<<8)|p[3];
+}
+
+u_long htonl(u_long h)
+
+{
+ union {
+ unsigned char u_nc[4];
+ u_long u_nl;
+ } nl;
+ register unsigned char* p = &nl.u_nc[0];
+ p[0] = (h>>24)&0xFF;
+ p[1] = (h>>16)&0xFF;
+ p[2] = (h>>8)&0xFF;
+ p[3] = (h&0xFF);
+ return nl.u_nl;
+}
+
+int getdomainname(char* domain,int len)
+
+{
+ /* edi = len */
+ struct socksysreq req;
+ register int ret, fd;
+ if (len>MAXHOSTNAMELEN)
+ len = MAXHOSTNAMELEN;
+
+ if ((fd = machdep_sys_open("/dev/socksys", 0)) < 0)
+ return fd;
+
+ req.args[0] = SO_GETIPDOMAIN;
+ req.args[1] = (int)domain;
+ req.args[2] = (int)len;
+ if((ret=machdep_sys_ioctl(fd, SIOCSOCKSYS, &req))<0) {
+ machdep_sys_close(fd);
+ return ret;
+ }
+
+ machdep_sys_close(fd);
+ domain[len-1] = '\0';
+ return 0;
+}
+
+int gethostname(char* name, int namelen)
+
+{
+ struct utsname uts;
+ register int ret, len;
+ char domain[MAXHOSTNAMELEN+1];
+
+ if (name==NULL)
+ return -EFAULT;
+ if ((ret=machdep_sys_uname(&uts))<0)
+ return ret;
+ if (namelen<(len=strlen(uts.nodename)))
+ return -EFAULT;
+ strncpy(name,uts.nodename,len);
+ if (namelen>len)
+ name[len] = '\0';
+ if ((ret=getdomainname(domain, namelen - len))<0)
+ return ret;
+ if (domain[0]=='\0')
+ return 0;
+ if (len + strlen(domain) + 2 > namelen)
+ return -EFAULT;
+ strcat(name, ".");
+ strcat(name, domain);
+ return 0;
+}
+
+int gettimeofday(struct timeval* tp, struct timezone* tz)
+
+{
+ register int ret;
+ if ((ret = machdep_sys_gettimeofday(tp, NULL))<0) {
+ errno = -ret;
+ return -1;
+ }
+ else {
+ return 0;
+ }
+}
+
+int kill(pid_t pid, int signo)
+
+{
+ register int ret;
+ if ((ret = machdep_sys_kill(pid,signo))<0) {
+ errno = -ret;
+ return -1;
+ }
+ else {
+ return 0;
+ }
+}
+
+typedef void (*signal_t(int signo, void (*func)(int)))(int);
+
+signal_t* _libc_signal = NULL;
+
+void (*signal(int signo, void (*func)(int)))(int)
+
+{
+ int ret;
+ void (*oldfunc)(int);
+ extern void (*machdep_sys_signal(int signo, void (*func)(int),int* r))(int);
+ if (_libc_signal!=NULL)
+ return (*_libc_signal)(signo, func);
+
+ oldfunc = machdep_sys_signal(signo, func, &ret);
+ if (ret!=0) {
+ errno = ret;
+ return SIG_ERR;
+ }
+ else {
+ return oldfunc;
+ }
+}
+
+int (*_libc_sigaction)(int ,const struct sigaction *, struct sigaction *) = NULL;
+int sigaction(int sig,const struct sigaction *act, struct sigaction *oact)
+
+{
+ register int ret;
+ if (_libc_sigaction!=NULL)
+ return (*_libc_sigaction)(sig,act,oact);
+ if ((ret = machdep_sys_sigaction(sig,act,oact))<0) {
+ errno = -ret;
+ return -1;
+ }
+ else {
+ return 0;
+ }
+}
+
+int (*_libc_sigprocmask)(int, const sigset_t *, sigset_t *) = NULL;
+
+int sigprocmask(int how, const sigset_t *set, sigset_t * oset)
+
+{
+ register int ret;
+ if (_libc_sigprocmask!=NULL)
+ return (*_libc_sigprocmask)(how,set,oset);
+ if ((ret = machdep_sys_sigprocmask(how,set,oset))<0) {
+ errno = -ret;
+ return -1;
+ }
+ else {
+ return 0;
+ }
+}
+
+int (*_libc_sigsuspend)(const sigset_t *) = NULL;
+
+int sigsuspend(const sigset_t *set)
+{
+ register int ret;
+ if (_libc_sigsuspend!=NULL)
+ return (*_libc_sigsuspend)(set);
+ if ((ret = machdep_sys_sigsuspend(set))<0) {
+ errno = -ret;
+ return -1;
+ }
+ else {
+ return 0;
+ }
+}
+
+int _sigrelse(sig)
+int sig;
+
+{
+ sigset_t mask;
+ sigemptyset(&mask);
+ sigaddset(&mask, sig);
+ return sigprocmask(SIG_UNBLOCK,&mask,NULL);
+}
+
+int _sighold(sig)
+int sig;
+
+{
+ sigset_t mask;
+ sigemptyset(&mask);
+ sigaddset(&mask, sig);
+ return sigprocmask(SIG_BLOCK,&mask,NULL);
+}
+
+void (*sigset(int sig, void (*func)(int)))(int)
+{
+ return signal(sig, func);
+}
+
+
+int (*_libc_getmsg)(int , struct strbuf *, struct strbuf *, int *) = NULL;
+
+int getmsg(int fd, struct strbuf * ctlptr, struct strbuf * dataptr,
+ int * flags)
+{
+ register int ret;
+ if (_libc_getmsg != NULL)
+ return (*_libc_getmsg)(fd,ctlptr,dataptr,flags);
+ else if ((ret=machdep_sys_getmsg(fd,ctlptr,dataptr,flags))<0) {
+ errno = -ret;
+ return -1;
+ }
+ else
+ return ret;
+}
+
+int (*_libc_putmsg)(int , const struct strbuf *, const struct strbuf *, int) = NULL;
+
+int putmsg(int fd, const struct strbuf * ctlptr, const struct strbuf * dataptr,
+ int flags)
+{
+ register int ret;
+ if (_libc_putmsg != NULL)
+ return (*_libc_putmsg)(fd,ctlptr,dataptr,flags);
+ else if ((ret=machdep_sys_putmsg(fd,ctlptr,dataptr,flags))<0) {
+ errno = -ret;
+ return -1;
+ }
+ else
+ return ret;
+}
+
+int ftime(struct timeb* tp)
+
+{
+ register int ret;
+ if ((ret=machdep_sys_ftime(tp))<0) {
+ errno = -ret;
+ return NOTOK;
+ }
+ return 0;
+}
+
+int getpagesize()
+
+{
+ register int ret;
+#if 0
+ if ((ret = machdep_sys_sysconf(_SC_PAGE_SIZE))<0) {
+ PANIC();
+ SET_ERRNO(-ret);
+ return -1;
+ }
+ else {
+ return 0;
+ }
+#else
+ return PAGESIZE;
+#endif
+}
+
+static pthread_mutex_t machdep_mutex =
+{ MUTEX_TYPE_COUNTING_FAST, PTHREAD_QUEUE_INITIALIZER, \
+ NULL, SEMAPHORE_CLEAR, { NULL }, MUTEX_FLAGS_INITED };
+
+static pthread_mutex_t malloc_mutex =
+{ MUTEX_TYPE_COUNTING_FAST, PTHREAD_QUEUE_INITIALIZER, \
+ NULL, SEMAPHORE_CLEAR, { NULL }, MUTEX_FLAGS_INITED };
+
+struct stdlock {
+ volatile long init;
+ pthread_mutex_t* mutex;
+};
+
+static void machdep_stdinitlock(struct stdlock* lock)
+
+{
+ if (lock==0) PANIC();
+ pthread_mutex_lock(&machdep_mutex);
+ if (!lock->init) {
+ register pthread_mutex_t* mutex;
+ pthread_mutexattr_t attr;
+
+ lock->init = 1;
+ lock->mutex = &machdep_mutex;
+ mutex = (pthread_mutex_t*) malloc(sizeof(pthread_mutex_t));
+ pthread_mutexattr_init (&attr);
+ pthread_mutexattr_settype (&attr, MUTEX_TYPE_COUNTING_FAST);
+ pthread_mutex_init(mutex, &attr);
+ lock->mutex = mutex;
+ }
+ pthread_mutex_unlock(&machdep_mutex);
+}
+
+void machdep_stdlock(struct stdlock* lock)
+
+{
+ if (lock==0) PANIC();
+ if (!lock->init)
+ machdep_stdinitlock(lock);
+ pthread_mutex_lock(lock->mutex);
+}
+
+void machdep_stdunlock(struct stdlock* lock)
+
+{
+ if (lock==0) PANIC();
+ if (!lock->init)
+ machdep_stdinitlock(lock);
+ pthread_mutex_unlock(lock->mutex);
+}
+
+int machdep_stdtrylock(struct stdlock* lock)
+
+{
+ if (lock==0) PANIC();
+ if (!lock->init)
+ machdep_stdinitlock(lock);
+ return pthread_mutex_trylock(lock->mutex);
+}
+
+int machdep_stdtryunlock(struct stdlock* lock)
+
+{
+ if (lock==0) PANIC();
+ if (!lock->init)
+ machdep_stdinitlock(lock);
+ if (pthread_mutex_trylock(lock->mutex))
+ return pthread_mutex_unlock(lock->mutex);
+ return 0;
+}
+
+extern void (*_libc_stdlock)(struct stdlock* lock);
+extern void (*_libc_stdunlock)(struct stdlock* lock);
+extern int (*_libc_stdtrylock)(struct stdlock* lock);
+extern int (*_libc_stdtryunlock)(struct stdlock* lock);
+
+int machdep_sys_init()
+
+{
+ typedef void (*voidfunc_t)();
+ extern voidfunc_t _libc_read;
+ extern voidfunc_t _libc_write;
+ extern voidfunc_t _libc_readv;
+ extern voidfunc_t _libc_writev;
+ extern voidfunc_t _libc_open;
+ extern voidfunc_t _libc_close;
+ extern voidfunc_t _libc_fork;
+ extern voidfunc_t _libc_fcntl;
+ extern voidfunc_t _libc_dup;
+ extern voidfunc_t _libc_pipe;
+ extern voidfunc_t _libc_select;
+ extern voidfunc_t _libc_malloc;
+ extern voidfunc_t _libc_realloc;
+ extern voidfunc_t _libc_free;
+ extern ssize_t pthread_read (int , char*, int );
+ extern ssize_t pthread_write (int , char*, int );
+ extern int pthread_close (int);
+ extern int pthread_dup (int);
+ extern int pthread_fork ();
+ extern int pthread_pipe (int*);
+ extern int pthread_fcntl(int, int, ...);
+ extern int pthread_open(const char *, int, ...);
+ extern ssize_t pthread_readv (int , const struct iovec *, int );
+ extern ssize_t pthread_writev (int , const struct iovec *, int );
+ extern int pthread_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
+ extern int pthread_getmsg(int , struct strbuf *, struct strbuf *,int*);
+ extern int pthread_putmsg(int , const struct strbuf *, const struct strbuf *,int);
+ extern void (*pthread_signal(int , void (*)(int)))(int);
+ extern int pthread_sigaction(int,const struct sigaction *, struct sigaction *);
+ extern int pthread_sigprocmask(int, const sigset_t *, sigset_t *);
+ extern int pthread_sigsuspend(const sigset_t *);
+
+
+ static struct {
+ voidfunc_t *p;
+ voidfunc_t f;
+ } maptable[] = {
+ {(voidfunc_t*)&_libc_read, (voidfunc_t) pthread_read},
+ {(voidfunc_t*)&_libc_write, (voidfunc_t) pthread_write},
+ {(voidfunc_t*)&_libc_readv, (voidfunc_t) pthread_readv},
+ {(voidfunc_t*)&_libc_writev, (voidfunc_t) pthread_writev},
+ {(voidfunc_t*)&_libc_open, (voidfunc_t) pthread_open},
+ {(voidfunc_t*)&_libc_close, (voidfunc_t) pthread_close},
+ {(voidfunc_t*)&_libc_fork, (voidfunc_t) pthread_fork},
+ {(voidfunc_t*)&_libc_fcntl, (voidfunc_t) pthread_fcntl},
+ {(voidfunc_t*)&_libc_dup, (voidfunc_t) pthread_dup},
+ {(voidfunc_t*)&_libc_pipe, (voidfunc_t) pthread_pipe},
+ {(voidfunc_t*)&_libc_select, (voidfunc_t) pthread_select},
+ {(voidfunc_t*)&_libc_getmsg, (voidfunc_t) pthread_getmsg},
+ {(voidfunc_t*)&_libc_putmsg, (voidfunc_t) pthread_putmsg},
+ {(voidfunc_t*)&_libc_signal, (voidfunc_t) pthread_signal},
+ {(voidfunc_t*)&_libc_sigaction, (voidfunc_t) pthread_sigaction},
+ {(voidfunc_t*)&_libc_sigprocmask, (voidfunc_t) pthread_sigprocmask},
+ {(voidfunc_t*)&_libc_sigsuspend, (voidfunc_t) pthread_sigsuspend},
+ {(voidfunc_t*) 0, (voidfunc_t) 0}
+ };
+ register int i;
+
+ for (i=0; maptable[i].p; i++)
+ *maptable[i].p = maptable[i].f;
+
+ _libc_stdlock = machdep_stdlock;
+ _libc_stdunlock = machdep_stdunlock;
+ _libc_stdtrylock = machdep_stdtrylock;
+ _libc_stdtryunlock = machdep_stdtryunlock;
+ return 0;
+}
+
+#if 0
+extern end;
+char* nd = (char*) &end;
+char* brk(const char* endds)
+
+{
+ register int ret;
+
+ if ((ret = machdep_sys_brk((char*)endds))<0) {
+ SET_ERRNO(-ret);
+ return (char*) -1;
+ }
+ else {
+ nd = (char*) endds;
+ return 0;
+ }
+}
+
+char *sbrk(int incr)
+
+{
+ register char* ret;
+ if (incr!=0 && (ret=brk(nd + incr))!=0)
+ return ret;
+ else
+ return nd - incr;
+}
+#endif
+
+sigset_t sigmask(int sig)
+
+{
+ sigset_t oset;
+ sigemptyset(&oset);
+ sigaddset(&oset, sig);
+ return oset;
+}
+
+sigset_t sigsetmask(sigset_t set)
+
+{
+ sigset_t oset;
+ sigprocmask(SIG_SETMASK,&set,&oset);
+ return oset;
+}
+
+sigset_t sigblock(sigset_t set)
+
+{
+ sigset_t oset;
+ sigprocmask(SIG_BLOCK,&set,&oset);
+ return oset;
+}
diff --git a/mit-pthreads/machdep/engine-i386-sco-3.2v5.h b/mit-pthreads/machdep/engine-i386-sco-3.2v5.h
new file mode 100644
index 00000000000..8b2aa362f06
--- /dev/null
+++ b/mit-pthreads/machdep/engine-i386-sco-3.2v5.h
@@ -0,0 +1,104 @@
+/* ==== machdep.h ============================================================
+ * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
+ *
+ * engine-i386-freebsd-2.0.h,v 1.1.4.1 1995/12/13 05:41:52 proven Exp
+ *
+ */
+
+#include <unistd.h>
+#include <setjmp.h>
+#include <sys/time.h>
+
+#ifndef __NORETURN
+#define __NORETURN
+#endif
+
+/*
+ * 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;
+#define JB_BP 3
+#define JB_SP 4
+#define JB_PC 5
+ 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 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));
+
+#endif
+
+__END_DECLS
diff --git a/mit-pthreads/machdep/engine-ip22-irix-5.2.c b/mit-pthreads/machdep/engine-ip22-irix-5.2.c
new file mode 100644
index 00000000000..d205d05f316
--- /dev/null
+++ b/mit-pthreads/machdep/engine-ip22-irix-5.2.c
@@ -0,0 +1,225 @@
+/* ==== machdep.c ============================================================
+ * Copyright (c) 1995 Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Machine dependent functions for IRIX-5.2 on the IP22
+ *
+ * 1.00 95/04/26 proven
+ * -Started coding this file.
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.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();
+ 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)
+{
+ int i;
+
+ 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;
+
+ if (setjmp(machdep_pthread->machdep_state)) {
+ machdep_pthread_start();
+ }
+
+ /*
+ * Set up new stact frame so that it looks like it
+ * returned from a longjmp() to the beginning of
+ * machdep_pthread_start().
+ */
+
+ /* IP22 stack starts high and builds down. */
+ machdep_pthread->machdep_state[JB_SP] =
+ (int)machdep_pthread->machdep_stack + stack_size - 1024;
+ machdep_pthread->machdep_state[JB_SP] &= ~7;
+
+ memcpy((void *)machdep_pthread->machdep_state[JB_SP],
+ (char *)(((int)&i) - 24), 32);
+
+}
+
+/* ==========================================================================
+ * machdep_sys_dup2()
+ */
+machdep_sys_dup2(int a, int b)
+{
+ machdep_sys_close(b);
+ machdep_sys_fcntl(a, F_DUPFD, b);
+}
+
+/* ==========================================================================
+ * machdep_sys_wait3()
+ */
+machdep_sys_wait3(int * b, int c, int * d)
+{
+ return(machdep_sys_waitsys(0, b, c, d));
+}
+
+/* ==========================================================================
+ * machdep_sys_waitpid()
+ */
+machdep_sys_waitpid(int a, int * b, int c)
+{
+ return(machdep_sys_waitsys(a, b, c, NULL));
+}
+
+struct stat;
+
+/* ==========================================================================
+ * _fxstat()
+ */
+int _fxstat(int __ver, 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);
+ }
+ fd_unlock(fd, FD_READ);
+ }
+ return(ret);
+}
+
+/* ==========================================================================
+ * _lxstat()
+ */
+int _lxstat(int __ver, const char * path, struct stat * buf)
+{
+ int ret;
+
+ if ((ret = machdep_sys_lstat(path, buf)) < OK) {
+ SET_ERRNO(-ret);
+ }
+ return(ret);
+
+}
+
+/* ==========================================================================
+ * _xstat()
+ */
+int _xstat(int __ver, const char * path, struct stat * buf)
+{
+ int ret;
+
+ if ((ret = machdep_sys_stat(path, buf)) < OK) {
+ SET_ERRNO(-ret);
+ }
+ return(ret);
+
+}
+
+/* ==========================================================================
+ * getdtablesize()
+ */
+machdep_sys_getdtablesize()
+{
+ return(sysconf(_SC_OPEN_MAX));
+}
+
+/* ==========================================================================
+ * machdep_sys_getdirentries()
+ */
+int machdep_sys_getdirentries(int fd, char * buf, int len, int * seek)
+{
+ int i;
+
+ i = machdep_sys_getdents(fd, buf, len);
+ return i;
+}
diff --git a/mit-pthreads/machdep/engine-ip22-irix-5.2.h b/mit-pthreads/machdep/engine-ip22-irix-5.2.h
new file mode 100644
index 00000000000..94dd386608e
--- /dev/null
+++ b/mit-pthreads/machdep/engine-ip22-irix-5.2.h
@@ -0,0 +1,108 @@
+/* ==== machdep.h ============================================================
+ * Copyright (c) 1994 Chris Provenzano, proven@athena.mit.edu
+ *
+ * $Id$
+ *
+ */
+
+#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.
+ */
+#define SEMAPHORE_CLEAR 0
+#define SEMAPHORE_SET 0xff
+
+/*
+ * More machine dependent macros
+ */
+#ifdef PTHREAD_KERNEL
+
+#define machdep_save_float_state(x)
+#define machdep_restore_float_state()
+
+#endif
+
+/*
+ * New types
+ */
+typedef char semaphore;
+
+/*
+ * sigset_t macros
+ */
+#define SIGMAX 32
+#define SIG_ANY(sig) \
+({ \
+ sigset_t *sig_addr = (sigset_t *)&sig; \
+ int ret = 0; \
+ int i; \
+ \
+ for (i = 1; i <= SIGMAX; i++) { \
+ if (sigismember(sig_addr, i)) { \
+ ret = 1; \
+ break; \
+ } \
+ } \
+ ret; \
+})
+
+/*
+ * New Strutures
+ */
+struct machdep_pthread {
+ void *(*start_routine)(void *);
+ void *start_argument;
+ void *machdep_stack;
+ struct itimerval machdep_timer;
+ jmp_buf machdep_state;
+};
+
+/*
+ * 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/mit-pthreads/machdep/engine-m68000-netbsd.c b/mit-pthreads/machdep/engine-m68000-netbsd.c
new file mode 100644
index 00000000000..6346c36ca7c
--- /dev/null
+++ b/mit-pthreads/machdep/engine-m68000-netbsd.c
@@ -0,0 +1,256 @@
+/* ==== 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>.
+ * updated and NetBSD/m68k work from Andy Finnell <andyf@vei.net>.
+ *
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#endif
+
+#include "pthread.h"
+#include <sys/syscall.h>
+#include <sys/stat.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_save_state()
+ */
+void machdep_save_float_state(struct pthread * pthread)
+{
+ char * fdata = pthread->machdep_data.machdep_fstate;
+
+ __asm__ ( "fmovem fp0-fp7,%0"::"m" (*fdata) );
+ __asm__ ( "fmovem fpcr/fpsr/fpi,%0"::"m" (fdata[80]) );
+}
+
+/* ==========================================================================
+ * machdep_restore_float_state()
+ */
+void machdep_restore_float_state(void)
+{
+ char * fdata = pthread_run->machdep_data.machdep_fstate;
+
+ __asm__ ( "fmovem %0,fp0-fp7"::"m" (*fdata) );
+ __asm__ ( "fmovem %0,fpcr/fpsr/fpi"::"m" (fdata[80]) );
+
+}
+
+/* ==========================================================================
+ * 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_stack_free()
+ */
+void __machdep_stack_free(void * stack)
+{
+ free(stack);
+}
+
+/* ==========================================================================
+ * __machdep_stack_alloc()
+ */
+void * __machdep_stack_alloc(size_t size)
+{
+ void * stack;
+
+ return((void*)malloc(size));
+}
+
+/* ==========================================================================
+ * 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 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, 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;
+
+ _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;
+}
+
+/* ==========================================================================
+ * 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_getdirentries()
+ */
+machdep_sys_getdirentries(int fd, char * buf, int len, int * seek)
+{
+ return(machdep_sys_getdents(fd, buf, len));
+}
+
+/* ==========================================================================
+ * 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));
+}
+
+int machdep_sys_ftruncate( int fd, off_t length)
+{
+ quad_t q;
+ int rv;
+
+ q = __syscall((quad_t)SYS_ftruncate, fd,0, length);
+ if( /* LINTED constant */ sizeof( quad_t ) == sizeof( register_t ) ||
+ /* LINTED constant */ BYTE_ORDER == LITTLE_ENDIAN )
+ rv = (int)q;
+ else
+ rv = (int)((u_quad_t)q >> 32);
+
+ return rv;
+}
+
+int machdep_sys_fstat( int f, struct stat* st )
+{
+ return __fstat13(f,st);
+}
diff --git a/mit-pthreads/machdep/engine-m68000-netbsd.h b/mit-pthreads/machdep/engine-m68000-netbsd.h
new file mode 100644
index 00000000000..ec3c6a01bce
--- /dev/null
+++ b/mit-pthreads/machdep/engine-m68000-netbsd.h
@@ -0,0 +1,107 @@
+/* ==== machdep.h ============================================================
+ * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
+ *
+ * $Id$
+ *
+ * m68k work by Andy Finnell <andyf@vei.net> based off work by
+ * David Leonard and Chris Provenzano.
+ *
+ */
+
+#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),"m" (*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;
+ char machdep_fstate[92];
+};
+
+/*
+ * Min pthread stacksize
+ */
+#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
+
+/*
+ * 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)
+
+
+#ifndef __machdep_stack_get
+#define __machdep_stack_get(x) (x)->machdep_stack
+#endif
+#ifndef __machdep_stack_set
+#define __machdep_stack_set(x, y) (x)->machdep_stack = y
+#endif
+#ifndef __machdep_stack_repl
+#define __machdep_stack_repl(x, y) \
+{ \
+ if (stack = __machdep_stack_get(x)) { \
+ __machdep_stack_free(stack); \
+ } \
+ __machdep_stack_set(x, y); \
+}
+#endif
+
+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/mit-pthreads/machdep/engine-r2000-ultrix-4.2.c b/mit-pthreads/machdep/engine-r2000-ultrix-4.2.c
new file mode 100644
index 00000000000..45c8cc73f24
--- /dev/null
+++ b/mit-pthreads/machdep/engine-r2000-ultrix-4.2.c
@@ -0,0 +1,209 @@
+/* ==== machdep.c ============================================================
+ * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Machine dependent functions for decstation with r2000/r3000
+ *
+ * 1.00 93/07/21 proven
+ * -Started coding this file.
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#endif
+
+#include <pthread.h>
+#include <stdlib.h>
+#include <errno.h>
+
+/*
+ * The r2000/r3000 processors do not have a test and set instruction, so
+ * the semaphore TEST_AND_SET macro is linked very closely to the interrupt
+ * handelling of the pthreads package.
+ */
+
+/* ==========================================================================
+ * semaphore_test_and_set()
+ *
+ * SEMAPHORE_TEST_AND_SET prevents interrupts, tests the lock and then
+ * turns interrupts back on, checking to see if any interrupts have occured
+ * between the prevent and resume.
+ */
+int semaphore_test_and_set(semaphore *lock)
+{
+ int rval;
+
+/* None of this should be necessary
+ sig_prevent();
+ if (!(rval = (*lock))) {
+ *lock = SEMAPHORE_SET;
+ }
+ sig_check_and_resume();
+ return(rval);
+*/
+}
+
+/* ==========================================================================
+ * machdep_save_state()
+ */
+int machdep_save_state(void)
+{
+ return(setjmp(pthread_run->machdep_data.machdep_state));
+}
+
+/* ==========================================================================
+ * machdep_save_float_state()
+ */
+void machdep_save_float_state(struct pthread * pthread)
+{
+ return;
+}
+
+/* ==========================================================================
+ * fake_longjmp()
+ */
+void fake_longjmp(jmp_buf env)
+{
+ asm("li $5,1; sw $5, 20($4); li $2,103; syscall");
+}
+
+/* ==========================================================================
+ * machdep_restore_state()
+ *
+ * When I redo machdep_save_state, I'll put the asm in machdep_save_state()
+ * and machdep_restore_state() and I won't have to do an additional function
+ * call.
+ */
+void machdep_restore_state(void)
+{
+ fake_longjmp(pthread_run->machdep_data.machdep_state);
+ /* longjmp(pthread_run->machdep_data.machdep_state, 1); */
+}
+
+/* ==========================================================================
+ * machdep_restore_float_state()
+ */
+void machdep_restore_float_state(void)
+{
+ return;
+}
+
+/* ==========================================================================
+ * 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;
+
+ 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[JB_RA] = (int)machdep_pthread_start;
+ machdep_pthread->machdep_state[JB_PC] = (int)machdep_pthread_start;
+
+ /* Stack starts high and builds down. */
+ machdep_pthread->machdep_state[JB_SP] =
+ (int)machdep_pthread->machdep_stack + stack_size;
+
+ /* This is the real global pointer */
+ /* machdep_pthread->machdep_state[JB_GP] = 0; */
+}
+
+/* ==========================================================================
+ * machdep_sys_sigprocmask()
+ * This isn't a real implementation; we can make the assumption that the
+ * pthreads library is not using oset, and that it is always blocking or
+ * unblocking all signals at once.
+ */
+int machdep_sys_sigprocmask(int how, const sigset_t *set, sigset_t *oset)
+{
+ switch(how) {
+ case SIG_BLOCK:
+ sigblock(*set);
+ break;
+ case SIG_UNBLOCK:
+ sigsetmask(~*set);
+ break;
+ case SIG_SETMASK:
+ sigsetmask(*set);
+ break;
+ default:
+ return -EINVAL;
+ }
+ return(OK);
+}
+
diff --git a/mit-pthreads/machdep/engine-r2000-ultrix-4.2.h b/mit-pthreads/machdep/engine-r2000-ultrix-4.2.h
new file mode 100644
index 00000000000..8e2d70f8feb
--- /dev/null
+++ b/mit-pthreads/machdep/engine-r2000-ultrix-4.2.h
@@ -0,0 +1,107 @@
+/* ==== machdep.h ============================================================
+ * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
+ *
+ * $Id$
+ *
+ * Description : Machine dependent header for decstation with r2000/r3000
+ * running Ultrix-4.2
+ *
+ * 1.00 93/07/21 proven
+ * -Started coding this file.
+ */
+
+#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.
+ */
+#define SEMAPHORE_CLEAR 0
+#define SEMAPHORE_SET 1
+
+#define SEMAPHORE_TEST_AND_SET(lock) semaphore_test_and_set(lock)
+#define SEMAPHORE_RESET(lock) *lock = SEMAPHORE_CLEAR
+
+/*
+ * New types
+ */
+typedef long semaphore;
+
+#if !defined(_POSIX_SOURCE)
+
+/* typedef int ssize_t; */
+
+#if !defined(__GNUC__)
+
+/*
+ * sigset_t macros
+ */
+typedef int sigset_t;
+#define sigaddset(set, num) ((*set) |= (1 << (num - 1)))
+#define sigemptyset(set) (*set = 0)
+
+#endif
+#endif
+
+#define SIG_ANY(sig) (sig)
+#define SIGMAX 31
+
+/*
+ * New Structures
+ */
+struct machdep_pthread {
+ void *(*start_routine)(void *);
+ void *start_argument;
+ void *machdep_stack;
+ struct itimerval machdep_timer;
+ jmp_buf machdep_state;
+};
+
+/*
+ * Static machdep_pthread initialization values.
+ * For initial thread only.
+ */
+#define MACHDEP_PTHREAD_INIT \
+{ NULL, NULL, NULL, { { 0, 0 }, { 0, 100000 } }, 0 }
+
+
+/*
+ * Min stacksize, arch dependent
+ */
+#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 | O_NDELAY)
+
+/*
+ * 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 semaphore_test_and_set __P_((semaphore *));
+int machdep_save_state __P_((void));
+
+#endif
+
+__END_DECLS
diff --git a/mit-pthreads/machdep/engine-romp-bsd.c b/mit-pthreads/machdep/engine-romp-bsd.c
new file mode 100644
index 00000000000..dd1a1096ece
--- /dev/null
+++ b/mit-pthreads/machdep/engine-romp-bsd.c
@@ -0,0 +1,99 @@
+/* ==== machdep.c ============================================================
+ * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Machine dependent functions for NetBSD on i386
+ *
+ * 1.00 93/08/04 proven
+ * -Started coding this file.
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#endif
+
+#include <pthread.h>
+
+/* ==========================================================================
+ * machdep_save_state()
+ */
+int machdep_save_state(void)
+{
+ return(_pthread_save(pthread_run->machdep_data.machdep_state, 0, 0));
+}
+
+/* ==========================================================================
+ * machdep_restore_state()
+ */
+void machdep_restore_state(void)
+{
+ _pthread_restore(pthread_run->machdep_data.machdep_state);
+}
+
+/* ==========================================================================
+ * 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 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_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;
+
+ _pthread_save(machdep_pthread->machdep_state,
+ (void *)((int)machdep_pthread->machdep_stack + stack_size),
+ machdep_pthread_start);
+}
+
diff --git a/mit-pthreads/machdep/engine-romp-bsd.h b/mit-pthreads/machdep/engine-romp-bsd.h
new file mode 100644
index 00000000000..28c59d35e70
--- /dev/null
+++ b/mit-pthreads/machdep/engine-romp-bsd.h
@@ -0,0 +1,100 @@
+/* ==== machdep.h ============================================================
+ * Copyright (c) 1993 John F. Carr, jfc@athena.mit.edu
+ *
+ * Description : Machine dependent header for IBM/RT
+ *
+ * 1.00 93/09/xx jfc
+ * -Coding this file.
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#endif
+
+#include <setjmp.h>
+#include <sys/time.h>
+#include <sys/types.h>
+
+/*
+ * Stuff for compiling
+ */
+#if defined(__GNUC__)
+#if defined(__cplusplus)
+#define __BEGIN_DECLS extern "C" {
+#define __END_DECLS };
+#else
+#define __BEGIN_DECLS
+#define __END_DECLS
+#if !defined(__STDC__)
+#define const __const
+#define inline __inline
+#define signed __signed
+#define volatile __volatile
+#endif
+#endif
+#else /* !__GNUC__ */
+#define __BEGIN_DECLS
+#define __END_DECLS
+#define const
+#define inline
+#define signed
+#define volatile
+#endif
+
+#define SEMAPHORE_CLEAR 0x0000
+#define SEMAPHORE_SET 0xff00
+#define SEMAPHORE_TEST_AND_SET(lock) _tsh(lock)
+#define SEMAPHORE_RESET(lock) *(lock) = SEMAPHORE_CLEAR
+extern unsigned short _tsh(volatile unsigned short *);
+
+typedef unsigned short semaphore;
+
+/*
+ * sigset_t macros
+ */
+#define SIG_ANY(sig) (sig)
+#define SIGMAX 31
+
+
+struct machdep_pthread {
+ void *(*start_routine)(void *);
+ void *start_argument;
+ void *machdep_stack;
+ struct itimerval machdep_timer;
+ jmp_buf machdep_state;
+};
+
+/*
+ * Static machdep_pthread initialization values.
+ * For initial thread only.
+ */
+#define MACHDEP_PTHREAD_INIT \
+{ NULL, NULL, NULL, { { 0, 0 }, { 0, 100000 } }, 0 }
+
+/*
+ * Min pthread stacksize
+ */
+#define PTHREAD_STACK_MIN 1024
+
+/*
+ * Some fd defines that are necessary to distinguish between posix
+ * behavior and bsd4.3 behavior.
+ */
+#define __FD_NONBLOCK O_NONBLOCK
+
+#if defined(PTHREAD_KERNEL)
+
+int machdep_save_state __P_((void));
+
+/* save(jmp_buf, stack pointer, restart proc) */
+extern int _pthread_save(jmp_buf, void *, void (*)());
+extern void _pthread_restore(jmp_buf);
+
+typedef int ssize_t;
+typedef unsigned int sigset_t;
+#define sigemptyset(sp) *(sp) = 0
+#define sigprocmask(op, nssp, ossp) if (ossp) *(int *)ossp = sigsetmask(*nssp); else sigsetmask(*nssp)
+#define sigdelset(sp, i) *(sp) &= ~(1 << (i))
+#define sigaddset(sp, i) *(sp) |= (1 << (i))
+#define sigismember(sp, i) (*(sp) & (1 << (i)))
+#endif
diff --git a/mit-pthreads/machdep/engine-sparc-netbsd-1.3.c b/mit-pthreads/machdep/engine-sparc-netbsd-1.3.c
new file mode 100644
index 00000000000..8e0520cfba5
--- /dev/null
+++ b/mit-pthreads/machdep/engine-sparc-netbsd-1.3.c
@@ -0,0 +1,232 @@
+/* ==== machdep.c ============================================================
+ * Copyright (c) 1993, 1994 Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Machine dependent functions for SunOS-4.1.3 on sparc
+ *
+ * 1.00 93/08/04 proven
+ * -Started coding this file.
+ *
+ * 98/10/22 bad
+ * -update for fat sigset_t in NetBSD 1.3H
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#endif
+
+#include "config.h"
+#include <pthread.h>
+#include <stdlib.h>
+#include <errno.h>
+
+/* ==========================================================================
+ * machdep_save_state()
+ */
+int machdep_save_state(void)
+{
+ /* Save register windows onto stackframe */
+ __asm__ ("ta 3");
+
+ 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_save_float_state()
+ */
+void machdep_save_float_state(struct pthread * pthread)
+{
+ return;
+}
+
+/* ==========================================================================
+ * machdep_restore_float_state()
+ */
+void machdep_restore_float_state(void)
+{
+ return;
+}
+
+/* ==========================================================================
+ * 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;
+
+ /* Save register windows onto stackframe */
+ __asm__ ("ta 3");
+
+ 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[3] = (int)machdep_pthread_start;
+ machdep_pthread->machdep_state[4] = (int)machdep_pthread_start;
+
+ /* Sparc stack starts high and builds down. */
+ machdep_pthread->machdep_state[2] =
+ (int)machdep_pthread->machdep_stack + stack_size - 1024;
+ machdep_pthread->machdep_state[2] &= ~7;
+
+}
+
+#if defined(HAVE_SYSCALL_GETDENTS)
+/* ==========================================================================
+ * machdep_sys_getdirentries()
+ *
+ * Always use getdents in place of getdirentries if possible --proven
+ */
+int machdep_sys_getdirentries(int fd, char * buf, int len, int * seek)
+{
+ return(machdep_sys_getdents(fd, buf, len));
+}
+#endif
+
+/* ==========================================================================
+ * 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 pid, int * statusp, int options)
+{
+ if (pid == -1)
+ pid = 0;
+ else if (pid == 0)
+ pid = - getpgrp ();
+ return machdep_sys_wait4 (pid, statusp, options, NULL);
+}
+
+#if !defined(HAVE_SYSCALL_SIGPROCMASK)
+#if 0
+/* ==========================================================================
+ * machdep_sys_sigprocmask()
+ * This isn't a real implementation; we can make the assumption that the
+ * pthreads library is not using oset, and that it is always blocking or
+ * unblocking all signals at once.
+ */
+int machdep_sys_sigprocmask(int how, const sigset_t *set, sigset_t *oset)
+{
+ switch(how) {
+ case SIG_BLOCK:
+ sigblock(*set);
+ break;
+ case SIG_UNBLOCK:
+ sigsetmask(~*set);
+ break;
+ case SIG_SETMASK:
+ sigsetmask(*set);
+ break;
+ default:
+ return -EINVAL;
+ }
+ return(OK);
+}
+
+/* ==========================================================================
+ * sigaction()
+ *
+ * Temporary until I do machdep_sys_sigaction()
+ */
+int sigaction(int sig, const struct sigaction *act, struct sigaction *oldact)
+{
+ return(sigvec(sig, (struct sigvec *)act, (struct sigvec *)oldact));
+}
+#endif
+#endif
+
+#if !defined(HAVE_SYSCALL_GETDTABLESIZE)
+/* ==========================================================================
+ * machdep_sys_getdtablesize()
+ */
+machdep_sys_getdtablesize()
+{
+ return(sysconf(_SC_OPEN_MAX));
+}
+#endif
diff --git a/mit-pthreads/machdep/engine-sparc-netbsd-1.3.h b/mit-pthreads/machdep/engine-sparc-netbsd-1.3.h
new file mode 100644
index 00000000000..a187d3dace8
--- /dev/null
+++ b/mit-pthreads/machdep/engine-sparc-netbsd-1.3.h
@@ -0,0 +1,106 @@
+/* ==== machdep.h ============================================================
+ * Copyright (c) 1994 Chris Provenzano, proven@athena.mit.edu
+ *
+ * engine-sparc-sunos-4.1.3.h,v 1.52.4.1 1995/12/13 05:42:33 proven Exp
+ *
+ */
+
+#include <unistd.h>
+#include <setjmp.h>
+#include <sys/time.h>
+#include <sys/cdefs.h>
+#include <sys/signal.h> /* for _NSIG */
+
+/*
+ * The first machine dependent functions are the SEMAPHORES
+ * needing the test and set instruction.
+ */
+#define SEMAPHORE_CLEAR 0
+#define SEMAPHORE_SET 0xff
+
+#define SEMAPHORE_TEST_AND_SET(lock) \
+({ \
+char *p = lock; \
+long temp; \
+ \
+__asm__ volatile("ldstub %1,%0" \
+ :"=r" (temp) \
+ :"m" (*p) \
+ :"memory"); \
+temp; \
+})
+
+#define SEMAPHORE_RESET(lock) \
+{ \
+__asm__ volatile("stb %1, %0" \
+ :"=m" (*lock) \
+ :"r" (SEMAPHORE_CLEAR) \
+ :"memory"); \
+}
+
+/*
+ * New types
+ */
+typedef char semaphore;
+
+/*
+ * sigset_t macros
+ */
+#define SIG_ANY(sig) (sig)
+#define SIGMAX (_NSIG-1)
+
+/*
+ * New Strutures
+ */
+struct machdep_pthread {
+ void *(*start_routine)(void *);
+ void *start_argument;
+ void *machdep_stack;
+ struct itimerval machdep_timer;
+ jmp_buf machdep_state;
+};
+
+/*
+ * 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 | O_NDELAY)
+
+/*
+ * 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/mit-pthreads/machdep/engine-sparc-sunos-4.1.3.c b/mit-pthreads/machdep/engine-sparc-sunos-4.1.3.c
new file mode 100644
index 00000000000..6916c3610cd
--- /dev/null
+++ b/mit-pthreads/machdep/engine-sparc-sunos-4.1.3.c
@@ -0,0 +1,227 @@
+/* ==== machdep.c ============================================================
+ * Copyright (c) 1993, 1994 Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Machine dependent functions for SunOS-4.1.3 on sparc
+ *
+ * 1.00 93/08/04 proven
+ * -Started coding this file.
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#endif
+
+#include "config.h"
+#include <pthread.h>
+#include <stdlib.h>
+#include <errno.h>
+
+/* ==========================================================================
+ * machdep_save_state()
+ */
+int machdep_save_state(void)
+{
+ /* Save register windows onto stackframe */
+ __asm__ ("ta 3");
+
+ 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_save_float_state()
+ */
+void machdep_save_float_state(struct pthread * pthread)
+{
+ return;
+}
+
+/* ==========================================================================
+ * machdep_restore_float_state()
+ */
+void machdep_restore_float_state(void)
+{
+ return;
+}
+
+/* ==========================================================================
+ * 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;
+
+ /* Save register windows onto stackframe */
+ __asm__ ("ta 3");
+
+ 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[3] = (int)machdep_pthread_start;
+ machdep_pthread->machdep_state[4] = (int)machdep_pthread_start;
+
+ /* Sparc stack starts high and builds down. */
+ machdep_pthread->machdep_state[2] =
+ (int)machdep_pthread->machdep_stack + stack_size - 1024;
+ machdep_pthread->machdep_state[2] &= ~7;
+
+}
+
+#if defined(HAVE_SYSCALL_GETDENTS)
+/* ==========================================================================
+ * machdep_sys_getdirentries()
+ *
+ * Always use getdents in place of getdirentries if possible --proven
+ */
+int machdep_sys_getdirentries(int fd, char * buf, int len, int * seek)
+{
+ return(machdep_sys_getdents(fd, buf, len));
+}
+#endif
+
+/* ==========================================================================
+ * 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 pid, int * statusp, int options)
+{
+ if (pid == -1)
+ pid = 0;
+ else if (pid == 0)
+ pid = - getpgrp ();
+ return machdep_sys_wait4 (pid, statusp, options, NULL);
+}
+
+#if !defined(HAVE_SYSCALL_SIGPROCMASK)
+/* ==========================================================================
+ * machdep_sys_sigprocmask()
+ * This isn't a real implementation; we can make the assumption that the
+ * pthreads library is not using oset, and that it is always blocking or
+ * unblocking all signals at once.
+ */
+int machdep_sys_sigprocmask(int how, const sigset_t *set, sigset_t *oset)
+{
+ switch(how) {
+ case SIG_BLOCK:
+ sigblock(*set);
+ break;
+ case SIG_UNBLOCK:
+ sigsetmask(~*set);
+ break;
+ case SIG_SETMASK:
+ sigsetmask(*set);
+ break;
+ default:
+ return -EINVAL;
+ }
+ return(OK);
+}
+
+/* ==========================================================================
+ * sigaction()
+ *
+ * Temporary until I do machdep_sys_sigaction()
+ */
+int sigaction(int sig, const struct sigaction *act, struct sigaction *oldact)
+{
+ return(sigvec(sig, (struct sigvec *)act, (struct sigvec *)oldact));
+}
+#endif
+
+#if !defined(HAVE_SYSCALL_GETDTABLESIZE)
+/* ==========================================================================
+ * machdep_sys_getdtablesize()
+ */
+machdep_sys_getdtablesize()
+{
+ return(sysconf(_SC_OPEN_MAX));
+}
+#endif
diff --git a/mit-pthreads/machdep/engine-sparc-sunos-4.1.3.h b/mit-pthreads/machdep/engine-sparc-sunos-4.1.3.h
new file mode 100644
index 00000000000..1a4a8768ad0
--- /dev/null
+++ b/mit-pthreads/machdep/engine-sparc-sunos-4.1.3.h
@@ -0,0 +1,105 @@
+/* ==== machdep.h ============================================================
+ * Copyright (c) 1994 Chris Provenzano, proven@athena.mit.edu
+ *
+ * $Id$
+ *
+ */
+
+#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.
+ */
+#define SEMAPHORE_CLEAR 0
+#define SEMAPHORE_SET 0xff
+
+#define SEMAPHORE_TEST_AND_SET(lock) \
+({ \
+char *p = lock; \
+long temp; \
+ \
+__asm__ volatile("ldstub %1,%0" \
+ :"=r" (temp) \
+ :"m" (*p) \
+ :"memory"); \
+temp; \
+})
+
+#define SEMAPHORE_RESET(lock) \
+{ \
+__asm__ volatile("stb %1, %0" \
+ :"=m" (*lock) \
+ :"r" (SEMAPHORE_CLEAR) \
+ :"memory"); \
+}
+
+/*
+ * 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;
+};
+
+/*
+ * 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 | O_NDELAY)
+
+/*
+ * 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/mit-pthreads/machdep/engine-sparc-sunos-5.3.c b/mit-pthreads/machdep/engine-sparc-sunos-5.3.c
new file mode 100644
index 00000000000..a228a408da3
--- /dev/null
+++ b/mit-pthreads/machdep/engine-sparc-sunos-5.3.c
@@ -0,0 +1,308 @@
+/* ==== machdep.c ============================================================
+ * Copyright (c) 1993, 1994 Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Machine dependent functions for SunOS-4.1.3 on sparc
+ *
+ * 1.00 93/08/04 proven
+ * -Started coding this file.
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/socket.h>
+#include <sys/procset.h>
+#include <sys/systeminfo.h>
+#include <poll.h>
+
+/* ==========================================================================
+ * machdep_save_state()
+ */
+int machdep_save_state(void)
+{
+ /* Save register windows onto stackframe */
+ __asm__ ("ta 3");
+
+ 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();
+ 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;
+
+ /* Save register windows onto stackframe */
+ __asm__ ("ta 3");
+
+ if (setjmp(machdep_pthread->machdep_state)) {
+ machdep_pthread_start();
+ }
+
+ /*
+ * Set up new stact frame so that it looks like it
+ * returned from a longjmp() to the beginning of
+ * machdep_pthread_start().
+ */
+
+ /* Sparc stack starts high and builds down. */
+ machdep_pthread->machdep_state[1] =
+ (int)machdep_pthread->machdep_stack + stack_size - 1024;
+ machdep_pthread->machdep_state[1] &= ~7;
+
+}
+
+/* ==========================================================================
+ * machdep_sys_getdirentries()
+ */
+int machdep_sys_getdirentries(int fd, char * buf, int len, int * seek)
+{
+ return(machdep_sys_getdents(fd, buf, len));
+}
+
+/* ==========================================================================
+ * machdep_sys_wait3()
+ */
+machdep_sys_wait3(int * b, int c, int * d)
+{
+ return(-ENOSYS);
+ /* return(machdep_sys_wait4(0, b, c, d)); */
+}
+
+/* ==========================================================================
+ * machdep_sys_waitpid()
+ */
+machdep_sys_waitpid(int a, int * b, int c)
+{
+ idtype_t id;
+
+ switch (a) {
+ case -1:
+ id = P_ALL;
+ break;
+ case 0:
+ a = machdep_sys_pgrpsys(0);
+ id = P_PGID;
+ break;
+ default:
+ if (a < 0) {
+ id = P_PGID;
+ a = -a;
+ } else {
+ id = P_PID;
+ }
+ break;
+ }
+
+ return(machdep_sys_waitsys(id, a, b, c));
+}
+
+/* ==========================================================================
+ * machdep_sys_dup2()
+ */
+machdep_sys_dup2(int a, int b)
+{
+ machdep_sys_close(b);
+ machdep_sys_fcntl(a, F_DUPFD, b);
+}
+
+/* ==========================================================================
+ * machdep_sys_ftruncate()
+ */
+machdep_sys_ftruncate(int a, off_t b)
+{
+ flock_t c;
+
+ c.l_len = 0;
+ c.l_start = b;
+ c.l_whence = 0;
+ return(machdep_sys_fcntl(a, F_FREESP, c));
+}
+
+/* ==========================================================================
+ * machdep_sys_select()
+ * Recoded to be quicker by Monty
+ */
+static fd_set bogus_fds; /* Always zero, never changed */
+
+machdep_sys_select(int nfds, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, struct timeval *timeout)
+{
+ struct pollfd fds[64],*ptr;
+ int i, fds_count, time_out, found;
+
+ /* Make sure each arg has a valid pointer */
+ if ((readfds == NULL) || (writefds == NULL) || (exceptfds == NULL)) {
+ if (exceptfds == NULL) {
+ exceptfds = &bogus_fds;
+ }
+ if (writefds == NULL) {
+ writefds = &bogus_fds;
+ }
+ if (readfds == NULL) {
+ readfds = &bogus_fds;
+ }
+ }
+
+ ptr=fds;
+ for (i = 0 ; i < nfds; i++)
+ {
+ if (FD_ISSET(i, readfds))
+ {
+ if (FD_ISSET(i, writefds))
+ ptr->events= POLLIN | POLLOUT;
+ else
+ ptr->events= POLLIN;
+ (ptr++)->fd=i;
+ }
+ else if (FD_ISSET(i, writefds))
+ {
+ ptr->events=POLLOUT;
+ (ptr++)->fd=i;
+ }
+ }
+ FD_ZERO(readfds);
+ FD_ZERO(writefds);
+ FD_ZERO(exceptfds);
+ time_out = timeout->tv_usec / 1000 + timeout->tv_sec * 1000;
+ fds_count=(int) (ptr-fds);
+ while ((found = machdep_sys_poll(fds, fds_count, time_out)) <= 0)
+ {
+ if (found != -ERESTART) /* Try again if restartable */
+ return(found); /* Usually 0 ; Cant read or write */
+ }
+
+ while (ptr-- != fds)
+ {
+ if (ptr->revents & POLLIN)
+ FD_SET(ptr->fd, readfds);
+ if (ptr->revents & POLLOUT)
+ FD_SET(ptr->fd,writefds);
+ }
+ return(found);
+}
+
+/* ==========================================================================
+ * machdep_sys_getdtablesize()
+ */
+machdep_sys_getdtablesize()
+{
+ return(sysconf(_SC_OPEN_MAX));
+}
+
+/* ==========================================================================
+ * getpagesize()
+ */
+getpagesize()
+{
+ return(sysconf(_SC_PAGESIZE));
+}
+
+/* ==========================================================================
+ * gethostname()
+ */
+int gethostname(char * name, int namelen)
+{
+ if (sysinfo(SI_HOSTNAME, name, namelen) == NOTOK) {
+ return(NOTOK);
+ } else {
+ return(OK);
+ }
+}
+
+/* ==========================================================================
+ * machdep_sys_sigaction()
+ *
+ * This is VERY temporary.
+ */
+int machdep_sys_sigaction(int a, void * b, void * c)
+{
+ return(sigaction(a, b, c));
+}
diff --git a/mit-pthreads/machdep/engine-sparc-sunos-5.3.h b/mit-pthreads/machdep/engine-sparc-sunos-5.3.h
new file mode 100644
index 00000000000..365ecd799eb
--- /dev/null
+++ b/mit-pthreads/machdep/engine-sparc-sunos-5.3.h
@@ -0,0 +1,129 @@
+/* ==== machdep.h ============================================================
+ * Copyright (c) 1994 Chris Provenzano, proven@athena.mit.edu
+ *
+ * $Id$
+ *
+ */
+
+#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.
+ */
+#define SEMAPHORE_CLEAR 0
+#define SEMAPHORE_SET 0xff
+
+#define SEMAPHORE_TEST_AND_SET(lock) \
+({ \
+char *p = lock; \
+long temp; \
+ \
+__asm__ volatile("ldstub %1,%0" \
+ :"=r" (temp) \
+ :"m" (*p) \
+ :"memory"); \
+temp; \
+})
+
+#define SEMAPHORE_RESET(lock) \
+{ \
+__asm__ volatile("stb %1, %0" \
+ :"=m" (*lock) \
+ :"r" (SEMAPHORE_CLEAR) \
+ :"memory"); \
+}
+
+/*
+ * More machine dependent macros
+ */
+#ifdef PTHREAD_KERNEL
+
+#define machdep_save_float_state(x)
+#define machdep_restore_float_state()
+
+#endif
+
+/*
+ * New types
+ */
+typedef char semaphore;
+
+/*
+ * sigset_t macros
+ */
+#define SIGMAX 31
+#define SIG_ANY(sig) \
+({ \
+ sigset_t *sig_addr = (sigset_t *)&sig; \
+ int ret = 0; \
+ int i; \
+ \
+ for (i = 1; i <= SIGMAX; i++) { \
+ if (sigismember(sig_addr, i)) { \
+ ret = 1; \
+ break; \
+ } \
+ } \
+ ret; \
+})
+
+/*
+ * New Strutures
+ */
+struct machdep_pthread {
+ void *(*start_routine)(void *);
+ void *start_argument;
+ void *machdep_stack;
+ struct itimerval machdep_timer;
+ jmp_buf machdep_state;
+};
+
+/*
+ * Static machdep_pthread initialization values.
+ * For initial thread only.
+ */
+#define MACHDEP_PTHREAD_INIT \
+{ NULL, NULL, NULL, { { 0, 0 }, { 0, 100000 } }, 0 }
+
+/*
+ * Minimum stack size
+ */
+#undef PTHREAD_STACK_MIN /* Defined in limits.h */
+#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 | O_NDELAY)
+
+/*
+ * 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/mit-pthreads/machdep/freebsd-1.1/compat.h b/mit-pthreads/machdep/freebsd-1.1/compat.h
new file mode 100755
index 00000000000..e7de318aa88
--- /dev/null
+++ b/mit-pthreads/machdep/freebsd-1.1/compat.h
@@ -0,0 +1,43 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/machdep/freebsd-1.1/dirent.h b/mit-pthreads/machdep/freebsd-1.1/dirent.h
new file mode 100755
index 00000000000..5226443f86b
--- /dev/null
+++ b/mit-pthreads/machdep/freebsd-1.1/dirent.h
@@ -0,0 +1,64 @@
+/*-
+ * 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/mit-pthreads/machdep/freebsd-1.1/socket.h b/mit-pthreads/machdep/freebsd-1.1/socket.h
new file mode 100755
index 00000000000..f13d01e7fe5
--- /dev/null
+++ b/mit-pthreads/machdep/freebsd-1.1/socket.h
@@ -0,0 +1,267 @@
+/*
+ * Copyright (c) 1982,1985,1986,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: @(#)socket.h 7.13 (Berkeley) 4/20/91
+ * $Id$
+ */
+
+#ifndef _SYS_SOCKET_H_
+#define _SYS_SOCKET_H_ 1
+
+/*
+ * Definitions related to sockets: types, address families, options.
+ */
+
+/*
+ * Types
+ */
+#define SOCK_STREAM 1 /* stream socket */
+#define SOCK_DGRAM 2 /* datagram socket */
+#define SOCK_RAW 3 /* raw-protocol interface */
+#define SOCK_RDM 4 /* reliably-delivered message */
+#define SOCK_SEQPACKET 5 /* sequenced packet stream */
+
+/*
+ * Option flags per-socket.
+ */
+#define SO_DEBUG 0x0001 /* turn on debugging info recording */
+#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
+#define SO_REUSEADDR 0x0004 /* allow local address reuse */
+#define SO_KEEPALIVE 0x0008 /* keep connections alive */
+#define SO_DONTROUTE 0x0010 /* just use interface addresses */
+#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
+#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
+#define SO_LINGER 0x0080 /* linger on close if data present */
+#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
+
+/*
+ * Additional options, not kept in so_options.
+ */
+#define SO_SNDBUF 0x1001 /* send buffer size */
+#define SO_RCVBUF 0x1002 /* receive buffer size */
+#define SO_SNDLOWAT 0x1003 /* send low-water mark */
+#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
+#define SO_SNDTIMEO 0x1005 /* send timeout */
+#define SO_RCVTIMEO 0x1006 /* receive timeout */
+#define SO_ERROR 0x1007 /* get error status and clear */
+#define SO_TYPE 0x1008 /* get socket type */
+
+/*
+ * Structure used for manipulating linger option.
+ */
+struct linger {
+ int l_onoff; /* option on/off */
+ int l_linger; /* linger time */
+};
+
+/*
+ * Level number for (get/set)sockopt() to apply to socket itself.
+ */
+#define SOL_SOCKET 0xffff /* options for socket level */
+
+/*
+ * Address families.
+ */
+#define AF_UNSPEC 0 /* unspecified */
+#define AF_UNIX 1 /* local to host (pipes, portals) */
+#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
+#define AF_IMPLINK 3 /* arpanet imp addresses */
+#define AF_PUP 4 /* pup protocols: e.g. BSP */
+#define AF_CHAOS 5 /* mit CHAOS protocols */
+#define AF_NS 6 /* XEROX NS protocols */
+#define AF_ISO 7 /* ISO protocols */
+#define AF_OSI AF_ISO
+#define AF_ECMA 8 /* european computer manufacturers */
+#define AF_DATAKIT 9 /* datakit protocols */
+#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
+#define AF_SNA 11 /* IBM SNA */
+#define AF_DECnet 12 /* DECnet */
+#define AF_DLI 13 /* DEC Direct data link interface */
+#define AF_LAT 14 /* LAT */
+#define AF_HYLINK 15 /* NSC Hyperchannel */
+#define AF_APPLETALK 16 /* Apple Talk */
+#define AF_ROUTE 17 /* Internal Routing Protocol */
+#define AF_LINK 18 /* Link layer interface */
+#define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */
+#define AF_RMP 20 /* HP's Remote Maint Protocol */
+#define AF_MAX 21
+
+/*
+ * Structure used by kernel to store most
+ * addresses.
+ */
+struct sockaddr {
+ u_char sa_len; /* total length */
+ u_char sa_family; /* address family */
+ char sa_data[14]; /* actually longer; address value */
+};
+
+/*
+ * Structure used by kernel to pass protocol
+ * information in raw sockets.
+ */
+struct sockproto {
+ u_short sp_family; /* address family */
+ u_short sp_protocol; /* protocol */
+};
+
+/*
+ * Protocol families, same as address families for now.
+ */
+#define PF_UNSPEC AF_UNSPEC
+#define PF_UNIX AF_UNIX
+#define PF_INET AF_INET
+#define PF_IMPLINK AF_IMPLINK
+#define PF_PUP AF_PUP
+#define PF_CHAOS AF_CHAOS
+#define PF_NS AF_NS
+#define PF_ISO AF_ISO
+#define PF_OSI AF_ISO
+#define PF_ECMA AF_ECMA
+#define PF_DATAKIT AF_DATAKIT
+#define PF_CCITT AF_CCITT
+#define PF_SNA AF_SNA
+#define PF_DECnet AF_DECnet
+#define PF_DLI AF_DLI
+#define PF_LAT AF_LAT
+#define PF_HYLINK AF_HYLINK
+#define PF_APPLETALK AF_APPLETALK
+#define PF_ROUTE AF_ROUTE
+#define PF_LINK AF_LINK
+#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */
+#define PF_RMP AF_RMP
+
+#define PF_MAX AF_MAX
+
+/*
+ * Maximum queue length specifiable by listen.
+ */
+#define SOMAXCONN 5
+
+/*
+ * Message header for recvmsg and sendmsg calls.
+ * Used value-result for recvmsg, value only for sendmsg.
+ */
+struct msghdr {
+ caddr_t msg_name; /* optional address */
+ u_int msg_namelen; /* size of address */
+ struct iovec *msg_iov; /* scatter/gather array */
+ u_int msg_iovlen; /* # elements in msg_iov */
+ caddr_t msg_control; /* ancillary data, see below */
+ u_int msg_controllen; /* ancillary data buffer len */
+ int msg_flags; /* flags on received message */
+};
+
+#define MSG_OOB 0x1 /* process out-of-band data */
+#define MSG_PEEK 0x2 /* peek at incoming message */
+#define MSG_DONTROUTE 0x4 /* send without using routing tables */
+#define MSG_EOR 0x8 /* data completes record */
+#define MSG_TRUNC 0x10 /* data discarded before delivery */
+#define MSG_CTRUNC 0x20 /* control data lost before delivery */
+#define MSG_WAITALL 0x40 /* wait for full request or error */
+
+/*
+ * Header for ancillary data objects in msg_control buffer.
+ * Used for additional information with/about a datagram
+ * not expressible by flags. The format is a sequence
+ * of message elements headed by cmsghdr structures.
+ */
+struct cmsghdr {
+ u_int cmsg_len; /* data byte count, including hdr */
+ int cmsg_level; /* originating protocol */
+ int cmsg_type; /* protocol-specific type */
+/* followed by u_char cmsg_data[]; */
+};
+
+/* given pointer to struct adatahdr, return pointer to data */
+#define CMSG_DATA(cmsg) ((u_char *)((cmsg) + 1))
+
+/* given pointer to struct adatahdr, return pointer to next adatahdr */
+#define CMSG_NXTHDR(mhdr, cmsg) \
+ (((caddr_t)(cmsg) + (cmsg)->cmsg_len + sizeof(struct cmsghdr) > \
+ (mhdr)->msg_control + (mhdr)->msg_controllen) ? \
+ (struct cmsghdr *)NULL : \
+ (struct cmsghdr *)((caddr_t)(cmsg) + ALIGN((cmsg)->cmsg_len)))
+
+#define CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control)
+
+/* "Socket"-level control message types: */
+#define SCM_RIGHTS 0x01 /* access rights (array of int) */
+
+/*
+ * 4.3 compat sockaddr, move to compat file later
+ */
+struct osockaddr {
+ u_short sa_family; /* address family */
+ char sa_data[14]; /* up to 14 bytes of direct address */
+};
+
+/*
+ * 4.3-compat message header (move to compat file later).
+ */
+struct omsghdr {
+ caddr_t msg_name; /* optional address */
+ int msg_namelen; /* size of address */
+ struct iovec *msg_iov; /* scatter/gather array */
+ int msg_iovlen; /* # elements in msg_iov */
+ caddr_t msg_accrights; /* access rights sent/received */
+ int msg_accrightslen;
+};
+
+#ifndef KERNEL
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int accept __P_((int, struct sockaddr *, int *));
+int bind __P_((int, const struct sockaddr *, int));
+int connect __P_((int, const struct sockaddr *, int));
+int getpeername __P_((int, struct sockaddr *, int *));
+int getsockname __P_((int, struct sockaddr *, int *));
+int getsockopt __P_((int, int, int, void *, int *));
+int listen __P_((int, int));
+ssize_t recv __P_((int, void *, size_t, int));
+ssize_t recvfrom __P_((int, void *, size_t, int,
+ struct sockaddr *, int *));
+int recvmsg __P_((int, struct msghdr *, int));
+ssize_t send __P_((int, const void *, size_t, int));
+ssize_t sendto __P_((int, const void *, size_t, int,
+ const struct sockaddr *, int));
+int sendmsg __P_((int, const struct msghdr *, int));
+int setsockopt __P_((int, int, int, const void *, int));
+int shutdown __P_((int, int));
+int socket __P_((int, int, int));
+int socketpair __P_((int, int, int, int *));
+__END_DECLS
+
+#endif /* !KERNEL */
+#endif /* _SYS_SOCKET_H_ */
diff --git a/mit-pthreads/machdep/freebsd-1.1/timers.h b/mit-pthreads/machdep/freebsd-1.1/timers.h
new file mode 100755
index 00000000000..3c4d057976a
--- /dev/null
+++ b/mit-pthreads/machdep/freebsd-1.1/timers.h
@@ -0,0 +1,68 @@
+/* ==== 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$
+ *
+ * Description : Basic timers header.
+ *
+ * 1.00 94/06/13 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS_TIMERS_H_
+#define _SYS_TIMERS_H_
+
+#include <sys/types.h>
+#include <time.h>
+
+struct timespec {
+ time_t tv_sec;
+ long tv_nsec;
+};
+
+#define TIMEVAL_TO_TIMESPEC(tv, ts) { \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000; \
+}
+#define TIMESPEC_TO_TIMEVAL(tv, ts) { \
+ (tv)->tv_sec = (ts)->tv_sec; \
+ (tv)->tv_usec = (ts)->tv_nsec / 1000; \
+}
+
+/*
+ * New functions
+ */
+
+__BEGIN_DECLS
+
+__END_DECLS
+
+#endif
diff --git a/mit-pthreads/machdep/freebsd-2.0/__math.h b/mit-pthreads/machdep/freebsd-2.0/__math.h
new file mode 100755
index 00000000000..27ed0f2575d
--- /dev/null
+++ b/mit-pthreads/machdep/freebsd-2.0/__math.h
@@ -0,0 +1,6 @@
+/*
+ * ANSI/POSIX
+ */
+extern char __infinity[];
+#define HUGE_VAL (*(double *) __infinity)
+
diff --git a/mit-pthreads/machdep/freebsd-2.0/__path.h b/mit-pthreads/machdep/freebsd-2.0/__path.h
new file mode 100755
index 00000000000..432494daafa
--- /dev/null
+++ b/mit-pthreads/machdep/freebsd-2.0/__path.h
@@ -0,0 +1,14 @@
+/*
+ * from: @(#)time.h 5.12 (Berkeley) 3/9/91
+ * $Id$
+ */
+
+#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/mit-pthreads/machdep/freebsd-2.0/__signal.h b/mit-pthreads/machdep/freebsd-2.0/__signal.h
new file mode 100755
index 00000000000..918955c9948
--- /dev/null
+++ b/mit-pthreads/machdep/freebsd-2.0/__signal.h
@@ -0,0 +1,8 @@
+#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/mit-pthreads/machdep/freebsd-2.0/__stdio.h b/mit-pthreads/machdep/freebsd-2.0/__stdio.h
new file mode 100755
index 00000000000..d60b9df7a54
--- /dev/null
+++ b/mit-pthreads/machdep/freebsd-2.0/__stdio.h
@@ -0,0 +1,8 @@
+
+#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/mit-pthreads/machdep/freebsd-2.0/__stdlib.h b/mit-pthreads/machdep/freebsd-2.0/__stdlib.h
new file mode 100755
index 00000000000..5ee2b8ed3d9
--- /dev/null
+++ b/mit-pthreads/machdep/freebsd-2.0/__stdlib.h
@@ -0,0 +1,66 @@
+/*-
+ * 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$
+ */
+
+#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/mit-pthreads/machdep/freebsd-2.0/__string.h b/mit-pthreads/machdep/freebsd-2.0/__string.h
new file mode 100755
index 00000000000..93d4fcf9dd2
--- /dev/null
+++ b/mit-pthreads/machdep/freebsd-2.0/__string.h
@@ -0,0 +1,21 @@
+
+#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/mit-pthreads/machdep/freebsd-2.0/__time.h b/mit-pthreads/machdep/freebsd-2.0/__time.h
new file mode 100755
index 00000000000..5c4b722bc3c
--- /dev/null
+++ b/mit-pthreads/machdep/freebsd-2.0/__time.h
@@ -0,0 +1,70 @@
+/*
+ * 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$
+ */
+
+#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/mit-pthreads/machdep/freebsd-2.0/__unistd.h b/mit-pthreads/machdep/freebsd-2.0/__unistd.h
new file mode 100755
index 00000000000..ed5b0657727
--- /dev/null
+++ b/mit-pthreads/machdep/freebsd-2.0/__unistd.h
@@ -0,0 +1,113 @@
+/*-
+ * 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$
+ */
+
+#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
+
+#ifndef _POSIX_VERSION
+#define _POSIX_VERSION 198808L
+#endif
+#ifndef _POSIX2_VERSION
+#define _POSIX2_VERSION 199212L
+#endif
+
+/* 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/mit-pthreads/machdep/freebsd-2.0/compat.h b/mit-pthreads/machdep/freebsd-2.0/compat.h
new file mode 100755
index 00000000000..e7de318aa88
--- /dev/null
+++ b/mit-pthreads/machdep/freebsd-2.0/compat.h
@@ -0,0 +1,43 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/machdep/freebsd-2.0/dirent.h b/mit-pthreads/machdep/freebsd-2.0/dirent.h
new file mode 100755
index 00000000000..5226443f86b
--- /dev/null
+++ b/mit-pthreads/machdep/freebsd-2.0/dirent.h
@@ -0,0 +1,64 @@
+/*-
+ * 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/mit-pthreads/machdep/freebsd-2.0/errno.h b/mit-pthreads/machdep/freebsd-2.0/errno.h
new file mode 100755
index 00000000000..3da61d692a3
--- /dev/null
+++ b/mit-pthreads/machdep/freebsd-2.0/errno.h
@@ -0,0 +1,160 @@
+/* $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/mit-pthreads/machdep/freebsd-2.0/timers.h b/mit-pthreads/machdep/freebsd-2.0/timers.h
new file mode 100755
index 00000000000..f9768c68c8f
--- /dev/null
+++ b/mit-pthreads/machdep/freebsd-2.0/timers.h
@@ -0,0 +1,45 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/machdep/freebsd-2.0/wait.h b/mit-pthreads/machdep/freebsd-2.0/wait.h
new file mode 100755
index 00000000000..7861e3fa180
--- /dev/null
+++ b/mit-pthreads/machdep/freebsd-2.0/wait.h
@@ -0,0 +1,162 @@
+/*
+ * 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$
+ */
+
+#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/mit-pthreads/machdep/hpux-10.20/__math.h b/mit-pthreads/machdep/hpux-10.20/__math.h
new file mode 100755
index 00000000000..8066bd60713
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-10.20/__math.h
@@ -0,0 +1,3 @@
+#define HUGE_VAL 1.7976931348623157e+308
+
+
diff --git a/mit-pthreads/machdep/hpux-10.20/__signal.h b/mit-pthreads/machdep/hpux-10.20/__signal.h
new file mode 100755
index 00000000000..fbb1d6ce2b1
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-10.20/__signal.h
@@ -0,0 +1,28 @@
+#include <sys/signal.h>
+
+#ifndef SIGCLD
+#define SIGCLD SIGCHLD
+#endif
+
+/* #define sigmask(n) ((unsigned int)1 << (((n) - 1) & (32 - 1))) */
+#define sigword(n) (((unsigned int)((n) - 1))>>5)
+
+#define __SIGEMPTYSET { 0, 0, 0, 0, 0, 0, 0, 0 }
+#define __SIGFILLSET { 0xffffffff,0xffffffff,0xffffffff,0xffffffff,\
+ 0xffffffff,0xffffffff,0xffffffff,0xffffffff}
+#define __SIGADDSET(s, n) ((s)->sigset[sigword(n)] |= sigmask(n))
+#define __SIGDELSET(s, n) ((s)->sigset[sigword(n)] &= ~sigmask(n))
+#define __SIGISMEMBER(s, n) ((s)->sigset[sigword(n)] & sigmask(n))
+
+#define SIGSET_SIZE sizeof(sigset_t)/sizeof(long)
+
+#define SIG_ANY(sig) sig_any(&sig)
+
+static inline int sig_any(sigset_t *sig) {
+ int i;
+ for (i=0; i < SIGSET_SIZE; i++)
+ if (sig->sigset[i] != 0)
+ return 1;
+ return 0;
+}
+
diff --git a/mit-pthreads/machdep/hpux-10.20/__stdio.h b/mit-pthreads/machdep/hpux-10.20/__stdio.h
new file mode 100755
index 00000000000..b8f1a07d9d6
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-10.20/__stdio.h
@@ -0,0 +1,11 @@
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef pthread_size_t size_t;
+#endif
+
+#include <sys/types.h>
+/*
+typedef pthread_fpos_t fpos_t;
+*/
+
diff --git a/mit-pthreads/machdep/hpux-10.20/__stdlib.h b/mit-pthreads/machdep/hpux-10.20/__stdlib.h
new file mode 100755
index 00000000000..37a14a960d5
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-10.20/__stdlib.h
@@ -0,0 +1,24 @@
+/* $Id$ */
+
+#ifndef __sys_stdtypes_h
+
+#ifndef _SYS___STDLIB_H_
+#define _SYS___STDLIB_H_
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef unsigned int size_t;
+#endif
+
+#ifndef _WCHAR_T
+#define _WCHAR_T
+typedef unsigned int wchar_t;
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/hpux-10.20/__string.h b/mit-pthreads/machdep/hpux-10.20/__string.h
new file mode 100755
index 00000000000..1badf6d660c
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-10.20/__string.h
@@ -0,0 +1,20 @@
+
+#ifndef _SYS_STDSYMS_INCLUDED
+#endif
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef pthread_size_t size_t;
+#endif
+
+/* Non-standard SunOS 4.x 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 *));
+__END_DECLS
+#endif
diff --git a/mit-pthreads/machdep/hpux-10.20/__time.h b/mit-pthreads/machdep/hpux-10.20/__time.h
new file mode 100755
index 00000000000..ae958dcc3cf
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-10.20/__time.h
@@ -0,0 +1,31 @@
+/* $Id$ */
+
+#ifndef __sys_stdtypes_h
+
+#ifndef _SYS__TIME_H_
+#define _SYS__TIME_H_
+
+#ifndef _CLOCK_T
+#define _CLOCK_T
+typedef long clock_t;
+#endif
+
+#ifndef _TIME_T
+#define _TIME_T
+typedef long time_t;
+#endif
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef unsigned int size_t;
+#endif
+
+#define CLOCKS_PER_SEC 1000000
+
+#if !defined(_ANSI_SOURCE) && !defined(CLK_TCK)
+#define CLK_TCK 60
+#endif /* not ANSI */
+
+#endif
+
+#endif /* !_SYS__TIME_H_ */
diff --git a/mit-pthreads/machdep/hpux-10.20/__unistd.h b/mit-pthreads/machdep/hpux-10.20/__unistd.h
new file mode 100755
index 00000000000..218e13d14ec
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-10.20/__unistd.h
@@ -0,0 +1,68 @@
+/* /afs/sipb.mit.edu/project/pthreads/src/CVS/pthreads/machdep/hpux-9.03/__unist
+d.h,v 1.2 1995/03/10 03:59:53 snl Exp */
+
+#ifndef _SYS___UNISTD_H_
+#define _SYS___UNISTD_H_
+
+#include <sys/stdsyms.h>
+#include <sys/types.h>
+#include <utime.h>
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef _GID_T
+#define _GID_T
+typedef long gid_t;
+#endif
+
+#ifndef _UID_T
+#define _UID_T
+typedef long uid_t;
+#endif
+
+#ifndef _PID_T
+#define _PID_T
+typedef long pid_t;
+#endif
+
+#ifndef _OFF_T
+#define _OFF_T
+typedef long off_t;
+#endif
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef unsigned int size_t;
+#endif
+
+#ifndef _SSIZE_T
+#define _SSIZE_T
+typedef int ssize_t;
+#endif
+
+#define ioctl_request_type int /* For fd.c */
+
+/* Symbolic constants for sysconf() variables defined by POSIX.1-1988: 0-7 */
+
+#define _SC_ARG_MAX 0 /* ARG_MAX: Max length of argument to exec()
+ including environment data */
+#define _SC_CHILD_MAX 1 /* CHILD_MAX: Max of processes per userid */
+#define _SC_CLK_TCK 2 /* Number of clock ticks per second */
+#define _SC_NGROUPS_MAX 3 /* NGROUPS_MAX: Max of simultaneous
+ supplementary group IDs per process */
+#define _SC_OPEN_MAX 4 /* OPEN_MAX: Max of files that one process
+ can have open at any one time */
+#define _SC_JOB_CONTROL 5 /* _POSIX_JOB_CONTROL: 1 iff supported */
+#define _SC_SAVED_IDS 6 /* _POSIX_SAVED_IDS: 1 iff supported */
+#define _SC_1_VERSION_88 7 /* _POSIX_VERSION: Date of POSIX.1-1988 */
+
+/* Symbolic constants for sysconf() variables added by POSIX.1-1990: 100-199 */
+
+#define _SC_STREAM_MAX 100 /* STREAM_MAX: Max of open stdio FILEs */
+#define _SC_TZNAME_MAX 101 /* TZNAME_MAX: Max length of timezone name */
+#define _SC_1_VERSION_90 102 /* _POSIX_VERSION: Date of POSIX.1-1990 */
+
+#endif /* _SYS___UNISTD_H_ */
+
diff --git a/mit-pthreads/machdep/hpux-10.20/cdefs.h b/mit-pthreads/machdep/hpux-10.20/cdefs.h
new file mode 100755
index 00000000000..643089e6df6
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-10.20/cdefs.h
@@ -0,0 +1,67 @@
+/* ==== cdefs.h ============================================================
+ * Copyright (c) 1994 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Similar to the BSD cdefs.h file.
+ *
+ * 1.00 94/01/26 proven
+ * -Started coding this file.
+ */
+
+#ifndef _PTHREAD_SYS_CDEFS_H_
+#define _PTHREAD_SYS_CDEFS_H_
+
+#include <sys/_inttypes.h>
+
+/* Stuff for compiling */
+#if defined(__GNUC__)
+#if defined(__cplusplus)
+#define __INLINE static inline
+#define __BEGIN_DECLS extern "C" {
+#define __END_DECLS };
+#else
+#define __INLINE extern inline
+#define __CAN_DO_EXTERN_INLINE
+#define __BEGIN_DECLS
+#define __END_DECLS
+#if !defined(__STDC__)
+#define const __const
+#define inline __inline
+#define signed __signed
+#define volatile __volatile
+#endif
+#endif
+#else /* !__GNUC__ */
+#define __INLINE static
+#define __BEGIN_DECLS
+#define __END_DECLS
+#endif
+
+#ifndef __NORETURN
+#define __NORETURN
+#endif /* __NORETURN not defined. */
+
+#ifndef _U_INT32_T_
+#define _U_INT32_T_
+typedef unsigned int u_int32_t;
+#endif
+
+#ifndef _U_INT16_T_
+#define _U_INT16_T_
+typedef unsigned short u_int16_t;
+#endif
+
+#ifndef _INT32_T_
+#define _INT32_T_
+/*
+typedef int int32_t;
+*/
+#endif
+
+#ifndef _INT16_T_
+#define _INT16_T_
+/*
+typedef short int16_t;
+*/
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/hpux-10.20/compat.h b/mit-pthreads/machdep/hpux-10.20/compat.h
new file mode 100755
index 00000000000..5a59434417c
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-10.20/compat.h
@@ -0,0 +1,45 @@
+/* ==== 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$
+ *
+ * Description : Compatibility header for networking code.
+ *
+ * 1.00 94/06/13 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS_COMPAT_H_
+#define _SYS_COMPAT_H_
+
+#define omsghdr msghdr
+
+#endif
diff --git a/mit-pthreads/machdep/hpux-10.20/dirent.h b/mit-pthreads/machdep/hpux-10.20/dirent.h
new file mode 100755
index 00000000000..5f17af345db
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-10.20/dirent.h
@@ -0,0 +1,61 @@
+/*-
+ * 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
+
+#endif /* !_SYS_DIRENT_H_ */
diff --git a/mit-pthreads/machdep/hpux-10.20/socket.h b/mit-pthreads/machdep/hpux-10.20/socket.h
new file mode 100755
index 00000000000..c7a37706940
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-10.20/socket.h
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 1982, 1985, 1986 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, 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'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * @(#)socket.h 7.3 (Berkeley) 6/27/88
+ */
+
+/*
+ * Definitions related to sockets: types, address families, options.
+ */
+
+#include <sys/stdsyms.h>
+#include <pthread/posix.h>
+#include <sys/cdefs.h>
+
+/*
+ * Types of sockets
+ */
+#define SOCK_STREAM 1 /* stream socket */
+#define SOCK_DGRAM 2 /* datagram socket */
+#define SOCK_RAW 3 /* raw-protocol interface */
+#define SOCK_RDM 4 /* reliably-delivered message */
+#define SOCK_SEQPACKET 5 /* sequenced packet stream */
+
+/*
+ * Option flags per-socket.
+ */
+#define SO_DEBUG 0x0001 /* turn on debugging info recording */
+#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
+#define SO_REUSEADDR 0x0004 /* allow local address reuse */
+#define SO_KEEPALIVE 0x0008 /* keep connections alive */
+#define SO_DONTROUTE 0x0010 /* just use interface addresses */
+#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
+#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
+#define SO_LINGER 0x0080 /* linger on close if data present */
+#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
+
+/*
+ * Additional options, not kept in so_options.
+ */
+#define SO_SNDBUF 0x1001 /* send buffer size */
+#define SO_RCVBUF 0x1002 /* receive buffer size */
+#define SO_SNDLOWAT 0x1003 /* send low-water mark */
+#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
+#define SO_SNDTIMEO 0x1005 /* send timeout */
+#define SO_RCVTIMEO 0x1006 /* receive timeout */
+#define SO_ERROR 0x1007 /* get error status and clear */
+#define SO_TYPE 0x1008 /* get socket type */
+#define SO_SND_COPYAVOID 0x1009 /* avoid copy on send*/
+#define SO_RCV_COPYAVOID 0x100a /* avoid copy on rcv */
+
+/*
+ * Level number for (get/set)sockopt() to apply to socket itself.
+ */
+#define SOL_SOCKET 0xffff /* options for socket level */
+
+/*
+ * Address families.
+ */
+#define AF_UNSPEC 0 /* unspecified */
+#define AF_UNIX 1 /* local to host (pipes, portals) */
+#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
+#define AF_IMPLINK 3 /* arpanet imp addresses */
+#define AF_PUP 4 /* pup protocols: e.g. BSP */
+#define AF_CHAOS 5 /* mit CHAOS protocols */
+#define AF_NS 6 /* XEROX NS protocols */
+#define AF_NBS 7 /* nbs protocols */
+#define AF_ECMA 8 /* european computer manufacturers */
+#define AF_DATAKIT 9 /* datakit protocols */
+#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
+#define AF_SNA 11 /* IBM SNA */
+#define AF_DECnet 12 /* DECnet */
+#define AF_DLI 13 /* Direct data link interface */
+#define AF_LAT 14 /* LAT */
+#define AF_HYLINK 15 /* NSC Hyperchannel */
+#define AF_APPLETALK 16 /* Apple Talk */
+#define AF_OTS 17 /* Used for OSI in the ifnets */
+#define AF_NIT 18 /* NIT */
+
+#define AF_MAX 19
+
+/*
+ * Structure used by kernel to store most
+ * addresses.
+ */
+struct sockaddr {
+ unsigned short sa_family; /* address family */
+ char sa_data[14]; /* up to 14 bytes of direct address */
+};
+
+/*
+ * Structure used by kernel to pass protocol
+ * information in raw sockets.
+ */
+struct sockproto {
+ unsigned short sp_family; /* address family */
+ unsigned short sp_protocol; /* protocol */
+};
+
+/*
+ * Protocol families, same as address families for now.
+ */
+#define PF_UNSPEC AF_UNSPEC
+#define PF_UNIX AF_UNIX
+#define PF_INET AF_INET
+#define PF_IMPLINK AF_IMPLINK
+#define PF_PUP AF_PUP
+#define PF_CHAOS AF_CHAOS
+#define PF_NS AF_NS
+#define PF_NBS AF_NBS
+#define PF_ECMA AF_ECMA
+#define PF_DATAKIT AF_DATAKIT
+#define PF_CCITT AF_CCITT
+#define PF_SNA AF_SNA
+#define PF_DECnet AF_DECnet
+#define PF_DLI AF_DLI
+#define PF_LAT AF_LAT
+#define PF_HYLINK AF_HYLINK
+#define PF_APPLETALK AF_APPLETALK
+
+#define PF_MAX AF_MAX
+
+/*
+ * Maximum queue length specifiable by listen.
+ */
+#define SOMAXCONN 20
+
+/*
+ * Message header for recvmsg and sendmsg calls.
+ */
+struct msghdr {
+ caddr_t msg_name; /* optional address */
+ int msg_namelen; /* size of address */
+ struct iovec *msg_iov; /* scatter/gather array */
+ int msg_iovlen; /* # elements in msg_iov */
+ caddr_t msg_accrights; /* access rights sent/received */
+ int msg_accrightslen;
+};
+
+#define MSG_OOB 0x1 /* process out-of-band data */
+#define MSG_PEEK 0x2 /* peek at incoming message */
+#define MSG_DONTROUTE 0x4 /* send without using routing tables */
+
+#define MSG_MAXIOVLEN 16
+
+/*
+ * Functions
+ */
+
+__BEGIN_DECLS
+
+int accept __P_((int, struct sockaddr *, int *));
+int bind __P_((int, const struct sockaddr *, int));
+int connect __P_((int, const struct sockaddr *, int));
+int listen __P_((int, int));
+int socket __P_((int, int, int));
+
+__END_DECLS
+
diff --git a/mit-pthreads/machdep/hpux-10.20/stdtypes.h b/mit-pthreads/machdep/hpux-10.20/stdtypes.h
new file mode 100755
index 00000000000..2b22abbf818
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-10.20/stdtypes.h
@@ -0,0 +1,74 @@
+/* @(#)stdtypes.h 1.6 90/01/04 SMI */
+
+/*
+ * Suppose you have an ANSI C or POSIX thingy that needs a typedef
+ * for thingy_t. Put it here and include this file wherever you
+ * define the thingy. This is used so that we don't have size_t in
+ * N (N > 1) different places and so that we don't have to have
+ * types.h included all the time and so that we can include this in
+ * the lint libs instead of termios.h which conflicts with ioctl.h.
+ */
+#ifndef __sys_stdtypes_h
+#define __sys_stdtypes_h
+
+#ifndef _SIGSET_T_
+#define _SIGSET_T_
+typedef int sigset_t; /* signal mask - may change */
+#endif
+
+#ifndef _SPEED_T_
+#define _SPEED_T_
+typedef unsigned int speed_t; /* tty speeds */
+#endif
+
+#ifndef _TCFLAG_T_
+#define _TCFLAG_T_
+typedef unsigned long tcflag_t; /* tty line disc modes */
+#endif
+
+#ifndef _CC_T_
+#define _CC_T_
+typedef unsigned char cc_t; /* tty control char */
+#endif
+
+#ifndef _PID_T_
+#define _PID_T_
+typedef int pid_t; /* process id */
+#endif
+
+#ifndef _MODE_T_
+#define _MODE_T_
+typedef unsigned short mode_t; /* file mode bits */
+#endif
+
+#ifndef _NLINK_T_
+#define _NLINK_T_
+typedef short nlink_t; /* links to a file */
+#endif
+
+#ifndef _CLOCK_T_
+#define _CLOCK_T_
+typedef long clock_t; /* units=ticks (typically 60/sec) */
+#endif
+
+#ifndef _TIME_T_
+#define _TIME_T_
+typedef long time_t; /* value = secs since epoch */
+#endif
+
+#ifndef _SIZE_T_
+#define _SIZE_T_
+typedef int size_t; /* ??? */
+#endif
+
+#ifndef _PTRDIFF_T_
+#define _PTRDIFF_T_
+typedef int ptrdiff_t; /* result of subtracting two pointers */
+#endif
+
+#ifndef _WCHAR_T_
+#define _WCHAR_T_
+typedef unsigned short wchar_t; /* big enough for biggest char set */
+#endif
+
+#endif /* !__sys_stdtypes_h */
diff --git a/mit-pthreads/machdep/hpux-10.20/time.h b/mit-pthreads/machdep/hpux-10.20/time.h
new file mode 100755
index 00000000000..544905b0749
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-10.20/time.h
@@ -0,0 +1,228 @@
+/* $Header$ */
+
+#ifndef _SYS_TIME_INCLUDED
+#define _SYS_TIME_INCLUDED
+
+/* time.h: Definitions for time handling functions */
+
+#ifdef _KERNEL_BUILD
+#include "../h/stdsyms.h"
+#else /* ! _KERNEL_BUILD */
+#include <sys/stdsyms.h>
+#endif /* _KERNEL_BUILD */
+
+#include <sys/types.h>
+
+/* ANSI C time constants, types, and structures */
+
+#ifdef _INCLUDE__STDC__
+# define CLOCKS_PER_SEC 1000000
+
+# ifndef NULL
+# define NULL 0
+# endif
+
+# ifndef _CLOCK_T
+# define _CLOCK_T
+ typedef unsigned long clock_t;
+# endif /* _CLOCK_T */
+
+# ifndef _TIME_T
+# define _TIME_T
+ typedef long time_t;
+# endif /* _TIME_T */
+
+# ifndef _SIZE_T
+# define _SIZE_T
+ typedef unsigned int size_t;
+# endif /* _SIZE_T */
+
+ /* Structure used with gmtime(), localtime(), mktime(), strftime(). */
+ struct tm {
+ int tm_sec; /* second (0-61, allows for leap seconds) */
+ int tm_min; /* minute (0-59) */
+ int tm_hour; /* hour (0-23) */
+ int tm_mday; /* day of the month (1-31) */
+ int tm_mon; /* month (0-11) */
+ int tm_year; /* years since 1900 */
+ int tm_wday; /* day of the week (0-6) */
+ int tm_yday; /* day of the year (0-365) */
+ int tm_isdst; /* non-0 if daylight savings time is in effect */
+ };
+#endif /* _INCLUDE__STDC__ */
+
+
+/* Additional types needed for HP-UX */
+
+#ifdef _INCLUDE_HPUX_SOURCE
+# ifndef _STRUCT_TIMEVAL
+# define _STRUCT_TIMEVAL
+ /* Structure returned by gettimeofday(2) system call and others */
+ struct timeval {
+ unsigned long tv_sec; /* seconds */
+ long tv_usec; /* and microseconds */
+ };
+# endif /* _STRUCT_TIMEVAL */
+
+ /* Structure used to represent timezones for gettimeofday(2) and others */
+ struct timezone {
+ int tz_minuteswest; /* minutes west of Greenwich */
+ int tz_dsttime; /* type of dst correction */
+ };
+
+ /* Structure defining a timer setting. */
+ struct itimerval {
+ struct timeval it_interval; /* timer interval */
+ struct timeval it_value; /* current value */
+ };
+#endif /* _INCLUDE_HPUX_SOURCE */
+
+
+/* Function prototypes and external variable declarations */
+
+#ifndef _KERNEL
+#ifdef __cplusplus
+ extern "C" {
+#endif /* __cplusplus */
+
+#ifdef _INCLUDE__STDC__
+# ifdef _PROTOTYPES
+ extern double difftime(time_t, time_t);
+ extern time_t mktime(struct tm *);
+ extern time_t time(time_t *);
+ extern char *ctime(const time_t *);
+ extern struct tm *gmtime(const time_t *);
+ extern struct tm *localtime(const time_t *);
+ extern size_t strftime(char *, size_t, const char *, const struct tm *);
+# else /* not _PROTOTYPES */
+ extern double difftime();
+ extern time_t mktime();
+ extern time_t time();
+ extern char *ctime();
+ extern struct tm *gmtime();
+ extern struct tm *localtime();
+ extern size_t strftime();
+# endif /* not _PROTOTYPES */
+
+# ifdef _CLASSIC_ANSI_TYPES
+ extern long clock();
+# else /* not _CLASSIC_ANSI_TYPES */
+# ifdef _PROTOTYPES
+ extern clock_t clock(void);
+# else /* not _PROTOTYPES */
+ extern clock_t clock();
+# endif /* not _PROTOTYPES */
+# endif /* not _CLASSIC_ANSI_TYPES */
+#endif /* _INCLUDE__STDC__ */
+
+#ifdef _INCLUDE_POSIX_SOURCE
+# ifdef _PROTOTYPES
+ extern void tzset(void);
+# else /* not _PROTOTYPES */
+ extern void tzset();
+# endif /* not _PROTOTYPES */
+
+ extern char *tzname[2];
+#endif /* _INCLUDE_POSIX_SOURCE */
+
+
+#ifdef _INCLUDE_XOPEN_SOURCE
+# ifdef _PROTOTYPES
+ extern char *strptime(const char *, const char *, struct tm *);
+# else /* not _PROTOTYPES */
+ extern char *strptime();
+# endif /* not _PROTOTYPES */
+
+ extern long timezone;
+ extern int daylight;
+#endif /* _INCLUDE_XOPEN_SOURCE */
+
+
+#ifdef _INCLUDE_HPUX_SOURCE
+# ifdef _PROTOTYPES
+ extern struct tm *getdate(const char *);
+ extern char *nl_asctime(struct tm *, char *, int);
+ extern char *nl_ctime(long *, char *, int);
+ extern char *nl_ascxtime(struct tm *, char *);
+ extern char *nl_cxtime(long *, char *);
+ extern int getitimer(int, struct itimerval *);
+ extern int setitimer(int, const struct itimerval *, struct itimerval *);
+ extern int gettimeofday(struct timeval *, struct timezone *);
+ extern int settimeofday(const struct timeval *, const struct timezone *);
+ extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
+ extern int stime(const time_t *);
+# else /* not _PROTOTYPES */
+ extern struct tm *getdate();
+ extern char *nl_asctime();
+ extern char *nl_ctime();
+ extern char *nl_ascxtime();
+ extern char *nl_cxtime();
+ extern int getitimer();
+ extern int setitimer();
+ extern int gettimeofday();
+ extern int settimeofday();
+ extern int select();
+ extern int stime();
+# endif /* not _PROTOTYPES */
+ extern int getdate_err;
+#endif /* _INCLUDE_HPUX_SOURCE */
+
+#ifdef __cplusplus
+ }
+#endif /* __cplusplus */
+#endif /* not _KERNEL */
+
+
+/*
+ * CLK_TCK is needed by the kernel, and also in the POSIX namespace.
+ */
+
+#ifdef _INCLUDE_POSIX_SOURCE
+# ifndef CLK_TCK
+# ifdef __hp9000s300
+# define CLK_TCK 50
+# endif /* __hp9000s300 */
+# ifdef __hp9000s800
+# define CLK_TCK 100
+# endif /* __hp9000s800 */
+# endif /* CLK_TCK */
+#endif
+
+
+/* Additional HP-UX structures, macros, and constants */
+
+#ifdef _INCLUDE_HPUX_SOURCE
+
+ /* Kernel instrumentation time value */
+ struct ki_timeval {
+ long tv_sec; /* seconds */
+ long tv_nunit; /* and native units */
+ };
+
+ /* Kinds of daylight savings time */
+# define DST_NONE 0 /* not on dst */
+# define DST_USA 1 /* USA style dst */
+# define DST_AUST 2 /* Australian style dst */
+# define DST_WET 3 /* Western European dst */
+# define DST_MET 4 /* Middle European dst */
+# define DST_EET 5 /* Eastern European dst */
+
+ /*
+ * Operations on timevals.
+ *
+ * NB: timercmp does not work for >= or <=.
+ */
+# define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
+# define timercmp(tvp, uvp, cmp) \
+ ((tvp)->tv_sec cmp (uvp)->tv_sec || \
+ (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
+# define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
+
+ /* Names of the interval timers */
+# define ITIMER_REAL 0
+# define ITIMER_VIRTUAL 1
+# define ITIMER_PROF 2
+
+#endif /* _INCLUDE_HPUX_SOURCE */
+
+#endif /* _SYS_TIME_INCLUDED */
diff --git a/mit-pthreads/machdep/hpux-10.20/timers.h b/mit-pthreads/machdep/hpux-10.20/timers.h
new file mode 100755
index 00000000000..5a76a295400
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-10.20/timers.h
@@ -0,0 +1,71 @@
+/* ==== 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$
+ *
+ * Description : Basic timers header.
+ *
+ * 1.00 94/06/13 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS_TIMERS_H_
+#define _SYS_TIMERS_H_
+
+#include <sys/signal.h>
+#include <sys/types.h>
+#include <time.h>
+
+/*
+struct timespec {
+ time_t tv_sec;
+ long tv_nsec;
+};
+*/
+
+#define TIMEVAL_TO_TIMESPEC(tv, ts) { \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000; \
+}
+#define TIMESPEC_TO_TIMEVAL(tv, ts) { \
+ (tv)->tv_sec = (ts)->tv_sec; \
+ (tv)->tv_usec = (ts)->tv_nsec / 1000; \
+}
+
+/*
+ * New functions
+ */
+
+__BEGIN_DECLS
+
+__END_DECLS
+
+#endif
diff --git a/mit-pthreads/machdep/hpux-10.20/uio.h b/mit-pthreads/machdep/hpux-10.20/uio.h
new file mode 100755
index 00000000000..d1ec4c94f22
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-10.20/uio.h
@@ -0,0 +1,25 @@
+/* ==== uio.h ============================================================
+ * Copyright (c) 1994 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Correct HP-UX header file.
+ */
+
+#ifndef _PTHREAD_UIO_H_
+#define _PTHREAD_UIO_H_
+
+#include <sys/cdefs.h>
+
+struct iovec {
+ void *iov_base;
+ size_t iov_len;
+};
+
+__BEGIN_DECLS
+
+int readv __P_((int, const struct iovec *, int));
+int writev __P_((int, const struct iovec *, int));
+
+__END_DECLS
+
+#endif
+
diff --git a/mit-pthreads/machdep/hpux-10.20/wait.h b/mit-pthreads/machdep/hpux-10.20/wait.h
new file mode 100755
index 00000000000..bca70d9f1ec
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-10.20/wait.h
@@ -0,0 +1,92 @@
+/*
+ * 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.
+ *
+ * from: @(#)wait.h 8.1 (Berkeley) 6/2/93
+ * $Id$
+ */
+
+#ifndef _SYS_WAIT_H_
+#define _SYS_WAIT_H_
+
+/*
+ * Macros to test the exit status returned by wait
+ * and extract the relevant values.
+ */
+#define _W_INT(i) (i)
+#define WCOREFLAG 0200
+
+#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
+
+#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 */
+
+#define WSTOPPED _WSTOPPED
+#endif /* _POSIX_SOURCE */
+
+#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 *));
+#endif
+
+__END_DECLS
+
+#endif
diff --git a/mit-pthreads/machdep/hpux-9.03/__math.h b/mit-pthreads/machdep/hpux-9.03/__math.h
new file mode 100755
index 00000000000..8066bd60713
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-9.03/__math.h
@@ -0,0 +1,3 @@
+#define HUGE_VAL 1.7976931348623157e+308
+
+
diff --git a/mit-pthreads/machdep/hpux-9.03/__signal.h b/mit-pthreads/machdep/hpux-9.03/__signal.h
new file mode 100755
index 00000000000..fbb1d6ce2b1
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-9.03/__signal.h
@@ -0,0 +1,28 @@
+#include <sys/signal.h>
+
+#ifndef SIGCLD
+#define SIGCLD SIGCHLD
+#endif
+
+/* #define sigmask(n) ((unsigned int)1 << (((n) - 1) & (32 - 1))) */
+#define sigword(n) (((unsigned int)((n) - 1))>>5)
+
+#define __SIGEMPTYSET { 0, 0, 0, 0, 0, 0, 0, 0 }
+#define __SIGFILLSET { 0xffffffff,0xffffffff,0xffffffff,0xffffffff,\
+ 0xffffffff,0xffffffff,0xffffffff,0xffffffff}
+#define __SIGADDSET(s, n) ((s)->sigset[sigword(n)] |= sigmask(n))
+#define __SIGDELSET(s, n) ((s)->sigset[sigword(n)] &= ~sigmask(n))
+#define __SIGISMEMBER(s, n) ((s)->sigset[sigword(n)] & sigmask(n))
+
+#define SIGSET_SIZE sizeof(sigset_t)/sizeof(long)
+
+#define SIG_ANY(sig) sig_any(&sig)
+
+static inline int sig_any(sigset_t *sig) {
+ int i;
+ for (i=0; i < SIGSET_SIZE; i++)
+ if (sig->sigset[i] != 0)
+ return 1;
+ return 0;
+}
+
diff --git a/mit-pthreads/machdep/hpux-9.03/__stdio.h b/mit-pthreads/machdep/hpux-9.03/__stdio.h
new file mode 100755
index 00000000000..091b065a2e9
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-9.03/__stdio.h
@@ -0,0 +1,8 @@
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef pthread_size_t size_t;
+#endif
+
+typedef pthread_fpos_t fpos_t;
+
diff --git a/mit-pthreads/machdep/hpux-9.03/__stdlib.h b/mit-pthreads/machdep/hpux-9.03/__stdlib.h
new file mode 100755
index 00000000000..37a14a960d5
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-9.03/__stdlib.h
@@ -0,0 +1,24 @@
+/* $Id$ */
+
+#ifndef __sys_stdtypes_h
+
+#ifndef _SYS___STDLIB_H_
+#define _SYS___STDLIB_H_
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef unsigned int size_t;
+#endif
+
+#ifndef _WCHAR_T
+#define _WCHAR_T
+typedef unsigned int wchar_t;
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/hpux-9.03/__string.h b/mit-pthreads/machdep/hpux-9.03/__string.h
new file mode 100755
index 00000000000..1badf6d660c
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-9.03/__string.h
@@ -0,0 +1,20 @@
+
+#ifndef _SYS_STDSYMS_INCLUDED
+#endif
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef pthread_size_t size_t;
+#endif
+
+/* Non-standard SunOS 4.x 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 *));
+__END_DECLS
+#endif
diff --git a/mit-pthreads/machdep/hpux-9.03/__time.h b/mit-pthreads/machdep/hpux-9.03/__time.h
new file mode 100755
index 00000000000..ae958dcc3cf
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-9.03/__time.h
@@ -0,0 +1,31 @@
+/* $Id$ */
+
+#ifndef __sys_stdtypes_h
+
+#ifndef _SYS__TIME_H_
+#define _SYS__TIME_H_
+
+#ifndef _CLOCK_T
+#define _CLOCK_T
+typedef long clock_t;
+#endif
+
+#ifndef _TIME_T
+#define _TIME_T
+typedef long time_t;
+#endif
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef unsigned int size_t;
+#endif
+
+#define CLOCKS_PER_SEC 1000000
+
+#if !defined(_ANSI_SOURCE) && !defined(CLK_TCK)
+#define CLK_TCK 60
+#endif /* not ANSI */
+
+#endif
+
+#endif /* !_SYS__TIME_H_ */
diff --git a/mit-pthreads/machdep/hpux-9.03/__unistd.h b/mit-pthreads/machdep/hpux-9.03/__unistd.h
new file mode 100755
index 00000000000..0e8515b1f96
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-9.03/__unistd.h
@@ -0,0 +1,66 @@
+/* /afs/sipb.mit.edu/project/pthreads/src/CVS/pthreads/machdep/hpux-9.03/__unist
+d.h,v 1.2 1995/03/10 03:59:53 snl Exp */
+
+#ifndef _SYS___UNISTD_H_
+#define _SYS___UNISTD_H_
+
+#include <sys/stdsyms.h>
+#include <sys/types.h>
+#include <utime.h>
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef _GID_T
+#define _GID_T
+typedef long gid_t;
+#endif
+
+#ifndef _UID_T
+#define _UID_T
+typedef long uid_t;
+#endif
+
+#ifndef _PID_T
+#define _PID_T
+typedef long pid_t;
+#endif
+
+#ifndef _OFF_T
+#define _OFF_T
+typedef long off_t;
+#endif
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef unsigned int size_t;
+#endif
+
+#ifndef _SSIZE_T
+#define _SSIZE_T
+typedef int ssize_t;
+#endif
+
+/* Symbolic constants for sysconf() variables defined by POSIX.1-1988: 0-7 */
+
+#define _SC_ARG_MAX 0 /* ARG_MAX: Max length of argument to exec()
+ including environment data */
+#define _SC_CHILD_MAX 1 /* CHILD_MAX: Max of processes per userid */
+#define _SC_CLK_TCK 2 /* Number of clock ticks per second */
+#define _SC_NGROUPS_MAX 3 /* NGROUPS_MAX: Max of simultaneous
+ supplementary group IDs per process */
+#define _SC_OPEN_MAX 4 /* OPEN_MAX: Max of files that one process
+ can have open at any one time */
+#define _SC_JOB_CONTROL 5 /* _POSIX_JOB_CONTROL: 1 iff supported */
+#define _SC_SAVED_IDS 6 /* _POSIX_SAVED_IDS: 1 iff supported */
+#define _SC_1_VERSION_88 7 /* _POSIX_VERSION: Date of POSIX.1-1988 */
+
+/* Symbolic constants for sysconf() variables added by POSIX.1-1990: 100-199 */
+
+#define _SC_STREAM_MAX 100 /* STREAM_MAX: Max of open stdio FILEs */
+#define _SC_TZNAME_MAX 101 /* TZNAME_MAX: Max length of timezone name */
+#define _SC_1_VERSION_90 102 /* _POSIX_VERSION: Date of POSIX.1-1990 */
+
+#endif /* _SYS___UNISTD_H_ */
+
diff --git a/mit-pthreads/machdep/hpux-9.03/cdefs.h b/mit-pthreads/machdep/hpux-9.03/cdefs.h
new file mode 100755
index 00000000000..041300cbe02
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-9.03/cdefs.h
@@ -0,0 +1,61 @@
+/* ==== cdefs.h ============================================================
+ * Copyright (c) 1994 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Similar to the BSD cdefs.h file.
+ *
+ * 1.00 94/01/26 proven
+ * -Started coding this file.
+ */
+
+#ifndef _PTHREAD_SYS_CDEFS_H_
+#define _PTHREAD_SYS_CDEFS_H_
+
+/* Stuff for compiling */
+#if defined(__GNUC__)
+#if defined(__cplusplus)
+#define __INLINE static inline
+#define __BEGIN_DECLS extern "C" {
+#define __END_DECLS };
+#else
+#define __INLINE extern inline
+#define __CAN_DO_EXTERN_INLINE
+#define __BEGIN_DECLS
+#define __END_DECLS
+#if !defined(__STDC__)
+#define const __const
+#define inline __inline
+#define signed __signed
+#define volatile __volatile
+#endif
+#endif
+#else /* !__GNUC__ */
+#define __INLINE static
+#define __BEGIN_DECLS
+#define __END_DECLS
+#endif
+
+#ifndef __NORETURN
+#define __NORETURN
+#endif /* __NORETURN not defined. */
+
+#ifndef _U_INT32_T_
+#define _U_INT32_T_
+typedef unsigned int u_int32_t;
+#endif
+
+#ifndef _U_INT16_T_
+#define _U_INT16_T_
+typedef unsigned short u_int16_t;
+#endif
+
+#ifndef _INT32_T_
+#define _INT32_T_
+typedef int int32_t;
+#endif
+
+#ifndef _INT16_T_
+#define _INT16_T_
+typedef short int16_t;
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/hpux-9.03/compat.h b/mit-pthreads/machdep/hpux-9.03/compat.h
new file mode 100755
index 00000000000..5a59434417c
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-9.03/compat.h
@@ -0,0 +1,45 @@
+/* ==== 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$
+ *
+ * Description : Compatibility header for networking code.
+ *
+ * 1.00 94/06/13 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS_COMPAT_H_
+#define _SYS_COMPAT_H_
+
+#define omsghdr msghdr
+
+#endif
diff --git a/mit-pthreads/machdep/hpux-9.03/dirent.h b/mit-pthreads/machdep/hpux-9.03/dirent.h
new file mode 100755
index 00000000000..5f17af345db
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-9.03/dirent.h
@@ -0,0 +1,61 @@
+/*-
+ * 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
+
+#endif /* !_SYS_DIRENT_H_ */
diff --git a/mit-pthreads/machdep/hpux-9.03/socket.h b/mit-pthreads/machdep/hpux-9.03/socket.h
new file mode 100755
index 00000000000..c7a37706940
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-9.03/socket.h
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 1982, 1985, 1986 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, 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'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * @(#)socket.h 7.3 (Berkeley) 6/27/88
+ */
+
+/*
+ * Definitions related to sockets: types, address families, options.
+ */
+
+#include <sys/stdsyms.h>
+#include <pthread/posix.h>
+#include <sys/cdefs.h>
+
+/*
+ * Types of sockets
+ */
+#define SOCK_STREAM 1 /* stream socket */
+#define SOCK_DGRAM 2 /* datagram socket */
+#define SOCK_RAW 3 /* raw-protocol interface */
+#define SOCK_RDM 4 /* reliably-delivered message */
+#define SOCK_SEQPACKET 5 /* sequenced packet stream */
+
+/*
+ * Option flags per-socket.
+ */
+#define SO_DEBUG 0x0001 /* turn on debugging info recording */
+#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
+#define SO_REUSEADDR 0x0004 /* allow local address reuse */
+#define SO_KEEPALIVE 0x0008 /* keep connections alive */
+#define SO_DONTROUTE 0x0010 /* just use interface addresses */
+#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
+#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
+#define SO_LINGER 0x0080 /* linger on close if data present */
+#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
+
+/*
+ * Additional options, not kept in so_options.
+ */
+#define SO_SNDBUF 0x1001 /* send buffer size */
+#define SO_RCVBUF 0x1002 /* receive buffer size */
+#define SO_SNDLOWAT 0x1003 /* send low-water mark */
+#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
+#define SO_SNDTIMEO 0x1005 /* send timeout */
+#define SO_RCVTIMEO 0x1006 /* receive timeout */
+#define SO_ERROR 0x1007 /* get error status and clear */
+#define SO_TYPE 0x1008 /* get socket type */
+#define SO_SND_COPYAVOID 0x1009 /* avoid copy on send*/
+#define SO_RCV_COPYAVOID 0x100a /* avoid copy on rcv */
+
+/*
+ * Level number for (get/set)sockopt() to apply to socket itself.
+ */
+#define SOL_SOCKET 0xffff /* options for socket level */
+
+/*
+ * Address families.
+ */
+#define AF_UNSPEC 0 /* unspecified */
+#define AF_UNIX 1 /* local to host (pipes, portals) */
+#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
+#define AF_IMPLINK 3 /* arpanet imp addresses */
+#define AF_PUP 4 /* pup protocols: e.g. BSP */
+#define AF_CHAOS 5 /* mit CHAOS protocols */
+#define AF_NS 6 /* XEROX NS protocols */
+#define AF_NBS 7 /* nbs protocols */
+#define AF_ECMA 8 /* european computer manufacturers */
+#define AF_DATAKIT 9 /* datakit protocols */
+#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
+#define AF_SNA 11 /* IBM SNA */
+#define AF_DECnet 12 /* DECnet */
+#define AF_DLI 13 /* Direct data link interface */
+#define AF_LAT 14 /* LAT */
+#define AF_HYLINK 15 /* NSC Hyperchannel */
+#define AF_APPLETALK 16 /* Apple Talk */
+#define AF_OTS 17 /* Used for OSI in the ifnets */
+#define AF_NIT 18 /* NIT */
+
+#define AF_MAX 19
+
+/*
+ * Structure used by kernel to store most
+ * addresses.
+ */
+struct sockaddr {
+ unsigned short sa_family; /* address family */
+ char sa_data[14]; /* up to 14 bytes of direct address */
+};
+
+/*
+ * Structure used by kernel to pass protocol
+ * information in raw sockets.
+ */
+struct sockproto {
+ unsigned short sp_family; /* address family */
+ unsigned short sp_protocol; /* protocol */
+};
+
+/*
+ * Protocol families, same as address families for now.
+ */
+#define PF_UNSPEC AF_UNSPEC
+#define PF_UNIX AF_UNIX
+#define PF_INET AF_INET
+#define PF_IMPLINK AF_IMPLINK
+#define PF_PUP AF_PUP
+#define PF_CHAOS AF_CHAOS
+#define PF_NS AF_NS
+#define PF_NBS AF_NBS
+#define PF_ECMA AF_ECMA
+#define PF_DATAKIT AF_DATAKIT
+#define PF_CCITT AF_CCITT
+#define PF_SNA AF_SNA
+#define PF_DECnet AF_DECnet
+#define PF_DLI AF_DLI
+#define PF_LAT AF_LAT
+#define PF_HYLINK AF_HYLINK
+#define PF_APPLETALK AF_APPLETALK
+
+#define PF_MAX AF_MAX
+
+/*
+ * Maximum queue length specifiable by listen.
+ */
+#define SOMAXCONN 20
+
+/*
+ * Message header for recvmsg and sendmsg calls.
+ */
+struct msghdr {
+ caddr_t msg_name; /* optional address */
+ int msg_namelen; /* size of address */
+ struct iovec *msg_iov; /* scatter/gather array */
+ int msg_iovlen; /* # elements in msg_iov */
+ caddr_t msg_accrights; /* access rights sent/received */
+ int msg_accrightslen;
+};
+
+#define MSG_OOB 0x1 /* process out-of-band data */
+#define MSG_PEEK 0x2 /* peek at incoming message */
+#define MSG_DONTROUTE 0x4 /* send without using routing tables */
+
+#define MSG_MAXIOVLEN 16
+
+/*
+ * Functions
+ */
+
+__BEGIN_DECLS
+
+int accept __P_((int, struct sockaddr *, int *));
+int bind __P_((int, const struct sockaddr *, int));
+int connect __P_((int, const struct sockaddr *, int));
+int listen __P_((int, int));
+int socket __P_((int, int, int));
+
+__END_DECLS
+
diff --git a/mit-pthreads/machdep/hpux-9.03/stdtypes.h b/mit-pthreads/machdep/hpux-9.03/stdtypes.h
new file mode 100755
index 00000000000..2b22abbf818
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-9.03/stdtypes.h
@@ -0,0 +1,74 @@
+/* @(#)stdtypes.h 1.6 90/01/04 SMI */
+
+/*
+ * Suppose you have an ANSI C or POSIX thingy that needs a typedef
+ * for thingy_t. Put it here and include this file wherever you
+ * define the thingy. This is used so that we don't have size_t in
+ * N (N > 1) different places and so that we don't have to have
+ * types.h included all the time and so that we can include this in
+ * the lint libs instead of termios.h which conflicts with ioctl.h.
+ */
+#ifndef __sys_stdtypes_h
+#define __sys_stdtypes_h
+
+#ifndef _SIGSET_T_
+#define _SIGSET_T_
+typedef int sigset_t; /* signal mask - may change */
+#endif
+
+#ifndef _SPEED_T_
+#define _SPEED_T_
+typedef unsigned int speed_t; /* tty speeds */
+#endif
+
+#ifndef _TCFLAG_T_
+#define _TCFLAG_T_
+typedef unsigned long tcflag_t; /* tty line disc modes */
+#endif
+
+#ifndef _CC_T_
+#define _CC_T_
+typedef unsigned char cc_t; /* tty control char */
+#endif
+
+#ifndef _PID_T_
+#define _PID_T_
+typedef int pid_t; /* process id */
+#endif
+
+#ifndef _MODE_T_
+#define _MODE_T_
+typedef unsigned short mode_t; /* file mode bits */
+#endif
+
+#ifndef _NLINK_T_
+#define _NLINK_T_
+typedef short nlink_t; /* links to a file */
+#endif
+
+#ifndef _CLOCK_T_
+#define _CLOCK_T_
+typedef long clock_t; /* units=ticks (typically 60/sec) */
+#endif
+
+#ifndef _TIME_T_
+#define _TIME_T_
+typedef long time_t; /* value = secs since epoch */
+#endif
+
+#ifndef _SIZE_T_
+#define _SIZE_T_
+typedef int size_t; /* ??? */
+#endif
+
+#ifndef _PTRDIFF_T_
+#define _PTRDIFF_T_
+typedef int ptrdiff_t; /* result of subtracting two pointers */
+#endif
+
+#ifndef _WCHAR_T_
+#define _WCHAR_T_
+typedef unsigned short wchar_t; /* big enough for biggest char set */
+#endif
+
+#endif /* !__sys_stdtypes_h */
diff --git a/mit-pthreads/machdep/hpux-9.03/time.h b/mit-pthreads/machdep/hpux-9.03/time.h
new file mode 100755
index 00000000000..544905b0749
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-9.03/time.h
@@ -0,0 +1,228 @@
+/* $Header$ */
+
+#ifndef _SYS_TIME_INCLUDED
+#define _SYS_TIME_INCLUDED
+
+/* time.h: Definitions for time handling functions */
+
+#ifdef _KERNEL_BUILD
+#include "../h/stdsyms.h"
+#else /* ! _KERNEL_BUILD */
+#include <sys/stdsyms.h>
+#endif /* _KERNEL_BUILD */
+
+#include <sys/types.h>
+
+/* ANSI C time constants, types, and structures */
+
+#ifdef _INCLUDE__STDC__
+# define CLOCKS_PER_SEC 1000000
+
+# ifndef NULL
+# define NULL 0
+# endif
+
+# ifndef _CLOCK_T
+# define _CLOCK_T
+ typedef unsigned long clock_t;
+# endif /* _CLOCK_T */
+
+# ifndef _TIME_T
+# define _TIME_T
+ typedef long time_t;
+# endif /* _TIME_T */
+
+# ifndef _SIZE_T
+# define _SIZE_T
+ typedef unsigned int size_t;
+# endif /* _SIZE_T */
+
+ /* Structure used with gmtime(), localtime(), mktime(), strftime(). */
+ struct tm {
+ int tm_sec; /* second (0-61, allows for leap seconds) */
+ int tm_min; /* minute (0-59) */
+ int tm_hour; /* hour (0-23) */
+ int tm_mday; /* day of the month (1-31) */
+ int tm_mon; /* month (0-11) */
+ int tm_year; /* years since 1900 */
+ int tm_wday; /* day of the week (0-6) */
+ int tm_yday; /* day of the year (0-365) */
+ int tm_isdst; /* non-0 if daylight savings time is in effect */
+ };
+#endif /* _INCLUDE__STDC__ */
+
+
+/* Additional types needed for HP-UX */
+
+#ifdef _INCLUDE_HPUX_SOURCE
+# ifndef _STRUCT_TIMEVAL
+# define _STRUCT_TIMEVAL
+ /* Structure returned by gettimeofday(2) system call and others */
+ struct timeval {
+ unsigned long tv_sec; /* seconds */
+ long tv_usec; /* and microseconds */
+ };
+# endif /* _STRUCT_TIMEVAL */
+
+ /* Structure used to represent timezones for gettimeofday(2) and others */
+ struct timezone {
+ int tz_minuteswest; /* minutes west of Greenwich */
+ int tz_dsttime; /* type of dst correction */
+ };
+
+ /* Structure defining a timer setting. */
+ struct itimerval {
+ struct timeval it_interval; /* timer interval */
+ struct timeval it_value; /* current value */
+ };
+#endif /* _INCLUDE_HPUX_SOURCE */
+
+
+/* Function prototypes and external variable declarations */
+
+#ifndef _KERNEL
+#ifdef __cplusplus
+ extern "C" {
+#endif /* __cplusplus */
+
+#ifdef _INCLUDE__STDC__
+# ifdef _PROTOTYPES
+ extern double difftime(time_t, time_t);
+ extern time_t mktime(struct tm *);
+ extern time_t time(time_t *);
+ extern char *ctime(const time_t *);
+ extern struct tm *gmtime(const time_t *);
+ extern struct tm *localtime(const time_t *);
+ extern size_t strftime(char *, size_t, const char *, const struct tm *);
+# else /* not _PROTOTYPES */
+ extern double difftime();
+ extern time_t mktime();
+ extern time_t time();
+ extern char *ctime();
+ extern struct tm *gmtime();
+ extern struct tm *localtime();
+ extern size_t strftime();
+# endif /* not _PROTOTYPES */
+
+# ifdef _CLASSIC_ANSI_TYPES
+ extern long clock();
+# else /* not _CLASSIC_ANSI_TYPES */
+# ifdef _PROTOTYPES
+ extern clock_t clock(void);
+# else /* not _PROTOTYPES */
+ extern clock_t clock();
+# endif /* not _PROTOTYPES */
+# endif /* not _CLASSIC_ANSI_TYPES */
+#endif /* _INCLUDE__STDC__ */
+
+#ifdef _INCLUDE_POSIX_SOURCE
+# ifdef _PROTOTYPES
+ extern void tzset(void);
+# else /* not _PROTOTYPES */
+ extern void tzset();
+# endif /* not _PROTOTYPES */
+
+ extern char *tzname[2];
+#endif /* _INCLUDE_POSIX_SOURCE */
+
+
+#ifdef _INCLUDE_XOPEN_SOURCE
+# ifdef _PROTOTYPES
+ extern char *strptime(const char *, const char *, struct tm *);
+# else /* not _PROTOTYPES */
+ extern char *strptime();
+# endif /* not _PROTOTYPES */
+
+ extern long timezone;
+ extern int daylight;
+#endif /* _INCLUDE_XOPEN_SOURCE */
+
+
+#ifdef _INCLUDE_HPUX_SOURCE
+# ifdef _PROTOTYPES
+ extern struct tm *getdate(const char *);
+ extern char *nl_asctime(struct tm *, char *, int);
+ extern char *nl_ctime(long *, char *, int);
+ extern char *nl_ascxtime(struct tm *, char *);
+ extern char *nl_cxtime(long *, char *);
+ extern int getitimer(int, struct itimerval *);
+ extern int setitimer(int, const struct itimerval *, struct itimerval *);
+ extern int gettimeofday(struct timeval *, struct timezone *);
+ extern int settimeofday(const struct timeval *, const struct timezone *);
+ extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
+ extern int stime(const time_t *);
+# else /* not _PROTOTYPES */
+ extern struct tm *getdate();
+ extern char *nl_asctime();
+ extern char *nl_ctime();
+ extern char *nl_ascxtime();
+ extern char *nl_cxtime();
+ extern int getitimer();
+ extern int setitimer();
+ extern int gettimeofday();
+ extern int settimeofday();
+ extern int select();
+ extern int stime();
+# endif /* not _PROTOTYPES */
+ extern int getdate_err;
+#endif /* _INCLUDE_HPUX_SOURCE */
+
+#ifdef __cplusplus
+ }
+#endif /* __cplusplus */
+#endif /* not _KERNEL */
+
+
+/*
+ * CLK_TCK is needed by the kernel, and also in the POSIX namespace.
+ */
+
+#ifdef _INCLUDE_POSIX_SOURCE
+# ifndef CLK_TCK
+# ifdef __hp9000s300
+# define CLK_TCK 50
+# endif /* __hp9000s300 */
+# ifdef __hp9000s800
+# define CLK_TCK 100
+# endif /* __hp9000s800 */
+# endif /* CLK_TCK */
+#endif
+
+
+/* Additional HP-UX structures, macros, and constants */
+
+#ifdef _INCLUDE_HPUX_SOURCE
+
+ /* Kernel instrumentation time value */
+ struct ki_timeval {
+ long tv_sec; /* seconds */
+ long tv_nunit; /* and native units */
+ };
+
+ /* Kinds of daylight savings time */
+# define DST_NONE 0 /* not on dst */
+# define DST_USA 1 /* USA style dst */
+# define DST_AUST 2 /* Australian style dst */
+# define DST_WET 3 /* Western European dst */
+# define DST_MET 4 /* Middle European dst */
+# define DST_EET 5 /* Eastern European dst */
+
+ /*
+ * Operations on timevals.
+ *
+ * NB: timercmp does not work for >= or <=.
+ */
+# define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
+# define timercmp(tvp, uvp, cmp) \
+ ((tvp)->tv_sec cmp (uvp)->tv_sec || \
+ (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
+# define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
+
+ /* Names of the interval timers */
+# define ITIMER_REAL 0
+# define ITIMER_VIRTUAL 1
+# define ITIMER_PROF 2
+
+#endif /* _INCLUDE_HPUX_SOURCE */
+
+#endif /* _SYS_TIME_INCLUDED */
diff --git a/mit-pthreads/machdep/hpux-9.03/timers.h b/mit-pthreads/machdep/hpux-9.03/timers.h
new file mode 100755
index 00000000000..3c4d057976a
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-9.03/timers.h
@@ -0,0 +1,68 @@
+/* ==== 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$
+ *
+ * Description : Basic timers header.
+ *
+ * 1.00 94/06/13 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS_TIMERS_H_
+#define _SYS_TIMERS_H_
+
+#include <sys/types.h>
+#include <time.h>
+
+struct timespec {
+ time_t tv_sec;
+ long tv_nsec;
+};
+
+#define TIMEVAL_TO_TIMESPEC(tv, ts) { \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000; \
+}
+#define TIMESPEC_TO_TIMEVAL(tv, ts) { \
+ (tv)->tv_sec = (ts)->tv_sec; \
+ (tv)->tv_usec = (ts)->tv_nsec / 1000; \
+}
+
+/*
+ * New functions
+ */
+
+__BEGIN_DECLS
+
+__END_DECLS
+
+#endif
diff --git a/mit-pthreads/machdep/hpux-9.03/uio.h b/mit-pthreads/machdep/hpux-9.03/uio.h
new file mode 100755
index 00000000000..d1ec4c94f22
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-9.03/uio.h
@@ -0,0 +1,25 @@
+/* ==== uio.h ============================================================
+ * Copyright (c) 1994 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Correct HP-UX header file.
+ */
+
+#ifndef _PTHREAD_UIO_H_
+#define _PTHREAD_UIO_H_
+
+#include <sys/cdefs.h>
+
+struct iovec {
+ void *iov_base;
+ size_t iov_len;
+};
+
+__BEGIN_DECLS
+
+int readv __P_((int, const struct iovec *, int));
+int writev __P_((int, const struct iovec *, int));
+
+__END_DECLS
+
+#endif
+
diff --git a/mit-pthreads/machdep/hpux-9.03/wait.h b/mit-pthreads/machdep/hpux-9.03/wait.h
new file mode 100755
index 00000000000..bca70d9f1ec
--- /dev/null
+++ b/mit-pthreads/machdep/hpux-9.03/wait.h
@@ -0,0 +1,92 @@
+/*
+ * 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.
+ *
+ * from: @(#)wait.h 8.1 (Berkeley) 6/2/93
+ * $Id$
+ */
+
+#ifndef _SYS_WAIT_H_
+#define _SYS_WAIT_H_
+
+/*
+ * Macros to test the exit status returned by wait
+ * and extract the relevant values.
+ */
+#define _W_INT(i) (i)
+#define WCOREFLAG 0200
+
+#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
+
+#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 */
+
+#define WSTOPPED _WSTOPPED
+#endif /* _POSIX_SOURCE */
+
+#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 *));
+#endif
+
+__END_DECLS
+
+#endif
diff --git a/mit-pthreads/machdep/i386-sco-3.2v5/__math.h b/mit-pthreads/machdep/i386-sco-3.2v5/__math.h
new file mode 100755
index 00000000000..4852683fcbf
--- /dev/null
+++ b/mit-pthreads/machdep/i386-sco-3.2v5/__math.h
@@ -0,0 +1,219 @@
+/* Copyright 1994-1995 The Santa Cruz Operation, Inc. All Rights Reserved. */
+
+
+#if defined(_NO_PROTOTYPE) /* Old, crufty environment */
+#include <oldstyle/__math.h>
+#elif defined(_XOPEN_SOURCE) || defined(_XPG4_VERS) /* Xpg4 environment */
+#include <xpg4/__math.h>
+#elif defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) /* Posix environment */
+#include <posix/__math.h>
+#elif _STRICT_ANSI /* Pure Ansi/ISO environment */
+#include <ansi/__math.h>
+#elif defined(_SCO_ODS_30) /* Old, Tbird compatible environment */
+#include <ods_30_compat/__math.h>
+#else /* Normal, default environment */
+/*
+ * Portions Copyright (C) 1983-1995 The Santa Cruz Operation, Inc.
+ * All Rights Reserved.
+ *
+ * The information in this file is provided for the exclusive use of
+ * the licensees of The Santa Cruz Operation, Inc. Such users have the
+ * right to use, modify, and incorporate this code into other products
+ * for purposes authorized by the license agreement provided they include
+ * this notice and the associated copyright notice with any such product.
+ * The information in this file is provided "AS IS" without warranty.
+ */
+
+/* Portions Copyright (c) 1990, 1991, 1992, 1993 UNIX System Laboratories, Inc. */
+/* Portions Copyright (c) 1979 - 1990 AT&T */
+/* All Rights Reserved */
+
+/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
+/* UNIX System Laboratories, Inc. */
+/* The copyright notice above does not evidence any */
+/* actual or intended publication of such source code. */
+
+#ifndef ___MATH_H
+#define ___MATH_H
+
+#pragma comment(exestr, "xpg4plus @(#) math.h 20.1 94/12/04 ")
+
+#pragma pack(4)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+extern double acos(double);
+extern double asin(double);
+extern double atan(double);
+extern double atan2(double, double);
+extern double cos(double);
+extern double sin(double);
+extern double tan(double);
+
+extern double cosh(double);
+extern double sinh(double);
+extern double tanh(double);
+
+extern double exp(double);
+extern double frexp(double, int *);
+extern double ldexp(double, int);
+extern double log(double);
+extern double log10(double);
+extern double modf(double, double *);
+
+extern double pow(double, double);
+extern double sqrt(double);
+
+extern double ceil(double);
+extern double fabs(double);
+extern double floor(double);
+extern double fmod(double, double);
+
+#ifndef HUGE_VAL
+extern const double __huge_val;
+#define HUGE_VAL (+__huge_val)
+#endif
+
+
+extern double erf(double);
+extern double erfc(double);
+extern double gamma(double);
+extern double hypot(double, double);
+extern double j0(double);
+extern double j1(double);
+extern double jn(int, double);
+extern double y0(double);
+extern double y1(double);
+extern double yn(int, double);
+extern double lgamma(double);
+extern int isnan(double);
+
+#define MAXFLOAT ((float)3.40282346638528860e+38)
+
+
+
+#define HUGE MAXFLOAT
+
+/*
+ * The following are all legal as XPG4 external functions but must only
+ * be declared in the non standards environments as they conflict with
+ * the user name space
+ */
+
+extern long double frexpl(long double, int *);
+extern long double ldexpl(long double, int);
+extern long double modfl(long double, long double *);
+
+extern float acosf(float);
+extern float asinf(float);
+extern float atanf(float);
+extern float atan2f(float, float);
+extern float cosf(float);
+extern float sinf(float);
+extern float tanf(float);
+
+extern float coshf(float);
+extern float sinhf(float);
+extern float tanhf(float);
+
+extern float expf(float);
+extern float logf(float);
+extern float log10f(float);
+
+extern float powf(float, float);
+extern float sqrtf(float);
+
+extern float ceilf(float);
+extern float fabsf(float);
+extern float floorf(float);
+extern float fmodf(float, float);
+extern float modff(float, float *);
+
+/* These are all extensions from XPG4 */
+
+extern double atof(const char *);
+extern double scalb(double, double);
+extern double logb(double);
+extern double log1p(double);
+extern double nextafter(double, double);
+extern double acosh(double);
+extern double asinh(double);
+extern double atanh(double);
+extern double cbrt(double);
+extern double copysign(double, double);
+extern double expm1(double);
+extern int ilogb(double);
+extern double remainder(double, double);
+extern double rint(double);
+extern int unordered(double, double);
+extern int finite(double);
+
+extern long double scalbl(long double, long double);
+extern long double logbl(long double);
+extern long double nextafterl(long double, long double);
+extern int unorderedl(long double, long double);
+extern int finitel(long double);
+
+
+
+
+extern int signgam;
+
+#define M_E 2.7182818284590452354
+#define M_LOG2E 1.4426950408889634074
+#define M_LOG10E 0.43429448190325182765
+#define M_LN2 0.69314718055994530942
+#define M_LN10 2.30258509299404568402
+#define M_PI 3.14159265358979323846
+#define M_PI_2 1.57079632679489661923
+#define M_PI_4 0.78539816339744830962
+#define M_1_PI 0.31830988618379067154
+#define M_2_PI 0.63661977236758134308
+#define M_2_SQRTPI 1.12837916709551257390
+#define M_SQRT2 1.41421356237309504880
+#define M_SQRT1_2 0.70710678118654752440
+
+
+
+#define _ABS(x) ((x) < 0 ? -(x) : (x))
+
+#define _REDUCE(TYPE, X, XN, C1, C2) { \
+ double x1 = (double)(TYPE)X, x2 = X - x1; \
+ X = x1 - (XN) * (C1); X += x2; X -= (XN) * (C2); }
+
+#define DOMAIN 1
+#define SING 2
+#define OVERFLOW 3
+#define UNDERFLOW 4
+#define TLOSS 5
+#define PLOSS 6
+
+#define _POLY1(x, c) ((c)[0] * (x) + (c)[1])
+#define _POLY2(x, c) (_POLY1((x), (c)) * (x) + (c)[2])
+#define _POLY3(x, c) (_POLY2((x), (c)) * (x) + (c)[3])
+#define _POLY4(x, c) (_POLY3((x), (c)) * (x) + (c)[4])
+#define _POLY5(x, c) (_POLY4((x), (c)) * (x) + (c)[5])
+#define _POLY6(x, c) (_POLY5((x), (c)) * (x) + (c)[6])
+#define _POLY7(x, c) (_POLY6((x), (c)) * (x) + (c)[7])
+#define _POLY8(x, c) (_POLY7((x), (c)) * (x) + (c)[8])
+#define _POLY9(x, c) (_POLY8((x), (c)) * (x) + (c)[9])
+
+
+#ifdef __cplusplus
+}
+inline int sqr(int i) {return(i*i);}
+inline double sqr(double i) {return(i*i);}
+
+#endif /* __cplusplus */
+
+#pragma pack()
+
+#if __cplusplus && !defined(PI)
+#define PI M_PI
+#endif /* __cplusplus */
+
+#endif /* _MATH_H */
+#endif
diff --git a/mit-pthreads/machdep/i386-sco-3.2v5/__signal.h b/mit-pthreads/machdep/i386-sco-3.2v5/__signal.h
new file mode 100755
index 00000000000..6a33d37a261
--- /dev/null
+++ b/mit-pthreads/machdep/i386-sco-3.2v5/__signal.h
@@ -0,0 +1,109 @@
+/* Copyright 1994-1995 The Santa Cruz Operation, Inc. All Rights Reserved. */
+
+
+#if defined(_NO_PROTOTYPE) /* Old, crufty environment */
+#include <sys/oldstyle/signal.h>
+#elif defined(_XOPEN_SOURCE) || defined(_XPG4_VERS) /* Xpg4 environment */
+#include <xpg4/signal.h>
+#elif defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) /* Posix environment */
+#include <sys/posix/__signal.h>
+#elif _STRICT_ANSI /* Pure Ansi/ISO environment */
+#include <sys/ansi/signal.h>
+#elif defined(_SCO_ODS_30) /* Old, Tbird compatible environment */
+#include <sys/ods_30_compat/signal.h>
+#else /* Normal, default environment */
+/*
+ * Portions Copyright (C) 1983-1995 The Santa Cruz Operation, Inc.
+ * All Rights Reserved.
+ *
+ * The information in this file is provided for the exclusive use of
+ * the licensees of The Santa Cruz Operation, Inc. Such users have the
+ * right to use, modify, and incorporate this code into other products
+ * for purposes authorized by the license agreement provided they include
+ * this notice and the associated copyright notice with any such product.
+ * The information in this file is provided "AS IS" without warranty.
+ */
+
+/* Portions Copyright (c) 1990, 1991, 1992, 1993 UNIX System Laboratories, Inc. */
+/* Portions Copyright (c) 1979 - 1990 AT&T */
+/* All Rights Reserved */
+
+/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
+/* UNIX System Laboratories, Inc. */
+/* The copyright notice above does not evidence any */
+/* actual or intended publication of such source code. */
+
+#ifndef ___SIGNAL_H
+#define ___SIGNAL_H
+
+#pragma comment(exestr, "xpg4plus @(#) signal.h 20.3 94/12/19 ")
+
+#ifndef _SIG_ATOMIC_T
+#define _SIG_ATOMIC_T
+ /* atomic entity for signal handling */
+typedef int sig_atomic_t;
+#endif
+
+extern const char * const _sys_siglist[];
+extern const int _sys_nsig;
+
+#ifndef _SYS_SIGNAL_H
+#include <sys/signal.h>
+#endif
+
+#define SignalBad ((SignalHandler)-1)
+#define SignalDefault ((SignalHandler)0)
+#define SignalIgnore ((SignalHandler)1)
+
+#define __sigmask(sig) (1 << ((sig) - 1))
+#define __SIGEMPTYSET (~SIGALL)
+#define __SIGFILLSET SIGALL
+#define __SIGADDSET(s,n) ((*s) |= (__sigmask(n)))
+#define __SIGDELSET(s,n) ((*s) &= ~(__sigmask(n)))
+#define __SIGISMEMBER(s,n) ((*s) & (__sigmask(n)))
+
+#if !defined(_SYS_TYPES_H)
+#include <sys/types.h>
+#endif
+
+
+#if __cplusplus
+extern "C" {
+#endif
+
+extern void (*signal(int, void(*)(int)))(int);
+extern int raise(int);
+
+extern void (*bsd_signal(int, void(*)(int)))(int);
+extern int ( *ssignal( int, int(*)(int) ) )(int);
+extern void ( *sigset( int, void(*)(int) ) )(int);
+extern int killpg(pid_t, int);
+#ifdef SS_ONSTACK /* Not defined on old versions of the OS */
+extern int sigaltstack(const stack_t *, stack_t *);
+extern int sigstack(struct sigstack *, struct sigstack *);
+#endif
+extern int sighold(int);
+extern int sigignore(int);
+extern int siginterrupt(int, int);
+extern int sigpause(int);
+extern int sigrelse(int);
+
+extern int (sigfillset)(sigset_t *);
+extern int (sigemptyset)(sigset_t *);
+extern int (sigaddset)(sigset_t *, int);
+extern int (sigdelset)(sigset_t *, int);
+extern int (sigismember)(const sigset_t *, int);
+extern int sigpending(sigset_t *);
+extern int sigsuspend(const sigset_t *);
+extern int sigprocmask(int, const sigset_t *, sigset_t *);
+extern int kill(pid_t, int);
+extern int sigaction(int, const struct sigaction *, struct sigaction *);
+
+#if __cplusplus
+};
+#endif
+
+
+#endif /* ___SIGNAL_H */
+
+#endif
diff --git a/mit-pthreads/machdep/i386-sco-3.2v5/__stdio.h b/mit-pthreads/machdep/i386-sco-3.2v5/__stdio.h
new file mode 100755
index 00000000000..f19672980ec
--- /dev/null
+++ b/mit-pthreads/machdep/i386-sco-3.2v5/__stdio.h
@@ -0,0 +1,113 @@
+/* Copyright 1994-1995 The Santa Cruz Operation, Inc. All Rights Reserved. */
+
+
+#if defined(_NO_PROTOTYPE) /* Old, crufty environment */
+#include <oldstyle/__stdio.h>
+#elif defined(_XOPEN_SOURCE) || defined(_XPG4_VERS) /* Xpg4 environment */
+#include <xpg4/__stdio.h>
+#elif defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) /* Posix environment */
+#include <posix/__stdio.h>
+#elif _STRICT_ANSI /* Pure Ansi/ISO environment */
+#include <ansi/__stdio.h>
+#elif defined(_SCO_ODS_30) /* Old, Tbird compatible environment */
+#include <ods_30_compat/__stdio.h>
+#else /* Normal, default environment */
+/*
+ * Portions Copyright (C) 1984-1995 The Santa Cruz Operation, Inc.
+ * All Rights Reserved.
+ *
+ * The information in this file is provided for the exclusive use of
+ * the licensees of The Santa Cruz Operation, Inc. Such users have the
+ * right to use, modify, and incorporate this code into other products
+ * for purposes authorized by the license agreement provided they include
+ * this notice and the associated copyright notice with any such product.
+ * The information in this file is provided "AS IS" without warranty.
+ */
+
+/* Portions Copyright (c) 1990, 1991, 1992, 1993 UNIX System Laboratories, Inc. */
+/* Portions Copyright (c) 1979 - 1990 AT&T */
+/* All Rights Reserved */
+
+/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
+/* UNIX System Laboratories, Inc. */
+/* The copyright notice above does not evidence any */
+/* actual or intended publication of such source code. */
+
+#ifndef ___STDIO_H
+#define ___STDIO_H
+
+#pragma comment(exestr, "xpg4plus @(#) stdio.h 20.1 94/12/04 ")
+
+#pragma pack(4)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef unsigned int size_t;
+#endif
+
+#ifndef _FPOS_T
+#define _FPOS_T
+typedef long fpos_t;
+#endif
+
+#ifndef _WCHAR_T
+#define _WCHAR_T
+typedef long wchar_t;
+#endif
+
+#ifndef _WINT_T
+#define _WINT_T
+typedef long wint_t;
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif /* NULL */
+
+#ifndef EOF
+#define EOF (-1)
+#endif
+
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+
+#ifndef TMP_MAX
+#define TMP_MAX 17576 /* 26 * 26 * 26 */
+#endif
+
+#define BUFSIZ 1024 /* default buffer size */
+
+
+#define _IOEOF 0020 /* EOF reached on read */
+#define _IOERR 0040 /* I/O error from system */
+
+#define _IOREAD 0001 /* currently reading */
+#define _IOWRT 0002 /* currently writing */
+#define _IORW 0200 /* opened for reading and writing */
+#define _IOMYBUF 0010 /* stdio malloc()'d buffer */
+
+#define _SBFSIZ 8
+
+#define L_cuserid 9
+
+/* Non name space polluting version of above */
+#define _P_tmpdir "/usr/tmp/"
+
+#ifndef _VA_LIST
+#define _VA_LIST char *
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#pragma pack()
+
+#endif /* ___STDIO_H */
+#endif
diff --git a/mit-pthreads/machdep/i386-sco-3.2v5/__stdlib.h b/mit-pthreads/machdep/i386-sco-3.2v5/__stdlib.h
new file mode 100755
index 00000000000..db6a8a56151
--- /dev/null
+++ b/mit-pthreads/machdep/i386-sco-3.2v5/__stdlib.h
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 1984-1995 The Santa Cruz Operation, Inc.
+ * All Rights Reserved.
+ *
+ * The information in this file is provided for the exclusive use of
+ * the licensees of The Santa Cruz Operation, Inc. Such users have the
+ * right to use, modify, and incorporate this code into other products
+ * for purposes authorized by the license agreement provided they include
+ * this notice and the associated copyright notice with any such product.
+ * The information in this file is provided "AS IS" without warranty.
+ */
+
+/* Portions Copyright (c) 1990, 1991, 1992, 1993 UNIX System Laboratories, Inc. */
+/* Portions Copyright (c) 1979 - 1990 AT&T */
+/* All Rights Reserved */
+
+/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
+/* UNIX System Laboratories, Inc. */
+/* The copyright notice above does not evidence any */
+/* actual or intended publication of such source code. */
+
+#ifndef ___STDLIB_H
+#define ___STDLIB_H
+
+#pragma comment(exestr, "posix @(#) stdlib.h 20.1 94/12/04 ")
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma pack(4)
+
+#ifndef _DIV_T
+#define _DIV_T
+typedef struct
+{
+ int quot;
+ int rem;
+} div_t;
+#endif
+
+#ifndef _LDIV_T
+#define _LDIV_T
+typedef struct
+{
+ long quot;
+ long rem;
+} ldiv_t;
+#endif
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef unsigned int size_t;
+#endif
+
+#if !defined(_SSIZE_T)
+#define _SSIZE_T
+typedef int ssize_t;
+#endif
+
+#ifndef _WCHAR_T
+#define _WCHAR_T
+typedef long wchar_t;
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif /* NULL */
+
+#define EXIT_FAILURE 1
+#define EXIT_SUCCESS 0
+#define RAND_MAX 077777
+
+
+
+extern unsigned char __ctype[];
+
+#define MB_CUR_MAX ((int)__ctype[520])
+
+extern double atof(const char *);
+extern int atoi(const char *);
+extern long atol(const char *);
+extern double strtod(const char *, char **);
+extern float strtof(const char *, char **);
+extern long strtol(const char *, char **, int);
+extern unsigned long strtoul(const char *, char **, int);
+
+extern int rand(void);
+extern void srand(unsigned int);
+
+extern void *calloc(size_t, size_t);
+extern void free(void *);
+extern void *malloc(size_t);
+extern void *realloc(void *, size_t);
+
+extern void abort(void);
+extern void exit(int);
+extern char *getenv(const char *);
+extern int system(const char *);
+
+extern void *bsearch(const void *, const void *, size_t, size_t,
+ int (*)(const void *, const void *));
+extern void qsort(void *, size_t, size_t,
+ int (*)(const void *, const void *));
+
+#ifdef __cplusplus
+#ifndef _ABS_INL
+#define _ABS_INL
+inline int (abs)(int i) {return (i > 0) ? i : -i;}
+#endif
+#else
+extern int (abs)(int); /* Protect from macro definitions */
+#endif
+
+extern div_t div(int, int);
+extern long labs(long);
+extern ldiv_t ldiv(long, long);
+
+extern int mbtowc(wchar_t *, const char *, size_t);
+extern int mblen(const char *, size_t);
+extern int wctomb(char *, wchar_t);
+
+extern size_t mbstowcs(wchar_t *, const char *, size_t);
+extern size_t wcstombs(char *, const wchar_t *, size_t);
+
+
+
+
+#define mblen(s, n) mbtowc((wchar_t *)0, s, n)
+
+#ifdef __cplusplus
+}
+#endif
+
+#pragma pack()
+
+#endif /* ___STDLIB_H */
diff --git a/mit-pthreads/machdep/i386-sco-3.2v5/__string.h b/mit-pthreads/machdep/i386-sco-3.2v5/__string.h
new file mode 100755
index 00000000000..e4bb93afe5a
--- /dev/null
+++ b/mit-pthreads/machdep/i386-sco-3.2v5/__string.h
@@ -0,0 +1,125 @@
+/* Copyright 1994-1995 The Santa Cruz Operation, Inc. All Rights Reserved. */
+
+
+#if defined(_NO_PROTOTYPE) /* Old, crufty environment */
+#include <oldstyle/string.h>
+#elif defined(_XOPEN_SOURCE) || defined(_XPG4_VERS) /* Xpg4 environment */
+#include <xpg4/string.h>
+#elif defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) /* Posix environment */
+#include <posix/string.h>
+#elif _STRICT_ANSI /* Pure Ansi/ISO environment */
+#include <ansi/string.h>
+#elif defined(_SCO_ODS_30) /* Old, Tbird compatible environment */
+#include <ods_30_compat/string.h>
+#else /* Normal, default environment */
+/*
+ * Portions Copyright (C) 1983-1995 The Santa Cruz Operation, Inc.
+ * All Rights Reserved.
+ *
+ * The information in this file is provided for the exclusive use of
+ * the licensees of The Santa Cruz Operation, Inc. Such users have the
+ * right to use, modify, and incorporate this code into other products
+ * for purposes authorized by the license agreement provided they include
+ * this notice and the associated copyright notice with any such product.
+ * The information in this file is provided "AS IS" without warranty.
+ */
+
+/* Portions Copyright (c) 1990, 1991, 1992, 1993 UNIX System Laboratories, Inc. */
+/* Portions Copyright (c) 1979 - 1990 AT&T */
+/* All Rights Reserved */
+
+/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
+/* UNIX System Laboratories, Inc. */
+/* The copyright notice above does not evidence any */
+/* actual or intended publication of such source code. */
+
+#ifndef ___STRING_H
+#define ___STRING_H
+
+#pragma comment(exestr, "xpg4plus @(#) string.h 20.1 94/12/04 ")
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef unsigned int size_t;
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif /* NULL */
+
+
+
+extern void *memchr(const void *, int, size_t);
+extern void *memcpy(void *, const void *, size_t);
+extern void *memccpy(void *, const void *, int, size_t);
+extern void *memmove(void *, const void *, size_t);
+extern void *memset(void *, int, size_t);
+
+extern char *strchr(const char *, int);
+extern char *strcpy(char *, const char *);
+extern char *strncpy(char *, const char *, size_t);
+extern char *strcat(char *, const char *);
+extern char *strncat(char *, const char *, size_t);
+extern char *strpbrk(const char *, const char *);
+extern char *strrchr(const char *, int);
+extern char *strstr(const char *, const char *);
+extern char *strtok(char *, const char *);
+extern char *strtok_r(char *, const char *, char **);
+extern char *strerror(int);
+extern char *strlist(char *, const char *, ...);
+
+extern int memcmp(const void *, const void *, size_t);
+extern int strcmp(const char *, const char *);
+extern int strcoll(const char *, const char *);
+extern int strncmp(const char *, const char *, size_t);
+
+extern void perror(const char *);
+extern char *strdup(const char *);
+extern int strncoll(const char *, const char *, int);
+extern size_t strnxfrm(char *, const char *, size_t , int);
+
+extern size_t strxfrm(char *, const char *, size_t);
+extern size_t strcspn(const char *, const char *);
+extern size_t strspn(const char *, const char *);
+extern size_t strlen(const char *);
+
+#ifdef __USLC__
+#pragma int_to_unsigned strcspn
+#pragma int_to_unsigned strspn
+#pragma int_to_unsigned strlen
+#endif
+
+#if !defined(__cplusplus) && defined(__USLC__)
+/* Use intrinsic ??? */
+#ifndef strlen
+#define strlen __std_hdr_strlen
+#endif
+#ifndef strcpy
+#define strcpy __std_hdr_strcpy
+#endif
+#ifndef strncpy
+#define strncpy __std_hdr_strncpy
+#endif
+#endif
+
+
+extern int ffs(int);
+/*
+ * The following two functions were withdrawn in XPG3,
+ * but are provided for backwards compatibility.
+ */
+extern int nl_strcmp(char *, char *);
+extern int nl_strncmp(char *, char *, int n);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ___STRING_H */
+#endif
diff --git a/mit-pthreads/machdep/i386-sco-3.2v5/__time.h b/mit-pthreads/machdep/i386-sco-3.2v5/__time.h
new file mode 100755
index 00000000000..4aeee737601
--- /dev/null
+++ b/mit-pthreads/machdep/i386-sco-3.2v5/__time.h
@@ -0,0 +1,141 @@
+/* Copyright 1994-1995 The Santa Cruz Operation, Inc. All Rights Reserved. */
+
+
+#if defined(_NO_PROTOTYPE) /* Old, crufty environment */
+#include <oldstyle/time.h>
+#elif defined(_XOPEN_SOURCE) || defined(_XPG4_VERS) /* Xpg4 environment */
+#include <xpg4/time.h>
+#elif defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) /* Posix environment */
+#include <posix/time.h>
+#elif _STRICT_ANSI /* Pure Ansi/ISO environment */
+#include <ansi/time.h>
+#elif defined(_SCO_ODS_30) /* Old, Tbird compatible environment */
+#include <ods_30_compat/time.h>
+#else /* Normal, default environment */
+/*
+ * Portions Copyright (C) 1983-1995 The Santa Cruz Operation, Inc.
+ * All Rights Reserved.
+ *
+ * The information in this file is provided for the exclusive use of
+ * the licensees of The Santa Cruz Operation, Inc. Such users have the
+ * right to use, modify, and incorporate this code into other products
+ * for purposes authorized by the license agreement provided they include
+ * this notice and the associated copyright notice with any such product.
+ * The information in this file is provided "AS IS" without warranty.
+ */
+
+/* Portions Copyright (c) 1990, 1991, 1992, 1993 UNIX System Laboratories, Inc. */
+/* Portions Copyright (c) 1979 - 1990 AT&T */
+/* All Rights Reserved */
+
+/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
+/* UNIX System Laboratories, Inc. */
+/* The copyright notice above does not evidence any */
+/* actual or intended publication of such source code. */
+
+#ifndef ___TIME_H
+#define ___TIME_H
+
+#pragma comment(exestr, "xpg4plus @(#) time.h 20.2 95/01/04 ")
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif /* NULL */
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef unsigned int size_t;
+#endif
+#ifndef _CLOCK_T
+#define _CLOCK_T
+typedef long clock_t;
+#endif
+#ifndef _TIME_T
+#define _TIME_T
+typedef long time_t;
+#endif
+
+#ifdef _POSIXTIMERS
+#include <sys/sudstime.h>
+#endif
+
+#define CLOCKS_PER_SEC 1000000 /* As required by XPG4 and friends */
+
+#pragma pack(4)
+
+#ifndef _STRUCT_TM
+#define _STRUCT_TM
+struct tm
+{
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+#define LTZNMAX 50
+ long tm_tzadj;
+ char tm_name[LTZNMAX]; /* name of timezone */
+};
+
+#pragma pack()
+#endif /* _STRUCT_TM */
+
+
+extern clock_t clock(void);
+extern double difftime(time_t, time_t);
+extern time_t mktime(struct tm *);
+extern time_t time(time_t *);
+extern char *asctime(const struct tm *);
+extern char *ctime (const time_t *);
+extern struct tm *gmtime(const time_t *);
+extern struct tm *localtime(const time_t *);
+extern size_t strftime(char *, size_t, const char *, const struct tm *);
+
+
+extern void tzset(void);
+extern char *tzname[];
+
+#ifndef CLK_TCK
+#define CLK_TCK _sysconf(2) /* 2 is _SC_CLK_TCK */
+#endif
+
+extern long timezone;
+extern int daylight;
+extern char *strptime(const char *, const char *, struct tm *);
+
+
+
+
+#include <sys/timeb.h>
+extern int ftime ( struct timeb * );
+extern char * nl_cxtime( long *, char * );
+extern char * nl_ascxtime( struct tm *, char * );
+extern int cftime(char *, const char *, const time_t *);
+extern int ascftime(char *, const char *, const struct tm *);
+extern long altzone;
+extern struct tm *getdate(const char *);
+extern int getdate_err;
+extern char *asctime_r(const struct tm *, char *,int);
+extern char *ctime_r(const time_t *, char *,int);
+extern struct tm *localtime_r(const time_t *, struct tm *);
+extern struct tm *gmtime_r(const time_t *, struct tm *);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifndef difftime
+#define difftime(t1, t0) ((double)((t1) - (t0)))
+#endif
+
+#endif /* ___TIME_H */
+#endif
diff --git a/mit-pthreads/machdep/i386-sco-3.2v5/__unistd.h b/mit-pthreads/machdep/i386-sco-3.2v5/__unistd.h
new file mode 100755
index 00000000000..408886301f5
--- /dev/null
+++ b/mit-pthreads/machdep/i386-sco-3.2v5/__unistd.h
@@ -0,0 +1,48 @@
+/*-
+ * 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
+ * __unistd.h,v 1.1 1995/01/03 12:54:54 proven Exp
+ */
+
+#ifndef ___UNISTD_H_
+#define ___UNISTD_H_
+
+#include <sys/types.h>
+#include <stddef.h>
+
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 1024
+#endif
+
+#endif
+
diff --git a/mit-pthreads/machdep/i386-sco-3.2v5/compat.h b/mit-pthreads/machdep/i386-sco-3.2v5/compat.h
new file mode 100755
index 00000000000..3befbffa68d
--- /dev/null
+++ b/mit-pthreads/machdep/i386-sco-3.2v5/compat.h
@@ -0,0 +1,46 @@
+/* ==== 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.
+ *
+ * compat.h,v 1.52 1995/10/20 09:32:56 proven Exp
+ *
+ * Description : Basic timers header.
+ *
+ * 1.00 94/06/13 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS_COMPAT_H_
+#define _SYS_COMPAT_H_
+
+#include <sys/types.h>
+
+#define omsghdr msghdr
+#endif
diff --git a/mit-pthreads/machdep/i386-sco-3.2v5/dirent.h b/mit-pthreads/machdep/i386-sco-3.2v5/dirent.h
new file mode 100755
index 00000000000..6f6804590bb
--- /dev/null
+++ b/mit-pthreads/machdep/i386-sco-3.2v5/dirent.h
@@ -0,0 +1,145 @@
+/* Copyright 1994-1995 The Santa Cruz Operation, Inc. All Rights Reserved. */
+
+
+#if defined(_NO_PROTOTYPE) /* Old, crufty environment */
+#include <oldstyle/dirent.h>
+#elif defined(_XOPEN_SOURCE) || defined(_XPG4_VERS) /* Xpg4 environment */
+#include <xpg4/dirent.h>
+#elif defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) /* Posix environment */
+#include <posix/dirent.h>
+#elif defined(_SCO_ODS_30) /* Old, Tbird compatible environment */
+#include <ods_30_compat/dirent.h>
+#else /* Normal, default environment */
+/*
+ * Portions Copyright (C) 1983-1995 The Santa Cruz Operation, Inc.
+ * All Rights Reserved.
+ *
+ * The information in this file is provided for the exclusive use of
+ * the licensees of The Santa Cruz Operation, Inc. Such users have the
+ * right to use, modify, and incorporate this code into other products
+ * for purposes authorized by the license agreement provided they include
+ * this notice and the associated copyright notice with any such product.
+ * The information in this file is provided "AS IS" without warranty.
+ */
+
+/* Portions Copyright (c) 1990, 1991, 1992, 1993 UNIX System Laboratories, Inc. */
+/* Portions Copyright (c) 1979 - 1990 AT&T */
+/* All Rights Reserved */
+
+/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
+/* UNIX System Laboratories, Inc. */
+/* The copyright notice above does not evidence any */
+/* actual or intended publication of such source code. */
+
+#ifndef _DIRENT_H
+#define _DIRENT_H
+
+#pragma comment(exestr, "xpg4plus @(#) dirent.h 20.1 94/12/04 ")
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma pack(4)
+
+#define MAXNAMLEN 512 /* maximum filename length */
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 1024
+#endif
+#undef DIRBLKSIZ
+#define DIRBLKSIZ 1048 /* buffer size for fs-indep. dirs */
+
+#ifndef _SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#ifndef _SYS_DIRENT_H
+#define _SYS_DIRENT_H
+#ifdef __STDC__
+#pragma comment(exestr, "@(#) dirent.h 25.8 94/09/22 ")
+#else
+#ident "@(#) dirent.h 25.8 94/09/22 "
+#endif
+/*
+ * Copyright (C) 1988-1994 The Santa Cruz Operation, Inc.
+ * All Rights Reserved.
+ * The information in this file is provided for the exclusive use of
+ * the licensees of The Santa Cruz Operation, Inc. Such users have the
+ * right to use, modify, and incorporate this code into other products
+ * for purposes authorized by the license agreement provided they include
+ * this notice and the associated copyright notice with any such product.
+ * The information in this file is provided "AS IS" without warranty.
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988 AT&T */
+/* All Rights Reserved */
+
+/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */
+/* The copyright notice above does not evidence any */
+/* actual or intended publication of such source code. */
+
+/* #ident "@)#(head.sys:dirent.h 1.3" */
+
+/*
+ * The following structure defines the file
+ * system independent directory entry.
+ *
+ */
+
+#include <sys/types.h>
+
+#ifdef _M_I386
+#pragma pack(4)
+#else
+#pragma pack(2)
+#endif
+
+#ifdef _INKERNEL
+/*
+ * dirent used by the kernel
+ */
+struct dirent {
+ ino32_t d_ino; /* inode number of entry */
+ off_t d_off; /* offset of disk directory entry */
+ unsigned short d_reclen; /* length of this record */
+ char d_name[MAXNAMLEN+1]; /* name of file */
+};
+
+#else /* !_INKERNEL */
+/*
+ * dirent as used by application code
+ * For now leave the declaration as is. When the new development system
+ * is implemented, ino_t may be ushort or ulong. If ino_t is ulong, there
+ * will be no d_pad field.
+ */
+struct dirent /* data from readdir() */
+ {
+#if defined(_IBCS2)
+ long d_ino;
+#else /* !_IBCS2 */
+ ino_t d_ino; /* inode number of entry */
+#if defined(_INO_16_T)
+ short d_pad; /* because ino_t is ushort */
+#endif /* defined(_INO_16_T) */
+#endif /* defined(_IBCS2) */
+ off_t d_off; /* offset of disk directory entry */
+ unsigned short d_reclen; /* length of this record */
+ char d_name[MAXNAMLEN+1]; /* name of file */
+ };
+#endif /* _INKERNEL */
+
+typedef struct dirent dirent_t;
+
+#pragma pack()
+#endif /* _SYS_DIRENT_H */
+
+#define d_fileno d_ino
+#define d_namlen d_reclen
+
+#ifdef __cplusplus
+}
+#endif
+
+#pragma pack()
+
+#endif /* _DIRENT_H */
+#endif
diff --git a/mit-pthreads/machdep/i386-sco-3.2v5/posix/__signal.h b/mit-pthreads/machdep/i386-sco-3.2v5/posix/__signal.h
new file mode 100755
index 00000000000..5680fc1491a
--- /dev/null
+++ b/mit-pthreads/machdep/i386-sco-3.2v5/posix/__signal.h
@@ -0,0 +1,69 @@
+/*
+ * Portions Copyright (C) 1983-1995 The Santa Cruz Operation, Inc.
+ * All Rights Reserved.
+ *
+ * The information in this file is provided for the exclusive use of
+ * the licensees of The Santa Cruz Operation, Inc. Such users have the
+ * right to use, modify, and incorporate this code into other products
+ * for purposes authorized by the license agreement provided they include
+ * this notice and the associated copyright notice with any such product.
+ * The information in this file is provided "AS IS" without warranty.
+ */
+
+/* Portions Copyright (c) 1990, 1991, 1992, 1993 UNIX System Laboratories, Inc. */
+/* Portions Copyright (c) 1979 - 1990 AT&T */
+/* All Rights Reserved */
+
+/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
+/* UNIX System Laboratories, Inc. */
+/* The copyright notice above does not evidence any */
+/* actual or intended publication of such source code. */
+
+#ifndef ___SIGNAL_H
+#define ___SIGNAL_H
+
+#pragma comment(exestr, "posix @(#) signal.h 20.3 94/12/19 ")
+
+#ifndef _SIG_ATOMIC_T
+#define _SIG_ATOMIC_T
+ /* atomic entity for signal handling */
+typedef int sig_atomic_t;
+#endif
+
+
+#ifndef _SYS_SIGNAL_H
+#include <sys/signal.h>
+#endif
+
+#if !defined(_SYS_TYPES_H)
+#include <sys/types.h>
+#endif
+
+
+#if __cplusplus
+extern "C" {
+#endif
+
+extern void (*signal(int, void(*)(int)))(int);
+extern int raise(int);
+
+
+
+extern int (sigfillset)(sigset_t *);
+extern int (sigemptyset)(sigset_t *);
+extern int (sigaddset)(sigset_t *, int);
+extern int (sigdelset)(sigset_t *, int);
+extern int (sigismember)(const sigset_t *, int);
+extern int sigpending(sigset_t *);
+extern int sigsuspend(const sigset_t *);
+extern int sigprocmask(int, const sigset_t *, sigset_t *);
+extern int kill(pid_t, int);
+extern int sigaction(int, const struct sigaction *, struct sigaction *);
+
+#if __cplusplus
+};
+#endif
+
+
+#endif /* ___SIGNAL_H */
+
diff --git a/mit-pthreads/machdep/i386-sco-3.2v5/socket.h b/mit-pthreads/machdep/i386-sco-3.2v5/socket.h
new file mode 100755
index 00000000000..4a53c7176f9
--- /dev/null
+++ b/mit-pthreads/machdep/i386-sco-3.2v5/socket.h
@@ -0,0 +1,490 @@
+/* @(#)socket.h 6.23 7/18/94 - STREAMware TCP/IP source */
+/*
+ * Copyrighted as an unpublished work.
+ * (c) Copyright 1987-1994 Legent Corporation
+ * All rights reserved.
+ *
+ * RESTRICTED RIGHTS
+ *
+ * These programs are supplied under a license. They may be used,
+ * disclosed, and/or copied only as permitted under such license
+ * agreement. Any copy must contain the above copyright notice and
+ * this restricted rights notice. Use, copying, and/or disclosure
+ * of the programs is strictly prohibited unless otherwise provided
+ * in the license agreement.
+ *
+ */
+/* SCCS IDENTIFICATION */
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, 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'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef __sys_socket_h
+#define __sys_socket_h
+
+#if !defined(FD_SETSIZE)
+/* Pick up select stuff from standard system include */
+#include <sys/types.h>
+#endif
+
+/* socket.h 6.1 83/07/29 */
+
+/*
+ * Definitions related to sockets: types, address families, options.
+ */
+
+/*
+ * Types
+ */
+#define SOCK_STREAM 1 /* stream socket */
+#define SOCK_DGRAM 2 /* datagram socket */
+#define SOCK_RAW 3 /* raw-protocol interface */
+#define SOCK_RDM 4 /* reliably-delivered message */
+#define SOCK_SEQPACKET 5 /* sequenced packet stream */
+
+/*
+ * Option flags per-socket.
+ */
+#define SO_DEBUG 0x0001 /* turn on debugging info recording */
+#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
+#define SO_REUSEADDR 0x0004 /* allow local address reuse */
+#define SO_KEEPALIVE 0x0008 /* keep connections alive */
+#define SO_DONTROUTE 0x0010 /* just use interface addresses */
+#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
+#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
+#define SO_LINGER 0x0080 /* linger on close if data present */
+#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
+#define SO_ORDREL 0x0200 /* give use orderly release */
+#define SO_IMASOCKET 0x0400 /* use socket semantics (affects bind) */
+#define SO_MGMT 0x0800 /* => it is used for mgmt. purposes */
+#define SO_REUSEPORT 0x1000 /* allow local port reuse */
+
+/*
+ * Additional options, not kept in so_options.
+ */
+#define SO_SNDBUF 0x1001 /* send buffer size */
+#define SO_RCVBUF 0x1002 /* receive buffer size */
+#define SO_SNDLOWAT 0x1003 /* send low-water mark */
+#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
+#define SO_SNDTIMEO 0x1005 /* send timeout */
+#define SO_RCVTIMEO 0x1006 /* receive timeout */
+#define SO_ERROR 0x1007 /* get error status and clear */
+#define SO_TYPE 0x1008 /* get socket type */
+#define SO_PROTOTYPE 0x1009 /* get/set protocol type */
+
+/*
+ * Structure used for manipulating linger option.
+ */
+struct linger {
+ int l_onoff; /* option on/off */
+ int l_linger; /* linger time */
+};
+
+/*
+ * Level number for (get/set)sockopt() to apply to socket itself.
+ */
+#define SOL_SOCKET 0xffff /* options for socket level */
+
+/*
+ * An option specification consists of an opthdr, followed by the value of
+ * the option. An options buffer contains one or more options. The len
+ * field of opthdr specifies the length of the option value in bytes. This
+ * length must be a multiple of sizeof(long) (use OPTLEN macro).
+ */
+
+struct opthdr {
+ long level; /* protocol level affected */
+ long name; /* option to modify */
+ long len; /* length of option value */
+};
+
+#define OPTLEN(x) ((((x) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
+#define OPTVAL(opt) ((char *)(opt + 1))
+
+#if defined(INKERNEL) || defined(_KERNEL) || defined(_INKERNEL)
+/*
+ * the optdefault structure is used for internal tables of option default
+ * values.
+ */
+struct optdefault {
+ int optname;/* the option */
+ char *val; /* ptr to default value */
+ int len; /* length of value */
+};
+
+/*
+ * the opproc structure is used to build tables of options processing
+ * functions for in_dooptions().
+ */
+struct opproc {
+ int level; /* options level this function handles */
+ int (*func) (); /* the function */
+};
+#endif
+
+/*
+ * Address families.
+ */
+#define AF_UNSPEC 0 /* unspecified */
+#define AF_UNIX 1 /* local to host (pipes, portals) */
+#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
+#define AF_IMPLINK 3 /* arpanet imp addresses */
+#define AF_PUP 4 /* pup protocols: e.g. BSP */
+#define AF_CHAOS 5 /* mit CHAOS protocols */
+#define AF_NS 6 /* XEROX NS protocols */
+#define AF_ISO 7 /* ISO protocols */
+#define AF_OSI AF_ISO
+#define AF_ECMA 8 /* european computer manufacturers */
+#define AF_DATAKIT 9 /* datakit protocols */
+#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
+#define AF_SNA 11 /* IBM SNA */
+#define AF_DECnet 12 /* DECnet */
+#define AF_DLI 13 /* Direct data link interface */
+#define AF_LAT 14 /* LAT */
+#define AF_HYLINK 15 /* NSC Hyperchannel */
+#define AF_APPLETALK 16 /* Apple Talk */
+#define AF_ROUTE 17 /* Internal Routing Protocol */
+#define AF_LINK 18 /* Link layer interface */
+#define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */
+
+#define AF_MAX 20
+
+/*
+ * Structure used by kernel to store most addresses.
+ */
+struct sockaddr {
+ u_short sa_family; /* address family */
+ char sa_data[14]; /* up to 14 bytes of direct address */
+};
+
+/*
+ * Structure used by kernel to pass protocol information in raw sockets.
+ */
+struct sockproto {
+ unsigned short sp_family; /* address family */
+ unsigned short sp_protocol; /* protocol */
+};
+
+/*
+ * Protocol families, same as address families for now.
+ */
+#define PF_UNSPEC AF_UNSPEC
+#define PF_UNIX AF_UNIX
+#define PF_INET AF_INET
+#define PF_IMPLINK AF_IMPLINK
+#define PF_PUP AF_PUP
+#define PF_CHAOS AF_CHAOS
+#define PF_NS AF_NS
+#define PF_NBS AF_NBS
+#define PF_ECMA AF_ECMA
+#define PF_DATAKIT AF_DATAKIT
+#define PF_CCITT AF_CCITT
+#define PF_SNA AF_SNA
+#define PF_DECnet AF_DECnet
+#define PF_DLI AF_DLI
+#define PF_LAT AF_LAT
+#define PF_HYLINK AF_HYLINK
+#define PF_APPLETALK AF_APPLETALK
+#define PF_ROUTE AF_ROUTE
+#define PF_LINK AF_LINK
+#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */
+
+#define PF_MAX AF_MAX
+
+/*
+ * Maximum queue length specifiable by listen.
+ */
+#define SOMAXCONN 5
+
+/*
+ * Message header for recvmsg and sendmsg calls.
+ * Used value-result for recmvsg, value only for sendmsg.
+ */
+struct msghdr {
+ caddr_t msg_name; /* optional address */
+ u_int msg_namelen; /* size of address */
+ struct iovec *msg_iov; /* scatter/gather array */
+ u_int msg_iovlen; /* # elements msg_iov */
+ caddr_t msg_control; /* ancillary data, see below */
+ u_int msg_controllen; /* ancillary data buffer len */
+ int msg_flags; /* flags on received message */
+};
+#define msg_accrights msg_control
+#define msg_accrightslen msg_controllen
+
+#define MSG_OOB 0x1 /* process out-of-band data */
+#define MSG_PEEK 0x2 /* peek at incoming message */
+#define MSG_DONTROUTE 0x4 /* send without using routing tables */
+#define MSG_EOR 0x8 /* data completes record */ /*notused*/
+#define MSG_TRUNC 0x10 /* data discarded before delivery */
+#define MSG_CTRUNC 0x20 /* control data lost before delivery */
+#define MSG_WAITALL 0x40 /* wait for full request or error */ /*notused*/
+
+#define MSG_MAXIOVLEN 16
+
+/*
+ * Header for ancillary data objects in msg_control buffer.
+ * Used for additional information with/about a datagram
+ * not expressible by flags. The format is a sequence
+ * of message elements headed by cmsghdr structures.
+ * In STREAMware, we shuffle the fields around a little from what
+ * they were in net-2, so that they line up the same as an opthdr
+ * which simplifies our socket implementation amazingly.
+ *
+ * Unfortunately, the opthdrs don't include their own length, which the
+ * cmsghdrs do. What this means is that TLI programmers will not be
+ * able to take something returned using these macros and immediately give
+ * it back to the stack. The size of the struct cmsghdr will have to be
+ * subtracted out.
+ * There doesn't seem to be a way to avoid this, since several applications
+ * look into the cmsg_len field and won't work if it doesn't include the size
+ * of the struct cmsghdr.
+ */
+struct cmsghdr {
+ int cmsg_level; /* originating protocol */
+ int cmsg_type; /* protocol-specific type */
+ u_int cmsg_len; /* data byte count, including hdr */
+/* followed by u_char cmsg_data[]; */
+};
+
+/* given pointer to struct adatahdr, return pointer to data */
+#define CMSG_DATA(cmsg) ((u_char *)((cmsg) + 1))
+
+/* given pointer to struct adatahdr, return pointer to next adatahdr */
+#define CMSG_NXTHDR(mhdr, cmsg) \
+ (((caddr_t)(cmsg) + (cmsg)->cmsg_len + sizeof(struct cmsghdr) > \
+ (mhdr)->msg_control + (mhdr)->msg_controllen) ? \
+ (struct cmsghdr *)NULL : \
+ (struct cmsghdr *)((caddr_t)(cmsg) + OPTLEN((cmsg)->cmsg_len)))
+
+#define CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control)
+
+/* "Socket"-level control message types: */
+#define SCM_RIGHTS 0x01 /* access rights (array of int) */
+
+/*
+ * This ioctl code uses BSD style ioctls to avoid copyin/out problems.
+ * Ioctls have the command encoded in the lower word, and the size of any in
+ * or out parameters in the upper word. The high 2 bits of the upper word
+ * are used to encode the in/out status of the parameter; for now we restrict
+ * parameters to at most 128 bytes.
+ */
+#define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */
+#define IOC_VOID 0x20000000 /* no parameters */
+#define IOC_OUT 0x40000000 /* copy out parameters */
+#define IOC_IN 0x80000000 /* copy in parameters */
+#define IOC_INOUT (IOC_IN|IOC_OUT)
+/* the 0x20000000 is so we can distinguish new ioctls from old */
+#define _IOS(x,y) (IOC_VOID|(x<<8)|y)
+#define _IOSR(x,y,t) (IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
+#define _IOSW(x,y,t) (IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
+/* this should be _IOSRW, but stdio got there first */
+#define _IOSWR(x,y,t) (IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
+
+/*
+ * Socket ioctl commands
+ */
+
+#define SIOCSHIWAT _IOSW('S', 1, int) /* set high watermark */
+#define SIOCGHIWAT _IOSR('S', 2, int) /* get high watermark */
+#define SIOCSLOWAT _IOSW('S', 3, int) /* set low watermark */
+#define SIOCGLOWAT _IOSR('S', 4, int) /* get low watermark */
+#define SIOCATMARK _IOSR('S', 5, int) /* at oob mark? */
+#define SIOCSPGRP _IOSW('S', 6, int) /* set process group */
+#define SIOCGPGRP _IOSR('S', 7, int) /* get process group */
+#define FIONREAD _IOSR('S', 8, int) /* BSD compatibilty */
+#define FIONBIO _IOSW('S', 9, int) /* BSD compatibilty */
+#define FIOASYNC _IOSW('S', 10, int) /* BSD compatibilty */
+#define SIOCPROTO _IOSW('S', 11, struct socknewproto) /* link proto */
+#define SIOCGETNAME _IOSR('S', 12, struct sockaddr) /* getsockname */
+#define SIOCGETPEER _IOSR('S', 13, struct sockaddr) /* getpeername */
+#define IF_UNITSEL _IOSW('S', 14, int) /* set unit number */
+#define SIOCXPROTO _IOS('S', 15) /* empty proto table */
+#define SIOCSHRDTYPE _IOSW('S', 16, int) /* set hardware type */
+
+#define SIOCADDRT _IOSW('R', 9, struct ortentry) /* add route */
+#define SIOCDELRT _IOSW('R', 10, struct ortentry) /* delete route */
+
+#define SIOCSIFADDR _IOSW('I', 11, struct ifreq) /* set ifnet address */
+#define SIOCGIFADDR _IOSWR('I', 12, struct ifreq) /* get ifnet address */
+#define SIOCSIFDSTADDR _IOSW('I', 13, struct ifreq) /* set p-p address */
+#define SIOCGIFDSTADDR _IOSWR('I', 14, struct ifreq) /* get p-p address */
+#define SIOCSIFFLAGS _IOSW('I', 15, struct ifreq) /* set ifnet flags */
+#define SIOCGIFFLAGS _IOSWR('I', 16, struct ifreq) /* get ifnet flags */
+#define SIOCGIFCONF _IOSWR('I', 17, struct ifconf) /* get ifnet list */
+
+#define SIOCSIFMTU _IOSW('I', 21, struct ifreq) /* get if_mtu */
+#define SIOCGIFMTU _IOSWR('I', 22, struct ifreq) /* set if_mtu */
+
+
+#define SIOCGIFBRDADDR _IOSWR('I', 32, struct ifreq) /* get broadcast addr */
+#define SIOCSIFBRDADDR _IOSW('I', 33, struct ifreq) /* set broadcast addr */
+#define SIOCGIFNETMASK _IOSWR('I', 34, struct ifreq) /* get net addr mask */
+#define SIOCSIFNETMASK _IOSW('I', 35, struct ifreq) /* set net addr mask */
+#define SIOCGIFMETRIC _IOSWR('I', 36, struct ifreq) /* get IF metric */
+#define SIOCSIFMETRIC _IOSW('I', 37, struct ifreq) /* set IF metric */
+
+#define SIOCSARP _IOSW('I', 38, struct arpreq) /* set arp entry */
+#define SIOCGARP _IOSWR('I', 39, struct arpreq) /* get arp entry */
+#define SIOCDARP _IOSW('I', 40, struct arpreq) /* delete arp entry */
+
+#define SIOCSIFNAME _IOSW('I', 41, struct ifreq) /* set interface name */
+#define SIOCGIFONEP _IOSWR('I', 42, struct ifreq) /* get one-packet params */
+#define SIOCSIFONEP _IOSW('I', 43, struct ifreq) /* set one-packet params */
+#define SIOCDIFADDR _IOSW('I', 44, struct ifreq) /* delete IF addr */
+#define SIOCAIFADDR _IOSW('I', 45, struct ifaliasreq) /*add/change IF alias*/
+#define SIOCADDMULTI _IOSW('I', 49, struct ifreq) /* add m'cast addr */
+#define SIOCDELMULTI _IOSW('I', 50, struct ifreq) /* del m'cast addr */
+#define SIOCGIFALIAS _IOSWR('I', 51, struct ifaliasreq) /* get IF alias */
+
+
+#define SIOCSOCKSYS _IOSW('I', 66, struct socksysreq) /* Pseudo socket syscall */
+
+/* these use ifr_metric to pass the information */
+#define SIOCSIFDEBUG _IOSW('I', 67, struct ifreq) /* set if debug level */
+#define SIOCGIFDEBUG _IOSWR('I', 68, struct ifreq) /* get if debug level */
+
+#define SIOCSIFTYPE _IOSW('I', 69, struct ifreq) /* set if MIB type */
+#define SIOCGIFTYPE _IOSWR('I', 70, struct ifreq) /* get if MIB type */
+
+#define SIOCGIFNUM _IOSR('I', 71, int) /* get number of ifs */
+/*
+ * This returns the number of ifreqs that SIOCGIFCONF would return, including
+ * aliases. This is the preferred way of sizing a buffer big enough to hold
+ * all interfaces.
+ */
+#define SIOCGIFANUM _IOSR('I', 72, int) /* get number of ifreqs */
+/*
+ * Interface specific performance tuning
+ */
+#define SIOCGIFPERF _IOSR('I', 73, struct ifreq) /* get perf info */
+#define SIOCSIFPERF _IOSR('I', 74, struct ifreq) /* get perf info */
+
+/*
+ * This structure is used to encode pseudo system calls
+ */
+struct socksysreq {
+ /* When porting, make this the widest thing it can be */
+ int args[7];
+};
+
+/*
+ * This structure is used for adding new protocols to the list supported by
+ * sockets.
+ */
+struct socknewproto {
+ int family; /* address family (AF_INET, etc.) */
+ int type; /* protocol type (SOCK_STREAM, etc.) */
+ int proto; /* per family proto number */
+ dev_t dev; /* major/minor to use (must be a clone) */
+ int flags; /* protosw flags */
+};
+
+/*
+ * utility definitions.
+ */
+
+#ifdef MIN
+#undef MIN
+#endif
+#define MIN(x,y) ((x) < (y) ? (x) : (y))
+#ifndef MAX
+#define MAX(x,y) ((x) > (y) ? (x) : (y))
+#endif
+
+#define MAXHOSTNAMELEN 256
+
+#define NBBY 8 /* number of bits in a byte */
+
+
+/* defines for user/kernel interface */
+
+#define MAX_MINOR (makedev(1,0) - 1) /* could be non-portable */
+
+#define SOCKETSYS 140 /* SCO 3.2v5 */
+
+#define SO_ACCEPT 1
+#define SO_BIND 2
+#define SO_CONNECT 3
+#define SO_GETPEERNAME 4
+#define SO_GETSOCKNAME 5
+#define SO_GETSOCKOPT 6
+#define SO_LISTEN 7
+#define SO_RECV 8
+#define SO_RECVFROM 9
+#define SO_SEND 10
+#define SO_SENDTO 11
+#define SO_SETSOCKOPT 12
+#define SO_SHUTDOWN 13
+#define SO_SOCKET 14
+#define SO_SELECT 15
+#define SO_GETIPDOMAIN 16
+#define SO_SETIPDOMAIN 17
+#define SO_ADJTIME 18
+#define SO_SETREUID 19
+#define SO_SETREGID 20
+#define SO_GETTIME 21
+#define SO_SETTIME 22
+#define SO_GETITIMER 23
+#define SO_SETITIMER 24
+#define SO_RECVMSG 25
+#define SO_SENDMSG 26
+#define SO_SOCKPAIR 27
+
+/*
+ * message flags
+ */
+#define M_BCAST 0x80000000
+
+/* Definitions and structures used for extracting */
+/* the size and/or the contents of kernel tables */
+
+/* Copyin/out values */
+#define GIARG 0x1
+#define CONTI 0x2
+#define GITAB 0x4
+
+struct gi_arg {
+ caddr_t gi_where;
+ unsigned gi_size;
+};
+
+#if !defined(_KERNEL) && !defined(INKERNEL) && !defined(_INKERNEL)
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int accept __P_((int, struct sockaddr *, int *));
+int bind __P_((int, const struct sockaddr *, int));
+int connect __P_((int, const struct sockaddr *, int));
+int getpeername __P_((int, struct sockaddr *, int *));
+int getsockname __P_((int, struct sockaddr *, int *));
+int getsockopt __P_((int, int, int, void *, int *));
+int setsockopt __P_((int, int, int, const void *, int));
+int listen __P_((int, int));
+ssize_t recv __P_((int, void *, size_t, int));
+ssize_t recvfrom __P_((int, void *, size_t, int, struct sockaddr *, int *));
+int recvmsg __P_((int, struct msghdr *, int));
+ssize_t send __P_((int, const void *, size_t, int));
+int sendmsg __P_((int, const struct msghdr *, int));
+ssize_t sendto __P_((int, const void *, size_t, int, const struct sockaddr *, int));
+int shutdown __P_((int, int));
+int socket __P_((int, int, int));
+int socketpair __P_((int, int, int, int[2]));
+__END_DECLS
+
+#endif /* !INKERNEL */
+#endif /* __sys_socket_h */
diff --git a/mit-pthreads/machdep/i386-sco-3.2v5/syscall.h b/mit-pthreads/machdep/i386-sco-3.2v5/syscall.h
new file mode 100755
index 00000000000..f49fba81b6e
--- /dev/null
+++ b/mit-pthreads/machdep/i386-sco-3.2v5/syscall.h
@@ -0,0 +1,175 @@
+/* Copyright 1994-1995 The Santa Cruz Operation, Inc. All Rights Reserved. */
+
+
+#if defined(_NO_PROTOTYPE) /* Old, crufty environment */
+#include <oldstyle/syscall.h>
+#elif defined(_SCO_ODS_30) /* Old, Tbird compatible environment */
+#include <ods_30_compat/syscall.h>
+#else /* Normal, default environment */
+/*
+/ Portions Copyright (C) 1983-1995 The Santa Cruz Operation, Inc.
+ * All Rights Reserved.
+ *
+ * The information in this file is provided for the exclusive use of
+ * the licensees of The Santa Cruz Operation, Inc. Such users have the
+ * right to use, modify, and incorporate this code into other products
+ * for purposes authorized by the license agreement provided they include
+ * this notice and the associated copyright notice with any such product.
+ * The information in this file is provided "AS IS" without warranty.
+ */
+
+/* Portions Copyright (c) 1990, 1991, 1992, 1993 UNIX System Laboratories, Inc. */
+/* Portions Copyright (c) 1979 - 1990 AT&T */
+
+#ident "xpg4plus @(#) sys.i386 20.1 94/12/04 "
+/* #ident "xpg4plus @(#)head:sys.i386 1.2" */
+
+/*
+/* Definitions of Kernel Entry Call Gates
+*/
+
+#ifndef _SYSCALL_H_
+#define _SYSCALL_H_
+
+/*#define SYSCALL $0x7,$0*/
+/*#define SIGCALL $0xF,$0*/
+
+/*
+/* Definitions of System Call Entry Point Numbers
+*/
+
+#define SYS_access 33
+#define SYS_acct 51
+#define SYS_advfs 70
+#define SYS_alarm 27
+#define SYS_break 17
+#define SYS_brk 17
+#define SYS_chdir 12
+#define SYS_chmod 15
+#define SYS_chown 16
+#define SYS_chroot 61
+#define SYS_close 6
+#define SYS_creat 8
+#define SYS_dup 41
+#define SYS_exec 11
+#define SYS_execve 59
+#define SYS_exit 1
+#define SYS_fcntl 62
+#define SYS_fork 2
+#define SYS_fstat 28
+#define SYS_fstatfs 38
+#define SYS_fxstat 125
+#define SYS_getdents 81
+#define SYS_getgid 47
+#define SYS_getmsg 85
+#define SYS_getpid 20
+#define SYS_gettimeofday 171
+#define SYS_getuid 24
+#define SYS_gtty 32
+#define SYS_ioctl 54
+#define SYS_kill 37
+#define SYS_link 9
+#define SYS_lock 45
+#define SYS_lseek 19
+#define SYS_lstat 91
+#define SYS_lxstat 124
+#define SYS_mkdir 80
+#define SYS_mknod 14
+#define SYS_mount 21
+#define SYS_msgsys 49
+#define SYS_nice 34
+#define SYS_open 5
+#define SYS_pause 29
+#define SYS_pipe 42
+#define SYS_plock 45
+#define SYS_poll 87
+#define SYS_prof 44
+#define SYS_ptrace 26
+#define SYS_putmsg 86
+#define SYS_rdebug 76
+#define SYS_read 3
+#define SYS_readlink 92
+#define SYS_readv 121
+#define SYS_rfstart 74
+#define SYS_rfstop 77
+#define SYS_rfsys 78
+#define SYS_rmdir 79
+#define SYS_rmount 72
+#define SYS_rumount 73
+#define SYS_seek 19
+#define SYS_semsys 53
+#define SYS_setgid 46
+#define SYS_setpgrp 39
+#define SYS_settimeofday 172
+#define SYS_setuid 23
+#define SYS_shmsys 52
+#define SYS_signal 48
+#define SYS_stat 18
+#define SYS_statfs 35
+#define SYS_stime 25
+#define SYS_stty 31
+#define SYS_symlink 90
+#define SYS_sync 36
+#define SYS_sys3b 50
+#define SYS_sysi86 50
+#define SYS_sysacct 51
+#define SYS_sysfs 84
+#define SYS_time 13
+#define SYS_times 43
+#define SYS_uadmin 55
+#define SYS_ulimit 63
+#define SYS_umask 60
+#define SYS_umount 22
+#define SYS_unadvfs 71
+#define SYS_unlink 10
+#define SYS_utime 30
+#define SYS_utssys 57
+#define SYS_wait 7
+#define SYS_write 4
+#define SYS_writev 122
+#define SYS_xstat 123
+#define SYS_ftruncate 192
+
+/* cxenix numbers are created by the formula
+ * (table index << 8) + CXENIX
+ */
+
+#define CXENIX 0x28 /* Decimal 40 */
+
+#define XLOCKING 0x0128
+#define CREATSEM 0x0228
+#define OPENSEM 0x0328
+#define SIGSEM 0x0428
+#define WAITSEM 0x0528
+#define NBWAITSEM 0x0628
+#define RDCHK 0x0728
+#define CHSIZE 0x0a28
+#define SYS_ftime 0x0b28
+#define NAP 0x0c28
+#define SDGET 0x0d28
+#define SDFREE 0x0e28
+#define SDENTER 0x0f28
+#define SDLEAVE 0x1028
+#define SDGETV 0x1128
+#define SDWAITV 0x1228
+#define PROCTL 0x2028
+#define EXECSEG 0x2128
+#define UNEXECSEG 0x2228
+#define SYS_select 0x2428
+#define SYS_eaccess 0x2528
+#define SYS_paccess 0x2628
+#define SYS_sigaction 0x2728
+#define SYS_sigprocmask 0x2828
+#define SYS_sigpending 0x2928
+#define SYS_sigsuspend 0x2a28
+#define SYS_getgroups 0x2b28
+#define SYS_setgroups 0x2c28
+#define SYS_sysconf 0x2d28
+#define SYS_pathconf 0x2e28
+#define SYS_fpathconf 0x2f28
+#define SYS_rename 0x3028
+#define SYS_setitimer 0x3828
+
+#define CLOCAL 127
+#endif
+#endif
diff --git a/mit-pthreads/machdep/i386-sco-3.2v5/timers.h b/mit-pthreads/machdep/i386-sco-3.2v5/timers.h
new file mode 100755
index 00000000000..cbc48ccc8d8
--- /dev/null
+++ b/mit-pthreads/machdep/i386-sco-3.2v5/timers.h
@@ -0,0 +1,68 @@
+/* ==== 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.
+ *
+ * timers.h,v 1.50.8.1 1996/03/05 08:28:36 proven 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/types.h>
+#include <time.h>
+
+struct timespec {
+ long tv_sec;
+ long tv_nsec;
+};
+
+#define TIMEVAL_TO_TIMESPEC(tv, ts) { \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000; \
+}
+#define TIMESPEC_TO_TIMEVAL(tv, ts) { \
+ (tv)->tv_sec = (ts)->tv_sec; \
+ (tv)->tv_usec = (ts)->tv_nsec / 1000; \
+}
+
+/*
+ * New functions
+ */
+
+__BEGIN_DECLS
+
+__END_DECLS
+
+#endif
diff --git a/mit-pthreads/machdep/i386-sco-3.2v5/trash.can b/mit-pthreads/machdep/i386-sco-3.2v5/trash.can
new file mode 100755
index 00000000000..33edf65aab6
--- /dev/null
+++ b/mit-pthreads/machdep/i386-sco-3.2v5/trash.can
@@ -0,0 +1 @@
+make: *** No targets specified and no makefile found. Stop.
diff --git a/mit-pthreads/machdep/irix-5.2/__math.h b/mit-pthreads/machdep/irix-5.2/__math.h
new file mode 100755
index 00000000000..229d5121524
--- /dev/null
+++ b/mit-pthreads/machdep/irix-5.2/__math.h
@@ -0,0 +1,4 @@
+
+extern char __infinity[];
+#define HUGE_VAL (*(double *) __infinity)
+
diff --git a/mit-pthreads/machdep/irix-5.2/__signal.h b/mit-pthreads/machdep/irix-5.2/__signal.h
new file mode 100755
index 00000000000..87797da3198
--- /dev/null
+++ b/mit-pthreads/machdep/irix-5.2/__signal.h
@@ -0,0 +1,15 @@
+#include <sys/signal.h>
+
+typedef int sig_atomic_t;
+
+#ifndef sigmask
+#define sigmask(n) ((unsigned int)1 << (((n) - 1) & (32 - 1)))
+#endif
+#define sigword(n) (((unsigned int)((n) - 1))>>5)
+
+#define __SIGEMPTYSET { 0, 0, 0, 0 };
+#define __SIGFILLSET { 0xffffffff,0xffffffff,0xffffffff,0xffffffff };
+#define __SIGADDSET(s, n) ((s)->sigbits[sigword(n)] |= sigmask(n))
+#define __SIGDELSET(s, n) ((s)->sigbits[sigword(n)] &= ~sigmask(n))
+#define __SIGISMEMBER(s, n) (sigmask(n) & (s)->sigbits[sigword(n)])
+
diff --git a/mit-pthreads/machdep/irix-5.2/__stdio.h b/mit-pthreads/machdep/irix-5.2/__stdio.h
new file mode 100755
index 00000000000..bb4c14b32c6
--- /dev/null
+++ b/mit-pthreads/machdep/irix-5.2/__stdio.h
@@ -0,0 +1,6 @@
+#if !defined(_SIZE_T) && !defined(_SIZE_T_)
+#define _SIZE_T
+typedef pthread_size_t size_t;
+#endif
+
+typedef pthread_fpos_t fpos_t;
diff --git a/mit-pthreads/machdep/irix-5.2/__stdlib.h b/mit-pthreads/machdep/irix-5.2/__stdlib.h
new file mode 100755
index 00000000000..2bec122c5f1
--- /dev/null
+++ b/mit-pthreads/machdep/irix-5.2/__stdlib.h
@@ -0,0 +1,30 @@
+#include <sgidefs.h>
+
+#if !defined(_SIZE_T) && !defined(_SIZE_T_)
+#define _SIZE_T
+#if (_MIPS_SZLONG == 32)
+typedef unsigned int size_t;
+#endif
+#if (_MIPS_SZLONG == 64)
+typedef unsigned long size_t;
+#endif
+#endif
+
+#ifndef _WCHAR_T
+#define _WCHAR_T
+#if (_MIPS_SZLONG == 32)
+typedef long wchar_t;
+#endif
+#if (_MIPS_SZLONG == 64)
+typedef __int32_t wchar_t;
+#endif
+#endif
+
+#ifndef __NORETURN
+#define __NORETURN
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
diff --git a/mit-pthreads/machdep/irix-5.2/__string.h b/mit-pthreads/machdep/irix-5.2/__string.h
new file mode 100755
index 00000000000..50261e73cfc
--- /dev/null
+++ b/mit-pthreads/machdep/irix-5.2/__string.h
@@ -0,0 +1,5 @@
+#if !defined(_SIZE_T) && !defined(_SIZE_T_)
+#define _SIZE_T
+typedef pthread_size_t size_t;
+#endif
+
diff --git a/mit-pthreads/machdep/irix-5.2/__time.h b/mit-pthreads/machdep/irix-5.2/__time.h
new file mode 100755
index 00000000000..51fb993b38d
--- /dev/null
+++ b/mit-pthreads/machdep/irix-5.2/__time.h
@@ -0,0 +1,21 @@
+#if !defined(_SIZE_T) && !defined(_SIZE_T_)
+#define _SIZE_T
+typedef pthread_size_t size_t;
+#endif
+
+#ifndef _CLOCK_T
+#define _CLOCK_T
+typedef pthread_clock_t clock_t;
+#endif
+
+#ifndef _TIME_T
+#define _TIME_T
+typedef pthread_time_t time_t;
+#endif /* !_TIME_T */
+
+#define CLOCKS_PER_SEC 1000000
+
+#ifndef CLK_TCK
+#define CLK_TCK sysconf(3) /* clock ticks per second */
+ /* 3 is _SC_CLK_TCK */
+#endif
diff --git a/mit-pthreads/machdep/irix-5.2/__unistd.h b/mit-pthreads/machdep/irix-5.2/__unistd.h
new file mode 100755
index 00000000000..0d71d631a5b
--- /dev/null
+++ b/mit-pthreads/machdep/irix-5.2/__unistd.h
@@ -0,0 +1,8 @@
+#include <sys/types.h>
+#include <sys/unistd.h>
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#define ioctl_request_type int /* For fd.c */
diff --git a/mit-pthreads/machdep/irix-5.2/compat.h b/mit-pthreads/machdep/irix-5.2/compat.h
new file mode 100755
index 00000000000..8fd504e504f
--- /dev/null
+++ b/mit-pthreads/machdep/irix-5.2/compat.h
@@ -0,0 +1,45 @@
+/* ==== 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$
+ *
+ * Description :
+ *
+ * 1.00 94/06/13 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS_COMPAT_H_
+#define _SYS_COMPAT_H_
+
+#define omsghdr msghdr
+
+#endif
diff --git a/mit-pthreads/machdep/irix-5.2/dirent.h b/mit-pthreads/machdep/irix-5.2/dirent.h
new file mode 100755
index 00000000000..79fe486951d
--- /dev/null
+++ b/mit-pthreads/machdep/irix-5.2/dirent.h
@@ -0,0 +1,21 @@
+#ifndef _SYS_DIRENT_H
+#define _SYS_DIRENT_H
+
+#if !defined(_POSIX_SOURCE)
+#define MAXNAMLEN 255 /* maximum filename length */
+#define DIRBUF 4096 /* buffer size for fs-indep. dirs */
+#endif /* !defined(_POSIX_SOURCE) */
+
+#include <sys/types.h>
+
+struct dirent { /* data from readdir() */
+ ino_t d_ino; /* inode number of entry */
+ off_t d_off; /* offset of disk direntory entry */
+ unsigned short d_reclen; /* length of this record */
+ char d_name[MAXNAMLEN+1];/* name of file */
+};
+
+#define d_namlen d_reclen
+#define d_fileno d_ino
+
+#endif /* _SYS_DIRENT_H */
diff --git a/mit-pthreads/machdep/irix-5.2/socket.h b/mit-pthreads/machdep/irix-5.2/socket.h
new file mode 100755
index 00000000000..b08d3939802
--- /dev/null
+++ b/mit-pthreads/machdep/irix-5.2/socket.h
@@ -0,0 +1,304 @@
+#ifndef __SYS_TPI_SOCKET_H__
+#ifndef __SYS_SOCKET_H__
+#define __SYS_SOCKET_H__
+/*
+ * Copyright (c) 1982,1985, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)socket.h 7.1 (Berkeley) 6/4/86
+ */
+#include <sys/cdefs.h>
+#include <sys/bsd_types.h>
+
+/*
+ * Definitions related to sockets: types, address families, options.
+ */
+
+/*
+ * Types
+ */
+#ifdef _STYPES_LATER /* old ABI */
+#define SOCK_STREAM 1 /* stream socket */
+#define SOCK_DGRAM 2 /* datagram socket */
+#define SOCK_RAW 3 /* raw-protocol interface */
+#define SOCK_RDM 4 /* reliably-delivered message */
+#define SOCK_SEQPACKET 5 /* sequenced packet stream */
+#else /* !_STYPES_LATER, new ABI */
+
+#ifndef NC_TPI_CLTS
+#define NC_TPI_CLTS 1 /* must agree with netconfig.h */
+#define NC_TPI_COTS 2 /* must agree with netconfig.h */
+#define NC_TPI_COTS_ORD 3 /* must agree with netconfig.h */
+#define NC_TPI_RAW 4 /* must agree with netconfig.h */
+#endif /* !NC_TPI_CLTS */
+
+#define SOCK_DGRAM NC_TPI_CLTS /* datagram socket */
+#define SOCK_STREAM NC_TPI_COTS /* stream socket */
+#define SOCK_RAW NC_TPI_RAW /* raw-protocol interface */
+#define SOCK_RDM 5 /* reliably-delivered message */
+#define SOCK_SEQPACKET 6 /* sequenced packet stream */
+
+#ifdef _KERNEL
+#define IRIX4_SOCK_STREAM 1 /* stream socket */
+#define IRIX4_SOCK_DGRAM 2 /* datagram socket */
+#define IRIX4_SOCK_RAW 3 /* raw-protocol interface */
+#define IRIX4_SOCK_RDM 4 /* reliably-delivered message */
+#define IRIX4_SOCK_SEQPACKET 5 /* sequenced packet stream */
+#endif /* _KERNEL */
+#endif /* _STYPES_LATER */
+
+/*
+ * Option flags per-socket.
+ */
+#define SO_DEBUG 0x0001 /* turn on debugging info recording */
+#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
+#define SO_REUSEADDR 0x0004 /* allow local address reuse */
+#define SO_KEEPALIVE 0x0008 /* keep connections alive */
+#define SO_DONTROUTE 0x0010 /* just use interface addresses */
+#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
+#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
+#define SO_LINGER 0x0080 /* linger on close if data present */
+#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
+#define SO_REUSEPORT 0x0200 /* allow local address,port reuse */
+#define SO_ORDREL 0x0200 /* MIPS ABI - unimplemented */
+#define SO_IMASOCKET 0x0400 /* use libsocket (not TLI) semantics */
+#define SO_CHAMELEON 0x1000 /* (cipso) set label to 1st req rcvd */
+
+/*
+ * Additional options, not kept in so_options.
+ */
+#define SO_SNDBUF 0x1001 /* send buffer size */
+#define SO_RCVBUF 0x1002 /* receive buffer size */
+#define SO_SNDLOWAT 0x1003 /* send low-water mark */
+#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
+#define SO_SNDTIMEO 0x1005 /* send timeout */
+#define SO_RCVTIMEO 0x1006 /* receive timeout */
+#define SO_ERROR 0x1007 /* get error status and clear */
+#define SO_TYPE 0x1008 /* get socket type */
+#define SO_PROTOTYPE 0x1009 /* get protocol type (libsocket) */
+
+/*
+ * Structure used for manipulating linger option.
+ */
+struct linger {
+ int l_onoff; /* option on/off */
+ int l_linger; /* linger time */
+};
+
+/*
+ * Level number for (get/set)sockopt() to apply to socket itself.
+ */
+#define SOL_SOCKET 0xffff /* options for socket level */
+
+/*
+ * Address families.
+ * XTP really is not an address family, but is included here to take
+ * up space, because other AF_ entries are numerically equal to their
+ * PF_ counterparts.
+ */
+#define AF_UNSPEC 0 /* unspecified */
+#define AF_UNIX 1 /* local to host (pipes, portals) */
+#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
+#define AF_IMPLINK 3 /* arpanet imp addresses */
+#define AF_PUP 4 /* pup protocols: e.g. BSP */
+#define AF_CHAOS 5 /* mit CHAOS protocols */
+#define AF_NS 6 /* XEROX NS protocols */
+#define AF_ISO 7 /* ISO protocols */
+#define AF_ECMA 8 /* european computer manufacturers */
+#define AF_DATAKIT 9 /* datakit protocols */
+#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
+#define AF_SNA 11 /* IBM SNA */
+#define AF_DECnet 12 /* DECnet */
+#define AF_DLI 13 /* DEC Direct data link interface */
+#define AF_LAT 14 /* LAT */
+#define AF_HYLINK 15 /* NSC Hyperchannel */
+#define AF_APPLETALK 16 /* Apple Talk */
+#define AF_ROUTE 17 /* Internal Routing Protocol */
+#ifdef __sgi
+#define AF_RAW 18 /* Raw link layer interface */
+#else
+#define AF_LINK 18 /* Link layer interface */
+#endif
+#define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */
+
+/* MIPS ABI VALUES - unimplemented */
+#define AF_NIT 17 /* Network Interface Tap */
+#define AF_802 18 /* IEEE 802.2, also ISO 8802 */
+#define AF_OSI 19 /* umbrella for all families used */
+#define AF_X25 20 /* CCITT X.25 in particular */
+#define AF_OSINET 21 /* AFI = 47, IDI = 4 */
+#define AF_GOSIP 22 /* U.S. Government OSI */
+
+
+#define AF_SDL 23 /* SGI Data Link for DLPI */
+
+#define AF_MAX (AF_SDL+1)
+
+/*
+ * Structure used by kernel to store most
+ * addresses.
+ */
+struct sockaddr {
+ u_short sa_family; /* address family */
+ char sa_data[14]; /* up to 14 bytes of direct address */
+};
+
+/*
+ * Structure used by kernel to pass protocol
+ * information in raw sockets.
+ */
+struct sockproto {
+ u_short sp_family; /* address family */
+ u_short sp_protocol; /* protocol */
+};
+
+/*
+ * An option specification consists of an opthdr, followed by the value of
+ * the option. An options buffer contains one or more options. The len
+ * field of opthdr specifies the length of the option value in bytes. This
+ * length must be a multiple of sizeof(long) (use OPTLEN macro).
+ */
+
+struct opthdr {
+ long level; /* protocol level affected */
+ long name; /* option to modify */
+ long len; /* length of option value */
+};
+
+#define OPTLEN(x) ((((x) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
+#define OPTVAL(opt) ((char *)(opt + 1))
+
+/*
+ * the optdefault structure is used for internal tables of option default
+ * values.
+ */
+struct optdefault {
+ int optname; /* the option */
+ char *val; /* ptr to default value */
+ int len; /* length of value */
+};
+
+struct tpisocket;
+struct T_optmgmt_req;
+struct msgb;
+
+/*
+ * the opproc structure is used to build tables of options processing
+ * functions for dooptions().
+ */
+struct opproc {
+ int level; /* options level this function handles */
+ int (*func)(struct tpisocket *, struct T_optmgmt_req *,
+ struct opthdr *, struct msgb *);
+ /* the function */
+};
+
+/*
+ * This structure is used to encode pseudo system calls
+ */
+struct socksysreq {
+ int args[7];
+};
+
+/*
+ * This structure is used for adding new protocols to the list supported by
+ * sockets.
+ */
+
+struct socknewproto {
+ int family; /* address family (AF_INET, etc.) */
+ int type; /* protocol type (SOCK_STREAM, etc.) */
+ int proto; /* per family proto number */
+ dev_t dev; /* major/minor to use (must be a clone) */
+ int flags; /* protosw flags */
+};
+
+/*
+ * Protocol families, same as address families for now.
+ */
+#define PF_UNSPEC AF_UNSPEC
+#define PF_UNIX AF_UNIX
+#define PF_INET AF_INET
+#define PF_IMPLINK AF_IMPLINK
+#define PF_PUP AF_PUP
+#define PF_CHAOS AF_CHAOS
+#define PF_NS AF_NS
+#define PF_ISO AF_ISO
+#define PF_ECMA AF_ECMA
+#define PF_DATAKIT AF_DATAKIT
+#define PF_CCITT AF_CCITT
+#define PF_SNA AF_SNA
+#define PF_DECnet AF_DECnet
+#define PF_DLI AF_DLI
+#define PF_LAT AF_LAT
+#define PF_HYLINK AF_HYLINK
+#define PF_APPLETALK AF_APPLETALK
+#define PF_ROUTE AF_ROUTE
+#define PF_LINK AF_LINK
+#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */
+#ifdef __sgi
+#define PF_RAW AF_RAW
+#endif
+
+/* MIPS ABI VALUES - unimplemented */
+#define PF_NIT AF_NIT /* Network Interface Tap */
+#define PF_802 AF_802 /* IEEE 802.2, also ISO 8802 */
+#define PF_OSI AF_OSI /* umbrella for all families used */
+#define PF_X25 AF_X25 /* CCITT X.25 in particular */
+#define PF_OSINET AF_OSINET /* AFI = 47, IDI = 4 */
+#define PF_GOSIP AF_GOSIP /* U.S. Government OSI */
+
+#define PF_MAX AF_MAX
+
+/*
+ * Maximum queue length specifiable by listen.
+ */
+#define SOMAXCONN 5
+
+/*
+ * Message header for recvmsg and sendmsg calls.
+ */
+struct msghdr {
+ caddr_t msg_name; /* optional address */
+ int msg_namelen; /* size of address */
+ struct iovec *msg_iov; /* scatter/gather array */
+ int msg_iovlen; /* # elements in msg_iov */
+ caddr_t msg_accrights; /* access rights sent/received */
+ int msg_accrightslen;
+};
+
+#define MSG_OOB 0x1 /* process out-of-band data */
+#define MSG_PEEK 0x2 /* peek at incoming message */
+#define MSG_DONTROUTE 0x4 /* send without using routing tables */
+#define MSG_EOR 0x8 /* data completes record (OSI only) */
+#ifdef XTP
+#define MSG_BTAG 0x40 /* XTP packet with BTAG field */
+#define MSG_ETAG 0x80 /* XTP packet with ETAG field */
+#endif
+
+#define MSG_MAXIOVLEN 16
+
+__BEGIN_DECLS
+int accept __P_((int, struct sockaddr *, int *));
+int bind __P_((int, const struct sockaddr *, int));
+int connect __P_((int, const struct sockaddr *, int));
+int getpeername __P_((int, struct sockaddr *, int *));
+int getsockname __P_((int, struct sockaddr *, int *));
+int getsockopt __P_((int, int, int, void *, int *));
+int listen __P_((int, int));
+ssize_t recv __P_((int, void *, size_t, int));
+ssize_t recvfrom __P_((int, void *, size_t, int, struct sockaddr *, int *));
+int recvmsg __P_((int, struct msghdr *, int));
+ssize_t send __P_((int, const void *, size_t, int));
+ssize_t sendto __P_((int, const void *, size_t, int,
+ const struct sockaddr *, int));
+int sendmsg __P_((int, const struct msghdr *, int));
+int setsockopt __P_((int, int, int, const void *, int));
+int shutdown __P_((int, int));
+int socket __P_((int, int, int));
+int socketpair __P_((int, int, int, int *));
+__END_DECLS
+
+#endif /* !__SYS_SOCKET_H__ */
+#endif /* !__SYS_TPI_SOCKET_H__ */
diff --git a/mit-pthreads/machdep/irix-5.2/timers.h b/mit-pthreads/machdep/irix-5.2/timers.h
new file mode 100755
index 00000000000..ffa24dc9a15
--- /dev/null
+++ b/mit-pthreads/machdep/irix-5.2/timers.h
@@ -0,0 +1,18 @@
+#ifndef __SYS_TIMERS_H__
+#define __SYS_TIMERS_H__
+
+struct timespec {
+ time_t tv_sec;
+ long tv_nsec;
+};
+
+#define TIMEVAL_TO_TIMESPEC(tv, ts) { \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000; \
+}
+#define TIMESPEC_TO_TIMEVAL(tv, ts) { \
+ (tv)->tv_sec = (ts)->tv_sec; \
+ (tv)->tv_usec = (ts)->tv_nsec / 1000; \
+}
+
+#endif /* !__SYS_TIMERS_H__ */
diff --git a/mit-pthreads/machdep/irix-5.2/wait.h b/mit-pthreads/machdep/irix-5.2/wait.h
new file mode 100755
index 00000000000..c0a7e7113d8
--- /dev/null
+++ b/mit-pthreads/machdep/irix-5.2/wait.h
@@ -0,0 +1,104 @@
+/*
+ * 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.
+ *
+ * @(#)wait.h 7.4 (Berkeley) 1/27/88
+ */
+#ifndef __SYS_WAIT_H__
+#define __SYS_WAIT_H__
+
+#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 WSTOPFLG 0177
+#define WIFSTOPPED(stat) ((_W_INT(stat)&0377)==_WSTOPPED&&((_W_INT(stat)>>8)&0377)!=0)
+#define WSTOPSIG(stat) ((_W_INT(stat)>>8)&0377)
+#define WIFSIGNALED(stat) ((_W_INT(stat)&0377)>0&&((_W_INT(stat)>>8)&0377)==0)
+#define WTERMSIG(stat) (_W_INT(stat)&0177)
+#define WIFEXITED(stat) ((_W_INT(stat)&0377)==0)
+#define WEXITSTATUS(stat) ((_W_INT(stat)>>8)&0377)
+#define WCOREDUMP(stat) (_W_INT(stat) & WCOREFLAG)
+
+/*
+ * Option bits for the second argument of wait3. 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 0100
+#define WUNTRACED 0004 /* for POSIX */
+
+#if !defined(_POSIX_SOURCE)
+
+/*
+ * Structure of the information in the first word returned by both
+ * wait and wait3. If w_stopval==_WSTOPPED, then the second structure
+ * describes the information returned, else the first. See WUNTRACED below.
+ */
+typedef union wait {
+ int w_status; /* used in syscall */
+ /*
+ * Terminated process status.
+ */
+ struct {
+#ifdef _MIPSEL
+ 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
+#ifdef _MIPSEB
+ 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 {
+#ifdef _MIPSEL
+ unsigned int w_Stopval:8, /* == W_STOPPED if stopped */
+ w_Stopsig:8, /* signal that stopped us */
+ w_Filler:16; /* upper bits filler */
+#endif
+#ifdef _MIPSEB
+ 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;
+} wait_t;
+#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 0004 /* wait for processes stopped by signals */
+#endif /* !defined(_POSIX_SOURCE) */
+
+#include <sys/types.h>
+#include <sys/cdefs.h>
+__BEGIN_DECLS
+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
+
+#endif /* __SYS_WAIT_H__ */
diff --git a/mit-pthreads/machdep/linux-1.0/__math.h b/mit-pthreads/machdep/linux-1.0/__math.h
new file mode 100755
index 00000000000..05c65d58321
--- /dev/null
+++ b/mit-pthreads/machdep/linux-1.0/__math.h
@@ -0,0 +1,4 @@
+#ifndef HUGE_VAL
+#define HUGE_VAL DBL_MAX
+#endif
+
diff --git a/mit-pthreads/machdep/linux-1.0/__path.h b/mit-pthreads/machdep/linux-1.0/__path.h
new file mode 100755
index 00000000000..9caeb7d3016
--- /dev/null
+++ b/mit-pthreads/machdep/linux-1.0/__path.h
@@ -0,0 +1,14 @@
+/*
+ * from: @(#)time.h 5.12 (Berkeley) 3/9/91
+ * $Id$
+ */
+
+#ifndef _SYS__PATH_H_
+#define _SYS__PATH_H_
+
+#define _PATH_PTY "/dev/"
+#define _PATH_TZDIR "/usr/lib/zoneinfo"
+#define _PATH_TZFILE "/usr/lib/zoneinfo/localtime"
+
+#endif /* !_SYS__PATH_H_ */
+
diff --git a/mit-pthreads/machdep/linux-1.0/__signal.h b/mit-pthreads/machdep/linux-1.0/__signal.h
new file mode 100755
index 00000000000..4cd671f155c
--- /dev/null
+++ b/mit-pthreads/machdep/linux-1.0/__signal.h
@@ -0,0 +1,24 @@
+#include <features.h>
+#include <linux/signal.h>
+
+#ifndef SIGCLD
+#define SIGCLD SIGCHLD
+#endif
+
+typedef int sig_atomic_t;
+
+typedef __sighandler_t SignalHandler;
+
+#define SignalBad ((SignalHandler)-1)
+#define SignalDefault ((SignalHandler)0)
+#define SignalIgnore ((SignalHandler)1)
+
+#define __sigmask(sig) (1 << ((sig) - 1))
+#define sigmask __sigmask
+
+#define __SIGFILLSET 0xffffffff
+#define __SIGEMPTYSET 0
+#define __SIGADDSET(s,n) ((*s) |= (__sigmask(n)))
+#define __SIGDELSET(s,n) ((*s) &= ~(__sigmask(n)))
+#define __SIGISMEMBER(s,n) ((*s) & (__sigmask(n)))
+
diff --git a/mit-pthreads/machdep/linux-1.0/__stdio.h b/mit-pthreads/machdep/linux-1.0/__stdio.h
new file mode 100755
index 00000000000..eb7e904c34d
--- /dev/null
+++ b/mit-pthreads/machdep/linux-1.0/__stdio.h
@@ -0,0 +1,7 @@
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef pthread_size_t size_t;
+#endif
+
+typedef pthread_fpos_t fpos_t;
diff --git a/mit-pthreads/machdep/linux-1.0/__stdlib.h b/mit-pthreads/machdep/linux-1.0/__stdlib.h
new file mode 100755
index 00000000000..eaa0bb988ee
--- /dev/null
+++ b/mit-pthreads/machdep/linux-1.0/__stdlib.h
@@ -0,0 +1,20 @@
+
+#ifndef _SYS___STDLIB_H_
+#define _SYS___STDLIB_H_
+
+#include <features.h>
+
+/* Get size_t, wchar_t and NULL from <stddef.h>. */
+#define __need_size_t
+#define __need_wchar_t
+#define __need_NULL
+#include <stddef.h>
+
+#define __need_Emath
+#include <errno.h>
+
+/* Get HUGE_VAL (returned by strtod on overflow) from <float.h>. */
+#define __need_HUGE_VAL
+#include <float.h>
+
+#endif
diff --git a/mit-pthreads/machdep/linux-1.0/__string.h b/mit-pthreads/machdep/linux-1.0/__string.h
new file mode 100755
index 00000000000..8a5e09608e0
--- /dev/null
+++ b/mit-pthreads/machdep/linux-1.0/__string.h
@@ -0,0 +1,18 @@
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef pthread_size_t size_t;
+#endif
+
+/* Non-standard Linux 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 *));
+char *strsep __P_((char **, const char *));
+__END_DECLS
+#endif
diff --git a/mit-pthreads/machdep/linux-1.0/__time.h b/mit-pthreads/machdep/linux-1.0/__time.h
new file mode 100755
index 00000000000..a088268286e
--- /dev/null
+++ b/mit-pthreads/machdep/linux-1.0/__time.h
@@ -0,0 +1,72 @@
+/* ==== __time.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$
+ *
+ * Description : System specific time header.
+ *
+ * 1.00 94/11/07 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS___TIME_H_
+#define _SYS___TIME_H_
+
+#include <features.h>
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef unsigned int size_t;
+#endif
+#ifndef _CLOCK_T
+#define _CLOCK_T
+typedef long clock_t;
+#endif
+#ifndef _TIME_T
+#define _TIME_T
+typedef long time_t;
+
+#ifndef NULL
+#ifdef __cplusplus
+#define NULL 0
+#else
+#define NULL ((void *) 0)
+#endif
+#endif
+#endif
+
+#define CLOCKS_PER_SEC 100
+#define CLK_TCK 100
+
+extern long int timezone;
+extern int daylight;
+
+#endif
diff --git a/mit-pthreads/machdep/linux-1.0/__unistd.h b/mit-pthreads/machdep/linux-1.0/__unistd.h
new file mode 100755
index 00000000000..0f15b7c4883
--- /dev/null
+++ b/mit-pthreads/machdep/linux-1.0/__unistd.h
@@ -0,0 +1,56 @@
+/*-
+ * 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$
+ */
+
+#ifndef _SYS___UNISTD_H_
+#define _SYS___UNISTD_H_
+
+#include <features.h>
+
+/* POSIX Standard approved as IEEE Std 1003.1 as of August, 1988. */
+#define _POSIX_VERSION 199009L
+#define _POSIX2_C_BIND 1
+#define _POSIX2_C_DEV 1
+#define _POSIX2_SW_DEV 1
+
+#define __need_size_t
+#define ioctl_request_type int /* For fd.c */
+
+#include <posix_opt.h>
+#include <sys/types.h>
+#include <stddef.h>
+
+#endif
+
diff --git a/mit-pthreads/machdep/linux-1.0/cdefs.h b/mit-pthreads/machdep/linux-1.0/cdefs.h
new file mode 100755
index 00000000000..f9d5668cfe6
--- /dev/null
+++ b/mit-pthreads/machdep/linux-1.0/cdefs.h
@@ -0,0 +1,23 @@
+/* This is intended to eventually find /usr/include/sys/cdefs.h
+ * if it's inside the ifdef then it won't work if this file is
+ * found in the include files path more than once.
+ *
+ * include_next is a GNU C extension, we might eventually want
+ * to have our own cdefs in here simply to avoid GNU C dependencies
+ * (though there are already enough in the asm stuff anyways)
+ * [gsstark:19950419.0307EST]
+ */
+#include_next <sys/cdefs.h>
+
+#ifndef _PTHREAD_SYS_CDEFS_H_
+#define _PTHREAD_SYS_CDEFS_H_
+
+#ifndef __NORETURN
+#define __NORETURN
+#endif /* __NORETURN not defined. */
+
+#if !defined(__cplusplus)
+#define __CAN_DO_EXTERN_INLINE
+#endif
+
+#endif /* _PTHREAD_SYS_CDEFS_H_ */
diff --git a/mit-pthreads/machdep/linux-1.0/compat.h b/mit-pthreads/machdep/linux-1.0/compat.h
new file mode 100755
index 00000000000..6edb992ac3d
--- /dev/null
+++ b/mit-pthreads/machdep/linux-1.0/compat.h
@@ -0,0 +1,47 @@
+/* ==== 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$
+ *
+ * Description : Basic timers header.
+ *
+ * 1.00 94/06/13 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS_COMPAT_H_
+#define _SYS_COMPAT_H_
+
+#include <sys/types.h>
+
+#define omsghdr msghdr
+
+#endif
diff --git a/mit-pthreads/machdep/linux-1.0/dirent.h b/mit-pthreads/machdep/linux-1.0/dirent.h
new file mode 100755
index 00000000000..7f783a198e0
--- /dev/null
+++ b/mit-pthreads/machdep/linux-1.0/dirent.h
@@ -0,0 +1,27 @@
+
+#ifndef _SYS_DIRENT_H
+#define _SYS_DIRENT_H
+
+#include <sys/types.h>
+#include <linux/limits.h>
+
+struct dirent {
+ long d_ino;
+ off_t d_off;
+ unsigned short d_reclen;
+ char d_name[NAME_MAX+1];
+};
+
+#ifndef d_fileno
+#define d_fileno d_ino
+#endif
+
+#ifndef d_namlen
+#define d_namlen d_reclen
+#endif
+
+#ifndef MAXNAMLEN
+#define MAXNAMLEN NAME_MAX
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/linux-1.0/errno.h b/mit-pthreads/machdep/linux-1.0/errno.h
new file mode 100755
index 00000000000..a94a56b0437
--- /dev/null
+++ b/mit-pthreads/machdep/linux-1.0/errno.h
@@ -0,0 +1,12 @@
+/* ==== errno.h ============================================================
+ * Copyright (c) 1994 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Errno is already broken up into data/prototyes.
+ */
+
+#ifndef _SYS_ERRNO_H_
+#define _SYS_ERRNO_H_
+
+#include <linux/errno.h>
+
+#endif
diff --git a/mit-pthreads/machdep/linux-1.0/socket.h b/mit-pthreads/machdep/linux-1.0/socket.h
new file mode 100755
index 00000000000..cc4c0fd262e
--- /dev/null
+++ b/mit-pthreads/machdep/linux-1.0/socket.h
@@ -0,0 +1,193 @@
+/* ==== socket.h.h ============================================================
+ * Copyright (c) 1994 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Correct Linux header file.
+ */
+
+#ifndef _PTHREAD_SOCKET_H_
+#define _PTHREAD_SOCKET_H_
+
+/* #include <linux/socket.h> */
+#ifndef _LINUX_SOCKET_H
+#define _LINUX_SOCKET_H
+
+/* IP options */
+#define IP_TOS 1
+#define IPTOS_LOWDELAY 0x10
+#define IPTOS_THROUGHPUT 0x08
+#define IPTOS_RELIABILITY 0x04
+#define IP_TTL 2
+#ifndef IP_HDRINCL
+#define IP_HDRINCL 3
+#endif
+#ifdef V1_3_WILL_DO_THIS_FUNKY_STUFF
+#define IP_OPTIONS 4
+#endif
+
+#endif
+
+/* #include <asm/socket.h> arch-dependent defines */
+#include <linux/sockios.h> /* the SIOCxxx I/O controls */
+#include <pthread/posix.h>
+
+struct sockaddr {
+ unsigned short sa_family; /* address family, AF_xxx */
+ char sa_data[14]; /* 14 bytes of protocol address */
+};
+
+struct linger {
+ int l_onoff; /* Linger active */
+ int l_linger; /* How long to linger for */
+};
+
+struct msghdr
+{
+ void * msg_name; /* Socket name */
+ int msg_namelen; /* Length of name */
+ struct iovec * msg_iov; /* Data blocks */
+ int msg_iovlen; /* Number of blocks */
+ void * msg_accrights; /* Per protocol magic (eg BSD file descriptor passing) */
+ int msg_accrightslen;/* Length of rights list */
+};
+
+/* Socket types. */
+#define SOCK_STREAM 1 /* stream (connection) socket */
+#define SOCK_DGRAM 2 /* datagram (conn.less) socket */
+#define SOCK_RAW 3 /* raw socket */
+#define SOCK_RDM 4 /* reliably-delivered message */
+#define SOCK_SEQPACKET 5 /* sequential packet socket */
+#define SOCK_PACKET 10 /* linux specific way of */
+ /* getting packets at the dev */
+ /* level. For writing rarp and */
+ /* other similar things on the */
+ /* user level. */
+
+/* Supported address families. */
+#define AF_UNSPEC 0
+#define AF_UNIX 1 /* Unix domain sockets */
+#define AF_INET 2 /* Internet IP Protocol */
+#define AF_AX25 3 /* Amateur Radio AX.25 */
+#define AF_IPX 4 /* Novell IPX */
+#define AF_APPLETALK 5 /* Appletalk DDP */
+#define AF_NETROM 6 /* Amateur radio NetROM */
+#define AF_BRIDGE 7 /* Multiprotocol bridge */
+#define AF_AAL5 8 /* Reserved for Werner's ATM */
+#define AF_X25 9 /* Reserved for X.25 project */
+#define AF_INET6 10 /* IP version 6 */
+#define AF_MAX 12 /* For now.. */
+
+/* Protocol families, same as address families. */
+#define PF_UNSPEC AF_UNSPEC
+#define PF_UNIX AF_UNIX
+#define PF_INET AF_INET
+#define PF_AX25 AF_AX25
+#define PF_IPX AF_IPX
+#define PF_APPLETALK AF_APPLETALK
+#define PF_NETROM AF_NETROM
+#define PF_BRIDGE AF_BRIDGE
+#define PF_AAL5 AF_AAL5
+#define PF_X25 AF_X25
+#define PF_INET6 AF_INET6
+
+#define PF_MAX AF_MAX
+
+/* Maximum queue length specificable by listen. */
+#define SOMAXCONN 128
+
+/* Flags we can use with send/ and recv. */
+#define MSG_OOB 1
+#define MSG_PEEK 2
+#define MSG_DONTROUTE 4
+
+/* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */
+#define SOL_SOCKET 1
+#define SOL_IP 0
+#define SOL_IPX 256
+#define SOL_AX25 257
+#define SOL_ATALK 258
+#define SOL_NETROM 259
+#define SOL_TCP 6
+#define SOL_UDP 17
+
+/* For setsockoptions(2) */
+#define SO_DEBUG 1
+#define SO_REUSEADDR 2
+#define SO_TYPE 3
+#define SO_ERROR 4
+#define SO_DONTROUTE 5
+#define SO_BROADCAST 6
+#define SO_SNDBUF 7
+#define SO_RCVBUF 8
+#define SO_KEEPALIVE 9
+#define SO_OOBINLINE 10
+#define SO_NO_CHECK 11
+#define SO_PRIORITY 12
+#define SO_LINGER 13
+/* To add :#define SO_REUSEPORT 14 */
+
+
+#define IP_MULTICAST_IF 32
+#define IP_MULTICAST_TTL 33
+#define IP_MULTICAST_LOOP 34
+#define IP_ADD_MEMBERSHIP 35
+#define IP_DROP_MEMBERSHIP 36
+
+
+/* These need to appear somewhere around here */
+#define IP_DEFAULT_MULTICAST_TTL 1
+#define IP_DEFAULT_MULTICAST_LOOP 1
+#define IP_MAX_MEMBERSHIPS 20
+
+/* IPX options */
+#define IPX_TYPE 1
+
+/* TCP options - this way around because someone left a set in the c library includes */
+#define TCP_NODELAY 1
+#define TCP_MAXSEG 2
+
+/* The various priorities. */
+#define SOPRI_INTERACTIVE 0
+#define SOPRI_NORMAL 1
+#define SOPRI_BACKGROUND 2
+
+/*
+ * Functions
+ */
+
+__BEGIN_DECLS
+
+int accept __P_((int, struct sockaddr *, int *));
+int bind __P_((int, const struct sockaddr *, int));
+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
+
+#endif
+
+
+
+
diff --git a/mit-pthreads/machdep/linux-1.0/timers.h b/mit-pthreads/machdep/linux-1.0/timers.h
new file mode 100755
index 00000000000..110cb27378c
--- /dev/null
+++ b/mit-pthreads/machdep/linux-1.0/timers.h
@@ -0,0 +1,71 @@
+/* ==== 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$
+ *
+ * Description : Basic timers header.
+ *
+ * 1.00 94/06/13 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS_TIMERS_H_
+#define _SYS_TIMERS_H_
+
+#include <pthread/config.h>
+#include <sys/types.h>
+#include <time.h>
+
+#ifndef _OS_HAS_TIMESPEC
+struct timespec {
+ time_t tv_sec;
+ long tv_nsec;
+};
+#endif
+
+#define TIMEVAL_TO_TIMESPEC(tv, ts) { \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000; \
+}
+#define TIMESPEC_TO_TIMEVAL(tv, ts) { \
+ (tv)->tv_sec = (ts)->tv_sec; \
+ (tv)->tv_usec = (ts)->tv_nsec / 1000; \
+}
+
+/*
+ * New functions
+ */
+
+__BEGIN_DECLS
+
+__END_DECLS
+
+#endif
diff --git a/mit-pthreads/machdep/linux-1.0/uio.h b/mit-pthreads/machdep/linux-1.0/uio.h
new file mode 100755
index 00000000000..67af5bf76e0
--- /dev/null
+++ b/mit-pthreads/machdep/linux-1.0/uio.h
@@ -0,0 +1,15 @@
+/* ==== uio.h ============================================================
+ * Copyright (c) 1994 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Correct Linux header file.
+ */
+
+#ifndef _PTHREAD_UIO_H_
+#define _PTHREAD_UIO_H_
+
+struct iovec {
+ void *iov_base;
+ size_t iov_len;
+};
+
+#endif
diff --git a/mit-pthreads/machdep/linux-1.0/wait.h b/mit-pthreads/machdep/linux-1.0/wait.h
new file mode 100755
index 00000000000..bcc28c5ef58
--- /dev/null
+++ b/mit-pthreads/machdep/linux-1.0/wait.h
@@ -0,0 +1,98 @@
+/* $NetBSD: wait.h,v 1.7 1994/06/29 06:46:23 cgd Exp $ */
+
+/*
+ * 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
+ */
+
+/*
+ * 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. Union wait is no supported with pthreads.
+ */
+#define __W_INT(i) (i)
+#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
+
+/* 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 */
+
+#define WSTOPPED __WSTOPPED
+#endif /* _POSIX_SOURCE */
+
+#include <sys/types.h>
+#include <sys/cdefs.h>
+
+#ifndef __WAIT_STATUS
+#define __WAIT_STATUS int *
+#endif
+
+__BEGIN_DECLS
+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
diff --git a/mit-pthreads/machdep/linux-2.0/__math.h b/mit-pthreads/machdep/linux-2.0/__math.h
new file mode 100755
index 00000000000..05c65d58321
--- /dev/null
+++ b/mit-pthreads/machdep/linux-2.0/__math.h
@@ -0,0 +1,4 @@
+#ifndef HUGE_VAL
+#define HUGE_VAL DBL_MAX
+#endif
+
diff --git a/mit-pthreads/machdep/linux-2.0/__path.h b/mit-pthreads/machdep/linux-2.0/__path.h
new file mode 100755
index 00000000000..9caeb7d3016
--- /dev/null
+++ b/mit-pthreads/machdep/linux-2.0/__path.h
@@ -0,0 +1,14 @@
+/*
+ * from: @(#)time.h 5.12 (Berkeley) 3/9/91
+ * $Id$
+ */
+
+#ifndef _SYS__PATH_H_
+#define _SYS__PATH_H_
+
+#define _PATH_PTY "/dev/"
+#define _PATH_TZDIR "/usr/lib/zoneinfo"
+#define _PATH_TZFILE "/usr/lib/zoneinfo/localtime"
+
+#endif /* !_SYS__PATH_H_ */
+
diff --git a/mit-pthreads/machdep/linux-2.0/__signal.h b/mit-pthreads/machdep/linux-2.0/__signal.h
new file mode 100755
index 00000000000..4cd671f155c
--- /dev/null
+++ b/mit-pthreads/machdep/linux-2.0/__signal.h
@@ -0,0 +1,24 @@
+#include <features.h>
+#include <linux/signal.h>
+
+#ifndef SIGCLD
+#define SIGCLD SIGCHLD
+#endif
+
+typedef int sig_atomic_t;
+
+typedef __sighandler_t SignalHandler;
+
+#define SignalBad ((SignalHandler)-1)
+#define SignalDefault ((SignalHandler)0)
+#define SignalIgnore ((SignalHandler)1)
+
+#define __sigmask(sig) (1 << ((sig) - 1))
+#define sigmask __sigmask
+
+#define __SIGFILLSET 0xffffffff
+#define __SIGEMPTYSET 0
+#define __SIGADDSET(s,n) ((*s) |= (__sigmask(n)))
+#define __SIGDELSET(s,n) ((*s) &= ~(__sigmask(n)))
+#define __SIGISMEMBER(s,n) ((*s) & (__sigmask(n)))
+
diff --git a/mit-pthreads/machdep/linux-2.0/__stdio.h b/mit-pthreads/machdep/linux-2.0/__stdio.h
new file mode 100755
index 00000000000..eb7e904c34d
--- /dev/null
+++ b/mit-pthreads/machdep/linux-2.0/__stdio.h
@@ -0,0 +1,7 @@
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef pthread_size_t size_t;
+#endif
+
+typedef pthread_fpos_t fpos_t;
diff --git a/mit-pthreads/machdep/linux-2.0/__stdlib.h b/mit-pthreads/machdep/linux-2.0/__stdlib.h
new file mode 100755
index 00000000000..eaa0bb988ee
--- /dev/null
+++ b/mit-pthreads/machdep/linux-2.0/__stdlib.h
@@ -0,0 +1,20 @@
+
+#ifndef _SYS___STDLIB_H_
+#define _SYS___STDLIB_H_
+
+#include <features.h>
+
+/* Get size_t, wchar_t and NULL from <stddef.h>. */
+#define __need_size_t
+#define __need_wchar_t
+#define __need_NULL
+#include <stddef.h>
+
+#define __need_Emath
+#include <errno.h>
+
+/* Get HUGE_VAL (returned by strtod on overflow) from <float.h>. */
+#define __need_HUGE_VAL
+#include <float.h>
+
+#endif
diff --git a/mit-pthreads/machdep/linux-2.0/__string.h b/mit-pthreads/machdep/linux-2.0/__string.h
new file mode 100755
index 00000000000..8a5e09608e0
--- /dev/null
+++ b/mit-pthreads/machdep/linux-2.0/__string.h
@@ -0,0 +1,18 @@
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef pthread_size_t size_t;
+#endif
+
+/* Non-standard Linux 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 *));
+char *strsep __P_((char **, const char *));
+__END_DECLS
+#endif
diff --git a/mit-pthreads/machdep/linux-2.0/__time.h b/mit-pthreads/machdep/linux-2.0/__time.h
new file mode 100755
index 00000000000..b86c153543a
--- /dev/null
+++ b/mit-pthreads/machdep/linux-2.0/__time.h
@@ -0,0 +1,78 @@
+/* ==== __time.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$
+ *
+ * Description : System specific time header.
+ *
+ * 1.00 94/11/07 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS___TIME_H_
+#define _SYS___TIME_H_
+
+#include <features.h>
+
+struct timespec
+ {
+ long int tv_sec; /* Seconds. */
+ long int tv_nsec; /* Nanoseconds. */
+ };
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef unsigned int size_t;
+#endif
+#ifndef _CLOCK_T
+#define _CLOCK_T
+typedef long clock_t;
+#endif
+#ifndef _TIME_T
+#define _TIME_T
+typedef long time_t;
+
+#ifndef NULL
+#ifdef __cplusplus
+#define NULL 0
+#else
+#define NULL ((void *) 0)
+#endif
+#endif
+#endif
+
+#define CLOCKS_PER_SEC 100
+#define CLK_TCK 100
+
+extern long int timezone;
+extern int daylight;
+
+#endif
diff --git a/mit-pthreads/machdep/linux-2.0/__unistd.h b/mit-pthreads/machdep/linux-2.0/__unistd.h
new file mode 100755
index 00000000000..444f070659a
--- /dev/null
+++ b/mit-pthreads/machdep/linux-2.0/__unistd.h
@@ -0,0 +1,62 @@
+/*-
+ * 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$
+ */
+
+#ifndef _SYS___UNISTD_H_
+#define _SYS___UNISTD_H_
+
+#include <features.h>
+
+/* POSIX Standard approved as IEEE Std 1003.1 as of August, 1988. */
+#define _POSIX_VERSION 199009L
+#define _POSIX2_C_BIND 1
+#define _POSIX2_C_DEV 1
+#define _POSIX2_SW_DEV 1
+
+#define __need_size_t
+
+#include <sys/types.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+int chroot(const char *);
+int gethostname(char *, int);
+#ifdef __cplusplus
+}
+#endif
+#endif
+
diff --git a/mit-pthreads/machdep/linux-2.0/cdefs.h b/mit-pthreads/machdep/linux-2.0/cdefs.h
new file mode 100755
index 00000000000..04f93a138c9
--- /dev/null
+++ b/mit-pthreads/machdep/linux-2.0/cdefs.h
@@ -0,0 +1,36 @@
+/* This is intended to eventually find /usr/include/sys/cdefs.h
+ * if it's inside the ifdef then it won't work if this file is
+ * found in the include files path more than once.
+ *
+ * include_next is a GNU C extension, we might eventually want
+ * to have our own cdefs in here simply to avoid GNU C dependencies
+ * (though there are already enough in the asm stuff anyways)
+ * [gsstark:19950419.0307EST]
+ */
+
+/* We are almost always included from features.h. */
+
+#ifndef _FEATURES_H
+#include <features.h>
+#endif
+
+#ifndef __BITS_SOCKET_H
+#define __BITS_SOCKET_H
+#endif
+
+#define __need_timespec
+
+#include_next <sys/cdefs.h>
+
+#ifndef _PTHREAD_SYS_CDEFS_H_
+#define _PTHREAD_SYS_CDEFS_H_
+
+#ifndef __NORETURN
+#define __NORETURN
+#endif /* __NORETURN not defined. */
+
+#if !defined(__cplusplus)
+#define __CAN_DO_EXTERN_INLINE
+#endif
+
+#endif /* _PTHREAD_SYS_CDEFS_H_ */
diff --git a/mit-pthreads/machdep/linux-2.0/compat.h b/mit-pthreads/machdep/linux-2.0/compat.h
new file mode 100755
index 00000000000..6edb992ac3d
--- /dev/null
+++ b/mit-pthreads/machdep/linux-2.0/compat.h
@@ -0,0 +1,47 @@
+/* ==== 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$
+ *
+ * Description : Basic timers header.
+ *
+ * 1.00 94/06/13 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS_COMPAT_H_
+#define _SYS_COMPAT_H_
+
+#include <sys/types.h>
+
+#define omsghdr msghdr
+
+#endif
diff --git a/mit-pthreads/machdep/linux-2.0/dirent.h b/mit-pthreads/machdep/linux-2.0/dirent.h
new file mode 100755
index 00000000000..7f783a198e0
--- /dev/null
+++ b/mit-pthreads/machdep/linux-2.0/dirent.h
@@ -0,0 +1,27 @@
+
+#ifndef _SYS_DIRENT_H
+#define _SYS_DIRENT_H
+
+#include <sys/types.h>
+#include <linux/limits.h>
+
+struct dirent {
+ long d_ino;
+ off_t d_off;
+ unsigned short d_reclen;
+ char d_name[NAME_MAX+1];
+};
+
+#ifndef d_fileno
+#define d_fileno d_ino
+#endif
+
+#ifndef d_namlen
+#define d_namlen d_reclen
+#endif
+
+#ifndef MAXNAMLEN
+#define MAXNAMLEN NAME_MAX
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/linux-2.0/errno.h b/mit-pthreads/machdep/linux-2.0/errno.h
new file mode 100755
index 00000000000..a94a56b0437
--- /dev/null
+++ b/mit-pthreads/machdep/linux-2.0/errno.h
@@ -0,0 +1,12 @@
+/* ==== errno.h ============================================================
+ * Copyright (c) 1994 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Errno is already broken up into data/prototyes.
+ */
+
+#ifndef _SYS_ERRNO_H_
+#define _SYS_ERRNO_H_
+
+#include <linux/errno.h>
+
+#endif
diff --git a/mit-pthreads/machdep/linux-2.0/extra/bits/local_lim.h b/mit-pthreads/machdep/linux-2.0/extra/bits/local_lim.h
new file mode 100644
index 00000000000..1a319ccdfd4
--- /dev/null
+++ b/mit-pthreads/machdep/linux-2.0/extra/bits/local_lim.h
@@ -0,0 +1,15 @@
+/* Minimum guaranteed maximum values for system limits. Linux version.
+
+/* The kernel header pollutes the namespace with the NR_OPEN symbol.
+ Remove this after including the header if necessary. */
+
+#ifndef NR_OPEN
+# define __undef_NR_OPEN
+#endif
+
+#include <linux/limits.h>
+
+#ifdef __undef_NR_OPEN
+# undef NR_OPEN
+# undef __undef_NR_OPEN
+#endif
diff --git a/mit-pthreads/machdep/linux-2.0/extra/bits/socket.h b/mit-pthreads/machdep/linux-2.0/extra/bits/socket.h
new file mode 100755
index 00000000000..cc4c0fd262e
--- /dev/null
+++ b/mit-pthreads/machdep/linux-2.0/extra/bits/socket.h
@@ -0,0 +1,193 @@
+/* ==== socket.h.h ============================================================
+ * Copyright (c) 1994 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Correct Linux header file.
+ */
+
+#ifndef _PTHREAD_SOCKET_H_
+#define _PTHREAD_SOCKET_H_
+
+/* #include <linux/socket.h> */
+#ifndef _LINUX_SOCKET_H
+#define _LINUX_SOCKET_H
+
+/* IP options */
+#define IP_TOS 1
+#define IPTOS_LOWDELAY 0x10
+#define IPTOS_THROUGHPUT 0x08
+#define IPTOS_RELIABILITY 0x04
+#define IP_TTL 2
+#ifndef IP_HDRINCL
+#define IP_HDRINCL 3
+#endif
+#ifdef V1_3_WILL_DO_THIS_FUNKY_STUFF
+#define IP_OPTIONS 4
+#endif
+
+#endif
+
+/* #include <asm/socket.h> arch-dependent defines */
+#include <linux/sockios.h> /* the SIOCxxx I/O controls */
+#include <pthread/posix.h>
+
+struct sockaddr {
+ unsigned short sa_family; /* address family, AF_xxx */
+ char sa_data[14]; /* 14 bytes of protocol address */
+};
+
+struct linger {
+ int l_onoff; /* Linger active */
+ int l_linger; /* How long to linger for */
+};
+
+struct msghdr
+{
+ void * msg_name; /* Socket name */
+ int msg_namelen; /* Length of name */
+ struct iovec * msg_iov; /* Data blocks */
+ int msg_iovlen; /* Number of blocks */
+ void * msg_accrights; /* Per protocol magic (eg BSD file descriptor passing) */
+ int msg_accrightslen;/* Length of rights list */
+};
+
+/* Socket types. */
+#define SOCK_STREAM 1 /* stream (connection) socket */
+#define SOCK_DGRAM 2 /* datagram (conn.less) socket */
+#define SOCK_RAW 3 /* raw socket */
+#define SOCK_RDM 4 /* reliably-delivered message */
+#define SOCK_SEQPACKET 5 /* sequential packet socket */
+#define SOCK_PACKET 10 /* linux specific way of */
+ /* getting packets at the dev */
+ /* level. For writing rarp and */
+ /* other similar things on the */
+ /* user level. */
+
+/* Supported address families. */
+#define AF_UNSPEC 0
+#define AF_UNIX 1 /* Unix domain sockets */
+#define AF_INET 2 /* Internet IP Protocol */
+#define AF_AX25 3 /* Amateur Radio AX.25 */
+#define AF_IPX 4 /* Novell IPX */
+#define AF_APPLETALK 5 /* Appletalk DDP */
+#define AF_NETROM 6 /* Amateur radio NetROM */
+#define AF_BRIDGE 7 /* Multiprotocol bridge */
+#define AF_AAL5 8 /* Reserved for Werner's ATM */
+#define AF_X25 9 /* Reserved for X.25 project */
+#define AF_INET6 10 /* IP version 6 */
+#define AF_MAX 12 /* For now.. */
+
+/* Protocol families, same as address families. */
+#define PF_UNSPEC AF_UNSPEC
+#define PF_UNIX AF_UNIX
+#define PF_INET AF_INET
+#define PF_AX25 AF_AX25
+#define PF_IPX AF_IPX
+#define PF_APPLETALK AF_APPLETALK
+#define PF_NETROM AF_NETROM
+#define PF_BRIDGE AF_BRIDGE
+#define PF_AAL5 AF_AAL5
+#define PF_X25 AF_X25
+#define PF_INET6 AF_INET6
+
+#define PF_MAX AF_MAX
+
+/* Maximum queue length specificable by listen. */
+#define SOMAXCONN 128
+
+/* Flags we can use with send/ and recv. */
+#define MSG_OOB 1
+#define MSG_PEEK 2
+#define MSG_DONTROUTE 4
+
+/* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */
+#define SOL_SOCKET 1
+#define SOL_IP 0
+#define SOL_IPX 256
+#define SOL_AX25 257
+#define SOL_ATALK 258
+#define SOL_NETROM 259
+#define SOL_TCP 6
+#define SOL_UDP 17
+
+/* For setsockoptions(2) */
+#define SO_DEBUG 1
+#define SO_REUSEADDR 2
+#define SO_TYPE 3
+#define SO_ERROR 4
+#define SO_DONTROUTE 5
+#define SO_BROADCAST 6
+#define SO_SNDBUF 7
+#define SO_RCVBUF 8
+#define SO_KEEPALIVE 9
+#define SO_OOBINLINE 10
+#define SO_NO_CHECK 11
+#define SO_PRIORITY 12
+#define SO_LINGER 13
+/* To add :#define SO_REUSEPORT 14 */
+
+
+#define IP_MULTICAST_IF 32
+#define IP_MULTICAST_TTL 33
+#define IP_MULTICAST_LOOP 34
+#define IP_ADD_MEMBERSHIP 35
+#define IP_DROP_MEMBERSHIP 36
+
+
+/* These need to appear somewhere around here */
+#define IP_DEFAULT_MULTICAST_TTL 1
+#define IP_DEFAULT_MULTICAST_LOOP 1
+#define IP_MAX_MEMBERSHIPS 20
+
+/* IPX options */
+#define IPX_TYPE 1
+
+/* TCP options - this way around because someone left a set in the c library includes */
+#define TCP_NODELAY 1
+#define TCP_MAXSEG 2
+
+/* The various priorities. */
+#define SOPRI_INTERACTIVE 0
+#define SOPRI_NORMAL 1
+#define SOPRI_BACKGROUND 2
+
+/*
+ * Functions
+ */
+
+__BEGIN_DECLS
+
+int accept __P_((int, struct sockaddr *, int *));
+int bind __P_((int, const struct sockaddr *, int));
+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
+
+#endif
+
+
+
+
diff --git a/mit-pthreads/machdep/linux-2.0/socket.h b/mit-pthreads/machdep/linux-2.0/socket.h
new file mode 100755
index 00000000000..fb43c394e10
--- /dev/null
+++ b/mit-pthreads/machdep/linux-2.0/socket.h
@@ -0,0 +1,196 @@
+/* ==== socket.h.h ============================================================
+ * Copyright (c) 1994 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Correct Linux header file.
+ */
+
+#ifndef _PTHREAD_SOCKET_H_
+#define _PTHREAD_SOCKET_H_
+
+/* #include <linux/socket.h> */
+#ifndef _LINUX_SOCKET_H
+#define _LINUX_SOCKET_H
+
+/* IP options */
+#define IP_TOS 1
+#define IPTOS_LOWDELAY 0x10
+#define IPTOS_THROUGHPUT 0x08
+#define IPTOS_RELIABILITY 0x04
+#define IP_TTL 2
+#ifndef IP_HDRINCL
+#define IP_HDRINCL 3
+#endif
+#ifdef V1_3_WILL_DO_THIS_FUNKY_STUFF
+#define IP_OPTIONS 4
+#endif
+
+#endif
+
+/* Type for length arguments in socket calls. */
+typedef unsigned int socklen_t;
+
+/* #include <asm/socket.h> arch-dependent defines */
+#include <linux/sockios.h> /* the SIOCxxx I/O controls */
+#include <pthread/posix.h>
+
+struct sockaddr {
+ unsigned short sa_family; /* address family, AF_xxx */
+ char sa_data[14]; /* 14 bytes of protocol address */
+};
+
+struct linger {
+ int l_onoff; /* Linger active */
+ int l_linger; /* How long to linger for */
+};
+
+struct msghdr
+{
+ void * msg_name; /* Socket name */
+ int msg_namelen; /* Length of name */
+ struct iovec * msg_iov; /* Data blocks */
+ int msg_iovlen; /* Number of blocks */
+ void * msg_accrights; /* Per protocol magic (eg BSD file descriptor passing) */
+ int msg_accrightslen;/* Length of rights list */
+};
+
+/* Socket types. */
+#define SOCK_STREAM 1 /* stream (connection) socket */
+#define SOCK_DGRAM 2 /* datagram (conn.less) socket */
+#define SOCK_RAW 3 /* raw socket */
+#define SOCK_RDM 4 /* reliably-delivered message */
+#define SOCK_SEQPACKET 5 /* sequential packet socket */
+#define SOCK_PACKET 10 /* linux specific way of */
+ /* getting packets at the dev */
+ /* level. For writing rarp and */
+ /* other similar things on the */
+ /* user level. */
+
+/* Supported address families. */
+#define AF_UNSPEC 0
+#define AF_UNIX 1 /* Unix domain sockets */
+#define AF_INET 2 /* Internet IP Protocol */
+#define AF_AX25 3 /* Amateur Radio AX.25 */
+#define AF_IPX 4 /* Novell IPX */
+#define AF_APPLETALK 5 /* Appletalk DDP */
+#define AF_NETROM 6 /* Amateur radio NetROM */
+#define AF_BRIDGE 7 /* Multiprotocol bridge */
+#define AF_AAL5 8 /* Reserved for Werner's ATM */
+#define AF_X25 9 /* Reserved for X.25 project */
+#define AF_INET6 10 /* IP version 6 */
+#define AF_MAX 12 /* For now.. */
+
+/* Protocol families, same as address families. */
+#define PF_UNSPEC AF_UNSPEC
+#define PF_UNIX AF_UNIX
+#define PF_INET AF_INET
+#define PF_AX25 AF_AX25
+#define PF_IPX AF_IPX
+#define PF_APPLETALK AF_APPLETALK
+#define PF_NETROM AF_NETROM
+#define PF_BRIDGE AF_BRIDGE
+#define PF_AAL5 AF_AAL5
+#define PF_X25 AF_X25
+#define PF_INET6 AF_INET6
+
+#define PF_MAX AF_MAX
+
+/* Maximum queue length specificable by listen. */
+#define SOMAXCONN 128
+
+/* Flags we can use with send/ and recv. */
+#define MSG_OOB 1
+#define MSG_PEEK 2
+#define MSG_DONTROUTE 4
+
+/* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */
+#define SOL_SOCKET 1
+#define SOL_IP 0
+#define SOL_IPX 256
+#define SOL_AX25 257
+#define SOL_ATALK 258
+#define SOL_NETROM 259
+#define SOL_TCP 6
+#define SOL_UDP 17
+
+/* For setsockoptions(2) */
+#define SO_DEBUG 1
+#define SO_REUSEADDR 2
+#define SO_TYPE 3
+#define SO_ERROR 4
+#define SO_DONTROUTE 5
+#define SO_BROADCAST 6
+#define SO_SNDBUF 7
+#define SO_RCVBUF 8
+#define SO_KEEPALIVE 9
+#define SO_OOBINLINE 10
+#define SO_NO_CHECK 11
+#define SO_PRIORITY 12
+#define SO_LINGER 13
+/* To add :#define SO_REUSEPORT 14 */
+
+
+#define IP_MULTICAST_IF 32
+#define IP_MULTICAST_TTL 33
+#define IP_MULTICAST_LOOP 34
+#define IP_ADD_MEMBERSHIP 35
+#define IP_DROP_MEMBERSHIP 36
+
+
+/* These need to appear somewhere around here */
+#define IP_DEFAULT_MULTICAST_TTL 1
+#define IP_DEFAULT_MULTICAST_LOOP 1
+#define IP_MAX_MEMBERSHIPS 20
+
+/* IPX options */
+#define IPX_TYPE 1
+
+/* TCP options - this way around because someone left a set in the c library includes */
+#define TCP_NODELAY 1
+#define TCP_MAXSEG 2
+
+/* The various priorities. */
+#define SOPRI_INTERACTIVE 0
+#define SOPRI_NORMAL 1
+#define SOPRI_BACKGROUND 2
+
+/*
+ * Functions
+ */
+
+__BEGIN_DECLS
+
+int accept __P_((int, struct sockaddr *, socklen_t *));
+int bind __P_((int, const struct sockaddr *, socklen_t));
+int connect __P_((int, const struct sockaddr *, socklen_t));
+int listen __P_((int, int));
+int socket __P_((int, int, int));
+
+int getsockopt __P_((int __s, int __level, int __optname,
+ void *__optval, socklen_t *__optlen));
+int setsockopt __P_((int __s, int __level, int __optname,
+ __const void *__optval, socklen_t optlen));
+int getsockname __P_((int __sockfd, struct sockaddr *__addr,
+ socklen_t *__paddrlen));
+int getpeername __P_((int __sockfd, struct sockaddr *__peer,
+ socklen_t *__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,
+ socklen_t __tolen));
+ssize_t recvfrom __P_((int __sockfd, void *__buff, size_t __len,
+ int __flags, struct sockaddr *__from,
+ socklen_t *__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
+
+#endif
+
+
+
+
diff --git a/mit-pthreads/machdep/linux-2.0/socketcall.h b/mit-pthreads/machdep/linux-2.0/socketcall.h
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/mit-pthreads/machdep/linux-2.0/socketcall.h
diff --git a/mit-pthreads/machdep/linux-2.0/timers.h b/mit-pthreads/machdep/linux-2.0/timers.h
new file mode 100755
index 00000000000..110cb27378c
--- /dev/null
+++ b/mit-pthreads/machdep/linux-2.0/timers.h
@@ -0,0 +1,71 @@
+/* ==== 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$
+ *
+ * Description : Basic timers header.
+ *
+ * 1.00 94/06/13 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS_TIMERS_H_
+#define _SYS_TIMERS_H_
+
+#include <pthread/config.h>
+#include <sys/types.h>
+#include <time.h>
+
+#ifndef _OS_HAS_TIMESPEC
+struct timespec {
+ time_t tv_sec;
+ long tv_nsec;
+};
+#endif
+
+#define TIMEVAL_TO_TIMESPEC(tv, ts) { \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000; \
+}
+#define TIMESPEC_TO_TIMEVAL(tv, ts) { \
+ (tv)->tv_sec = (ts)->tv_sec; \
+ (tv)->tv_usec = (ts)->tv_nsec / 1000; \
+}
+
+/*
+ * New functions
+ */
+
+__BEGIN_DECLS
+
+__END_DECLS
+
+#endif
diff --git a/mit-pthreads/machdep/linux-2.0/uio.h b/mit-pthreads/machdep/linux-2.0/uio.h
new file mode 100755
index 00000000000..67af5bf76e0
--- /dev/null
+++ b/mit-pthreads/machdep/linux-2.0/uio.h
@@ -0,0 +1,15 @@
+/* ==== uio.h ============================================================
+ * Copyright (c) 1994 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Correct Linux header file.
+ */
+
+#ifndef _PTHREAD_UIO_H_
+#define _PTHREAD_UIO_H_
+
+struct iovec {
+ void *iov_base;
+ size_t iov_len;
+};
+
+#endif
diff --git a/mit-pthreads/machdep/linux-2.0/wait.h b/mit-pthreads/machdep/linux-2.0/wait.h
new file mode 100755
index 00000000000..bcc28c5ef58
--- /dev/null
+++ b/mit-pthreads/machdep/linux-2.0/wait.h
@@ -0,0 +1,98 @@
+/* $NetBSD: wait.h,v 1.7 1994/06/29 06:46:23 cgd Exp $ */
+
+/*
+ * 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
+ */
+
+/*
+ * 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. Union wait is no supported with pthreads.
+ */
+#define __W_INT(i) (i)
+#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
+
+/* 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 */
+
+#define WSTOPPED __WSTOPPED
+#endif /* _POSIX_SOURCE */
+
+#include <sys/types.h>
+#include <sys/cdefs.h>
+
+#ifndef __WAIT_STATUS
+#define __WAIT_STATUS int *
+#endif
+
+__BEGIN_DECLS
+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
diff --git a/mit-pthreads/machdep/netbsd-0.9/dirent.h b/mit-pthreads/machdep/netbsd-0.9/dirent.h
new file mode 100755
index 00000000000..5226443f86b
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-0.9/dirent.h
@@ -0,0 +1,64 @@
+/*-
+ * 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/mit-pthreads/machdep/netbsd-1.0/__math.h b/mit-pthreads/machdep/netbsd-1.0/__math.h
new file mode 100755
index 00000000000..dc009d822f4
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.0/__math.h
@@ -0,0 +1,6 @@
+/*
+ * ANSI/POSIX
+ */
+extern char __infinity[];
+#define HUGE_VAL (*(double *) __infinity)
+
diff --git a/mit-pthreads/machdep/netbsd-1.0/__path.h b/mit-pthreads/machdep/netbsd-1.0/__path.h
new file mode 100755
index 00000000000..432494daafa
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.0/__path.h
@@ -0,0 +1,14 @@
+/*
+ * from: @(#)time.h 5.12 (Berkeley) 3/9/91
+ * $Id$
+ */
+
+#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/mit-pthreads/machdep/netbsd-1.0/__signal.h b/mit-pthreads/machdep/netbsd-1.0/__signal.h
new file mode 100755
index 00000000000..918955c9948
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.0/__signal.h
@@ -0,0 +1,8 @@
+#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/mit-pthreads/machdep/netbsd-1.0/__stdio.h b/mit-pthreads/machdep/netbsd-1.0/__stdio.h
new file mode 100755
index 00000000000..d60b9df7a54
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.0/__stdio.h
@@ -0,0 +1,8 @@
+
+#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/mit-pthreads/machdep/netbsd-1.0/__stdlib.h b/mit-pthreads/machdep/netbsd-1.0/__stdlib.h
new file mode 100755
index 00000000000..7b24491b892
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.0/__stdlib.h
@@ -0,0 +1,60 @@
+/*-
+ * 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$
+ */
+
+#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;
+#undef _BSD_WCHAR_T_
+#endif
+
+#ifndef __NORETURN
+#define __NORETURN
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#endif /* _STDLIB_H_ */
diff --git a/mit-pthreads/machdep/netbsd-1.0/__string.h b/mit-pthreads/machdep/netbsd-1.0/__string.h
new file mode 100755
index 00000000000..1ebee28e708
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.0/__string.h
@@ -0,0 +1,20 @@
+
+#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/mit-pthreads/machdep/netbsd-1.0/__time.h b/mit-pthreads/machdep/netbsd-1.0/__time.h
new file mode 100755
index 00000000000..16ea9d1f0dd
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.0/__time.h
@@ -0,0 +1,69 @@
+/*
+ * 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$
+ */
+
+#ifndef _SYS__TIME_H_
+#define _SYS__TIME_H_
+
+#include <machine/ansi.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(_ANSI_SOURCE)
+#define CLK_TCK 100
+#endif /* not ANSI */
+
+#endif /* !_SYS__TIME_H_ */
diff --git a/mit-pthreads/machdep/netbsd-1.0/__unistd.h b/mit-pthreads/machdep/netbsd-1.0/__unistd.h
new file mode 100755
index 00000000000..b4741ba6725
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.0/__unistd.h
@@ -0,0 +1,107 @@
+/*-
+ * 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$
+ */
+
+#ifndef _SYS___UNISTD_H_
+#define _SYS___UNISTD_H_
+
+#include <sys/types.h>
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+/* 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 ((unsigned char)'\377')
+
+/* 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/mit-pthreads/machdep/netbsd-1.0/compat.h b/mit-pthreads/machdep/netbsd-1.0/compat.h
new file mode 100755
index 00000000000..e7de318aa88
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.0/compat.h
@@ -0,0 +1,43 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/machdep/netbsd-1.0/dirent.h b/mit-pthreads/machdep/netbsd-1.0/dirent.h
new file mode 100755
index 00000000000..5226443f86b
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.0/dirent.h
@@ -0,0 +1,64 @@
+/*-
+ * 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/mit-pthreads/machdep/netbsd-1.0/errno.h b/mit-pthreads/machdep/netbsd-1.0/errno.h
new file mode 100755
index 00000000000..3da61d692a3
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.0/errno.h
@@ -0,0 +1,160 @@
+/* $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/mit-pthreads/machdep/netbsd-1.0/time.h b/mit-pthreads/machdep/netbsd-1.0/time.h
new file mode 100755
index 00000000000..f2cc61f8d75
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.0/time.h
@@ -0,0 +1,125 @@
+/* $NetBSD: time.h,v 1.8 1994/06/29 06:45:44 cgd Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 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.
+ *
+ * @(#)time.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _SYS_TIME_H_
+#define _SYS_TIME_H_
+
+/*
+ * Structure returned by gettimeofday(2) system call,
+ * and used in other calls.
+ */
+struct timeval {
+ long tv_sec; /* seconds */
+ long tv_usec; /* and microseconds */
+};
+
+/*
+ * Structure defined by POSIX.4 to be like a timeval.
+ */
+struct timespec {
+ long tv_sec; /* seconds */
+ long tv_nsec; /* and nanoseconds */
+};
+
+#define TIMEVAL_TO_TIMESPEC(tv, ts) { \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000; \
+}
+#define TIMESPEC_TO_TIMEVAL(tv, ts) { \
+ (tv)->tv_sec = (ts)->tv_sec; \
+ (tv)->tv_usec = (ts)->tv_nsec / 1000; \
+}
+
+struct timezone {
+ int tz_minuteswest; /* minutes west of Greenwich */
+ int tz_dsttime; /* type of dst correction */
+};
+#define DST_NONE 0 /* not on dst */
+#define DST_USA 1 /* USA style dst */
+#define DST_AUST 2 /* Australian style dst */
+#define DST_WET 3 /* Western European dst */
+#define DST_MET 4 /* Middle European dst */
+#define DST_EET 5 /* Eastern European dst */
+#define DST_CAN 6 /* Canada */
+
+/* Operations on timevals. */
+#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
+#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
+#define timercmp(tvp, uvp, cmp) \
+ (((tvp)->tv_sec == (uvp)->tv_sec) ? \
+ ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
+ ((tvp)->tv_sec cmp (uvp)->tv_sec))
+
+/*
+ * Names of the interval timers, and structure
+ * defining a timer setting.
+ */
+#define ITIMER_REAL 0
+#define ITIMER_VIRTUAL 1
+#define ITIMER_PROF 2
+
+struct itimerval {
+ struct timeval it_interval; /* timer interval */
+ struct timeval it_value; /* current value */
+};
+
+/*
+ * Getkerninfo clock information structure
+ */
+struct clockinfo {
+ int hz; /* clock frequency */
+ int tick; /* micro-seconds per hz tick */
+ int stathz; /* statistics clock frequency */
+ int profhz; /* profiling clock frequency */
+};
+
+#include <time.h>
+
+#ifndef _POSIX_SOURCE
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int adjtime __P_((const struct timeval *, struct timeval *));
+int getitimer __P_((int, struct itimerval *));
+int gettimeofday __P_((struct timeval *, struct timezone *));
+int setitimer __P_((int, const struct itimerval *, struct itimerval *));
+int settimeofday __P_((const struct timeval *, const struct timezone *));
+int utimes __P_((const char *, const struct timeval *));
+__END_DECLS
+#endif /* !POSIX */
+
+#endif /* !_SYS_TIME_H_ */
diff --git a/mit-pthreads/machdep/netbsd-1.0/timers.h b/mit-pthreads/machdep/netbsd-1.0/timers.h
new file mode 100755
index 00000000000..f9768c68c8f
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.0/timers.h
@@ -0,0 +1,45 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/machdep/netbsd-1.0/wait.h b/mit-pthreads/machdep/netbsd-1.0/wait.h
new file mode 100755
index 00000000000..c1cd876d052
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.0/wait.h
@@ -0,0 +1,158 @@
+/* $NetBSD: wait.h,v 1.7 1994/06/29 06:46:23 cgd Exp $ */
+
+/*
+ * 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
+ */
+
+/*
+ * 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
diff --git a/mit-pthreads/machdep/netbsd-1.1/__math.h b/mit-pthreads/machdep/netbsd-1.1/__math.h
new file mode 100755
index 00000000000..dc009d822f4
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.1/__math.h
@@ -0,0 +1,6 @@
+/*
+ * ANSI/POSIX
+ */
+extern char __infinity[];
+#define HUGE_VAL (*(double *) __infinity)
+
diff --git a/mit-pthreads/machdep/netbsd-1.1/__path.h b/mit-pthreads/machdep/netbsd-1.1/__path.h
new file mode 100755
index 00000000000..be7f9f6c658
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.1/__path.h
@@ -0,0 +1,14 @@
+/*
+ * from: @(#)time.h 5.12 (Berkeley) 3/9/91
+ * __path.h,v 1.1 1995/01/03 12:53:32 proven 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/mit-pthreads/machdep/netbsd-1.1/__signal.h b/mit-pthreads/machdep/netbsd-1.1/__signal.h
new file mode 100755
index 00000000000..e41e9218261
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.1/__signal.h
@@ -0,0 +1,20 @@
+#include <sys/signal.h>
+
+#if NSIG <= 32
+#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)
+
+#else /* XXX Netbsd >= 1.3H */
+#define __SIGEMPTYSET { 0, 0, 0, 0}
+#define __SIGFILLSET { 0xffffffff, 0xffffffff, \
+ 0xffffffff, 0xffffffff }
+#define __SIGMASK(n) (1 << (((n) - 1) & 31))
+#define __SIGWORD(n) (((n) - 1) >> 5)
+#define __SIGADDSET(s, n) ((s)->__bits[__SIGWORD(n)] |= __SIGMASK(n))
+#define __SIGDELSET(s, n) ((s)->__bits[__SIGWORD(n)] &= ~__SIGMASK(n))
+#define __SIGISMEMBER(s, n) (((s)->__bits[__SIGWORD(n)] & __SIGMASK(n)) != 0)
+
+#endif
diff --git a/mit-pthreads/machdep/netbsd-1.1/__stdio.h b/mit-pthreads/machdep/netbsd-1.1/__stdio.h
new file mode 100755
index 00000000000..d60b9df7a54
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.1/__stdio.h
@@ -0,0 +1,8 @@
+
+#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/mit-pthreads/machdep/netbsd-1.1/__stdlib.h b/mit-pthreads/machdep/netbsd-1.1/__stdlib.h
new file mode 100755
index 00000000000..189bb5e8799
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.1/__stdlib.h
@@ -0,0 +1,60 @@
+/*-
+ * 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
+ * __stdlib.h,v 1.1 1995/01/03 12:53:34 proven 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;
+#undef _BSD_WCHAR_T_
+#endif
+
+#ifndef __NORETURN
+#define __NORETURN
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#endif /* _STDLIB_H_ */
diff --git a/mit-pthreads/machdep/netbsd-1.1/__string.h b/mit-pthreads/machdep/netbsd-1.1/__string.h
new file mode 100755
index 00000000000..1ebee28e708
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.1/__string.h
@@ -0,0 +1,20 @@
+
+#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/mit-pthreads/machdep/netbsd-1.1/__time.h b/mit-pthreads/machdep/netbsd-1.1/__time.h
new file mode 100755
index 00000000000..27ceb815852
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.1/__time.h
@@ -0,0 +1,69 @@
+/*
+ * 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
+ * __time.h,v 1.1 1994/12/13 07:18:55 proven Exp
+ */
+
+#ifndef _SYS__TIME_H_
+#define _SYS__TIME_H_
+
+#include <machine/ansi.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(_ANSI_SOURCE)
+#define CLK_TCK 100
+#endif /* not ANSI */
+
+#endif /* !_SYS__TIME_H_ */
diff --git a/mit-pthreads/machdep/netbsd-1.1/__unistd.h b/mit-pthreads/machdep/netbsd-1.1/__unistd.h
new file mode 100755
index 00000000000..cea3165c229
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.1/__unistd.h
@@ -0,0 +1,107 @@
+/*-
+ * 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
+ * __unistd.h,v 1.1 1995/01/03 12:53:35 proven Exp
+ */
+
+#ifndef _SYS___UNISTD_H_
+#define _SYS___UNISTD_H_
+
+#include <sys/types.h>
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+/* 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 ((unsigned char)'\377')
+
+/* 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/mit-pthreads/machdep/netbsd-1.1/compat.h b/mit-pthreads/machdep/netbsd-1.1/compat.h
new file mode 100755
index 00000000000..f843795cc0a
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.1/compat.h
@@ -0,0 +1,43 @@
+/* ==== 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.
+ *
+ * compat.h,v 1.50 1994/08/08 03:44:05 proven 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/mit-pthreads/machdep/netbsd-1.1/dirent.h b/mit-pthreads/machdep/netbsd-1.1/dirent.h
new file mode 100755
index 00000000000..cf004a274d6
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.1/dirent.h
@@ -0,0 +1,95 @@
+/* $NetBSD: dirent.h,v 1.12 1996/04/09 20:55:25 cgd Exp $ */
+
+/*-
+ * Copyright (c) 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.
+ *
+ * @(#)dirent.h 8.3 (Berkeley) 8/10/94
+ */
+
+/*
+ * The dirent structure defines the format of directory entries returned by
+ * the getdirentries(2) system call.
+ *
+ * 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_int32_t d_fileno; /* file number of entry */
+ u_int16_t d_reclen; /* length of this record */
+ u_int8_t d_type; /* file type, see below */
+ u_int8_t 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
+};
+
+#ifdef PTHREAD_KERNEL
+#define d_ino d_fileno
+#endif
+
+/*
+ * File types
+ */
+#define DT_UNKNOWN 0
+#define DT_FIFO 1
+#define DT_CHR 2
+#define DT_DIR 4
+#define DT_BLK 6
+#define DT_REG 8
+#define DT_LNK 10
+#define DT_SOCK 12
+#define DT_WHT 14
+
+/*
+ * Convert between stat structure types and directory types.
+ */
+#define IFTODT(mode) (((mode) & 0170000) >> 12)
+#define DTTOIF(dirtype) ((dirtype) << 12)
+
+#if defined(_KERNEL)
+/*
+ * The DIRENT_SIZE macro gives the minimum record length which will hold
+ * the directory entry. This requires the amount of space in struct dirent
+ * without the d_name field, plus enough space for the name with a terminating
+ * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
+ */
+#define DIRENT_SIZE(dp) \
+ ((sizeof (struct dirent) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
+
+#endif /* !_KERNEL */
diff --git a/mit-pthreads/machdep/netbsd-1.1/errno.h b/mit-pthreads/machdep/netbsd-1.1/errno.h
new file mode 100755
index 00000000000..c313b578c5a
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.1/errno.h
@@ -0,0 +1,170 @@
+/* $NetBSD: errno.h,v 1.10 1996/01/20 01:33:53 jtc 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 _KERNEL
+extern int errno; /* global error number */
+
+#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
+extern int sys_nerr;
+extern const char *const sys_errlist[];
+#endif
+#endif
+
+#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 */
+
+#ifdef _KERNEL
+/* pseudo-errors returned inside kernel to modify return to process */
+#define ERESTART -1 /* restart syscall */
+#define EJUSTRETURN -2 /* don't modify regs, just return */
+#endif
diff --git a/mit-pthreads/machdep/netbsd-1.1/time.h b/mit-pthreads/machdep/netbsd-1.1/time.h
new file mode 100755
index 00000000000..a701db9c62e
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.1/time.h
@@ -0,0 +1,153 @@
+/* $NetBSD: time.h,v 1.17 1996/02/01 00:10:36 jtc Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 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.
+ *
+ * @(#)time.h 8.2 (Berkeley) 7/10/94
+ */
+
+#ifndef _SYS_TIME_H_
+#define _SYS_TIME_H_
+
+#include <sys/types.h>
+
+/*
+ * Structure returned by gettimeofday(2) system call,
+ * and used in other calls.
+ */
+struct timeval {
+ long tv_sec; /* seconds */
+ long tv_usec; /* and microseconds */
+};
+
+/*
+ * Structure defined by POSIX.1b to be like a timeval.
+ */
+struct timespec {
+ time_t tv_sec; /* seconds */
+ long tv_nsec; /* and nanoseconds */
+};
+
+#define TIMEVAL_TO_TIMESPEC(tv, ts) { \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000; \
+}
+#define TIMESPEC_TO_TIMEVAL(tv, ts) { \
+ (tv)->tv_sec = (ts)->tv_sec; \
+ (tv)->tv_usec = (ts)->tv_nsec / 1000; \
+}
+
+struct timezone {
+ int tz_minuteswest; /* minutes west of Greenwich */
+ int tz_dsttime; /* type of dst correction */
+};
+#define DST_NONE 0 /* not on dst */
+#define DST_USA 1 /* USA style dst */
+#define DST_AUST 2 /* Australian style dst */
+#define DST_WET 3 /* Western European dst */
+#define DST_MET 4 /* Middle European dst */
+#define DST_EET 5 /* Eastern European dst */
+#define DST_CAN 6 /* Canada */
+
+/* Operations on timevals. */
+#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
+#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
+#define timercmp(tvp, uvp, cmp) \
+ (((tvp)->tv_sec == (uvp)->tv_sec) ? \
+ ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
+ ((tvp)->tv_sec cmp (uvp)->tv_sec))
+#define timeradd(tvp, uvp, vvp) \
+ do { \
+ (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
+ (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
+ if ((vvp)->tv_usec >= 1000000) { \
+ (vvp)->tv_sec++; \
+ (vvp)->tv_usec -= 1000000; \
+ } \
+ } while (0)
+#define timersub(tvp, uvp, vvp) \
+ do { \
+ (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
+ (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
+ if ((vvp)->tv_usec < 0) { \
+ (vvp)->tv_sec--; \
+ (vvp)->tv_usec += 1000000; \
+ } \
+ } while (0)
+
+/*
+ * Names of the interval timers, and structure
+ * defining a timer setting.
+ */
+#define ITIMER_REAL 0
+#define ITIMER_VIRTUAL 1
+#define ITIMER_PROF 2
+
+struct itimerval {
+ struct timeval it_interval; /* timer interval */
+ struct timeval it_value; /* current value */
+};
+
+/*
+ * Getkerninfo clock information structure
+ */
+struct clockinfo {
+ int hz; /* clock frequency */
+ int tick; /* micro-seconds per hz tick */
+ int tickadj; /* clock skew rate for adjtime() */
+ int stathz; /* statistics clock frequency */
+ int profhz; /* profiling clock frequency */
+};
+
+#ifdef _KERNEL
+int itimerfix __P_((struct timeval *tv));
+int itimerdecr __P_((struct itimerval *itp, int usec));
+void microtime __P_((struct timeval *tv));
+#else /* !_KERNEL */
+#include <time.h>
+
+#ifndef _POSIX_SOURCE
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int adjtime __P_((const struct timeval *, struct timeval *));
+int getitimer __P_((int, struct itimerval *));
+int gettimeofday __P_((struct timeval *, struct timezone *));
+int setitimer __P_((int, const struct itimerval *, struct itimerval *));
+int settimeofday __P_((const struct timeval *, const struct timezone *));
+int utimes __P_((const char *, const struct timeval *));
+__END_DECLS
+#endif /* !POSIX */
+
+#endif /* !_KERNEL */
+
+#endif /* !_SYS_TIME_H_ */
diff --git a/mit-pthreads/machdep/netbsd-1.1/timers.h b/mit-pthreads/machdep/netbsd-1.1/timers.h
new file mode 100755
index 00000000000..b603b78e6b2
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.1/timers.h
@@ -0,0 +1,45 @@
+/* ==== 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.
+ *
+ * timers.h,v 1.50 1994/08/08 03:44:09 proven 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/mit-pthreads/machdep/netbsd-1.1/wait.h b/mit-pthreads/machdep/netbsd-1.1/wait.h
new file mode 100755
index 00000000000..0a1e9285e56
--- /dev/null
+++ b/mit-pthreads/machdep/netbsd-1.1/wait.h
@@ -0,0 +1,163 @@
+/* $NetBSD: wait.h,v 1.11 1996/04/09 20:55:51 cgd Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993, 1994
+ * 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.2 (Berkeley) 7/10/94
+ */
+
+#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 /* don't 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 /* !_SYS_WAIT_H_ */
diff --git a/mit-pthreads/machdep/openbsd-2.0/__math.h b/mit-pthreads/machdep/openbsd-2.0/__math.h
new file mode 100755
index 00000000000..27ed0f2575d
--- /dev/null
+++ b/mit-pthreads/machdep/openbsd-2.0/__math.h
@@ -0,0 +1,6 @@
+/*
+ * ANSI/POSIX
+ */
+extern char __infinity[];
+#define HUGE_VAL (*(double *) __infinity)
+
diff --git a/mit-pthreads/machdep/openbsd-2.0/__path.h b/mit-pthreads/machdep/openbsd-2.0/__path.h
new file mode 100755
index 00000000000..432494daafa
--- /dev/null
+++ b/mit-pthreads/machdep/openbsd-2.0/__path.h
@@ -0,0 +1,14 @@
+/*
+ * from: @(#)time.h 5.12 (Berkeley) 3/9/91
+ * $Id$
+ */
+
+#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/mit-pthreads/machdep/openbsd-2.0/__signal.h b/mit-pthreads/machdep/openbsd-2.0/__signal.h
new file mode 100755
index 00000000000..918955c9948
--- /dev/null
+++ b/mit-pthreads/machdep/openbsd-2.0/__signal.h
@@ -0,0 +1,8 @@
+#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/mit-pthreads/machdep/openbsd-2.0/__stdio.h b/mit-pthreads/machdep/openbsd-2.0/__stdio.h
new file mode 100755
index 00000000000..d60b9df7a54
--- /dev/null
+++ b/mit-pthreads/machdep/openbsd-2.0/__stdio.h
@@ -0,0 +1,8 @@
+
+#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/mit-pthreads/machdep/openbsd-2.0/__stdlib.h b/mit-pthreads/machdep/openbsd-2.0/__stdlib.h
new file mode 100755
index 00000000000..5ee2b8ed3d9
--- /dev/null
+++ b/mit-pthreads/machdep/openbsd-2.0/__stdlib.h
@@ -0,0 +1,66 @@
+/*-
+ * 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$
+ */
+
+#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/mit-pthreads/machdep/openbsd-2.0/__string.h b/mit-pthreads/machdep/openbsd-2.0/__string.h
new file mode 100755
index 00000000000..93d4fcf9dd2
--- /dev/null
+++ b/mit-pthreads/machdep/openbsd-2.0/__string.h
@@ -0,0 +1,21 @@
+
+#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/mit-pthreads/machdep/openbsd-2.0/__time.h b/mit-pthreads/machdep/openbsd-2.0/__time.h
new file mode 100755
index 00000000000..5c4b722bc3c
--- /dev/null
+++ b/mit-pthreads/machdep/openbsd-2.0/__time.h
@@ -0,0 +1,70 @@
+/*
+ * 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$
+ */
+
+#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/mit-pthreads/machdep/openbsd-2.0/__unistd.h b/mit-pthreads/machdep/openbsd-2.0/__unistd.h
new file mode 100755
index 00000000000..41244522461
--- /dev/null
+++ b/mit-pthreads/machdep/openbsd-2.0/__unistd.h
@@ -0,0 +1,109 @@
+/*-
+ * 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$
+ */
+
+#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/mit-pthreads/machdep/openbsd-2.0/compat.h b/mit-pthreads/machdep/openbsd-2.0/compat.h
new file mode 100755
index 00000000000..e7de318aa88
--- /dev/null
+++ b/mit-pthreads/machdep/openbsd-2.0/compat.h
@@ -0,0 +1,43 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/machdep/openbsd-2.0/dirent.h b/mit-pthreads/machdep/openbsd-2.0/dirent.h
new file mode 100755
index 00000000000..5226443f86b
--- /dev/null
+++ b/mit-pthreads/machdep/openbsd-2.0/dirent.h
@@ -0,0 +1,64 @@
+/*-
+ * 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/mit-pthreads/machdep/openbsd-2.0/errno.h b/mit-pthreads/machdep/openbsd-2.0/errno.h
new file mode 100755
index 00000000000..3da61d692a3
--- /dev/null
+++ b/mit-pthreads/machdep/openbsd-2.0/errno.h
@@ -0,0 +1,160 @@
+/* $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/mit-pthreads/machdep/openbsd-2.0/timers.h b/mit-pthreads/machdep/openbsd-2.0/timers.h
new file mode 100755
index 00000000000..f9768c68c8f
--- /dev/null
+++ b/mit-pthreads/machdep/openbsd-2.0/timers.h
@@ -0,0 +1,45 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/machdep/openbsd-2.0/wait.h b/mit-pthreads/machdep/openbsd-2.0/wait.h
new file mode 100755
index 00000000000..7861e3fa180
--- /dev/null
+++ b/mit-pthreads/machdep/openbsd-2.0/wait.h
@@ -0,0 +1,162 @@
+/*
+ * 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$
+ */
+
+#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/mit-pthreads/machdep/posix-alpha-osf1.h b/mit-pthreads/machdep/posix-alpha-osf1.h
new file mode 100644
index 00000000000..1d8bb6c5c4b
--- /dev/null
+++ b/mit-pthreads/machdep/posix-alpha-osf1.h
@@ -0,0 +1,7 @@
+#ifndef _PTHREAD_POSIX_H_
+#define _PTHREAD_POSIX_H_
+
+#define __WAIT_STATUS int *
+#include <pthread/types.h>
+
+#endif
diff --git a/mit-pthreads/machdep/posix-bsdi-1.1.h b/mit-pthreads/machdep/posix-bsdi-1.1.h
new file mode 100644
index 00000000000..4c56ea93a3b
--- /dev/null
+++ b/mit-pthreads/machdep/posix-bsdi-1.1.h
@@ -0,0 +1,34 @@
+/* ==== 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$
+ *
+ * 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>
+
+#define __NORETURN
+
+#ifndef __WAIT_STATUS
+#define __WAIT_STATUS int *
+#endif
+
+#endif
+
diff --git a/mit-pthreads/machdep/posix-bsdi-2.0.h b/mit-pthreads/machdep/posix-bsdi-2.0.h
new file mode 100644
index 00000000000..4c56ea93a3b
--- /dev/null
+++ b/mit-pthreads/machdep/posix-bsdi-2.0.h
@@ -0,0 +1,34 @@
+/* ==== 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$
+ *
+ * 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>
+
+#define __NORETURN
+
+#ifndef __WAIT_STATUS
+#define __WAIT_STATUS int *
+#endif
+
+#endif
+
diff --git a/mit-pthreads/machdep/posix-freebsd-1.1.h b/mit-pthreads/machdep/posix-freebsd-1.1.h
new file mode 100644
index 00000000000..e1a00e9efd1
--- /dev/null
+++ b/mit-pthreads/machdep/posix-freebsd-1.1.h
@@ -0,0 +1,33 @@
+/* ==== 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$
+ *
+ * 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>
+
+#define __NORETURN
+
+#ifndef __WAIT_STATUS
+#define __WAIT_STATUS int *
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/posix-freebsd-2.0.h b/mit-pthreads/machdep/posix-freebsd-2.0.h
new file mode 100644
index 00000000000..7bad77aba02
--- /dev/null
+++ b/mit-pthreads/machdep/posix-freebsd-2.0.h
@@ -0,0 +1,31 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/machdep/posix-hpux-10.20.h b/mit-pthreads/machdep/posix-hpux-10.20.h
new file mode 100644
index 00000000000..c7ecb429e79
--- /dev/null
+++ b/mit-pthreads/machdep/posix-hpux-10.20.h
@@ -0,0 +1,23 @@
+/* ==== posix.h ============================================================
+ * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * $Id$
+ *
+ * Description : Convert an Ultrix-4.2 system to a more or less POSIX system.
+ *
+ * 1.00 93/07/20 proven
+ * -Started coding this file.
+ */
+
+#ifndef _PTHREAD_POSIX_H_
+#define _PTHREAD_POSIX_H_
+
+/* Make sure we have size_t defined */
+#include <pthread/types.h>
+
+#ifndef __WAIT_STATUS
+#define __WAIT_STATUS int *
+#endif
+
+#endif
+
diff --git a/mit-pthreads/machdep/posix-hpux-9.03.h b/mit-pthreads/machdep/posix-hpux-9.03.h
new file mode 100644
index 00000000000..c7ecb429e79
--- /dev/null
+++ b/mit-pthreads/machdep/posix-hpux-9.03.h
@@ -0,0 +1,23 @@
+/* ==== posix.h ============================================================
+ * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * $Id$
+ *
+ * Description : Convert an Ultrix-4.2 system to a more or less POSIX system.
+ *
+ * 1.00 93/07/20 proven
+ * -Started coding this file.
+ */
+
+#ifndef _PTHREAD_POSIX_H_
+#define _PTHREAD_POSIX_H_
+
+/* Make sure we have size_t defined */
+#include <pthread/types.h>
+
+#ifndef __WAIT_STATUS
+#define __WAIT_STATUS int *
+#endif
+
+#endif
+
diff --git a/mit-pthreads/machdep/posix-i386-sco-3.2v5.h b/mit-pthreads/machdep/posix-i386-sco-3.2v5.h
new file mode 100644
index 00000000000..ab91311612d
--- /dev/null
+++ b/mit-pthreads/machdep/posix-i386-sco-3.2v5.h
@@ -0,0 +1,35 @@
+/* ==== 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.
+ *
+ * posix-freebsd-2.0.h,v 1.1 1995/03/01 01:21:30 proven 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 __NORETURN
+#define __NORETURN
+#endif
+
+#ifndef __WAIT_STATUS
+#define __WAIT_STATUS int *
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/posix-irix-5.2.h b/mit-pthreads/machdep/posix-irix-5.2.h
new file mode 100644
index 00000000000..d387bbbbf69
--- /dev/null
+++ b/mit-pthreads/machdep/posix-irix-5.2.h
@@ -0,0 +1,31 @@
+/* ==== posix.h ============================================================
+ * Copyright (c) 1995 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Convert an IRIX-5.2 system to a more or less POSIX system.
+ *
+ * $Id$
+ *
+ * 1.00 95/06/01 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/mit-pthreads/machdep/posix-linux-1.0.h b/mit-pthreads/machdep/posix-linux-1.0.h
new file mode 100644
index 00000000000..7f665d6b44a
--- /dev/null
+++ b/mit-pthreads/machdep/posix-linux-1.0.h
@@ -0,0 +1,31 @@
+/* ==== posix.h ============================================================
+ * Copyright (c) 1993, 1994 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * $Id$
+ *
+ * Description : Convert a Linux-1.0 system to a more or less POSIX system.
+ * Mostly POSIX already
+ */
+
+#ifndef _PTHREAD_POSIX_H_
+#define _PTHREAD_POSIX_H_
+
+#include <sys/cdefs.h>
+
+/* Make sure we have size_t defined */
+#include <pthread/types.h>
+
+#define __INLINE extern inline
+/*
+ * OK now do stuff to make the code compile.
+ * Every OS has its own prototypes for each function
+ */
+#ifdef malloc
+#undef malloc
+#endif
+
+#ifdef free
+#undef free
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/posix-linux-2.0.h b/mit-pthreads/machdep/posix-linux-2.0.h
new file mode 100644
index 00000000000..7f665d6b44a
--- /dev/null
+++ b/mit-pthreads/machdep/posix-linux-2.0.h
@@ -0,0 +1,31 @@
+/* ==== posix.h ============================================================
+ * Copyright (c) 1993, 1994 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * $Id$
+ *
+ * Description : Convert a Linux-1.0 system to a more or less POSIX system.
+ * Mostly POSIX already
+ */
+
+#ifndef _PTHREAD_POSIX_H_
+#define _PTHREAD_POSIX_H_
+
+#include <sys/cdefs.h>
+
+/* Make sure we have size_t defined */
+#include <pthread/types.h>
+
+#define __INLINE extern inline
+/*
+ * OK now do stuff to make the code compile.
+ * Every OS has its own prototypes for each function
+ */
+#ifdef malloc
+#undef malloc
+#endif
+
+#ifdef free
+#undef free
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/posix-netbsd-0.9.h b/mit-pthreads/machdep/posix-netbsd-0.9.h
new file mode 100644
index 00000000000..00ff2efa327
--- /dev/null
+++ b/mit-pthreads/machdep/posix-netbsd-0.9.h
@@ -0,0 +1,22 @@
+/* ==== 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$
+ *
+ * 1.00 93/07/20 proven
+ * -Started coding this file.
+ */
+
+#ifndef _PTHREAD_POSIX_H_
+#define _PTHREAD_POSIX_H_
+
+#include <sys/cdefs.h>
+
+/* Make sure we have size_t defined */
+#include <pthread/types.h>
+
+#define __NORETURN
+
+#endif
diff --git a/mit-pthreads/machdep/posix-netbsd-1.0.h b/mit-pthreads/machdep/posix-netbsd-1.0.h
new file mode 100644
index 00000000000..7bad77aba02
--- /dev/null
+++ b/mit-pthreads/machdep/posix-netbsd-1.0.h
@@ -0,0 +1,31 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/machdep/posix-netbsd-1.1.h b/mit-pthreads/machdep/posix-netbsd-1.1.h
new file mode 100644
index 00000000000..f4ff1dfae05
--- /dev/null
+++ b/mit-pthreads/machdep/posix-netbsd-1.1.h
@@ -0,0 +1,31 @@
+/* ==== 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.
+ *
+ * posix-netbsd-1.0.h,v 1.53 1995/02/17 03:41:34 proven 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/mit-pthreads/machdep/posix-openbsd-2.0.h b/mit-pthreads/machdep/posix-openbsd-2.0.h
new file mode 100644
index 00000000000..7bad77aba02
--- /dev/null
+++ b/mit-pthreads/machdep/posix-openbsd-2.0.h
@@ -0,0 +1,31 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/machdep/posix-romp-bsd.h b/mit-pthreads/machdep/posix-romp-bsd.h
new file mode 100644
index 00000000000..7825622b064
--- /dev/null
+++ b/mit-pthreads/machdep/posix-romp-bsd.h
@@ -0,0 +1,33 @@
+/* ==== posix.h ============================================================
+ * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Convert a system to a more or less POSIX system.
+ *
+ * 1.00 93/07/20 proven
+ * -Started coding this file.
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#endif
+
+#ifndef O_NONBLOCK
+#ifdef FNDELAY
+#define O_NONBLOCK FNDELAY
+#endif
+#endif
+
+#ifndef O_ACCMODE
+#define O_ACCMODE (O_RDONLY|O_RDWR|O_WRONLY)
+#endif
+
+#ifndef S_ISREG
+#define S_ISREG(x) ((x & S_IFMT) == S_IFREG)
+#endif
+
+#ifndef ENOSYS
+#define ENOSYS EINVAL
+#endif
+
+/* Make sure we have size_t defined */
+#include <pthread/types.h>
diff --git a/mit-pthreads/machdep/posix-sco-3.2v5.h b/mit-pthreads/machdep/posix-sco-3.2v5.h
new file mode 100644
index 00000000000..ab91311612d
--- /dev/null
+++ b/mit-pthreads/machdep/posix-sco-3.2v5.h
@@ -0,0 +1,35 @@
+/* ==== 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.
+ *
+ * posix-freebsd-2.0.h,v 1.1 1995/03/01 01:21:30 proven 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 __NORETURN
+#define __NORETURN
+#endif
+
+#ifndef __WAIT_STATUS
+#define __WAIT_STATUS int *
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/posix-sunos-4.1.3.h b/mit-pthreads/machdep/posix-sunos-4.1.3.h
new file mode 100644
index 00000000000..719386bc558
--- /dev/null
+++ b/mit-pthreads/machdep/posix-sunos-4.1.3.h
@@ -0,0 +1,27 @@
+/* ==== posix.h ============================================================
+ * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * $Id$
+ *
+ * Description : Do the right thing for a sunos 4.1.3 system.
+ *
+ * 1.00 93/07/20 proven
+ * -Started coding this file.
+ */
+
+#ifndef _PTHREAD_POSIX_H_
+#ifndef __WAIT_STATUS
+#define __WAIT_STATUS int *
+#endif
+
+#define _PTHREAD_POSIX_H_
+
+#include <sys/cdefs.h>
+
+/* Make sure we have size_t defined */
+#include <pthread/types.h>
+
+extern long strtol();
+extern unsigned long strtoul();
+
+#endif
diff --git a/mit-pthreads/machdep/posix-sunos-5.3.h b/mit-pthreads/machdep/posix-sunos-5.3.h
new file mode 100644
index 00000000000..9fb765d60c3
--- /dev/null
+++ b/mit-pthreads/machdep/posix-sunos-5.3.h
@@ -0,0 +1,22 @@
+/* ==== posix.h ============================================================
+ * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * $Id$
+ *
+ * Description : Do the right thing for a sunos 4.1.3 system.
+ *
+ * 1.00 93/07/20 proven
+ * -Started coding this file.
+ */
+
+#ifndef _PTHREAD_POSIX_H_
+#define _PTHREAD_POSIX_H_
+
+/* Make sure we have size_t defined */
+#include <pthread/types.h>
+
+#ifndef __WAIT_STATUS
+#define __WAIT_STATUS int *
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/posix-sunos-5.5.h b/mit-pthreads/machdep/posix-sunos-5.5.h
new file mode 100644
index 00000000000..9fb765d60c3
--- /dev/null
+++ b/mit-pthreads/machdep/posix-sunos-5.5.h
@@ -0,0 +1,22 @@
+/* ==== posix.h ============================================================
+ * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * $Id$
+ *
+ * Description : Do the right thing for a sunos 4.1.3 system.
+ *
+ * 1.00 93/07/20 proven
+ * -Started coding this file.
+ */
+
+#ifndef _PTHREAD_POSIX_H_
+#define _PTHREAD_POSIX_H_
+
+/* Make sure we have size_t defined */
+#include <pthread/types.h>
+
+#ifndef __WAIT_STATUS
+#define __WAIT_STATUS int *
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/posix-ultrix-4.2.h b/mit-pthreads/machdep/posix-ultrix-4.2.h
new file mode 100644
index 00000000000..f21aec23ea3
--- /dev/null
+++ b/mit-pthreads/machdep/posix-ultrix-4.2.h
@@ -0,0 +1,24 @@
+/* ==== posix.h ============================================================
+ * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * $Id$
+ *
+ * Description : Convert an Ultrix-4.2 system to a more or less POSIX system.
+ *
+ * 1.00 93/07/20 proven
+ * -Started coding this file.
+ */
+
+#ifndef _PTHREAD_POSIX_H_
+#define _PTHREAD_POSIX_H_
+
+#include <sys/cdefs.h>
+
+/* Make sure we have size_t defined */
+#include <pthread/types.h>
+
+#ifndef __WAIT_STATUS
+#define __WAIT_STATUS int *
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/sco-3.2v5/__math.h b/mit-pthreads/machdep/sco-3.2v5/__math.h
new file mode 100755
index 00000000000..4852683fcbf
--- /dev/null
+++ b/mit-pthreads/machdep/sco-3.2v5/__math.h
@@ -0,0 +1,219 @@
+/* Copyright 1994-1995 The Santa Cruz Operation, Inc. All Rights Reserved. */
+
+
+#if defined(_NO_PROTOTYPE) /* Old, crufty environment */
+#include <oldstyle/__math.h>
+#elif defined(_XOPEN_SOURCE) || defined(_XPG4_VERS) /* Xpg4 environment */
+#include <xpg4/__math.h>
+#elif defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) /* Posix environment */
+#include <posix/__math.h>
+#elif _STRICT_ANSI /* Pure Ansi/ISO environment */
+#include <ansi/__math.h>
+#elif defined(_SCO_ODS_30) /* Old, Tbird compatible environment */
+#include <ods_30_compat/__math.h>
+#else /* Normal, default environment */
+/*
+ * Portions Copyright (C) 1983-1995 The Santa Cruz Operation, Inc.
+ * All Rights Reserved.
+ *
+ * The information in this file is provided for the exclusive use of
+ * the licensees of The Santa Cruz Operation, Inc. Such users have the
+ * right to use, modify, and incorporate this code into other products
+ * for purposes authorized by the license agreement provided they include
+ * this notice and the associated copyright notice with any such product.
+ * The information in this file is provided "AS IS" without warranty.
+ */
+
+/* Portions Copyright (c) 1990, 1991, 1992, 1993 UNIX System Laboratories, Inc. */
+/* Portions Copyright (c) 1979 - 1990 AT&T */
+/* All Rights Reserved */
+
+/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
+/* UNIX System Laboratories, Inc. */
+/* The copyright notice above does not evidence any */
+/* actual or intended publication of such source code. */
+
+#ifndef ___MATH_H
+#define ___MATH_H
+
+#pragma comment(exestr, "xpg4plus @(#) math.h 20.1 94/12/04 ")
+
+#pragma pack(4)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+extern double acos(double);
+extern double asin(double);
+extern double atan(double);
+extern double atan2(double, double);
+extern double cos(double);
+extern double sin(double);
+extern double tan(double);
+
+extern double cosh(double);
+extern double sinh(double);
+extern double tanh(double);
+
+extern double exp(double);
+extern double frexp(double, int *);
+extern double ldexp(double, int);
+extern double log(double);
+extern double log10(double);
+extern double modf(double, double *);
+
+extern double pow(double, double);
+extern double sqrt(double);
+
+extern double ceil(double);
+extern double fabs(double);
+extern double floor(double);
+extern double fmod(double, double);
+
+#ifndef HUGE_VAL
+extern const double __huge_val;
+#define HUGE_VAL (+__huge_val)
+#endif
+
+
+extern double erf(double);
+extern double erfc(double);
+extern double gamma(double);
+extern double hypot(double, double);
+extern double j0(double);
+extern double j1(double);
+extern double jn(int, double);
+extern double y0(double);
+extern double y1(double);
+extern double yn(int, double);
+extern double lgamma(double);
+extern int isnan(double);
+
+#define MAXFLOAT ((float)3.40282346638528860e+38)
+
+
+
+#define HUGE MAXFLOAT
+
+/*
+ * The following are all legal as XPG4 external functions but must only
+ * be declared in the non standards environments as they conflict with
+ * the user name space
+ */
+
+extern long double frexpl(long double, int *);
+extern long double ldexpl(long double, int);
+extern long double modfl(long double, long double *);
+
+extern float acosf(float);
+extern float asinf(float);
+extern float atanf(float);
+extern float atan2f(float, float);
+extern float cosf(float);
+extern float sinf(float);
+extern float tanf(float);
+
+extern float coshf(float);
+extern float sinhf(float);
+extern float tanhf(float);
+
+extern float expf(float);
+extern float logf(float);
+extern float log10f(float);
+
+extern float powf(float, float);
+extern float sqrtf(float);
+
+extern float ceilf(float);
+extern float fabsf(float);
+extern float floorf(float);
+extern float fmodf(float, float);
+extern float modff(float, float *);
+
+/* These are all extensions from XPG4 */
+
+extern double atof(const char *);
+extern double scalb(double, double);
+extern double logb(double);
+extern double log1p(double);
+extern double nextafter(double, double);
+extern double acosh(double);
+extern double asinh(double);
+extern double atanh(double);
+extern double cbrt(double);
+extern double copysign(double, double);
+extern double expm1(double);
+extern int ilogb(double);
+extern double remainder(double, double);
+extern double rint(double);
+extern int unordered(double, double);
+extern int finite(double);
+
+extern long double scalbl(long double, long double);
+extern long double logbl(long double);
+extern long double nextafterl(long double, long double);
+extern int unorderedl(long double, long double);
+extern int finitel(long double);
+
+
+
+
+extern int signgam;
+
+#define M_E 2.7182818284590452354
+#define M_LOG2E 1.4426950408889634074
+#define M_LOG10E 0.43429448190325182765
+#define M_LN2 0.69314718055994530942
+#define M_LN10 2.30258509299404568402
+#define M_PI 3.14159265358979323846
+#define M_PI_2 1.57079632679489661923
+#define M_PI_4 0.78539816339744830962
+#define M_1_PI 0.31830988618379067154
+#define M_2_PI 0.63661977236758134308
+#define M_2_SQRTPI 1.12837916709551257390
+#define M_SQRT2 1.41421356237309504880
+#define M_SQRT1_2 0.70710678118654752440
+
+
+
+#define _ABS(x) ((x) < 0 ? -(x) : (x))
+
+#define _REDUCE(TYPE, X, XN, C1, C2) { \
+ double x1 = (double)(TYPE)X, x2 = X - x1; \
+ X = x1 - (XN) * (C1); X += x2; X -= (XN) * (C2); }
+
+#define DOMAIN 1
+#define SING 2
+#define OVERFLOW 3
+#define UNDERFLOW 4
+#define TLOSS 5
+#define PLOSS 6
+
+#define _POLY1(x, c) ((c)[0] * (x) + (c)[1])
+#define _POLY2(x, c) (_POLY1((x), (c)) * (x) + (c)[2])
+#define _POLY3(x, c) (_POLY2((x), (c)) * (x) + (c)[3])
+#define _POLY4(x, c) (_POLY3((x), (c)) * (x) + (c)[4])
+#define _POLY5(x, c) (_POLY4((x), (c)) * (x) + (c)[5])
+#define _POLY6(x, c) (_POLY5((x), (c)) * (x) + (c)[6])
+#define _POLY7(x, c) (_POLY6((x), (c)) * (x) + (c)[7])
+#define _POLY8(x, c) (_POLY7((x), (c)) * (x) + (c)[8])
+#define _POLY9(x, c) (_POLY8((x), (c)) * (x) + (c)[9])
+
+
+#ifdef __cplusplus
+}
+inline int sqr(int i) {return(i*i);}
+inline double sqr(double i) {return(i*i);}
+
+#endif /* __cplusplus */
+
+#pragma pack()
+
+#if __cplusplus && !defined(PI)
+#define PI M_PI
+#endif /* __cplusplus */
+
+#endif /* _MATH_H */
+#endif
diff --git a/mit-pthreads/machdep/sco-3.2v5/__signal.h b/mit-pthreads/machdep/sco-3.2v5/__signal.h
new file mode 100755
index 00000000000..6a33d37a261
--- /dev/null
+++ b/mit-pthreads/machdep/sco-3.2v5/__signal.h
@@ -0,0 +1,109 @@
+/* Copyright 1994-1995 The Santa Cruz Operation, Inc. All Rights Reserved. */
+
+
+#if defined(_NO_PROTOTYPE) /* Old, crufty environment */
+#include <sys/oldstyle/signal.h>
+#elif defined(_XOPEN_SOURCE) || defined(_XPG4_VERS) /* Xpg4 environment */
+#include <xpg4/signal.h>
+#elif defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) /* Posix environment */
+#include <sys/posix/__signal.h>
+#elif _STRICT_ANSI /* Pure Ansi/ISO environment */
+#include <sys/ansi/signal.h>
+#elif defined(_SCO_ODS_30) /* Old, Tbird compatible environment */
+#include <sys/ods_30_compat/signal.h>
+#else /* Normal, default environment */
+/*
+ * Portions Copyright (C) 1983-1995 The Santa Cruz Operation, Inc.
+ * All Rights Reserved.
+ *
+ * The information in this file is provided for the exclusive use of
+ * the licensees of The Santa Cruz Operation, Inc. Such users have the
+ * right to use, modify, and incorporate this code into other products
+ * for purposes authorized by the license agreement provided they include
+ * this notice and the associated copyright notice with any such product.
+ * The information in this file is provided "AS IS" without warranty.
+ */
+
+/* Portions Copyright (c) 1990, 1991, 1992, 1993 UNIX System Laboratories, Inc. */
+/* Portions Copyright (c) 1979 - 1990 AT&T */
+/* All Rights Reserved */
+
+/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
+/* UNIX System Laboratories, Inc. */
+/* The copyright notice above does not evidence any */
+/* actual or intended publication of such source code. */
+
+#ifndef ___SIGNAL_H
+#define ___SIGNAL_H
+
+#pragma comment(exestr, "xpg4plus @(#) signal.h 20.3 94/12/19 ")
+
+#ifndef _SIG_ATOMIC_T
+#define _SIG_ATOMIC_T
+ /* atomic entity for signal handling */
+typedef int sig_atomic_t;
+#endif
+
+extern const char * const _sys_siglist[];
+extern const int _sys_nsig;
+
+#ifndef _SYS_SIGNAL_H
+#include <sys/signal.h>
+#endif
+
+#define SignalBad ((SignalHandler)-1)
+#define SignalDefault ((SignalHandler)0)
+#define SignalIgnore ((SignalHandler)1)
+
+#define __sigmask(sig) (1 << ((sig) - 1))
+#define __SIGEMPTYSET (~SIGALL)
+#define __SIGFILLSET SIGALL
+#define __SIGADDSET(s,n) ((*s) |= (__sigmask(n)))
+#define __SIGDELSET(s,n) ((*s) &= ~(__sigmask(n)))
+#define __SIGISMEMBER(s,n) ((*s) & (__sigmask(n)))
+
+#if !defined(_SYS_TYPES_H)
+#include <sys/types.h>
+#endif
+
+
+#if __cplusplus
+extern "C" {
+#endif
+
+extern void (*signal(int, void(*)(int)))(int);
+extern int raise(int);
+
+extern void (*bsd_signal(int, void(*)(int)))(int);
+extern int ( *ssignal( int, int(*)(int) ) )(int);
+extern void ( *sigset( int, void(*)(int) ) )(int);
+extern int killpg(pid_t, int);
+#ifdef SS_ONSTACK /* Not defined on old versions of the OS */
+extern int sigaltstack(const stack_t *, stack_t *);
+extern int sigstack(struct sigstack *, struct sigstack *);
+#endif
+extern int sighold(int);
+extern int sigignore(int);
+extern int siginterrupt(int, int);
+extern int sigpause(int);
+extern int sigrelse(int);
+
+extern int (sigfillset)(sigset_t *);
+extern int (sigemptyset)(sigset_t *);
+extern int (sigaddset)(sigset_t *, int);
+extern int (sigdelset)(sigset_t *, int);
+extern int (sigismember)(const sigset_t *, int);
+extern int sigpending(sigset_t *);
+extern int sigsuspend(const sigset_t *);
+extern int sigprocmask(int, const sigset_t *, sigset_t *);
+extern int kill(pid_t, int);
+extern int sigaction(int, const struct sigaction *, struct sigaction *);
+
+#if __cplusplus
+};
+#endif
+
+
+#endif /* ___SIGNAL_H */
+
+#endif
diff --git a/mit-pthreads/machdep/sco-3.2v5/__stdio.h b/mit-pthreads/machdep/sco-3.2v5/__stdio.h
new file mode 100755
index 00000000000..f19672980ec
--- /dev/null
+++ b/mit-pthreads/machdep/sco-3.2v5/__stdio.h
@@ -0,0 +1,113 @@
+/* Copyright 1994-1995 The Santa Cruz Operation, Inc. All Rights Reserved. */
+
+
+#if defined(_NO_PROTOTYPE) /* Old, crufty environment */
+#include <oldstyle/__stdio.h>
+#elif defined(_XOPEN_SOURCE) || defined(_XPG4_VERS) /* Xpg4 environment */
+#include <xpg4/__stdio.h>
+#elif defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) /* Posix environment */
+#include <posix/__stdio.h>
+#elif _STRICT_ANSI /* Pure Ansi/ISO environment */
+#include <ansi/__stdio.h>
+#elif defined(_SCO_ODS_30) /* Old, Tbird compatible environment */
+#include <ods_30_compat/__stdio.h>
+#else /* Normal, default environment */
+/*
+ * Portions Copyright (C) 1984-1995 The Santa Cruz Operation, Inc.
+ * All Rights Reserved.
+ *
+ * The information in this file is provided for the exclusive use of
+ * the licensees of The Santa Cruz Operation, Inc. Such users have the
+ * right to use, modify, and incorporate this code into other products
+ * for purposes authorized by the license agreement provided they include
+ * this notice and the associated copyright notice with any such product.
+ * The information in this file is provided "AS IS" without warranty.
+ */
+
+/* Portions Copyright (c) 1990, 1991, 1992, 1993 UNIX System Laboratories, Inc. */
+/* Portions Copyright (c) 1979 - 1990 AT&T */
+/* All Rights Reserved */
+
+/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
+/* UNIX System Laboratories, Inc. */
+/* The copyright notice above does not evidence any */
+/* actual or intended publication of such source code. */
+
+#ifndef ___STDIO_H
+#define ___STDIO_H
+
+#pragma comment(exestr, "xpg4plus @(#) stdio.h 20.1 94/12/04 ")
+
+#pragma pack(4)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef unsigned int size_t;
+#endif
+
+#ifndef _FPOS_T
+#define _FPOS_T
+typedef long fpos_t;
+#endif
+
+#ifndef _WCHAR_T
+#define _WCHAR_T
+typedef long wchar_t;
+#endif
+
+#ifndef _WINT_T
+#define _WINT_T
+typedef long wint_t;
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif /* NULL */
+
+#ifndef EOF
+#define EOF (-1)
+#endif
+
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+
+#ifndef TMP_MAX
+#define TMP_MAX 17576 /* 26 * 26 * 26 */
+#endif
+
+#define BUFSIZ 1024 /* default buffer size */
+
+
+#define _IOEOF 0020 /* EOF reached on read */
+#define _IOERR 0040 /* I/O error from system */
+
+#define _IOREAD 0001 /* currently reading */
+#define _IOWRT 0002 /* currently writing */
+#define _IORW 0200 /* opened for reading and writing */
+#define _IOMYBUF 0010 /* stdio malloc()'d buffer */
+
+#define _SBFSIZ 8
+
+#define L_cuserid 9
+
+/* Non name space polluting version of above */
+#define _P_tmpdir "/usr/tmp/"
+
+#ifndef _VA_LIST
+#define _VA_LIST char *
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#pragma pack()
+
+#endif /* ___STDIO_H */
+#endif
diff --git a/mit-pthreads/machdep/sco-3.2v5/__stdlib.h b/mit-pthreads/machdep/sco-3.2v5/__stdlib.h
new file mode 100755
index 00000000000..db6a8a56151
--- /dev/null
+++ b/mit-pthreads/machdep/sco-3.2v5/__stdlib.h
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 1984-1995 The Santa Cruz Operation, Inc.
+ * All Rights Reserved.
+ *
+ * The information in this file is provided for the exclusive use of
+ * the licensees of The Santa Cruz Operation, Inc. Such users have the
+ * right to use, modify, and incorporate this code into other products
+ * for purposes authorized by the license agreement provided they include
+ * this notice and the associated copyright notice with any such product.
+ * The information in this file is provided "AS IS" without warranty.
+ */
+
+/* Portions Copyright (c) 1990, 1991, 1992, 1993 UNIX System Laboratories, Inc. */
+/* Portions Copyright (c) 1979 - 1990 AT&T */
+/* All Rights Reserved */
+
+/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
+/* UNIX System Laboratories, Inc. */
+/* The copyright notice above does not evidence any */
+/* actual or intended publication of such source code. */
+
+#ifndef ___STDLIB_H
+#define ___STDLIB_H
+
+#pragma comment(exestr, "posix @(#) stdlib.h 20.1 94/12/04 ")
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma pack(4)
+
+#ifndef _DIV_T
+#define _DIV_T
+typedef struct
+{
+ int quot;
+ int rem;
+} div_t;
+#endif
+
+#ifndef _LDIV_T
+#define _LDIV_T
+typedef struct
+{
+ long quot;
+ long rem;
+} ldiv_t;
+#endif
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef unsigned int size_t;
+#endif
+
+#if !defined(_SSIZE_T)
+#define _SSIZE_T
+typedef int ssize_t;
+#endif
+
+#ifndef _WCHAR_T
+#define _WCHAR_T
+typedef long wchar_t;
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif /* NULL */
+
+#define EXIT_FAILURE 1
+#define EXIT_SUCCESS 0
+#define RAND_MAX 077777
+
+
+
+extern unsigned char __ctype[];
+
+#define MB_CUR_MAX ((int)__ctype[520])
+
+extern double atof(const char *);
+extern int atoi(const char *);
+extern long atol(const char *);
+extern double strtod(const char *, char **);
+extern float strtof(const char *, char **);
+extern long strtol(const char *, char **, int);
+extern unsigned long strtoul(const char *, char **, int);
+
+extern int rand(void);
+extern void srand(unsigned int);
+
+extern void *calloc(size_t, size_t);
+extern void free(void *);
+extern void *malloc(size_t);
+extern void *realloc(void *, size_t);
+
+extern void abort(void);
+extern void exit(int);
+extern char *getenv(const char *);
+extern int system(const char *);
+
+extern void *bsearch(const void *, const void *, size_t, size_t,
+ int (*)(const void *, const void *));
+extern void qsort(void *, size_t, size_t,
+ int (*)(const void *, const void *));
+
+#ifdef __cplusplus
+#ifndef _ABS_INL
+#define _ABS_INL
+inline int (abs)(int i) {return (i > 0) ? i : -i;}
+#endif
+#else
+extern int (abs)(int); /* Protect from macro definitions */
+#endif
+
+extern div_t div(int, int);
+extern long labs(long);
+extern ldiv_t ldiv(long, long);
+
+extern int mbtowc(wchar_t *, const char *, size_t);
+extern int mblen(const char *, size_t);
+extern int wctomb(char *, wchar_t);
+
+extern size_t mbstowcs(wchar_t *, const char *, size_t);
+extern size_t wcstombs(char *, const wchar_t *, size_t);
+
+
+
+
+#define mblen(s, n) mbtowc((wchar_t *)0, s, n)
+
+#ifdef __cplusplus
+}
+#endif
+
+#pragma pack()
+
+#endif /* ___STDLIB_H */
diff --git a/mit-pthreads/machdep/sco-3.2v5/__string.h b/mit-pthreads/machdep/sco-3.2v5/__string.h
new file mode 100755
index 00000000000..e4bb93afe5a
--- /dev/null
+++ b/mit-pthreads/machdep/sco-3.2v5/__string.h
@@ -0,0 +1,125 @@
+/* Copyright 1994-1995 The Santa Cruz Operation, Inc. All Rights Reserved. */
+
+
+#if defined(_NO_PROTOTYPE) /* Old, crufty environment */
+#include <oldstyle/string.h>
+#elif defined(_XOPEN_SOURCE) || defined(_XPG4_VERS) /* Xpg4 environment */
+#include <xpg4/string.h>
+#elif defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) /* Posix environment */
+#include <posix/string.h>
+#elif _STRICT_ANSI /* Pure Ansi/ISO environment */
+#include <ansi/string.h>
+#elif defined(_SCO_ODS_30) /* Old, Tbird compatible environment */
+#include <ods_30_compat/string.h>
+#else /* Normal, default environment */
+/*
+ * Portions Copyright (C) 1983-1995 The Santa Cruz Operation, Inc.
+ * All Rights Reserved.
+ *
+ * The information in this file is provided for the exclusive use of
+ * the licensees of The Santa Cruz Operation, Inc. Such users have the
+ * right to use, modify, and incorporate this code into other products
+ * for purposes authorized by the license agreement provided they include
+ * this notice and the associated copyright notice with any such product.
+ * The information in this file is provided "AS IS" without warranty.
+ */
+
+/* Portions Copyright (c) 1990, 1991, 1992, 1993 UNIX System Laboratories, Inc. */
+/* Portions Copyright (c) 1979 - 1990 AT&T */
+/* All Rights Reserved */
+
+/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
+/* UNIX System Laboratories, Inc. */
+/* The copyright notice above does not evidence any */
+/* actual or intended publication of such source code. */
+
+#ifndef ___STRING_H
+#define ___STRING_H
+
+#pragma comment(exestr, "xpg4plus @(#) string.h 20.1 94/12/04 ")
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef unsigned int size_t;
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif /* NULL */
+
+
+
+extern void *memchr(const void *, int, size_t);
+extern void *memcpy(void *, const void *, size_t);
+extern void *memccpy(void *, const void *, int, size_t);
+extern void *memmove(void *, const void *, size_t);
+extern void *memset(void *, int, size_t);
+
+extern char *strchr(const char *, int);
+extern char *strcpy(char *, const char *);
+extern char *strncpy(char *, const char *, size_t);
+extern char *strcat(char *, const char *);
+extern char *strncat(char *, const char *, size_t);
+extern char *strpbrk(const char *, const char *);
+extern char *strrchr(const char *, int);
+extern char *strstr(const char *, const char *);
+extern char *strtok(char *, const char *);
+extern char *strtok_r(char *, const char *, char **);
+extern char *strerror(int);
+extern char *strlist(char *, const char *, ...);
+
+extern int memcmp(const void *, const void *, size_t);
+extern int strcmp(const char *, const char *);
+extern int strcoll(const char *, const char *);
+extern int strncmp(const char *, const char *, size_t);
+
+extern void perror(const char *);
+extern char *strdup(const char *);
+extern int strncoll(const char *, const char *, int);
+extern size_t strnxfrm(char *, const char *, size_t , int);
+
+extern size_t strxfrm(char *, const char *, size_t);
+extern size_t strcspn(const char *, const char *);
+extern size_t strspn(const char *, const char *);
+extern size_t strlen(const char *);
+
+#ifdef __USLC__
+#pragma int_to_unsigned strcspn
+#pragma int_to_unsigned strspn
+#pragma int_to_unsigned strlen
+#endif
+
+#if !defined(__cplusplus) && defined(__USLC__)
+/* Use intrinsic ??? */
+#ifndef strlen
+#define strlen __std_hdr_strlen
+#endif
+#ifndef strcpy
+#define strcpy __std_hdr_strcpy
+#endif
+#ifndef strncpy
+#define strncpy __std_hdr_strncpy
+#endif
+#endif
+
+
+extern int ffs(int);
+/*
+ * The following two functions were withdrawn in XPG3,
+ * but are provided for backwards compatibility.
+ */
+extern int nl_strcmp(char *, char *);
+extern int nl_strncmp(char *, char *, int n);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ___STRING_H */
+#endif
diff --git a/mit-pthreads/machdep/sco-3.2v5/__time.h b/mit-pthreads/machdep/sco-3.2v5/__time.h
new file mode 100755
index 00000000000..4aeee737601
--- /dev/null
+++ b/mit-pthreads/machdep/sco-3.2v5/__time.h
@@ -0,0 +1,141 @@
+/* Copyright 1994-1995 The Santa Cruz Operation, Inc. All Rights Reserved. */
+
+
+#if defined(_NO_PROTOTYPE) /* Old, crufty environment */
+#include <oldstyle/time.h>
+#elif defined(_XOPEN_SOURCE) || defined(_XPG4_VERS) /* Xpg4 environment */
+#include <xpg4/time.h>
+#elif defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) /* Posix environment */
+#include <posix/time.h>
+#elif _STRICT_ANSI /* Pure Ansi/ISO environment */
+#include <ansi/time.h>
+#elif defined(_SCO_ODS_30) /* Old, Tbird compatible environment */
+#include <ods_30_compat/time.h>
+#else /* Normal, default environment */
+/*
+ * Portions Copyright (C) 1983-1995 The Santa Cruz Operation, Inc.
+ * All Rights Reserved.
+ *
+ * The information in this file is provided for the exclusive use of
+ * the licensees of The Santa Cruz Operation, Inc. Such users have the
+ * right to use, modify, and incorporate this code into other products
+ * for purposes authorized by the license agreement provided they include
+ * this notice and the associated copyright notice with any such product.
+ * The information in this file is provided "AS IS" without warranty.
+ */
+
+/* Portions Copyright (c) 1990, 1991, 1992, 1993 UNIX System Laboratories, Inc. */
+/* Portions Copyright (c) 1979 - 1990 AT&T */
+/* All Rights Reserved */
+
+/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
+/* UNIX System Laboratories, Inc. */
+/* The copyright notice above does not evidence any */
+/* actual or intended publication of such source code. */
+
+#ifndef ___TIME_H
+#define ___TIME_H
+
+#pragma comment(exestr, "xpg4plus @(#) time.h 20.2 95/01/04 ")
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif /* NULL */
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef unsigned int size_t;
+#endif
+#ifndef _CLOCK_T
+#define _CLOCK_T
+typedef long clock_t;
+#endif
+#ifndef _TIME_T
+#define _TIME_T
+typedef long time_t;
+#endif
+
+#ifdef _POSIXTIMERS
+#include <sys/sudstime.h>
+#endif
+
+#define CLOCKS_PER_SEC 1000000 /* As required by XPG4 and friends */
+
+#pragma pack(4)
+
+#ifndef _STRUCT_TM
+#define _STRUCT_TM
+struct tm
+{
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+#define LTZNMAX 50
+ long tm_tzadj;
+ char tm_name[LTZNMAX]; /* name of timezone */
+};
+
+#pragma pack()
+#endif /* _STRUCT_TM */
+
+
+extern clock_t clock(void);
+extern double difftime(time_t, time_t);
+extern time_t mktime(struct tm *);
+extern time_t time(time_t *);
+extern char *asctime(const struct tm *);
+extern char *ctime (const time_t *);
+extern struct tm *gmtime(const time_t *);
+extern struct tm *localtime(const time_t *);
+extern size_t strftime(char *, size_t, const char *, const struct tm *);
+
+
+extern void tzset(void);
+extern char *tzname[];
+
+#ifndef CLK_TCK
+#define CLK_TCK _sysconf(2) /* 2 is _SC_CLK_TCK */
+#endif
+
+extern long timezone;
+extern int daylight;
+extern char *strptime(const char *, const char *, struct tm *);
+
+
+
+
+#include <sys/timeb.h>
+extern int ftime ( struct timeb * );
+extern char * nl_cxtime( long *, char * );
+extern char * nl_ascxtime( struct tm *, char * );
+extern int cftime(char *, const char *, const time_t *);
+extern int ascftime(char *, const char *, const struct tm *);
+extern long altzone;
+extern struct tm *getdate(const char *);
+extern int getdate_err;
+extern char *asctime_r(const struct tm *, char *,int);
+extern char *ctime_r(const time_t *, char *,int);
+extern struct tm *localtime_r(const time_t *, struct tm *);
+extern struct tm *gmtime_r(const time_t *, struct tm *);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifndef difftime
+#define difftime(t1, t0) ((double)((t1) - (t0)))
+#endif
+
+#endif /* ___TIME_H */
+#endif
diff --git a/mit-pthreads/machdep/sco-3.2v5/__unistd.h b/mit-pthreads/machdep/sco-3.2v5/__unistd.h
new file mode 100755
index 00000000000..408886301f5
--- /dev/null
+++ b/mit-pthreads/machdep/sco-3.2v5/__unistd.h
@@ -0,0 +1,48 @@
+/*-
+ * 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
+ * __unistd.h,v 1.1 1995/01/03 12:54:54 proven Exp
+ */
+
+#ifndef ___UNISTD_H_
+#define ___UNISTD_H_
+
+#include <sys/types.h>
+#include <stddef.h>
+
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 1024
+#endif
+
+#endif
+
diff --git a/mit-pthreads/machdep/sco-3.2v5/compat.h b/mit-pthreads/machdep/sco-3.2v5/compat.h
new file mode 100755
index 00000000000..3befbffa68d
--- /dev/null
+++ b/mit-pthreads/machdep/sco-3.2v5/compat.h
@@ -0,0 +1,46 @@
+/* ==== 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.
+ *
+ * compat.h,v 1.52 1995/10/20 09:32:56 proven Exp
+ *
+ * Description : Basic timers header.
+ *
+ * 1.00 94/06/13 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS_COMPAT_H_
+#define _SYS_COMPAT_H_
+
+#include <sys/types.h>
+
+#define omsghdr msghdr
+#endif
diff --git a/mit-pthreads/machdep/sco-3.2v5/dirent.h b/mit-pthreads/machdep/sco-3.2v5/dirent.h
new file mode 100755
index 00000000000..6f6804590bb
--- /dev/null
+++ b/mit-pthreads/machdep/sco-3.2v5/dirent.h
@@ -0,0 +1,145 @@
+/* Copyright 1994-1995 The Santa Cruz Operation, Inc. All Rights Reserved. */
+
+
+#if defined(_NO_PROTOTYPE) /* Old, crufty environment */
+#include <oldstyle/dirent.h>
+#elif defined(_XOPEN_SOURCE) || defined(_XPG4_VERS) /* Xpg4 environment */
+#include <xpg4/dirent.h>
+#elif defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) /* Posix environment */
+#include <posix/dirent.h>
+#elif defined(_SCO_ODS_30) /* Old, Tbird compatible environment */
+#include <ods_30_compat/dirent.h>
+#else /* Normal, default environment */
+/*
+ * Portions Copyright (C) 1983-1995 The Santa Cruz Operation, Inc.
+ * All Rights Reserved.
+ *
+ * The information in this file is provided for the exclusive use of
+ * the licensees of The Santa Cruz Operation, Inc. Such users have the
+ * right to use, modify, and incorporate this code into other products
+ * for purposes authorized by the license agreement provided they include
+ * this notice and the associated copyright notice with any such product.
+ * The information in this file is provided "AS IS" without warranty.
+ */
+
+/* Portions Copyright (c) 1990, 1991, 1992, 1993 UNIX System Laboratories, Inc. */
+/* Portions Copyright (c) 1979 - 1990 AT&T */
+/* All Rights Reserved */
+
+/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
+/* UNIX System Laboratories, Inc. */
+/* The copyright notice above does not evidence any */
+/* actual or intended publication of such source code. */
+
+#ifndef _DIRENT_H
+#define _DIRENT_H
+
+#pragma comment(exestr, "xpg4plus @(#) dirent.h 20.1 94/12/04 ")
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma pack(4)
+
+#define MAXNAMLEN 512 /* maximum filename length */
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 1024
+#endif
+#undef DIRBLKSIZ
+#define DIRBLKSIZ 1048 /* buffer size for fs-indep. dirs */
+
+#ifndef _SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#ifndef _SYS_DIRENT_H
+#define _SYS_DIRENT_H
+#ifdef __STDC__
+#pragma comment(exestr, "@(#) dirent.h 25.8 94/09/22 ")
+#else
+#ident "@(#) dirent.h 25.8 94/09/22 "
+#endif
+/*
+ * Copyright (C) 1988-1994 The Santa Cruz Operation, Inc.
+ * All Rights Reserved.
+ * The information in this file is provided for the exclusive use of
+ * the licensees of The Santa Cruz Operation, Inc. Such users have the
+ * right to use, modify, and incorporate this code into other products
+ * for purposes authorized by the license agreement provided they include
+ * this notice and the associated copyright notice with any such product.
+ * The information in this file is provided "AS IS" without warranty.
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988 AT&T */
+/* All Rights Reserved */
+
+/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */
+/* The copyright notice above does not evidence any */
+/* actual or intended publication of such source code. */
+
+/* #ident "@)#(head.sys:dirent.h 1.3" */
+
+/*
+ * The following structure defines the file
+ * system independent directory entry.
+ *
+ */
+
+#include <sys/types.h>
+
+#ifdef _M_I386
+#pragma pack(4)
+#else
+#pragma pack(2)
+#endif
+
+#ifdef _INKERNEL
+/*
+ * dirent used by the kernel
+ */
+struct dirent {
+ ino32_t d_ino; /* inode number of entry */
+ off_t d_off; /* offset of disk directory entry */
+ unsigned short d_reclen; /* length of this record */
+ char d_name[MAXNAMLEN+1]; /* name of file */
+};
+
+#else /* !_INKERNEL */
+/*
+ * dirent as used by application code
+ * For now leave the declaration as is. When the new development system
+ * is implemented, ino_t may be ushort or ulong. If ino_t is ulong, there
+ * will be no d_pad field.
+ */
+struct dirent /* data from readdir() */
+ {
+#if defined(_IBCS2)
+ long d_ino;
+#else /* !_IBCS2 */
+ ino_t d_ino; /* inode number of entry */
+#if defined(_INO_16_T)
+ short d_pad; /* because ino_t is ushort */
+#endif /* defined(_INO_16_T) */
+#endif /* defined(_IBCS2) */
+ off_t d_off; /* offset of disk directory entry */
+ unsigned short d_reclen; /* length of this record */
+ char d_name[MAXNAMLEN+1]; /* name of file */
+ };
+#endif /* _INKERNEL */
+
+typedef struct dirent dirent_t;
+
+#pragma pack()
+#endif /* _SYS_DIRENT_H */
+
+#define d_fileno d_ino
+#define d_namlen d_reclen
+
+#ifdef __cplusplus
+}
+#endif
+
+#pragma pack()
+
+#endif /* _DIRENT_H */
+#endif
diff --git a/mit-pthreads/machdep/sco-3.2v5/posix/__signal.h b/mit-pthreads/machdep/sco-3.2v5/posix/__signal.h
new file mode 100755
index 00000000000..5680fc1491a
--- /dev/null
+++ b/mit-pthreads/machdep/sco-3.2v5/posix/__signal.h
@@ -0,0 +1,69 @@
+/*
+ * Portions Copyright (C) 1983-1995 The Santa Cruz Operation, Inc.
+ * All Rights Reserved.
+ *
+ * The information in this file is provided for the exclusive use of
+ * the licensees of The Santa Cruz Operation, Inc. Such users have the
+ * right to use, modify, and incorporate this code into other products
+ * for purposes authorized by the license agreement provided they include
+ * this notice and the associated copyright notice with any such product.
+ * The information in this file is provided "AS IS" without warranty.
+ */
+
+/* Portions Copyright (c) 1990, 1991, 1992, 1993 UNIX System Laboratories, Inc. */
+/* Portions Copyright (c) 1979 - 1990 AT&T */
+/* All Rights Reserved */
+
+/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
+/* UNIX System Laboratories, Inc. */
+/* The copyright notice above does not evidence any */
+/* actual or intended publication of such source code. */
+
+#ifndef ___SIGNAL_H
+#define ___SIGNAL_H
+
+#pragma comment(exestr, "posix @(#) signal.h 20.3 94/12/19 ")
+
+#ifndef _SIG_ATOMIC_T
+#define _SIG_ATOMIC_T
+ /* atomic entity for signal handling */
+typedef int sig_atomic_t;
+#endif
+
+
+#ifndef _SYS_SIGNAL_H
+#include <sys/signal.h>
+#endif
+
+#if !defined(_SYS_TYPES_H)
+#include <sys/types.h>
+#endif
+
+
+#if __cplusplus
+extern "C" {
+#endif
+
+extern void (*signal(int, void(*)(int)))(int);
+extern int raise(int);
+
+
+
+extern int (sigfillset)(sigset_t *);
+extern int (sigemptyset)(sigset_t *);
+extern int (sigaddset)(sigset_t *, int);
+extern int (sigdelset)(sigset_t *, int);
+extern int (sigismember)(const sigset_t *, int);
+extern int sigpending(sigset_t *);
+extern int sigsuspend(const sigset_t *);
+extern int sigprocmask(int, const sigset_t *, sigset_t *);
+extern int kill(pid_t, int);
+extern int sigaction(int, const struct sigaction *, struct sigaction *);
+
+#if __cplusplus
+};
+#endif
+
+
+#endif /* ___SIGNAL_H */
+
diff --git a/mit-pthreads/machdep/sco-3.2v5/socket.h b/mit-pthreads/machdep/sco-3.2v5/socket.h
new file mode 100755
index 00000000000..4a53c7176f9
--- /dev/null
+++ b/mit-pthreads/machdep/sco-3.2v5/socket.h
@@ -0,0 +1,490 @@
+/* @(#)socket.h 6.23 7/18/94 - STREAMware TCP/IP source */
+/*
+ * Copyrighted as an unpublished work.
+ * (c) Copyright 1987-1994 Legent Corporation
+ * All rights reserved.
+ *
+ * RESTRICTED RIGHTS
+ *
+ * These programs are supplied under a license. They may be used,
+ * disclosed, and/or copied only as permitted under such license
+ * agreement. Any copy must contain the above copyright notice and
+ * this restricted rights notice. Use, copying, and/or disclosure
+ * of the programs is strictly prohibited unless otherwise provided
+ * in the license agreement.
+ *
+ */
+/* SCCS IDENTIFICATION */
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, 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'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef __sys_socket_h
+#define __sys_socket_h
+
+#if !defined(FD_SETSIZE)
+/* Pick up select stuff from standard system include */
+#include <sys/types.h>
+#endif
+
+/* socket.h 6.1 83/07/29 */
+
+/*
+ * Definitions related to sockets: types, address families, options.
+ */
+
+/*
+ * Types
+ */
+#define SOCK_STREAM 1 /* stream socket */
+#define SOCK_DGRAM 2 /* datagram socket */
+#define SOCK_RAW 3 /* raw-protocol interface */
+#define SOCK_RDM 4 /* reliably-delivered message */
+#define SOCK_SEQPACKET 5 /* sequenced packet stream */
+
+/*
+ * Option flags per-socket.
+ */
+#define SO_DEBUG 0x0001 /* turn on debugging info recording */
+#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
+#define SO_REUSEADDR 0x0004 /* allow local address reuse */
+#define SO_KEEPALIVE 0x0008 /* keep connections alive */
+#define SO_DONTROUTE 0x0010 /* just use interface addresses */
+#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
+#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
+#define SO_LINGER 0x0080 /* linger on close if data present */
+#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
+#define SO_ORDREL 0x0200 /* give use orderly release */
+#define SO_IMASOCKET 0x0400 /* use socket semantics (affects bind) */
+#define SO_MGMT 0x0800 /* => it is used for mgmt. purposes */
+#define SO_REUSEPORT 0x1000 /* allow local port reuse */
+
+/*
+ * Additional options, not kept in so_options.
+ */
+#define SO_SNDBUF 0x1001 /* send buffer size */
+#define SO_RCVBUF 0x1002 /* receive buffer size */
+#define SO_SNDLOWAT 0x1003 /* send low-water mark */
+#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
+#define SO_SNDTIMEO 0x1005 /* send timeout */
+#define SO_RCVTIMEO 0x1006 /* receive timeout */
+#define SO_ERROR 0x1007 /* get error status and clear */
+#define SO_TYPE 0x1008 /* get socket type */
+#define SO_PROTOTYPE 0x1009 /* get/set protocol type */
+
+/*
+ * Structure used for manipulating linger option.
+ */
+struct linger {
+ int l_onoff; /* option on/off */
+ int l_linger; /* linger time */
+};
+
+/*
+ * Level number for (get/set)sockopt() to apply to socket itself.
+ */
+#define SOL_SOCKET 0xffff /* options for socket level */
+
+/*
+ * An option specification consists of an opthdr, followed by the value of
+ * the option. An options buffer contains one or more options. The len
+ * field of opthdr specifies the length of the option value in bytes. This
+ * length must be a multiple of sizeof(long) (use OPTLEN macro).
+ */
+
+struct opthdr {
+ long level; /* protocol level affected */
+ long name; /* option to modify */
+ long len; /* length of option value */
+};
+
+#define OPTLEN(x) ((((x) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
+#define OPTVAL(opt) ((char *)(opt + 1))
+
+#if defined(INKERNEL) || defined(_KERNEL) || defined(_INKERNEL)
+/*
+ * the optdefault structure is used for internal tables of option default
+ * values.
+ */
+struct optdefault {
+ int optname;/* the option */
+ char *val; /* ptr to default value */
+ int len; /* length of value */
+};
+
+/*
+ * the opproc structure is used to build tables of options processing
+ * functions for in_dooptions().
+ */
+struct opproc {
+ int level; /* options level this function handles */
+ int (*func) (); /* the function */
+};
+#endif
+
+/*
+ * Address families.
+ */
+#define AF_UNSPEC 0 /* unspecified */
+#define AF_UNIX 1 /* local to host (pipes, portals) */
+#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
+#define AF_IMPLINK 3 /* arpanet imp addresses */
+#define AF_PUP 4 /* pup protocols: e.g. BSP */
+#define AF_CHAOS 5 /* mit CHAOS protocols */
+#define AF_NS 6 /* XEROX NS protocols */
+#define AF_ISO 7 /* ISO protocols */
+#define AF_OSI AF_ISO
+#define AF_ECMA 8 /* european computer manufacturers */
+#define AF_DATAKIT 9 /* datakit protocols */
+#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
+#define AF_SNA 11 /* IBM SNA */
+#define AF_DECnet 12 /* DECnet */
+#define AF_DLI 13 /* Direct data link interface */
+#define AF_LAT 14 /* LAT */
+#define AF_HYLINK 15 /* NSC Hyperchannel */
+#define AF_APPLETALK 16 /* Apple Talk */
+#define AF_ROUTE 17 /* Internal Routing Protocol */
+#define AF_LINK 18 /* Link layer interface */
+#define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */
+
+#define AF_MAX 20
+
+/*
+ * Structure used by kernel to store most addresses.
+ */
+struct sockaddr {
+ u_short sa_family; /* address family */
+ char sa_data[14]; /* up to 14 bytes of direct address */
+};
+
+/*
+ * Structure used by kernel to pass protocol information in raw sockets.
+ */
+struct sockproto {
+ unsigned short sp_family; /* address family */
+ unsigned short sp_protocol; /* protocol */
+};
+
+/*
+ * Protocol families, same as address families for now.
+ */
+#define PF_UNSPEC AF_UNSPEC
+#define PF_UNIX AF_UNIX
+#define PF_INET AF_INET
+#define PF_IMPLINK AF_IMPLINK
+#define PF_PUP AF_PUP
+#define PF_CHAOS AF_CHAOS
+#define PF_NS AF_NS
+#define PF_NBS AF_NBS
+#define PF_ECMA AF_ECMA
+#define PF_DATAKIT AF_DATAKIT
+#define PF_CCITT AF_CCITT
+#define PF_SNA AF_SNA
+#define PF_DECnet AF_DECnet
+#define PF_DLI AF_DLI
+#define PF_LAT AF_LAT
+#define PF_HYLINK AF_HYLINK
+#define PF_APPLETALK AF_APPLETALK
+#define PF_ROUTE AF_ROUTE
+#define PF_LINK AF_LINK
+#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */
+
+#define PF_MAX AF_MAX
+
+/*
+ * Maximum queue length specifiable by listen.
+ */
+#define SOMAXCONN 5
+
+/*
+ * Message header for recvmsg and sendmsg calls.
+ * Used value-result for recmvsg, value only for sendmsg.
+ */
+struct msghdr {
+ caddr_t msg_name; /* optional address */
+ u_int msg_namelen; /* size of address */
+ struct iovec *msg_iov; /* scatter/gather array */
+ u_int msg_iovlen; /* # elements msg_iov */
+ caddr_t msg_control; /* ancillary data, see below */
+ u_int msg_controllen; /* ancillary data buffer len */
+ int msg_flags; /* flags on received message */
+};
+#define msg_accrights msg_control
+#define msg_accrightslen msg_controllen
+
+#define MSG_OOB 0x1 /* process out-of-band data */
+#define MSG_PEEK 0x2 /* peek at incoming message */
+#define MSG_DONTROUTE 0x4 /* send without using routing tables */
+#define MSG_EOR 0x8 /* data completes record */ /*notused*/
+#define MSG_TRUNC 0x10 /* data discarded before delivery */
+#define MSG_CTRUNC 0x20 /* control data lost before delivery */
+#define MSG_WAITALL 0x40 /* wait for full request or error */ /*notused*/
+
+#define MSG_MAXIOVLEN 16
+
+/*
+ * Header for ancillary data objects in msg_control buffer.
+ * Used for additional information with/about a datagram
+ * not expressible by flags. The format is a sequence
+ * of message elements headed by cmsghdr structures.
+ * In STREAMware, we shuffle the fields around a little from what
+ * they were in net-2, so that they line up the same as an opthdr
+ * which simplifies our socket implementation amazingly.
+ *
+ * Unfortunately, the opthdrs don't include their own length, which the
+ * cmsghdrs do. What this means is that TLI programmers will not be
+ * able to take something returned using these macros and immediately give
+ * it back to the stack. The size of the struct cmsghdr will have to be
+ * subtracted out.
+ * There doesn't seem to be a way to avoid this, since several applications
+ * look into the cmsg_len field and won't work if it doesn't include the size
+ * of the struct cmsghdr.
+ */
+struct cmsghdr {
+ int cmsg_level; /* originating protocol */
+ int cmsg_type; /* protocol-specific type */
+ u_int cmsg_len; /* data byte count, including hdr */
+/* followed by u_char cmsg_data[]; */
+};
+
+/* given pointer to struct adatahdr, return pointer to data */
+#define CMSG_DATA(cmsg) ((u_char *)((cmsg) + 1))
+
+/* given pointer to struct adatahdr, return pointer to next adatahdr */
+#define CMSG_NXTHDR(mhdr, cmsg) \
+ (((caddr_t)(cmsg) + (cmsg)->cmsg_len + sizeof(struct cmsghdr) > \
+ (mhdr)->msg_control + (mhdr)->msg_controllen) ? \
+ (struct cmsghdr *)NULL : \
+ (struct cmsghdr *)((caddr_t)(cmsg) + OPTLEN((cmsg)->cmsg_len)))
+
+#define CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control)
+
+/* "Socket"-level control message types: */
+#define SCM_RIGHTS 0x01 /* access rights (array of int) */
+
+/*
+ * This ioctl code uses BSD style ioctls to avoid copyin/out problems.
+ * Ioctls have the command encoded in the lower word, and the size of any in
+ * or out parameters in the upper word. The high 2 bits of the upper word
+ * are used to encode the in/out status of the parameter; for now we restrict
+ * parameters to at most 128 bytes.
+ */
+#define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */
+#define IOC_VOID 0x20000000 /* no parameters */
+#define IOC_OUT 0x40000000 /* copy out parameters */
+#define IOC_IN 0x80000000 /* copy in parameters */
+#define IOC_INOUT (IOC_IN|IOC_OUT)
+/* the 0x20000000 is so we can distinguish new ioctls from old */
+#define _IOS(x,y) (IOC_VOID|(x<<8)|y)
+#define _IOSR(x,y,t) (IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
+#define _IOSW(x,y,t) (IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
+/* this should be _IOSRW, but stdio got there first */
+#define _IOSWR(x,y,t) (IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
+
+/*
+ * Socket ioctl commands
+ */
+
+#define SIOCSHIWAT _IOSW('S', 1, int) /* set high watermark */
+#define SIOCGHIWAT _IOSR('S', 2, int) /* get high watermark */
+#define SIOCSLOWAT _IOSW('S', 3, int) /* set low watermark */
+#define SIOCGLOWAT _IOSR('S', 4, int) /* get low watermark */
+#define SIOCATMARK _IOSR('S', 5, int) /* at oob mark? */
+#define SIOCSPGRP _IOSW('S', 6, int) /* set process group */
+#define SIOCGPGRP _IOSR('S', 7, int) /* get process group */
+#define FIONREAD _IOSR('S', 8, int) /* BSD compatibilty */
+#define FIONBIO _IOSW('S', 9, int) /* BSD compatibilty */
+#define FIOASYNC _IOSW('S', 10, int) /* BSD compatibilty */
+#define SIOCPROTO _IOSW('S', 11, struct socknewproto) /* link proto */
+#define SIOCGETNAME _IOSR('S', 12, struct sockaddr) /* getsockname */
+#define SIOCGETPEER _IOSR('S', 13, struct sockaddr) /* getpeername */
+#define IF_UNITSEL _IOSW('S', 14, int) /* set unit number */
+#define SIOCXPROTO _IOS('S', 15) /* empty proto table */
+#define SIOCSHRDTYPE _IOSW('S', 16, int) /* set hardware type */
+
+#define SIOCADDRT _IOSW('R', 9, struct ortentry) /* add route */
+#define SIOCDELRT _IOSW('R', 10, struct ortentry) /* delete route */
+
+#define SIOCSIFADDR _IOSW('I', 11, struct ifreq) /* set ifnet address */
+#define SIOCGIFADDR _IOSWR('I', 12, struct ifreq) /* get ifnet address */
+#define SIOCSIFDSTADDR _IOSW('I', 13, struct ifreq) /* set p-p address */
+#define SIOCGIFDSTADDR _IOSWR('I', 14, struct ifreq) /* get p-p address */
+#define SIOCSIFFLAGS _IOSW('I', 15, struct ifreq) /* set ifnet flags */
+#define SIOCGIFFLAGS _IOSWR('I', 16, struct ifreq) /* get ifnet flags */
+#define SIOCGIFCONF _IOSWR('I', 17, struct ifconf) /* get ifnet list */
+
+#define SIOCSIFMTU _IOSW('I', 21, struct ifreq) /* get if_mtu */
+#define SIOCGIFMTU _IOSWR('I', 22, struct ifreq) /* set if_mtu */
+
+
+#define SIOCGIFBRDADDR _IOSWR('I', 32, struct ifreq) /* get broadcast addr */
+#define SIOCSIFBRDADDR _IOSW('I', 33, struct ifreq) /* set broadcast addr */
+#define SIOCGIFNETMASK _IOSWR('I', 34, struct ifreq) /* get net addr mask */
+#define SIOCSIFNETMASK _IOSW('I', 35, struct ifreq) /* set net addr mask */
+#define SIOCGIFMETRIC _IOSWR('I', 36, struct ifreq) /* get IF metric */
+#define SIOCSIFMETRIC _IOSW('I', 37, struct ifreq) /* set IF metric */
+
+#define SIOCSARP _IOSW('I', 38, struct arpreq) /* set arp entry */
+#define SIOCGARP _IOSWR('I', 39, struct arpreq) /* get arp entry */
+#define SIOCDARP _IOSW('I', 40, struct arpreq) /* delete arp entry */
+
+#define SIOCSIFNAME _IOSW('I', 41, struct ifreq) /* set interface name */
+#define SIOCGIFONEP _IOSWR('I', 42, struct ifreq) /* get one-packet params */
+#define SIOCSIFONEP _IOSW('I', 43, struct ifreq) /* set one-packet params */
+#define SIOCDIFADDR _IOSW('I', 44, struct ifreq) /* delete IF addr */
+#define SIOCAIFADDR _IOSW('I', 45, struct ifaliasreq) /*add/change IF alias*/
+#define SIOCADDMULTI _IOSW('I', 49, struct ifreq) /* add m'cast addr */
+#define SIOCDELMULTI _IOSW('I', 50, struct ifreq) /* del m'cast addr */
+#define SIOCGIFALIAS _IOSWR('I', 51, struct ifaliasreq) /* get IF alias */
+
+
+#define SIOCSOCKSYS _IOSW('I', 66, struct socksysreq) /* Pseudo socket syscall */
+
+/* these use ifr_metric to pass the information */
+#define SIOCSIFDEBUG _IOSW('I', 67, struct ifreq) /* set if debug level */
+#define SIOCGIFDEBUG _IOSWR('I', 68, struct ifreq) /* get if debug level */
+
+#define SIOCSIFTYPE _IOSW('I', 69, struct ifreq) /* set if MIB type */
+#define SIOCGIFTYPE _IOSWR('I', 70, struct ifreq) /* get if MIB type */
+
+#define SIOCGIFNUM _IOSR('I', 71, int) /* get number of ifs */
+/*
+ * This returns the number of ifreqs that SIOCGIFCONF would return, including
+ * aliases. This is the preferred way of sizing a buffer big enough to hold
+ * all interfaces.
+ */
+#define SIOCGIFANUM _IOSR('I', 72, int) /* get number of ifreqs */
+/*
+ * Interface specific performance tuning
+ */
+#define SIOCGIFPERF _IOSR('I', 73, struct ifreq) /* get perf info */
+#define SIOCSIFPERF _IOSR('I', 74, struct ifreq) /* get perf info */
+
+/*
+ * This structure is used to encode pseudo system calls
+ */
+struct socksysreq {
+ /* When porting, make this the widest thing it can be */
+ int args[7];
+};
+
+/*
+ * This structure is used for adding new protocols to the list supported by
+ * sockets.
+ */
+struct socknewproto {
+ int family; /* address family (AF_INET, etc.) */
+ int type; /* protocol type (SOCK_STREAM, etc.) */
+ int proto; /* per family proto number */
+ dev_t dev; /* major/minor to use (must be a clone) */
+ int flags; /* protosw flags */
+};
+
+/*
+ * utility definitions.
+ */
+
+#ifdef MIN
+#undef MIN
+#endif
+#define MIN(x,y) ((x) < (y) ? (x) : (y))
+#ifndef MAX
+#define MAX(x,y) ((x) > (y) ? (x) : (y))
+#endif
+
+#define MAXHOSTNAMELEN 256
+
+#define NBBY 8 /* number of bits in a byte */
+
+
+/* defines for user/kernel interface */
+
+#define MAX_MINOR (makedev(1,0) - 1) /* could be non-portable */
+
+#define SOCKETSYS 140 /* SCO 3.2v5 */
+
+#define SO_ACCEPT 1
+#define SO_BIND 2
+#define SO_CONNECT 3
+#define SO_GETPEERNAME 4
+#define SO_GETSOCKNAME 5
+#define SO_GETSOCKOPT 6
+#define SO_LISTEN 7
+#define SO_RECV 8
+#define SO_RECVFROM 9
+#define SO_SEND 10
+#define SO_SENDTO 11
+#define SO_SETSOCKOPT 12
+#define SO_SHUTDOWN 13
+#define SO_SOCKET 14
+#define SO_SELECT 15
+#define SO_GETIPDOMAIN 16
+#define SO_SETIPDOMAIN 17
+#define SO_ADJTIME 18
+#define SO_SETREUID 19
+#define SO_SETREGID 20
+#define SO_GETTIME 21
+#define SO_SETTIME 22
+#define SO_GETITIMER 23
+#define SO_SETITIMER 24
+#define SO_RECVMSG 25
+#define SO_SENDMSG 26
+#define SO_SOCKPAIR 27
+
+/*
+ * message flags
+ */
+#define M_BCAST 0x80000000
+
+/* Definitions and structures used for extracting */
+/* the size and/or the contents of kernel tables */
+
+/* Copyin/out values */
+#define GIARG 0x1
+#define CONTI 0x2
+#define GITAB 0x4
+
+struct gi_arg {
+ caddr_t gi_where;
+ unsigned gi_size;
+};
+
+#if !defined(_KERNEL) && !defined(INKERNEL) && !defined(_INKERNEL)
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int accept __P_((int, struct sockaddr *, int *));
+int bind __P_((int, const struct sockaddr *, int));
+int connect __P_((int, const struct sockaddr *, int));
+int getpeername __P_((int, struct sockaddr *, int *));
+int getsockname __P_((int, struct sockaddr *, int *));
+int getsockopt __P_((int, int, int, void *, int *));
+int setsockopt __P_((int, int, int, const void *, int));
+int listen __P_((int, int));
+ssize_t recv __P_((int, void *, size_t, int));
+ssize_t recvfrom __P_((int, void *, size_t, int, struct sockaddr *, int *));
+int recvmsg __P_((int, struct msghdr *, int));
+ssize_t send __P_((int, const void *, size_t, int));
+int sendmsg __P_((int, const struct msghdr *, int));
+ssize_t sendto __P_((int, const void *, size_t, int, const struct sockaddr *, int));
+int shutdown __P_((int, int));
+int socket __P_((int, int, int));
+int socketpair __P_((int, int, int, int[2]));
+__END_DECLS
+
+#endif /* !INKERNEL */
+#endif /* __sys_socket_h */
diff --git a/mit-pthreads/machdep/sco-3.2v5/syscall.h b/mit-pthreads/machdep/sco-3.2v5/syscall.h
new file mode 100755
index 00000000000..f49fba81b6e
--- /dev/null
+++ b/mit-pthreads/machdep/sco-3.2v5/syscall.h
@@ -0,0 +1,175 @@
+/* Copyright 1994-1995 The Santa Cruz Operation, Inc. All Rights Reserved. */
+
+
+#if defined(_NO_PROTOTYPE) /* Old, crufty environment */
+#include <oldstyle/syscall.h>
+#elif defined(_SCO_ODS_30) /* Old, Tbird compatible environment */
+#include <ods_30_compat/syscall.h>
+#else /* Normal, default environment */
+/*
+/ Portions Copyright (C) 1983-1995 The Santa Cruz Operation, Inc.
+ * All Rights Reserved.
+ *
+ * The information in this file is provided for the exclusive use of
+ * the licensees of The Santa Cruz Operation, Inc. Such users have the
+ * right to use, modify, and incorporate this code into other products
+ * for purposes authorized by the license agreement provided they include
+ * this notice and the associated copyright notice with any such product.
+ * The information in this file is provided "AS IS" without warranty.
+ */
+
+/* Portions Copyright (c) 1990, 1991, 1992, 1993 UNIX System Laboratories, Inc. */
+/* Portions Copyright (c) 1979 - 1990 AT&T */
+
+#ident "xpg4plus @(#) sys.i386 20.1 94/12/04 "
+/* #ident "xpg4plus @(#)head:sys.i386 1.2" */
+
+/*
+/* Definitions of Kernel Entry Call Gates
+*/
+
+#ifndef _SYSCALL_H_
+#define _SYSCALL_H_
+
+/*#define SYSCALL $0x7,$0*/
+/*#define SIGCALL $0xF,$0*/
+
+/*
+/* Definitions of System Call Entry Point Numbers
+*/
+
+#define SYS_access 33
+#define SYS_acct 51
+#define SYS_advfs 70
+#define SYS_alarm 27
+#define SYS_break 17
+#define SYS_brk 17
+#define SYS_chdir 12
+#define SYS_chmod 15
+#define SYS_chown 16
+#define SYS_chroot 61
+#define SYS_close 6
+#define SYS_creat 8
+#define SYS_dup 41
+#define SYS_exec 11
+#define SYS_execve 59
+#define SYS_exit 1
+#define SYS_fcntl 62
+#define SYS_fork 2
+#define SYS_fstat 28
+#define SYS_fstatfs 38
+#define SYS_fxstat 125
+#define SYS_getdents 81
+#define SYS_getgid 47
+#define SYS_getmsg 85
+#define SYS_getpid 20
+#define SYS_gettimeofday 171
+#define SYS_getuid 24
+#define SYS_gtty 32
+#define SYS_ioctl 54
+#define SYS_kill 37
+#define SYS_link 9
+#define SYS_lock 45
+#define SYS_lseek 19
+#define SYS_lstat 91
+#define SYS_lxstat 124
+#define SYS_mkdir 80
+#define SYS_mknod 14
+#define SYS_mount 21
+#define SYS_msgsys 49
+#define SYS_nice 34
+#define SYS_open 5
+#define SYS_pause 29
+#define SYS_pipe 42
+#define SYS_plock 45
+#define SYS_poll 87
+#define SYS_prof 44
+#define SYS_ptrace 26
+#define SYS_putmsg 86
+#define SYS_rdebug 76
+#define SYS_read 3
+#define SYS_readlink 92
+#define SYS_readv 121
+#define SYS_rfstart 74
+#define SYS_rfstop 77
+#define SYS_rfsys 78
+#define SYS_rmdir 79
+#define SYS_rmount 72
+#define SYS_rumount 73
+#define SYS_seek 19
+#define SYS_semsys 53
+#define SYS_setgid 46
+#define SYS_setpgrp 39
+#define SYS_settimeofday 172
+#define SYS_setuid 23
+#define SYS_shmsys 52
+#define SYS_signal 48
+#define SYS_stat 18
+#define SYS_statfs 35
+#define SYS_stime 25
+#define SYS_stty 31
+#define SYS_symlink 90
+#define SYS_sync 36
+#define SYS_sys3b 50
+#define SYS_sysi86 50
+#define SYS_sysacct 51
+#define SYS_sysfs 84
+#define SYS_time 13
+#define SYS_times 43
+#define SYS_uadmin 55
+#define SYS_ulimit 63
+#define SYS_umask 60
+#define SYS_umount 22
+#define SYS_unadvfs 71
+#define SYS_unlink 10
+#define SYS_utime 30
+#define SYS_utssys 57
+#define SYS_wait 7
+#define SYS_write 4
+#define SYS_writev 122
+#define SYS_xstat 123
+#define SYS_ftruncate 192
+
+/* cxenix numbers are created by the formula
+ * (table index << 8) + CXENIX
+ */
+
+#define CXENIX 0x28 /* Decimal 40 */
+
+#define XLOCKING 0x0128
+#define CREATSEM 0x0228
+#define OPENSEM 0x0328
+#define SIGSEM 0x0428
+#define WAITSEM 0x0528
+#define NBWAITSEM 0x0628
+#define RDCHK 0x0728
+#define CHSIZE 0x0a28
+#define SYS_ftime 0x0b28
+#define NAP 0x0c28
+#define SDGET 0x0d28
+#define SDFREE 0x0e28
+#define SDENTER 0x0f28
+#define SDLEAVE 0x1028
+#define SDGETV 0x1128
+#define SDWAITV 0x1228
+#define PROCTL 0x2028
+#define EXECSEG 0x2128
+#define UNEXECSEG 0x2228
+#define SYS_select 0x2428
+#define SYS_eaccess 0x2528
+#define SYS_paccess 0x2628
+#define SYS_sigaction 0x2728
+#define SYS_sigprocmask 0x2828
+#define SYS_sigpending 0x2928
+#define SYS_sigsuspend 0x2a28
+#define SYS_getgroups 0x2b28
+#define SYS_setgroups 0x2c28
+#define SYS_sysconf 0x2d28
+#define SYS_pathconf 0x2e28
+#define SYS_fpathconf 0x2f28
+#define SYS_rename 0x3028
+#define SYS_setitimer 0x3828
+
+#define CLOCAL 127
+#endif
+#endif
diff --git a/mit-pthreads/machdep/sco-3.2v5/timers.h b/mit-pthreads/machdep/sco-3.2v5/timers.h
new file mode 100755
index 00000000000..cbc48ccc8d8
--- /dev/null
+++ b/mit-pthreads/machdep/sco-3.2v5/timers.h
@@ -0,0 +1,68 @@
+/* ==== 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.
+ *
+ * timers.h,v 1.50.8.1 1996/03/05 08:28:36 proven 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/types.h>
+#include <time.h>
+
+struct timespec {
+ long tv_sec;
+ long tv_nsec;
+};
+
+#define TIMEVAL_TO_TIMESPEC(tv, ts) { \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000; \
+}
+#define TIMESPEC_TO_TIMEVAL(tv, ts) { \
+ (tv)->tv_sec = (ts)->tv_sec; \
+ (tv)->tv_usec = (ts)->tv_nsec / 1000; \
+}
+
+/*
+ * New functions
+ */
+
+__BEGIN_DECLS
+
+__END_DECLS
+
+#endif
diff --git a/mit-pthreads/machdep/sco-3.2v5/trash.can b/mit-pthreads/machdep/sco-3.2v5/trash.can
new file mode 100755
index 00000000000..33edf65aab6
--- /dev/null
+++ b/mit-pthreads/machdep/sco-3.2v5/trash.can
@@ -0,0 +1 @@
+make: *** No targets specified and no makefile found. Stop.
diff --git a/mit-pthreads/machdep/sunos-4.1.3/__math.h b/mit-pthreads/machdep/sunos-4.1.3/__math.h
new file mode 100755
index 00000000000..9de1dc6d4bd
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-4.1.3/__math.h
@@ -0,0 +1,5 @@
+/*
+ * Posix (actually ansi C) section
+ */
+#define HUGE_VAL (__infinity()) /* Produces IEEE Infinity. */
+
diff --git a/mit-pthreads/machdep/sunos-4.1.3/__path.h b/mit-pthreads/machdep/sunos-4.1.3/__path.h
new file mode 100755
index 00000000000..2665b5a0e8a
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-4.1.3/__path.h
@@ -0,0 +1,12 @@
+/*
+ * $Id$
+ */
+
+#ifndef _SYS__PATH_H_
+#define _SYS__PATH_H_
+
+#define _PATH_PTY "/dev/"
+#define _PATH_TZDIR "/usr/share/zoneinfo"
+#define _PATH_TZFILE "localtime"
+
+#endif /* !_SYS__PATH_H_ */
diff --git a/mit-pthreads/machdep/sunos-4.1.3/__signal.h b/mit-pthreads/machdep/sunos-4.1.3/__signal.h
new file mode 100755
index 00000000000..f8b4fb8b6de
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-4.1.3/__signal.h
@@ -0,0 +1,11 @@
+
+#include <sys/signal.h>
+#include <sys/stdtypes.h>
+
+typedef int sig_atomic_t;
+
+#define __SIGFILLSET 0xffffffff
+#define __SIGEMPTYSET 0
+#define __SIGADDSET(s,n) ((*s) |= (1 << ((n) - 1)))
+#define __SIGDELSET(s,n) ((*s) &= ~(1 << ((n) - 1)))
+#define __SIGISMEMBER(s,n) ((*s) & (1 << ((n) - 1)))
diff --git a/mit-pthreads/machdep/sunos-4.1.3/__stdio.h b/mit-pthreads/machdep/sunos-4.1.3/__stdio.h
new file mode 100755
index 00000000000..6ca5e57396d
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-4.1.3/__stdio.h
@@ -0,0 +1,4 @@
+
+typedef pthread_fpos_t fpos_t;
+
+#include <sys/stdtypes.h>
diff --git a/mit-pthreads/machdep/sunos-4.1.3/__stdlib.h b/mit-pthreads/machdep/sunos-4.1.3/__stdlib.h
new file mode 100755
index 00000000000..7bb9093c51c
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-4.1.3/__stdlib.h
@@ -0,0 +1,28 @@
+/* $Id$ */
+
+#ifndef __sys_stdtypes_h
+
+#ifndef _SYS___STDLIB_H_
+#define _SYS___STDLIB_H_
+
+#include <sys/stdtypes.h> /* to get size_t */
+
+#if (! defined _SIZE_T_ ) && (! defined(_GCC_SIZE_T))
+#define _SIZE_T_
+#define _GCC_SIZE_T
+typedef pthread_size_t size_t;
+#endif
+
+#if (! defined _WCHAR_T_ ) && (! defined(_GCC_WCHAR_T))
+#define _WCHAR_T_
+#define _GCC_WCHAR_T
+typedef unsigned int wchar_t;
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/sunos-4.1.3/__string.h b/mit-pthreads/machdep/sunos-4.1.3/__string.h
new file mode 100755
index 00000000000..0859a80cf24
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-4.1.3/__string.h
@@ -0,0 +1,14 @@
+
+#include <sys/stdtypes.h>
+
+/* Non-standard SunOS 4.x 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 *));
+__END_DECLS
+#endif
diff --git a/mit-pthreads/machdep/sunos-4.1.3/__time.h b/mit-pthreads/machdep/sunos-4.1.3/__time.h
new file mode 100755
index 00000000000..1ffa0e47d3f
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-4.1.3/__time.h
@@ -0,0 +1,2 @@
+
+#include <sys/stdtypes.h>
diff --git a/mit-pthreads/machdep/sunos-4.1.3/__unistd.h b/mit-pthreads/machdep/sunos-4.1.3/__unistd.h
new file mode 100755
index 00000000000..3b86527252c
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-4.1.3/__unistd.h
@@ -0,0 +1,73 @@
+/*-
+ * 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$
+ */
+
+#ifndef _SYS___UNISTD_H_
+#define _SYS___UNISTD_H_
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#define _SC_ARG_MAX 1 /* space for argv & envp */
+#define _SC_CHILD_MAX 2 /* maximum children per process??? */
+#define _SC_CLK_TCK 3 /* clock ticks/sec */
+#define _SC_NGROUPS_MAX 4 /* number of groups if multple supp. */
+#define _SC_OPEN_MAX 5 /* max open files per process */
+#define _SC_JOB_CONTROL 6 /* do we have job control */
+#define _SC_SAVED_IDS 7 /* do we have saved uid/gids */
+#define _SC_VERSION 8 /* POSIX version supported */
+
+#define _POSIX_JOB_CONTROL 1
+#define _POSIX_SAVED_IDS 1
+#define _POSIX_VERSION 198808
+
+#define _PC_LINK_MAX 1 /* max links to file/dir */
+#define _PC_MAX_CANON 2 /* max line length */
+#define _PC_MAX_INPUT 3 /* max "packet" to a tty device */
+#define _PC_NAME_MAX 4 /* max pathname component length */
+#define _PC_PATH_MAX 5 /* max pathname length */
+#define _PC_PIPE_BUF 6 /* size of a pipe */
+#define _PC_CHOWN_RESTRICTED 7 /* can we give away files */
+#define _PC_NO_TRUNC 8 /* trunc or error on >NAME_MAX */
+#define _PC_VDISABLE 9 /* best char to shut off tty c_cc */
+#define _PC_LAST 9 /* highest value of any _PC_* */
+
+#ifndef NULL
+#define NULL 0 /* null pointer constant */
+#endif
+
+typedef int ssize_t;
+
+#endif
diff --git a/mit-pthreads/machdep/sunos-4.1.3/cdefs.h b/mit-pthreads/machdep/sunos-4.1.3/cdefs.h
new file mode 100755
index 00000000000..a059fa3d3fc
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-4.1.3/cdefs.h
@@ -0,0 +1,61 @@
+/* ==== cdefs.h ============================================================
+ * Copyright (c) 1994 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Similar to the BSD cdefs.h file.
+ *
+ * 1.00 94/01/26 proven
+ * -Started coding this file.
+ */
+
+#ifndef _PTHREAD_SYS_CDEFS_H_
+#define _PTHREAD_SYS_CDEFS_H_
+
+/* Stuff for compiling */
+#if defined(__GNUC__)
+#if defined(__cplusplus)
+#define __INLINE static inline
+#define __BEGIN_DECLS extern "C" {
+#define __END_DECLS };
+#else
+#define __INLINE extern inline
+#define __CAN_DO_EXTERN_INLINE
+#define __BEGIN_DECLS
+#define __END_DECLS
+#if !defined(__STDC__)
+#define const __const
+#define inline __inline
+#define signed __signed
+#define volatile __volatile
+#endif
+#endif
+#else /* !__GNUC__ */
+#define __BEGIN_DECLS
+#define __END_DECLS
+#define __INLINE static
+#endif
+
+#ifndef __NORETURN
+#define __NORETURN
+#endif /* __NORETURN not defined. */
+
+#ifndef _U_INT32_T_
+#define _U_INT32_T_
+typedef unsigned int u_int32_t;
+#endif
+
+#ifndef _U_INT16_T_
+#define _U_INT16_T_
+typedef unsigned short u_int16_t;
+#endif
+
+#ifndef _INT32_T_
+#define _INT32_T_
+typedef int int32_t;
+#endif
+
+#ifndef _INT16_T_
+#define _INT16_T_
+typedef short int16_t;
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/sunos-4.1.3/compat.h b/mit-pthreads/machdep/sunos-4.1.3/compat.h
new file mode 100755
index 00000000000..b2a846d00ee
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-4.1.3/compat.h
@@ -0,0 +1,45 @@
+/* ==== 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$
+ *
+ * Description : Basic timers header.
+ *
+ * 1.00 94/06/13 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS_COMPAT_H_
+#define _SYS_COMPAT_H_
+
+#define omsghdr msghdr
+
+#endif
diff --git a/mit-pthreads/machdep/sunos-4.1.3/dirent.h b/mit-pthreads/machdep/sunos-4.1.3/dirent.h
new file mode 100755
index 00000000000..c2048b1741c
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-4.1.3/dirent.h
@@ -0,0 +1,64 @@
+/*-
+ * 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 {
+ off_t d_off; /* offset of next disk dir entry */
+ 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
+
+#endif /* !_SYS_DIRENT_H_ */
+
+
diff --git a/mit-pthreads/machdep/sunos-4.1.3/fcntlcom.h b/mit-pthreads/machdep/sunos-4.1.3/fcntlcom.h
new file mode 100755
index 00000000000..2b7acce7696
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-4.1.3/fcntlcom.h
@@ -0,0 +1,163 @@
+/* @(#)fcntlcom.h 1.13 91/06/18 SMI; from UCB fcntl.h 5.2 1/8/86 */
+
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef __sys_fcntlcom_h
+#define __sys_fcntlcom_h
+
+#include <sys/cdefs.h>
+
+/*
+ * Rewack the FXXXXX values as _FXXXX so that _POSIX_SOURCE works.
+ */
+#define _FOPEN (-1) /* from sys/file.h, kernel use only */
+#define _FREAD 0x0001 /* read enabled */
+#define _FWRITE 0x0002 /* write enabled */
+#define _FNDELAY 0x0004 /* non blocking I/O (4.2 style) */
+#define _FAPPEND 0x0008 /* append (writes guaranteed at the end) */
+#define _FSETBLK 0x0010 /* use block offsets */
+#define _FASYNC 0x0040 /* signal pgrp when data ready */
+#define _FSHLOCK 0x0080 /* BSD flock() shared lock present */
+#define _FEXLOCK 0x0100 /* BSD flock() exclusive lock present */
+#define _FCREAT 0x0200 /* open with file create */
+#define _FTRUNC 0x0400 /* open with truncation */
+#define _FEXCL 0x0800 /* error on open if file exists */
+#define _FNBIO 0x1000 /* non blocking I/O (sys5 style) */
+#define _FSYNC 0x2000 /* do all writes synchronously */
+#define _FNONBLOCK 0x4000 /* non blocking I/O (POSIX style) */
+#define _FNOCTTY 0x8000 /* don't assign a ctty on this open */
+#define _FMARK 0x10000 /* internal; mark during gc() */
+#define _FDEFER 0x20000 /* internal; defer for next gc pass */
+
+#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
+
+/*
+ * Flag values for open(2) and fcntl(2)
+ * The kernel adds 1 to the open modes to turn it into some
+ * combination of FREAD and FWRITE.
+ */
+#define O_RDONLY 0 /* +1 == FREAD */
+#define O_WRONLY 1 /* +1 == FWRITE */
+#define O_RDWR 2 /* +1 == FREAD|FWRITE */
+#define O_APPEND _FAPPEND
+#define O_CREAT _FCREAT
+#define O_TRUNC _FTRUNC
+#define O_EXCL _FEXCL
+/* O_SYNC _FSYNC not posix, defined below */
+/* O_NDELAY _FNDELAY set in include/fcntl.h */
+/* O_NDELAY _FNBIO set in 5include/fcntl.h */
+#define O_NONBLOCK _FNONBLOCK
+#define O_NOCTTY _FNOCTTY
+
+#ifndef _POSIX_SOURCE
+
+#define O_SYNC _FSYNC
+
+/*
+ * Flags that work for fcntl(fd, F_SETFL, FXXXX)
+ */
+#define FAPPEND _FAPPEND
+#define FSYNC _FSYNC
+#define FASYNC _FASYNC
+#define FNBIO _FNBIO
+#define FNONBIO _FNONBLOCK /* XXX fix to be NONBLOCK everywhere */
+#define FNDELAY _FNDELAY
+
+/*
+ * Flags that are disallowed for fcntl's (FCNTLCANT);
+ * used for opens, internal state, or locking.
+ */
+#define FREAD _FREAD
+#define FWRITE _FWRITE
+#define FMARK _FMARK
+#define FDEFER _FDEFER
+#define FSETBLK _FSETBLK
+#define FSHLOCK _FSHLOCK
+#define FEXLOCK _FEXLOCK
+
+/*
+ * The rest of the flags, used only for opens
+ */
+#define FOPEN _FOPEN
+#define FCREAT _FCREAT
+#define FTRUNC _FTRUNC
+#define FEXCL _FEXCL
+#define FNOCTTY _FNOCTTY
+
+#endif !_POSIX_SOURCE
+
+/* XXX close on exec request; must match UF_EXCLOSE in user.h */
+#define FD_CLOEXEC 1 /* posix */
+
+/* fcntl(2) requests */
+#define F_DUPFD 0 /* Duplicate fildes */
+#define F_GETFD 1 /* Get fildes flags (close on exec) */
+#define F_SETFD 2 /* Set fildes flags (close on exec) */
+#define F_GETFL 3 /* Get file flags */
+#define F_SETFL 4 /* Set file flags */
+#ifndef _POSIX_SOURCE
+#define F_GETOWN 5 /* Get owner - for ASYNC */
+#define F_SETOWN 6 /* Set owner - for ASYNC */
+#endif /* !_POSIX_SOURCE */
+#define F_GETLK 7 /* Get record-locking information */
+#define F_SETLK 8 /* Set or Clear a record-lock (Non-Blocking) */
+#define F_SETLKW 9 /* Set or Clear a record-lock (Blocking) */
+#ifndef _POSIX_SOURCE
+#define F_RGETLK 10 /* Test a remote lock to see if it is blocked */
+#define F_RSETLK 11 /* Set or unlock a remote lock */
+#define F_CNVT 12 /* Convert a fhandle to an open fd */
+#define F_RSETLKW 13 /* Set or Clear remote record-lock(Blocking) */
+#endif /* !_POSIX_SOURCE */
+
+/* fcntl(2) flags (l_type field of flock structure) */
+#define F_RDLCK 1 /* read lock */
+#define F_WRLCK 2 /* write lock */
+#define F_UNLCK 3 /* remove lock(s) */
+#ifndef _POSIX_SOURCE
+#define F_UNLKSYS 4 /* remove remote locks for a given system */
+#endif /* !_POSIX_SOURCE */
+
+#include <sys/stdtypes.h>
+
+/* file segment locking set data type - information passed to system by user */
+struct flock {
+ short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */
+ short l_whence; /* flag to choose starting offset */
+ long l_start; /* relative offset, in bytes */
+ long l_len; /* length, in bytes; 0 means lock to EOF */
+ short l_pid; /* returned with F_GETLK */
+ short l_xxx; /* reserved for future use */
+};
+
+#ifndef _POSIX_SOURCE
+/* extended file segment locking set data type */
+struct eflock {
+ short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */
+ short l_whence; /* flag to choose starting offset */
+ long l_start; /* relative offset, in bytes */
+ long l_len; /* length, in bytes; 0 means lock to EOF */
+ short l_pid; /* returned with F_GETLK */
+ short l_xxx; /* reserved for future use */
+ long l_rpid; /* Remote process id wanting this lock */
+ long l_rsys; /* Remote system id wanting this lock */
+};
+#endif /* !_POSIX_SOURCE */
+
+#ifndef KERNEL
+#include <sys/stat.h> /* sigh. for the mode bits for open/creat */
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+int open __P_((const char *path, int flags, ...));
+int creat __P_((const char *path, mode_t modes));
+int fcntl __P_((int fd, int cmd, ...));
+
+__END_DECLS
+
+#endif /* !KERNEL */
+#endif /* !__sys_fcntlcom_h */
diff --git a/mit-pthreads/machdep/sunos-4.1.3/signal.h b/mit-pthreads/machdep/sunos-4.1.3/signal.h
new file mode 100755
index 00000000000..02a19860922
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-4.1.3/signal.h
@@ -0,0 +1,98 @@
+#ifndef __sys_signal_h
+#define __sys_signal_h
+
+#define NSIG 32
+
+/*
+ * If any signal defines (SIG*) are added, deleted, or changed, the same
+ * changes must be made in /usr/include/signal.h as well.
+ */
+#define SIGHUP 1 /* hangup */
+#define SIGINT 2 /* interrupt */
+#define SIGQUIT 3 /* quit */
+#define SIGILL 4 /* illegal instruction (not reset when caught) */
+#define SIGTRAP 5 /* trace trap (not reset when caught) */
+#define SIGIOT 6 /* IOT instruction */
+#define SIGABRT 6 /* used by abort, replace SIGIOT in the future */
+#define SIGEMT 7 /* EMT instruction */
+#define SIGFPE 8 /* floating point exception */
+#define SIGKILL 9 /* kill (cannot be caught or ignored) */
+#define SIGBUS 10 /* bus error */
+#define SIGSEGV 11 /* segmentation violation */
+#define SIGSYS 12 /* bad argument to system call */
+#define SIGPIPE 13 /* write on a pipe with no one to read it */
+#define SIGALRM 14 /* alarm clock */
+#define SIGTERM 15 /* software termination signal from kill */
+#define SIGURG 16 /* urgent condition on IO channel */
+#define SIGSTOP 17 /* sendable stop signal not from tty */
+#define SIGTSTP 18 /* stop signal from tty */
+#define SIGCONT 19 /* continue a stopped process */
+#define SIGCHLD 20 /* to parent on child stop or exit */
+#define SIGCLD 20 /* System V name for SIGCHLD */
+#define SIGTTIN 21 /* to readers pgrp upon background tty read */
+#define SIGTTOU 22 /* like TTIN for output if (tp->t_local&LTOSTOP) */
+#define SIGIO 23 /* input/output possible signal */
+#define SIGPOLL SIGIO /* System V name for SIGIO */
+#define SIGXCPU 24 /* exceeded CPU time limit */
+#define SIGXFSZ 25 /* exceeded file size limit */
+#define SIGVTALRM 26 /* virtual time alarm */
+#define SIGPROF 27 /* profiling time alarm */
+#define SIGWINCH 28 /* window changed */
+#define SIGLOST 29 /* resource lost (eg, record-lock lost) */
+#define SIGUSR1 30 /* user defined signal 1 */
+#define SIGUSR2 31 /* user defined signal 2 */
+
+struct sigvec {
+ void (*sv_handler)(); /* signal handler */
+ int sv_mask; /* signal mask to apply */
+ int sv_flags; /* see signal options below */
+};
+#define SV_ONSTACK 0x0001 /* take signal on signal stack */
+#define SV_INTERRUPT 0x0002 /* do not restart system on signal return */
+#define SV_RESETHAND 0x0004 /* reset signal handler to SIG_DFL when signal taken */
+/*
+ * If any SA_NOCLDSTOP or SV_NOCLDSTOP is change, the same
+ * changes must be made in /usr/include/signal.h as well.
+ */
+#define SV_NOCLDSTOP 0x0008 /* don't send a SIGCHLD on child stop */
+#define SA_ONSTACK SV_ONSTACK
+#define SA_INTERRUPT SV_INTERRUPT
+#define SA_RESETHAND SV_RESETHAND
+
+#define SA_NOCLDSTOP SV_NOCLDSTOP
+#define sv_onstack sv_flags /* isn't compatibility wonderful! */
+
+/*
+ * If SIG_ERR, SIG_DFL, SIG_IGN, or SIG_HOLD are changed, the same changes
+ * must be made in /usr/include/signal.h as well.
+ */
+#define SIG_ERR (void (*)())-1
+#define SIG_DFL (void (*)())0
+#define SIG_IGN (void (*)())1
+
+/*
+ * Macro for converting signal number to a mask suitable for sigblock().
+ */
+#define sigmask(m) (1 << ((m)-1))
+
+/*
+ * If SIG_BLOCK, SIG_UNBLOCK, or SIG_SETMASK are changed, the same changes
+ * must be made in /usr/include/signal.h as well.
+ */
+#define SIG_BLOCK 0x0001
+#define SIG_UNBLOCK 0x0002
+#define SIG_SETMASK 0x0004
+
+/*
+ * If changes are made to sigset_t or struct sigaction, the same changes
+ * must be made in /usr/include/signal.h as well.
+ */
+#include <sys/stdtypes.h>
+
+struct sigaction {
+ void (*sa_handler)();
+ sigset_t sa_mask;
+ int sa_flags;
+};
+
+#endif /* !__sys_signal_h */
diff --git a/mit-pthreads/machdep/sunos-4.1.3/stat.h b/mit-pthreads/machdep/sunos-4.1.3/stat.h
new file mode 100755
index 00000000000..35e7f760204
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-4.1.3/stat.h
@@ -0,0 +1,94 @@
+/* @(#)stat.h 2.19 90/01/24 SMI; from UCB 4.7 83/05/21 */
+
+/*
+ * NOTE: changes to this file should also be made to xpg2include/sys/stat.h
+ */
+
+#ifndef __sys_stat_h
+#define __sys_stat_h
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+struct stat {
+ dev_t st_dev;
+ ino_t st_ino;
+ mode_t st_mode;
+ short st_nlink;
+ uid_t st_uid;
+ gid_t st_gid;
+ dev_t st_rdev;
+ off_t st_size;
+ time_t st_atime;
+ int st_spare1;
+ time_t st_mtime;
+ int st_spare2;
+ time_t st_ctime;
+ int st_spare3;
+ long st_blksize;
+ long st_blocks;
+ long st_spare4[2];
+};
+
+#define _IFMT 0170000 /* type of file */
+#define _IFDIR 0040000 /* directory */
+#define _IFCHR 0020000 /* character special */
+#define _IFBLK 0060000 /* block special */
+#define _IFREG 0100000 /* regular */
+#define _IFLNK 0120000 /* symbolic link */
+#define _IFSOCK 0140000 /* socket */
+#define _IFIFO 0010000 /* fifo */
+
+#define S_ISUID 0004000 /* set user id on execution */
+#define S_ISGID 0002000 /* set group id on execution */
+#ifndef _POSIX_SOURCE
+#define S_ISVTX 0001000 /* save swapped text even after use */
+#define S_IREAD 0000400 /* read permission, owner */
+#define S_IWRITE 0000200 /* write permission, owner */
+#define S_IEXEC 0000100 /* execute/search permission, owner */
+
+#define S_ENFMT 0002000 /* enforcement-mode locking */
+
+#define S_IFMT _IFMT
+#define S_IFDIR _IFDIR
+#define S_IFCHR _IFCHR
+#define S_IFBLK _IFBLK
+#define S_IFREG _IFREG
+#define S_IFLNK _IFLNK
+#define S_IFSOCK _IFSOCK
+#define S_IFIFO _IFIFO
+#endif !_POSIX_SOURCE
+
+#define S_IRWXU 0000700 /* rwx, owner */
+#define S_IRUSR 0000400 /* read permission, owner */
+#define S_IWUSR 0000200 /* write permission, owner */
+#define S_IXUSR 0000100 /* execute/search permission, owner */
+#define S_IRWXG 0000070 /* rwx, group */
+#define S_IRGRP 0000040 /* read permission, group */
+#define S_IWGRP 0000020 /* write permission, grougroup */
+#define S_IXGRP 0000010 /* execute/search permission, group */
+#define S_IRWXO 0000007 /* rwx, other */
+#define S_IROTH 0000004 /* read permission, other */
+#define S_IWOTH 0000002 /* write permission, other */
+#define S_IXOTH 0000001 /* execute/search permission, other */
+
+#define S_ISBLK(m) (((m)&_IFMT) == _IFBLK)
+#define S_ISCHR(m) (((m)&_IFMT) == _IFCHR)
+#define S_ISDIR(m) (((m)&_IFMT) == _IFDIR)
+#define S_ISFIFO(m) (((m)&_IFMT) == _IFIFO)
+#define S_ISREG(m) (((m)&_IFMT) == _IFREG)
+#ifndef _POSIX_SOURCE
+#define S_ISLNK(m) (((m)&_IFMT) == _IFLNK)
+#define S_ISSOCK(m) (((m)&_IFMT) == _IFSOCK)
+#endif
+
+__BEGIN_DECLS
+int chmod __P_((const char *path, mode_t mode));
+int fstat __P_((int fd, struct stat *sbuf));
+int mkdir __P_((char *path, mode_t mode));
+int mkfifo __P_((char *path, mode_t mode));
+int stat __P_((const char *path, struct stat *sbuf));
+mode_t umask __P_((mode_t mask));
+__END_DECLS
+
+#endif /* !__sys_stat_h */
diff --git a/mit-pthreads/machdep/sunos-4.1.3/time.h b/mit-pthreads/machdep/sunos-4.1.3/time.h
new file mode 100755
index 00000000000..20bb085e4d8
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-4.1.3/time.h
@@ -0,0 +1,69 @@
+/* @(#)time.h 2.12 91/05/22 SMI; from UCB 7.1 6/4/86 */
+
+/*
+ * 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.
+ */
+
+#ifndef _SYS_TIME_H_
+#define _SYS_TIME_H_
+
+#include <sys/cdefs.h>
+/*
+ * Structure returned by gettimeofday(2) system call,
+ * and used in other calls.
+ */
+
+struct timeval {
+ long tv_sec; /* seconds */
+ long tv_usec; /* and microseconds */
+};
+
+struct timezone {
+ int tz_minuteswest; /* minutes west of Greenwich */
+ int tz_dsttime; /* type of dst correction */
+};
+
+#define DST_NONE 0 /* not on dst */
+#define DST_USA 1 /* USA style dst */
+#define DST_AUST 2 /* Australian style dst */
+#define DST_WET 3 /* Western European dst */
+#define DST_MET 4 /* Middle European dst */
+#define DST_EET 5 /* Eastern European dst */
+#define DST_CAN 6 /* Canada */
+#define DST_GB 7 /* Great Britain and Eire */
+#define DST_RUM 8 /* Rumania */
+#define DST_TUR 9 /* Turkey */
+#define DST_AUSTALT 10 /* Australian style with shift in 1986 */
+
+/*
+ * Operations on timevals.
+ *
+ * NB: timercmp does not work for >= or <=.
+ */
+#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
+#define timercmp(tvp, uvp, cmp) \
+ ((tvp)->tv_sec cmp (uvp)->tv_sec || \
+ (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
+#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
+
+/*
+ * Names of the interval timers, and structure
+ * defining a timer setting.
+ */
+#define ITIMER_REAL 0
+#define ITIMER_VIRTUAL 1
+#define ITIMER_PROF 2
+
+struct itimerval {
+ struct timeval it_interval; /* timer interval */
+ struct timeval it_value; /* current value */
+};
+
+__BEGIN_DECLS
+int gettimeofday __P_((struct timeval *, struct timezone *));
+__END_DECLS
+
+
+#endif
diff --git a/mit-pthreads/machdep/sunos-4.1.3/timers.h b/mit-pthreads/machdep/sunos-4.1.3/timers.h
new file mode 100755
index 00000000000..3c4d057976a
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-4.1.3/timers.h
@@ -0,0 +1,68 @@
+/* ==== 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$
+ *
+ * Description : Basic timers header.
+ *
+ * 1.00 94/06/13 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS_TIMERS_H_
+#define _SYS_TIMERS_H_
+
+#include <sys/types.h>
+#include <time.h>
+
+struct timespec {
+ time_t tv_sec;
+ long tv_nsec;
+};
+
+#define TIMEVAL_TO_TIMESPEC(tv, ts) { \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000; \
+}
+#define TIMESPEC_TO_TIMEVAL(tv, ts) { \
+ (tv)->tv_sec = (ts)->tv_sec; \
+ (tv)->tv_usec = (ts)->tv_nsec / 1000; \
+}
+
+/*
+ * New functions
+ */
+
+__BEGIN_DECLS
+
+__END_DECLS
+
+#endif
diff --git a/mit-pthreads/machdep/sunos-4.1.3/wait.h b/mit-pthreads/machdep/sunos-4.1.3/wait.h
new file mode 100755
index 00000000000..97f5fb261f7
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-4.1.3/wait.h
@@ -0,0 +1,22 @@
+#ifndef _SYS_WAIT_H_
+#define _SYS_WAIT_H_
+
+#define WNOHANG 1 /* dont hang in wait */
+#define WUNTRACED 2 /* tell about stopped, untraced children */
+
+pid_t wait __P_((int *));
+pid_t waitpid __P_((pid_t, int *, int));
+
+#define _W_INT(i) (i)
+#define WCOREFLAG 0200
+
+#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)
+
+#endif /* _SYS_WAIT_H_ */
diff --git a/mit-pthreads/machdep/sunos-5.3/__math.h b/mit-pthreads/machdep/sunos-5.3/__math.h
new file mode 100755
index 00000000000..5404b52c661
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.3/__math.h
@@ -0,0 +1,16 @@
+/*
+ * ANSI/POSIX
+ */
+typedef union _h_val {
+ unsigned long _i[2];
+ double _d;
+} _h_val;
+
+#ifdef __STDC__
+extern const _h_val __huge_val;
+#else
+extern _h_val __huge_val;
+#endif
+
+#define HUGE_VAL __huge_val._d
+
diff --git a/mit-pthreads/machdep/sunos-5.3/__signal.h b/mit-pthreads/machdep/sunos-5.3/__signal.h
new file mode 100755
index 00000000000..638c1ca7331
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.3/__signal.h
@@ -0,0 +1,19 @@
+#include <sys/feature_tests.h>
+#include <sys/signal.h>
+
+/*
+typedef struct {
+ unsigned long __sigbits[4];
+} sigset_t;
+*/
+
+typedef int sig_atomic_t;
+
+#define sigmask(n) ((unsigned int)1 << (((n) - 1) & (32 - 1)))
+#define sigword(n) (((unsigned int)((n) - 1))>>5)
+
+#define __SIGEMPTYSET { 0, 0, 0, 0 };
+#define __SIGFILLSET { 0xffffffff,0xffffffff,0xffffffff,0xffffffff };
+#define __SIGADDSET(s, n) ((s)->__sigbits[sigword(n)] |= sigmask(n))
+#define __SIGDELSET(s, n) ((s)->__sigbits[sigword(n)] &= ~sigmask(n))
+#define __SIGISMEMBER(s, n) (sigmask(n) & (s)->__sigbits[sigword(n)])
diff --git a/mit-pthreads/machdep/sunos-5.3/__stdio.h b/mit-pthreads/machdep/sunos-5.3/__stdio.h
new file mode 100755
index 00000000000..4dd4becdbe9
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.3/__stdio.h
@@ -0,0 +1,6 @@
+typedef pthread_fpos_t fpos_t;
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef pthread_size_t size_t;
+#endif
diff --git a/mit-pthreads/machdep/sunos-5.3/__stdlib.h b/mit-pthreads/machdep/sunos-5.3/__stdlib.h
new file mode 100755
index 00000000000..a0717ce3c2b
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.3/__stdlib.h
@@ -0,0 +1,27 @@
+
+#ifndef _SYS___STDLIB_H_
+#define _SYS___STDLIB_H_
+
+#include <sys/feature_tests.h>
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef unsigned int size_t;
+#endif
+
+#ifndef _UID_T
+#define _UID_T
+typedef long uid_t;
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef _WCHAR_T
+#define _WCHAR_T
+typedef long wchar_t;
+#endif
+
+
+#endif
diff --git a/mit-pthreads/machdep/sunos-5.3/__string.h b/mit-pthreads/machdep/sunos-5.3/__string.h
new file mode 100755
index 00000000000..9cb12a07bb7
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.3/__string.h
@@ -0,0 +1,12 @@
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef pthread_size_t size_t;
+#endif
+
+/* Non-standard NetBSD string routines. */
+#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
+__BEGIN_DECLS
+char *strdup __P_((const char *));
+__END_DECLS
+#endif
diff --git a/mit-pthreads/machdep/sunos-5.3/__time.h b/mit-pthreads/machdep/sunos-5.3/__time.h
new file mode 100755
index 00000000000..231e997acfa
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.3/__time.h
@@ -0,0 +1,69 @@
+/* ==== 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$
+ *
+ * Description : System specific time header.
+ *
+ * 1.00 94/11/07 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS___TIME_H_
+#define _SYS___TIME_H_
+
+#include <sys/feature_tests.h>
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef unsigned size_t;
+#endif
+#ifndef _CLOCK_T
+#define _CLOCK_T
+typedef long clock_t;
+#endif
+#ifndef _TIME_T
+#define _TIME_T
+typedef long time_t;
+#endif
+#ifndef _CLOCKID_T
+#define _CLOCKID_T
+typedef int clockid_t;
+#endif
+#ifndef _TIMER_T
+#define _TIMER_T
+typedef int timer_t;
+#endif
+
+#include <sys/time.h>
+#include <sys/siginfo.h>
+
+#endif
diff --git a/mit-pthreads/machdep/sunos-5.3/__unistd.h b/mit-pthreads/machdep/sunos-5.3/__unistd.h
new file mode 100755
index 00000000000..4e83a863735
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.3/__unistd.h
@@ -0,0 +1,47 @@
+/*-
+ * 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$
+ */
+
+#ifndef _SYS___UNISTD_H_
+#define _SYS___UNISTD_H_
+
+#include <sys/types.h>
+#include <sys/unistd.h>
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/sunos-5.3/cdefs.h b/mit-pthreads/machdep/sunos-5.3/cdefs.h
new file mode 100755
index 00000000000..f95f7b36958
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.3/cdefs.h
@@ -0,0 +1,59 @@
+/* ==== cdefs.h ============================================================
+ * Copyright (c) 1994 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Similar to the BSD cdefs.h file.
+ *
+ * 1.00 94/01/26 proven
+ * -Started coding this file.
+ */
+
+#ifndef _PTHREAD_SYS_CDEFS_H_
+#define _PTHREAD_SYS_CDEFS_H_
+
+/* Stuff for compiling */
+#if defined(__GNUC__)
+#if defined(__cplusplus)
+#define __INLINE static inline
+#define __BEGIN_DECLS extern "C" {
+#define __END_DECLS };
+#else
+#define __INLINE extern inline
+#define __CAN_DO_EXTERN_INLINE
+#define __BEGIN_DECLS
+#define __END_DECLS
+#define const __const
+#define inline __inline
+#define signed __signed
+#define volatile __volatile
+#endif
+#else /* !__GNUC__ */
+#define __BEGIN_DECLS
+#define __END_DECLS
+#define __INLINE static
+#endif
+
+#ifndef __NORETURN
+#define __NORETURN
+#endif /* __NORETURN not defined. */
+
+#ifndef _U_INT32_T_
+#define _U_INT32_T_
+typedef unsigned int u_int32_t;
+#endif
+
+#ifndef _U_INT16_T_
+#define _U_INT16_T_
+typedef unsigned short u_int16_t;
+#endif
+
+#ifndef _INT32_T_
+#define _INT32_T_
+typedef int int32_t;
+#endif
+
+#ifndef _INT16_T_
+#define _INT16_T_
+typedef short int16_t;
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/sunos-5.3/compat.h b/mit-pthreads/machdep/sunos-5.3/compat.h
new file mode 100755
index 00000000000..b2a846d00ee
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.3/compat.h
@@ -0,0 +1,45 @@
+/* ==== 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$
+ *
+ * Description : Basic timers header.
+ *
+ * 1.00 94/06/13 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS_COMPAT_H_
+#define _SYS_COMPAT_H_
+
+#define omsghdr msghdr
+
+#endif
diff --git a/mit-pthreads/machdep/sunos-5.3/dirent.h b/mit-pthreads/machdep/sunos-5.3/dirent.h
new file mode 100755
index 00000000000..303d3d7df2b
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.3/dirent.h
@@ -0,0 +1,64 @@
+/*-
+ * 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 */
+ off_t d_off; /* offset of next disk dir entry */
+ u_short d_reclen; /* length of this record */
+#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_namlen d_reclen
+#define d_ino d_fileno
+
+#endif /* !_SYS_DIRENT_H_ */
+
+
diff --git a/mit-pthreads/machdep/sunos-5.3/socket.h b/mit-pthreads/machdep/sunos-5.3/socket.h
new file mode 100755
index 00000000000..0b075622fed
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.3/socket.h
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 1982, 1985, 1986 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, 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'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * @(#)socket.h 7.3 (Berkeley) 6/27/88
+ */
+
+#ifndef _SYS_SOCKET_H
+#define _SYS_SOCKET_H
+
+/*
+ * Types of sockets
+ */
+#define SOCK_STREAM 2 /* stream socket */
+#define SOCK_DGRAM 1 /* datagram socket */
+#define SOCK_RAW 4 /* raw-protocol interface */
+#define SOCK_RDM 5 /* reliably-delivered message */
+#define SOCK_SEQPACKET 6 /* sequenced packet stream */
+
+/*
+ * Option flags per-socket.
+ */
+#define SO_DEBUG 0x0001 /* turn on debugging info recording */
+#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
+#define SO_REUSEADDR 0x0004 /* allow local address reuse */
+#define SO_KEEPALIVE 0x0008 /* keep connections alive */
+#define SO_DONTROUTE 0x0010 /* just use interface addresses */
+#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
+#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
+#define SO_LINGER 0x0080 /* linger on close if data present */
+#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
+
+/*
+ * Additional options, not kept in so_options.
+ */
+#define SO_SNDBUF 0x1001 /* send buffer size */
+#define SO_RCVBUF 0x1002 /* receive buffer size */
+#define SO_SNDLOWAT 0x1003 /* send low-water mark */
+#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
+#define SO_SNDTIMEO 0x1005 /* send timeout */
+#define SO_RCVTIMEO 0x1006 /* receive timeout */
+#define SO_ERROR 0x1007 /* get error status and clear */
+#define SO_TYPE 0x1008 /* get socket type */
+#define SO_PROTOTYPE 0x1009 /* get/set protocol type */
+
+/*
+ * Level number for (get/set)sockopt() to apply to socket itself.
+ */
+#define SOL_SOCKET 0xffff /* options for socket level */
+
+/*
+ * Address families.
+ */
+#define AF_UNSPEC 0 /* unspecified */
+#define AF_UNIX 1 /* local to host (pipes, portals) */
+#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
+#define AF_IMPLINK 3 /* arpanet imp addresses */
+#define AF_PUP 4 /* pup protocols: e.g. BSP */
+#define AF_CHAOS 5 /* mit CHAOS protocols */
+#define AF_NS 6 /* XEROX NS protocols */
+#define AF_NBS 7 /* nbs protocols */
+#define AF_ECMA 8 /* european computer manufacturers */
+#define AF_DATAKIT 9 /* datakit protocols */
+#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
+#define AF_SNA 11 /* IBM SNA */
+#define AF_DECnet 12 /* DECnet */
+#define AF_DLI 13 /* Direct data link interface */
+#define AF_LAT 14 /* LAT */
+#define AF_HYLINK 15 /* NSC Hyperchannel */
+#define AF_APPLETALK 16 /* Apple Talk */
+#define AF_NIT 17 /* NIT */
+#define AF_802 18 /* IEEE 802.2, also ISO 8802 */
+#define AF_ISO 19 /* ISO protocols */
+#define AF_OSI AF_ISO
+#define AF_X25 20 /* CCITT X.25 in particular */
+#define AF_OSINET 21
+#define AF_GOSIP 22
+#define AF_MAX 22
+
+/*
+ * Structure used by kernel to store most
+ * addresses.
+ */
+struct sockaddr {
+ unsigned short sa_family; /* address family */
+ char sa_data[14]; /* up to 14 bytes of direct address */
+};
+
+/*
+ * Structure used by kernel to pass protocol
+ * information in raw sockets.
+ */
+struct sockproto {
+ unsigned short sp_family; /* address family */
+ unsigned short sp_protocol; /* protocol */
+};
+
+/*
+ * Protocol families, same as address families for now.
+ */
+#define PF_UNSPEC AF_UNSPEC
+#define PF_UNIX AF_UNIX
+#define PF_INET AF_INET
+#define PF_IMPLINK AF_IMPLINK
+#define PF_PUP AF_PUP
+#define PF_CHAOS AF_CHAOS
+#define PF_NS AF_NS
+#define PF_NBS AF_NBS
+#define PF_ECMA AF_ECMA
+#define PF_DATAKIT AF_DATAKIT
+#define PF_CCITT AF_CCITT
+#define PF_SNA AF_SNA
+#define PF_DECnet AF_DECnet
+#define PF_DLI AF_DLI
+#define PF_LAT AF_LAT
+#define PF_HYLINK AF_HYLINK
+#define PF_APPLETALK AF_APPLETALK
+#define PF_NIT AF_NIT
+#define PF_802 AF_802
+#define PF_ISO AF_ISO
+#define PF_OSI AF_ISO
+#define PF_X25 AF_X25
+#define PF_OSINET AF_OSINET
+#define PF_GOSIP AF_GOSIP
+#define PF_MAX AF_MAX
+
+/*
+ * Maximum queue length specifiable by listen.
+ */
+#define SOMAXCONN 5
+
+/*
+ * Message header for recvmsg and sendmsg calls.
+ */
+struct msghdr {
+ caddr_t msg_name; /* optional address */
+ int msg_namelen; /* size of address */
+ struct iovec *msg_iov; /* scatter/gather array */
+ int msg_iovlen; /* # elements in msg_iov */
+ caddr_t msg_accrights; /* access rights sent/received */
+ int msg_accrightslen;
+};
+
+#define MSG_OOB 0x1 /* process out-of-band data */
+#define MSG_PEEK 0x2 /* peek at incoming message */
+#define MSG_DONTROUTE 0x4 /* send without using routing tables */
+
+#define MSG_MAXIOVLEN 16
+
+#include <sys/cdefs.h>
+/*
+ * Functions
+ */
+
+__BEGIN_DECLS
+
+int accept __P_((int, struct sockaddr *, int *));
+int bind __P_((int, const struct sockaddr *, int));
+int connect __P_((int, const struct sockaddr *, int));
+int listen __P_((int, int));
+int socket __P_((int, int, int));
+int setsockopt __P_((int, int, int, const void *, int));
+int getsockname __P_((int, struct sockaddr *, int *));
+int shutdown __P_((int, int));
+int getpeername __P_((int, struct sockaddr *, int *));
+__END_DECLS
+
+#endif /* _SYS_SOCKET_H */
diff --git a/mit-pthreads/machdep/sunos-5.3/timers.h b/mit-pthreads/machdep/sunos-5.3/timers.h
new file mode 100755
index 00000000000..3ee2c78f088
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.3/timers.h
@@ -0,0 +1,72 @@
+/* ==== 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$
+ *
+ * Description : Basic timers header.
+ *
+ * 1.00 94/06/13 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS_TIMERS_H_
+#define _SYS_TIMERS_H_
+
+#include <sys/types.h>
+#include <time.h>
+
+#define tv_sec tv_sec
+#define tv_nsec tv_nsec
+
+#define TIMEVAL_TO_TIMESPEC(tv, ts) { \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000; \
+}
+#define TIMESPEC_TO_TIMEVAL(tv, ts) { \
+ (tv)->tv_sec = (ts)->tv_sec; \
+ (tv)->tv_usec = (ts)->tv_nsec / 1000; \
+}
+
+/*
+ * New functions
+ */
+
+#ifndef NOT_USED
+/* for sleep.h */
+/* int gettimeofday __P_((struct timeval *,struct timezone *)); */
+int gettimeofday __P_((struct timeval *,void *));
+#endif
+
+__BEGIN_DECLS
+
+__END_DECLS
+
+#endif
diff --git a/mit-pthreads/machdep/sunos-5.3/uio.h b/mit-pthreads/machdep/sunos-5.3/uio.h
new file mode 100755
index 00000000000..7786142dd87
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.3/uio.h
@@ -0,0 +1,40 @@
+/* ==== uio.h ============================================================
+ * Copyright (c) 1994 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Correct Solaris header file.
+ */
+
+#ifndef _PTHREAD_UIO_H_
+#define _PTHREAD_UIO_H_
+
+#include <sys/cdefs.h>
+
+struct iovec {
+ void *iov_base;
+ size_t iov_len;
+};
+
+typedef struct iovec iovec_t;
+
+struct uio {
+ iovec_t *uio_iov; /* pointer to array of iovecs */
+ int uio_iovcnt; /* number of iovecs */
+ /* These are all bogus */
+ int _uio_offset; /* file offset */
+ int uio_segflg; /* address space (kernel or user) */
+ short uio_fmode; /* file mode flags */
+ int _uio_limit; /* u-limit (maximum "block" offset) */
+ int uio_resid; /* residual count */
+};
+
+typedef struct uio uio_t;
+
+__BEGIN_DECLS
+
+int readv __P_((int, const struct iovec *, int));
+int writev __P_((int, const struct iovec *, int));
+
+__END_DECLS
+
+#endif
+
diff --git a/mit-pthreads/machdep/sunos-5.5/__math.h b/mit-pthreads/machdep/sunos-5.5/__math.h
new file mode 100755
index 00000000000..5404b52c661
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.5/__math.h
@@ -0,0 +1,16 @@
+/*
+ * ANSI/POSIX
+ */
+typedef union _h_val {
+ unsigned long _i[2];
+ double _d;
+} _h_val;
+
+#ifdef __STDC__
+extern const _h_val __huge_val;
+#else
+extern _h_val __huge_val;
+#endif
+
+#define HUGE_VAL __huge_val._d
+
diff --git a/mit-pthreads/machdep/sunos-5.5/__signal.h b/mit-pthreads/machdep/sunos-5.5/__signal.h
new file mode 100755
index 00000000000..638c1ca7331
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.5/__signal.h
@@ -0,0 +1,19 @@
+#include <sys/feature_tests.h>
+#include <sys/signal.h>
+
+/*
+typedef struct {
+ unsigned long __sigbits[4];
+} sigset_t;
+*/
+
+typedef int sig_atomic_t;
+
+#define sigmask(n) ((unsigned int)1 << (((n) - 1) & (32 - 1)))
+#define sigword(n) (((unsigned int)((n) - 1))>>5)
+
+#define __SIGEMPTYSET { 0, 0, 0, 0 };
+#define __SIGFILLSET { 0xffffffff,0xffffffff,0xffffffff,0xffffffff };
+#define __SIGADDSET(s, n) ((s)->__sigbits[sigword(n)] |= sigmask(n))
+#define __SIGDELSET(s, n) ((s)->__sigbits[sigword(n)] &= ~sigmask(n))
+#define __SIGISMEMBER(s, n) (sigmask(n) & (s)->__sigbits[sigword(n)])
diff --git a/mit-pthreads/machdep/sunos-5.5/__stdio.h b/mit-pthreads/machdep/sunos-5.5/__stdio.h
new file mode 100755
index 00000000000..4dd4becdbe9
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.5/__stdio.h
@@ -0,0 +1,6 @@
+typedef pthread_fpos_t fpos_t;
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef pthread_size_t size_t;
+#endif
diff --git a/mit-pthreads/machdep/sunos-5.5/__stdlib.h b/mit-pthreads/machdep/sunos-5.5/__stdlib.h
new file mode 100755
index 00000000000..a0717ce3c2b
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.5/__stdlib.h
@@ -0,0 +1,27 @@
+
+#ifndef _SYS___STDLIB_H_
+#define _SYS___STDLIB_H_
+
+#include <sys/feature_tests.h>
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef unsigned int size_t;
+#endif
+
+#ifndef _UID_T
+#define _UID_T
+typedef long uid_t;
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef _WCHAR_T
+#define _WCHAR_T
+typedef long wchar_t;
+#endif
+
+
+#endif
diff --git a/mit-pthreads/machdep/sunos-5.5/__string.h b/mit-pthreads/machdep/sunos-5.5/__string.h
new file mode 100755
index 00000000000..9cb12a07bb7
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.5/__string.h
@@ -0,0 +1,12 @@
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef pthread_size_t size_t;
+#endif
+
+/* Non-standard NetBSD string routines. */
+#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
+__BEGIN_DECLS
+char *strdup __P_((const char *));
+__END_DECLS
+#endif
diff --git a/mit-pthreads/machdep/sunos-5.5/__time.h b/mit-pthreads/machdep/sunos-5.5/__time.h
new file mode 100755
index 00000000000..231e997acfa
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.5/__time.h
@@ -0,0 +1,69 @@
+/* ==== 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$
+ *
+ * Description : System specific time header.
+ *
+ * 1.00 94/11/07 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS___TIME_H_
+#define _SYS___TIME_H_
+
+#include <sys/feature_tests.h>
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef unsigned size_t;
+#endif
+#ifndef _CLOCK_T
+#define _CLOCK_T
+typedef long clock_t;
+#endif
+#ifndef _TIME_T
+#define _TIME_T
+typedef long time_t;
+#endif
+#ifndef _CLOCKID_T
+#define _CLOCKID_T
+typedef int clockid_t;
+#endif
+#ifndef _TIMER_T
+#define _TIMER_T
+typedef int timer_t;
+#endif
+
+#include <sys/time.h>
+#include <sys/siginfo.h>
+
+#endif
diff --git a/mit-pthreads/machdep/sunos-5.5/__unistd.h b/mit-pthreads/machdep/sunos-5.5/__unistd.h
new file mode 100755
index 00000000000..4e83a863735
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.5/__unistd.h
@@ -0,0 +1,47 @@
+/*-
+ * 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$
+ */
+
+#ifndef _SYS___UNISTD_H_
+#define _SYS___UNISTD_H_
+
+#include <sys/types.h>
+#include <sys/unistd.h>
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/sunos-5.5/cdefs.h b/mit-pthreads/machdep/sunos-5.5/cdefs.h
new file mode 100755
index 00000000000..f95f7b36958
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.5/cdefs.h
@@ -0,0 +1,59 @@
+/* ==== cdefs.h ============================================================
+ * Copyright (c) 1994 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Similar to the BSD cdefs.h file.
+ *
+ * 1.00 94/01/26 proven
+ * -Started coding this file.
+ */
+
+#ifndef _PTHREAD_SYS_CDEFS_H_
+#define _PTHREAD_SYS_CDEFS_H_
+
+/* Stuff for compiling */
+#if defined(__GNUC__)
+#if defined(__cplusplus)
+#define __INLINE static inline
+#define __BEGIN_DECLS extern "C" {
+#define __END_DECLS };
+#else
+#define __INLINE extern inline
+#define __CAN_DO_EXTERN_INLINE
+#define __BEGIN_DECLS
+#define __END_DECLS
+#define const __const
+#define inline __inline
+#define signed __signed
+#define volatile __volatile
+#endif
+#else /* !__GNUC__ */
+#define __BEGIN_DECLS
+#define __END_DECLS
+#define __INLINE static
+#endif
+
+#ifndef __NORETURN
+#define __NORETURN
+#endif /* __NORETURN not defined. */
+
+#ifndef _U_INT32_T_
+#define _U_INT32_T_
+typedef unsigned int u_int32_t;
+#endif
+
+#ifndef _U_INT16_T_
+#define _U_INT16_T_
+typedef unsigned short u_int16_t;
+#endif
+
+#ifndef _INT32_T_
+#define _INT32_T_
+typedef int int32_t;
+#endif
+
+#ifndef _INT16_T_
+#define _INT16_T_
+typedef short int16_t;
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/sunos-5.5/compat.h b/mit-pthreads/machdep/sunos-5.5/compat.h
new file mode 100755
index 00000000000..b2a846d00ee
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.5/compat.h
@@ -0,0 +1,45 @@
+/* ==== 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$
+ *
+ * Description : Basic timers header.
+ *
+ * 1.00 94/06/13 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS_COMPAT_H_
+#define _SYS_COMPAT_H_
+
+#define omsghdr msghdr
+
+#endif
diff --git a/mit-pthreads/machdep/sunos-5.5/dirent.h b/mit-pthreads/machdep/sunos-5.5/dirent.h
new file mode 100755
index 00000000000..303d3d7df2b
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.5/dirent.h
@@ -0,0 +1,64 @@
+/*-
+ * 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 */
+ off_t d_off; /* offset of next disk dir entry */
+ u_short d_reclen; /* length of this record */
+#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_namlen d_reclen
+#define d_ino d_fileno
+
+#endif /* !_SYS_DIRENT_H_ */
+
+
diff --git a/mit-pthreads/machdep/sunos-5.5/socket.h b/mit-pthreads/machdep/sunos-5.5/socket.h
new file mode 100755
index 00000000000..0b075622fed
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.5/socket.h
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 1982, 1985, 1986 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, 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'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * @(#)socket.h 7.3 (Berkeley) 6/27/88
+ */
+
+#ifndef _SYS_SOCKET_H
+#define _SYS_SOCKET_H
+
+/*
+ * Types of sockets
+ */
+#define SOCK_STREAM 2 /* stream socket */
+#define SOCK_DGRAM 1 /* datagram socket */
+#define SOCK_RAW 4 /* raw-protocol interface */
+#define SOCK_RDM 5 /* reliably-delivered message */
+#define SOCK_SEQPACKET 6 /* sequenced packet stream */
+
+/*
+ * Option flags per-socket.
+ */
+#define SO_DEBUG 0x0001 /* turn on debugging info recording */
+#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
+#define SO_REUSEADDR 0x0004 /* allow local address reuse */
+#define SO_KEEPALIVE 0x0008 /* keep connections alive */
+#define SO_DONTROUTE 0x0010 /* just use interface addresses */
+#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
+#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
+#define SO_LINGER 0x0080 /* linger on close if data present */
+#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
+
+/*
+ * Additional options, not kept in so_options.
+ */
+#define SO_SNDBUF 0x1001 /* send buffer size */
+#define SO_RCVBUF 0x1002 /* receive buffer size */
+#define SO_SNDLOWAT 0x1003 /* send low-water mark */
+#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
+#define SO_SNDTIMEO 0x1005 /* send timeout */
+#define SO_RCVTIMEO 0x1006 /* receive timeout */
+#define SO_ERROR 0x1007 /* get error status and clear */
+#define SO_TYPE 0x1008 /* get socket type */
+#define SO_PROTOTYPE 0x1009 /* get/set protocol type */
+
+/*
+ * Level number for (get/set)sockopt() to apply to socket itself.
+ */
+#define SOL_SOCKET 0xffff /* options for socket level */
+
+/*
+ * Address families.
+ */
+#define AF_UNSPEC 0 /* unspecified */
+#define AF_UNIX 1 /* local to host (pipes, portals) */
+#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
+#define AF_IMPLINK 3 /* arpanet imp addresses */
+#define AF_PUP 4 /* pup protocols: e.g. BSP */
+#define AF_CHAOS 5 /* mit CHAOS protocols */
+#define AF_NS 6 /* XEROX NS protocols */
+#define AF_NBS 7 /* nbs protocols */
+#define AF_ECMA 8 /* european computer manufacturers */
+#define AF_DATAKIT 9 /* datakit protocols */
+#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
+#define AF_SNA 11 /* IBM SNA */
+#define AF_DECnet 12 /* DECnet */
+#define AF_DLI 13 /* Direct data link interface */
+#define AF_LAT 14 /* LAT */
+#define AF_HYLINK 15 /* NSC Hyperchannel */
+#define AF_APPLETALK 16 /* Apple Talk */
+#define AF_NIT 17 /* NIT */
+#define AF_802 18 /* IEEE 802.2, also ISO 8802 */
+#define AF_ISO 19 /* ISO protocols */
+#define AF_OSI AF_ISO
+#define AF_X25 20 /* CCITT X.25 in particular */
+#define AF_OSINET 21
+#define AF_GOSIP 22
+#define AF_MAX 22
+
+/*
+ * Structure used by kernel to store most
+ * addresses.
+ */
+struct sockaddr {
+ unsigned short sa_family; /* address family */
+ char sa_data[14]; /* up to 14 bytes of direct address */
+};
+
+/*
+ * Structure used by kernel to pass protocol
+ * information in raw sockets.
+ */
+struct sockproto {
+ unsigned short sp_family; /* address family */
+ unsigned short sp_protocol; /* protocol */
+};
+
+/*
+ * Protocol families, same as address families for now.
+ */
+#define PF_UNSPEC AF_UNSPEC
+#define PF_UNIX AF_UNIX
+#define PF_INET AF_INET
+#define PF_IMPLINK AF_IMPLINK
+#define PF_PUP AF_PUP
+#define PF_CHAOS AF_CHAOS
+#define PF_NS AF_NS
+#define PF_NBS AF_NBS
+#define PF_ECMA AF_ECMA
+#define PF_DATAKIT AF_DATAKIT
+#define PF_CCITT AF_CCITT
+#define PF_SNA AF_SNA
+#define PF_DECnet AF_DECnet
+#define PF_DLI AF_DLI
+#define PF_LAT AF_LAT
+#define PF_HYLINK AF_HYLINK
+#define PF_APPLETALK AF_APPLETALK
+#define PF_NIT AF_NIT
+#define PF_802 AF_802
+#define PF_ISO AF_ISO
+#define PF_OSI AF_ISO
+#define PF_X25 AF_X25
+#define PF_OSINET AF_OSINET
+#define PF_GOSIP AF_GOSIP
+#define PF_MAX AF_MAX
+
+/*
+ * Maximum queue length specifiable by listen.
+ */
+#define SOMAXCONN 5
+
+/*
+ * Message header for recvmsg and sendmsg calls.
+ */
+struct msghdr {
+ caddr_t msg_name; /* optional address */
+ int msg_namelen; /* size of address */
+ struct iovec *msg_iov; /* scatter/gather array */
+ int msg_iovlen; /* # elements in msg_iov */
+ caddr_t msg_accrights; /* access rights sent/received */
+ int msg_accrightslen;
+};
+
+#define MSG_OOB 0x1 /* process out-of-band data */
+#define MSG_PEEK 0x2 /* peek at incoming message */
+#define MSG_DONTROUTE 0x4 /* send without using routing tables */
+
+#define MSG_MAXIOVLEN 16
+
+#include <sys/cdefs.h>
+/*
+ * Functions
+ */
+
+__BEGIN_DECLS
+
+int accept __P_((int, struct sockaddr *, int *));
+int bind __P_((int, const struct sockaddr *, int));
+int connect __P_((int, const struct sockaddr *, int));
+int listen __P_((int, int));
+int socket __P_((int, int, int));
+int setsockopt __P_((int, int, int, const void *, int));
+int getsockname __P_((int, struct sockaddr *, int *));
+int shutdown __P_((int, int));
+int getpeername __P_((int, struct sockaddr *, int *));
+__END_DECLS
+
+#endif /* _SYS_SOCKET_H */
diff --git a/mit-pthreads/machdep/sunos-5.5/timers.h b/mit-pthreads/machdep/sunos-5.5/timers.h
new file mode 100755
index 00000000000..3aad5f80065
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.5/timers.h
@@ -0,0 +1,70 @@
+/* ==== 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$
+ *
+ * Description : Basic timers header.
+ *
+ * 1.00 94/06/13 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS_TIMERS_H_
+#define _SYS_TIMERS_H_
+
+#include <sys/types.h>
+#include <time.h>
+
+#define tv_sec tv_sec
+#define tv_nsec tv_nsec
+
+#define TIMEVAL_TO_TIMESPEC(tv, ts) { \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000; \
+}
+#define TIMESPEC_TO_TIMEVAL(tv, ts) { \
+ (tv)->tv_sec = (ts)->tv_sec; \
+ (tv)->tv_usec = (ts)->tv_nsec / 1000; \
+}
+
+/*
+ * New functions
+ */
+
+#ifdef NOT_USED
+int gettimeofday __P_((struct timeval *,struct timezone *)); /* for sleep.h */
+#endif
+
+__BEGIN_DECLS
+
+__END_DECLS
+
+#endif
diff --git a/mit-pthreads/machdep/sunos-5.5/uio.h b/mit-pthreads/machdep/sunos-5.5/uio.h
new file mode 100755
index 00000000000..7786142dd87
--- /dev/null
+++ b/mit-pthreads/machdep/sunos-5.5/uio.h
@@ -0,0 +1,40 @@
+/* ==== uio.h ============================================================
+ * Copyright (c) 1994 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Correct Solaris header file.
+ */
+
+#ifndef _PTHREAD_UIO_H_
+#define _PTHREAD_UIO_H_
+
+#include <sys/cdefs.h>
+
+struct iovec {
+ void *iov_base;
+ size_t iov_len;
+};
+
+typedef struct iovec iovec_t;
+
+struct uio {
+ iovec_t *uio_iov; /* pointer to array of iovecs */
+ int uio_iovcnt; /* number of iovecs */
+ /* These are all bogus */
+ int _uio_offset; /* file offset */
+ int uio_segflg; /* address space (kernel or user) */
+ short uio_fmode; /* file mode flags */
+ int _uio_limit; /* u-limit (maximum "block" offset) */
+ int uio_resid; /* residual count */
+};
+
+typedef struct uio uio_t;
+
+__BEGIN_DECLS
+
+int readv __P_((int, const struct iovec *, int));
+int writev __P_((int, const struct iovec *, int));
+
+__END_DECLS
+
+#endif
+
diff --git a/mit-pthreads/machdep/syscall-alpha-netbsd-1.1.S b/mit-pthreads/machdep/syscall-alpha-netbsd-1.1.S
new file mode 100644
index 00000000000..5b7dd017426
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-alpha-netbsd-1.1.S
@@ -0,0 +1,206 @@
+#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
diff --git a/mit-pthreads/machdep/syscall-alpha-netbsd-1.3.S b/mit-pthreads/machdep/syscall-alpha-netbsd-1.3.S
new file mode 100644
index 00000000000..61435a729d7
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-alpha-netbsd-1.3.S
@@ -0,0 +1,228 @@
+#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
+
+#ifndef SYS___sigsuspend14
+/* 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
+#endif /* SYS_sigsuspend14 */
+
+#ifndef SYS___sigprocmask14
+/* 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
+#endif /* SYS_sigprocmask14 */
+
+/* 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/mit-pthreads/machdep/syscall-alpha-osf1.S b/mit-pthreads/machdep/syscall-alpha-osf1.S
new file mode 100644
index 00000000000..fad823a7352
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-alpha-osf1.S
@@ -0,0 +1,97 @@
+#include <asm.h>
+#include <regdef.h>
+#define COMPAT_43
+#include <syscall.h>
+
+#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, 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 machdep_sys_##x
+
+ .globl machdep_cerror
+machdep_cerror:
+ br t0, 1f
+1:
+ 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
+
+/* So is the sigsuspend system call */
+ .align 4
+ .globl machdep_sys_sigsuspend
+ .ent machdep_sys_sigsuspend, 0
+machdep_sys_sigsuspend:
+ .frame sp,0,ra
+
+ bis a0, a0, a1
+ ldq a0, 0(a1)
+ ldiq v0, SYS_sigsuspend
+ CHMK()
+ ret
+ .end machdep_sys_sigsuspend
+
+/* More stuff ... */
+ .align 4
+ .globl machdep_restore_from_setjmp
+ .ent machdep_restore_from_setjmp, 0
+machdep_restore_from_setjmp:
+ .frame sp, 16, ra
+ ldgp gp, 0(t12)
+ lda sp, -16(sp)
+ stq ra, 0(sp)
+ ldq v0, 280(a0)
+ subq v0, 0x00000000acedbade, t0
+ bne t0, botch
+ cmoveq a1, 0x1, a1
+ stq a1, 32(a0)
+ ldiq v0, 0x67
+ call_pal 0x83
+botch:
+ /* This should cause the program to crash. Eventually, fix it
+ up to print a message first. */
+ jsr abort
+ .end machdep_restore_from_setjmp
diff --git a/mit-pthreads/machdep/syscall-arm32-netbsd-1.3.S b/mit-pthreads/machdep/syscall-arm32-netbsd-1.3.S
new file mode 100644
index 00000000000..5914674b508
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-arm32-netbsd-1.3.S
@@ -0,0 +1,193 @@
+/* ==== syscall.S ============================================================
+ * Copyright (c) 1990 The Regents of the University of California.
+ * Copyright (c) 1993 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
+ *
+ * 1.00 93/08/26 proven
+ * -Started coding this file.
+ *
+ * 1.01 93/11/13 proven
+ * -The functions readv() and writev() added.
+ */
+
+#ifndef lint
+ .text
+ .asciz "$Id$";
+#endif
+
+#if defined(SYSLIBC_SCCS) && !defined(lint)
+ .asciz "@(#)syscall.s 5.1 (Berkeley) 4/23/90"
+#endif /* SYSLIBC_SCCS and not lint */
+
+#include <machine/asm.h>
+#include <sys/syscall.h>
+
+/*
+ * Initial asm stuff for all functions.
+ */
+ .text
+ .align 0
+
+
+/* ==========================================================================
+ * machdep_sys_fork()
+ */
+ .globl _C_LABEL(machdep_sys_fork);
+
+_C_LABEL(machdep_sys_fork):;
+
+ swi SYS_fork
+ bcs 1f
+ sub r1, r1, #0x00000001
+ and r0, r0, r1
+ mov r15, r14
+
+
+
+/* ==========================================================================
+ * machdep_sys_fstat()
+ */
+ .globl _C_LABEL(machdep_sys_fstat);
+
+_C_LABEL(machdep_sys_fstat):;
+
+ swi SYS___fstat13
+ bcs 1f
+ mov r15, r14
+
+/* ==========================================================================
+ * machdep_sys___syscall()
+ */
+
+_machdep_sys___syscall:;
+
+ swi SYS___syscall
+ bcs 1f
+ mov r15, r14
+
+
+#ifndef SYS___sigsuspend14
+/* ==========================================================================
+ * machdep_sys_sigsuspend()
+ */
+ .globl _C_LABEL(machdep_sys_sigsuspend);
+
+_C_LABEL(machdep_sys_sigsuspend):;
+
+ ldr r0, [r0]
+ swi SYS_sigsuspend
+ bcs 1f
+ mov r0, #0x00000000
+ mov r15, r14
+
+#endif
+
+#ifndef SYS___sigprocmask14
+/* ==========================================================================
+ * machdep_sys_sigprocmask()
+ */
+ .globl _C_LABEL(machdep_sys_sigprocmask);
+
+_C_LABEL(machdep_sys_sigprocmask):;
+
+ teq r1, #0x00000000
+ moveq r0, #0x00000001
+ moveq r1, #0x00000000
+ ldrne r1, [r1]
+ swi SYS_sigprocmask
+ bcs 1f
+ teq r2, #0x00000000
+ strne r0, [r2]
+ mov r0, #0x00000000
+ mov r15, r14
+#endif
+
+/* ==========================================================================
+ * machdep_sys_ftruncate()
+ */
+ .global _C_LABEL(machdep_sys_ftruncate)
+_C_LABEL(machdep_sys_ftruncate):
+ mov r12, r13
+ stmfd r13!, {r11, r12, r14, r15}
+ sub r13, r13, #8
+ stmia r13, {r1-r2}
+ mov r3, #0
+ sub r11, r12, #4
+ mov r2, r0
+ mov r1, #0
+ mov r0, #201
+ bl _machdep_sys___syscall
+ ldmea r11, {r11, r13, r15}
+
+/* ==========================================================================
+ * machdep_sys_lseek()
+ */
+ .global _C_LABEL(machdep_sys_lseek)
+
+_C_LABEL(machdep_sys_lseek):
+ mov r12, r13
+ stmfd r13!, {r11, r12, r14, r15}
+ str r3, [r13, #-4]!
+ sub r13, r13, #8
+ stmia r13, {r1-r2}
+ sub r11, r12, #4
+ mov r3, #0
+ mov r2, r0
+ mov r1, #0
+ mov r0, #SYS_lseek
+ bl _machdep_sys___syscall
+ ldmea r11, {r11, r13, r15}
+
+/* ==========================================================================
+ * machdep_sys_pipe()
+ */
+ .globl _C_LABEL(machdep_sys_pipe);
+
+_C_LABEL(machdep_sys_pipe):;
+
+ mov r2, r0
+ swi SYS_pipe
+ bcs 1f
+ str r0, [r2, #0x0000]
+ str r1, [r2, #0x0004]
+ mov r0, #0x00000000
+ mov r15, r14
+
+
+1:
+ rsb r0, r0, #0x00000000
+ mvn r1, #0x00000000
+ mov r15, r14
diff --git a/mit-pthreads/machdep/syscall-hppa-hpux-10.20.S b/mit-pthreads/machdep/syscall-hppa-hpux-10.20.S
new file mode 100644
index 00000000000..c63d845bae5
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-hppa-hpux-10.20.S
@@ -0,0 +1,23 @@
+ .CODE
+
+machdep_error
+ sub %r0,%r28,%r28
+ bv,n %r0(%r2)
+
+machdep_sys_fork
+
+ .PROC
+ .CALLINFO NO_CALLS,FRAME=0
+
+ ldil -0x80000,%r1
+ ble 4(%sr7,%r1)
+ ldi 2 ,%r22
+ or,= %r0,%r22,%r0
+ b,n machdep_error
+ or,= %r29,%r0,%r0
+ copy %r0,%r28
+ bv,n %r0(%r2)
+
+ .PROCEND
+ .EXPORT machdep_sys_fork,ENTRY
+
diff --git a/mit-pthreads/machdep/syscall-hppa-hpux-9.03.S b/mit-pthreads/machdep/syscall-hppa-hpux-9.03.S
new file mode 100644
index 00000000000..c63d845bae5
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-hppa-hpux-9.03.S
@@ -0,0 +1,23 @@
+ .CODE
+
+machdep_error
+ sub %r0,%r28,%r28
+ bv,n %r0(%r2)
+
+machdep_sys_fork
+
+ .PROC
+ .CALLINFO NO_CALLS,FRAME=0
+
+ ldil -0x80000,%r1
+ ble 4(%sr7,%r1)
+ ldi 2 ,%r22
+ or,= %r0,%r22,%r0
+ b,n machdep_error
+ or,= %r29,%r0,%r0
+ copy %r0,%r28
+ bv,n %r0(%r2)
+
+ .PROCEND
+ .EXPORT machdep_sys_fork,ENTRY
+
diff --git a/mit-pthreads/machdep/syscall-i386-bsdi-1.1.S b/mit-pthreads/machdep/syscall-i386-bsdi-1.1.S
new file mode 100644
index 00000000000..e54cd0d0773
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-i386-bsdi-1.1.S
@@ -0,0 +1,288 @@
+/* ==== syscall.S ============================================================
+ * Copyright (c) 1990 The Regents of the University of California.
+ * Copyright (c) 1993 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
+ *
+ * 1.00 93/08/26 proven
+ * -Started coding this file.
+ *
+ * 1.01 93/11/13 proven
+ * -The functions readv() and writev() added.
+ */
+
+#ifndef lint
+ .text
+ .asciz "$Id$";
+#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>
+
+#define SYSCALL(x) \
+ .globl _machdep_sys_/**/x; \
+ \
+_machdep_sys_/**/x:; \
+ \
+ movl $(SYS_/**/x), %eax; \
+ .byte 0x9a; .long 0; .word 7; \
+ jb 1b; \
+ ret;
+
+/*
+ * 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_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)
+
+/* ==========================================================================
+ * machdep_sys_pipe()
+ */
+SYSCALL(pipe)
+
+/* ==========================================================================
+ * machdep_sys_dup()
+ */
+SYSCALL(dup)
+
+/* ==========================================================================
+ * machdep_sys_dup2()
+ */
+SYSCALL(dup2)
+
+/* ==========================================================================
+ * 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_execve()
+ */
+SYSCALL(execve)
+
+/* ==========================================================================
+ * machdep_sys_fstat()
+ */
+SYSCALL(fstat)
+
+/* ==========================================================================
+ * machdep_sys_fchown()
+ */
+SYSCALL(fchown)
+
+/* ==========================================================================
+ * machdep_sys_fchmod()
+ */
+SYSCALL(fchmod)
+
+/* ==========================================================================
+ * machdep_sys_chown()
+ */
+SYSCALL(chown)
+
+/* ==========================================================================
+ * machdep_sys_chmod()
+ */
+SYSCALL(chmod)
+
+/* ==========================================================================
+ * machdep_sys_chdir()
+ */
+SYSCALL(chdir)
+
+/* ==========================================================================
+ * machdep_sys_chdir()
+ */
+SYSCALL(link)
+
+/* ==========================================================================
+ * machdep_sys_chdir()
+ */
+SYSCALL(unlink)
+
+/* ==========================================================================
+ * machdep_sys_chdir()
+ */
+SYSCALL(rename)
+
+/* ==========================================================================
+ * Nonstandard calls used to make the system work
+ *
+ * ==========================================================================
+ * machdep_sys_select()
+ */
+SYSCALL(select)
+
+/* ==========================================================================
+ * machdep_sys_getdirentries()
+ */
+SYSCALL(getdirentries)
+
+/* ==========================================================================
+ * machdep_sys_wait4()
+ */
+SYSCALL(wait4)
+
+/* ==========================================================================
+ * 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)
+
+/* ==========================================================================
+ * machdep_sys_sendto()
+ */
+SYSCALL(sendto)
+
+/* ==========================================================================
+ * machdep_sys_recvfrom()
+ */
+SYSCALL(recvfrom)
+
+/* ==========================================================================
+ * machdep_sys_sendmsg()
+ */
+SYSCALL(sendmsg)
+
+/* ==========================================================================
+ * machdep_sys_recvmsg()
+ */
+SYSCALL(recvmsg)
+
+/* ==========================================================================
+ * machdep_sys_shutdown() - Is this correct?
+ */
+SYSCALL(shutdown)
+
diff --git a/mit-pthreads/machdep/syscall-i386-bsdi-2.0.S b/mit-pthreads/machdep/syscall-i386-bsdi-2.0.S
new file mode 100644
index 00000000000..8a56717da31
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-i386-bsdi-2.0.S
@@ -0,0 +1,294 @@
+/* ==== syscall.S ============================================================
+ * Copyright (c) 1990 The Regents of the University of California.
+ * Copyright (c) 1993 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
+ *
+ * 1.00 93/08/26 proven
+ * -Started coding this file.
+ *
+ * 1.01 93/11/13 proven
+ * -The functions readv() and writev() added.
+ */
+
+#ifndef lint
+ .text
+ .asciz "syscall-i386-netbsd-1.0.S,v 1.56 1995/09/26 21:04:05 raeburn 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>
+
+/*
+ * 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_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
+
+
+/* BSDI DEFS.h,v 2.1 1995/02/03 06:28:24 polk Exp */
+
+/*-
+ * Copyright (c) 1990, 1993
+ * 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.
+ *
+ * @(#)DEFS.h 8.1 (Berkeley) 6/4/93
+ */
+
+#ifdef PROF
+#define ENTRY(x) .globl _/**/x; .align 2; _/**/x: \
+ .data; 1:; .long 0; .text; \
+ pushl %ebp; movl %esp,%ebp; \
+ leal 1b,%eax; call mcount; leave
+#define ASENTRY(x) .globl x; .align 2; x: \
+ .data; 1:; .long 0; .text; \
+ pushl %ebp; movl %esp,%ebp; \
+ leal 1b,%eax; call mcount; leave
+#else
+#define ENTRY(x) .globl _/**/x; .align 2; _/**/x:
+#define ASENTRY(x) .globl x; .align 2; x:
+#endif
+
+/*-
+ * Copyright (c) 1990, 1993
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)_setjmp.s 8.1 (Berkeley) 6/4/93"
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * C library -- _setjmp, _longjmp
+ *
+ * _longjmp(a,v)
+ * will generate a "return(v)" from the last call to
+ * _setjmp(a)
+ * by restoring registers from the stack.
+ * The previous signal state is NOT restored.
+ */
+
+
+.globl __setjmp; /* Patch by Jan Legenhausen (monty) */
+.align 2;
+__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)
+ movl $0,%eax
+ ret
+
+.globl __longjmp; /* Patch by Jan Legenhausen ? (monty) */
+.align 2;
+__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
+ cmpl $0,%eax
+ jne 1f
+ movl $1,%eax
+1: movl %ecx,0(%esp)
+ ret
diff --git a/mit-pthreads/machdep/syscall-i386-freebsd-1.1.S b/mit-pthreads/machdep/syscall-i386-freebsd-1.1.S
new file mode 100644
index 00000000000..5777cc5e06d
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-i386-freebsd-1.1.S
@@ -0,0 +1,293 @@
+/* ==== syscall.S ============================================================
+ * Copyright (c) 1990 The Regents of the University of California.
+ * Copyright (c) 1993 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
+ *
+ * 1.00 93/08/26 proven
+ * -Started coding this file.
+ *
+ * 1.01 93/11/13 proven
+ * -The functions readv() and writev() added.
+ */
+
+#ifndef lint
+ .text
+ .asciz "$Id$";
+#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>
+
+#define SYSCALL(x) \
+ .globl _machdep_sys_/**/x; \
+ \
+_machdep_sys_/**/x:; \
+ \
+ movl $(SYS_/**/x), %eax; \
+ .byte 0x9a; .long 0; .word 7; \
+ jb 1b; \
+ ret;
+
+/*
+ * 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_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)
+
+/* ==========================================================================
+ * machdep_sys_stat()
+ */
+SYSCALL(stat)
+
+/* ==========================================================================
+ * machdep_sys_pipe()
+ */
+SYSCALL(pipe)
+
+/* ==========================================================================
+ * machdep_sys_dup()
+ */
+SYSCALL(dup)
+
+/* ==========================================================================
+ * machdep_sys_dup2()
+ */
+SYSCALL(dup2)
+
+/* ==========================================================================
+ * 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_execve()
+ */
+SYSCALL(execve)
+
+/* ==========================================================================
+ * machdep_sys_fstat()
+ */
+SYSCALL(fstat)
+
+/* ==========================================================================
+ * machdep_sys_fchown()
+ */
+SYSCALL(fchown)
+
+/* ==========================================================================
+ * machdep_sys_fchmod()
+ */
+SYSCALL(fchmod)
+
+/* ==========================================================================
+ * machdep_sys_chown()
+ */
+SYSCALL(chown)
+
+/* ==========================================================================
+ * machdep_sys_chmod()
+ */
+SYSCALL(chmod)
+
+/* ==========================================================================
+ * machdep_sys_chdir()
+ */
+SYSCALL(chdir)
+
+/* ==========================================================================
+ * machdep_sys_chdir()
+ */
+SYSCALL(link)
+
+/* ==========================================================================
+ * machdep_sys_chdir()
+ */
+SYSCALL(unlink)
+
+/* ==========================================================================
+ * machdep_sys_chdir()
+ */
+SYSCALL(rename)
+
+/* ==========================================================================
+ * Nonstandard calls used to make the system work
+ *
+ * ==========================================================================
+ * machdep_sys_select()
+ */
+SYSCALL(select)
+
+/* ==========================================================================
+ * machdep_sys_getdirentries()
+ */
+SYSCALL(getdirentries)
+
+/* ==========================================================================
+ * machdep_sys_wait4()
+ */
+SYSCALL(wait4)
+
+/* ==========================================================================
+ * 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)
+
+/* ==========================================================================
+ * machdep_sys_sendto()
+ */
+SYSCALL(sendto)
+
+/* ==========================================================================
+ * machdep_sys_recvfrom()
+ */
+SYSCALL(recvfrom)
+
+/* ==========================================================================
+ * machdep_sys_sendmsg()
+ */
+SYSCALL(sendmsg)
+
+/* ==========================================================================
+ * machdep_sys_recvmsg()
+ */
+SYSCALL(recvmsg)
+
+/* ==========================================================================
+ * machdep_sys_shutdown()
+ */
+SYSCALL(shutdown)
+
diff --git a/mit-pthreads/machdep/syscall-i386-freebsd-2.0.S b/mit-pthreads/machdep/syscall-i386-freebsd-2.0.S
new file mode 100644
index 00000000000..b713bcac344
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-i386-freebsd-2.0.S
@@ -0,0 +1,240 @@
+/* ==== 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__
+
+#ifdef __ELF__
+#define NAME(X) machdep_sys_##X
+#else
+#define NAME(X) _machdep_sys_##X
+#endif
+
+#else
+
+#ifdef __ELF__
+#define NAME(X) machdep_sys_/**/X
+#else
+#define NAME(X) _machdep_sys_/**/X
+#endif
+
+#endif
+
+#ifdef __ELF__
+#define END(X) 5: ; .type NAME(X),@function ; .size NAME(X),5b - NAME(X)
+#define KERNCALL int $0x80
+#else
+#define END(X)
+#define KERNCALL .byte 0x9a; .long 0; .word 7;
+#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 NAME(fork);
+
+NAME(fork):;
+
+ movl $(SYS_fork), %eax;
+ KERNCALL;
+ cmpl $0, %edx
+ je 2f
+ movl $0, %eax
+2:
+ ret;
+ END(fork)
+
+/* ==========================================================================
+ * machdep_sys___syscall()
+ */
+
+_machdep_sys___syscall:;
+
+ movl $(SYS___syscall), %eax;
+ KERNCALL;
+ jb 3f;
+ ret
+
+/* ==========================================================================
+ * machdep_sys_sigsuspend()
+ */
+ .globl NAME(sigsuspend);
+
+NAME(sigsuspend):;
+
+ movl 4(%esp),%eax # fetch mask arg
+ movl (%eax),%eax # indirect to mask arg
+ movl %eax,4(%esp)
+ movl $(SYS_sigsuspend), %eax;
+ KERNCALL;
+ jb 3f;
+ ret
+3:
+ neg %eax
+ movl $0xffffffff,%edx
+ ret
+ END(sigsuspend)
+
+/* ==========================================================================
+ * machdep_sys_sigprocmask()
+ */
+ .globl NAME(sigprocmask);
+
+NAME(sigprocmask):;
+
+ movl 8(%esp),%ecx
+ movl (%ecx),%ecx
+ movl %ecx,8(%esp)
+ movl $ SYS_sigprocmask , %eax
+ KERNCALL;
+ jb 4f;
+ ret
+4:
+ neg %eax
+ movl $0xffffffff,%edx
+ ret
+ END(sigprocmask)
+
+/* ==========================================================================
+ * machdep_sys_lseek()
+ */
+ .globl NAME(lseek);
+
+NAME(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
+ END(lseek)
+
+/* ==========================================================================
+ * machdep_sys_ftruncate() ; Added by Monty
+ */
+ .globl NAME(ftruncate);
+
+NAME(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
+ END(ftruncate)
+
+/* ==========================================================================
+ * machdep_sys_setjmp()
+ */
+ .globl NAME(setjmp);
+
+NAME(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
+ END(setjmp)
+
+/* ==========================================================================
+ * machdep_sys_longjmp()
+ */
+ .globl NAME(longjmp);
+
+NAME(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
+ END(longjmp)
diff --git a/mit-pthreads/machdep/syscall-i386-linux-1.0.S b/mit-pthreads/machdep/syscall-i386-linux-1.0.S
new file mode 100644
index 00000000000..1399c812e2f
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-i386-linux-1.0.S
@@ -0,0 +1,406 @@
+/* ==== syscall.S ============================================================
+ * Copyright (c) 1994 Chris Provenzano, proven@mit.edu
+ * All rights reserved.
+ *
+ * Description : Machine dependent syscalls for i386/i486/i586
+ *
+ * 1.00 93/08/26 proven
+ * -Started coding this file.
+ *
+ * 1.01 93/11/13 proven
+ * -The functions readv() and writev() added.
+ *
+ * 1.16 94/01/30 proven
+ * -This file now requires gas version 2.0 or greater.
+ */
+
+#ifndef lint
+ .text
+ .asciz "$Id$";
+#endif
+
+#include <sys/syscall.h>
+#include <config.h>
+
+#ifdef __ELF__
+
+#define NAME(X) machdep_sys_##X
+#define END(X) 1: ; .type NAME(X),@function ; .size NAME(X),1b - NAME(X)
+
+#else
+
+#define NAME(X) _machdep_sys_##X
+#define END(X)
+
+#endif
+
+#define SYSCALL0(x) \
+ .globl NAME(x) ; \
+ \
+NAME(x): \
+ \
+ push %ebx; \
+ lea SYS_##x, %eax; \
+ int $0x80; \
+ pop %ebx; \
+ ret; \
+ \
+ END(x)
+
+#define SYSCALL1(x) \
+ .globl NAME(x) ; \
+ \
+NAME(x): \
+ \
+ push %ebx; \
+ mov 8(%esp), %ebx; \
+ lea SYS_##x, %eax; \
+ int $0x80; \
+ pop %ebx; \
+ ret; \
+ \
+ END(x)
+
+#define SYSCALL2(x) \
+ .globl NAME(x) ; \
+ \
+NAME(x): \
+ \
+ push %ebx; \
+ mov 8(%esp), %ebx; \
+ mov 12(%esp), %ecx; \
+ lea SYS_##x, %eax; \
+ int $0x80; \
+ pop %ebx; \
+ ret; \
+ \
+ END(x)
+
+#define STATCALL2(x) \
+ .globl NAME(x) ; \
+ \
+NAME(x): \
+ \
+ push %ebx; \
+ mov 8(%esp), %ebx; \
+ mov 12(%esp), %ecx; \
+ lea SYS_prev_##x, %eax; \
+ int $0x80; \
+ pop %ebx; \
+ ret; \
+ END(x)
+
+#define SYSCALL3(x) \
+ .globl NAME(x) ; \
+ \
+NAME(x): \
+ \
+ push %ebx; \
+ mov 8(%esp), %ebx; \
+ mov 12(%esp), %ecx; \
+ mov 16(%esp), %edx; \
+ lea SYS_##x, %eax; \
+ int $0x80; \
+ pop %ebx; \
+ ret; \
+ END(x)
+
+
+#define SYSCALL4(x) \
+ .globl NAME(x) ; \
+ \
+NAME(x): \
+ \
+ push %ebx; \
+ push %esi; \
+ mov 12(%esp), %ebx; \
+ mov 16(%esp), %ecx; \
+ mov 20(%esp), %edx; \
+ mov 24(%esp), %esi; \
+ lea SYS_##x, %eax; \
+ int $0x80; \
+ pop %esi; \
+ pop %ebx; \
+ ret; \
+ END(x)
+
+#define SYSCALL5(x) \
+ .globl NAME(x) ; \
+ \
+NAME(x): \
+ \
+ push %ebx; \
+ push %esi; \
+ push %edi; \
+ mov 16(%esp), %ebx; \
+ mov 20(%esp), %ecx; \
+ mov 24(%esp), %edx; \
+ mov 28(%esp), %esi; \
+ mov 32(%esp), %edi; \
+ lea SYS_##x, %eax; \
+ int $0x80; \
+ pop %edi; \
+ pop %esi; \
+ pop %ebx; \
+ ret; \
+ END(x)
+
+/* =========================================================================
+ * exit 1 select 82
+ * fork 2 fstatfs 100
+ * read 3 socketcall 102
+ * write 4 flock 143
+ * open 5 readv 145
+ * creat 8 writev 146
+ * link 9
+ * unlink 10
+ * execve 11
+ * chdir 12
+ * chmod 15
+ * chown 16
+ * lseek 19
+ * rename 38
+ * dup 41
+ * pipe 42
+ * ioctl 54
+ * fcntl 55
+ * dup2 63
+ * readdir 89
+ * ftruncate 93
+ * fchmod 94
+ * fchown 95
+ */
+
+/*
+ * Initial asm stuff for all functions.
+ */
+ .text
+ .align 2
+
+
+/* ==========================================================================
+ * machdep_sys_read()
+ */
+SYSCALL3(read)
+
+/* ==========================================================================
+ * machdep_sys_write()
+ */
+SYSCALL3(write)
+
+/* ==========================================================================
+ * machdep_sys_open()
+ */
+SYSCALL3(open)
+
+/* ==========================================================================
+ * machdep_sys_close()
+ */
+SYSCALL1(close)
+
+/* ==========================================================================
+ * machdep_sys_creat()
+ */
+SYSCALL2(creat)
+
+/* ==========================================================================
+ * machdep_sys_dup2()
+ */
+SYSCALL2(dup2)
+
+/* ==========================================================================
+ * machdep_sys_fcntl()
+ */
+SYSCALL3(fcntl)
+
+/* ==========================================================================
+ * machdep_sys_fchown()
+ */
+SYSCALL3(fchown)
+
+/* ==========================================================================
+ * machdep_sys_fchmod()
+ */
+SYSCALL2(fchmod)
+
+/* ==========================================================================
+ * machdep_sys_ioctl()
+ */
+SYSCALL3(ioctl)
+
+/* ==========================================================================
+ * machdep_sys_chown()
+ */
+SYSCALL3(chown)
+
+/* ==========================================================================
+ * machdep_sys_chmod()
+ */
+SYSCALL2(chmod)
+
+/* ==========================================================================
+ * machdep_sys_chdir()
+ */
+SYSCALL1(chdir)
+
+/* ==========================================================================
+ * machdep_sys_unlink()
+ */
+SYSCALL1(unlink)
+
+/* ==========================================================================
+ * machdep_sys_link()
+ */
+SYSCALL2(link)
+
+/* ==========================================================================
+ * machdep_sys_rename()
+ */
+SYSCALL2(rename)
+
+/* ==========================================================================
+ * machdep_sys_lseek()
+ */
+SYSCALL3(lseek)
+
+/* ==========================================================================
+ * machdep_sys_pipe()
+ */
+SYSCALL1(pipe)
+
+/* ==========================================================================
+ * machdep_sys_dup()
+ */
+SYSCALL1(dup)
+
+/* ==========================================================================
+ * machdep_sys_fork()
+ */
+SYSCALL0(fork)
+
+/* ==========================================================================
+ * machdep_sys_execve()
+ */
+SYSCALL3(execve)
+
+/* ==========================================================================
+ * machdep_sys_stat()
+ */
+#ifdef __ELF__
+STATCALL2(stat)
+#else
+SYSCALL2(stat)
+#endif
+
+/* ==========================================================================
+ * machdep_sys_fstat()
+ */
+#ifdef __ELF__
+STATCALL2(fstat)
+#else
+SYSCALL2(fstat)
+#endif
+
+/* ==========================================================================
+ * machdep_sys_lstat()
+ */
+#ifdef __ELF__
+STATCALL2(lstat)
+#else
+SYSCALL2(lstat)
+#endif
+
+/* ==========================================================================
+ * machdep_sys_fstatfs()
+ */
+SYSCALL2(fstatfs)
+
+
+/* ==========================================================================
+ * machdep_sys_ftruncate()
+ */
+SYSCALL2(ftruncate)
+
+/* ==========================================================================
+ * Nonstandard calls used to make the system work
+ *
+ * ==========================================================================
+ * machdep_sys_select()
+ */
+
+ .globl NAME(select)
+
+NAME(select):
+
+ push %ebx
+ lea 8(%esp), %ebx
+ lea SYS_select, %eax
+ int $0x80
+ pop %ebx
+ ret
+ END(select)
+
+/* ==========================================================================
+ * machdep_sys_wait4()
+ */
+SYSCALL4(wait4)
+
+/* ==========================================================================
+ * machdep_sys_readdir()
+ */
+SYSCALL3(readdir)
+
+/* ==========================================================================
+ * machdep_sys_socketcall()
+ */
+SYSCALL2(socketcall)
+
+
+SYSCALL1(exit)
+SYSCALL3(sigprocmask)
+
+/* ==========================================================================
+ * machdep_sys_sigsuspend()
+ */
+
+ .globl NAME(sigsuspend)
+
+NAME(sigsuspend):
+
+ push %ebp
+ mov %esp,%ebp
+ push %edi
+ push %esi
+ push %ebx
+ mov 8(%ebp), %edx
+ mov (%edx), %edx
+ lea SYS_sigsuspend, %eax
+ int $0x80
+ pop %ebx
+ pop %esi
+ pop %edi
+ mov %ebp,%esp
+ pop %ebp
+ ret
+ END(sigsuspend)
+
+/* ==========================================================================
+ * machdep_sys_readv()
+ */
+#ifdef HAVE_SYSCALL_READV
+SYSCALL3(readv)
+#endif
+
+/* ==========================================================================
+ * machdep_sys_writev()
+ */
+#ifdef HAVE_SYSCALL_WRITEV
+SYSCALL3(writev)
+#endif
+
+/* ==========================================================================
+ * machdep_sys_flock()
+ */
+#ifdef HAVE_SYSCALL_FLOCK
+SYSCALL2(flock)
+#endif
diff --git a/mit-pthreads/machdep/syscall-i386-linux-2.0.S b/mit-pthreads/machdep/syscall-i386-linux-2.0.S
new file mode 100644
index 00000000000..d5807b2d9b4
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-i386-linux-2.0.S
@@ -0,0 +1,389 @@
+/* ==== syscall.S ============================================================
+ * Copyright (c) 1994 Chris Provenzano, proven@mit.edu
+ * All rights reserved.
+ *
+ * Description : Machine dependent syscalls for i386/i486/i586
+ *
+ * 1.00 93/08/26 proven
+ * -Started coding this file.
+ *
+ * 1.01 93/11/13 proven
+ * -The functions readv() and writev() added.
+ *
+ * 1.16 94/01/30 proven
+ * -This file now requires gas version 2.0 or greater.
+ */
+
+#ifndef lint
+ .text
+ .asciz "$Id$";
+#endif
+
+#include <sys/syscall.h>
+#include <config.h>
+
+#ifdef __ELF__
+
+#define NAME(X) machdep_sys_##X
+#define END(X) 1: ; .type NAME(X),@function ; .size NAME(X),1b - NAME(X)
+
+#else
+
+#define NAME(X) _machdep_sys_##X
+#define END(X)
+
+#endif
+
+#define SYSCALL0(x) \
+ .globl NAME(x) ; \
+ \
+NAME(x): \
+ \
+ push %ebx; \
+ lea SYS_##x, %eax; \
+ int $0x80; \
+ pop %ebx; \
+ ret; \
+ \
+ END(x)
+
+#define SYSCALL1(x) \
+ .globl NAME(x) ; \
+ \
+NAME(x): \
+ \
+ push %ebx; \
+ mov 8(%esp), %ebx; \
+ lea SYS_##x, %eax; \
+ int $0x80; \
+ pop %ebx; \
+ ret; \
+ \
+ END(x)
+
+#define SYSCALL2(x) \
+ .globl NAME(x) ; \
+ \
+NAME(x): \
+ \
+ push %ebx; \
+ mov 8(%esp), %ebx; \
+ mov 12(%esp), %ecx; \
+ lea SYS_##x, %eax; \
+ int $0x80; \
+ pop %ebx; \
+ ret; \
+ \
+ END(x)
+
+#define SYSCALL3(x) \
+ .globl NAME(x) ; \
+ \
+NAME(x): \
+ \
+ push %ebx; \
+ mov 8(%esp), %ebx; \
+ mov 12(%esp), %ecx; \
+ mov 16(%esp), %edx; \
+ lea SYS_##x, %eax; \
+ int $0x80; \
+ pop %ebx; \
+ ret; \
+ END(x)
+
+
+#define SYSCALL4(x) \
+ .globl NAME(x) ; \
+ \
+NAME(x): \
+ \
+ push %ebx; \
+ push %esi; \
+ mov 12(%esp), %ebx; \
+ mov 16(%esp), %ecx; \
+ mov 20(%esp), %edx; \
+ mov 24(%esp), %esi; \
+ lea SYS_##x, %eax; \
+ int $0x80; \
+ pop %esi; \
+ pop %ebx; \
+ ret; \
+ END(x)
+
+#define SYSCALL5(x) \
+ .globl NAME(x) ; \
+ \
+NAME(x): \
+ \
+ push %ebx; \
+ push %esi; \
+ push %edi; \
+ mov 16(%esp), %ebx; \
+ mov 20(%esp), %ecx; \
+ mov 24(%esp), %edx; \
+ mov 28(%esp), %esi; \
+ mov 32(%esp), %edi; \
+ lea SYS_##x, %eax; \
+ int $0x80; \
+ pop %edi; \
+ pop %esi; \
+ pop %ebx; \
+ ret; \
+ END(x)
+
+/* =========================================================================
+ * exit 1 select 82
+ * fork 2 fstatfs 100
+ * read 3 socketcall 102
+ * write 4 flock 143
+ * open 5 readv 145
+ * creat 8 writev 146
+ * link 9
+ * unlink 10
+ * execve 11
+ * chdir 12
+ * chmod 15
+ * chown 16
+ * lseek 19
+ * rename 38
+ * dup 41
+ * pipe 42
+ * ioctl 54
+ * fcntl 55
+ * dup2 63
+ * readdir 89
+ * ftruncate 93
+ * fchmod 94
+ * fchown 95
+ */
+
+/*
+ * Initial asm stuff for all functions.
+ */
+ .text
+ .align 2
+
+
+/* ==========================================================================
+ * machdep_sys_read()
+ */
+SYSCALL3(read)
+
+/* ==========================================================================
+ * machdep_sys_write()
+ */
+SYSCALL3(write)
+
+/* ==========================================================================
+ * machdep_sys_open()
+ */
+SYSCALL3(open)
+
+/* ==========================================================================
+ * machdep_sys_close()
+ */
+SYSCALL1(close)
+
+/* ==========================================================================
+ * machdep_sys_creat()
+ */
+SYSCALL2(creat)
+
+/* ==========================================================================
+ * machdep_sys_dup2()
+ */
+SYSCALL2(dup2)
+
+/* ==========================================================================
+ * machdep_sys_fcntl()
+ */
+SYSCALL3(fcntl)
+
+/* ==========================================================================
+ * machdep_sys_fchown()
+ */
+SYSCALL3(fchown)
+
+/* ==========================================================================
+ * machdep_sys_fchmod()
+ */
+SYSCALL2(fchmod)
+
+/* ==========================================================================
+ * machdep_sys_ioctl()
+ */
+SYSCALL3(ioctl)
+
+/* ==========================================================================
+ * machdep_sys_chown()
+ */
+SYSCALL3(chown)
+
+/* ==========================================================================
+ * machdep_sys_chmod()
+ */
+SYSCALL2(chmod)
+
+/* ==========================================================================
+ * machdep_sys_chdir()
+ */
+SYSCALL1(chdir)
+
+/* ==========================================================================
+ * machdep_sys_unlink()
+ */
+SYSCALL1(unlink)
+
+/* ==========================================================================
+ * machdep_sys_link()
+ */
+SYSCALL2(link)
+
+/* ==========================================================================
+ * machdep_sys_rename()
+ */
+SYSCALL2(rename)
+
+/* ==========================================================================
+ * machdep_sys_lseek()
+ */
+SYSCALL3(lseek)
+
+/* ==========================================================================
+ * machdep_sys_pipe()
+ */
+SYSCALL1(pipe)
+
+/* ==========================================================================
+ * machdep_sys_dup()
+ */
+SYSCALL1(dup)
+
+/* ==========================================================================
+ * machdep_sys_fork()
+ */
+SYSCALL0(fork)
+
+/* ==========================================================================
+ * machdep_sys_execve()
+ */
+SYSCALL3(execve)
+
+/* ==========================================================================
+ * machdep_sys_stat()
+ */
+SYSCALL2(stat)
+
+/* ==========================================================================
+ * machdep_sys_fstat()
+ */
+SYSCALL2(fstat)
+
+/* ==========================================================================
+ * machdep_sys_lstat()
+ */
+SYSCALL2(lstat)
+
+/* ==========================================================================
+ * machdep_sys_fstatfs()
+ */
+SYSCALL2(fstatfs)
+
+/* ==========================================================================
+ * machdep_sys_ftruncate()
+ */
+SYSCALL2(ftruncate)
+
+/* ==========================================================================
+ * machdep_sys_chroot()
+ */
+SYSCALL1(chroot)
+
+/* ==========================================================================
+ * machdep_sys_uname()
+ */
+SYSCALL1(uname)
+
+/* ==========================================================================
+ * Nonstandard calls used to make the system work
+ *
+ * ==========================================================================
+ * machdep_sys_select()
+ */
+
+ .globl NAME(select)
+
+NAME(select):
+
+ push %ebx
+ lea 8(%esp), %ebx
+ lea SYS_select, %eax
+ int $0x80
+ pop %ebx
+ ret
+ END(select)
+
+/* ==========================================================================
+ * machdep_sys_wait4()
+ */
+SYSCALL4(wait4)
+
+/* ==========================================================================
+ * machdep_sys_readdir()
+ */
+SYSCALL3(readdir)
+
+/* ==========================================================================
+ * machdep_sys_socketcall()
+ */
+SYSCALL2(socketcall)
+
+
+SYSCALL1(exit)
+SYSCALL3(sigprocmask)
+
+/* ==========================================================================
+ * machdep_sys_sigsuspend()
+ */
+
+ .globl NAME(sigsuspend)
+
+NAME(sigsuspend):
+
+ push %ebp
+ mov %esp,%ebp
+ push %edi
+ push %esi
+ push %ebx
+ mov 8(%ebp), %edx
+ mov (%edx), %edx
+ lea SYS_sigsuspend, %eax
+ int $0x80
+ pop %ebx
+ pop %esi
+ pop %edi
+ mov %ebp,%esp
+ pop %ebp
+ ret
+ END(sigsuspend)
+
+/* ==========================================================================
+ * machdep_sys_readv()
+ */
+#ifdef HAVE_SYSCALL_READV
+SYSCALL3(readv)
+#endif
+
+/* ==========================================================================
+ * machdep_sys_writev()
+ */
+#ifdef HAVE_SYSCALL_WRITEV
+SYSCALL3(writev)
+#endif
+
+/* ==========================================================================
+ * machdep_sys_flock()
+ */
+#ifdef HAVE_SYSCALL_FLOCK
+SYSCALL2(flock)
+#endif
diff --git a/mit-pthreads/machdep/syscall-i386-netbsd-0.9.S b/mit-pthreads/machdep/syscall-i386-netbsd-0.9.S
new file mode 100644
index 00000000000..8d768a673d3
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-i386-netbsd-0.9.S
@@ -0,0 +1,229 @@
+/* ==== syscall.S ============================================================
+ * Copyright (c) 1990 The Regents of the University of California.
+ * Copyright (c) 1993 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
+ *
+ * 1.00 93/08/26 proven
+ * -Started coding this file.
+ *
+ * 1.01 93/11/13 proven
+ * -The functions readv() and writev() added.
+ */
+
+#ifndef lint
+ .text
+ .asciz "$Id$";
+#endif
+
+#if defined(SYSLIBC_SCCS) && !defined(lint)
+ .asciz "@(#)syscall.s 5.1 (Berkeley) 4/23/90"
+#endif /* SYSLIBC_SCCS and not lint */
+
+#include <machine/asm.h>
+#include <sys/syscall.h>
+
+#define SYSCALL(x) \
+ .globl _machdep_sys_/**/x; \
+ \
+_machdep_sys_/**/x:; \
+ \
+ movl $(SYS_/**/x), %eax; \
+ .byte 0x9a; .long 0; .word 7; \
+ jb 1b; \
+ ret;
+
+/*
+ * 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_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)
+
+/* ==========================================================================
+ * machdep_sys_pipe()
+ */
+SYSCALL(pipe)
+
+/* ==========================================================================
+ * machdep_sys_dup()
+ */
+SYSCALL(dup)
+
+/* ==========================================================================
+ * machdep_sys_dup2()
+ */
+SYSCALL(dup2)
+
+/* ==========================================================================
+ * 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_execve()
+ */
+SYSCALL(execve)
+
+/* ==========================================================================
+ * machdep_sys_fstat()
+ */
+SYSCALL(fstat)
+
+/* ==========================================================================
+ * Nonstandard calls used to make the system work
+ *
+ * ==========================================================================
+ * machdep_sys_select()
+ */
+SYSCALL(select)
+
+/* ==========================================================================
+ * machdep_sys_getdirentries()
+ */
+SYSCALL(getdirentries)
+
+/* ==========================================================================
+ * 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)
+
+/* ==========================================================================
+ * machdep_sys_sendto()
+ */
+SYSCALL(sendto)
+
+/* ==========================================================================
+ * machdep_sys_recvfrom()
+ */
+SYSCALL(recvfrom)
+
diff --git a/mit-pthreads/machdep/syscall-i386-netbsd-1.0.S b/mit-pthreads/machdep/syscall-i386-netbsd-1.0.S
new file mode 100644
index 00000000000..da535dd2f80
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-i386-netbsd-1.0.S
@@ -0,0 +1,158 @@
+/* ==== syscall.S ============================================================
+ * Copyright (c) 1990 The Regents of the University of California.
+ * Copyright (c) 1993 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
+ *
+ * 1.00 93/08/26 proven
+ * -Started coding this file.
+ *
+ * 1.01 93/11/13 proven
+ * -The functions readv() and writev() added.
+ */
+
+#ifndef lint
+ .text
+ .asciz "$Id$";
+#endif
+
+#if defined(SYSLIBC_SCCS) && !defined(lint)
+ .asciz "@(#)syscall.s 5.1 (Berkeley) 4/23/90"
+#endif /* SYSLIBC_SCCS and not lint */
+
+#include <machine/asm.h>
+#include <sys/syscall.h>
+
+/*
+ * 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_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
diff --git a/mit-pthreads/machdep/syscall-i386-netbsd-1.1.S b/mit-pthreads/machdep/syscall-i386-netbsd-1.1.S
new file mode 100644
index 00000000000..a74d2ac1af6
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-i386-netbsd-1.1.S
@@ -0,0 +1,181 @@
+/* ==== syscall.S ============================================================
+ * Copyright (c) 1990 The Regents of the University of California.
+ * Copyright (c) 1993 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
+ *
+ * 1.00 93/08/26 proven
+ * -Started coding this file.
+ *
+ * 1.01 93/11/13 proven
+ * -The functions readv() and writev() added.
+ */
+
+#ifndef lint
+ .text
+ .asciz "$Id$";
+#endif
+
+#if defined(SYSLIBC_SCCS) && !defined(lint)
+ .asciz "@(#)syscall.s 5.1 (Berkeley) 4/23/90"
+#endif /* SYSLIBC_SCCS and not lint */
+
+#include <machine/asm.h>
+#include <sys/syscall.h>
+
+/*
+ * Initial asm stuff for all functions.
+ */
+ .text
+ .align 2
+
+
+/* ==========================================================================
+ * 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;
+ int $0x80;
+ 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;
+ int $0x80;
+ jb 3f;
+ ret
+
+3:
+
+ 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_sigprocmask()
+ */
+ .globl _machdep_sys_sigprocmask;
+
+_machdep_sys_sigprocmask:;
+
+ movl 8(%esp),%ecx
+ movl (%ecx),%ecx
+ movl %ecx,8(%esp)
+ movl $(SYS_sigprocmask), %eax;
+ int $0x80;
+ jb 3b;
+ ret
+
+/* ==========================================================================
+ * machdep_sys_pipe()
+ */
+ .globl _machdep_sys_pipe;
+
+_machdep_sys_pipe:;
+
+ movl $(SYS_pipe), %eax;
+ int $0x80;
+ jb 3b;
+ movl 4(%esp),%ecx
+ movl %eax,(%ecx)
+ movl %edx,4(%ecx)
+ xorl %eax,%eax
+ ret
+
diff --git a/mit-pthreads/machdep/syscall-i386-netbsd-1.3.S b/mit-pthreads/machdep/syscall-i386-netbsd-1.3.S
new file mode 100644
index 00000000000..85dc6b3e5bc
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-i386-netbsd-1.3.S
@@ -0,0 +1,200 @@
+/* ==== syscall.S ============================================================
+ * Copyright (c) 1990 The Regents of the University of California.
+ * Copyright (c) 1993 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
+ *
+ * 1.00 93/08/26 proven
+ * -Started coding this file.
+ *
+ * 1.01 93/11/13 proven
+ * -The functions readv() and writev() added.
+ */
+
+#ifndef lint
+ .text
+ .asciz "$Id$";
+#endif
+
+#if defined(SYSLIBC_SCCS) && !defined(lint)
+ .asciz "@(#)syscall.s 5.1 (Berkeley) 4/23/90"
+#endif /* SYSLIBC_SCCS and not lint */
+
+#include <machine/asm.h>
+#include <sys/syscall.h>
+
+/*
+ * Initial asm stuff for all functions.
+ */
+ .text
+ .align 2
+
+
+/* ==========================================================================
+ * machdep_sys_fork()
+ */
+ .globl _C_LABEL(machdep_sys_fork);
+
+_C_LABEL(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;
+ int $0x80;
+ jb 3f;
+ ret
+
+#ifndef SYS___sigsuspend14
+/* ==========================================================================
+ * machdep_sys_sigsuspend()
+ */
+ .globl _C_LABEL(machdep_sys_sigsuspend);
+
+_C_LABEL(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;
+ int $0x80;
+ jb 3f;
+ ret
+#endif
+
+3:
+
+ neg %eax
+ movl $0xffffffff,%edx
+ ret
+
+/* ==========================================================================
+ * machdep_sys_lseek()
+ */
+ .globl _C_LABEL(machdep_sys_lseek);
+
+_C_LABEL(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 _C_LABEL(machdep_sys_ftruncate);
+
+_C_LABEL(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
+
+#ifndef SYS___sigprocmask14
+/* ==========================================================================
+ * machdep_sys_sigprocmask()
+ */
+ .globl _C_LABEL(machdep_sys_sigprocmask);
+
+_C_LABEL(machdep_sys_sigprocmask):;
+
+ movl 8(%esp),%ecx
+ movl (%ecx),%ecx
+ movl %ecx,8(%esp)
+ movl $(SYS_sigprocmask), %eax;
+ int $0x80;
+ jb 3b;
+ ret
+#endif
+
+/* ==========================================================================
+ * machdep_sys_pipe()
+ */
+ .globl _C_LABEL(machdep_sys_pipe);
+
+_C_LABEL(machdep_sys_pipe):;
+
+ movl $(SYS_pipe), %eax;
+ int $0x80;
+ jb 3b;
+ movl 4(%esp),%ecx
+ movl %eax,(%ecx)
+ movl %edx,4(%ecx)
+ xorl %eax,%eax
+ ret
+
+/* ==========================================================================
+ * machdep_sys_fstat()
+ */
+ .globl _C_LABEL(machdep_sys_fstat);
+
+_C_LABEL(machdep_sys_fstat):;
+ movl $(SYS___fstat13), %eax;
+ int $0x80;
+ jb 4f;
+ ret
+4:
+ neg %eax
+ movl $0xffffffff,%edx
+ ret
+
diff --git a/mit-pthreads/machdep/syscall-i386-openbsd-2.0.S b/mit-pthreads/machdep/syscall-i386-openbsd-2.0.S
new file mode 100644
index 00000000000..cfdbbc77f73
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-i386-openbsd-2.0.S
@@ -0,0 +1,237 @@
+/* ==== 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
+
diff --git a/mit-pthreads/machdep/syscall-i386-sco-3.2v5.S b/mit-pthreads/machdep/syscall-i386-sco-3.2v5.S
new file mode 100644
index 00000000000..0a60dcdd866
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-i386-sco-3.2v5.S
@@ -0,0 +1,442 @@
+/* ==== 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-sco-3.2v5.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/errno.h>
+#include <sys/syscall.h>
+
+#ifdef _SCO_ELF
+
+#define NAME(X) machdep_sys_##X
+#define GETADDR(X) \
+ call 1f; \
+1: \
+ popl %ebx; \
+ addl $NAME(X)+[.-1b], %ebx
+
+#define END(X) 1: ; .type NAME(X),@function ; .size NAME(X),1b - NAME(X)
+
+#else
+
+#define NAME(X) _machdep_sys_##X
+#define END(X)
+
+#endif
+
+#ifdef __STDC__
+
+#define SYSCALL(x) \
+ .globl NAME(x); \
+ \
+NAME(x): \
+ movl $(SYS_##x##), %eax; \
+ lcall $7, $0; \
+ jae 1f; \
+ cmp $(ERESTART), %eax; \
+ je NAME(x); \
+ neg %eax; \
+1: \
+ ret; \
+\
+ END(x)
+
+
+#else
+
+#define SYSCALL(x) \
+ .globl NAME(x); \
+ \
+NAME(x): \
+ \
+ movl $(SYS_/**/x), %eax; \
+ lcall $7, $0; \
+ jb 1b; \
+ ret; \
+ END(x)
+
+#endif
+
+
+/*
+ * Initial asm stuff for all functions.
+ */
+ .text
+ .align 2
+
+/* ==========================================================================
+ * machdep_sys_fork()
+ */
+ .globl NAME(fork);
+
+NAME(fork):;
+ movl $(SYS_fork), %eax
+ lcall $7, $0
+ jae 1f
+ neg %eax
+ ret
+1:
+ test %edx, %edx
+ je 2f
+ xor %eax, %eax
+2:
+ ret;
+ END(fork)
+
+/* ==========================================================================
+ * NAME(getdents)
+ */
+ .globl NAME(getdents);
+
+NAME(getdents):
+ movl $(SYS_getdents), %eax;
+ lcall $7, $0
+ jae 1f
+ neg %eax
+1:
+ ret;
+ END(getdents)
+
+/* ==========================================================================
+ * NAME(fxstat)
+ */
+ .globl NAME(fxstat);
+
+NAME(fxstat):;
+ movl $(SYS_fxstat), %eax;
+ lcall $7, $0
+ jae 1f
+ neg %eax;
+ ret;
+1:
+ xor %eax, %eax;
+ ret;
+ END(fxstat)
+
+/* ==========================================================================
+ * NAME(signal)
+ */
+ .globl NAME(signal);
+
+NAME(signal):;
+ movl 4(%esp), %ecx
+ movl $(SYS_signal),%eax
+#if 0
+ call .L1
+.L1:
+ popl %edx
+ addl $(NAME(sigreturn)+[.-.L1]), %edx
+#else
+ movl $NAME(sigreturn), %edx
+#endif
+ lcall $7,$0
+ jae 1f
+# movl %eax, 12(%esp)
+ neg %eax
+ ret
+1:
+# xor %eax, %eax
+# movl %eax, 12(%esp)
+ ret
+ END(signal)
+
+/* ==========================================================================
+ * NAME(sigaction)
+ */
+ .globl NAME(sigaction);
+
+NAME(sigaction):
+ movl $(SYS_sigaction),%eax
+#if 0
+ call .L2
+.L2:
+ popl %edx
+ addl $(NAME(sigreturn)+[.-.L2]), %edx
+#else
+ movl $NAME(sigreturn), %edx
+#endif
+ lcall $7, $0
+ jb 1f
+ xor %eax, %eax
+ ret
+1:
+ neg %eax
+ ret
+ END(sigaction)
+
+ .globl NAME(sigreturn)
+NAME(sigreturn):
+ addl $4,%esp
+ lcall $0xf, $0
+ nop
+ nop
+ END(sigreturn)
+
+/* ==========================================================================
+ * NAME(waitpid)
+ */
+ .globl NAME(waitpid);
+
+NAME(waitpid):
+ .byte 0x9c
+ popl %eax
+ orl $0x8c4, %eax
+ pushl %eax
+ .byte 0x9d
+ movl $(SYS_wait), %eax
+ lcall $7, $0
+ jae 2f
+ cmpl $(ERESTART), %al
+ je NAME(waitpid)
+ neg %eax
+3:
+ ret
+2:
+ movl 8(%esp), %ecx
+ test %ecx,%ecx
+ je 3b
+ mov %edx, (%ecx)
+ ret
+ END(waitpid)
+
+/* ==========================================================================
+ * NAME(uname)
+ */
+ .globl NAME(uname);
+
+NAME(uname):
+ pushl $0
+ pushl $0
+ pushl 12(%esp)
+ subl $4, %esp
+ movl $(SYS_utssys), %eax
+ .byte 0x9a; .long 0; .word 7;
+ jb 1f
+ addl $16, %esp
+ ret
+1:
+ addl $16, %esp
+ neg %eax
+ ret
+ END(uname)
+
+
+/* ==========================================================================
+ * machdep_sys_ftruncate
+ */
+
+SYSCALL(ftruncate)
+
+/* ==========================================================================
+ * machdep_sys_ftime
+ */
+
+SYSCALL(ftime)
+
+/* ==========================================================================
+ * machdep_sys_gettimeofday()
+ */
+
+SYSCALL(gettimeofday)
+
+/* ==========================================================================
+ * machdep_sys_kill()
+ */
+
+SYSCALL(kill)
+
+/* ==========================================================================
+ * pthread_sys_setitimer
+ */
+ .globl NAME(setitimer);
+
+NAME(setitimer):;
+ movl $(SYS_setitimer), %eax;
+ lcall $7, $0
+ jae 1f
+ neg %eax
+ ret
+1:
+ xor %eax, %eax
+ ret;
+ END(setitimer)
+
+/* ==========================================================================
+ * pthread_sys_sysconf
+ */
+ .globl NAME(sysconf);
+
+NAME(sysconf):;
+ movl $(SYS_sysconf), %eax;
+ lcall $7, $0
+ jae 1f
+ neg %eax
+1:
+ ret;
+ END(sysconf)
+
+/* ==========================================================================
+ * pthread_sys_sysi86()
+ */
+ .globl NAME(sysi86);
+
+NAME(sysi86):;
+ movl $(SYS_sysi86), %eax
+ lcall $7, $0
+ jae 1f
+ neg %eax
+1:
+ ret;
+ END(sysi86)
+
+
+/* ==========================================================================
+ * machdep_sys_brk()
+ */
+ .globl NAME(brk);
+
+NAME(brk):;
+ movl $(SYS_break), %eax
+ lcall $7, $0
+ jae 1f
+ neg %eax
+ ret
+1:
+ xor %eax, %eax
+ ret;
+ END(brk)
+
+/* ==========================================================================
+ * machdep_sys_pipe()
+ */
+ .globl NAME(pipe);
+
+NAME(pipe):;
+ movl $(SYS_pipe), %eax;
+ lcall $7, $0
+ jae 1f
+ neg %eax
+ ret
+1:
+ movl 4(%esp), %ecx
+ movl %eax, (%ecx)
+ movl %edx, 4(%ecx)
+ xor %eax, %eax
+ ret;
+ END(brk)
+
+/* ==========================================================================
+ * machdep_sys_fcntl()
+ */
+ .globl NAME(fcntl);
+
+NAME(fcntl):;
+ movl $(SYS_fcntl), %eax
+ lcall $7, $0
+ jae 1f
+ neg %eax
+1:
+ ret
+ END(fcntl)
+
+
+/* ==========================================================================
+ * machdep_sys_select()
+ */
+ .globl NAME(select);
+
+NAME(select):;
+ movl $(SYS_select), %eax
+ lcall $7, $0
+ jae 1f
+ cmp $(ERESTART), %eax
+ jne 2f
+ movl $(EINTR), %eax
+2:
+ neg %eax
+1:
+ ret
+ END(select)
+
+
+/* ==========================================================================
+ * setjmp()
+ */
+ .globl setjmp;
+
+setjmp:
+ movl 4(%esp),%eax
+ movl %ebx,(%eax)
+ movl %esi,4(%eax)
+ movl %edi,8(%eax)
+ movl %ebp,12(%eax)
+ popl %edx
+ movl %esp,16(%eax)
+ movl %edx,20(%eax)
+ subl %eax,%eax
+ jmp *%edx
+1: ; .type setjmp,@function ; .size setjmp,1b - setjmp
+
+/* ==========================================================================
+ * longjmp()
+ */
+ .globl longjmp;
+
+longjmp:
+ movl 4(%esp),%edx
+ movl 8(%esp),%eax
+ movl 0(%edx),%ebx
+ movl 4(%edx),%esi
+ movl 8(%edx),%edi
+ movl 12(%edx),%ebp
+ movl 16(%edx),%esp
+ test %eax,%eax
+ jne 1f
+ inc %eax
+1:
+ jmp *20(%edx)
+1: ; .type longjmp,@function ; .size longjmp,1b - longjmp
diff --git a/mit-pthreads/machdep/syscall-ip22-irix-5.2.S b/mit-pthreads/machdep/syscall-ip22-irix-5.2.S
new file mode 100644
index 00000000000..ded0fc55e38
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-ip22-irix-5.2.S
@@ -0,0 +1,106 @@
+#include <sys.s>
+#include <sys/regdef.h>
+
+/*
+ Kernel syscall interface:
+ Input:
+ v0 syscall number
+ Output:
+
+ This macro is similar to SYSCALL in sys/syscall.h, but not completely.
+ There's room for optimization, if we assume this will continue to
+ be assembled as one file.
+
+ Compile with -DPIC for pic code.
+*/
+
+#ifdef PIC
+#define PICOPT .option pic2
+#else
+#define PICOPT
+#endif
+
+
+#define YSYSCALL(x) \
+ PICOPT; \
+ .globl machdep_sys_##x; \
+ .ent machdep_sys_##x, 0; \
+machdep_sys_##x:; \
+ .frame sp,0,ra; \
+ .set noreorder; \
+ li v0, SYS_##x; \
+ syscall; \
+ bne a3, zero, 1b; \
+ nop; \
+ j ra; \
+ nop; \
+ .end machdep_sys_##x
+
+/* ==========================================================================
+ * error code for all syscalls. The error value is returned as the negative
+ * of the errno value.
+ */
+
+1:
+ subu v0,zero,v0;
+ j ra;
+
+/* ==========================================================================
+ * lstat
+ */
+ PICOPT;
+ .globl machdep_sys_lstat;
+ .ent machdep_sys_lstat, 0;
+machdep_sys_lstat:;
+ .frame sp,0,ra;
+ .set noreorder;
+ move a2, a1
+ move a1, a0
+ li a0, 2
+ li v0, SYS_lxstat;
+ syscall;
+ bne a3, zero, 1b;
+ nop;
+ j ra;
+ nop;
+ .end machdep_sys_lstat
+
+/* ==========================================================================
+ * fstat
+ */
+ PICOPT;
+ .globl machdep_sys_fstat;
+ .ent machdep_sys_fstat, 0;
+machdep_sys_fstat:;
+ .frame sp,0,ra;
+ .set noreorder;
+ move a2, a1
+ move a1, a0
+ li a0, 2
+ li v0, SYS_fxstat;
+ syscall;
+ bne a3, zero, 1b;
+ nop;
+ j ra;
+ nop;
+ .end machdep_sys_fstat
+
+/* ==========================================================================
+ * stat
+ */
+ PICOPT;
+ .globl machdep_sys_stat;
+ .ent machdep_sys_stat, 0;
+machdep_sys_stat:;
+ .frame sp,0,ra;
+ .set noreorder;
+ move a2, a1
+ move a1, a0
+ li a0, 2
+ li v0, SYS_xstat;
+ syscall;
+ bne a3, zero, 1b;
+ nop;
+ j ra;
+ nop;
+ .end machdep_sys_stat
diff --git a/mit-pthreads/machdep/syscall-m68000-netbsd.S b/mit-pthreads/machdep/syscall-m68000-netbsd.S
new file mode 100644
index 00000000000..f36286770a2
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-m68000-netbsd.S
@@ -0,0 +1,83 @@
+
+#ifndef lint
+ .text
+ .asciz "$Id$";
+#endif
+
+#include <machine/asm.h>
+#include <sys/syscall.h>
+
+#ifdef __STDC__
+#define IMM #
+#define SYSCALL(x) .even; ENTRY(machdep_sys_ ## x); \
+ movl IMM SYS_ ## x,d0; trap IMM 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_pipe
+ */
+ .even
+ENTRY(machdep_sys_pipe);
+ movl #SYS_pipe,d0
+ trap #0
+ jcs err
+ movl sp@(4),a0
+ movl d0,a0@+
+ movl d1,a0@
+ clrl d0
+ rts
+
+#ifndef SYS___sigsuspend14
+ .even
+ENTRY(machdep_sys_sigsuspend)
+ movl sp@(4),a0
+ movl a0@,sp@(4)
+ movl #SYS_compat_13_sigsuspend13,d0
+ trap #0
+ jcs err
+ clrl d0
+ rts
+#endif
+
+#ifndef SYS___sigprocmask14
+ .even
+ENTRY(machdep_sys_sigprocmask)
+ tstl sp@(8)
+ jne gotptr
+/* movl #0,sp@(8) /* null mask pointer; block empty set */
+ movl #1,sp@(4)
+ jra doit
+gotptr:
+ movl sp@(8),a0
+ movl a0@,sp@(8)
+doit:
+ movl #SYS_compat_13_sigprocmask13,d0
+ trap #0
+ jcs err
+ tstl sp@(12)
+ jeq out
+ movl sp@(12),a0
+ movl d0,a0@
+out:
+ clrl d0
+ rts
+#endif
diff --git a/mit-pthreads/machdep/syscall-r2000-ultrix-4.2.S b/mit-pthreads/machdep/syscall-r2000-ultrix-4.2.S
new file mode 100644
index 00000000000..dc891dc37bd
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-r2000-ultrix-4.2.S
@@ -0,0 +1,166 @@
+/* ==== syscall.S ============================================================
+ * 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 syscalls for decstation with r2000/r3000
+ *
+ * 1.00 93/08/14 proven
+ * -Started coding this file.
+ */
+
+ .text
+ .ascii "$Id$";
+
+#include <syscall.h>
+#include <machine/regdef.h>
+
+/*
+ * 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. Eventually I want to load the errno value directly
+ * into pthread_run->error but until then ...
+ */
+machdep_error:
+ negu v0, v0 /* Return negative of errno value. */
+ j ra
+
+/* ==========================================================================
+ * Syscalls already done,
+ * Standard Other important BSD sockets
+ * fork = 2 select = 93 socket = 97
+ * read = 3 readv = 120 connect = 98
+ * write = 4 writev = 121 accept = 99
+ * open = 5 getdirentries = send = 101
+ * close = 6 recv = 102
+ * creat = 8 bind = 104
+ * link = 9 listen = 106
+ * unlink = 10 recvmsg = 113
+ * chdir = 12 sendmsg = 114
+ * chmod = 15 getsockopt = 118
+ * chown = 16 recvfrom = 125
+ * lseek = 19 sendto = 133
+ * stat = 38 shutdown = 134
+ * dup = 41 getpeername = 141
+ * pipe = 42
+ * execve = 59
+ * fstat = 62
+ * wait3 = 84
+ * dup2 = 90
+ * fcntl = 92
+ * fchown = 123
+ * fchmod = 124
+ * rename = 128
+ * waitpid = 189
+ * ======================================================================= */
+
+/* ==========================================================================
+ * machdep_sys_fork()
+ */
+ .globl machdep_sys_fork
+ .ent machdep_sys_fork
+
+machdep_sys_fork:
+
+ .frame sp,0,ra /* No frame, return address in ra */
+
+ li v0,SYS_fork /* Load fork syscall # into v0 */
+ syscall
+ bne a3,zero,machdep_error /* Error if a3 != 0 */
+ beqz v1,__fork_parent /* Second return value = 0, if parent */
+ li v0,0
+__fork_parent:
+ j ra
+
+ .end machdep_sys_fork
+
+/* ==========================================================================
+ * machdep_sys_pipe()
+ */
+ .globl machdep_sys_pipe
+ .ent machdep_sys_pipe
+
+machdep_sys_pipe:
+
+ .frame sp,0,ra /* No frame, return address in ra */
+
+ li v0,SYS_pipe /* Load pipe syscall # into v0 */
+ syscall
+ bne a3,zero,machdep_error /* Error if a3 != 0 */
+ sw v0, 0(a0)
+ sw v1, 4(a0)
+ li v0, 0
+ j ra
+
+ .end machdep_sys_pipe
+
+/* ==========================================================================
+ * Other important asm routines.
+ * ======================================================================= */
+/* ==========================================================================
+ * fake_setjmp()
+ */
+ .globl fake_setjmp
+ .ent fake_setjmp
+
+fake_setjmp:
+
+ .frame sp,0,ra /* No frame, return address in ra */
+
+ /* Save all the important registers */
+ sw ra,8(a0)
+ sw gp,124(a0)
+ sw sp,128(a0)
+ sw s0,76(a0)
+ /* More registers needed. */
+ j ra
+
+ .end fake_longjmp
+
+/* ==========================================================================
+ * machdep_sys_longjmp()
+ */
+ .globl machdep_sys_longjmp
+ .ent machdep_sys_longjmp
+
+machdep_sys_longjmp:
+
+ .frame sp,0,ra /* No frame, return address in ra */
+ li a1,1 /* Load 1 into reg a1 */
+ sw a1, 20(a0); /* Load a1 into address a0 + 20 */
+ li v0,SYS_sigreturn /* Load sigreturn syscall # into v0 */
+ syscall /* Do syscall to do longjmp */
+ j ra
+
+ .end machdep_sys_longjmp
diff --git a/mit-pthreads/machdep/syscall-romp-bsd.S b/mit-pthreads/machdep/syscall-romp-bsd.S
new file mode 100644
index 00000000000..233f0b9430b
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-romp-bsd.S
@@ -0,0 +1,327 @@
+/* ==== syscall.S ============================================================
+ * Copyright (c) 1993 by John F. Carr, jfc@mit.edu
+ *
+ * 1.00 93/09/xx proven
+ * -Started coding this file.
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#endif
+
+/* DO NOT USE COLONS IN THIS FILE, GCC CAN'T HANDLE THEM */
+/* #include <copyright.h> */
+
+ .globl .oVncs
+ .text
+ .align 2
+
+/* ==========================================================================
+ * machdep_sys_write()
+ */
+ .globl _machdep_sys_write
+ .globl _.machdep_sys_write
+
+ .text 2
+_machdep_sys_write:
+ .long _.machdep_sys_write
+
+ .text
+_.machdep_sys_write:
+ lcs r0,0(r3)
+ svc 4(r0)
+ bntbr r15
+ store r2,_errno,r5
+ brx r15
+ cal r2,-1(r0)
+
+
+/* ==========================================================================
+ * machdep_sys_read()
+ */
+ .globl _machdep_sys_read
+ .globl _.machdep_sys_read
+
+ .text 2
+_machdep_sys_read:
+ .long _.machdep_sys_read
+
+ .text
+_.machdep_sys_read:
+ lcs r0,0(r3)
+ svc 3(r0)
+ bntbr r15
+ store r2,_errno,r5
+ brx r15
+ cal r2,-1(r0)
+
+
+/* ==========================================================================
+ * machdep_sys_open()
+ */
+ .globl _machdep_sys_open
+ .globl _.machdep_sys_open
+
+ .text 2
+_machdep_sys_open:
+ .long _.machdep_sys_open
+
+ .text
+_.machdep_sys_open:
+ lcs r0,0(r2)
+ svc 5(r0)
+ bntbr r15
+ store r2,_errno,r5
+ brx r15
+ cal r2,-1(r0)
+
+
+/* ==========================================================================
+ * machdep_sys_bind()
+ */
+ .globl _machdep_sys_bind
+ .globl _.machdep_sys_bind
+
+ .text 2
+_machdep_sys_bind:
+ .long _.machdep_sys_bind
+
+ .text
+_.machdep_sys_bind:
+ ls r0,0(r3)
+ svc 104(r0)
+ bntbr r15
+ store r2,_errno,r5
+ brx r15
+ cal r2,-1(r0)
+
+
+/* ==========================================================================
+ * machdep_sys_socket()
+ */
+ .globl _machdep_sys_socket
+ .globl _.machdep_sys_socket
+
+ .text 2
+_machdep_sys_socket:
+ .long _.machdep_sys_socket
+
+ .text
+ .align 2
+_.machdep_sys_socket:
+ svc 97(r0)
+ bntbr r15
+ store r2,_errno,r5
+ brx r15
+ cal r2,-1(r0)
+
+
+/* ==========================================================================
+ * machdep_sys_close()
+ */
+ .globl _machdep_sys_close
+ .globl _.machdep_sys_close
+
+ .text 2
+_machdep_sys_close:
+ .long _.machdep_sys_close
+
+ .text
+ .align 2
+_.machdep_sys_close:
+ svc 6(r0)
+ bntbr r15
+ store r2,_errno,r5
+ brx r15
+ cal r2,-1(r0)
+
+
+/* ==========================================================================
+ * machdep_sys_connect()
+ */
+ .globl _machdep_sys_connect
+ .globl _.machdep_sys_connect
+
+ .text 2
+_machdep_sys_connect:
+ .long _.machdep_sys_connect
+
+ .text
+_.machdep_sys_connect:
+ lcs r0,0(r3)
+ svc 98(r0)
+ bntbr r15
+ store r2,_errno,r5
+ brx r15
+ cal r2,-1(r0)
+
+/* ==========================================================================
+ * machdep_sys_accept()
+ */
+ .globl _machdep_sys_accept
+ .globl _.machdep_sys_accept
+
+ .text 2
+_machdep_sys_accept:
+ .long _.machdep_sys_accept
+
+ .text
+_.machdep_sys_accept:
+ lcs r0,0(r3)
+ svc 99(r0)
+ bntbr r15
+ store r2,_errno,r5
+ cal r2,-1(r0)
+
+/* ==========================================================================
+ * machdep_sys_listen()
+ */
+ .globl _machdep_sys_listen
+ .globl _.machdep_sys_listen
+
+ .text 2
+ .align 2
+_machdep_sys_listen:
+ .long _.machdep_sys_listen
+
+ .text
+ .align 2
+_.machdep_sys_listen:
+ svc 106(r0)
+ bntbr r15
+ brx r15
+ twoc r2,r2
+
+/* ==========================================================================
+ * machdep_sys_fcntl()
+ */
+ .globl _.machdep_sys_fcntl
+ .globl _machdep_sys_fcntl
+
+ .text 2
+_machdep_sys_fcntl:
+ .long _.machdep_sys_fcntl
+ .text
+_.machdep_sys_fcntl:
+ lcs r0,0(sp)
+ svc 92(r0)
+ bntbr r15
+ store r2,_errno,r5
+ brx r15
+ cal r2,-1(r0)
+
+/* ==========================================================================
+ * machdep_sys_getpeername()
+ */
+ .globl _machdep_sys_getpeername
+ .globl _.machdep_sys_getpeername
+
+ .text 2
+_machdep_sys_getpeername:
+ .long _.machdep_sys_getpeername
+
+ .text
+_.machdep_sys_getpeername:
+ ls r0,0(sp)
+ svc 141(r0)
+ bntbr r15
+ brx r15
+ twoc r2,r2
+
+
+/* ==========================================================================
+ * machdep_sys_getsockopt()
+ */
+ .globl _machdep_sys_getsockopt
+ .globl _.machdep_sys_getsockopt
+
+ .text 2
+_machdep_sys_getsockopt:
+ .long _.machdep_sys_getsockopt
+
+ .text
+_.machdep_sys_getsockopt:
+ ls r0,0(sp)
+ svc 118(r0)
+ bntbr r15
+ brx r15
+ twoc r2,r2
+
+
+/* ==========================================================================
+ * machdep_sys_select()
+ */
+
+ .globl _.machdep_sys_select
+ .globl _machdep_sys_select
+
+ .text 2
+_machdep_sys_select:
+ .long _.machdep_sys_select
+ .text
+_.machdep_sys_select:
+ svc 93(r0)
+ bntbr r15
+ brx r15
+ twoc r2,r2
+
+/* ==========================================================================
+ * __tsh()
+ */
+ .globl _._tsh
+ .globl __tsh
+ .text 2
+__tsh: .long _._tsh
+ .text
+ .align 2
+_._tsh:
+ brx r15
+ tsh r2,0(r2)
+
+
+/* ==========================================================================
+ * __pthread_save()
+ */
+ .globl __pthread_save
+ .globl _._pthread_save
+ .text 2
+__pthread_save:
+ .long _._pthread_save
+ .text
+ .align 2
+_._pthread_save:
+ ail r5,r4,0
+ jne 1f
+ mr r4,sp
+ lis r5,0
+ stm r4,0(r2)
+ brx r15
+ lis r2,0
+1:
+ mr r0,r15 # save old return address
+ ls r15,0(r4) # new return address
+ mr r5,r4 # r0 to restore
+ mr r4,r3 # sp to restore
+ stm r4,0(r2)
+ brx r0
+ lis r2,0
+
+
+/* ==========================================================================
+ * __pthread_restore()
+ */
+ .globl __pthread_restore
+ .globl _._pthread_restore
+ .text 2
+__pthread_restore:
+ .long _._pthread_restore
+ .text
+ .align 2
+_._pthread_restore:
+ lm r4,0(r2)
+ mr r0,r5
+ lis r2,1
+ brx r15
+ mr sp,r4
+
+
diff --git a/mit-pthreads/machdep/syscall-sparc-netbsd-1.1.S b/mit-pthreads/machdep/syscall-sparc-netbsd-1.1.S
new file mode 100644
index 00000000000..9c4da4b1325
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-sparc-netbsd-1.1.S
@@ -0,0 +1,102 @@
+/* ==== syscall.S ============================================================
+ * Copyright (c) 1994 Chris Provenzano, proven@mit.edu
+ * All rights reserved.
+ *
+ */
+
+#ifndef lint
+ .text
+ .asciz "$Id$";
+#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/mit-pthreads/machdep/syscall-sparc-netbsd-1.3.S b/mit-pthreads/machdep/syscall-sparc-netbsd-1.3.S
new file mode 100644
index 00000000000..74a51e756b7
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-sparc-netbsd-1.3.S
@@ -0,0 +1,172 @@
+/* ==== syscall.S ============================================================
+ * Copyright (c) 1994 Chris Provenzano, proven@mit.edu
+ * All rights reserved.
+ *
+ */
+
+#ifndef lint
+ .text
+ .asciz "$Id$";
+#endif
+
+#include <machine/asm.h>
+#include <sys/syscall.h>
+
+#define SYSCALL(x) \
+ .globl _C_LABEL(machdep_sys_##x); \
+ \
+_C_LABEL(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 _C_LABEL(machdep_sys_pipe)
+
+_C_LABEL(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 _C_LABEL(machdep_sys_fork);
+
+_C_LABEL(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
+
+#ifndef SYS___sigprocmask14
+/* ==========================================================================
+ * machdep_sys_sigprocmask()
+ */
+ .globl _C_LABEL(machdep_sys_sigprocmask);
+
+_C_LABEL(machdep_sys_sigprocmask):;
+
+ ld [%o1], %o1;
+ mov SYS_sigprocmask, %g1;
+ ta 0;
+ bcs 1b;
+ nop;
+ retl
+ nop
+#endif
+
+#ifndef SYS___sigsuspend14
+/* ==========================================================================
+ * machdep_sys_sigsuspend()
+ */
+ .globl _C_LABEL(machdep_sys_sigsuspend);
+
+_C_LABEL(machdep_sys_sigsuspend):;
+
+ ld [%o0], %o0;
+ mov SYS_sigsuspend, %g1;
+ ta 0;
+ bcs 1b;
+ nop;
+ retl
+ nop
+#endif
+
+/* ==========================================================================
+ * machdep_sys_fstat()
+ */
+ .globl _C_LABEL(machdep_sys_fstat);
+
+_C_LABEL(machdep_sys_fstat):;
+
+ mov SYS___fstat13, %g1;
+ ta 0;
+ bcs 1b;
+ nop;
+ retl
+ nop
+
+/* ==========================================================================
+ * machdep_sys___syscall()
+ */
+_machdep_sys___syscall:;
+
+ mov SYS___syscall, %g1;
+ ta 0;
+ bcs 1b;
+ nop;
+ retl
+ nop
+
+/* ==========================================================================
+ * machdep_sys_lseek()
+ */
+ .global _C_LABEL(machdep_sys_lseek)
+
+_C_LABEL(machdep_sys_lseek):
+ save %sp,-112,%sp
+ mov %i1,%o4
+ mov %i2,%o5
+ st %i3,[%sp+92]
+ mov 0,%o0
+ mov SYS_lseek,%o1
+ mov %i0,%o2
+ call _machdep_sys___syscall,0
+ mov 0,%o3
+ mov %o0,%i0
+ mov %o1,%i1
+ ret
+ restore
+
+/* ==========================================================================
+ * machdep_sys_ftruncate()
+ */
+ .global _C_LABEL(machdep_sys_ftruncate)
+
+_C_LABEL(machdep_sys_ftruncate):
+ save %sp,-104,%sp
+ mov %i1,%o4
+ mov %i2,%o5
+ mov 0,%o0
+ mov SYS_ftruncate,%o1
+ mov %i0,%o2
+ call _machdep_sys___syscall,0
+ mov 0,%o3
+ mov %o0,%o1
+ sra %o0,31,%o0
+ ret
+ restore %g0,%o1,%o0
diff --git a/mit-pthreads/machdep/syscall-sparc-sunos-4.1.3.S b/mit-pthreads/machdep/syscall-sparc-sunos-4.1.3.S
new file mode 100644
index 00000000000..ec293b0ca3f
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-sparc-sunos-4.1.3.S
@@ -0,0 +1,113 @@
+/* ==== syscall.S ============================================================
+ * Copyright (c) 1994 Chris Provenzano, proven@mit.edu
+ * All rights reserved.
+ *
+ */
+
+#ifndef lint
+ .text
+ .asciz "$Id$";
+#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;
+ tst %o1
+ bne,a __fork_parent
+ mov %g0, %o0
+__fork_parent:;
+ retl
+
+/* POSIX-compliant getpgrp() takes no arguments. The SunOS syscall wants
+ one, and gives the POSIXy result if that argument is zero. */
+ .globl _getpgrp
+_getpgrp:
+ mov SYS_getpgrp, %g1
+ mov 0, %i0
+ ta 0
+ bcs 1b
+ nop
+ retl
+ nop
+
+#if 0
+/* I think this bit of magic will do the right thing for other syscalls.
+ We get here with the new `errno' code in %o0. It should get stored in
+ *__error(), and -1 returned to the caller. */
+ .globl cerror
+cerror:
+ save %sp,-104,%sp
+ /* Now value is in %i0. Store it in *__error(). */
+ call ___error
+ nop
+ st %i0,[%o0]
+
+ /* Now also store a copy in global variable errno, for routines
+ like isatty that want to examine it and which haven't been
+ converted yet. */
+ sethi %hi(_errno), %o0
+ st %i0,[%o0+%lo(_errno)]
+
+#if 0 /* use this if you want -errno returned */
+ sub %r0,%i0,%i0
+#else /* return -1 */
+ mov -1,%i0
+#endif
+ retl
+ restore
+#endif
diff --git a/mit-pthreads/machdep/syscall-sparc-sunos-5.3.S b/mit-pthreads/machdep/syscall-sparc-sunos-5.3.S
new file mode 100644
index 00000000000..822055ad04e
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-sparc-sunos-5.3.S
@@ -0,0 +1,65 @@
+/* ==== syscall.S ============================================================
+ * Copyright (c) 1994 Chris Provenzano, proven@mit.edu
+ * All rights reserved.
+ *
+ */
+
+#ifndef lint
+ .text
+ .asciz "$Id$";
+#endif
+
+#define _ASM
+#include <sys/syscall.h>
+
+/*
+ * 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_fork()
+ */
+ .globl machdep_sys_fork;
+
+machdep_sys_fork:;
+
+ mov SYS_fork, %g1;
+ ta 0;
+ bcs 1b;
+ nop;
+ tst %o1
+ bne,a __fork_parent
+ mov %g0, %o0
+__fork_parent:;
+ retl
+ nop; /* Added by monty to keep sparc assembler happy */
+
+/* ==========================================================================
+ * Berkeley socket stuff
+ *
+ * ==========================================================================
+ * machdep_sys_socketcall()
+ */
+ .globl machdep_sys_socketcall;
+
+machdep_sys_socketcall:;
+
+ mov 83, %g1;
+ ta 0;
+ bcs,a 2b;
+ sub %r0,%o0,%o0;
+ retl
+ nop; /* Added by monty to keep sparc assembler happy */
diff --git a/mit-pthreads/machdep/syscall-sparc-sunos4.S b/mit-pthreads/machdep/syscall-sparc-sunos4.S
new file mode 100644
index 00000000000..ec293b0ca3f
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-sparc-sunos4.S
@@ -0,0 +1,113 @@
+/* ==== syscall.S ============================================================
+ * Copyright (c) 1994 Chris Provenzano, proven@mit.edu
+ * All rights reserved.
+ *
+ */
+
+#ifndef lint
+ .text
+ .asciz "$Id$";
+#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;
+ tst %o1
+ bne,a __fork_parent
+ mov %g0, %o0
+__fork_parent:;
+ retl
+
+/* POSIX-compliant getpgrp() takes no arguments. The SunOS syscall wants
+ one, and gives the POSIXy result if that argument is zero. */
+ .globl _getpgrp
+_getpgrp:
+ mov SYS_getpgrp, %g1
+ mov 0, %i0
+ ta 0
+ bcs 1b
+ nop
+ retl
+ nop
+
+#if 0
+/* I think this bit of magic will do the right thing for other syscalls.
+ We get here with the new `errno' code in %o0. It should get stored in
+ *__error(), and -1 returned to the caller. */
+ .globl cerror
+cerror:
+ save %sp,-104,%sp
+ /* Now value is in %i0. Store it in *__error(). */
+ call ___error
+ nop
+ st %i0,[%o0]
+
+ /* Now also store a copy in global variable errno, for routines
+ like isatty that want to examine it and which haven't been
+ converted yet. */
+ sethi %hi(_errno), %o0
+ st %i0,[%o0+%lo(_errno)]
+
+#if 0 /* use this if you want -errno returned */
+ sub %r0,%i0,%i0
+#else /* return -1 */
+ mov -1,%i0
+#endif
+ retl
+ restore
+#endif
diff --git a/mit-pthreads/machdep/syscall-template-alpha-netbsd-1.1.S b/mit-pthreads/machdep/syscall-template-alpha-netbsd-1.1.S
new file mode 100644
index 00000000000..a2941ece7c9
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-template-alpha-netbsd-1.1.S
@@ -0,0 +1,46 @@
+#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/mit-pthreads/machdep/syscall-template-alpha-netbsd-1.3.S b/mit-pthreads/machdep/syscall-template-alpha-netbsd-1.3.S
new file mode 100644
index 00000000000..12595feabc1
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-template-alpha-netbsd-1.3.S
@@ -0,0 +1,53 @@
+#include <machine/asm.h>
+#define COMPAT_43
+#include <sys/syscall.h>
+#define CHMK() call_pal 0x83
+
+#ifdef SYS___sigsuspend14
+#define SYS_sigsuspend SYS___sigsuspend14
+#endif
+#ifdef SYS___sigprocmask14
+#define SYS_sigprocmask SYS___sigprocmask14
+#endif
+
+#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/mit-pthreads/machdep/syscall-template-alpha-osf1.S b/mit-pthreads/machdep/syscall-template-alpha-osf1.S
new file mode 100644
index 00000000000..bc4653b5f9e
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-template-alpha-osf1.S
@@ -0,0 +1,46 @@
+#include <asm.h>
+#include <regdef.h>
+#define COMPAT_43
+#include <syscall.h>
+
+#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, 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
+
+#define XSYSCALL(x) SIMPLE_SYSCALL(x)
+
+XSYSCALL(SYSCALL_NAME)
diff --git a/mit-pthreads/machdep/syscall-template-arm32-netbsd-1.3.S b/mit-pthreads/machdep/syscall-template-arm32-netbsd-1.3.S
new file mode 100644
index 00000000000..923d2c03a75
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-template-arm32-netbsd-1.3.S
@@ -0,0 +1,55 @@
+#include <machine/asm.h>
+#include <sys/syscall.h>
+
+#ifdef SYS___sigsuspend14
+#define SYS_sigsuspend SYS___sigsuspend14
+#endif
+#ifdef SYS___sigprocmask14
+#define SYS_sigprocmask SYS___sigprocmask14
+#endif
+
+#ifdef __STDC__
+
+#define SYSCALL(x) \
+ .globl _C_LABEL(machdep_sys_##x); \
+ \
+_C_LABEL(machdep_sys_##x):; \
+ \
+ swi SYS_##x; \
+ bcs 1b; \
+ mov r15, r14;
+
+#else
+
+#define SYSCALL(x) \
+ .globl _C_LABEL(_machdep_sys_/**/x); \
+ \
+_C_LABEL(machdep_sys_/**/x):; \
+ \
+ swi SYS_/**/x; \
+ bcs 1b; \
+ mov r15, r14;
+
+#endif
+
+
+/*
+ * Initial asm stuff for all functions.
+ */
+ .text
+ .align 0
+
+
+/* ==========================================================================
+ * error code for all syscalls. The error value is returned as the negative
+ * of the errno value.
+ */
+
+1:
+ rsb r0, r0, #0x00000000
+ mvn r1, #0x00000000
+ mov r15, r14
+
+#define XSYSCALL(NAME) SYSCALL(NAME)
+
+XSYSCALL(SYSCALL_NAME)
diff --git a/mit-pthreads/machdep/syscall-template-hppa-hpux-10.20.S b/mit-pthreads/machdep/syscall-template-hppa-hpux-10.20.S
new file mode 100644
index 00000000000..0123b1deee7
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-template-hppa-hpux-10.20.S
@@ -0,0 +1,27 @@
+/* ==== syscall.S ============================================================
+ * Written 1996 by Stefan Grefen, grefen@convex.com
+ */
+
+#include <sys/syscall.h>
+
+#define _CAT(a,b)a##b
+#define CAT(a,b)_CAT(a,b)
+
+#define MKNAME(a)CAT(a,SYSCALL_NAME)
+
+ .CODE
+machdep_error
+ sub %r0,%r28,%r28
+ bv,n %r0(%r2)
+
+ .label MKNAME(machdep_sys_)
+ .PROC
+ .CALLINFO NO_CALLS,FRAME=0
+ ldil -0x80000,%r1
+ ble 4(%sr7,%r1)
+ ldi MKNAME(SYS_),%r22
+ or,= %r0,%r22,%r0
+ b,n machdep_error
+ bv,n %r0(%r2)
+ .PROCEND
+ .EXPORT MKNAME(machdep_sys_)
diff --git a/mit-pthreads/machdep/syscall-template-hppa-hpux-9.03.S b/mit-pthreads/machdep/syscall-template-hppa-hpux-9.03.S
new file mode 100644
index 00000000000..0123b1deee7
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-template-hppa-hpux-9.03.S
@@ -0,0 +1,27 @@
+/* ==== syscall.S ============================================================
+ * Written 1996 by Stefan Grefen, grefen@convex.com
+ */
+
+#include <sys/syscall.h>
+
+#define _CAT(a,b)a##b
+#define CAT(a,b)_CAT(a,b)
+
+#define MKNAME(a)CAT(a,SYSCALL_NAME)
+
+ .CODE
+machdep_error
+ sub %r0,%r28,%r28
+ bv,n %r0(%r2)
+
+ .label MKNAME(machdep_sys_)
+ .PROC
+ .CALLINFO NO_CALLS,FRAME=0
+ ldil -0x80000,%r1
+ ble 4(%sr7,%r1)
+ ldi MKNAME(SYS_),%r22
+ or,= %r0,%r22,%r0
+ b,n machdep_error
+ bv,n %r0(%r2)
+ .PROCEND
+ .EXPORT MKNAME(machdep_sys_)
diff --git a/mit-pthreads/machdep/syscall-template-i386-bsdi-2.0.S b/mit-pthreads/machdep/syscall-template-i386-bsdi-2.0.S
new file mode 100644
index 00000000000..3299f49195f
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-template-i386-bsdi-2.0.S
@@ -0,0 +1,48 @@
+#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/mit-pthreads/machdep/syscall-template-i386-freebsd-2.0.S b/mit-pthreads/machdep/syscall-template-i386-freebsd-2.0.S
new file mode 100644
index 00000000000..1906a949c8b
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-template-i386-freebsd-2.0.S
@@ -0,0 +1,59 @@
+#include <sys/syscall.h>
+
+#ifdef __STDC__
+
+#define SYS(X) SYS_##X
+#ifdef __ELF__
+#define NAME(X) machdep_sys_##X
+#else
+#define NAME(X) _machdep_sys_##X
+#endif
+
+#else
+
+#define SYS(X) SYS_/**/X
+#ifdef __ELF__
+#define NAME(X) machdep_sys_/**/X
+#else
+#define NAME(X) _machdep_sys_/**/X
+#endif
+
+#endif
+
+#ifdef __ELF__
+#define END(X) 5: ; .type NAME(X),@function ; .size NAME(X),5b - NAME(X)
+#define KERNCALL int $0x80
+#else
+#define END(X)
+#define KERNCALL .byte 0x9a; .long 0; .word 7;
+#endif
+
+#define SYSCALL(x) \
+ .globl NAME(x); \
+ \
+NAME(x):; \
+ movl $(SYS(x)), %eax; \
+ KERNCALL; \
+ jb 1b; \
+ ret; \
+ END(x)
+
+/*
+ * 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/mit-pthreads/machdep/syscall-template-i386-netbsd-1.1.S b/mit-pthreads/machdep/syscall-template-i386-netbsd-1.1.S
new file mode 100644
index 00000000000..c5e76bb4538
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-template-i386-netbsd-1.1.S
@@ -0,0 +1,49 @@
+#include <machine/asm.h>
+#include <sys/syscall.h>
+
+#ifdef __STDC__
+
+#define SYSCALL(x) \
+ .globl _machdep_sys_##x; \
+ \
+_machdep_sys_##x:; \
+ \
+ movl $(SYS_##x), %eax; \
+ int $0x80; \
+ jb 1b; \
+ ret;
+
+#else
+
+#define SYSCALL(x) \
+ .globl _machdep_sys_/**/x; \
+ \
+_machdep_sys_/**/x:; \
+ \
+ movl $(SYS_/**/x), %eax; \
+ int $0x80; \
+ 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/mit-pthreads/machdep/syscall-template-i386-netbsd-1.3.S b/mit-pthreads/machdep/syscall-template-i386-netbsd-1.3.S
new file mode 100644
index 00000000000..d6dffc35132
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-template-i386-netbsd-1.3.S
@@ -0,0 +1,56 @@
+#include <machine/asm.h>
+#include <sys/syscall.h>
+
+#ifdef SYS___sigsuspend14
+#define SYS_sigsuspend SYS___sigsuspend14
+#endif
+#ifdef SYS___sigprocmask14
+#define SYS_sigprocmask SYS___sigprocmask14
+#endif
+
+#ifdef __STDC__
+
+#define SYSCALL(x) \
+ .globl _C_LABEL(machdep_sys_##x); \
+ \
+_C_LABEL(machdep_sys_##x):; \
+ \
+ movl $(SYS_##x), %eax; \
+ int $0x80; \
+ jb 1b; \
+ ret;
+
+#else
+
+#define _SYSCALL(x) \
+ .globl _C_LABEL(machdep_sys_/**/x); \
+ \
+_C_LABEL(machdep_sys_/**/x):; \
+ \
+ movl $(SYS_/**/x), %eax; \
+ int $0x80; \
+ 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/mit-pthreads/machdep/syscall-template-i386-netbsd1.0.S b/mit-pthreads/machdep/syscall-template-i386-netbsd1.0.S
new file mode 100644
index 00000000000..83a2405ed51
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-template-i386-netbsd1.0.S
@@ -0,0 +1,49 @@
+#include <machine/asm.h>
+#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/mit-pthreads/machdep/syscall-template-i386-openbsd-2.0.S b/mit-pthreads/machdep/syscall-template-i386-openbsd-2.0.S
new file mode 100644
index 00000000000..34fb5caaa43
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-template-i386-openbsd-2.0.S
@@ -0,0 +1,48 @@
+#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/mit-pthreads/machdep/syscall-template-i386-sco-3.2v5.S b/mit-pthreads/machdep/syscall-template-i386-sco-3.2v5.S
new file mode 100644
index 00000000000..753475b5c3d
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-template-i386-sco-3.2v5.S
@@ -0,0 +1,67 @@
+#include <sys/errno.h>
+#include <sys/syscall.h>
+
+#ifdef _SCO_ELF
+
+#define NAME(X) machdep_sys_##X
+#define END(X) 1: ; .type NAME(X),@function ; .size NAME(X),1b - NAME(X)
+#define GETBX(X) \
+ push %ebx; \
+ call 1f; \
+1: \
+ popl %ebx;
+#else
+
+#define NAME(X) _machdep_sys_##X
+#define END(X)
+
+#endif
+
+#ifdef __STDC__
+
+#define SYSCALL(x) \
+ .globl NAME(x); \
+ \
+NAME(x):; \
+ movl $(SYS_##x##), %eax; \
+ .byte 0x9a; .long 0; .word 7; \
+ jae 1f; \
+ cmp $(ERESTART), %eax; \
+ je NAME(x); \
+ neg %eax; \
+1: \
+ ret; \
+ END(x)
+
+#else
+
+#define SYSCALL(x) \
+ .globl _machdep_sys_/**/x; \
+ \
+machdep_sys_/**/x:; \
+ \
+ movl $(SYS_/**/x), %eax; \
+ .byte 0x9a; .long 0; .word 7; \
+ jae 1f; \
+ neg %eax;
+1: \
+ 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.
+ */
+
+#define XSYSCALL(NAME) SYSCALL(NAME)
+
+XSYSCALL(SYSCALL_NAME)
diff --git a/mit-pthreads/machdep/syscall-template-ip22-irix-5.2.S b/mit-pthreads/machdep/syscall-template-ip22-irix-5.2.S
new file mode 100644
index 00000000000..722b001671b
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-template-ip22-irix-5.2.S
@@ -0,0 +1,51 @@
+#include <sys.s>
+#include <sys/regdef.h>
+/* #include <sys/asm.h> */
+
+/*
+ Kernel syscall interface:
+ Input:
+ v0 syscall number
+ Output:
+
+ This macro is similar to SYSCALL in sys/syscall.h, but not completely.
+ There's room for optimization, if we assume this will continue to
+ be assembled as one file.
+
+ Compile with -DPIC for pic code.
+*/
+
+#ifdef PIC
+#define PICOPT .option pic2
+#else
+#define PICOPT
+#endif
+
+
+#define YSYSCALL(x) \
+ PICOPT; \
+ .globl machdep_sys_##x; \
+ .ent machdep_sys_##x, 0; \
+machdep_sys_##x:; \
+ .frame sp,0,ra; \
+ .set noreorder; \
+ li v0, SYS_##x; \
+ syscall; \
+ bne a3, zero, 1b; \
+ nop; \
+ j ra; \
+ nop; \
+ .end machdep_sys_##x
+
+/* ==========================================================================
+ * error code for all syscalls. The error value is returned as the negative
+ * of the errno value.
+ */
+
+1:
+ subu v0,zero,v0;
+ j ra;
+
+#define XSYSCALL(x) YSYSCALL(x)
+
+XSYSCALL(SYSCALL_NAME)
diff --git a/mit-pthreads/machdep/syscall-template-m68000-netbsd.S b/mit-pthreads/machdep/syscall-template-m68000-netbsd.S
new file mode 100644
index 00000000000..ce16bb5523c
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-template-m68000-netbsd.S
@@ -0,0 +1,43 @@
+#include <machine/asm.h>
+#include <sys/syscall.h>
+
+#ifdef SYS___sigsuspend14
+#define SYS_sigsuspend SYS___sigsuspend14
+#endif
+#ifdef SYS___sigprocmask14
+#define SYS_sigprocmask SYS___sigprocmask14
+#endif
+
+
+#ifdef __STDC__
+#define IMM #
+#define SYSCALL(x) .even; \
+ ENTRY(machdep_sys_ ## x); \
+ movl IMM SYS_ ## x,d0; \
+ trap IMM 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
+
+#define XSYSCALL(NAME) SYSCALL(NAME)
+
+XSYSCALL(SYSCALL_NAME)
diff --git a/mit-pthreads/machdep/syscall-template-r2000-ultrix-4.2.S b/mit-pthreads/machdep/syscall-template-r2000-ultrix-4.2.S
new file mode 100644
index 00000000000..575fe3c3d74
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-template-r2000-ultrix-4.2.S
@@ -0,0 +1,77 @@
+/* ==== syscall.S ============================================================
+ * 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 syscalls for decstation with r2000/r3000
+ *
+ * 1.00 93/08/14 proven
+ * -Started coding this file.
+ */
+
+ .text
+ .ascii "$Id$";
+
+#include <syscall.h>
+#include <machine/regdef.h>
+
+#define SYSCALL(x) \
+ \
+ .globl machdep_sys_##x; \
+ .ent machdep_sys_##x; \
+ \
+machdep_sys_##x:; \
+ \
+ .frame sp,0,ra; /* No frame, return address in ra */ \
+ \
+ li v0,SYS_##x; /* Load syscall # into v0 */ \
+ syscall; \
+ bne a3,zero,machdep_error; /* Error if a3 != 0 */ \
+ j ra; \
+ \
+ .end machdep_sys_##x
+
+/*
+ * 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. Eventually I want to load the errno value directly
+ * into pthread_run->error but until then ...
+ */
+machdep_error:
+ negu v0, v0 /* Return negative of errno value. */
+ j ra
+
+#define XSYSCALL(NAME) SYSCALL(NAME)
+
+XSYSCALL(SYSCALL_NAME)
diff --git a/mit-pthreads/machdep/syscall-template-sparc-netbsd-1.1.S b/mit-pthreads/machdep/syscall-template-sparc-netbsd-1.1.S
new file mode 100644
index 00000000000..2d07892a315
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-template-sparc-netbsd-1.1.S
@@ -0,0 +1,40 @@
+/* ==== 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/mit-pthreads/machdep/syscall-template-sparc-netbsd-1.3.S b/mit-pthreads/machdep/syscall-template-sparc-netbsd-1.3.S
new file mode 100644
index 00000000000..2caad5c3437
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-template-sparc-netbsd-1.3.S
@@ -0,0 +1,48 @@
+/* ==== syscall.S ============================================================
+ * Copyright (c) 1994 Chris Provenzano, proven@mit.edu
+ * All rights reserved.
+ *
+ */
+
+#include <machine/asm.h>
+#include <sys/syscall.h>
+
+#ifdef SYS___sigsuspend14
+#define SYS_sigsuspend SYS___sigsuspend14
+#endif
+#ifdef SYS___sigprocmask14
+#define SYS_sigprocmask SYS___sigprocmask14
+#endif
+
+#define SYSCALL(x) \
+ .globl _C_LABEL(machdep_sys_##x); \
+ \
+_C_LABEL(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/mit-pthreads/machdep/syscall-template-sparc-sunos-5.3.S b/mit-pthreads/machdep/syscall-template-sparc-sunos-5.3.S
new file mode 100644
index 00000000000..65a796a057d
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-template-sparc-sunos-5.3.S
@@ -0,0 +1,45 @@
+/* ==== syscall.S ============================================================
+ * Copyright (c) 1994 Chris Provenzano, proven@mit.edu
+ * All rights reserved.
+ *
+ */
+
+#ifndef lint
+ .text
+ .asciz "$Id$";
+#endif
+
+#define _ASM
+#include <sys/syscall.h>
+
+/*
+ * 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 concat2(a,b) a ## b
+#define concat(a,b) concat2(a,b)
+#define SYSval concat(SYS_,SYSCALL_NAME)
+#define procname concat(machdep_sys_,SYSCALL_NAME)
+
+ .globl procname
+
+procname:
+ mov SYSval, %g1
+ ta 0
+ bcs,a 2b
+ sub %r0,%o0,%o0
+ retl
+ nop
diff --git a/mit-pthreads/machdep/syscall-template-sparc-sunos4.S b/mit-pthreads/machdep/syscall-template-sparc-sunos4.S
new file mode 100644
index 00000000000..2d07892a315
--- /dev/null
+++ b/mit-pthreads/machdep/syscall-template-sparc-sunos4.S
@@ -0,0 +1,40 @@
+/* ==== 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/mit-pthreads/machdep/ultrix-4.2/__math.h b/mit-pthreads/machdep/ultrix-4.2/__math.h
new file mode 100755
index 00000000000..6249d720039
--- /dev/null
+++ b/mit-pthreads/machdep/ultrix-4.2/__math.h
@@ -0,0 +1,2 @@
+#define HUGE_VAL 1.8e+308
+
diff --git a/mit-pthreads/machdep/ultrix-4.2/__signal.h b/mit-pthreads/machdep/ultrix-4.2/__signal.h
new file mode 100755
index 00000000000..68364772a6a
--- /dev/null
+++ b/mit-pthreads/machdep/ultrix-4.2/__signal.h
@@ -0,0 +1,66 @@
+#include <ansi_compat.h>
+
+#define NSIG 32
+
+#define SIGHUP 1 /* hangup */
+#define SIGINT 2 /* interrupt */
+#define SIGQUIT 3 /* quit */
+#define SIGILL 4 /* illegal instruction (not reset when caught) */
+#define SIGTRAP 5 /* trace trap (not reset when caught) */
+#define SIGIOT 6 /* IOT instruction */
+#define SIGEMT 7 /* EMT instruction */
+#define SIGFPE 8 /* floating point exception */
+#define SIGKILL 9 /* kill (cannot be caught or ignored) */
+#define SIGBUS 10 /* bus error */
+#define SIGSEGV 11 /* segmentation violation */
+#define SIGSYS 12 /* bad argument to system call */
+#define SIGPIPE 13 /* write on a pipe with no one to read it */
+#define SIGALRM 14 /* alarm clock */
+#define SIGTERM 15 /* software termination signal from kill */
+#define SIGURG 16 /* urgent condition on IO channel */
+#define SIGSTOP 17 /* sendable stop signal not from tty */
+#define SIGTSTP 18 /* stop signal from tty */
+#define SIGCONT 19 /* continue a stopped process */
+#define SIGCHLD 20 /* to parent on child stop or exit */
+#define SIGTTIN 21 /* to readers pgrp upon background tty read */
+#define SIGTTOU 22 /* like TTIN for output if (tp->t_local&LTOSTOP) */
+#define SIGIO 23 /* input/output possible signal */
+#define SIGXCPU 24 /* exceeded CPU time limit */
+#define SIGXFSZ 25 /* exceeded file size limit */
+#define SIGVTALRM 26 /* virtual time alarm */
+#define SIGPROF 27 /* profiling time alarm */
+#define SIGWINCH 28 /* window size changes */
+#define SIGLOST 29 /* Sys-V rec lock: notify user upon server crash */
+#define SIGUSR1 30 /* User signal 1 (from SysV) */
+#define SIGUSR2 31 /* User signal 2 (from SysV) */
+
+/* Add System V signal definitions (DLB001) */
+#define SIGCLD SIGCHLD /* System V name for SIGCHLD */
+#define SIGABRT SIGIOT
+
+typedef long sig_atomic_t;
+typedef unsigned int sigset_t;
+
+struct sigaction {
+ void (*sa_handler)(); /* signal handler */
+ sigset_t sa_mask; /* signal mask to apply */
+ int sa_flags; /* see signal options below */
+};
+
+/* Defines for sigprocmask() call. POSIX.
+ */
+#define SIG_BLOCK 1 /* Add these signals to block mask */
+#define SIG_UNBLOCK 2 /* Remove these signals from block mask */
+#define SIG_SETMASK 3 /* Set block mask to this mask */
+
+#define SIG_ERR ((void (*)())(-1))
+#define SIG_DFL ((void (*)())( 0))
+#define SIG_IGN ((void (*)())( 1))
+
+
+#define __SIGFILLSET 0xffffffff
+#define __SIGEMPTYSET 0
+#define __SIGADDSET(s,n) ((*s) |= (1 << ((n) - 1)))
+#define __SIGDELSET(s,n) ((*s) &= ~(1 << ((n) - 1)))
+#define __SIGISMEMBER(s,n) ((*s) & (1 << ((n) - 1)))
+
diff --git a/mit-pthreads/machdep/ultrix-4.2/__stdio.h b/mit-pthreads/machdep/ultrix-4.2/__stdio.h
new file mode 100755
index 00000000000..3f6aee47de3
--- /dev/null
+++ b/mit-pthreads/machdep/ultrix-4.2/__stdio.h
@@ -0,0 +1,7 @@
+
+#if ! defined(_SIZE_T_)
+#define _SIZE_T_
+typedef pthread_size_t size_t;
+#endif
+
+typedef pthread_fpos_t fpos_t;
diff --git a/mit-pthreads/machdep/ultrix-4.2/__stdlib.h b/mit-pthreads/machdep/ultrix-4.2/__stdlib.h
new file mode 100755
index 00000000000..e2e52cc41c9
--- /dev/null
+++ b/mit-pthreads/machdep/ultrix-4.2/__stdlib.h
@@ -0,0 +1,21 @@
+
+#ifndef _SYS___STDLIB_H_
+#define _SYS___STDLIB_H_
+
+#include <ansi_compat.h>
+
+#ifndef _SIZE_T_
+#define _SIZE_T_
+typedef unsigned int size_t;
+#endif
+
+#ifndef _WCHAR_T_
+#define _WCHAR_T_
+typedef unsigned int wchar_t;
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/ultrix-4.2/__string.h b/mit-pthreads/machdep/ultrix-4.2/__string.h
new file mode 100755
index 00000000000..03039b5cf73
--- /dev/null
+++ b/mit-pthreads/machdep/ultrix-4.2/__string.h
@@ -0,0 +1,17 @@
+
+#if ! defined(_SIZE_T_)
+#define _SIZE_T_
+typedef pthread_size_t size_t;
+#endif
+
+/* Non-standard Ultrix 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));
+__END_DECLS
+#endif
+
diff --git a/mit-pthreads/machdep/ultrix-4.2/__time.h b/mit-pthreads/machdep/ultrix-4.2/__time.h
new file mode 100755
index 00000000000..dddc54430bc
--- /dev/null
+++ b/mit-pthreads/machdep/ultrix-4.2/__time.h
@@ -0,0 +1,69 @@
+/*
+ * 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$
+ */
+
+#ifndef _SYS__TIME_H_
+#define _SYS__TIME_H_
+
+#include <ansi_compat.h>
+
+#ifndef _CLOCK_T_
+#define _CLOCK_T_
+typedef int clock_t;
+#endif
+
+#ifndef _TIME_T_
+#define _TIME_T_
+typedef int time_t;
+#endif
+
+#ifndef _SIZE_T_
+#define _SIZE_T_
+typedef unsigned int size_t;
+#endif
+
+#define CLOCKS_PER_SEC 1000000
+
+#if !defined(_ANSI_SOURCE)
+#define CLK_TCK 60
+#endif /* not ANSI */
+
+#endif /* !_SYS__TIME_H_ */
diff --git a/mit-pthreads/machdep/ultrix-4.2/__unistd.h b/mit-pthreads/machdep/ultrix-4.2/__unistd.h
new file mode 100755
index 00000000000..f570242ef0d
--- /dev/null
+++ b/mit-pthreads/machdep/ultrix-4.2/__unistd.h
@@ -0,0 +1,51 @@
+/*-
+ * 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$
+ */
+
+#ifndef _SYS___UNISTD_H_
+#define _SYS___UNISTD_H_
+
+#include <sys/types.h>
+
+#ifndef _SSIZE_T_
+#define _SSIZE_T_
+typedef int ssize_t;
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/ultrix-4.2/cdefs.h b/mit-pthreads/machdep/ultrix-4.2/cdefs.h
new file mode 100755
index 00000000000..4e1dc1c280d
--- /dev/null
+++ b/mit-pthreads/machdep/ultrix-4.2/cdefs.h
@@ -0,0 +1,66 @@
+/* ==== cdefs.h ============================================================
+ * Copyright (c) 1994 by Chris Provenzano, proven@athena.mit.edu
+ *
+ * Description : Similar to the BSD cdefs.h file.
+ *
+ * 1.00 94/01/26 proven
+ * -Started coding this file.
+ */
+
+#ifndef _PTHREAD_SYS_CDEFS_H_
+#define _PTHREAD_SYS_CDEFS_H_
+
+/* Stuff for compiling */
+#if defined(__GNUC__)
+#if defined(__cplusplus)
+#define __INLINE static inline
+#define __BEGIN_DECLS extern "C" {
+#define __END_DECLS };
+#else
+#define __INLINE extern inline
+#define __CAN_DO_EXTERN_INLINE
+#define __BEGIN_DECLS
+#define __END_DECLS
+#if !defined(__STDC__)
+#define const __const
+#define inline __inline
+#define signed __signed
+#define volatile __volatile
+#endif
+#endif
+#else /* !__GNUC__ */
+#define __INLINE static
+#define __BEGIN_DECLS
+#define __END_DECLS
+#endif
+
+#ifndef __NORETURN
+#define __NORETURN
+#endif /* __NORETURN not defined. */
+
+#ifndef _U_INT32_T_
+#define _U_INT32_T_
+typedef unsigned int u_int32_t;
+#endif
+
+#ifndef _U_INT16_T_
+#define _U_INT16_T_
+typedef unsigned short u_int16_t;
+#endif
+
+#ifndef _INT32_T_
+#define _INT32_T_
+typedef int int32_t;
+#endif
+
+#ifndef _INT16_T_
+#define _INT16_T_
+typedef short int16_t;
+#endif
+
+#ifndef _SSIZE_T_
+#define _SSIZE_T_
+typedef int ssize_t;
+#endif
+
+#endif
diff --git a/mit-pthreads/machdep/ultrix-4.2/compat.h b/mit-pthreads/machdep/ultrix-4.2/compat.h
new file mode 100755
index 00000000000..b2a846d00ee
--- /dev/null
+++ b/mit-pthreads/machdep/ultrix-4.2/compat.h
@@ -0,0 +1,45 @@
+/* ==== 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$
+ *
+ * Description : Basic timers header.
+ *
+ * 1.00 94/06/13 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS_COMPAT_H_
+#define _SYS_COMPAT_H_
+
+#define omsghdr msghdr
+
+#endif
diff --git a/mit-pthreads/machdep/ultrix-4.2/dirent.h b/mit-pthreads/machdep/ultrix-4.2/dirent.h
new file mode 100755
index 00000000000..5f17af345db
--- /dev/null
+++ b/mit-pthreads/machdep/ultrix-4.2/dirent.h
@@ -0,0 +1,61 @@
+/*-
+ * 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
+
+#endif /* !_SYS_DIRENT_H_ */
diff --git a/mit-pthreads/machdep/ultrix-4.2/errno.h b/mit-pthreads/machdep/ultrix-4.2/errno.h
new file mode 100755
index 00000000000..b47633a9456
--- /dev/null
+++ b/mit-pthreads/machdep/ultrix-4.2/errno.h
@@ -0,0 +1,180 @@
+/*
+ * 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 _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 EAGAIN 11 /* No more processes */
+#define ENOMEM 12 /* Cannot allocate memory */
+#define EACCES 13 /* Permission denied */
+#define EFAULT 14 /* Bad address */
+/* 15 Non POSIX */
+/* 16 Non POSIX */
+#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 */
+/* 26 Non POSIX */
+#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 */
+/* 35 Non POSIX */
+/* 36 Non POSIX */
+/* 37 Non POSIX */
+/* 38 Non POSIX */
+/* 39 Non POSIX */
+/* 40 Non POSIX */
+/* 41 Non POSIX */
+/* 42 Non POSIX */
+/* 43 Non POSIX */
+/* 44 Non POSIX */
+/* 45 Non POSIX */
+/* 46 Non POSIX */
+/* 47 Non POSIX */
+/* 48 Non POSIX */
+/* 49 Non POSIX */
+/* 50 Non POSIX */
+/* 51 Non POSIX */
+/* 52 Non POSIX */
+/* 53 Non POSIX */
+/* 54 Non POSIX */
+/* 55 Non POSIX */
+/* 56 Non POSIX */
+/* 57 Non POSIX */
+/* 58 Non POSIX */
+/* 59 Non POSIX */
+/* 60 Non POSIX */
+/* 61 Non POSIX */
+/* 62 Non POSIX */
+#define ENAMETOOLONG 63 /* File name too long */
+/* 64 Non POSIX */
+/* 65 Non POSIX */
+#define ENOTEMPTY 66 /* Directory not empty */
+/* 67 Non POSIX */
+/* 68 Non POSIX */
+/* 69 Non POSIX */
+/* 70 Non POSIX */
+/* 71 Non POSIX */
+/* 72 Non POSIX */
+/* 73 Non POSIX */
+/* 74 Non POSIX */
+#define ENOLCK 75 /* No locks available */
+#define ENOSYS 76 /* Function not implemented */
+
+#ifndef _POSIX_SOURCE
+#define ENOTBLK 15 /* Block device required */
+#define EBUSY 16 /* Device busy */
+#define ETXTBSY 26 /* Text file busy */
+
+/* non-blocking and interrupt i/o */
+#define EWOULDBLOCK 35 /* Operation would block */
+#define EDEADLK EWOULDBLOCK /* Resource deadlock avoided */
+#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 on socket */
+#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 /* Connection timed out */
+#define ECONNREFUSED 61 /* Connection refused */
+
+#define ELOOP 62 /* Too many levels of symbolic links */
+
+#define EHOSTDOWN 64 /* Host is down */
+#define EHOSTUNREACH 65 /* No route to host */
+
+/* quotas & mush */
+#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 */
+
+/* IPC errors */
+#define ENOMSG 72 /* RPC struct is bad */
+#define EIDRM 73 /* RPC version wrong */
+
+/* Alignment error of some type (i.e., cluster, page, block ...) */
+#define EALIGN 74 /* RPC prog. not avail */
+#endif /* _POSIX_SOURCE */
+
+#endif /* _SYS_ERRNO_H_ */
diff --git a/mit-pthreads/machdep/ultrix-4.2/time.h b/mit-pthreads/machdep/ultrix-4.2/time.h
new file mode 100755
index 00000000000..1dbb32b67a4
--- /dev/null
+++ b/mit-pthreads/machdep/ultrix-4.2/time.h
@@ -0,0 +1,83 @@
+/*
+ * 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$
+ */
+
+#ifndef _SYS_TIME_H_
+#define _SYS_TIME_H_
+
+#include <time.h>
+#include <sys/cdefs.h>
+
+struct timeval {
+ long tv_sec; /* seconds */
+ long tv_usec; /* microseconds */
+};
+
+struct timezone {
+ int tz_minuteswest; /* minutes west of Greenwich */
+ int tz_dsttime; /* dst correction */
+};
+#define DST_NONE 0 /* not on dst */
+#define DST_USA 1 /* USA style dst */
+#define DST_AUST 2 /* Australian style dst */
+#define DST_WET 3 /* Western European dst */
+#define DST_MET 4 /* Middle European dst */
+#define DST_EET 5 /* Eastern European dst */
+
+
+struct itimerval {
+ struct timeval it_interval; /* timer interval */
+ struct timeval it_value; /* current value */
+};
+#define ITIMER_REAL 0
+#define ITIMER_VIRTUAL 1
+#define ITIMER_PROF 2
+
+/*
+ * Functions
+ */
+__BEGIN_DECLS
+
+int gettimeofday __P_((struct timeval *, struct timezone *));
+
+__END_DECLS
+
+#endif
diff --git a/mit-pthreads/machdep/ultrix-4.2/timers.h b/mit-pthreads/machdep/ultrix-4.2/timers.h
new file mode 100755
index 00000000000..3c4d057976a
--- /dev/null
+++ b/mit-pthreads/machdep/ultrix-4.2/timers.h
@@ -0,0 +1,68 @@
+/* ==== 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$
+ *
+ * Description : Basic timers header.
+ *
+ * 1.00 94/06/13 proven
+ * -Started coding this file.
+ */
+
+#ifndef _SYS_TIMERS_H_
+#define _SYS_TIMERS_H_
+
+#include <sys/types.h>
+#include <time.h>
+
+struct timespec {
+ time_t tv_sec;
+ long tv_nsec;
+};
+
+#define TIMEVAL_TO_TIMESPEC(tv, ts) { \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000; \
+}
+#define TIMESPEC_TO_TIMEVAL(tv, ts) { \
+ (tv)->tv_sec = (ts)->tv_sec; \
+ (tv)->tv_usec = (ts)->tv_nsec / 1000; \
+}
+
+/*
+ * New functions
+ */
+
+__BEGIN_DECLS
+
+__END_DECLS
+
+#endif
diff --git a/mit-pthreads/machdep/ultrix-4.2/wait.h b/mit-pthreads/machdep/ultrix-4.2/wait.h
new file mode 100755
index 00000000000..8114f7e461d
--- /dev/null
+++ b/mit-pthreads/machdep/ultrix-4.2/wait.h
@@ -0,0 +1,121 @@
+
+#ifndef _SYS_WAIT_H_
+#define _SYS_WAIT_H_
+
+#include <ansi_compat.h>
+#include <sys/cdefs.h>
+
+#if !defined(_POSIX_SOURCE)
+union wait {
+#else
+union __wait {
+#endif /* !defined(_POSIX_SOURCE) */
+#ifdef __vax
+ int w_status; /* used in syscall */
+#endif /* __vax */
+#ifdef __mips__
+ unsigned int w_status; /* used in syscall */
+#endif /* __mips */
+ /*
+ * Terminated process status.
+ */
+ struct {
+#ifdef __vax
+ unsigned short w_Termsig:7; /* termination signal */
+ unsigned short w_Coredump:1; /* core dump indicator */
+ unsigned short w_Retcode:8; /* exit code if w_termsig==0 */
+#endif /* __vax */
+#ifdef __mips__
+#ifdef __MIPSEL__
+ unsigned int w_Termsig:7; /* termination signal */
+ unsigned int w_Coredump:1; /* core dump indicator */
+ unsigned int w_Retcode:8; /* exit code if w_termsig==0 */
+ unsigned int w_Filler:16; /* pad to word boundary */
+#endif /* __MIPSEL */
+#ifdef __MIPSEB__
+ unsigned int w_Filler:16; /* pad to word boundary */
+ unsigned int w_Retcode:8; /* exit code if w_termsig==0 */
+ unsigned int w_Coredump:1; /* core dump indicator */
+ unsigned int w_Termsig:7; /* termination signal */
+#endif /* __MIPSEB */
+#endif /* __mips */
+ } w_T;
+ /*
+ * Stopped process status. Returned
+ * only for traced children unless requested
+ * with the WUNTRACED option bit.
+ */
+ struct {
+#ifdef __vax
+ unsigned short w_Stopval:8; /* == W_STOPPED if stopped */
+ unsigned short w_Stopsig:8; /* signal that stopped us */
+#endif /* __vax */
+#ifdef __mips__
+#ifdef __MIPSEL__
+ unsigned int w_Stopval:8; /* == W_STOPPED if stopped */
+ unsigned int w_Stopsig:8; /* signal that stopped us */
+ unsigned int w_Filler:16; /* pad to word boundary */
+#endif /* __MIPSEL */
+#ifdef __MIPSEB__
+ unsigned int w_Filler:16; /* pad to word boundary */
+ unsigned int w_Stopsig:8; /* signal that stopped us */
+ unsigned int w_Stopval:8; /* == W_STOPPED if stopped */
+#endif /* __MIPSEB */
+#endif /* __mips */
+ } w_S;
+};
+
+#if !defined(_POSIX_SOURCE)
+#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 0177 /* value of s.stopval if process is stopped */
+#endif /* !defined(_POSIX_SOURCE) */
+
+#ifdef WSTOPPED
+#define _WSTOPPED WSTOPPED
+#else
+#define _WSTOPPED 0177
+#endif
+
+/*
+ * Option bits for the second argument of wait3. 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 */
+
+/*
+ * Must cast as union wait * because POSIX defines the input to these macros
+ * as int.
+ */
+
+#ifdef _POSIX_SOURCE
+#define WIFSTOPPED(x) (((union __wait *)&(x))->w_S.w_Stopval == _WSTOPPED)
+#define WIFSIGNALED(x) (((union __wait *)&(x))->w_S.w_Stopval != _WSTOPPED && ((union __wait *)&(x))->w_T.w_Termsig != 0)
+#define WIFEXITED(x) (((union __wait *)&(x))->w_S.w_Stopval != _WSTOPPED && ((union __wait *)&(x))->w_T.w_Termsig == 0)
+#define WEXITSTATUS(x) (((union __wait *)&(x))->w_T.w_Retcode)
+#define WTERMSIG(x) (((union __wait *)&(x))->w_T.w_Termsig)
+#define WSTOPSIG(x) (((union __wait *)&(x))->w_S.w_Stopsig)
+#endif /* _POSIX_SOURCE */
+
+#if !defined(_POSIX_SOURCE)
+#define WIFSTOPPED(x) (((union wait *)&(x))->w_stopval == WSTOPPED)
+#define WIFSIGNALED(x) (((union wait *)&(x))->w_stopval != WSTOPPED && ((union wait *)&(x))->w_termsig != 0)
+#define WIFEXITED(x) (((union wait *)&(x))->w_stopval != WSTOPPED && ((union wait *)&(x))->w_termsig == 0)
+#define WEXITSTATUS(x) (((union wait *)&(x))->w_retcode)
+#define WTERMSIG(x) (((union wait *)&(x))->w_termsig)
+#define WSTOPSIG(x) (((union wait *)&(x))->w_stopsig)
+#endif /* !defined(_POSIX_SOURCE) */
+
+pid_t wait __P_((int *));
+pid_t waitpid __P_((pid_t, int *, int));
+
+#endif /* _SYS_WAIT_H_ */
diff --git a/mit-pthreads/machdep/unistd-i386-freebsd-1.1.h b/mit-pthreads/machdep/unistd-i386-freebsd-1.1.h
new file mode 100644
index 00000000000..033e70de5e5
--- /dev/null
+++ b/mit-pthreads/machdep/unistd-i386-freebsd-1.1.h
@@ -0,0 +1,178 @@
+/*-
+ * 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/types.h>
+#include <sys/unistd.h>
+
+#define STDIN_FILENO 0 /* standard input file descriptor */
+#define STDOUT_FILENO 1 /* standard output file descriptor */
+#define STDERR_FILENO 2 /* standard error file descriptor */
+
+#ifndef NULL
+#define NULL 0 /* null pointer constant */
+#endif
+
+typedef int ssize_t; /* count of bytes or error indication */
+
+__BEGIN_DECLS
+void _exit __P_((int));
+int access __P_((const char *, int));
+u_int alarm __P_((u_int));
+int chdir __P_((const char *));
+int chown __P_((const char *, uid_t, gid_t));
+int close __P_((int));
+char *cuserid __P_((char *));
+int dup __P_((int));
+int dup2 __P_((int, int));
+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 execve __P_((const char *, char * const *, char * const *));
+int execvp __P_((const char *, char * const *));
+pid_t fork __P_((void));
+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));
+int isatty __P_((int));
+int link __P_((const char *, const char *));
+off_t lseek __P_((int, off_t, int));
+long pathconf __P_((const char *, int)); /* not yet */
+int pause __P_((void));
+int pipe __P_((int *));
+ssize_t read __P_((int, void *, size_t));
+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));
+u_int sleep __P_((u_int));
+long sysconf __P_((int)); /* not yet */
+pid_t tcgetpgrp __P_((int));
+int tcsetpgrp __P_((int, pid_t));
+char *ttyname __P_((int));
+int unlink __P_((const char *));
+ssize_t write __P_((int, const void *, size_t));
+
+#ifndef _POSIX_SOURCE
+
+/* structure timeval required for select() */
+#include <sys/time.h>
+
+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 select __P_((int, fd_set *, fd_set *, fd_set *, struct timeval *));
+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));
+void *valloc __P_((size_t)); /* obsoleted by malloc() */
+int vfork __P_((void));
+
+#endif /* !_POSIX_SOURCE */
+__END_DECLS
+
+#endif /* !_UNISTD_H_ */
diff --git a/mit-pthreads/machdep/unistd-i386-linux-1.0.h b/mit-pthreads/machdep/unistd-i386-linux-1.0.h
new file mode 100644
index 00000000000..e7a3c5de1e4
--- /dev/null
+++ b/mit-pthreads/machdep/unistd-i386-linux-1.0.h
@@ -0,0 +1,59 @@
+/*-
+ * 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 <features.h>
+
+/* POSIX Standard approved as IEEE Std 1003.1 as of August, 1988. */
+#define _POSIX_VERSION 199009L
+#define _POSIX2_C_BIND 1
+#define _POSIX2_C_DEV 1
+#define _POSIX2_SW_DEV 1
+
+#define __need_size_t
+
+#include <posix_opt.h>
+#include <sys/types.h>
+#include <stddef.h>
+
+#define STDIN_FILENO 0 /* standard input file descriptor */
+#define STDOUT_FILENO 1 /* standard output file descriptor */
+#define STDERR_FILENO 2 /* standard error file descriptor */
+
+#include <pthread/unistd.h>
+
+#endif /* !_UNISTD_H_ */
diff --git a/mit-pthreads/machdep/unistd-i386-linux-2.0.h b/mit-pthreads/machdep/unistd-i386-linux-2.0.h
new file mode 100644
index 00000000000..e7a3c5de1e4
--- /dev/null
+++ b/mit-pthreads/machdep/unistd-i386-linux-2.0.h
@@ -0,0 +1,59 @@
+/*-
+ * 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 <features.h>
+
+/* POSIX Standard approved as IEEE Std 1003.1 as of August, 1988. */
+#define _POSIX_VERSION 199009L
+#define _POSIX2_C_BIND 1
+#define _POSIX2_C_DEV 1
+#define _POSIX2_SW_DEV 1
+
+#define __need_size_t
+
+#include <posix_opt.h>
+#include <sys/types.h>
+#include <stddef.h>
+
+#define STDIN_FILENO 0 /* standard input file descriptor */
+#define STDOUT_FILENO 1 /* standard output file descriptor */
+#define STDERR_FILENO 2 /* standard error file descriptor */
+
+#include <pthread/unistd.h>
+
+#endif /* !_UNISTD_H_ */
diff --git a/mit-pthreads/machdep/unistd-sparc-sunos-4.1.3.h b/mit-pthreads/machdep/unistd-sparc-sunos-4.1.3.h
new file mode 100644
index 00000000000..4d2161b628f
--- /dev/null
+++ b/mit-pthreads/machdep/unistd-sparc-sunos-4.1.3.h
@@ -0,0 +1,215 @@
+/*-
+ * 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.
+ *
+ * from: @(#)unistd.h 5.13 (Berkeley) 6/17/91
+ * $Id$
+ */
+
+#ifndef _UNISTD_H_
+#define _UNISTD_H_
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#define _NO_STDIO_SIZE_T
+
+#define _SC_ARG_MAX 1 /* space for argv & envp */
+#define _SC_CHILD_MAX 2 /* maximum children per process??? */
+#define _SC_CLK_TCK 3 /* clock ticks/sec */
+#define _SC_NGROUPS_MAX 4 /* number of groups if multple supp. */
+#define _SC_OPEN_MAX 5 /* max open files per process */
+#define _SC_JOB_CONTROL 6 /* do we have job control */
+#define _SC_SAVED_IDS 7 /* do we have saved uid/gids */
+#define _SC_VERSION 8 /* POSIX version supported */
+
+#define _POSIX_JOB_CONTROL 1
+#define _POSIX_SAVED_IDS 1
+#define _POSIX_VERSION 198808
+
+#define _PC_LINK_MAX 1 /* max links to file/dir */
+#define _PC_MAX_CANON 2 /* max line length */
+#define _PC_MAX_INPUT 3 /* max "packet" to a tty device */
+#define _PC_NAME_MAX 4 /* max pathname component length */
+#define _PC_PATH_MAX 5 /* max pathname length */
+#define _PC_PIPE_BUF 6 /* size of a pipe */
+#define _PC_CHOWN_RESTRICTED 7 /* can we give away files */
+#define _PC_NO_TRUNC 8 /* trunc or error on >NAME_MAX */
+#define _PC_VDISABLE 9 /* best char to shut off tty c_cc */
+#define _PC_LAST 9 /* highest value of any _PC_* */
+
+
+#define STDIN_FILENO 0 /* standard input file descriptor */
+#define STDOUT_FILENO 1 /* standard output file descriptor */
+#define STDERR_FILENO 2 /* standard error file descriptor */
+
+#ifndef NULL
+#define NULL 0 /* null pointer constant */
+#endif
+
+typedef int ssize_t;
+
+__BEGIN_DECLS
+void _exit __P_((int));
+int access __P_((const char *, int));
+unsigned alarm __P_((unsigned));
+int chdir __P_((const char *));
+int chown __P_((const char *, uid_t, gid_t));
+int close __P_((int));
+size_t confstr __P_((int, char *, size_t));
+char *cuserid __P_((char *));
+int dup __P_((int));
+int dup2 __P_((int, int));
+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 execve __P_((const char *, char * const *, char * const *));
+int execvp __P_((const char *, char * const *));
+pid_t fork __P_((void));
+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));
+int isatty __P_((int));
+int link __P_((const char *, const char *));
+off_t lseek __P_((int, off_t, int));
+long pathconf __P_((const char *, int)); /* not yet */
+int pause __P_((void));
+int pipe __P_((int *));
+ssize_t read __P_((int, void *, size_t));
+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));
+unsigned sleep __P_((unsigned));
+long sysconf __P_((int)); /* not yet */
+pid_t tcgetpgrp __P_((int));
+int tcsetpgrp __P_((int, pid_t));
+char *ttyname __P_((int));
+int unlink __P_((const char *));
+ssize_t write __P_((int, const void *, size_t));
+
+#ifndef _POSIX_SOURCE
+
+/* structure timeval required for select() */
+#include <sys/time.h>
+
+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 getdomainname __P_((char *, int));
+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 const char *const 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 select __P_((int, fd_set *, fd_set *, fd_set *, struct timeval *));
+int setdomainname __P_((const char *, 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));
+void *valloc __P_((size_t)); /* obsoleted by malloc() */
+pid_t vfork __P_((void));
+
+int getopt __P_((int, char * const *, const char *));
+extern char *optarg; /* getopt(3) external variables */
+extern int opterr;
+extern int optind;
+extern int optopt;
+int getsubopt __P_((char **, char * const *, char **));
+extern char *suboptarg; /* getsubopt(3) external variable */
+#endif /* !_POSIX_SOURCE */
+__END_DECLS
+
+#endif /* !_UNISTD_H_ */
diff --git a/mit-pthreads/net/GNUmakefile.inc b/mit-pthreads/net/GNUmakefile.inc
new file mode 100644
index 00000000000..6b89617f63b
--- /dev/null
+++ b/mit-pthreads/net/GNUmakefile.inc
@@ -0,0 +1,14 @@
+# from: @(#)Makefile.inc 5.21 (Berkeley) 5/24/91
+# $Id$
+
+# gen sources
+VPATH:= ${VPATH}:${srcdir}/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 \
+ res_debug.c serv_internal.c $(SRCS)
+
diff --git a/mit-pthreads/net/Makefile.inc b/mit-pthreads/net/Makefile.inc
new file mode 100644
index 00000000000..08be88c808f
--- /dev/null
+++ b/mit-pthreads/net/Makefile.inc
@@ -0,0 +1,13 @@
+# from: @(#)Makefile.inc 5.21 (Berkeley) 5/24/91
+# $Id$
+
+# gen sources
+.PATH: ${srcdir}/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 gethostname.c
diff --git a/mit-pthreads/net/gethostbyaddr.c b/mit-pthreads/net/gethostbyaddr.c
new file mode 100644
index 00000000000..f80e47ffd99
--- /dev/null
+++ b/mit-pthreads/net/gethostbyaddr.c
@@ -0,0 +1,161 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/gethostbyname.c b/mit-pthreads/net/gethostbyname.c
new file mode 100644
index 00000000000..aaaaf79b31b
--- /dev/null
+++ b/mit-pthreads/net/gethostbyname.c
@@ -0,0 +1,167 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/gethostent.c b/mit-pthreads/net/gethostent.c
new file mode 100644
index 00000000000..d6feb7aa164
--- /dev/null
+++ b/mit-pthreads/net/gethostent.c
@@ -0,0 +1,162 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/gethostname.c b/mit-pthreads/net/gethostname.c
new file mode 100644
index 00000000000..8bec0793296
--- /dev/null
+++ b/mit-pthreads/net/gethostname.c
@@ -0,0 +1,22 @@
+/* Copyright Abandoned 2000 TCX DataKonsult AB & Monty Program KB & Detron HB
+ This file is public domain and comes with NO WARRANTY of any kind */
+
+#include "config.h"
+#include <pthread.h>
+#include <sys/utsname.h>
+
+#ifdef HAVE_SYSCALL_UNAME
+int gethostname(char *name, int len)
+{
+ int ret;
+ struct utsname buf;
+
+ if ((ret = machdep_sys_chroot(&buf)) < OK)
+ {
+ SET_ERRNO(-ret);
+ }
+ else
+ strncpy(name,uname->sysname, len);
+ return(ret);
+}
+#endif
diff --git a/mit-pthreads/net/getnetbyaddr.c b/mit-pthreads/net/getnetbyaddr.c
new file mode 100644
index 00000000000..6fba661c92e
--- /dev/null
+++ b/mit-pthreads/net/getnetbyaddr.c
@@ -0,0 +1,65 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/getnetbyname.c b/mit-pthreads/net/getnetbyname.c
new file mode 100644
index 00000000000..5b044ceb7a7
--- /dev/null
+++ b/mit-pthreads/net/getnetbyname.c
@@ -0,0 +1,72 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/getnetent.c b/mit-pthreads/net/getnetent.c
new file mode 100644
index 00000000000..05af0b09159
--- /dev/null
+++ b/mit-pthreads/net/getnetent.c
@@ -0,0 +1,145 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/getproto.c b/mit-pthreads/net/getproto.c
new file mode 100644
index 00000000000..f6313bf1510
--- /dev/null
+++ b/mit-pthreads/net/getproto.c
@@ -0,0 +1,65 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/getprotoent.c b/mit-pthreads/net/getprotoent.c
new file mode 100644
index 00000000000..8bd8d95ec14
--- /dev/null
+++ b/mit-pthreads/net/getprotoent.c
@@ -0,0 +1,143 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/getprotoname.c b/mit-pthreads/net/getprotoname.c
new file mode 100644
index 00000000000..7bd7b925091
--- /dev/null
+++ b/mit-pthreads/net/getprotoname.c
@@ -0,0 +1,73 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/getservbyname.c b/mit-pthreads/net/getservbyname.c
new file mode 100644
index 00000000000..f482b544fd0
--- /dev/null
+++ b/mit-pthreads/net/getservbyname.c
@@ -0,0 +1,76 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/getservbyport.c b/mit-pthreads/net/getservbyport.c
new file mode 100644
index 00000000000..e3418212c0b
--- /dev/null
+++ b/mit-pthreads/net/getservbyport.c
@@ -0,0 +1,68 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/getservent.c b/mit-pthreads/net/getservent.c
new file mode 100644
index 00000000000..b0a7e039f69
--- /dev/null
+++ b/mit-pthreads/net/getservent.c
@@ -0,0 +1,146 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/herror.c b/mit-pthreads/net/herror.c
new file mode 100644
index 00000000000..935c8e7ea38
--- /dev/null
+++ b/mit-pthreads/net/herror.c
@@ -0,0 +1,92 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/inet_addr.c b/mit-pthreads/net/inet_addr.c
new file mode 100644
index 00000000000..75ca154d4c2
--- /dev/null
+++ b/mit-pthreads/net/inet_addr.c
@@ -0,0 +1,156 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/inet_lnaof.c b/mit-pthreads/net/inet_lnaof.c
new file mode 100644
index 00000000000..752a5f03f79
--- /dev/null
+++ b/mit-pthreads/net/inet_lnaof.c
@@ -0,0 +1,61 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/inet_makeaddr.c b/mit-pthreads/net/inet_makeaddr.c
new file mode 100644
index 00000000000..a4995e2b4c4
--- /dev/null
+++ b/mit-pthreads/net/inet_makeaddr.c
@@ -0,0 +1,64 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/inet_netof.c b/mit-pthreads/net/inet_netof.c
new file mode 100644
index 00000000000..40d3f4c3385
--- /dev/null
+++ b/mit-pthreads/net/inet_netof.c
@@ -0,0 +1,60 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/inet_network.c b/mit-pthreads/net/inet_network.c
new file mode 100644
index 00000000000..cc0f1b4e603
--- /dev/null
+++ b/mit-pthreads/net/inet_network.c
@@ -0,0 +1,98 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/inet_ntoa.c b/mit-pthreads/net/inet_ntoa.c
new file mode 100644
index 00000000000..cd206afcf2a
--- /dev/null
+++ b/mit-pthreads/net/inet_ntoa.c
@@ -0,0 +1,85 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/net_internal.c b/mit-pthreads/net/net_internal.c
new file mode 100644
index 00000000000..2c25ff76693
--- /dev/null
+++ b/mit-pthreads/net/net_internal.c
@@ -0,0 +1,78 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/net_internal.h b/mit-pthreads/net/net_internal.h
new file mode 100644
index 00000000000..10ece181a94
--- /dev/null
+++ b/mit-pthreads/net/net_internal.h
@@ -0,0 +1,57 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/proto_internal.c b/mit-pthreads/net/proto_internal.c
new file mode 100644
index 00000000000..db3ab04ec77
--- /dev/null
+++ b/mit-pthreads/net/proto_internal.c
@@ -0,0 +1,78 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/proto_internal.h b/mit-pthreads/net/proto_internal.h
new file mode 100644
index 00000000000..d40f77b519e
--- /dev/null
+++ b/mit-pthreads/net/proto_internal.h
@@ -0,0 +1,57 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/res_comp.c b/mit-pthreads/net/res_comp.c
new file mode 100644
index 00000000000..45a4bcafed2
--- /dev/null
+++ b/mit-pthreads/net/res_comp.c
@@ -0,0 +1,340 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/res_debug.c b/mit-pthreads/net/res_debug.c
new file mode 100644
index 00000000000..3e2084fccf8
--- /dev/null
+++ b/mit-pthreads/net/res_debug.c
@@ -0,0 +1,749 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/res_init.c b/mit-pthreads/net/res_init.c
new file mode 100644
index 00000000000..0a5c944c974
--- /dev/null
+++ b/mit-pthreads/net/res_init.c
@@ -0,0 +1,55 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/res_internal.c b/mit-pthreads/net/res_internal.c
new file mode 100644
index 00000000000..4eab65bf5aa
--- /dev/null
+++ b/mit-pthreads/net/res_internal.c
@@ -0,0 +1,576 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/res_internal.h b/mit-pthreads/net/res_internal.h
new file mode 100644
index 00000000000..4a4691bab84
--- /dev/null
+++ b/mit-pthreads/net/res_internal.h
@@ -0,0 +1,84 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/res_mkquery.c b/mit-pthreads/net/res_mkquery.c
new file mode 100644
index 00000000000..42f27318368
--- /dev/null
+++ b/mit-pthreads/net/res_mkquery.c
@@ -0,0 +1,212 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/res_query.c b/mit-pthreads/net/res_query.c
new file mode 100644
index 00000000000..1727e6d1179
--- /dev/null
+++ b/mit-pthreads/net/res_query.c
@@ -0,0 +1,97 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/res_querydomain.c b/mit-pthreads/net/res_querydomain.c
new file mode 100644
index 00000000000..31beeb7a62c
--- /dev/null
+++ b/mit-pthreads/net/res_querydomain.c
@@ -0,0 +1,66 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/res_search.c b/mit-pthreads/net/res_search.c
new file mode 100644
index 00000000000..2c84f0d68f3
--- /dev/null
+++ b/mit-pthreads/net/res_search.c
@@ -0,0 +1,168 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/res_send.c b/mit-pthreads/net/res_send.c
new file mode 100644
index 00000000000..84162e8e387
--- /dev/null
+++ b/mit-pthreads/net/res_send.c
@@ -0,0 +1,313 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/serv_internal.c b/mit-pthreads/net/serv_internal.c
new file mode 100644
index 00000000000..f4acc8697ae
--- /dev/null
+++ b/mit-pthreads/net/serv_internal.c
@@ -0,0 +1,80 @@
+/*
+ * 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$";
+#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/mit-pthreads/net/serv_internal.h b/mit-pthreads/net/serv_internal.h
new file mode 100644
index 00000000000..1d933826083
--- /dev/null
+++ b/mit-pthreads/net/serv_internal.h
@@ -0,0 +1,57 @@
+/*
+ * 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$";
+#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/mit-pthreads/patches/Streepy.html b/mit-pthreads/patches/Streepy.html
new file mode 100755
index 00000000000..a3b4faa815f
--- /dev/null
+++ b/mit-pthreads/patches/Streepy.html
@@ -0,0 +1,2873 @@
+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/mit-pthreads/patches/Streepy2.html b/mit-pthreads/patches/Streepy2.html
new file mode 100755
index 00000000000..80d44d6440c
--- /dev/null
+++ b/mit-pthreads/patches/Streepy2.html
@@ -0,0 +1,93 @@
+<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/mit-pthreads/patches/bill_lear b/mit-pthreads/patches/bill_lear
new file mode 100755
index 00000000000..f49b79c4272
--- /dev/null
+++ b/mit-pthreads/patches/bill_lear
@@ -0,0 +1,70 @@
+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/mit-pthreads/patches/chris_demetriou b/mit-pthreads/patches/chris_demetriou
new file mode 100755
index 00000000000..283d6c1999c
--- /dev/null
+++ b/mit-pthreads/patches/chris_demetriou
@@ -0,0 +1,149 @@
+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$";
+ #endif
+
diff --git a/mit-pthreads/patches/mevans b/mit-pthreads/patches/mevans
new file mode 100755
index 00000000000..d5ff2f27610
--- /dev/null
+++ b/mit-pthreads/patches/mevans
@@ -0,0 +1,642 @@
+=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/mit-pthreads/patches/p153 b/mit-pthreads/patches/p153
new file mode 100755
index 00000000000..4e374e29a10
--- /dev/null
+++ b/mit-pthreads/patches/p153
@@ -0,0 +1,90 @@
+<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/mit-pthreads/patches/p155 b/mit-pthreads/patches/p155
new file mode 100755
index 00000000000..dbdfa7de899
--- /dev/null
+++ b/mit-pthreads/patches/p155
@@ -0,0 +1,96 @@
+<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/mit-pthreads/pg++ b/mit-pthreads/pg++
new file mode 100755
index 00000000000..0d5f78929ae
--- /dev/null
+++ b/mit-pthreads/pg++
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+pthreads_root=/usr/local/pthreads
+build_root=/dr1/my/masters/mysql/mit-pthreads
+src_root=/dr1/my/masters/mysql/mit-pthreads
+
+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 g++ '"$@"' $include_dir $lib_dir $libs
diff --git a/mit-pthreads/pgcc b/mit-pthreads/pgcc
new file mode 100755
index 00000000000..6eed8a2d0f0
--- /dev/null
+++ b/mit-pthreads/pgcc
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+pthreads_root=/usr/local/pthreads
+build_root=/dr1/my/masters/mysql/mit-pthreads
+src_root=/dr1/my/masters/mysql/mit-pthreads
+
+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 gcc '"$@"' $include_dir $lib_dir $libs
diff --git a/mit-pthreads/pthreads/GNUmakefile.inc b/mit-pthreads/pthreads/GNUmakefile.inc
new file mode 100644
index 00000000000..c8621495bac
--- /dev/null
+++ b/mit-pthreads/pthreads/GNUmakefile.inc
@@ -0,0 +1,46 @@
+# from: @(#)Makefile.inc 5.6 (Berkeley) 6/4/91
+
+# pthread sources
+VPATH := $(VPATH):${srcdir}/pthreads
+
+SRCS:= cleanup.c cond.c fd.c fd_kern.c fd_pipe.c fd_sysv.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 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 \
+ case " $(SYSCALL_EXCEPTIONS) " in \
+ *" "$$s" "*) ;; \
+ *) echo $$s ;; \
+ esac ; \
+ done
+STD_SYSCALLS:=$(shell $(SYSCALL_FILTER_RULE))
+STD_SYSCALL_FILES:= $(addprefix S,$(addsuffix .o,$(STD_SYSCALLS)))
+EXTRA_OBJS := $(EXTRA_OBJS) syscalls.o
+# EXTRA_OBJS := $(EXTRA_OBJS) $(STD_SYSCALL_FILES)
+
+ifndef SYSCALL_PIC_COMPILE
+SYSCALL_PIC_COMPILE=true
+endif
+
+obj/syscalls.o: syscall-template.S
+ -rm -rf obj/syscalls
+ mkdir obj/syscalls
+ for syscall in $(STD_SYSCALLS) ; do \
+ echo $$syscall ; \
+ $(CC) $(CFLAGS) -DSYSCALL_NAME=$$syscall -c syscall-template.S -o obj/syscalls/S$$syscall.o ; \
+ $(SYSCALL_PIC_COMPILE) ; \
+ done
+ x=`pwd` && cd obj/syscalls && ld -r -o ../syscalls.o S*.o && cd $$x
+ rm -r obj/syscalls
+endif
+
+syscall.o: ${.CURDIR}/pthreads/syscall.S
+ cpp ${CPPFLAGS} ${.CURDIR}/pthreads/syscall.S > syscall.i
+ as syscall.i
+ rm syscall.i
+ mv a.out syscall.o
diff --git a/mit-pthreads/pthreads/Makefile.inc b/mit-pthreads/pthreads/Makefile.inc
new file mode 100644
index 00000000000..3939d57de6e
--- /dev/null
+++ b/mit-pthreads/pthreads/Makefile.inc
@@ -0,0 +1,75 @@
+# from: @(#)Makefile.inc 5.6 (Berkeley) 6/4/91
+
+# pthread sources
+.PATH: ${srcdir}/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
+
+.if $(HAVE_SYSCALL_TEMPLATE) == yes
+OBJS+= syscalls.o
+.if !defined(NOPIC)
+SOBJS+= syscalls.so
+SYSCALL_PIC_COMPILE= $(CC) $(CFLAGS) -DSYSCALL_NAME=$$syscall -DPIC -c ${.CURDIR}/syscall-template.S -o ${.OBJDIR}/syscalls/S$$syscall.so
+.else
+SYSCALL_PIC_COMPILE= true
+.endif
+.if !defined(NOPROFILE)
+POBJS+= syscalls.po
+SYSCALL_PROF_COMPILE= $(CC) $(CFLAGS) -DSYSCALL_NAME=$$syscall -pg -c ${.CURDIR}/syscall-template.S -o ${.OBJDIR}/syscalls/S$$syscall.po
+.else
+SYSCALL_PROF_COMPILE= true
+.endif
+
+OPSYS!= uname -s
+
+syscalls.o syscalls.so syscalls.po : syscall-template.S
+ -rm -rf ${.OBJDIR}/syscalls
+ mkdir ${.OBJDIR}/syscalls
+ for syscall in $(AVAILABLE_SYSCALLS) ; do \
+ case " $(SYSCALL_EXCEPTIONS) " in \
+ *" "$$syscall" "*) ;; \
+ *) echo $$syscall ; \
+ $(CC) $(CFLAGS) -DSYSCALL_NAME=$$syscall -c ${.CURDIR}/syscall-template.S -o ${.OBJDIR}/syscalls/S$$syscall.o ; \
+ $(SYSCALL_PIC_COMPILE) ; \
+ $(SYSCALL_PROF_COMPILE) ;; \
+ esac ; \
+ done
+ x=`pwd` && cd ${.OBJDIR}/syscalls && ld -r -o ../syscalls.o *.o && cd $$x
+.if !defined(NOPIC)
+ x=`pwd` && cd ${.OBJDIR}/syscalls && ld -r -o ../syscalls.so *.so && cd $$x
+.endif
+.if !defined(NOPROFILE)
+ x=`pwd` && cd ${.OBJDIR}/syscalls && ld -r -o ../syscalls.po *.po && cd $$x
+.endif
+ rm -r ${.OBJDIR}/syscalls
+.endif
+
+syscall.o: syscall.S
+.if (${OPSYS} == "FreeBSD")
+ $(CC) -c -x assembler-with-cpp -o syscall.o ${.CURDIR}/syscall.S
+.else
+ cpp ${CPPFLAGS} ${.CURDIR}/syscall.S > syscall.i
+ as syscall.i
+ rm syscall.i
+ mv a.out syscall.o
+.endif
+
+syscall.po: syscall.S
+.if (${OPSYS} == "FreeBSD")
+ $(CC) -c -x assembler-with-cpp -o syscall.po ${.CURDIR}/syscall.S
+.else
+ cpp ${CPPFLAGS} ${.CURDIR}/syscall.S > syscall.i
+ as syscall.i
+ rm syscall.i
+ mv a.out syscall.po
+.endif
+
+MAN2+=
+
+MAN3+=
+
diff --git a/mit-pthreads/pthreads/_exit.c b/mit-pthreads/pthreads/_exit.c
new file mode 100644
index 00000000000..fde795011ce
--- /dev/null
+++ b/mit-pthreads/pthreads/_exit.c
@@ -0,0 +1,80 @@
+/* ==== _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$";
+#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/mit-pthreads/pthreads/cleanup.c b/mit-pthreads/pthreads/cleanup.c
new file mode 100644
index 00000000000..3eb096b8337
--- /dev/null
+++ b/mit-pthreads/pthreads/cleanup.c
@@ -0,0 +1,84 @@
+/* ==== 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$";
+#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/mit-pthreads/pthreads/cond.c b/mit-pthreads/pthreads/cond.c
new file mode 100644
index 00000000000..8dacd0397ce
--- /dev/null
+++ b/mit-pthreads/pthreads/cond.c
@@ -0,0 +1,437 @@
+/* ==== 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 variable functions.
+ *
+ * 1.00 93/10/28 proven
+ * -Started coding this file.
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#endif
+
+#include <pthread.h>
+#include <sys/time.h>
+#include <stdlib.h>
+#include <timers.h>
+#include <errno.h>
+
+#ifndef ETIME
+#define ETIME ETIMEDOUT
+#endif
+
+/* ==========================================================================
+ * pthread_cond_is_debug()
+ *
+ * Check that cond is a debug cond and if so returns entry number into
+ * array of debug condes.
+ */
+static int pthread_cond_debug_count = 0;
+static pthread_cond_t ** pthread_cond_debug_ptrs = NULL;
+static pthread_mutex_t pthread_cond_debug_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+static inline int pthread_cond_is_debug(pthread_cond_t * cond)
+{
+ int i;
+
+ for (i = 0; i < pthread_cond_debug_count; i++) {
+ if (pthread_cond_debug_ptrs[i] == cond) {
+ return(i);
+ }
+ }
+ return(NOTOK);
+}
+/* ==========================================================================
+ * 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, const pthread_condattr_t *cond_attr)
+{
+ enum pthread_condtype type;
+
+ /* 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);
+ }
+ type = cond_attr->c_type;
+ } else {
+ type = COND_TYPE_FAST;
+ }
+
+ switch (type) {
+ case COND_TYPE_FAST:
+ case COND_TYPE_COUNTING_FAST:
+ break;
+ case COND_TYPE_DEBUG:
+ pthread_mutex_lock(&pthread_cond_debug_mutex);
+ if (pthread_cond_is_debug(cond) == NOTOK) {
+ pthread_cond_t ** new;
+
+ if ((new = (pthread_cond_t **)realloc(pthread_cond_debug_ptrs,
+ (pthread_cond_debug_count + 1) * (sizeof(void *)))) == NULL) {
+ pthread_mutex_unlock(&pthread_cond_debug_mutex);
+ return(ENOMEM);
+ }
+ pthread_cond_debug_ptrs = new;
+ pthread_cond_debug_ptrs[pthread_cond_debug_count++] = cond;
+ } else {
+ pthread_mutex_unlock(&pthread_cond_debug_mutex);
+ return(EBUSY);
+ }
+ pthread_mutex_unlock(&pthread_cond_debug_mutex);
+ break;
+ case COND_TYPE_STATIC_FAST:
+ defualt:
+ return(EINVAL);
+ break;
+ }
+
+ /* Set all other paramaters */
+ pthread_queue_init(&cond->c_queue);
+ cond->c_flags |= COND_FLAGS_INITED;
+ cond->c_type = type;
+ return(OK);
+}
+
+/* ==========================================================================
+ * pthread_cond_destroy()
+ */
+int pthread_cond_destroy(pthread_cond_t *cond)
+{
+ int i;
+
+ /* Only check if cond is of type other than fast */
+ switch(cond->c_type) {
+ case COND_TYPE_FAST:
+ case COND_TYPE_COUNTING_FAST:
+ break;
+ case COND_TYPE_DEBUG:
+ if (pthread_queue_get(&(cond->c_queue))) {
+ return(EBUSY);
+ }
+ pthread_mutex_lock(&pthread_cond_debug_mutex);
+ if ((i = pthread_cond_is_debug(cond)) == NOTOK) {
+ pthread_mutex_unlock(&pthread_cond_debug_mutex);
+ return(EINVAL);
+ }
+
+ /* Remove the cond from the list of debug condition variables */
+ pthread_cond_debug_ptrs[i] =
+ pthread_cond_debug_ptrs[--pthread_cond_debug_count];
+ pthread_cond_debug_ptrs[pthread_cond_debug_count] = NULL;
+ pthread_mutex_unlock(&pthread_cond_debug_mutex);
+ 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 = 0;
+ return(OK);
+}
+
+/* ==========================================================================
+ * pthread_cond_wait()
+ */
+int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
+{
+ int rval;
+
+ pthread_sched_prevent();
+ switch (cond->c_type) {
+ case COND_TYPE_DEBUG:
+ pthread_mutex_lock(&pthread_cond_debug_mutex);
+ if (pthread_cond_is_debug(cond) == NOTOK) {
+ pthread_mutex_unlock(&pthread_cond_debug_mutex);
+ pthread_sched_resume();
+ return(EINVAL);
+ }
+ pthread_mutex_unlock(&pthread_cond_debug_mutex);
+
+ /*
+ * Fast condition variables do not check for any error conditions.
+ */
+ case COND_TYPE_FAST:
+ case COND_TYPE_STATIC_FAST:
+ 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;
+ case COND_TYPE_COUNTING_FAST:
+ {
+ int count = mutex->m_data.m_count;
+
+ pthread_queue_enq(&cond->c_queue, pthread_run);
+ 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);
+ break;
+ }
+ default:
+ rval = EINVAL;
+ break;
+ }
+ pthread_sched_resume();
+ return(rval);
+}
+
+/* ==========================================================================
+ * pthread_cond_timedwait()
+ */
+int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
+ const struct timespec * abstime)
+{
+ struct timespec current_time, new_time;
+ int rval = OK;
+
+ pthread_sched_prevent();
+ machdep_gettimeofday(& current_time);
+
+ switch (cond->c_type) {
+ case COND_TYPE_DEBUG:
+ pthread_mutex_lock(&pthread_cond_debug_mutex);
+ if (pthread_cond_is_debug(cond) == NOTOK) {
+ pthread_mutex_unlock(&pthread_cond_debug_mutex);
+ pthread_sched_resume();
+ return(EINVAL);
+ }
+ pthread_mutex_unlock(&pthread_cond_debug_mutex);
+
+ /*
+ * Fast condition variables do not check for any error conditions.
+ */
+ case COND_TYPE_FAST:
+ case COND_TYPE_STATIC_FAST:
+
+ /* Set pthread wakeup time*/
+ pthread_run->wakeup_time = *abstime;
+
+ /* Install us on the sleep queue */
+ sleep_schedule (&current_time, &(pthread_run->wakeup_time));
+
+ pthread_queue_enq(&cond->c_queue, pthread_run);
+ 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) {
+ SET_ERRNO(ETIME);
+ rval = ETIME;
+ }
+
+ CLEAR_PF_DONE_EVENT(pthread_run);
+ pthread_mutex_lock(mutex);
+ return(rval);
+ break;
+ case COND_TYPE_COUNTING_FAST:
+ {
+ int count = mutex->m_data.m_count;
+
+ /* Set pthread wakeup time*/
+ pthread_run->wakeup_time = *abstime;
+
+ /* Install us on the sleep queue */
+ sleep_schedule (&current_time, &(pthread_run->wakeup_time));
+
+ pthread_queue_enq(&cond->c_queue, pthread_run);
+ 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) {
+ SET_ERRNO(ETIME);
+ rval = ETIME;
+ }
+
+ CLEAR_PF_DONE_EVENT(pthread_run);
+ pthread_mutex_lock(mutex);
+ mutex->m_data.m_count = count;
+ return(rval);
+ break;
+ }
+ default:
+ rval = EINVAL;
+ break;
+ }
+ pthread_sched_resume();
+ return(rval);
+}
+
+/* ==========================================================================
+ * pthread_cond_signal()
+ */
+int pthread_cond_signal(pthread_cond_t *cond)
+{
+ struct pthread *pthread;
+ int rval;
+
+ pthread_sched_prevent();
+ switch (cond->c_type) {
+ case COND_TYPE_DEBUG:
+ pthread_mutex_lock(&pthread_cond_debug_mutex);
+ if (pthread_cond_is_debug(cond) == NOTOK) {
+ pthread_mutex_unlock(&pthread_cond_debug_mutex);
+ pthread_sched_resume();
+ return(EINVAL);
+ }
+ pthread_mutex_unlock(&pthread_cond_debug_mutex);
+
+ case COND_TYPE_FAST:
+ case COND_TYPE_STATIC_FAST:
+ if (pthread = pthread_queue_deq(&cond->c_queue)) {
+ if ((SET_PF_DONE_EVENT(pthread)) == OK) {
+ pthread_sched_other_resume(pthread);
+ } else {
+ pthread_sched_resume();
+ }
+ return(OK);
+ }
+ rval = OK;
+ break;
+ default:
+ rval = EINVAL;
+ break;
+ }
+ pthread_sched_resume();
+ return(rval);
+}
+
+/* ==========================================================================
+ * pthread_cond_broadcast()
+ *
+ * Not much different then the above routine.
+ */
+int pthread_cond_broadcast(pthread_cond_t *cond)
+{
+ struct pthread * pthread, * high_pthread, * low_pthread;
+ int rval;
+
+ pthread_sched_prevent();
+ switch (cond->c_type) {
+ case COND_TYPE_DEBUG:
+ pthread_mutex_lock(&pthread_cond_debug_mutex);
+ if (pthread_cond_is_debug(cond) == NOTOK) {
+ pthread_mutex_unlock(&pthread_cond_debug_mutex);
+ pthread_sched_resume();
+ return(EINVAL);
+ }
+ pthread_mutex_unlock(&pthread_cond_debug_mutex);
+
+ case COND_TYPE_FAST:
+ case COND_TYPE_STATIC_FAST:
+ if (pthread = pthread_queue_deq(&cond->c_queue)) {
+ pthread->state = PS_RUNNING;
+ high_pthread = pthread;
+
+ while (pthread = pthread_queue_deq(&cond->c_queue)) {
+ if (pthread->pthread_priority >
+ high_pthread->pthread_priority) {
+ low_pthread = high_pthread;
+ high_pthread = pthread;
+ } else {
+ low_pthread = pthread;
+ }
+ if ((SET_PF_DONE_EVENT(low_pthread)) == OK) {
+ pthread_prio_queue_enq(pthread_current_prio_queue,
+ low_pthread);
+ low_pthread->state = PS_RUNNING;
+ }
+ }
+ if ((SET_PF_DONE_EVENT(high_pthread)) == OK) {
+ pthread_sched_other_resume(high_pthread);
+ } else {
+ pthread_sched_resume();
+ }
+ return(OK);
+ }
+ rval = OK;
+ break;
+ default:
+ rval = EINVAL;
+ break;
+ }
+ pthread_sched_resume();
+ return(rval);
+}
+
diff --git a/mit-pthreads/pthreads/condattr.c b/mit-pthreads/pthreads/condattr.c
new file mode 100644
index 00000000000..ac010bdf4b1
--- /dev/null
+++ b/mit-pthreads/pthreads/condattr.c
@@ -0,0 +1,90 @@
+/* ==== 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$";
+#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/mit-pthreads/pthreads/dump_state.c b/mit-pthreads/pthreads/dump_state.c
new file mode 100644
index 00000000000..3d9840bad64
--- /dev/null
+++ b/mit-pthreads/pthreads/dump_state.c
@@ -0,0 +1,88 @@
+/* ==== 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$
+ *
+ * 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/mit-pthreads/pthreads/errno.c b/mit-pthreads/pthreads/errno.c
new file mode 100644
index 00000000000..bc680235424
--- /dev/null
+++ b/mit-pthreads/pthreads/errno.c
@@ -0,0 +1,53 @@
+/* ==== 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$";
+#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/mit-pthreads/pthreads/fd.c b/mit-pthreads/pthreads/fd.c
new file mode 100644
index 00000000000..3eb59c11bd1
--- /dev/null
+++ b/mit-pthreads/pthreads/fd.c
@@ -0,0 +1,1083 @@
+/* ==== 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$";
+#endif
+
+#include "config.h"
+#include <pthread.h>
+#include <stdlib.h>
+#include <string.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)
+{
+ off_t 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/mit-pthreads/pthreads/fd_kern.c b/mit-pthreads/pthreads/fd_kern.c
new file mode 100644
index 00000000000..f4ada4e4fd4
--- /dev/null
+++ b/mit-pthreads/pthreads/fd_kern.c
@@ -0,0 +1,1950 @@
+/* ==== 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$";
+#endif
+
+#include "config.h"
+#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>
+
+#if defined (HAVE_SYSCALL_SENDTO) && !defined (HAVE_SYSCALL_SEND)
+
+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);
+}
+
+#endif
+
+#if defined (HAVE_SYSCALL_RECVFROM) && !defined (HAVE_SYSCALL_RECV)
+
+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);
+}
+
+#endif
+
+/* ==========================================================================
+ * 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;
+ extern off_t machdep_sys_lseek(int, off_t, int);
+ 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);
+}
+
+#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()
+ */
+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.
+ * ======================================================================= */
+
+#if defined (HAVE_SYSCALL_SOCKET) || defined (HAVE_SYSCALL_SOCKETCALL)
+
+/* ==========================================================================
+ * 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);
+}
+
+#endif
+
+#if defined (HAVE_SYSCALL_BIND) || defined (HAVE_SYSCALL_SOCKETCALL)
+
+/* ==========================================================================
+ * bind()
+ */
+#ifdef _OS_HAS_SOCKLEN_T
+int bind(int fd, const struct sockaddr *name, socklen_t namelen)
+#else
+int bind(int fd, const struct sockaddr *name, int namelen)
+#endif
+{
+ /* 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);
+}
+
+#endif
+
+#if defined (HAVE_SYSCALL_CONNECT) || defined (HAVE_SYSCALL_SOCKETCALL)
+
+/* ==========================================================================
+ * connect()
+ */
+#ifdef _OS_HAS_SOCKLEN_T
+int connect(int fd, const struct sockaddr *name, socklen_t namelen)
+#else
+int connect(int fd, const struct sockaddr *name, int namelen)
+#endif
+{
+ 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);
+}
+
+#endif
+
+#if defined (HAVE_SYSCALL_ACCEPT) || defined (HAVE_SYSCALL_SOCKETCALL)
+
+/* ==========================================================================
+ * accept()
+ */
+#ifdef _OS_HAS_SOCKLEN_T
+int accept(int fd, struct sockaddr *name, socklen_t *namelen)
+#else
+int accept(int fd, struct sockaddr *name, int *namelen)
+#endif
+{
+ 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);
+}
+
+#endif
+
+#if defined (HAVE_SYSCALL_LISTEN) || defined (HAVE_SYSCALL_SOCKETCALL)
+
+/* ==========================================================================
+ * 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);
+}
+
+#endif
+
+#if defined (HAVE_SYSCALL_SEND) || defined (HAVE_SYSCALL_SOCKETCALL)
+
+/* ==========================================================================
+ * 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
+
+#if defined (HAVE_SYSCALL_SENDTO) || defined (HAVE_SYSCALL_SOCKETCALL)
+
+/* ==========================================================================
+ * 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()
+ */
+#ifdef _OS_HAS_SOCKLEN_T
+ssize_t sendto(int fd, const void * msg, size_t len, int flags,
+ const struct sockaddr *to, socklen_t to_len)
+#else
+ssize_t sendto(int fd, const void * msg, size_t len, int flags,
+ const struct sockaddr *to, int to_len)
+#endif
+{
+ return(sendto_timedwait(fd, msg, len, flags, to, to_len, NULL));
+}
+
+#endif
+
+#if defined (HAVE_SYSCALL_SENDMSG) || defined (HAVE_SYSCALL_SOCKETCALL)
+
+/* ==========================================================================
+ * 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));
+}
+
+#endif
+
+#if defined (HAVE_SYSCALL_RECV) || defined (HAVE_SYSCALL_SOCKETCALL)
+
+/* ==========================================================================
+ * 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
+
+#if defined (HAVE_SYSCALL_RECVFROM) || defined (HAVE_SYSCALL_SOCKETCALL)
+
+/* ==========================================================================
+ * 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()
+ */
+#ifdef _OS_HAS_SOCKLEN_T
+ssize_t recvfrom(int fd, void * buf, size_t len, int flags,
+ struct sockaddr * from, socklen_t * from_len)
+#else
+ssize_t recvfrom(int fd, void * buf, size_t len, int flags,
+ struct sockaddr * from, int * from_len)
+#endif
+{
+ return(recvfrom_timedwait(fd, buf, len, flags, from, from_len, NULL));
+}
+
+#endif
+
+#if defined (HAVE_SYSCALL_RECVMSG) || defined (HAVE_SYSCALL_SOCKETCALL)
+
+/* ==========================================================================
+ * 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));
+}
+
+#endif
+
+#if defined (HAVE_SYSCALL_SHUTDOWN) || defined (HAVE_SYSCALL_SOCKETCALL)
+
+/* ==========================================================================
+ * 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);
+}
+
+#endif
+
+#if defined (HAVE_SYSCALL_SETSOCKOPT) || defined (HAVE_SYSCALL_SOCKETCALL)
+
+/* ==========================================================================
+ * setsockopt()
+ */
+#ifdef _OS_HAS_SOCKLEN_T
+int setsockopt(int fd, int level, int optname, const void * optval, socklen_t optlen)
+#else
+int setsockopt(int fd, int level, int optname, const void * optval, int optlen)
+#endif
+{
+ 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;
+}
+
+#endif
+
+#if defined (HAVE_SYSCALL_GETSOCKOPT) || defined (HAVE_SYSCALL_SOCKETCALL)
+
+/* ==========================================================================
+ * getsockopt()
+ */
+#ifdef _OS_HAS_SOCKLEN_T
+int getsockopt(int fd, int level, int optname, void * optval, socklen_t * optlen)
+#else
+int getsockopt(int fd, int level, int optname, void * optval, int * optlen)
+#endif
+{
+ 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;
+}
+
+#endif
+
+#if defined (HAVE_SYSCALL_GETSOCKOPT) || defined (HAVE_SYSCALL_SOCKETCALL)
+
+/* ==========================================================================
+ * getsockname()
+ */
+#ifdef _OS_HAS_SOCKLEN_T
+int getsockname(int fd, struct sockaddr * name, socklen_t * naddrlen)
+#else
+int getsockname(int fd, struct sockaddr * name, int * naddrlen)
+#endif
+{
+ 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
+
+#if defined (HAVE_SYSCALL_GETPEERNAME) || defined (HAVE_SYSCALL_SOCKETCALL)
+
+/* ==========================================================================
+ * getpeername()
+ */
+#ifdef _OS_HAS_SOCKLEN_T
+int getpeername(int fd, struct sockaddr * peer, socklen_t * paddrlen)
+#else
+int getpeername(int fd, struct sockaddr * peer, int * paddrlen)
+#endif
+{
+ 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;
+}
+
+#endif
+
+#if defined (HAVE_SYSCALL_SOCKETPAIR) || defined (HAVE_SYSCALL_SOCKETCALL)
+
+/* ==========================================================================
+ * 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);
+}
+
+#endif
diff --git a/mit-pthreads/pthreads/fd_pipe.c b/mit-pthreads/pthreads/fd_pipe.c
new file mode 100644
index 00000000000..e8bc20857ed
--- /dev/null
+++ b/mit-pthreads/pthreads/fd_pipe.c
@@ -0,0 +1,257 @@
+/* ==== 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$";
+#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>
+#include <string.h>
+#include <stdlib.h>
+
+#ifndef MIN
+#define MIN(a,b) ((a)<(b)?(a):(b))
+#endif
+
+/* ==========================================================================
+ * The pipe lock is never unlocked until all pthreads waiting are done with it
+ * read()
+ */
+pthread_ssize_t __pipe_read(union fd_data fd_data, int flags, void *buf,
+ size_t nbytes, struct timespec * timeout)
+{
+ struct __pipe *fd = (struct __pipe *)fd_data.ptr;
+ struct pthread * pthread;
+ int ret = 0;
+
+ if (flags & O_ACCMODE) { return(NOTOK); }
+
+ /* If there is nothing to read, go to sleep */
+ if (fd->count == 0) {
+ if (flags == WR_CLOSED) {
+ return(0);
+ }
+
+ pthread_sched_prevent();
+
+ /* queue pthread for a FDR_WAIT */
+ pthread_run->next = NULL;
+ fd->wait = pthread_run;
+
+ pthread_resched_resume(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;
+ }
+
+ if (pthread = fd->wait) {
+ fd->wait = NULL;
+ pthread_sched_prevent();
+ pthread_sched_other_resume(pthread);
+ }
+ }
+ 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.
+ */
+pthread_ssize_t __pipe_write(union fd_data fd_data, int flags, const void *buf,
+ size_t nbytes, struct timespec * timeout) {
+ struct __pipe *fd = (struct __pipe *)fd_data.ptr;
+ struct pthread * pthread;
+ int ret, count;
+
+ if (!(flags & O_ACCMODE)) { return(NOTOK); }
+
+ while (fd->flags != RD_CLOSED) {
+ if (pthread = fd->wait) {
+
+ pthread_sched_prevent();
+
+ /* 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;
+ fd->wait = NULL;
+
+ /* Wake up waiting pthread */
+ pthread_sched_other_resume(pthread);
+ }
+
+ 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) {
+ pthread_sched_prevent();
+ fd->wait = pthread_run;
+ pthread_resched_resume(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)
+{
+ struct pthread * pthread;
+
+ if (!(fd->flags)) {
+ if (pthread = fd->wait) {
+ if (flags & O_ACCMODE) {
+ fd->count = 0;
+ fd->wait = NULL;
+ fd->flags |= WR_CLOSED;
+ pthread_sched_prevent();
+ pthread_resched_resume(pthread);
+ } else {
+ /* Should send a signal */
+ fd->flags |= RD_CLOSED;
+ }
+ }
+ } else {
+ free(fd);
+ return(OK);
+ }
+}
+
+/* ==========================================================================
+ * For fcntl() which isn't implemented yet
+ * __pipe_enosys()
+ */
+static int __pipe_enosys()
+{
+ SET_ERRNO(ENOSYS);
+ return(NOTOK);
+}
+
+/* ==========================================================================
+ * For writev() and readv() which aren't implemented yet
+ * __pipe_enosys_v()
+ */
+static int __pipe_enosys_v(union fd_data fd, int flags,
+ const struct iovec *vec, int nvec,
+ struct timespec *timeout)
+{
+ SET_ERRNO(ENOSYS);
+ return(NOTOK);
+}
+
+/* ==========================================================================
+ * For lseek() which isn't implemented yet
+ * __pipe_enosys_o()
+ */
+static off_t __pipe_enosys_o()
+{
+ SET_ERRNO(ENOSYS);
+ return(NOTOK);
+}
+
+/*
+ * File descriptor operations
+ */
+struct fd_ops fd_ops[] = {
+{ __pipe_write, __pipe_read, __pipe_close, __pipe_enosys,
+ __pipe_enosys_v, __pipe_enosys_v, __pipe_enosys_o, 0 },
+};
+
+/* ==========================================================================
+ * 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/mit-pthreads/pthreads/fd_sysv.c b/mit-pthreads/pthreads/fd_sysv.c
new file mode 100644
index 00000000000..6dc01a49aa4
--- /dev/null
+++ b/mit-pthreads/pthreads/fd_sysv.c
@@ -0,0 +1,897 @@
+/* ==== 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$";
+#endif
+
+#include <config.h>
+#include <pthread.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/mit-pthreads/pthreads/file.c b/mit-pthreads/pthreads/file.c
new file mode 100644
index 00000000000..4b8a8aad6db
--- /dev/null
+++ b/mit-pthreads/pthreads/file.c
@@ -0,0 +1,129 @@
+/* ==== 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$";
+#endif
+
+#include <pthread.h>
+#include <stdio.h>
+
+/* ==========================================================================
+ * flockfile()
+ */
+void flockfile(FILE *fp)
+{
+ pthread_mutex_t *mutex;
+ int fd, flags;
+
+ if ((fd = fileno(fp)) >= 0) {
+ pthread_mutex_lock(mutex = &(fd_table[fd]->mutex));
+
+ if (fp->_flags & __SRW) {
+ flags = FD_READ | FD_WRITE;
+ } else {
+ if (fp->_flags & __SWR) {
+ flags = FD_WRITE;
+ } else {
+ flags = FD_READ;
+ }
+ }
+
+ /* This might fail but POSIX doesn't give a damn. */
+ fd_basic_lock(fd, flags, mutex, NULL);
+ pthread_mutex_unlock(mutex);
+ }
+}
+
+/* ==========================================================================
+ * ftrylockfile()
+ */
+int ftrylockfile(FILE *fp)
+{
+ pthread_mutex_t *mutex;
+ int fd, flags;
+
+ if ((fd = fileno(fp)) >= 0) {
+ pthread_mutex_lock(mutex = &(fd_table[fd]->mutex));
+
+ if (fp->_flags & __SRW) {
+ flags = FD_READ | FD_WRITE;
+ } else {
+ if (fp->_flags & __SWR) {
+ flags = FD_WRITE;
+ } else {
+ flags = FD_READ;
+ }
+ }
+ if (!(fd_table[fd]->r_owner && fd_table[fd]->w_owner)) {
+ fd_basic_lock(fd, flags, mutex, NULL);
+ fd = OK;
+ } else {
+ fd = NOTOK;
+ }
+ pthread_mutex_unlock(mutex);
+ } else {
+ fd = OK;
+ }
+ return(fd);
+}
+
+/* ==========================================================================
+ * funlockfile()
+ */
+void funlockfile(FILE *fp)
+{
+ pthread_mutex_t *mutex;
+ int fd, flags;
+
+ if ((fd = fileno(fp)) >= 0) {
+ pthread_mutex_lock(mutex = &(fd_table[fd]->mutex));
+
+ if (fp->_flags & __SRW) {
+ flags = FD_READ | FD_WRITE;
+ } else {
+ if (fp->_flags & __SWR) {
+ flags = FD_WRITE;
+ } else {
+ flags = FD_READ;
+ }
+ }
+ fd_basic_unlock(fd, flags);
+ pthread_mutex_unlock(mutex);
+ }
+}
+
diff --git a/mit-pthreads/pthreads/globals.c b/mit-pthreads/pthreads/globals.c
new file mode 100644
index 00000000000..921588fb220
--- /dev/null
+++ b/mit-pthreads/pthreads/globals.c
@@ -0,0 +1,85 @@
+/* ==== 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$";
+#endif
+
+#include <pthread.h>
+
+/*
+ * Initial thread, running thread, and top of link list of all threads.
+ */
+struct pthread *pthread_run=NULL;
+struct pthread *pthread_initial=NULL;
+struct pthread *pthread_link_list=NULL;
+
+sigset_t * uthread_sigmask; /* Current process signal mask */
+
+/*
+ * Dead thread queue, and threads elligible to be alloced queue.
+ */
+struct pthread_queue pthread_dead_queue;
+struct pthread_queue pthread_alloc_queue;
+
+/*
+ * Queue for all threads elidgeable to run this scheduling round.
+ */
+struct pthread_prio_queue * pthread_current_prio_queue=NULL;
+
+/*
+ * default thread attributes
+ */
+pthread_attr_t pthread_attr_default = { SCHED_RR, PTHREAD_DEFAULT_PRIORITY,
+ PTHREAD_CREATE_JOINABLE, NULL, NULL, NULL, PTHREAD_STACK_DEFAULT };
+
+/*
+ * File table information
+ */
+struct fd_table_entry **fd_table=NULL;
+
+/*
+ * A we a fork()ed process
+ */
+volatile int fork_lock = 0;
+volatile int pthread_kernel_lock=0;
+
+/*
+ * The page size, as returned by getpagesize()
+ */
+size_t pthread_pagesize=0;
+
diff --git a/mit-pthreads/pthreads/info.c b/mit-pthreads/pthreads/info.c
new file mode 100644
index 00000000000..2b9722ba291
--- /dev/null
+++ b/mit-pthreads/pthreads/info.c
@@ -0,0 +1,77 @@
+/* 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/mit-pthreads/pthreads/init.cc b/mit-pthreads/pthreads/init.cc
new file mode 100644
index 00000000000..24a131a60a5
--- /dev/null
+++ b/mit-pthreads/pthreads/init.cc
@@ -0,0 +1,9 @@
+
+/*
+ * 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/mit-pthreads/pthreads/malloc.c b/mit-pthreads/pthreads/malloc.c
new file mode 100644
index 00000000000..76fe03824ac
--- /dev/null
+++ b/mit-pthreads/pthreads/malloc.c
@@ -0,0 +1,383 @@
+/* ==== 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$";
+#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.
+ */
+#ifdef __alpha
+#define _MOST_RESTRICTIVE_ALIGNMENT_TYPE char*
+#else
+#define _MOST_RESTRICTIVE_ALIGNMENT_TYPE double
+#endif /* __alpha */
+union overhead {
+ _MOST_RESTRICTIVE_ALIGNMENT_TYPE __alignment_pad0;
+ 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 */
+ size_t 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];
+#ifndef hpux
+extern char *sbrk();
+#endif
+
+static size_t pagesz; /* page size */
+static int pagebucket; /* page size bucket */
+static pthread_mutex_t malloc_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+#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 size_t sz; /* size of desired block */
+ size_t amt; /* amount to allocate */
+ size_t 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 = 1L << (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 (op == (union overhead *) -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)
+{
+ pthread_mutex_t *mutex;
+ union overhead *op;
+ size_t amt;
+ size_t bucket, n;
+
+ mutex = &malloc_mutex;
+ pthread_mutex_lock(mutex);
+ /*
+ * First time malloc is called, setup page size and
+ * align break pointer so all data will be page aligned.
+ */
+ if (pagesz == 0) {
+ size_t x;
+ pagesz = n = getpagesize();
+ op = (union overhead *)sbrk(0);
+ x = sizeof (*op) - ((long)op & (n - 1));
+ if (n < x)
+ n = n + pagesz - x;
+ 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) {
+ 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) {
+ pthread_mutex_unlock(mutex);
+ return (NULL);
+ }
+ bucket++;
+ }
+ ASSERT (bucket < NBUCKETS);
+ /*
+ * 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) {
+ pthread_mutex_unlock(mutex);
+ 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
+ pthread_mutex_unlock(mutex);
+ return ((char *)(op + 1));
+}
+
+/* ==========================================================================
+ * free()
+ */
+void free(void *cp)
+{
+ pthread_mutex_t *mutex;
+ union overhead *op;
+ int size;
+
+ mutex = &malloc_mutex;
+ pthread_mutex_lock(mutex);
+ if (cp == NULL) {
+ pthread_mutex_unlock(mutex);
+ 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) {
+ pthread_mutex_unlock(mutex);
+ 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;
+
+ pthread_mutex_unlock(mutex);
+}
+
+/* ==========================================================================
+ * realloc()
+ *
+ * Storage compaction is no longer supported, fix program and try again.
+ */
+void *realloc(void *cp, size_t nbytes)
+{
+ pthread_mutex_t *mutex;
+ size_t onb;
+ size_t i;
+ 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);
+ }
+
+ mutex = &malloc_mutex;
+ pthread_mutex_lock(mutex);
+ onb = 1L << (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 = 1L << (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
+ pthread_mutex_unlock(mutex);
+ return(cp);
+ }
+ pthread_mutex_unlock(mutex);
+
+ if ((res = malloc(nbytes)) == NULL) {
+ free(cp);
+ return (NULL);
+ }
+
+ memcpy(res, cp, (nbytes < onb) ? nbytes : onb);
+ 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 --git a/mit-pthreads/pthreads/mutex.c b/mit-pthreads/pthreads/mutex.c
new file mode 100644
index 00000000000..1a2ca6fa1c1
--- /dev/null
+++ b/mit-pthreads/pthreads/mutex.c
@@ -0,0 +1,371 @@
+/* ==== 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$";
+#endif
+
+#include <pthread.h>
+#include <stdlib.h>
+#include <errno.h>
+
+/* ==========================================================================
+ * pthread_mutex_is_debug()
+ *
+ * Check that mutex is a debug mutex and if so returns entry number into
+ * array of debug mutexes.
+ */
+static int pthread_mutex_debug_count = 0;
+static pthread_mutex_t ** pthread_mutex_debug_ptrs = NULL;
+
+static inline int pthread_mutex_is_debug(pthread_mutex_t * mutex)
+{
+ int i;
+
+ for (i = 0; i < pthread_mutex_debug_count; i++) {
+ if (pthread_mutex_debug_ptrs[i] == mutex) {
+ return(i);
+ }
+ }
+ return(NOTOK);
+}
+
+/* ==========================================================================
+ * 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,
+ const pthread_mutexattr_t *mutex_attr)
+{
+ enum pthread_mutextype type;
+
+ /* 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);
+ }
+ type = mutex_attr->m_type;
+ } else {
+ type = MUTEX_TYPE_FAST;
+ }
+ mutex->m_flags = 0;
+
+ pthread_sched_prevent();
+
+ switch(type) {
+ case MUTEX_TYPE_FAST:
+ break;
+ case MUTEX_TYPE_STATIC_FAST:
+ pthread_sched_resume();
+ return(EINVAL);
+ break;
+ case MUTEX_TYPE_COUNTING_FAST:
+ mutex->m_data.m_count = 0;
+ break;
+ case MUTEX_TYPE_DEBUG:
+ if (pthread_mutex_is_debug(mutex) == NOTOK) {
+ pthread_mutex_t ** new;
+
+ if ((new = (pthread_mutex_t **)realloc(pthread_mutex_debug_ptrs,
+ (pthread_mutex_debug_count + 1) * (sizeof(void *)))) == NULL) {
+ pthread_sched_resume();
+ return(ENOMEM);
+ }
+ pthread_mutex_debug_ptrs = new;
+ pthread_mutex_debug_ptrs[pthread_mutex_debug_count++] = mutex;
+ } else {
+ pthread_sched_resume();
+ return(EBUSY);
+ }
+ break;
+ default:
+ pthread_sched_resume();
+ return(EINVAL);
+ break;
+ }
+ /* Set all other paramaters */
+ pthread_queue_init(&mutex->m_queue);
+ mutex->m_flags |= MUTEX_FLAGS_INITED;
+ mutex->m_owner = NULL;
+ mutex->m_type = type;
+
+ pthread_sched_resume();
+ return(OK);
+}
+
+/* ==========================================================================
+ * pthread_mutex_destroy()
+ */
+int pthread_mutex_destroy(pthread_mutex_t *mutex)
+{
+ int i;
+
+ pthread_sched_prevent();
+
+ /* Only check if mutex is of type other than fast */
+ switch(mutex->m_type) {
+ case MUTEX_TYPE_FAST:
+ break;
+ case MUTEX_TYPE_STATIC_FAST:
+ pthread_sched_resume();
+ return(EINVAL);
+ break;
+ case MUTEX_TYPE_COUNTING_FAST:
+ mutex->m_data.m_count = 0;
+ break;
+ case MUTEX_TYPE_DEBUG:
+ if ((i = pthread_mutex_is_debug(mutex)) == NOTOK) {
+ pthread_sched_resume();
+ return(EINVAL);
+ }
+ if (mutex->m_owner) {
+ pthread_sched_resume();
+ return(EBUSY);
+ }
+
+ /* Remove the mutex from the list of debug mutexes */
+ pthread_mutex_debug_ptrs[i] =
+ pthread_mutex_debug_ptrs[--pthread_mutex_debug_count];
+ pthread_mutex_debug_ptrs[pthread_mutex_debug_count] = NULL;
+ break;
+ default:
+ pthread_sched_resume();
+ return(EINVAL);
+ break;
+ }
+
+ /* Cleanup mutex, others might want to use it. */
+ pthread_queue_init(&mutex->m_queue);
+ mutex->m_owner = NULL;
+ mutex->m_flags = 0;
+
+ pthread_sched_resume();
+ return(OK);
+}
+
+/* ==========================================================================
+ * pthread_mutex_trylock()
+ */
+int pthread_mutex_trylock(pthread_mutex_t *mutex)
+{
+ int rval;
+
+ pthread_sched_prevent();
+ 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;
+ case MUTEX_TYPE_COUNTING_FAST:
+ if (mutex->m_owner) {
+ if (mutex->m_owner == pthread_run) {
+ mutex->m_data.m_count++;
+ rval = OK;
+ } else {
+ rval = EBUSY;
+ }
+ } else {
+ mutex->m_owner = pthread_run;
+ rval = OK;
+ }
+ break;
+ case MUTEX_TYPE_DEBUG:
+ if (pthread_mutex_is_debug(mutex) != NOTOK) {
+ if (!mutex->m_owner) {
+ mutex->m_owner = pthread_run;
+ rval = OK;
+ } else {
+ rval = EBUSY;
+ }
+ } else {
+ rval = EINVAL;
+ }
+ break;
+ default:
+ rval = EINVAL;
+ break;
+ }
+
+ pthread_sched_resume();
+ return(rval);
+}
+
+/* ==========================================================================
+ * pthread_mutex_lock()
+ */
+int pthread_mutex_lock(pthread_mutex_t *mutex)
+{
+ int rval;
+
+ pthread_sched_prevent();
+ 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) {
+ pthread_queue_enq(&mutex->m_queue, pthread_run);
+
+ /* Reschedule will unlock scheduler */
+ pthread_resched_resume(PS_MUTEX_WAIT);
+ return(OK);
+ }
+ mutex->m_owner = pthread_run;
+ rval = OK;
+ break;
+ case MUTEX_TYPE_COUNTING_FAST:
+ if (mutex->m_owner) {
+ if (mutex->m_owner != pthread_run) {
+ pthread_queue_enq(&mutex->m_queue, pthread_run);
+
+ /* Reschedule will unlock scheduler */
+ pthread_resched_resume(PS_MUTEX_WAIT);
+ return(OK);
+ } else {
+ mutex->m_data.m_count++;
+ }
+ } else {
+ mutex->m_owner = pthread_run;
+ }
+ rval = OK;
+ break;
+ case MUTEX_TYPE_DEBUG:
+ if (pthread_mutex_is_debug(mutex) != NOTOK) {
+ if (mutex->m_owner) {
+ if (mutex->m_owner != pthread_run) {
+ pthread_queue_enq(&mutex->m_queue, pthread_run);
+
+ /* Reschedule will unlock pthread_run */
+ pthread_resched_resume(PS_MUTEX_WAIT);
+
+ if (mutex->m_owner != pthread_run) {
+ PANIC();
+ }
+ return(OK);
+ }
+ rval = EDEADLK;
+ break;
+ }
+ mutex->m_owner = pthread_run;
+ rval = OK;
+ break;
+ }
+ rval = EINVAL;
+ break;
+ default:
+ rval = EINVAL;
+ break;
+ }
+
+ pthread_sched_resume();
+ return(rval);
+}
+
+/* ==========================================================================
+ * pthread_mutex_unlock()
+ */
+int pthread_mutex_unlock(pthread_mutex_t *mutex)
+{
+ struct pthread *pthread;
+ int rval;
+
+ pthread_sched_prevent();
+
+ 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 = pthread_queue_deq(&mutex->m_queue)) {
+
+ /* Reschedule will unlock scheduler */
+ pthread_sched_other_resume(mutex->m_owner);
+ return(OK);
+ }
+ rval = OK;
+ break;
+ case MUTEX_TYPE_COUNTING_FAST:
+ if (mutex->m_data.m_count) {
+ mutex->m_data.m_count--;
+ rval = OK;
+ break;
+ }
+ if (mutex->m_owner = pthread_queue_deq(&mutex->m_queue)) {
+
+ /* Reschedule will unlock scheduler */
+ pthread_sched_other_resume(mutex->m_owner);
+ return(OK);
+ }
+ rval = OK;
+ break;
+ case MUTEX_TYPE_DEBUG:
+ if (pthread_mutex_is_debug(mutex) != NOTOK) {
+ if (mutex->m_owner == pthread_run) {
+ if (mutex->m_owner = pthread_queue_deq(&mutex->m_queue)) {
+
+ /* Reschedule will unlock scheduler */
+ pthread_sched_other_resume(mutex->m_owner);
+ return(OK);
+ }
+ rval = OK;
+ } else {
+ rval = EPERM;
+ }
+ } else {
+ rval = EINVAL;
+ }
+ break;
+ default:
+ rval = EINVAL;
+ break;
+ }
+ pthread_sched_resume();
+ return(rval);
+}
diff --git a/mit-pthreads/pthreads/mutexattr.c b/mit-pthreads/pthreads/mutexattr.c
new file mode 100644
index 00000000000..d045b5041a0
--- /dev/null
+++ b/mit-pthreads/pthreads/mutexattr.c
@@ -0,0 +1,90 @@
+/* ==== 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$";
+#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/mit-pthreads/pthreads/panic.c b/mit-pthreads/pthreads/panic.c
new file mode 100644
index 00000000000..6b963acd651
--- /dev/null
+++ b/mit-pthreads/pthreads/panic.c
@@ -0,0 +1,58 @@
+/* ==== 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/mit-pthreads/pthreads/prio_queue.c b/mit-pthreads/pthreads/prio_queue.c
new file mode 100644
index 00000000000..d976f9cd68f
--- /dev/null
+++ b/mit-pthreads/pthreads/prio_queue.c
@@ -0,0 +1,176 @@
+/* ==== 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$";
+#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/mit-pthreads/pthreads/process.c b/mit-pthreads/pthreads/process.c
new file mode 100644
index 00000000000..9b3abb3384b
--- /dev/null
+++ b/mit-pthreads/pthreads/process.c
@@ -0,0 +1,208 @@
+/* ==== 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$";
+#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/mit-pthreads/pthreads/pthread.c b/mit-pthreads/pthreads/pthread.c
new file mode 100644
index 00000000000..6f7e2d53980
--- /dev/null
+++ b/mit-pthreads/pthreads/pthread.c
@@ -0,0 +1,293 @@
+/* ==== 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$";
+#endif
+
+#include <pthread.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <errno.h>
+#include <string.h>
+#include <sched.h>
+
+/* ==========================================================================
+ * sched_yield()
+ */
+int sched_yield()
+{
+ sig_handler_fake(SIGVTALRM);
+ return(OK);
+}
+
+/* ==========================================================================
+ * 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()
+ */
+extern void pthread_cleanupspecific(void);
+
+void pthread_exit(void *status)
+{
+ pthread_t pthread;
+
+ /* Save return value */
+ pthread_run->ret = status;
+
+ /* First execute all cleanup handlers */
+ while (pthread_run->cleanup) {
+ pthread_cleanup_pop(1);
+ }
+
+ /* Don't forget the cleanup attr */
+ if (pthread_run->attr.cleanup_attr) {
+ pthread_run->attr.cleanup_attr(pthread_run->attr.arg_attr);
+ }
+
+ /* Next run thread-specific data desctructors */
+ if (pthread_run->specific_data) {
+ pthread_cleanupspecific();
+ }
+
+ pthread_sched_prevent();
+
+ if (!(pthread_run->attr.flags & PTHREAD_DETACHED)) {
+ /*
+ * Are there any threads joined to this one,
+ * if so wake them and let them detach this thread.
+ */
+ while (pthread = pthread_queue_deq(&(pthread_run->join_queue))) {
+ pthread_prio_queue_enq(pthread_current_prio_queue, pthread);
+ pthread->state = PS_RUNNING;
+ }
+ pthread_queue_enq(&pthread_dead_queue, pthread_run);
+ pthread_resched_resume(PS_DEAD);
+ } else {
+ pthread_queue_enq(&pthread_alloc_queue, pthread_run);
+ pthread_resched_resume(PS_UNALLOCED);
+ }
+
+ /* This thread will never run again */
+ PANIC();
+
+}
+
+/*----------------------------------------------------------------------
+ * 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()
+ */
+static inline void __pthread_free(pthread_t new_thread)
+{
+ pthread_sched_prevent();
+ new_thread->state = PS_UNALLOCED;
+ new_thread->attr.stacksize_attr = 0;
+ new_thread->attr.stackaddr_attr = NULL;
+ pthread_queue_enq(&pthread_alloc_queue, new_thread);
+ pthread_sched_resume();
+}
+/* ==========================================================================
+ * __pthread_alloc()
+ */
+/* static inline pthread_t __pthread_alloc(const pthread_attr_t *attr) */
+static pthread_t __pthread_alloc(const pthread_attr_t *attr)
+{
+ pthread_t thread;
+ void * stack;
+ void * old;
+
+ pthread_sched_prevent();
+ thread = pthread_queue_deq(&pthread_alloc_queue);
+ pthread_sched_resume();
+
+ if (thread) {
+ if (stack = attr->stackaddr_attr) {
+ __machdep_stack_repl(&(thread->machdep_data), stack);
+ } else {
+ if ((__machdep_stack_get(&(thread->machdep_data)) == NULL)
+ || (attr->stacksize_attr > thread->attr.stacksize_attr)) {
+ if (stack = __machdep_stack_alloc(attr->stacksize_attr)) {
+ __machdep_stack_repl(&(thread->machdep_data), stack);
+ } else {
+ __pthread_free(thread);
+ thread = NULL;
+ }
+ }
+ }
+ } else {
+ /* We should probable allocate several for efficiency */
+ if (thread = (pthread_t)malloc(sizeof(struct pthread))) {
+ /* Link new thread into list of all threads */
+
+ pthread_sched_prevent();
+ thread->state = PS_UNALLOCED;
+ thread->pll = pthread_link_list;
+ pthread_link_list = thread;
+ pthread_sched_resume();
+
+ if ((stack = attr->stackaddr_attr) ||
+ (stack = __machdep_stack_alloc(attr->stacksize_attr))) {
+ __machdep_stack_set(&(thread->machdep_data), stack);
+ } else {
+ __machdep_stack_set(&(thread->machdep_data), NULL);
+ __pthread_free(thread);
+ thread = NULL;
+ }
+ }
+ }
+ return(thread);
+}
+
+/* ==========================================================================
+ * 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)
+{
+ pthread_t new_thread;
+ int nsec = 100000000;
+ int retval = OK;
+
+ if (! attr)
+ attr = &pthread_attr_default;
+
+ if (new_thread = __pthread_alloc(attr)) {
+
+ __machdep_pthread_create(&(new_thread->machdep_data),
+ start_routine, arg, attr->stacksize_attr, nsec, 0);
+
+ memcpy(&new_thread->attr, attr, sizeof(pthread_attr_t));
+ if (new_thread->attr.flags & PTHREAD_INHERIT_SCHED) {
+ new_thread->pthread_priority = pthread_run->pthread_priority;
+ new_thread->attr.sched_priority = pthread_run->pthread_priority;
+ new_thread->attr.schedparam_policy =
+ pthread_run->attr.schedparam_policy;
+ } else {
+ new_thread->pthread_priority = new_thread->attr.sched_priority;
+ }
+
+ if (!(new_thread->attr.flags & PTHREAD_NOFLOAT)) {
+ machdep_save_float_state(new_thread);
+ }
+
+ /* Initialize signalmask */
+ new_thread->sigmask = pthread_run->sigmask;
+ sigemptyset(&(new_thread->sigpending));
+ new_thread->sigcount = 0;
+
+ pthread_queue_init(&(new_thread->join_queue));
+ new_thread->specific_data = NULL;
+ new_thread->specific_data_count = 0;
+ new_thread->cleanup = NULL;
+ new_thread->queue = NULL;
+ 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;
+
+ pthread_sched_prevent();
+
+
+ pthread_sched_other_resume(new_thread);
+ /*
+ * Assignment must be outside of the locked pthread kernel incase
+ * thread is a bogus address resulting in a seg-fault. We want the
+ * original thread to be capable of handling the resulting signal.
+ * --proven
+ */
+ (*thread) = new_thread;
+ } else {
+ retval = EAGAIN;
+ }
+ return(retval);
+}
diff --git a/mit-pthreads/pthreads/pthread_attr.c b/mit-pthreads/pthreads/pthread_attr.c
new file mode 100644
index 00000000000..5e1c0302227
--- /dev/null
+++ b/mit-pthreads/pthreads/pthread_attr.c
@@ -0,0 +1,255 @@
+/* ==== 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$";
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+#include <string.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_attr_default, 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);
+}
+
+/* ==========================================================================
+ * pthread_attr_setcleanup()
+ */
+int pthread_attr_setcleanup(pthread_attr_t *attr, void (*routine)(void *),
+ void * arg)
+{
+ attr->cleanup_attr = routine;
+ attr->arg_attr = arg;
+ return(OK);
+}
+
+/* ==========================================================================
+ * pthread_attr_getdetachstate()
+ */
+int pthread_attr_getdetachstate(pthread_attr_t *attr, int * detachstate)
+{
+ *detachstate = attr->flags & PTHREAD_DETACHED;
+ return(OK);
+}
+
+/* ==========================================================================
+ * pthread_attr_setdetachstate()
+ */
+int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
+{
+ attr->flags = (attr->flags & ~(PTHREAD_DETACHED)) |
+ (detachstate & PTHREAD_DETACHED);
+ return(OK);
+}
+
+/* ==========================================================================
+ * pthread_attr_getfloatstate()
+ */
+int pthread_attr_getfloatstate(pthread_attr_t *attr, int * floatstate)
+{
+ *floatstate = attr->flags & PTHREAD_NOFLOAT;
+ return(OK);
+}
+
+/* ==========================================================================
+ * pthread_attr_setfloatstate()
+ */
+int pthread_attr_setfloatstate(pthread_attr_t *attr, int floatstate)
+{
+ attr->flags = (attr->flags & ~(PTHREAD_NOFLOAT)) |
+ (floatstate & PTHREAD_NOFLOAT);
+ return(OK);
+}
+
+/* ==========================================================================
+ * pthread_attr_getscope()
+ */
+int pthread_attr_getscope(pthread_attr_t *attr, int * contentionscope)
+{
+ *contentionscope = attr->flags & PTHREAD_SCOPE_SYSTEM;
+ return(OK);
+}
+
+/* ==========================================================================
+ * pthread_attr_setscope()
+ */
+int pthread_attr_setscope(pthread_attr_t *attr, int contentionscope)
+{
+ int ret;
+
+ switch (contentionscope) {
+ case PTHREAD_SCOPE_PROCESS:
+ attr->flags = (attr->flags & ~(PTHREAD_SCOPE_PROCESS))
+ | PTHREAD_SCOPE_PROCESS;
+ ret = OK;
+ break;
+ case PTHREAD_SCOPE_SYSTEM:
+ ret = ENOSYS;
+ break;
+ default:
+ ret = EINVAL;
+ break;
+ }
+
+ return(ret);
+}
+
+/* ==========================================================================
+ * pthread_attr_getinheritsched()
+ */
+int pthread_attr_getinheritsched(pthread_attr_t *attr, int * inheritsched)
+{
+ *inheritsched = attr->flags & PTHREAD_INHERIT_SCHED;
+ return(OK);
+}
+
+/* ==========================================================================
+ * pthread_attr_setinheritsched()
+ */
+int pthread_attr_setinheritsched(pthread_attr_t *attr, int inheritsched)
+{
+ attr->flags = (attr->flags & ~(PTHREAD_INHERIT_SCHED)) |
+ (inheritsched & PTHREAD_INHERIT_SCHED);
+ return(OK);
+}
+
+/* ==========================================================================
+ * pthread_attr_getschedpolicy()
+ */
+int pthread_attr_getschedpolicy(pthread_attr_t *attr, int * schedpolicy)
+{
+ *schedpolicy = (int)attr->schedparam_policy;
+ return(OK);
+}
+
+/* ==========================================================================
+ * pthread_attr_setschedpolicy()
+ */
+int pthread_attr_setschedpolicy(pthread_attr_t *attr, int schedpolicy)
+{
+ int ret;
+
+ switch(schedpolicy) {
+ case SCHED_FIFO:
+ case SCHED_IO:
+ case SCHED_RR:
+ attr->schedparam_policy = schedpolicy;
+ ret = OK;
+ break;
+ default:
+ ret = EINVAL;
+ break;
+ }
+ return(ret);
+}
+
+/* ==========================================================================
+ * pthread_attr_getschedparam()
+ */
+int pthread_attr_getschedparam(pthread_attr_t *attr, struct sched_param * param)
+{
+ param->sched_priority = attr->sched_priority;
+ return(OK);
+}
+
+/* ==========================================================================
+ * pthread_attr_setschedparam()
+ */
+int pthread_attr_setschedparam(pthread_attr_t *attr, struct sched_param * param)
+{
+ if ((param->sched_priority >= PTHREAD_MIN_PRIORITY) &&
+ (param->sched_priority <= PTHREAD_MAX_PRIORITY)) {
+ attr->sched_priority = param->sched_priority;
+ return(OK);
+ }
+ return(EINVAL);
+}
+
diff --git a/mit-pthreads/pthreads/pthread_cancel.c b/mit-pthreads/pthreads/pthread_cancel.c
new file mode 100644
index 00000000000..4191a269027
--- /dev/null
+++ b/mit-pthreads/pthreads/pthread_cancel.c
@@ -0,0 +1,258 @@
+/* ==== 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/mit-pthreads/pthreads/pthread_detach.c b/mit-pthreads/pthreads/pthread_detach.c
new file mode 100644
index 00000000000..d3ae8c03bb3
--- /dev/null
+++ b/mit-pthreads/pthreads/pthread_detach.c
@@ -0,0 +1,92 @@
+/* ==== 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$";
+#endif
+
+#include <errno.h>
+#include <pthread.h>
+
+/* ==========================================================================
+ * pthread_detach()
+ */
+int pthread_detach(pthread_t pthread)
+{
+ struct pthread * next_thread, * high_thread, * low_thread;
+ int ret;
+
+ pthread_sched_prevent();
+
+ /* Check that thread isn't detached already */
+ if (!(pthread->attr.flags & PTHREAD_DETACHED)) {
+
+ pthread->attr.flags |= PTHREAD_DETACHED;
+
+ /* Wakeup all threads waiting on a join */
+ if (next_thread = pthread_queue_deq(&(pthread->join_queue))) {
+ high_thread = next_thread;
+
+ while (next_thread = pthread_queue_deq(&(pthread->join_queue))) {
+ if (high_thread->pthread_priority < next_thread->pthread_priority) {
+ low_thread = high_thread;
+ high_thread = next_thread;
+ } else {
+ low_thread = next_thread;
+ }
+ pthread_prio_queue_enq(pthread_current_prio_queue, low_thread);
+ low_thread->state = PS_RUNNING;
+ }
+ /* If the thread is dead then move it to the alloc queue */
+ if (pthread_queue_remove(&pthread_dead_queue, pthread) == OK) {
+ pthread_queue_enq(&pthread_alloc_queue, pthread);
+ }
+ pthread_sched_other_resume(high_thread);
+ return(OK);
+ }
+ /* If the thread is dead then move it to the alloc queue */
+ if (pthread_queue_remove(&pthread_dead_queue, pthread) == OK) {
+ pthread_queue_enq(&pthread_alloc_queue, pthread);
+ pthread->state = PS_UNALLOCED;
+ }
+ ret = OK;
+ } else {
+ ret = ESRCH;
+ }
+ pthread_sched_resume();
+ return(ret);
+}
diff --git a/mit-pthreads/pthreads/pthread_init.c b/mit-pthreads/pthreads/pthread_init.c
new file mode 100644
index 00000000000..83e19fe0229
--- /dev/null
+++ b/mit-pthreads/pthreads/pthread_init.c
@@ -0,0 +1,135 @@
+/* ==== 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$";
+#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/mit-pthreads/pthreads/pthread_join.c b/mit-pthreads/pthreads/pthread_join.c
new file mode 100644
index 00000000000..879250020a1
--- /dev/null
+++ b/mit-pthreads/pthreads/pthread_join.c
@@ -0,0 +1,139 @@
+/* ==== 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$";
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+static int testDeadlock( struct pthread_queue *queue, pthread_t target );
+
+/* ==========================================================================
+ * pthread_join()
+ */
+int pthread_join(pthread_t pthread, void **thread_return)
+{
+ int ret;
+
+ 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();
+ return(ESRCH);
+ }
+
+ /*
+ * Now check if other thread has exited
+ * 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 */
+ 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;
+ }
+ 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 */
+}
diff --git a/mit-pthreads/pthreads/pthread_kill.c b/mit-pthreads/pthreads/pthread_kill.c
new file mode 100644
index 00000000000..9e3e61488a3
--- /dev/null
+++ b/mit-pthreads/pthreads/pthread_kill.c
@@ -0,0 +1,93 @@
+/* ==== 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$";
+#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/mit-pthreads/pthreads/pthread_once.c b/mit-pthreads/pthreads/pthread_once.c
new file mode 100644
index 00000000000..0a3dcd23fae
--- /dev/null
+++ b/mit-pthreads/pthreads/pthread_once.c
@@ -0,0 +1,59 @@
+/* ==== 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$";
+#endif
+
+#include <pthread.h>
+
+/* ==========================================================================
+ * pthread_once()
+ */
+int pthread_once(pthread_once_t *once_control, void (*init_routine)(void))
+{
+ /* Check first for speed */
+ if (once_control->state == PTHREAD_NEEDS_INIT) {
+ pthread_mutex_lock(&(once_control->mutex));
+ if (once_control->state == PTHREAD_NEEDS_INIT) {
+ init_routine();
+ once_control->state = PTHREAD_DONE_INIT;
+ }
+ pthread_mutex_unlock(&(once_control->mutex));
+ }
+ return(OK);
+}
diff --git a/mit-pthreads/pthreads/queue.c b/mit-pthreads/pthreads/queue.c
new file mode 100644
index 00000000000..c33774bf4dd
--- /dev/null
+++ b/mit-pthreads/pthreads/queue.c
@@ -0,0 +1,143 @@
+/* ==== 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$";
+#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()
+ */
+int pthread_queue_remove(struct pthread_queue *queue, struct pthread *thread)
+{
+ struct pthread **current = &(queue->q_next);
+ struct pthread *prev = NULL;
+ int ret = NOTOK;
+
+ while (*current) {
+ if (*current == thread) {
+ if ((*current)->next) {
+ *current = (*current)->next;
+ } else {
+ queue->q_last = prev;
+ *current = NULL;
+ }
+ thread->queue = NULL;
+ thread->next = NULL;
+ ret = OK;
+ break;
+ }
+ prev = *current;
+ current = &((*current)->next);
+ }
+ return(ret);
+}
+
+/* ==========================================================================
+ * pthread_llist_remove()
+ */
+int pthread_llist_remove(struct pthread **llist, struct pthread *thread)
+{
+ while (*llist) {
+ if (*llist == thread) {
+ *llist = thread->next;
+ return(OK);
+ }
+ llist = &(*llist)->next;
+ }
+ return(NOTOK);
+}
+
diff --git a/mit-pthreads/pthreads/readv.c b/mit-pthreads/pthreads/readv.c
new file mode 100644
index 00000000000..fd63d31cf94
--- /dev/null
+++ b/mit-pthreads/pthreads/readv.c
@@ -0,0 +1,85 @@
+/* ==== readv.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 : Implementation of readv().
+ *
+ * 1.00 95/06/19 proven
+ * -Started coding this file.
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#endif
+
+#include "config.h"
+
+#ifndef HAVE_SYSCALL_READV
+
+#include <errno.h>
+#include <unistd.h>
+#include <sys/uio.h>
+#include <sys/types.h>
+
+/* ==========================================================================
+ * machdep_sys_readv()
+ */
+int machdep_sys_readv(int fd, struct iovec * vector, int count)
+{
+ size_t bytes, i;
+ char *buffer;
+ int ret = 0;
+
+ /* Find the total number of bytes to be read. */
+ for (bytes = 0, i = 0; i < count; ++i)
+ bytes += vector[i].iov_len;
+
+ if (bytes) {
+ /*
+ * Allocate a temporary buffer to hold the data.
+ * Don't use alloca because threads tend to have smaller stacks.
+ */
+ if ((buffer = (char *)malloc(bytes)) == NULL) {
+ return(-ENOMEM);
+ }
+ ret = (int)machdep_sys_read(fd, buffer, bytes);
+
+ /* Copy the data from memory specified by VECTOR to BUFFER */
+ for (i = 0, bytes = 0; ret > 0; ret -= vector[i].iov_len) {
+ memcpy(vector[i].iov_base, buffer + bytes,
+ ret > vector[i].iov_len ? vector[i].iov_len : ret);
+ bytes += vector[i].iov_len;
+ }
+ free(buffer);
+ }
+ return(ret);
+}
+
+#endif
diff --git a/mit-pthreads/pthreads/schedparam.c b/mit-pthreads/pthreads/schedparam.c
new file mode 100644
index 00000000000..b4b28577022
--- /dev/null
+++ b/mit-pthreads/pthreads/schedparam.c
@@ -0,0 +1,170 @@
+/* ==== 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$";
+#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/mit-pthreads/pthreads/select.c b/mit-pthreads/pthreads/select.c
new file mode 100644
index 00000000000..eaafce31f19
--- /dev/null
+++ b/mit-pthreads/pthreads/select.c
@@ -0,0 +1,255 @@
+/* ==== 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$";
+#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/mit-pthreads/pthreads/sig.c b/mit-pthreads/pthreads/sig.c
new file mode 100644
index 00000000000..85d4465bf1c
--- /dev/null
+++ b/mit-pthreads/pthreads/sig.c
@@ -0,0 +1,452 @@
+/* ==== 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$";
+#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/mit-pthreads/pthreads/signal.c b/mit-pthreads/pthreads/signal.c
new file mode 100644
index 00000000000..7da4183c1cb
--- /dev/null
+++ b/mit-pthreads/pthreads/signal.c
@@ -0,0 +1,653 @@
+/* ==== 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$";
+#endif
+
+#include <config.h>
+#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;
+
+#if defined(HAVE_SYSCALL_SIGACTION) || defined(HAVE_SYSCALL_KSIGACTION)
+ struct sigaction act;
+
+ act.sa_handler = sig_handler_real;
+ sigemptyset(&(act.sa_mask));
+ act.sa_flags = 0;
+#endif
+
+ /* Initialize the important signals */
+ for (i = 0; signum_to_initialize[i]; i++) {
+
+#if defined(HAVE_SYSCALL_SIGACTION) || defined(HAVE_SYSCALL_KSIGACTION)
+ if (sigaction(signum_to_initialize[i], &act, NULL)) {
+#else
+ if (signal(signum_to_initialize[i], sig_handler_real)) {
+#endif
+ 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);
+
+#if defined(HAVE_SYSCALL_SIGACTION) || defined(HAVE_SYSCALL_KSIGACTION)
+ sigaction(j, &act, NULL);
+#else
+ signal(j, sig_handler_real);
+#endif
+
+ sig_next:;
+ }
+
+#if defined BROKEN_SIGNALS
+ signal(SIGCHLD, sig_handler_real);
+#endif
+
+}
+
diff --git a/mit-pthreads/pthreads/sleep.c b/mit-pthreads/pthreads/sleep.c
new file mode 100644
index 00000000000..1c13dd2eb1d
--- /dev/null
+++ b/mit-pthreads/pthreads/sleep.c
@@ -0,0 +1,367 @@
+/* ==== 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 : All the appropriate sleep routines.
+ *
+ * 1.00 93/12/28 proven
+ * -Started coding this file.
+ *
+ * 1.36 94/06/04 proven
+ * -Use new timer structure pthread_timer, that uses seconds
+ * -nano seconds. Rewrite all routines completely.
+ *
+ * 1.38 94/06/13 proven
+ * -switch pthread_timer to timespec
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#endif
+
+#include <pthread.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <signal.h>
+#include <unistd.h>
+#include <sys/compat.h>
+
+struct pthread * pthread_sleep = NULL;
+
+/* ==========================================================================
+ * sleep_compare_time()
+ */
+/* static inline int sleep_compare_time(struct timespec * time1,
+ struct timespec * time2) */
+static int sleep_compare_time(struct timespec * time1, struct timespec * time2)
+{
+ if ((time1->tv_sec < time2->tv_sec) ||
+ ((time1->tv_sec == time2->tv_sec) && (time1->tv_nsec < time2->tv_nsec))) {
+ return(-1);
+ }
+ if ((time1->tv_sec == time2->tv_sec) && (time1->tv_nsec == time2->tv_nsec)){
+ return(0);
+ }
+ return(1);
+}
+
+/* ==========================================================================
+ * machdep_stop_timer()
+ *
+ * Returns the time left on the timer.
+ */
+static struct itimerval timestop = { { 0, 0 }, { 0, 0 } };
+
+void machdep_stop_timer(struct timespec *current)
+{
+ struct itimerval timenow;
+
+ setitimer(ITIMER_REAL, & timestop, & timenow);
+ __pthread_signal_delete(SIGALRM);
+ if (current) {
+ current->tv_nsec = timenow.it_value.tv_usec * 1000;
+ current->tv_sec = timenow.it_value.tv_sec;
+ }
+}
+
+/* ==========================================================================
+ * machdep_start_timer()
+ */
+int machdep_start_timer(struct timespec *current, struct timespec *wakeup)
+{
+ struct itimerval timeout;
+
+ timeout.it_value.tv_usec = (wakeup->tv_nsec - current->tv_nsec) / 1000;
+ timeout.it_value.tv_sec = wakeup->tv_sec - current->tv_sec;
+ timeout.it_interval.tv_usec = 0;
+ timeout.it_interval.tv_sec = 0;
+ if (timeout.it_value.tv_usec < 0) {
+ timeout.it_value.tv_usec += 1000000;
+ timeout.it_value.tv_sec--;
+ }
+
+ if (((long) timeout.it_value.tv_sec >= 0) &&
+ ((timeout.it_value.tv_usec) || (timeout.it_value.tv_sec))) {
+ if (setitimer(ITIMER_REAL, & timeout, NULL) < 0)
+ {
+ fprintf(stderr,"Got error %d from setitimer with:\n\
+ wakeup: tv_sec: %ld tv_nsec: %ld\n\
+ current: tv_sec: %ld tv_nsec: %ld\n\
+ argument: tv_sec: %ld tv_usec: %ld\n",
+ errno,
+ wakeup->tv_sec, wakeup->tv_nsec,
+ current->tv_sec, current->tv_nsec,
+ timeout.it_value.tv_sec, timeout.it_value.tv_usec);
+ PANIC();
+ }
+ } else {
+ /*
+ * There is no time on the timer.
+ * This shouldn't happen,
+ * but isn't fatal.
+ */
+ sig_handler_fake(SIGALRM);
+ }
+ return(OK);
+}
+
+/* ==========================================================================
+ * sleep_schedule()
+ *
+ * Assumes that the current thread is the thread to be scheduled
+ * and that the kthread is already locked.
+ */
+void sleep_schedule(struct timespec *current_time, struct timespec *new_time)
+{
+ struct pthread * pthread_sleep_current, * pthread_sleep_prev;
+
+ /* Record the new time as the current thread's wakeup time. */
+ pthread_run->wakeup_time = *new_time;
+
+ /* any threads? */
+ if (pthread_sleep_current = pthread_sleep) {
+ if (sleep_compare_time(&(pthread_sleep_current->wakeup_time),
+ new_time) <= 0) {
+ /* Don't need to restart timer */
+ while (pthread_sleep_current->sll) {
+
+ pthread_sleep_prev = pthread_sleep_current;
+ pthread_sleep_current = pthread_sleep_current->sll;
+
+ if (sleep_compare_time(&(pthread_sleep_current->wakeup_time),
+ new_time) > 0) {
+ pthread_run->sll = pthread_sleep_current;
+ pthread_sleep_prev->sll = pthread_run;
+ return;
+ }
+ }
+
+ /* 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(current_time, new_time);
+ pthread_run->sll = pthread_sleep_current;
+ pthread_sleep = pthread_run;
+ }
+ } else {
+ /* Start timer and enqueue thread */
+ machdep_start_timer(current_time, new_time);
+ pthread_sleep = pthread_run;
+ pthread_run->sll = NULL;
+ }
+}
+
+/* ==========================================================================
+ * sleep_wakeup()
+ *
+ * This routine is called by the interrupt handler, which has already
+ * locked the current kthread. Since all threads on this list are owned
+ * by the current kthread, rescheduling won't be a problem.
+ */
+int sleep_spurious_wakeup = 0;
+int sleep_wakeup()
+{
+ struct pthread *pthread_sleep_next;
+ struct timespec current_time;
+ int ret = 0;
+
+ if (pthread_sleep == NULL) {
+ return(NOTOK);
+ }
+
+ machdep_gettimeofday(&current_time);
+ if (sleep_compare_time(&(pthread_sleep->wakeup_time), &current_time) > 0) {
+ machdep_start_timer(&current_time, &(pthread_sleep->wakeup_time));
+ sleep_spurious_wakeup++;
+ return(OK);
+ }
+
+ do {
+ if (pthread_sleep->pthread_priority > ret) {
+ ret = pthread_sleep->pthread_priority;
+ }
+
+ /*
+ * Clean up removed thread and start it running again.
+ *
+ * Note: It is VERY important to remove the thread form the
+ * current queue before putting it on the run queue.
+ * Both queues use pthread_sleep->next, and the thread that points
+ * to pthread_sleep should point to pthread_sleep->next then
+ * pthread_sleep should be put on the run queue.
+ */
+ if ((SET_PF_DONE_EVENT(pthread_sleep)) == OK) {
+ if (pthread_sleep->queue)
+ pthread_queue_remove(pthread_sleep->queue, pthread_sleep);
+ pthread_prio_queue_enq(pthread_current_prio_queue, pthread_sleep);
+ pthread_sleep->state = PS_RUNNING;
+ }
+
+ pthread_sleep_next = pthread_sleep->sll;
+ pthread_sleep->sll = NULL;
+
+ if ((pthread_sleep = pthread_sleep_next) == NULL) {
+ /* No more threads on sleep queue */
+ return(ret);
+ }
+ } while (sleep_compare_time(&(pthread_sleep->wakeup_time), &(current_time)) <= 0);
+
+ /* Start timer for next time interval */
+ machdep_start_timer(&current_time, &(pthread_sleep->wakeup_time));
+ return(ret);
+}
+
+
+/* ==========================================================================
+ * __sleep()
+ */
+void __sleep(struct timespec * time_to_sleep)
+{
+ struct pthread *pthread_sleep_prev;
+ struct timespec current_time, wakeup_time;
+
+ pthread_sched_prevent();
+
+ /* Get real time */
+ machdep_gettimeofday(&current_time);
+ wakeup_time.tv_sec = current_time.tv_sec + time_to_sleep->tv_sec;
+ wakeup_time.tv_nsec = current_time.tv_nsec + time_to_sleep->tv_nsec;
+
+ sleep_schedule(&current_time, &wakeup_time);
+
+ /* 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 */
+ time_to_sleep->tv_sec = pthread_run->wakeup_time.tv_sec;
+ time_to_sleep->tv_nsec = pthread_run->wakeup_time.tv_nsec;
+}
+
+/* ==========================================================================
+ * pthread_nanosleep()
+ */
+unsigned int pthread_nanosleep(unsigned int nseconds)
+{
+ struct timespec time_to_sleep;
+
+ if (nseconds) {
+ time_to_sleep.tv_nsec = nseconds;
+ time_to_sleep.tv_sec = 0;
+ __sleep(&time_to_sleep);
+ nseconds = time_to_sleep.tv_nsec;
+ }
+ return(nseconds);
+}
+
+/* ==========================================================================
+ * usleep()
+ */
+void usleep(unsigned int useconds)
+{
+ struct timespec time_to_sleep;
+
+ if (useconds) {
+ time_to_sleep.tv_nsec = (useconds % 1000000) * 1000;
+ time_to_sleep.tv_sec = useconds / 1000000;
+ __sleep(&time_to_sleep);
+ }
+}
+
+/* ==========================================================================
+ * sleep()
+ */
+unsigned int sleep(unsigned int seconds)
+{
+ struct timespec time_to_sleep;
+
+ if (seconds) {
+ time_to_sleep.tv_sec = seconds;
+ time_to_sleep.tv_nsec = 0;
+ __sleep(&time_to_sleep);
+ seconds = time_to_sleep.tv_sec;
+ }
+ return(seconds);
+}
+
+/* ==========================================================================
+ * sleep_cancel()
+ *
+ * Cannot be called while kernel is locked.
+ * Does not wake sleeping thread up, just remove it from the sleep queue.
+ */
+int sleep_cancel(struct pthread * pthread)
+{
+ struct timespec current_time, delta_time;
+ struct pthread * pthread_last;
+ int rval = NOTOK;
+
+ /* Lock sleep queue, Note this may be on a different kthread queue */
+ pthread_sched_prevent();
+
+ if (pthread_sleep) {
+ if (pthread == pthread_sleep) {
+ rval = OK;
+ machdep_stop_timer(&delta_time);
+ if (pthread_sleep = pthread_sleep->sll) {
+ current_time.tv_sec = delta_time.tv_sec;
+ current_time.tv_nsec = delta_time.tv_nsec;
+ current_time.tv_sec += pthread_sleep->wakeup_time.tv_sec;
+ current_time.tv_nsec += pthread_sleep->wakeup_time.tv_nsec;
+ while (current_time.tv_nsec > 1000000000) {
+ current_time.tv_nsec -= 1000000000;
+ current_time.tv_sec++;
+ }
+ machdep_start_timer(&(current_time),
+ &(pthread_sleep->wakeup_time));
+ }
+ } else {
+ for (pthread_last = pthread_sleep; pthread_last;
+ pthread_last = pthread_last->sll) {
+ if (pthread_last->sll == pthread) {
+ pthread_last->sll = pthread->sll;
+ rval = OK;
+ break;
+ }
+ }
+ }
+ }
+
+ pthread_sched_resume();
+ pthread->sll = NULL;
+ return(rval);
+}
diff --git a/mit-pthreads/pthreads/specific.c b/mit-pthreads/pthreads/specific.c
new file mode 100644
index 00000000000..898f9b0cd1b
--- /dev/null
+++ b/mit-pthreads/pthreads/specific.c
@@ -0,0 +1,198 @@
+/* ==== 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$";
+#endif
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <string.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/mit-pthreads/pthreads/stat.c b/mit-pthreads/pthreads/stat.c
new file mode 100644
index 00000000000..f18b7c6bd24
--- /dev/null
+++ b/mit-pthreads/pthreads/stat.c
@@ -0,0 +1,116 @@
+/* ==== 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$";
+#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);
+
+}
+
+#ifdef HAVE_SYSCALL_FSTATFS
+/* ==========================================================================
+ * 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);
+}
+#endif
diff --git a/mit-pthreads/pthreads/wait.c b/mit-pthreads/pthreads/wait.c
new file mode 100644
index 00000000000..9f0418ca8a1
--- /dev/null
+++ b/mit-pthreads/pthreads/wait.c
@@ -0,0 +1,159 @@
+/* ==== 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$";
+#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/mit-pthreads/pthreads/wrapper.c b/mit-pthreads/pthreads/wrapper.c
new file mode 100644
index 00000000000..6e3f4478fcf
--- /dev/null
+++ b/mit-pthreads/pthreads/wrapper.c
@@ -0,0 +1,149 @@
+/* ==== 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$";
+#endif
+
+#include "config.h"
+#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);
+
+}
+
+
+/* ==========================================================================
+ * chroot()
+ */
+
+#ifdef HAVE_SYSCALL_CHROOT
+int chroot(const char * name)
+{
+ int ret;
+
+ if ((ret = machdep_sys_chroot(name)) < OK) {
+ SET_ERRNO(-ret);
+ }
+ return(ret);
+
+}
+#endif
diff --git a/mit-pthreads/pthreads/writev.c b/mit-pthreads/pthreads/writev.c
new file mode 100644
index 00000000000..9823d5ad201
--- /dev/null
+++ b/mit-pthreads/pthreads/writev.c
@@ -0,0 +1,89 @@
+/* ==== writev.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 : Implementation of writev().
+ *
+ * 1.00 95/06/19 proven
+ * -Started coding this file.
+ */
+
+#ifndef lint
+static const char rcsid[] = "$Id$";
+#endif
+
+#include "config.h"
+
+#ifndef HAVE_SYSCALL_WRITEV
+
+#include <errno.h>
+#include <unistd.h>
+#include <sys/uio.h>
+#include <sys/types.h>
+
+/* ==========================================================================
+ * machdep_sys_writev()
+ *
+ * modified from the GNU C Library posix/writev.c
+ */
+int machdep_sys_writev(int fd, struct iovec * vector, int count)
+{
+ size_t bytes, i;
+ char *buffer;
+ int ret;
+
+ /* Find the total number of bytes to be written. */
+ for (bytes = 0, i = 0; i < count; ++i)
+ bytes += vector[i].iov_len;
+
+ if (bytes) {
+ /*
+ * Allocate a temporary buffer to hold the data.
+ * Don't use alloca because threads tend to have smaller stacks.
+ */
+ if ((buffer = (char *)malloc(bytes)) == NULL) {
+ return(-ENOMEM);
+ }
+ /* Copy the data from memory specified by VECTOR to BUFFER */
+ for (ret = 0, i = 0; i < count; ++i) {
+ memcpy(buffer + ret, vector[i].iov_base, vector[i].iov_len);
+ ret += vector[i].iov_len;
+ }
+ } else {
+ buffer = NULL;
+ }
+
+ ret = (int)machdep_sys_write(fd, buffer, bytes);
+ if (buffer)
+ free(buffer);
+ return(ret);
+}
+
+#endif
diff --git a/mit-pthreads/scripts/GNUmakefile.inc b/mit-pthreads/scripts/GNUmakefile.inc
new file mode 100755
index 00000000000..6309f28ca55
--- /dev/null
+++ b/mit-pthreads/scripts/GNUmakefile.inc
@@ -0,0 +1,24 @@
+VPATH := $(VPATH):${srcdir}/scripts
+SCRIPTS= pgcc pg++
+
+abspath := $(shell pwd)
+
+all-bin: $(SCRIPTS)
+
+pgcc: pgcc.sh
+ sed -e 's!EXEC_PREFIX!$(exec_prefix)!g' \
+ -e 's!BUILD_PREFIX!$(abspath)!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
+
+pg++: pgcc.sh
+ sed -e 's!EXEC_PREFIX!$(exec_prefix)!g' \
+ -e 's!BUILD_PREFIX!$(abspath)!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++
diff --git a/mit-pthreads/scripts/Makefile.inc b/mit-pthreads/scripts/Makefile.inc
new file mode 100644
index 00000000000..441f6b51d29
--- /dev/null
+++ b/mit-pthreads/scripts/Makefile.inc
@@ -0,0 +1,30 @@
+.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/mit-pthreads/scripts/pgcc.sh b/mit-pthreads/scripts/pgcc.sh
new file mode 100755
index 00000000000..6bd6cbeccdb
--- /dev/null
+++ b/mit-pthreads/scripts/pgcc.sh
@@ -0,0 +1,32 @@
+#!/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/mit-pthreads/stdio/GNUmakefile.inc b/mit-pthreads/stdio/GNUmakefile.inc
new file mode 100755
index 00000000000..7cb1371661d
--- /dev/null
+++ b/mit-pthreads/stdio/GNUmakefile.inc
@@ -0,0 +1,26 @@
+
+# from: @(#)Makefile.inc 5.7 (Berkeley) 6/27/91
+# $Id$
+
+# Thread safe stdio sources
+VPATH:= ${VPATH}:${srcdir}/stdio
+
+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 $(SRCS)
+
+# tempnam.c tmpnam.c tmpfile.c
+#
+# SRCS:= sys_errlist.c $(SRCS)
+# sys_errlist.c: make_errlist
+# (FOO=`pwd`; cd ${srcdir}/stdio/make_errlist; \
+# $(MAKE) CC=$(CC) srcdir=${srcdir} objdir=$${FOO})
+# `pwd`/make_errlist;
diff --git a/mit-pthreads/stdio/Makefile.inc b/mit-pthreads/stdio/Makefile.inc
new file mode 100644
index 00000000000..10c598c328f
--- /dev/null
+++ b/mit-pthreads/stdio/Makefile.inc
@@ -0,0 +1,20 @@
+
+# from: @(#)Makefile.inc 5.7 (Berkeley) 6/27/91
+# $Id$
+
+# Thread safe stdio sources
+.PATH: ${srcdir}/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/mit-pthreads/stdio/README b/mit-pthreads/stdio/README
new file mode 100755
index 00000000000..8e4c07909e9
--- /dev/null
+++ b/mit-pthreads/stdio/README
@@ -0,0 +1,41 @@
+Copyright (c) 1993, 1994 Chris Provenzano. All rights reserved.
+
+This is a threadsafe stdio based on the BSD stdio written by Chris Torek.
+This product includes software developed by the Univeristy of California,
+Berkeley and its contributors.
+
+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. The routine 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.
+
+
+
+Things to do.
+
+Fix printf so it uses the ininf function.
diff --git a/mit-pthreads/stdio/clrerr.c b/mit-pthreads/stdio/clrerr.c
new file mode 100644
index 00000000000..e809cfb8efd
--- /dev/null
+++ b/mit-pthreads/stdio/clrerr.c
@@ -0,0 +1,51 @@
+/*-
+ * 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: @(#)clrerr.c 5.3 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#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/mit-pthreads/stdio/fclose.c b/mit-pthreads/stdio/fclose.c
new file mode 100644
index 00000000000..c5db0808f6a
--- /dev/null
+++ b/mit-pthreads/stdio/fclose.c
@@ -0,0 +1,73 @@
+/*-
+ * 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: @(#)fclose.c 5.2 (Berkeley) 2/1/91";*/
+static char *rcsid = "$Id$";
+#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 (fp->_flags & __SMBF)
+ free((char *)fp->_bf._base);
+ if (HASUB(fp))
+ FREEUB(fp);
+ if (HASLB(fp))
+ FREELB(fp);
+ if (__sclose(fp) < 0)
+ r = EOF;
+/* funlockfile(fp); Don't unlock. The close() already has. */
+ fp->_file = -1;
+ fp->_flags = 0; /* release this FILE for reuse, DO THIS LAST */
+ return(r);
+ }
+ errno = EBADF;
+ return(EOF);
+}
diff --git a/mit-pthreads/stdio/fdopen.c b/mit-pthreads/stdio/fdopen.c
new file mode 100644
index 00000000000..4c006f24c7c
--- /dev/null
+++ b/mit-pthreads/stdio/fdopen.c
@@ -0,0 +1,93 @@
+/*-
+ * 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: @(#)fdopen.c 5.6 (Berkeley) 2/24/91";*/
+static char *rcsid = "$Id$";
+#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);
+ }
+
+ __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/mit-pthreads/stdio/feof.c b/mit-pthreads/stdio/feof.c
new file mode 100644
index 00000000000..10946fee581
--- /dev/null
+++ b/mit-pthreads/stdio/feof.c
@@ -0,0 +1,55 @@
+/*-
+ * 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: @(#)feof.c 5.1 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#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/mit-pthreads/stdio/ferror.c b/mit-pthreads/stdio/ferror.c
new file mode 100644
index 00000000000..b80ddab037e
--- /dev/null
+++ b/mit-pthreads/stdio/ferror.c
@@ -0,0 +1,55 @@
+/*-
+ * 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: @(#)ferror.c 5.1 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#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/mit-pthreads/stdio/fflush.c b/mit-pthreads/stdio/fflush.c
new file mode 100644
index 00000000000..766691045b5
--- /dev/null
+++ b/mit-pthreads/stdio/fflush.c
@@ -0,0 +1,98 @@
+/*-
+ * 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: @(#)fflush.c 5.1 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#endif /* LIBC_SCCS and not lint */
+
+#include <pthread.h>
+#include <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/mit-pthreads/stdio/fgetc.c b/mit-pthreads/stdio/fgetc.c
new file mode 100644
index 00000000000..c5eb2ee5986
--- /dev/null
+++ b/mit-pthreads/stdio/fgetc.c
@@ -0,0 +1,65 @@
+/*-
+ * 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: @(#)fgetc.c 5.3 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#endif /* LIBC_SCCS and not lint */
+
+#include <pthread.h>
+#include <stdio.h>
+
+fgetc(fp)
+ FILE *fp;
+{
+ int ret;
+
+ flockfile(fp);
+ ret = __sgetc(fp);
+ funlockfile(fp);
+ return(ret);
+}
+
+int __getc(FILE *_p)
+{
+ int ret;
+ flockfile(_p);
+ ret = __sgetc(_p);
+ funlockfile(_p);
+ return(ret);
+}
+
diff --git a/mit-pthreads/stdio/fgetline.c b/mit-pthreads/stdio/fgetline.c
new file mode 100644
index 00000000000..219660612f1
--- /dev/null
+++ b/mit-pthreads/stdio/fgetline.c
@@ -0,0 +1,170 @@
+/*-
+ * 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: @(#)fgetline.c 5.2 (Berkeley) 5/4/91";*/
+static char *rcsid = "$Id$";
+#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) memcpy((void *)(fp->_lb._base + off), (void *)fp->_p,
+ 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) memcpy((void *)(fp->_lb._base + off), (void *)fp->_p, 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/mit-pthreads/stdio/fgetpos.c b/mit-pthreads/stdio/fgetpos.c
new file mode 100644
index 00000000000..c81b48e3cc8
--- /dev/null
+++ b/mit-pthreads/stdio/fgetpos.c
@@ -0,0 +1,85 @@
+/*-
+ * 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: @(#)fgetpos.c 5.1 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#endif /* LIBC_SCCS and not lint */
+
+#include <pthread.h>
+#include <unistd.h>
+#include <stdio.h>
+#include "local.h"
+
+fgetpos(fp, pos)
+ FILE *fp;
+ fpos_t *pos;
+{
+ flockfile(fp);
+
+ /*
+ * Find offset of underlying I/O object, then
+ * adjust for buffered bytes.
+ */
+ if (fp->_flags & __SOFF) {
+ *pos = fp->_offset;
+ } else {
+ *pos = __sseek(fp, (off_t)0, SEEK_CUR);
+ }
+
+ if (*pos != (fpos_t)-1) {
+ 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(fp);
+ return ((*pos) == (fpos_t)-1);
+}
diff --git a/mit-pthreads/stdio/fgets.c b/mit-pthreads/stdio/fgets.c
new file mode 100644
index 00000000000..5ee5c4d6608
--- /dev/null
+++ b/mit-pthreads/stdio/fgets.c
@@ -0,0 +1,110 @@
+/*-
+ * 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: @(#)fgets.c 5.4 (Berkeley) 5/4/91";*/
+static char *rcsid = "$Id$";
+#endif /* LIBC_SCCS and not lint */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.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) memcpy((void *)s, (void *)p, len);
+ s += len;
+ break;
+ }
+ fp->_r -= len;
+ fp->_p += len;
+ (void) memcpy((void *)s, (void *)p, len);
+ s += len;
+ } while ((n -= len) != 0);
+
+ *s = 0;
+ funlockfile(fp);
+ return (buf);
+}
diff --git a/mit-pthreads/stdio/fileno.c b/mit-pthreads/stdio/fileno.c
new file mode 100644
index 00000000000..475bd509993
--- /dev/null
+++ b/mit-pthreads/stdio/fileno.c
@@ -0,0 +1,55 @@
+/*-
+ * 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: @(#)fileno.c 5.1 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#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/mit-pthreads/stdio/findfp.c b/mit-pthreads/stdio/findfp.c
new file mode 100644
index 00000000000..35817eb6a5f
--- /dev/null
+++ b/mit-pthreads/stdio/findfp.c
@@ -0,0 +1,161 @@
+/*-
+ * 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: @(#)findfp.c 5.10 (Berkeley) 2/24/91";*/
+static char *rcsid = "$Id$";
+#endif /* LIBC_SCCS and not lint */
+
+#include <pthread.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.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 };
+FILE *__iob = __sF;
+FILE *_iob = __sF;
+
+pthread_mutex_t __sfp_mutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t __sfp_cond = PTHREAD_COND_INITIALIZER;
+/*
+ * __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(struct glue) + 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.
+ * Do the pthread_once stuff here to keep pthread_once_t out of the
+ * header files. No reason sprintf.c &c should need to include pthread.h...
+ */
+static void __s_real_init ()
+{
+ /* make sure we clean up on exit */
+ __cleanup = _cleanup;
+}
+
+static pthread_once_t sdidinit = PTHREAD_ONCE_INIT;
+
+void __sinit ()
+{
+ pthread_once (&sdidinit, __s_real_init);
+}
diff --git a/mit-pthreads/stdio/flags.c b/mit-pthreads/stdio/flags.c
new file mode 100644
index 00000000000..c0971003312
--- /dev/null
+++ b/mit-pthreads/stdio/flags.c
@@ -0,0 +1,93 @@
+/*-
+ * 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: @(#)flags.c 5.1 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#endif /* LIBC_SCCS and not lint */
+
+#include <pthread.h>
+#include <sys/types.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.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/mit-pthreads/stdio/floatio.h b/mit-pthreads/stdio/floatio.h
new file mode 100644
index 00000000000..cf3821488ae
--- /dev/null
+++ b/mit-pthreads/stdio/floatio.h
@@ -0,0 +1,47 @@
+/*-
+ * 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$
+ */
+
+/*
+ * 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/mit-pthreads/stdio/fopen.c b/mit-pthreads/stdio/fopen.c
new file mode 100644
index 00000000000..d44c17b633f
--- /dev/null
+++ b/mit-pthreads/stdio/fopen.c
@@ -0,0 +1,90 @@
+/*-
+ * 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: @(#)fopen.c 5.5 (Berkeley) 2/5/91";*/
+static char *rcsid = "$Id$";
+#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);
+ }
+
+ __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, (off_t)0, SEEK_END);
+ }
+ pthread_mutex_unlock(&__sfp_mutex);
+ return (fp);
+}
diff --git a/mit-pthreads/stdio/fprintf.c b/mit-pthreads/stdio/fprintf.c
new file mode 100644
index 00000000000..bdeb49c054d
--- /dev/null
+++ b/mit-pthreads/stdio/fprintf.c
@@ -0,0 +1,71 @@
+/*-
+ * 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$";
+#endif /* LIBC_SCCS and not lint */
+
+#include <pthread.h>
+#include <stdio.h>
+#if __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+#if __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;
+
+#if __STDC__
+ va_start(ap, fmt);
+#else
+ va_start(ap);
+#endif
+ ret = vfprintf(fp, fmt, ap);
+ va_end(ap);
+ return (ret);
+}
diff --git a/mit-pthreads/stdio/fpurge.c b/mit-pthreads/stdio/fpurge.c
new file mode 100644
index 00000000000..7edbb0b30cd
--- /dev/null
+++ b/mit-pthreads/stdio/fpurge.c
@@ -0,0 +1,73 @@
+/*-
+ * 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: @(#)fpurge.c 5.2 (Berkeley) 2/24/91";*/
+static char *rcsid = "$Id$";
+#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/mit-pthreads/stdio/fputc.c b/mit-pthreads/stdio/fputc.c
new file mode 100644
index 00000000000..e6dd752f81b
--- /dev/null
+++ b/mit-pthreads/stdio/fputc.c
@@ -0,0 +1,73 @@
+/*-
+ * 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: @(#)fputc.c 5.3 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#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);
+}
+
+int __putc(int _c, FILE *_p)
+{
+ int ret;
+ flockfile(_p);
+ ret = __sputc(_c, _p);
+ funlockfile(_p);
+ return(ret);
+}
+
+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));
+}
+
diff --git a/mit-pthreads/stdio/fputs.c b/mit-pthreads/stdio/fputs.c
new file mode 100644
index 00000000000..882b828409e
--- /dev/null
+++ b/mit-pthreads/stdio/fputs.c
@@ -0,0 +1,67 @@
+/*-
+ * 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: @(#)fputs.c 5.6 (Berkeley) 2/24/91";*/
+static char *rcsid = "$Id$";
+#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/mit-pthreads/stdio/fread.c b/mit-pthreads/stdio/fread.c
new file mode 100644
index 00000000000..0d8ec6186c7
--- /dev/null
+++ b/mit-pthreads/stdio/fread.c
@@ -0,0 +1,84 @@
+/*-
+ * 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: @(#)fread.c 5.4 (Berkeley) 5/4/91";*/
+static char *rcsid = "$Id$";
+#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) memcpy((void *)p, (void *)fp->_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) memcpy((void *)p, (void *)fp->_p, resid);
+ fp->_r -= resid;
+ fp->_p += resid;
+done_fread:;
+ funlockfile(fp);
+ return (count);
+}
diff --git a/mit-pthreads/stdio/freopen.c b/mit-pthreads/stdio/freopen.c
new file mode 100644
index 00000000000..f45571c8ea0
--- /dev/null
+++ b/mit-pthreads/stdio/freopen.c
@@ -0,0 +1,149 @@
+/*-
+ * 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: @(#)freopen.c 5.6 (Berkeley) 2/24/91";*/
+static char *rcsid = "$Id$";
+#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);
+ }
+
+ __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;
+ } else {
+ /* unlock __sfp_mutex, and try again later */
+ pthread_mutex_unlock(&__sfp_mutex);
+ pthread_yield();
+ continue;
+ }
+ /* @@ Yo, Chris! Between the "break" and "continue" statements
+ above, the program will never get here. What gives? */
+ pthread_mutex_unlock(&__sfp_mutex);
+ funlockfile(fp);
+ return(ret);
+ }
+ (void)fclose(fp);
+ return(NULL);
+}
diff --git a/mit-pthreads/stdio/fscanf.c b/mit-pthreads/stdio/fscanf.c
new file mode 100644
index 00000000000..8fbbac5d102
--- /dev/null
+++ b/mit-pthreads/stdio/fscanf.c
@@ -0,0 +1,73 @@
+/*-
+ * 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$";
+#endif /* LIBC_SCCS and not lint */
+
+#include <pthread.h>
+#include <stdio.h>
+#if __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+#if __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/mit-pthreads/stdio/fseek.c b/mit-pthreads/stdio/fseek.c
new file mode 100644
index 00000000000..5c7feda638f
--- /dev/null
+++ b/mit-pthreads/stdio/fseek.c
@@ -0,0 +1,248 @@
+/*-
+ * 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$";
+#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;
+{
+#if __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/mit-pthreads/stdio/fsetpos.c b/mit-pthreads/stdio/fsetpos.c
new file mode 100644
index 00000000000..a421d405f51
--- /dev/null
+++ b/mit-pthreads/stdio/fsetpos.c
@@ -0,0 +1,54 @@
+/*-
+ * 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: @(#)fsetpos.c 5.2 (Berkeley) 2/5/91";*/
+static char *rcsid = "$Id$";
+#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/mit-pthreads/stdio/ftell.c b/mit-pthreads/stdio/ftell.c
new file mode 100644
index 00000000000..e5961fa50b6
--- /dev/null
+++ b/mit-pthreads/stdio/ftell.c
@@ -0,0 +1,90 @@
+/*-
+ * 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$";
+#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/mit-pthreads/stdio/funopen.c b/mit-pthreads/stdio/funopen.c
new file mode 100644
index 00000000000..f8b37ed0ae4
--- /dev/null
+++ b/mit-pthreads/stdio/funopen.c
@@ -0,0 +1,105 @@
+/*-
+ * 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$";
+#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)();
+#if __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/mit-pthreads/stdio/fvwrite.c b/mit-pthreads/stdio/fvwrite.c
new file mode 100644
index 00000000000..5ed25b4e7b4
--- /dev/null
+++ b/mit-pthreads/stdio/fvwrite.c
@@ -0,0 +1,190 @@
+/*-
+ * 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: @(#)fvwrite.c 5.3 (Berkeley) 5/4/91";*/
+static char *rcsid = "$Id$";
+#endif /* LIBC_SCCS and not lint */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.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) memcpy((void *)fp->_p, (void *)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/mit-pthreads/stdio/fvwrite.h b/mit-pthreads/stdio/fvwrite.h
new file mode 100644
index 00000000000..b3474563a4e
--- /dev/null
+++ b/mit-pthreads/stdio/fvwrite.h
@@ -0,0 +1,54 @@
+/*-
+ * 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$
+ */
+
+/*
+ * 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/mit-pthreads/stdio/fwalk.c b/mit-pthreads/stdio/fwalk.c
new file mode 100644
index 00000000000..58a199e0707
--- /dev/null
+++ b/mit-pthreads/stdio/fwalk.c
@@ -0,0 +1,132 @@
+/*-
+ * 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: @(#)fwalk.c 5.2 (Berkeley) 2/24/91";*/
+static char *rcsid = "$Id$";
+#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 = n;
+ saveg = g;
+ savefp = fp;
+ continue;
+ }
+ } else {
+ ret |= __sflush(fp);
+ funlockfile(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)) {
+ flockfile(fp);
+ ret |= __sflush(fp);
+ funlockfile(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/mit-pthreads/stdio/fwrite.c b/mit-pthreads/stdio/fwrite.c
new file mode 100644
index 00000000000..5eada4ee84b
--- /dev/null
+++ b/mit-pthreads/stdio/fwrite.c
@@ -0,0 +1,80 @@
+/*-
+ * 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: @(#)fwrite.c 5.5 (Berkeley) 2/24/91";*/
+static char *rcsid = "$Id$";
+#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;
+ if (! n)
+ return(0);
+
+ 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/mit-pthreads/stdio/getc.c b/mit-pthreads/stdio/getc.c
new file mode 100644
index 00000000000..6896e78bc7e
--- /dev/null
+++ b/mit-pthreads/stdio/getc.c
@@ -0,0 +1,58 @@
+/*-
+ * 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: @(#)getc.c 5.1 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#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/mit-pthreads/stdio/getc_unlocked.c b/mit-pthreads/stdio/getc_unlocked.c
new file mode 100644
index 00000000000..01db3bcea2a
--- /dev/null
+++ b/mit-pthreads/stdio/getc_unlocked.c
@@ -0,0 +1,55 @@
+/*-
+ * 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: @(#)getc.c 5.1 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#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/mit-pthreads/stdio/getchar.c b/mit-pthreads/stdio/getchar.c
new file mode 100644
index 00000000000..6e631c6c1b1
--- /dev/null
+++ b/mit-pthreads/stdio/getchar.c
@@ -0,0 +1,58 @@
+/*-
+ * 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: @(#)getchar.c 5.3 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#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/mit-pthreads/stdio/getchar_unlocked.c b/mit-pthreads/stdio/getchar_unlocked.c
new file mode 100644
index 00000000000..40945c5dd57
--- /dev/null
+++ b/mit-pthreads/stdio/getchar_unlocked.c
@@ -0,0 +1,54 @@
+/*-
+ * 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: @(#)getchar.c 5.3 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#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/mit-pthreads/stdio/gets.c b/mit-pthreads/stdio/gets.c
new file mode 100644
index 00000000000..0e7967ae3fe
--- /dev/null
+++ b/mit-pthreads/stdio/gets.c
@@ -0,0 +1,71 @@
+/*-
+ * 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: @(#)gets.c 5.3 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#endif /* LIBC_SCCS and not lint */
+
+#include <pthread.h>
+#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/mit-pthreads/stdio/getw.c b/mit-pthreads/stdio/getw.c
new file mode 100644
index 00000000000..623ba6258a1
--- /dev/null
+++ b/mit-pthreads/stdio/getw.c
@@ -0,0 +1,51 @@
+/*-
+ * 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: @(#)getw.c 5.3 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#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/mit-pthreads/stdio/glue.h b/mit-pthreads/stdio/glue.h
new file mode 100644
index 00000000000..e5103bbb0b3
--- /dev/null
+++ b/mit-pthreads/stdio/glue.h
@@ -0,0 +1,49 @@
+/*-
+ * 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$
+ */
+
+/*
+ * The first few FILEs are statically allocated; others are dynamically
+ * allocated and linked in via this glue structure.
+ */
+typedef struct glue {
+ struct glue *next;
+ int niobs;
+ FILE *iobs;
+} __sglue_type;
+extern struct glue __sglue;
diff --git a/mit-pthreads/stdio/local.h b/mit-pthreads/stdio/local.h
new file mode 100644
index 00000000000..068754fad38
--- /dev/null
+++ b/mit-pthreads/stdio/local.h
@@ -0,0 +1,90 @@
+/*-
+ * 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$
+ */
+
+/*
+ * Information local to this implementation of stdio,
+ * in particular, macros and private variables.
+ */
+
+#include <sys/types.h>
+#include <stddef.h>
+
+extern FILE *__sfp __P_((void));
+extern int __sflush __P_((FILE *));
+extern int __srefill __P_((FILE *));
+extern int __swrite __P_((FILE *, const char *, int));
+extern int __sread __P_((FILE *, char *, int));
+extern fpos_t __sseek __P_((FILE *, off_t, int));
+extern int __sclose __P_((FILE *));
+extern void __sinit __P_((void));
+extern void _cleanup __P_((void));
+extern void __smakebuf __P_((FILE *));
+extern int __swhatbuf __P_((FILE *, size_t *, int *));
+extern int __swalk_sflush __P_(());
+extern int __swsetup __P_((FILE *));
+extern int __sflags __P_((const char *, int *));
+
+extern void (*__cleanup) __P_((void));
+
+/*
+ * 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/mit-pthreads/stdio/makebuf.c b/mit-pthreads/stdio/makebuf.c
new file mode 100644
index 00000000000..316abe054b6
--- /dev/null
+++ b/mit-pthreads/stdio/makebuf.c
@@ -0,0 +1,122 @@
+/*-
+ * 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: @(#)makebuf.c 5.3 (Berkeley) 5/6/93";*/
+static char *rcsid = "$Id$";
+#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"
+
+void (*__cleanup) __P_((void));
+
+/*
+ * 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/mit-pthreads/stdio/mktemp.c b/mit-pthreads/stdio/mktemp.c
new file mode 100644
index 00000000000..7fdc631ad0b
--- /dev/null
+++ b/mit-pthreads/stdio/mktemp.c
@@ -0,0 +1,126 @@
+/*
+ * 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$";
+#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/mit-pthreads/stdio/perror.c b/mit-pthreads/stdio/perror.c
new file mode 100644
index 00000000000..19fe52f5010
--- /dev/null
+++ b/mit-pthreads/stdio/perror.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 1988 Regents of the University of California.
+ * Copyright (c) 1993, 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[] = "@(#)perror.c 5.11 (Berkeley) 2/24/91";
+#endif /* LIBC_SCCS and not lint */
+
+#include <pthread.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
+char *strerror(int); /* For systems that don't prototype it in string.h */
+
+void
+perror(s)
+ const char *s;
+{
+ char * e;
+
+ if (fd_lock(STDERR_FILENO, FD_WRITE, NULL) == OK) {
+ if (s && *s) {
+ fd_table[STDERR_FILENO]->ops->write(fd_table[STDERR_FILENO]->fd,
+ fd_table[STDERR_FILENO]->flags, s, strlen(s), NULL);
+ fd_table[STDERR_FILENO]->ops->write(fd_table[STDERR_FILENO]->fd,
+ fd_table[STDERR_FILENO]->flags, ": ", 2, NULL);
+ }
+ e = strerror(errno);
+ fd_table[STDERR_FILENO]->ops->write(fd_table[STDERR_FILENO]->fd,
+ fd_table[STDERR_FILENO]->flags, e, strlen(e), NULL);
+ fd_table[STDERR_FILENO]->ops->write(fd_table[STDERR_FILENO]->fd,
+ fd_table[STDERR_FILENO]->flags, "\n", 1, NULL);
+ fd_unlock(STDERR_FILENO, FD_WRITE);
+ }
+}
diff --git a/mit-pthreads/stdio/printf.c b/mit-pthreads/stdio/printf.c
new file mode 100644
index 00000000000..a298509d341
--- /dev/null
+++ b/mit-pthreads/stdio/printf.c
@@ -0,0 +1,56 @@
+/*-
+ * 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: @(#)printf.c 5.6 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdarg.h>
+#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/mit-pthreads/stdio/putc.c b/mit-pthreads/stdio/putc.c
new file mode 100644
index 00000000000..ac71e35ff25
--- /dev/null
+++ b/mit-pthreads/stdio/putc.c
@@ -0,0 +1,60 @@
+/*-
+ * 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: @(#)putc.c 5.1 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#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/mit-pthreads/stdio/putc_unlocked.c b/mit-pthreads/stdio/putc_unlocked.c
new file mode 100644
index 00000000000..7c9c78ff1e8
--- /dev/null
+++ b/mit-pthreads/stdio/putc_unlocked.c
@@ -0,0 +1,56 @@
+/*-
+ * 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: @(#)putc.c 5.1 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#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/mit-pthreads/stdio/putchar.c b/mit-pthreads/stdio/putchar.c
new file mode 100644
index 00000000000..c22a11ea25d
--- /dev/null
+++ b/mit-pthreads/stdio/putchar.c
@@ -0,0 +1,60 @@
+/*-
+ * 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: @(#)putchar.c 5.3 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#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/mit-pthreads/stdio/putchar_unlocked.c b/mit-pthreads/stdio/putchar_unlocked.c
new file mode 100644
index 00000000000..df27a501211
--- /dev/null
+++ b/mit-pthreads/stdio/putchar_unlocked.c
@@ -0,0 +1,56 @@
+/*-
+ * 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: @(#)putchar.c 5.3 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#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/mit-pthreads/stdio/puts.c b/mit-pthreads/stdio/puts.c
new file mode 100644
index 00000000000..97f8b3599f2
--- /dev/null
+++ b/mit-pthreads/stdio/puts.c
@@ -0,0 +1,71 @@
+/*-
+ * 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: @(#)puts.c 5.6 (Berkeley) 2/24/91";*/
+static char *rcsid = "$Id$";
+#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/mit-pthreads/stdio/putw.c b/mit-pthreads/stdio/putw.c
new file mode 100644
index 00000000000..79473f0e243
--- /dev/null
+++ b/mit-pthreads/stdio/putw.c
@@ -0,0 +1,64 @@
+/*-
+ * 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: @(#)putw.c 5.3 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#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/mit-pthreads/stdio/refill.c b/mit-pthreads/stdio/refill.c
new file mode 100644
index 00000000000..396895e56ff
--- /dev/null
+++ b/mit-pthreads/stdio/refill.c
@@ -0,0 +1,189 @@
+/*-
+ * 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: @(#)refill.c 5.3 (Berkeley) 2/24/91";*/
+static char *rcsid = "$Id$";
+#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 = n;
+ saveg = g;
+ savefp = fp;
+ continue;
+ }
+ } else {
+ (void) __sflush(fp);
+ funlockfile(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)) {
+ flockfile(fp);
+ (void) __sflush(fp);
+ funlockfile(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 */
+ __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->_file == -1) {
+ fp->_flags |= __SEOF;
+ return(EOF);
+ }
+
+ 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/mit-pthreads/stdio/remove.c b/mit-pthreads/stdio/remove.c
new file mode 100644
index 00000000000..116537e3a0f
--- /dev/null
+++ b/mit-pthreads/stdio/remove.c
@@ -0,0 +1,50 @@
+/*-
+ * 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: @(#)remove.c 5.3 (Berkeley) 2/24/91";*/
+static char *rcsid = "$Id$";
+#endif /* LIBC_SCCS and not lint */
+
+#include <pthread.h>
+#include <unistd.h>
+
+remove(file)
+ const char *file;
+{
+ return (unlink(file));
+}
diff --git a/mit-pthreads/stdio/rewind.c b/mit-pthreads/stdio/rewind.c
new file mode 100644
index 00000000000..17d4418db39
--- /dev/null
+++ b/mit-pthreads/stdio/rewind.c
@@ -0,0 +1,55 @@
+/*-
+ * 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: @(#)rewind.c 5.6 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#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/mit-pthreads/stdio/rget.c b/mit-pthreads/stdio/rget.c
new file mode 100644
index 00000000000..a2b19afb130
--- /dev/null
+++ b/mit-pthreads/stdio/rget.c
@@ -0,0 +1,58 @@
+/*-
+ * 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: @(#)rget.c 5.1 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#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/mit-pthreads/stdio/scanf.c b/mit-pthreads/stdio/scanf.c
new file mode 100644
index 00000000000..9f9f5a6665e
--- /dev/null
+++ b/mit-pthreads/stdio/scanf.c
@@ -0,0 +1,72 @@
+/*-
+ * 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$";
+#endif /* LIBC_SCCS and not lint */
+
+#include <pthread.h>
+#include <stdio.h>
+#if __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+#if __STDC__
+scanf(char const *fmt, ...)
+#else
+scanf(fmt, va_alist)
+ char *fmt;
+ va_dcl
+#endif
+{
+ int ret;
+ va_list ap;
+
+#if __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/mit-pthreads/stdio/setbuf.c b/mit-pthreads/stdio/setbuf.c
new file mode 100644
index 00000000000..af8d088089d
--- /dev/null
+++ b/mit-pthreads/stdio/setbuf.c
@@ -0,0 +1,52 @@
+/*-
+ * 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: @(#)setbuf.c 5.3 (Berkeley) 1/20/91";*/
+static char *rcsid = "$Id$";
+#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/mit-pthreads/stdio/setbuffer.c b/mit-pthreads/stdio/setbuffer.c
new file mode 100644
index 00000000000..0c79e55fd93
--- /dev/null
+++ b/mit-pthreads/stdio/setbuffer.c
@@ -0,0 +1,64 @@
+/*-
+ * 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: @(#)setbuffer.c 5.5 (Berkeley) 3/18/91";*/
+static char *rcsid = "$Id$";
+#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/mit-pthreads/stdio/setvbuf.c b/mit-pthreads/stdio/setvbuf.c
new file mode 100644
index 00000000000..288d8c32db0
--- /dev/null
+++ b/mit-pthreads/stdio/setvbuf.c
@@ -0,0 +1,154 @@
+/*-
+ * 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: @(#)setvbuf.c 5.5 (Berkeley) 5/6/93";*/
+static char *rcsid = "$Id$";
+#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 = size; /* Was 0 (mevans) */
+ 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/mit-pthreads/stdio/snprintf.c b/mit-pthreads/stdio/snprintf.c
new file mode 100644
index 00000000000..dd9bca24f73
--- /dev/null
+++ b/mit-pthreads/stdio/snprintf.c
@@ -0,0 +1,79 @@
+/*-
+ * 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$";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdio.h>
+#if __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+#if __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);
+#if __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/mit-pthreads/stdio/sprintf.c b/mit-pthreads/stdio/sprintf.c
new file mode 100644
index 00000000000..a500e8d4afa
--- /dev/null
+++ b/mit-pthreads/stdio/sprintf.c
@@ -0,0 +1,78 @@
+/*-
+ * 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$";
+#endif /* LIBC_SCCS and not lint */
+
+#include <limits.h>
+#include <stdio.h>
+#if __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#include "local.h"
+
+#if __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;
+#if __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/mit-pthreads/stdio/sscanf.c b/mit-pthreads/stdio/sscanf.c
new file mode 100644
index 00000000000..50148192b9c
--- /dev/null
+++ b/mit-pthreads/stdio/sscanf.c
@@ -0,0 +1,79 @@
+/*-
+ * 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$";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdio.h>
+#include <string.h>
+#if __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#include "local.h"
+
+#if __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;
+#if __STDC__
+ va_start(ap, fmt);
+#else
+ va_start(ap);
+#endif
+ ret = __svfscanf(&f, fmt, ap);
+ va_end(ap);
+ return (ret);
+}
diff --git a/mit-pthreads/stdio/stdio.c b/mit-pthreads/stdio/stdio.c
new file mode 100644
index 00000000000..0b676eeb09b
--- /dev/null
+++ b/mit-pthreads/stdio/stdio.c
@@ -0,0 +1,104 @@
+/*-
+ * 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: @(#)stdio.c 5.3 (Berkeley) 2/24/91";*/
+static char *rcsid = "$Id$";
+#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 (fd_table[fp->_file]->ops->use_kfds < 2) {
+ ret = fd_table[fp->_file]->ops->read(fd_table[fp->_file]->fd,
+ fd_table[fp->_file]->flags, buf, n, NULL);
+ } else {
+ pthread_ssize_t (*readfn)() = fd_table[fp->_file]->ops->read;
+ ret = readfn(fd_table[fp->_file]->fd, buf, n);
+ }
+ if (ret >= 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 */
+ if (fd_table[fp->_file]->ops->use_kfds < 2) {
+ return(fd_table[fp->_file]->ops->write(fd_table[fp->_file]->fd,
+ fd_table[fp->_file]->flags, buf, n, NULL));
+ } else {
+ pthread_ssize_t (*writefn)() = fd_table[fp->_file]->ops->write;
+ return(writefn(fd_table[fp->_file]->fd,buf,n));
+ }
+}
+
+fpos_t __sseek(FILE *fp, off_t offset, int whence)
+{
+ register fpos_t ret;
+
+ ret = (fpos_t)lseek(fp->_file, 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/mit-pthreads/stdio/strerror.c b/mit-pthreads/stdio/strerror.c
new file mode 100644
index 00000000000..5aea7e7a4fc
--- /dev/null
+++ b/mit-pthreads/stdio/strerror.c
@@ -0,0 +1,67 @@
+/*
+ * 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/mit-pthreads/stdio/tempnam.c b/mit-pthreads/stdio/tempnam.c
new file mode 100644
index 00000000000..88150a18019
--- /dev/null
+++ b/mit-pthreads/stdio/tempnam.c
@@ -0,0 +1,87 @@
+/*
+ * 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$";
+#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 (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/mit-pthreads/stdio/tmpfile.c b/mit-pthreads/stdio/tmpfile.c
new file mode 100644
index 00000000000..471bed33716
--- /dev/null
+++ b/mit-pthreads/stdio/tmpfile.c
@@ -0,0 +1,80 @@
+/*-
+ * 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$";
+#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)];
+
+ memcpy(buf, _PATH_TMP, sizeof(_PATH_TMP) - 1);
+ memcpy( buf + sizeof(_PATH_TMP) - 1, TRAILER, 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/mit-pthreads/stdio/tmpnam.c b/mit-pthreads/stdio/tmpnam.c
new file mode 100644
index 00000000000..8d65b21b037
--- /dev/null
+++ b/mit-pthreads/stdio/tmpnam.c
@@ -0,0 +1,55 @@
+/*-
+ * 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$";
+#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/mit-pthreads/stdio/ungetc.c b/mit-pthreads/stdio/ungetc.c
new file mode 100644
index 00000000000..e035f93d5f2
--- /dev/null
+++ b/mit-pthreads/stdio/ungetc.c
@@ -0,0 +1,155 @@
+/*-
+ * 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: @(#)ungetc.c 5.6 (Berkeley) 5/4/91";*/
+static char *rcsid = "$Id$";
+#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) memcpy((void *)(p + i), (void *)p, (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);
+ __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/mit-pthreads/stdio/vfprintf.c b/mit-pthreads/stdio/vfprintf.c
new file mode 100644
index 00000000000..fd990bb1889
--- /dev/null
+++ b/mit-pthreads/stdio/vfprintf.c
@@ -0,0 +1,788 @@
+/*-
+ * 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: @(#)vfprintf.c 5.50 (Berkeley) 12/16/92";*/
+static char *rcsid = "$Id$";
+#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 <stdarg.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;
+ pthread_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;
+ pthread_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
+
+#if defined (__alpha) && !defined(_GNUC_)
+#define quad_t long
+#define u_quad_t unsigned long
+#else /* 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)(size_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';
+/* #if !defined(__alpha__) && !defined(hpux) */
+#ifndef THIS_IS_NEVER_DEFINED
+ digits = __dtoa(value, mode, ndigits, decpt, &dsgn, &rve);
+#else
+ { char *ecvt(double,int,int*,int*);
+
+ digits = ecvt(value, ndigits, decpt, &dsgn);
+ rve = (digits + (int)strlen(digits));
+ }
+#endif
+ 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/mit-pthreads/stdio/vfscanf.c b/mit-pthreads/stdio/vfscanf.c
new file mode 100644
index 00000000000..f6d0a40aa51
--- /dev/null
+++ b/mit-pthreads/stdio/vfscanf.c
@@ -0,0 +1,750 @@
+/*-
+ * 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$";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#if __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/mit-pthreads/stdio/vprintf.c b/mit-pthreads/stdio/vprintf.c
new file mode 100644
index 00000000000..4999c4fb239
--- /dev/null
+++ b/mit-pthreads/stdio/vprintf.c
@@ -0,0 +1,51 @@
+/*-
+ * 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: @(#)vprintf.c 5.6 (Berkeley) 2/24/91";*/
+static char *rcsid = "$Id$";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdarg.h>
+#include <stdio.h>
+
+vprintf(fmt, ap)
+ char const *fmt;
+ pthread_va_list ap;
+{
+ return (vfprintf(stdout, fmt, ap));
+}
diff --git a/mit-pthreads/stdio/vscanf.c b/mit-pthreads/stdio/vscanf.c
new file mode 100644
index 00000000000..5a562f89528
--- /dev/null
+++ b/mit-pthreads/stdio/vscanf.c
@@ -0,0 +1,55 @@
+/*-
+ * 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
+ * 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$";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdarg.h>
+#include <stdio.h>
+
+vscanf(fmt, ap)
+ const char *fmt;
+ pthread_va_list ap;
+{
+ int r;
+ flockfile(stdin);
+ r = __svfscanf(stdin, fmt, ap);
+ funlockfile(stdin);
+ return(r);
+}
diff --git a/mit-pthreads/stdio/vsnprintf.c b/mit-pthreads/stdio/vsnprintf.c
new file mode 100644
index 00000000000..8fd1e6d8613
--- /dev/null
+++ b/mit-pthreads/stdio/vsnprintf.c
@@ -0,0 +1,65 @@
+/*-
+ * 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: @(#)vsnprintf.c 5.2 (Berkeley) 2/5/91";*/
+static char *rcsid = "$Id$";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+
+vsnprintf(str, n, fmt, ap)
+ char *str;
+ size_t n;
+ const char *fmt;
+ pthread_va_list ap;
+{
+ int ret;
+ FILE f;
+
+ if ((int)n < 1)
+ return (EOF);
+ 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;
+ return (ret);
+}
diff --git a/mit-pthreads/stdio/vsprintf.c b/mit-pthreads/stdio/vsprintf.c
new file mode 100644
index 00000000000..c6cdb708be3
--- /dev/null
+++ b/mit-pthreads/stdio/vsprintf.c
@@ -0,0 +1,62 @@
+/*-
+ * 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: @(#)vsprintf.c 5.5 (Berkeley) 2/5/91";*/
+static char *rcsid = "$Id$";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdarg.h>
+#include <limits.h>
+#include <stdio.h>
+
+vsprintf(str, fmt, ap)
+ char *str;
+ const char *fmt;
+ pthread_va_list ap;
+{
+ int ret;
+ FILE f;
+
+ f._file = -1;
+ 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/mit-pthreads/stdio/vsscanf.c b/mit-pthreads/stdio/vsscanf.c
new file mode 100644
index 00000000000..9d9cdcffeeb
--- /dev/null
+++ b/mit-pthreads/stdio/vsscanf.c
@@ -0,0 +1,62 @@
+/*-
+ * 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
+ * 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$";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
+vsscanf(str, fmt, ap)
+ const char *str;
+ const char *fmt;
+ pthread_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/mit-pthreads/stdio/wbuf.c b/mit-pthreads/stdio/wbuf.c
new file mode 100644
index 00000000000..58cb9ad058e
--- /dev/null
+++ b/mit-pthreads/stdio/wbuf.c
@@ -0,0 +1,89 @@
+/*-
+ * 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[] = "@(#)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/mit-pthreads/stdio/wsetup.c b/mit-pthreads/stdio/wsetup.c
new file mode 100644
index 00000000000..1c86f45a973
--- /dev/null
+++ b/mit-pthreads/stdio/wsetup.c
@@ -0,0 +1,91 @@
+/*-
+ * 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: @(#)wsetup.c 5.2 (Berkeley) 2/24/91";*/
+static char *rcsid = "$Id$";
+#endif /* LIBC_SCCS and not lint */
+
+#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 */
+ __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/mit-pthreads/stdio/xprintf.c b/mit-pthreads/stdio/xprintf.c
new file mode 100644
index 00000000000..668e8bc0605
--- /dev/null
+++ b/mit-pthreads/stdio/xprintf.c
@@ -0,0 +1,883 @@
+/*
+** 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$
+** VERSION: $Revision$
+** DATE: $Date$
+**
+** 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,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, 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,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, 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, va_list ap){
+ return vxprintf(fout,stdout,zFormat,ap);
+}
diff --git a/mit-pthreads/stdlib/GNUmakefile.inc b/mit-pthreads/stdlib/GNUmakefile.inc
new file mode 100755
index 00000000000..2f55ce8b217
--- /dev/null
+++ b/mit-pthreads/stdlib/GNUmakefile.inc
@@ -0,0 +1,7 @@
+# @(#)Makefile.inc 5.6 (Berkeley) 6/4/91
+
+# stdlib sources
+VPATH:= ${VPATH}:${srcdir}/stdlib
+
+SRCS:= abort.c exit.c strtod.c getopt.c rand.c random.c strtol.c strtoul.c \
+ system.c $(SRCS)
diff --git a/mit-pthreads/stdlib/Makefile.inc b/mit-pthreads/stdlib/Makefile.inc
new file mode 100644
index 00000000000..cc323d1d0e1
--- /dev/null
+++ b/mit-pthreads/stdlib/Makefile.inc
@@ -0,0 +1,10 @@
+# @(#)Makefile.inc 5.6 (Berkeley) 6/4/91
+
+# stdlib sources
+.PATH: ${srcdir}/${MACHINE}/stdlib ${srcdir}/stdlib
+
+SRCS+= exit.c strtod.c getopt.c rand.c random.c strtol.c strtoul.c
+
+# SRCS+=abort.c atexit.c atoi.c atof.c atol.c bsearch.c calloc.c div.c \
+# getenv.c heapsort.c labs.c ldiv.c malloc.c multibyte.c \
+# putenv.c qsort.c radixsort.c setenv.c system.c
diff --git a/mit-pthreads/stdlib/abort.c b/mit-pthreads/stdlib/abort.c
new file mode 100644
index 00000000000..474c35f6107
--- /dev/null
+++ b/mit-pthreads/stdlib/abort.c
@@ -0,0 +1,67 @@
+/*
+ * 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$";
+#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/mit-pthreads/stdlib/atexit.h b/mit-pthreads/stdlib/atexit.h
new file mode 100644
index 00000000000..d13dc588781
--- /dev/null
+++ b/mit-pthreads/stdlib/atexit.h
@@ -0,0 +1,46 @@
+/*-
+ * 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$
+ */
+
+/* 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/mit-pthreads/stdlib/exit.c b/mit-pthreads/stdlib/exit.c
new file mode 100644
index 00000000000..159a066d797
--- /dev/null
+++ b/mit-pthreads/stdlib/exit.c
@@ -0,0 +1,89 @@
+/*-
+ * 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$";
+#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/mit-pthreads/stdlib/getopt.c b/mit-pthreads/stdlib/getopt.c
new file mode 100644
index 00000000000..71fafd49490
--- /dev/null
+++ b/mit-pthreads/stdlib/getopt.c
@@ -0,0 +1,135 @@
+/*
+ * 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 <config.h>
+#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/mit-pthreads/stdlib/rand.c b/mit-pthreads/stdlib/rand.c
new file mode 100644
index 00000000000..9367dceed25
--- /dev/null
+++ b/mit-pthreads/stdlib/rand.c
@@ -0,0 +1,64 @@
+/*-
+ * 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/mit-pthreads/stdlib/random.c b/mit-pthreads/stdlib/random.c
new file mode 100644
index 00000000000..8cba96e7534
--- /dev/null
+++ b/mit-pthreads/stdlib/random.c
@@ -0,0 +1,389 @@
+/*
+ * 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/mit-pthreads/stdlib/strtod.c b/mit-pthreads/stdlib/strtod.c
new file mode 100644
index 00000000000..173ca1e4bdf
--- /dev/null
+++ b/mit-pthreads/stdlib/strtod.c
@@ -0,0 +1,178 @@
+/*
+** 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/mit-pthreads/stdlib/strtol.c b/mit-pthreads/stdlib/strtol.c
new file mode 100644
index 00000000000..91be90cc94c
--- /dev/null
+++ b/mit-pthreads/stdlib/strtol.c
@@ -0,0 +1,131 @@
+/*-
+ * 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$";
+#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/mit-pthreads/stdlib/strtoul.c b/mit-pthreads/stdlib/strtoul.c
new file mode 100644
index 00000000000..c6b6b01a0f2
--- /dev/null
+++ b/mit-pthreads/stdlib/strtoul.c
@@ -0,0 +1,109 @@
+/*
+ * 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$";
+#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/mit-pthreads/stdlib/system.c b/mit-pthreads/stdlib/system.c
new file mode 100644
index 00000000000..e7cc164fbc7
--- /dev/null
+++ b/mit-pthreads/stdlib/system.c
@@ -0,0 +1,83 @@
+/*
+ * 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$";
+#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/mit-pthreads/string/GNUmakefile.inc b/mit-pthreads/string/GNUmakefile.inc
new file mode 100755
index 00000000000..f3994d31479
--- /dev/null
+++ b/mit-pthreads/string/GNUmakefile.inc
@@ -0,0 +1,7 @@
+# from: @(#)Makefile.inc 5.21 (Berkeley) 5/24/91
+# $Id$
+
+# gen sources
+VPATH:= ${VPATH}:${srcdir}/string
+
+SRCS:= strtok.c $(SRCS)
diff --git a/mit-pthreads/string/Makefile.inc b/mit-pthreads/string/Makefile.inc
new file mode 100644
index 00000000000..4a5536bac4a
--- /dev/null
+++ b/mit-pthreads/string/Makefile.inc
@@ -0,0 +1,8 @@
+# from: @(#)Makefile.inc 5.21 (Berkeley) 5/24/91
+# $Id$
+
+# string sources
+.PATH: ${srcdir}/string
+
+SRCS+= strtok.c
+
diff --git a/mit-pthreads/string/strtok.c b/mit-pthreads/string/strtok.c
new file mode 100644
index 00000000000..4c08dcc4d37
--- /dev/null
+++ b/mit-pthreads/string/strtok.c
@@ -0,0 +1,119 @@
+/*
+ * 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$";
+#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/mit-pthreads/tests/.cvsignore b/mit-pthreads/tests/.cvsignore
new file mode 100644
index 00000000000..f3c7a7c5da6
--- /dev/null
+++ b/mit-pthreads/tests/.cvsignore
@@ -0,0 +1 @@
+Makefile
diff --git a/mit-pthreads/tests/Makefile.in b/mit-pthreads/tests/Makefile.in
new file mode 100644
index 00000000000..6e01b6bffc3
--- /dev/null
+++ b/mit-pthreads/tests/Makefile.in
@@ -0,0 +1,164 @@
+# === 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/mit-pthreads/tests/README b/mit-pthreads/tests/README
new file mode 100755
index 00000000000..bb4a3e7ce01
--- /dev/null
+++ b/mit-pthreads/tests/README
@@ -0,0 +1,26 @@
+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/mit-pthreads/tests/bench_fcntl.c b/mit-pthreads/tests/bench_fcntl.c
new file mode 100644
index 00000000000..046046adda4
--- /dev/null
+++ b/mit-pthreads/tests/bench_fcntl.c
@@ -0,0 +1,82 @@
+/* ==== 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/mit-pthreads/tests/bench_pipe.c b/mit-pthreads/tests/bench_pipe.c
new file mode 100644
index 00000000000..8555cf37f67
--- /dev/null
+++ b/mit-pthreads/tests/bench_pipe.c
@@ -0,0 +1,115 @@
+/* ==== 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/mit-pthreads/tests/bench_read.c b/mit-pthreads/tests/bench_read.c
new file mode 100644
index 00000000000..28c8469e270
--- /dev/null
+++ b/mit-pthreads/tests/bench_read.c
@@ -0,0 +1,88 @@
+/* ==== 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/mit-pthreads/tests/p_bench_getpid.c b/mit-pthreads/tests/p_bench_getpid.c
new file mode 100644
index 00000000000..d972d075c1d
--- /dev/null
+++ b/mit-pthreads/tests/p_bench_getpid.c
@@ -0,0 +1,78 @@
+/* ==== 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/mit-pthreads/tests/p_bench_mutex.c b/mit-pthreads/tests/p_bench_mutex.c
new file mode 100644
index 00000000000..e3179f08072
--- /dev/null
+++ b/mit-pthreads/tests/p_bench_mutex.c
@@ -0,0 +1,78 @@
+/* ==== 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/mit-pthreads/tests/p_bench_pthread_create.c b/mit-pthreads/tests/p_bench_pthread_create.c
new file mode 100644
index 00000000000..b31b680c665
--- /dev/null
+++ b/mit-pthreads/tests/p_bench_pthread_create.c
@@ -0,0 +1,92 @@
+/* ==== 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/mit-pthreads/tests/p_bench_read.c b/mit-pthreads/tests/p_bench_read.c
new file mode 100644
index 00000000000..52a6aca7706
--- /dev/null
+++ b/mit-pthreads/tests/p_bench_read.c
@@ -0,0 +1,103 @@
+/* ==== 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/mit-pthreads/tests/p_bench_semaphore.c b/mit-pthreads/tests/p_bench_semaphore.c
new file mode 100644
index 00000000000..b3bce340b95
--- /dev/null
+++ b/mit-pthreads/tests/p_bench_semaphore.c
@@ -0,0 +1,82 @@
+/* ==== 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/mit-pthreads/tests/p_bench_yield.c b/mit-pthreads/tests/p_bench_yield.c
new file mode 100644
index 00000000000..bb6d86be09e
--- /dev/null
+++ b/mit-pthreads/tests/p_bench_yield.c
@@ -0,0 +1,123 @@
+/* ==== 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/mit-pthreads/tests/test_create.c b/mit-pthreads/tests/test_create.c
new file mode 100644
index 00000000000..2d82db07c5f
--- /dev/null
+++ b/mit-pthreads/tests/test_create.c
@@ -0,0 +1,35 @@
+/* ==== 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/mit-pthreads/tests/test_cwd.c b/mit-pthreads/tests/test_cwd.c
new file mode 100644
index 00000000000..979c173d5fc
--- /dev/null
+++ b/mit-pthreads/tests/test_cwd.c
@@ -0,0 +1,11 @@
+#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/mit-pthreads/tests/test_execve.c b/mit-pthreads/tests/test_execve.c
new file mode 100644
index 00000000000..f7988457df9
--- /dev/null
+++ b/mit-pthreads/tests/test_execve.c
@@ -0,0 +1,57 @@
+/* ==== 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/mit-pthreads/tests/test_fcntl.c b/mit-pthreads/tests/test_fcntl.c
new file mode 100644
index 00000000000..60bc77ce464
--- /dev/null
+++ b/mit-pthreads/tests/test_fcntl.c
@@ -0,0 +1,32 @@
+#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/mit-pthreads/tests/test_fork.c b/mit-pthreads/tests/test_fork.c
new file mode 100644
index 00000000000..4c2125e678a
--- /dev/null
+++ b/mit-pthreads/tests/test_fork.c
@@ -0,0 +1,60 @@
+/* ==== 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/mit-pthreads/tests/test_netdb.c b/mit-pthreads/tests/test_netdb.c
new file mode 100644
index 00000000000..a944579237f
--- /dev/null
+++ b/mit-pthreads/tests/test_netdb.c
@@ -0,0 +1,110 @@
+/* ==== 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/mit-pthreads/tests/test_pause.c b/mit-pthreads/tests/test_pause.c
new file mode 100644
index 00000000000..46c5080e43e
--- /dev/null
+++ b/mit-pthreads/tests/test_pause.c
@@ -0,0 +1,19 @@
+#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/mit-pthreads/tests/test_preemption.c b/mit-pthreads/tests/test_preemption.c
new file mode 100644
index 00000000000..9181c127fe4
--- /dev/null
+++ b/mit-pthreads/tests/test_preemption.c
@@ -0,0 +1,38 @@
+/* ==== 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/mit-pthreads/tests/test_preemption_float.c b/mit-pthreads/tests/test_preemption_float.c
new file mode 100644
index 00000000000..e12192044c6
--- /dev/null
+++ b/mit-pthreads/tests/test_preemption_float.c
@@ -0,0 +1,98 @@
+/* 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/mit-pthreads/tests/test_pthread_cond_timedwait.c b/mit-pthreads/tests/test_pthread_cond_timedwait.c
new file mode 100644
index 00000000000..fe21408f11e
--- /dev/null
+++ b/mit-pthreads/tests/test_pthread_cond_timedwait.c
@@ -0,0 +1,93 @@
+/* ==== 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/mit-pthreads/tests/test_pthread_join.c b/mit-pthreads/tests/test_pthread_join.c
new file mode 100644
index 00000000000..fd2ec6a78b2
--- /dev/null
+++ b/mit-pthreads/tests/test_pthread_join.c
@@ -0,0 +1,78 @@
+/* ==== 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/mit-pthreads/tests/test_pthread_mutex.c b/mit-pthreads/tests/test_pthread_mutex.c
new file mode 100644
index 00000000000..2fb0574f5cb
--- /dev/null
+++ b/mit-pthreads/tests/test_pthread_mutex.c
@@ -0,0 +1,221 @@
+/* ==== 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/mit-pthreads/tests/test_pw.c b/mit-pthreads/tests/test_pw.c
new file mode 100644
index 00000000000..0ef6d428180
--- /dev/null
+++ b/mit-pthreads/tests/test_pw.c
@@ -0,0 +1,20 @@
+#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/mit-pthreads/tests/test_readdir.c b/mit-pthreads/tests/test_readdir.c
new file mode 100644
index 00000000000..6de1841bdbc
--- /dev/null
+++ b/mit-pthreads/tests/test_readdir.c
@@ -0,0 +1,42 @@
+/* ==== 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/mit-pthreads/tests/test_select.c b/mit-pthreads/tests/test_select.c
new file mode 100644
index 00000000000..0401d77a666
--- /dev/null
+++ b/mit-pthreads/tests/test_select.c
@@ -0,0 +1,115 @@
+#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/mit-pthreads/tests/test_setjmp.c b/mit-pthreads/tests/test_setjmp.c
new file mode 100644
index 00000000000..ea24ecd63bc
--- /dev/null
+++ b/mit-pthreads/tests/test_setjmp.c
@@ -0,0 +1,13 @@
+#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/mit-pthreads/tests/test_sleep.c b/mit-pthreads/tests/test_sleep.c
new file mode 100644
index 00000000000..f228d08a2ca
--- /dev/null
+++ b/mit-pthreads/tests/test_sleep.c
@@ -0,0 +1,46 @@
+/* ==== 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/mit-pthreads/tests/test_sock_1.c b/mit-pthreads/tests/test_sock_1.c
new file mode 100644
index 00000000000..e23755a67dc
--- /dev/null
+++ b/mit-pthreads/tests/test_sock_1.c
@@ -0,0 +1,204 @@
+/* ==== 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) {
+ printf("Error: sock_accept:accept()\n");
+ 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/mit-pthreads/tests/test_sock_2.c b/mit-pthreads/tests/test_sock_2.c
new file mode 100644
index 00000000000..5ec82fd7499
--- /dev/null
+++ b/mit-pthreads/tests/test_sock_2.c
@@ -0,0 +1,116 @@
+/* ==== 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) {
+ 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) {
+ printf("Error: sock_accept:accept()\n");
+ 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) {
+ printf("Error: sock_accept:accept()\n");
+ exit(1);
+ }
+
+ /* Setup a write thread */
+ if (pthread_create(&thread, NULL, sock_write, &fd)) {
+ printf("Error: sock_accept:pthread_create(sock_write)\n");
+ exit(1);
+ }
+ if ((tmp = read(fd, buf, 1024)) <= 0) {
+ tmp = read(fd, buf, 1024);
+ printf("Error: sock_accept:read() == %d\n", tmp);
+ exit(1);
+ }
+ printf("%s\n", buf);
+ close(fd);
+}
+
+main()
+{
+ pthread_t thread;
+ int i;
+
+ switch(fork()) {
+ case -1:
+ printf("Error: main:fork()\n");
+ 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)) {
+ printf("Error: main:pthread_create(sock_accept)\n");
+ exit(1);
+ }
+ pthread_exit(NULL);
+}
diff --git a/mit-pthreads/tests/test_sock_2a.c b/mit-pthreads/tests/test_sock_2a.c
new file mode 100644
index 00000000000..9f767b7c675
--- /dev/null
+++ b/mit-pthreads/tests/test_sock_2a.c
@@ -0,0 +1,87 @@
+/* ==== 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) {
+ 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 ((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 */
+
+ 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);
+}
+
+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)) {
+ printf("Error: main:pthread_create(sock_connect)\n");
+ 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/mit-pthreads/tests/test_stdio_1.c b/mit-pthreads/tests/test_stdio_1.c
new file mode 100644
index 00000000000..648343a2c9d
--- /dev/null
+++ b/mit-pthreads/tests/test_stdio_1.c
@@ -0,0 +1,124 @@
+#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/mit-pthreads/tests/test_switch.c b/mit-pthreads/tests/test_switch.c
new file mode 100644
index 00000000000..4c184158fb8
--- /dev/null
+++ b/mit-pthreads/tests/test_switch.c
@@ -0,0 +1,97 @@
+/* ==== 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
+}