From b42951578188c5aab5c9f8cbcde4a743f8092cdc Mon Sep 17 00:00:00 2001 From: cvs2svn Date: Sun, 2 Apr 2000 07:41:18 +0000 Subject: This commit was manufactured by cvs2svn to create branch 'ALSA'. --- lib/libc/Makefile | 44 - lib/libc/Makefile.inc | 56 - lib/libc/alpha/Makefile.inc | 9 - lib/libc/alpha/SYS.h | 132 - lib/libc/alpha/gen/Makefile.inc | 45 - lib/libc/alpha/gen/_setjmp.S | 134 - lib/libc/alpha/gen/divrem.m4 | 197 - lib/libc/alpha/gen/fabs.S | 35 - lib/libc/alpha/gen/flt_rounds.c | 57 - lib/libc/alpha/gen/fpgetmask.c | 49 - lib/libc/alpha/gen/fpgetround.c | 48 - lib/libc/alpha/gen/fpgetsticky.c | 48 - lib/libc/alpha/gen/fpsetmask.c | 51 - lib/libc/alpha/gen/fpsetround.c | 55 - lib/libc/alpha/gen/fpsetsticky.c | 55 - lib/libc/alpha/gen/frexp.c | 53 - lib/libc/alpha/gen/infinity.c | 33 - lib/libc/alpha/gen/isinf.c | 52 - lib/libc/alpha/gen/ldexp.c | 134 - lib/libc/alpha/gen/modf.c | 104 - lib/libc/alpha/gen/setjmp.S | 136 - lib/libc/alpha/gen/sigsetjmp.S | 73 - lib/libc/alpha/net/Makefile.inc | 3 - lib/libc/alpha/net/byte_swap_2.S | 47 - lib/libc/alpha/net/byte_swap_4.S | 53 - lib/libc/alpha/net/htonl.S | 32 - lib/libc/alpha/net/htons.S | 32 - lib/libc/alpha/net/ntohl.S | 32 - lib/libc/alpha/net/ntohs.S | 32 - lib/libc/alpha/stdlib/Makefile.inc | 3 - lib/libc/alpha/string/Makefile.inc | 3 - lib/libc/alpha/string/bcopy.S | 288 - lib/libc/alpha/string/bzero.S | 110 - lib/libc/alpha/string/ffs.S | 91 - lib/libc/alpha/string/memcpy.S | 4 - lib/libc/alpha/string/memmove.S | 4 - lib/libc/alpha/sys/Makefile.inc | 17 - lib/libc/alpha/sys/Ovfork.S | 35 - lib/libc/alpha/sys/brk.S | 50 - lib/libc/alpha/sys/cerror.S | 54 - lib/libc/alpha/sys/exect.S | 35 - lib/libc/alpha/sys/fork.S | 35 - lib/libc/alpha/sys/pipe.S | 37 - lib/libc/alpha/sys/ptrace.S | 37 - lib/libc/alpha/sys/sbrk.S | 50 - lib/libc/alpha/sys/setlogin.S | 37 - lib/libc/alpha/sys/sigreturn.S | 38 - lib/libc/alpha/sys/syscall.S | 32 - lib/libc/amd64/SYS.h | 94 - lib/libc/amd64/gen/Makefile.inc | 5 - lib/libc/amd64/gen/_setjmp.S | 89 - lib/libc/amd64/gen/frexp.c | 67 - lib/libc/amd64/gen/infinity.c | 9 - lib/libc/amd64/gen/isinf.c | 68 - lib/libc/amd64/gen/ldexp.c | 74 - lib/libc/amd64/gen/setjmp.S | 116 - lib/libc/amd64/gen/sigsetjmp.S | 127 - lib/libc/amd64/net/Makefile.inc | 4 - lib/libc/amd64/net/htonl.S | 53 - lib/libc/amd64/net/htons.S | 51 - lib/libc/amd64/net/ntohl.S | 53 - lib/libc/amd64/net/ntohs.S | 51 - lib/libc/amd64/sys/Makefile.inc | 28 - lib/libc/amd64/sys/brk.S | 91 - lib/libc/amd64/sys/cerror.S | 70 - lib/libc/amd64/sys/exect.S | 56 - lib/libc/amd64/sys/pipe.S | 51 - lib/libc/amd64/sys/ptrace.S | 62 - lib/libc/amd64/sys/reboot.S | 47 - lib/libc/amd64/sys/sbrk.S | 95 - lib/libc/amd64/sys/setlogin.S | 59 - lib/libc/amd64/sys/sigreturn.S | 52 - lib/libc/amd64/sys/vfork.S | 72 - lib/libc/compat-43/Makefile.inc | 16 - lib/libc/compat-43/creat.2 | 62 - lib/libc/compat-43/creat.c | 56 - lib/libc/compat-43/gethostid.3 | 76 - lib/libc/compat-43/gethostid.c | 59 - lib/libc/compat-43/getwd.c | 54 - lib/libc/compat-43/killpg.2 | 97 - lib/libc/compat-43/killpg.c | 59 - lib/libc/compat-43/sethostid.c | 57 - lib/libc/compat-43/setpgrp.c | 50 - lib/libc/compat-43/setrgid.c | 50 - lib/libc/compat-43/setruid.3 | 80 - lib/libc/compat-43/setruid.c | 50 - lib/libc/compat-43/sigblock.2 | 85 - lib/libc/compat-43/sigcompat.c | 113 - lib/libc/compat-43/sigpause.2 | 75 - lib/libc/compat-43/sigsetmask.2 | 83 - lib/libc/compat-43/sigvec.2 | 327 - lib/libc/db/Makefile.inc | 11 - lib/libc/db/README | 40 - lib/libc/db/btree/Makefile.inc | 8 - lib/libc/db/btree/bt_close.c | 184 - lib/libc/db/btree/bt_conv.c | 221 - lib/libc/db/btree/bt_debug.c | 329 - lib/libc/db/btree/bt_delete.c | 657 -- lib/libc/db/btree/bt_get.c | 105 - lib/libc/db/btree/bt_open.c | 447 -- lib/libc/db/btree/bt_overflow.c | 228 - lib/libc/db/btree/bt_page.c | 100 - lib/libc/db/btree/bt_put.c | 320 - lib/libc/db/btree/bt_search.c | 213 - lib/libc/db/btree/bt_seq.c | 460 -- lib/libc/db/btree/bt_split.c | 828 --- lib/libc/db/btree/bt_utils.c | 260 - lib/libc/db/btree/btree.h | 383 - lib/libc/db/btree/extern.h | 70 - lib/libc/db/changelog | 103 - lib/libc/db/db/Makefile.inc | 6 - lib/libc/db/db/db.c | 99 - lib/libc/db/docs/hash.usenix.ps | 12209 ------------------------------- lib/libc/db/docs/libtp.usenix.ps | 12340 -------------------------------- lib/libc/db/hash/Makefile.inc | 7 - lib/libc/db/hash/README | 72 - lib/libc/db/hash/extern.h | 65 - lib/libc/db/hash/hash.c | 1003 --- lib/libc/db/hash/hash.h | 293 - lib/libc/db/hash/hash_bigkey.c | 667 -- lib/libc/db/hash/hash_buf.c | 355 - lib/libc/db/hash/hash_func.c | 212 - lib/libc/db/hash/hash_log2.c | 54 - lib/libc/db/hash/hash_page.c | 946 --- lib/libc/db/hash/hsearch.c | 107 - lib/libc/db/hash/ndbm.c | 229 - lib/libc/db/hash/page.h | 92 - lib/libc/db/hash/search.h | 51 - lib/libc/db/man/Makefile.inc | 10 - lib/libc/db/man/btree.3 | 234 - lib/libc/db/man/dbopen.3 | 477 -- lib/libc/db/man/hash.3 | 160 - lib/libc/db/man/mpool.3 | 220 - lib/libc/db/man/recno.3 | 217 - lib/libc/db/mpool/Makefile.inc | 6 - lib/libc/db/mpool/README | 7 - lib/libc/db/mpool/mpool.c | 465 -- lib/libc/db/mpool/mpool.libtp | 746 -- lib/libc/db/recno/Makefile.inc | 7 - lib/libc/db/recno/extern.h | 54 - lib/libc/db/recno/rec_close.c | 185 - lib/libc/db/recno/rec_delete.c | 197 - lib/libc/db/recno/rec_get.c | 311 - lib/libc/db/recno/rec_open.c | 243 - lib/libc/db/recno/rec_put.c | 279 - lib/libc/db/recno/rec_search.c | 126 - lib/libc/db/recno/rec_seq.c | 131 - lib/libc/db/recno/rec_utils.c | 122 - lib/libc/db/recno/recno.h | 39 - lib/libc/db/test/Makefile | 23 - lib/libc/db/test/README | 74 - lib/libc/db/test/btree.tests/main.c | 765 -- lib/libc/db/test/dbtest.c | 753 -- lib/libc/db/test/hash.tests/driver2.c | 114 - lib/libc/db/test/hash.tests/makedb.sh | 13 - lib/libc/db/test/hash.tests/tcreat3.c | 105 - lib/libc/db/test/hash.tests/tdel.c | 122 - lib/libc/db/test/hash.tests/testit | 147 - lib/libc/db/test/hash.tests/thash4.c | 132 - lib/libc/db/test/hash.tests/tread2.c | 105 - lib/libc/db/test/hash.tests/tseq.c | 88 - lib/libc/db/test/hash.tests/tverify.c | 107 - lib/libc/db/test/run.test | 705 -- lib/libc/gen/Makefile.inc | 122 - lib/libc/gen/__xuname.c | 125 - lib/libc/gen/_rand48.c | 46 - lib/libc/gen/_spinlock_stub.c | 64 - lib/libc/gen/alarm.3 | 96 - lib/libc/gen/alarm.c | 59 - lib/libc/gen/arc4random.3 | 87 - lib/libc/gen/arc4random.c | 172 - lib/libc/gen/assert.c | 52 - lib/libc/gen/clock.3 | 69 - lib/libc/gen/clock.c | 57 - lib/libc/gen/closedir.c | 64 - lib/libc/gen/confstr.3 | 126 - lib/libc/gen/confstr.c | 86 - lib/libc/gen/crypt.c | 100 - lib/libc/gen/ctermid.3 | 107 - lib/libc/gen/ctermid.c | 61 - lib/libc/gen/daemon.3 | 80 - lib/libc/gen/daemon.c | 73 - lib/libc/gen/devname.3 | 69 - lib/libc/gen/devname.c | 105 - lib/libc/gen/directory.3 | 198 - lib/libc/gen/disklabel.c | 177 - lib/libc/gen/dladdr.3 | 121 - lib/libc/gen/dlfcn.c | 182 - lib/libc/gen/dllockinit.3 | 111 - lib/libc/gen/dlopen.3 | 230 - lib/libc/gen/drand48.c | 22 - lib/libc/gen/erand48.c | 23 - lib/libc/gen/err.3 | 204 - lib/libc/gen/err.c | 208 - lib/libc/gen/errlst.c | 148 - lib/libc/gen/exec.3 | 291 - lib/libc/gen/exec.c | 318 - lib/libc/gen/fnmatch.3 | 149 - lib/libc/gen/fnmatch.c | 231 - lib/libc/gen/frexp.3 | 86 - lib/libc/gen/fstab.c | 264 - lib/libc/gen/ftok.3 | 83 - lib/libc/gen/ftok.c | 47 - lib/libc/gen/fts-compat.c | 1114 --- lib/libc/gen/fts-compat.h | 128 - lib/libc/gen/fts.3 | 755 -- lib/libc/gen/fts.c | 1114 --- lib/libc/gen/getbootfile.3 | 70 - lib/libc/gen/getbootfile.c | 55 - lib/libc/gen/getbsize.3 | 80 - lib/libc/gen/getbsize.c | 106 - lib/libc/gen/getcap.3 | 529 -- lib/libc/gen/getcap.c | 1046 --- lib/libc/gen/getcwd.3 | 156 - lib/libc/gen/getcwd.c | 288 - lib/libc/gen/getdiskbyname.3 | 65 - lib/libc/gen/getdomainname.3 | 99 - lib/libc/gen/getdomainname.c | 61 - lib/libc/gen/getfsent.3 | 151 - lib/libc/gen/getgrent.3 | 206 - lib/libc/gen/getgrent.c | 553 -- lib/libc/gen/getgrouplist.3 | 94 - lib/libc/gen/getgrouplist.c | 91 - lib/libc/gen/gethostname.3 | 98 - lib/libc/gen/gethostname.c | 55 - lib/libc/gen/getloadavg.3 | 67 - lib/libc/gen/getloadavg.c | 71 - lib/libc/gen/getlogin.c | 80 - lib/libc/gen/getmntinfo.3 | 111 - lib/libc/gen/getmntinfo.c | 70 - lib/libc/gen/getnetgrent.3 | 129 - lib/libc/gen/getnetgrent.c | 634 -- lib/libc/gen/getobjformat.3 | 124 - lib/libc/gen/getobjformat.c | 119 - lib/libc/gen/getosreldate.c | 63 - lib/libc/gen/getpagesize.3 | 61 - lib/libc/gen/getpagesize.c | 61 - lib/libc/gen/getpass.3 | 95 - lib/libc/gen/getpass.c | 97 - lib/libc/gen/getpwent.3 | 220 - lib/libc/gen/getpwent.c | 860 --- lib/libc/gen/getttyent.3 | 210 - lib/libc/gen/getttyent.c | 266 - lib/libc/gen/getusershell.3 | 100 - lib/libc/gen/getusershell.c | 139 - lib/libc/gen/getvfsbyname.3 | 98 - lib/libc/gen/getvfsbyname.c | 82 - lib/libc/gen/getvfsent.3 | 163 - lib/libc/gen/getvfsent.c | 177 - lib/libc/gen/glob.3 | 447 -- lib/libc/gen/glob.c | 864 --- lib/libc/gen/initgroups.3 | 84 - lib/libc/gen/initgroups.c | 60 - lib/libc/gen/isatty.c | 63 - lib/libc/gen/isinf.3 | 78 - lib/libc/gen/jrand48.c | 21 - lib/libc/gen/lcong48.c | 30 - lib/libc/gen/ldexp.3 | 78 - lib/libc/gen/lockf.3 | 255 - lib/libc/gen/lockf.c | 92 - lib/libc/gen/lrand48.c | 23 - lib/libc/gen/modf.3 | 73 - lib/libc/gen/mrand48.c | 23 - lib/libc/gen/msgctl.3 | 213 - lib/libc/gen/msgctl.c | 15 - lib/libc/gen/msgget.3 | 137 - lib/libc/gen/msgget.c | 14 - lib/libc/gen/msgrcv.3 | 211 - lib/libc/gen/msgrcv.c | 17 - lib/libc/gen/msgsnd.3 | 168 - lib/libc/gen/msgsnd.c | 16 - lib/libc/gen/nice.3 | 70 - lib/libc/gen/nice.c | 58 - lib/libc/gen/nlist.3 | 79 - lib/libc/gen/nlist.c | 413 -- lib/libc/gen/nrand48.c | 21 - lib/libc/gen/ntp_gettime.c | 55 - lib/libc/gen/opendir.c | 276 - lib/libc/gen/pause.3 | 84 - lib/libc/gen/pause.c | 54 - lib/libc/gen/popen.3 | 200 - lib/libc/gen/popen.c | 191 - lib/libc/gen/psignal.3 | 111 - lib/libc/gen/psignal.c | 65 - lib/libc/gen/pw_scan.c | 174 - lib/libc/gen/pw_scan.h | 40 - lib/libc/gen/pwcache.3 | 95 - lib/libc/gen/pwcache.c | 119 - lib/libc/gen/raise.3 | 78 - lib/libc/gen/raise.c | 46 - lib/libc/gen/rand48.3 | 165 - lib/libc/gen/rand48.h | 30 - lib/libc/gen/readdir.c | 125 - lib/libc/gen/rewinddir.c | 50 - lib/libc/gen/scandir.3 | 107 - lib/libc/gen/scandir.c | 146 - lib/libc/gen/seed48.c | 36 - lib/libc/gen/seekdir.c | 54 - lib/libc/gen/sem_destroy.3 | 83 - lib/libc/gen/sem_getvalue.3 | 77 - lib/libc/gen/sem_init.3 | 100 - lib/libc/gen/sem_open.3 | 80 - lib/libc/gen/sem_post.3 | 71 - lib/libc/gen/sem_wait.3 | 92 - lib/libc/gen/semconfig.c | 13 - lib/libc/gen/semctl.c | 42 - lib/libc/gen/semget.c | 15 - lib/libc/gen/semop.c | 15 - lib/libc/gen/setdomainname.c | 57 - lib/libc/gen/setflags.3 | 78 - lib/libc/gen/setflags.c | 154 - lib/libc/gen/setflagsbyname.3 | 78 - lib/libc/gen/setflagsbyname.c | 154 - lib/libc/gen/sethostname.c | 58 - lib/libc/gen/setjmp.3 | 174 - lib/libc/gen/setjmperr.c | 55 - lib/libc/gen/setmode.3 | 116 - lib/libc/gen/setmode.c | 457 -- lib/libc/gen/setproctitle.3 | 101 - lib/libc/gen/setproctitle.c | 162 - lib/libc/gen/shmat.c | 19 - lib/libc/gen/shmctl.c | 19 - lib/libc/gen/shmdt.c | 17 - lib/libc/gen/shmget.c | 19 - lib/libc/gen/siginterrupt.3 | 112 - lib/libc/gen/siginterrupt.c | 62 - lib/libc/gen/siglist.c | 110 - lib/libc/gen/signal.3 | 233 - lib/libc/gen/signal.c | 60 - lib/libc/gen/sigsetops.3 | 114 - lib/libc/gen/sigsetops.c | 108 - lib/libc/gen/sleep.3 | 84 - lib/libc/gen/sleep.c | 73 - lib/libc/gen/srand48.c | 30 - lib/libc/gen/stringlist.3 | 122 - lib/libc/gen/stringlist.c | 120 - lib/libc/gen/strtofflags.3 | 78 - lib/libc/gen/strtofflags.c | 154 - lib/libc/gen/sysconf.3 | 187 - lib/libc/gen/sysconf.c | 299 - lib/libc/gen/sysctl.3 | 768 -- lib/libc/gen/sysctl.c | 182 - lib/libc/gen/sysctlbyname.c | 37 - lib/libc/gen/syslog.3 | 276 - lib/libc/gen/syslog.c | 365 - lib/libc/gen/tcgetpgrp.3 | 80 - lib/libc/gen/tcsendbreak.3 | 155 - lib/libc/gen/tcsetattr.3 | 331 - lib/libc/gen/tcsetpgrp.3 | 101 - lib/libc/gen/telldir.c | 157 - lib/libc/gen/termios.c | 250 - lib/libc/gen/time.3 | 86 - lib/libc/gen/time.c | 52 - lib/libc/gen/times.3 | 138 - lib/libc/gen/times.c | 67 - lib/libc/gen/timezone.3 | 68 - lib/libc/gen/timezone.c | 135 - lib/libc/gen/ttyname.3 | 129 - lib/libc/gen/ttyname.c | 222 - lib/libc/gen/ttyslot.c | 68 - lib/libc/gen/tzset.3 | 326 - lib/libc/gen/ualarm.3 | 99 - lib/libc/gen/ualarm.c | 65 - lib/libc/gen/uname.3 | 94 - lib/libc/gen/uname.c | 125 - lib/libc/gen/unvis.3 | 164 - lib/libc/gen/unvis.c | 247 - lib/libc/gen/usleep.3 | 81 - lib/libc/gen/usleep.c | 54 - lib/libc/gen/utime.3 | 88 - lib/libc/gen/utime.c | 57 - lib/libc/gen/valloc.3 | 76 - lib/libc/gen/valloc.c | 50 - lib/libc/gen/vis.3 | 265 - lib/libc/gen/vis.c | 187 - lib/libc/gen/wait.c | 54 - lib/libc/gen/wait3.c | 50 - lib/libc/gen/waitpid.c | 60 - lib/libc/gmon/Makefile.inc | 17 - lib/libc/gmon/gmon.c | 263 - lib/libc/gmon/mcount.c | 325 - lib/libc/gmon/moncontrol.3 | 106 - lib/libc/i386/DEFS.h | 41 - lib/libc/i386/SYS.h | 94 - lib/libc/i386/gen/Makefile.inc | 5 - lib/libc/i386/gen/_setjmp.S | 89 - lib/libc/i386/gen/alloca.S | 60 - lib/libc/i386/gen/fabs.S | 49 - lib/libc/i386/gen/frexp.c | 67 - lib/libc/i386/gen/infinity.c | 9 - lib/libc/i386/gen/isinf.c | 68 - lib/libc/i386/gen/ldexp.c | 74 - lib/libc/i386/gen/modf.S | 79 - lib/libc/i386/gen/setjmp.S | 116 - lib/libc/i386/gen/sigsetjmp.S | 127 - lib/libc/i386/net/Makefile.inc | 4 - lib/libc/i386/net/htonl.S | 53 - lib/libc/i386/net/htons.S | 51 - lib/libc/i386/net/ntohl.S | 53 - lib/libc/i386/net/ntohs.S | 51 - lib/libc/i386/stdlib/Makefile.inc | 4 - lib/libc/i386/stdlib/abs.S | 51 - lib/libc/i386/stdlib/div.S | 47 - lib/libc/i386/stdlib/labs.S | 51 - lib/libc/i386/stdlib/ldiv.S | 47 - lib/libc/i386/string/Makefile.inc | 6 - lib/libc/i386/string/bcmp.S | 70 - lib/libc/i386/string/bcopy.S | 103 - lib/libc/i386/string/bzero.S | 87 - lib/libc/i386/string/ffs.S | 59 - lib/libc/i386/string/index.S | 69 - lib/libc/i386/string/memchr.S | 64 - lib/libc/i386/string/memcmp.S | 81 - lib/libc/i386/string/memcpy.S | 2 - lib/libc/i386/string/memmove.S | 2 - lib/libc/i386/string/memset.S | 95 - lib/libc/i386/string/rindex.S | 70 - lib/libc/i386/string/strcat.S | 106 - lib/libc/i386/string/strchr.S | 69 - lib/libc/i386/string/strcmp.S | 125 - lib/libc/i386/string/strcpy.S | 95 - lib/libc/i386/string/strlen.S | 59 - lib/libc/i386/string/strncmp.S | 172 - lib/libc/i386/string/strrchr.S | 70 - lib/libc/i386/string/swab.S | 105 - lib/libc/i386/sys/Makefile.inc | 28 - lib/libc/i386/sys/Ovfork.S | 72 - lib/libc/i386/sys/brk.S | 91 - lib/libc/i386/sys/cerror.S | 70 - lib/libc/i386/sys/exect.S | 56 - lib/libc/i386/sys/fork.S | 51 - lib/libc/i386/sys/i386_get_ioperm.2 | 84 - lib/libc/i386/sys/i386_get_ioperm.c | 51 - lib/libc/i386/sys/i386_get_ldt.2 | 98 - lib/libc/i386/sys/i386_get_ldt.c | 49 - lib/libc/i386/sys/i386_set_ioperm.c | 45 - lib/libc/i386/sys/i386_set_ldt.c | 49 - lib/libc/i386/sys/i386_vm86.2 | 96 - lib/libc/i386/sys/i386_vm86.c | 44 - lib/libc/i386/sys/pipe.S | 51 - lib/libc/i386/sys/ptrace.S | 62 - lib/libc/i386/sys/reboot.S | 47 - lib/libc/i386/sys/rfork.S | 51 - lib/libc/i386/sys/sbrk.S | 95 - lib/libc/i386/sys/setlogin.S | 59 - lib/libc/i386/sys/sigreturn.S | 52 - lib/libc/i386/sys/syscall.S | 57 - lib/libc/include/libc_private.h | 66 - lib/libc/include/spinlock.h | 71 - lib/libc/locale/Makefile.inc | 26 - lib/libc/locale/ansi.c | 151 - lib/libc/locale/big5.c | 120 - lib/libc/locale/collate.c | 211 - lib/libc/locale/collate.h | 67 - lib/libc/locale/collcmp.c | 84 - lib/libc/locale/ctype.3 | 145 - lib/libc/locale/euc.4 | 242 - lib/libc/locale/euc.5 | 242 - lib/libc/locale/euc.c | 223 - lib/libc/locale/frune.c | 103 - lib/libc/locale/isalnum.3 | 91 - lib/libc/locale/isalpha.3 | 89 - lib/libc/locale/isascii.3 | 59 - lib/libc/locale/isblank.3 | 58 - lib/libc/locale/iscntrl.3 | 79 - lib/libc/locale/isctype.c | 233 - lib/libc/locale/isdigit.3 | 74 - lib/libc/locale/isgraph.3 | 91 - lib/libc/locale/islower.3 | 79 - lib/libc/locale/isprint.3 | 91 - lib/libc/locale/ispunct.3 | 82 - lib/libc/locale/isspace.3 | 74 - lib/libc/locale/isupper.3 | 79 - lib/libc/locale/isxdigit.3 | 77 - lib/libc/locale/lconv.c | 70 - lib/libc/locale/localeconv.c | 49 - lib/libc/locale/mbrune.3 | 158 - lib/libc/locale/mbrune.c | 112 - lib/libc/locale/mskanji.c | 107 - lib/libc/locale/multibyte.3 | 242 - lib/libc/locale/nomacros.c | 9 - lib/libc/locale/none.c | 91 - lib/libc/locale/rune.3 | 272 - lib/libc/locale/rune.c | 173 - lib/libc/locale/runetype.c | 64 - lib/libc/locale/setinvalidrune.c | 44 - lib/libc/locale/setlocale.3 | 336 - lib/libc/locale/setlocale.c | 321 - lib/libc/locale/setlocale.h | 34 - lib/libc/locale/setrunelocale.c | 140 - lib/libc/locale/table.c | 258 - lib/libc/locale/toascii.3 | 70 - lib/libc/locale/tolower.3 | 91 - lib/libc/locale/tolower.c | 60 - lib/libc/locale/toupper.3 | 91 - lib/libc/locale/toupper.c | 60 - lib/libc/locale/utf2.4 | 88 - lib/libc/locale/utf2.5 | 88 - lib/libc/locale/utf2.c | 150 - lib/libc/mips/:errfix | 5 - lib/libc/mips/Makefile.inc | 4 - lib/libc/mips/SYS.h | 80 - lib/libc/mips/gen/Makefile.inc | 6 - lib/libc/mips/gen/_setjmp.S | 132 - lib/libc/mips/gen/fabs.S | 54 - lib/libc/mips/gen/flt_rounds.c | 27 - lib/libc/mips/gen/fpgetmask.c | 19 - lib/libc/mips/gen/fpgetround.c | 19 - lib/libc/mips/gen/fpgetsticky.c | 19 - lib/libc/mips/gen/fpsetmask.c | 28 - lib/libc/mips/gen/fpsetround.c | 28 - lib/libc/mips/gen/fpsetsticky.c | 28 - lib/libc/mips/gen/frexp.c | 73 - lib/libc/mips/gen/infinity.c | 15 - lib/libc/mips/gen/isinf.S | 95 - lib/libc/mips/gen/ldexp.S | 217 - lib/libc/mips/gen/modf.S | 75 - lib/libc/mips/gen/setjmp.S | 128 - lib/libc/mips/gen/sigsetjmp.S | 78 - lib/libc/mips/net/Makefile.inc | 4 - lib/libc/mips/net/htonl.S | 69 - lib/libc/mips/net/htons.S | 65 - lib/libc/mips/stdlib/Makefile.inc | 0 lib/libc/mips/string/Makefile.inc | 7 - lib/libc/mips/string/bcmp.S | 120 - lib/libc/mips/string/bcopy.S | 127 - lib/libc/mips/string/bzero.S | 74 - lib/libc/mips/string/ffs.S | 57 - lib/libc/mips/string/index.S | 56 - lib/libc/mips/string/rindex.S | 55 - lib/libc/mips/string/strcmp.S | 66 - lib/libc/mips/string/strlen.S | 53 - lib/libc/mips/sys/Makefile.inc | 0 lib/libc/mips/sys/Ovfork.S | 63 - lib/libc/mips/sys/brk.S | 81 - lib/libc/mips/sys/cerror.S | 51 - lib/libc/mips/sys/exect.S | 53 - lib/libc/mips/sys/fork.S | 56 - lib/libc/mips/sys/pipe.S | 56 - lib/libc/mips/sys/ptrace.S | 54 - lib/libc/mips/sys/sbrk.S | 64 - lib/libc/mips/sys/setlogin.S | 55 - lib/libc/mips/sys/sigpending.S | 55 - lib/libc/mips/sys/sigprocmask.S | 63 - lib/libc/mips/sys/sigreturn.S | 48 - lib/libc/mips/sys/sigsuspend.S | 55 - lib/libc/mips/sys/syscall.S | 47 - lib/libc/mipseb/Makefile.inc | 1 - lib/libc/mipseb/SYS.h | 80 - lib/libc/mipseb/gen/Makefile.inc | 1 - lib/libc/mipseb/net/Makefile.inc | 1 - lib/libc/mipseb/stdlib/Makefile.inc | 1 - lib/libc/mipseb/string/Makefile.inc | 1 - lib/libc/mipseb/sys/Makefile.inc | 1 - lib/libc/mipsel/Makefile.inc | 1 - lib/libc/mipsel/SYS.h | 80 - lib/libc/mipsel/gen/Makefile.inc | 1 - lib/libc/mipsel/net/Makefile.inc | 1 - lib/libc/mipsel/stdlib/Makefile.inc | 1 - lib/libc/mipsel/string/Makefile.inc | 1 - lib/libc/mipsel/sys/Makefile.inc | 1 - lib/libc/net/Makefile.inc | 82 - lib/libc/net/addr2ascii.3 | 217 - lib/libc/net/addr2ascii.c | 92 - lib/libc/net/ascii2addr.c | 72 - lib/libc/net/base64.c | 316 - lib/libc/net/byteorder.3 | 77 - lib/libc/net/ether_addr.c | 226 - lib/libc/net/ethers.3 | 196 - lib/libc/net/getaddrinfo.3 | 408 -- lib/libc/net/getaddrinfo.c | 927 --- lib/libc/net/gethostbydns.c | 778 -- lib/libc/net/gethostbyht.c | 202 - lib/libc/net/gethostbyname.3 | 305 - lib/libc/net/gethostbynis.c | 145 - lib/libc/net/gethostnamadr.c | 224 - lib/libc/net/getipnodebyname.3 | 447 -- lib/libc/net/getnameinfo.3 | 232 - lib/libc/net/getnameinfo.c | 235 - lib/libc/net/getnetbydns.c | 313 - lib/libc/net/getnetbyht.c | 173 - lib/libc/net/getnetbynis.c | 177 - lib/libc/net/getnetent.3 | 160 - lib/libc/net/getnetnamadr.c | 190 - lib/libc/net/getproto.c | 55 - lib/libc/net/getprotoent.3 | 147 - lib/libc/net/getprotoent.c | 119 - lib/libc/net/getprotoname.c | 62 - lib/libc/net/getservbyname.c | 79 - lib/libc/net/getservbyport.c | 74 - lib/libc/net/getservent.3 | 157 - lib/libc/net/getservent.c | 278 - lib/libc/net/herror.c | 109 - lib/libc/net/if_indextoname.3 | 144 - lib/libc/net/ifname.c | 212 - lib/libc/net/inet.3 | 267 - lib/libc/net/inet6_option_space.3 | 451 -- lib/libc/net/inet6_rthdr_space.3 | 327 - lib/libc/net/inet_addr.c | 197 - lib/libc/net/inet_lnaof.c | 66 - lib/libc/net/inet_makeaddr.c | 69 - lib/libc/net/inet_net_ntop.c | 147 - lib/libc/net/inet_net_pton.c | 214 - lib/libc/net/inet_neta.c | 91 - lib/libc/net/inet_netof.c | 65 - lib/libc/net/inet_network.c | 99 - lib/libc/net/inet_ntoa.c | 64 - lib/libc/net/inet_ntop.c | 198 - lib/libc/net/inet_pton.c | 221 - lib/libc/net/ip6opt.c | 386 - lib/libc/net/iso_addr.3 | 111 - lib/libc/net/iso_addr.c | 117 - lib/libc/net/linkaddr.3 | 138 - lib/libc/net/linkaddr.c | 158 - lib/libc/net/map_v4v6.c | 128 - lib/libc/net/name6.c | 1305 ---- lib/libc/net/ns.3 | 131 - lib/libc/net/ns_addr.c | 227 - lib/libc/net/ns_name.c | 593 -- lib/libc/net/ns_netint.c | 54 - lib/libc/net/ns_ntoa.c | 100 - lib/libc/net/ns_parse.c | 190 - lib/libc/net/ns_print.c | 743 -- lib/libc/net/ns_ttl.c | 151 - lib/libc/net/nsap_addr.c | 114 - lib/libc/net/rcmd.3 | 293 - lib/libc/net/rcmd.c | 693 -- lib/libc/net/recv.c | 50 - lib/libc/net/res_comp.c | 267 - lib/libc/net/res_config.h | 8 - lib/libc/net/res_data.c | 83 - lib/libc/net/res_debug.c | 987 --- lib/libc/net/res_init.c | 551 -- lib/libc/net/res_mkquery.c | 206 - lib/libc/net/res_mkupdate.c | 414 -- lib/libc/net/res_query.c | 421 -- lib/libc/net/res_send.c | 927 --- lib/libc/net/res_update.c | 516 -- lib/libc/net/resolver.3 | 352 - lib/libc/net/rthdr.c | 310 - lib/libc/net/send.c | 50 - lib/libc/net/vars.c | 42 - lib/libc/nls/Makefile.inc | 10 - lib/libc/nls/catclose.3 | 55 - lib/libc/nls/catclose.c | 25 - lib/libc/nls/catgets.3 | 68 - lib/libc/nls/catgets.c | 28 - lib/libc/nls/catopen.3 | 100 - lib/libc/nls/catopen.c | 26 - lib/libc/nls/msgcat.c | 452 -- lib/libc/nls/msgcat.h | 170 - lib/libc/posix1e/Makefile | 38 - lib/libc/posix1e/acl.3 | 180 - lib/libc/posix1e/acl_delete.3 | 124 - lib/libc/posix1e/acl_delete.c | 57 - lib/libc/posix1e/acl_dup.3 | 105 - lib/libc/posix1e/acl_free.3 | 89 - lib/libc/posix1e/acl_free.c | 43 - lib/libc/posix1e/acl_from_text.3 | 125 - lib/libc/posix1e/acl_from_text.c | 246 - lib/libc/posix1e/acl_get.3 | 138 - lib/libc/posix1e/acl_get.c | 97 - lib/libc/posix1e/acl_init.3 | 104 - lib/libc/posix1e/acl_init.c | 67 - lib/libc/posix1e/acl_set.3 | 131 - lib/libc/posix1e/acl_set.c | 88 - lib/libc/posix1e/acl_support.c | 409 -- lib/libc/posix1e/acl_support.h | 46 - lib/libc/posix1e/acl_to_text.3 | 130 - lib/libc/posix1e/acl_to_text.c | 233 - lib/libc/posix1e/acl_valid.3 | 144 - lib/libc/posix1e/acl_valid.c | 97 - lib/libc/posix1e/posix1e.3 | 101 - lib/libc/quad/Makefile.inc | 19 - lib/libc/quad/TESTS/Makefile | 11 - lib/libc/quad/TESTS/divrem.c | 78 - lib/libc/quad/TESTS/mul.c | 74 - lib/libc/quad/adddi3.c | 60 - lib/libc/quad/anddi3.c | 58 - lib/libc/quad/ashldi3.c | 66 - lib/libc/quad/ashrdi3.c | 75 - lib/libc/quad/cmpdi2.c | 59 - lib/libc/quad/divdi3.c | 65 - lib/libc/quad/fixdfdi.c | 62 - lib/libc/quad/fixsfdi.c | 63 - lib/libc/quad/fixunsdfdi.c | 96 - lib/libc/quad/fixunssfdi.c | 100 - lib/libc/quad/floatdidf.c | 74 - lib/libc/quad/floatdisf.c | 76 - lib/libc/quad/floatunsdidf.c | 59 - lib/libc/quad/iordi3.c | 58 - lib/libc/quad/lshldi3.c | 66 - lib/libc/quad/lshrdi3.c | 65 - lib/libc/quad/moddi3.c | 67 - lib/libc/quad/muldi3.c | 246 - lib/libc/quad/negdi2.c | 57 - lib/libc/quad/notdi2.c | 58 - lib/libc/quad/qdivrem.c | 279 - lib/libc/quad/quad.h | 115 - lib/libc/quad/subdi3.c | 59 - lib/libc/quad/ucmpdi2.c | 58 - lib/libc/quad/udivdi3.c | 53 - lib/libc/quad/umoddi3.c | 55 - lib/libc/quad/xordi3.c | 58 - lib/libc/regex/COPYRIGHT | 56 - lib/libc/regex/Makefile.inc | 17 - lib/libc/regex/WHATSNEW | 94 - lib/libc/regex/cclass.h | 62 - lib/libc/regex/cname.h | 141 - lib/libc/regex/engine.c | 1092 --- lib/libc/regex/re_format.7 | 273 - lib/libc/regex/regcomp.c | 1777 ----- lib/libc/regex/regerror.c | 177 - lib/libc/regex/regex.3 | 541 -- lib/libc/regex/regex2.h | 173 - lib/libc/regex/regexec.c | 181 - lib/libc/regex/regfree.c | 80 - lib/libc/regex/utils.h | 57 - lib/libc/rpc/DISCLAIMER | 28 - lib/libc/rpc/Makefile.inc | 120 - lib/libc/rpc/PSD.doc/nfs.rfc.ms | 1372 ---- lib/libc/rpc/PSD.doc/rpc.prog.ms | 2684 ------- lib/libc/rpc/PSD.doc/rpc.rfc.ms | 1302 ---- lib/libc/rpc/PSD.doc/rpcgen.ms | 1299 ---- lib/libc/rpc/PSD.doc/xdr.nts.ms | 1966 ----- lib/libc/rpc/PSD.doc/xdr.rfc.ms | 1058 --- lib/libc/rpc/README | 233 - lib/libc/rpc/auth_des.c | 554 -- lib/libc/rpc/auth_none.c | 136 - lib/libc/rpc/auth_time.c | 503 -- lib/libc/rpc/auth_unix.c | 349 - lib/libc/rpc/authdes_prot.c | 82 - lib/libc/rpc/authunix_prot.c | 68 - lib/libc/rpc/bindresvport.3 | 106 - lib/libc/rpc/bindresvport.c | 143 - lib/libc/rpc/clnt_generic.c | 137 - lib/libc/rpc/clnt_perror.c | 254 - lib/libc/rpc/clnt_raw.c | 242 - lib/libc/rpc/clnt_simple.c | 122 - lib/libc/rpc/clnt_tcp.c | 580 -- lib/libc/rpc/clnt_udp.c | 567 -- lib/libc/rpc/clnt_unix.c | 635 -- lib/libc/rpc/crypt_client.c | 90 - lib/libc/rpc/des_crypt.3 | 130 - lib/libc/rpc/des_crypt.c | 153 - lib/libc/rpc/des_soft.c | 67 - lib/libc/rpc/get_myaddress.c | 112 - lib/libc/rpc/getpublickey.c | 172 - lib/libc/rpc/getrpcent.3 | 98 - lib/libc/rpc/getrpcent.c | 303 - lib/libc/rpc/getrpcport.3 | 31 - lib/libc/rpc/getrpcport.c | 63 - lib/libc/rpc/key_call.c | 427 -- lib/libc/rpc/key_prot_xdr.c | 166 - lib/libc/rpc/netname.c | 136 - lib/libc/rpc/netnamer.c | 324 - lib/libc/rpc/pmap_clnt.c | 149 - lib/libc/rpc/pmap_getmaps.c | 86 - lib/libc/rpc/pmap_getport.c | 91 - lib/libc/rpc/pmap_prot.c | 59 - lib/libc/rpc/pmap_prot2.c | 118 - lib/libc/rpc/pmap_rmt.c | 415 -- lib/libc/rpc/publickey.3 | 47 - lib/libc/rpc/publickey.5 | 38 - lib/libc/rpc/rpc.3 | 1767 ----- lib/libc/rpc/rpc.5 | 35 - lib/libc/rpc/rpc_callmsg.c | 193 - lib/libc/rpc/rpc_commondata.c | 43 - lib/libc/rpc/rpc_dtablesize.c | 61 - lib/libc/rpc/rpc_prot.c | 297 - lib/libc/rpc/rpc_secure.3 | 254 - lib/libc/rpc/rpcdname.c | 77 - lib/libc/rpc/rstat.1 | 58 - lib/libc/rpc/rstat_svc.8 | 22 - lib/libc/rpc/rtime.3 | 47 - lib/libc/rpc/rtime.c | 157 - lib/libc/rpc/svc.c | 494 -- lib/libc/rpc/svc_auth.c | 216 - lib/libc/rpc/svc_auth_des.c | 531 -- lib/libc/rpc/svc_auth_unix.c | 148 - lib/libc/rpc/svc_raw.c | 168 - lib/libc/rpc/svc_run.c | 87 - lib/libc/rpc/svc_simple.c | 150 - lib/libc/rpc/svc_tcp.c | 484 -- lib/libc/rpc/svc_udp.c | 480 -- lib/libc/rpc/svc_unix.c | 530 -- lib/libc/stdio/Makefile.inc | 45 - lib/libc/stdio/_flock_stub.c | 81 - lib/libc/stdio/asprintf.c | 81 - lib/libc/stdio/clrerr.c | 56 - lib/libc/stdio/fclose.3 | 95 - lib/libc/stdio/fclose.c | 76 - lib/libc/stdio/fdopen.c | 91 - lib/libc/stdio/feof.c | 57 - lib/libc/stdio/ferror.3 | 101 - lib/libc/stdio/ferror.c | 57 - lib/libc/stdio/fflush.3 | 111 - lib/libc/stdio/fflush.c | 101 - lib/libc/stdio/fgetc.c | 57 - lib/libc/stdio/fgetln.3 | 125 - lib/libc/stdio/fgetln.c | 165 - lib/libc/stdio/fgetpos.c | 58 - lib/libc/stdio/fgets.3 | 157 - lib/libc/stdio/fgets.c | 115 - lib/libc/stdio/fileno.c | 57 - lib/libc/stdio/findfp.c | 186 - lib/libc/stdio/flags.c | 95 - lib/libc/stdio/floatio.h | 46 - lib/libc/stdio/fopen.3 | 242 - lib/libc/stdio/fopen.c | 86 - lib/libc/stdio/fprintf.c | 73 - lib/libc/stdio/fpurge.c | 74 - lib/libc/stdio/fputc.c | 58 - lib/libc/stdio/fputs.3 | 108 - lib/libc/stdio/fputs.c | 70 - lib/libc/stdio/fread.3 | 107 - lib/libc/stdio/fread.c | 90 - lib/libc/stdio/freopen.c | 164 - lib/libc/stdio/fscanf.c | 77 - lib/libc/stdio/fseek.3 | 230 - lib/libc/stdio/fseek.c | 269 - lib/libc/stdio/fsetpos.c | 57 - lib/libc/stdio/ftell.c | 114 - lib/libc/stdio/funopen.3 | 170 - lib/libc/stdio/funopen.c | 81 - lib/libc/stdio/fvwrite.c | 213 - lib/libc/stdio/fvwrite.h | 56 - lib/libc/stdio/fwalk.c | 64 - lib/libc/stdio/fwrite.c | 79 - lib/libc/stdio/getc.3 | 137 - lib/libc/stdio/getc.c | 62 - lib/libc/stdio/getchar.c | 61 - lib/libc/stdio/gets.c | 75 - lib/libc/stdio/getw.c | 54 - lib/libc/stdio/glue.h | 47 - lib/libc/stdio/local.h | 87 - lib/libc/stdio/makebuf.c | 118 - lib/libc/stdio/mktemp.3 | 219 - lib/libc/stdio/mktemp.c | 196 - lib/libc/stdio/perror.c | 67 - lib/libc/stdio/printf.3 | 658 -- lib/libc/stdio/printf.c | 72 - lib/libc/stdio/putc.3 | 134 - lib/libc/stdio/putc.c | 63 - lib/libc/stdio/putchar.c | 64 - lib/libc/stdio/puts.c | 73 - lib/libc/stdio/putw.c | 66 - lib/libc/stdio/refill.c | 136 - lib/libc/stdio/remove.3 | 79 - lib/libc/stdio/remove.c | 53 - lib/libc/stdio/rewind.c | 58 - lib/libc/stdio/rget.c | 64 - lib/libc/stdio/scanf.3 | 441 -- lib/libc/stdio/scanf.c | 76 - lib/libc/stdio/setbuf.3 | 203 - lib/libc/stdio/setbuf.c | 50 - lib/libc/stdio/setbuffer.c | 66 - lib/libc/stdio/setvbuf.c | 169 - lib/libc/stdio/snprintf.c | 89 - lib/libc/stdio/sprintf.c | 81 - lib/libc/stdio/sscanf.c | 97 - lib/libc/stdio/stdio.3 | 295 - lib/libc/stdio/stdio.c | 111 - lib/libc/stdio/tempnam.c | 96 - lib/libc/stdio/tmpfile.c | 82 - lib/libc/stdio/tmpnam.3 | 220 - lib/libc/stdio/tmpnam.c | 65 - lib/libc/stdio/ungetc.3 | 96 - lib/libc/stdio/ungetc.c | 166 - lib/libc/stdio/vasprintf.c | 65 - lib/libc/stdio/vfprintf.c | 1278 ---- lib/libc/stdio/vfscanf.c | 786 -- lib/libc/stdio/vprintf.c | 53 - lib/libc/stdio/vscanf.c | 59 - lib/libc/stdio/vsnprintf.c | 72 - lib/libc/stdio/vsprintf.c | 64 - lib/libc/stdio/vsscanf.c | 78 - lib/libc/stdio/wbuf.c | 93 - lib/libc/stdio/wsetup.c | 95 - lib/libc/stdlib/Makefile.inc | 39 - lib/libc/stdlib/abort.3 | 71 - lib/libc/stdlib/abort.c | 85 - lib/libc/stdlib/abs.3 | 75 - lib/libc/stdlib/abs.c | 45 - lib/libc/stdlib/alloca.3 | 79 - lib/libc/stdlib/atexit.3 | 78 - lib/libc/stdlib/atexit.c | 69 - lib/libc/stdlib/atexit.h | 45 - lib/libc/stdlib/atof.3 | 74 - lib/libc/stdlib/atof.c | 46 - lib/libc/stdlib/atoi.3 | 74 - lib/libc/stdlib/atoi.c | 46 - lib/libc/stdlib/atol.3 | 75 - lib/libc/stdlib/atol.c | 46 - lib/libc/stdlib/bsearch.3 | 91 - lib/libc/stdlib/bsearch.c | 81 - lib/libc/stdlib/calloc.c | 52 - lib/libc/stdlib/div.3 | 68 - lib/libc/stdlib/div.c | 79 - lib/libc/stdlib/exit.3 | 96 - lib/libc/stdlib/exit.c | 75 - lib/libc/stdlib/getenv.3 | 167 - lib/libc/stdlib/getenv.c | 91 - lib/libc/stdlib/getopt.3 | 264 - lib/libc/stdlib/getopt.c | 123 - lib/libc/stdlib/getsubopt.3 | 147 - lib/libc/stdlib/getsubopt.c | 99 - lib/libc/stdlib/heapsort.c | 183 - lib/libc/stdlib/labs.3 | 67 - lib/libc/stdlib/labs.c | 45 - lib/libc/stdlib/ldiv.3 | 71 - lib/libc/stdlib/ldiv.c | 58 - lib/libc/stdlib/malloc.3 | 460 -- lib/libc/stdlib/malloc.c | 1137 --- lib/libc/stdlib/memory.3 | 71 - lib/libc/stdlib/merge.c | 350 - lib/libc/stdlib/netbsd_strtod.c | 2517 ------- lib/libc/stdlib/putenv.c | 58 - lib/libc/stdlib/qsort.3 | 236 - lib/libc/stdlib/qsort.c | 178 - lib/libc/stdlib/radixsort.3 | 162 - lib/libc/stdlib/radixsort.c | 318 - lib/libc/stdlib/rand.3 | 103 - lib/libc/stdlib/rand.c | 105 - lib/libc/stdlib/random.3 | 190 - lib/libc/stdlib/random.c | 494 -- lib/libc/stdlib/reallocf.c | 39 - lib/libc/stdlib/realpath.3 | 126 - lib/libc/stdlib/realpath.c | 165 - lib/libc/stdlib/setenv.c | 122 - lib/libc/stdlib/strhash.c | 410 -- lib/libc/stdlib/strtod.3 | 134 - lib/libc/stdlib/strtod.c | 2443 ------- lib/libc/stdlib/strtol.3 | 169 - lib/libc/stdlib/strtol.c | 131 - lib/libc/stdlib/strtoll.c | 138 - lib/libc/stdlib/strtoq.c | 138 - lib/libc/stdlib/strtoul.3 | 164 - lib/libc/stdlib/strtoul.c | 109 - lib/libc/stdlib/strtoull.c | 116 - lib/libc/stdlib/strtouq.c | 116 - lib/libc/stdlib/system.3 | 101 - lib/libc/stdlib/system.c | 99 - lib/libc/stdtime/Makefile.inc | 15 - lib/libc/stdtime/asctime.c | 70 - lib/libc/stdtime/ctime.3 | 350 - lib/libc/stdtime/difftime.c | 77 - lib/libc/stdtime/localtime.c | 1772 ----- lib/libc/stdtime/private.h | 218 - lib/libc/stdtime/strftime.3 | 260 - lib/libc/stdtime/strftime.c | 458 -- lib/libc/stdtime/strptime.3 | 139 - lib/libc/stdtime/strptime.c | 543 -- lib/libc/stdtime/time2posix.3 | 116 - lib/libc/stdtime/timelocal.c | 245 - lib/libc/stdtime/timelocal.h | 54 - lib/libc/stdtime/tzfile.5 | 138 - lib/libc/stdtime/tzfile.h | 190 - lib/libc/string/Makefile.inc | 33 - lib/libc/string/bcmp.3 | 72 - lib/libc/string/bcmp.c | 59 - lib/libc/string/bcopy.3 | 72 - lib/libc/string/bcopy.c | 139 - lib/libc/string/bstring.3 | 110 - lib/libc/string/bzero.3 | 69 - lib/libc/string/bzero.c | 2 - lib/libc/string/ffs.3 | 62 - lib/libc/string/ffs.c | 54 - lib/libc/string/index.3 | 81 - lib/libc/string/index.c | 57 - lib/libc/string/memccpy.3 | 74 - lib/libc/string/memccpy.c | 59 - lib/libc/string/memchr.3 | 82 - lib/libc/string/memchr.c | 59 - lib/libc/string/memcmp.3 | 83 - lib/libc/string/memcmp.c | 61 - lib/libc/string/memcpy.3 | 84 - lib/libc/string/memcpy.c | 2 - lib/libc/string/memmove.3 | 76 - lib/libc/string/memmove.c | 2 - lib/libc/string/memset.3 | 71 - lib/libc/string/memset.c | 132 - lib/libc/string/rindex.3 | 83 - lib/libc/string/rindex.c | 59 - lib/libc/string/strcasecmp.3 | 90 - lib/libc/string/strcasecmp.c | 76 - lib/libc/string/strcat.3 | 99 - lib/libc/string/strcat.c | 50 - lib/libc/string/strchr.3 | 88 - lib/libc/string/strchr.c | 2 - lib/libc/string/strcmp.3 | 95 - lib/libc/string/strcmp.c | 55 - lib/libc/string/strcoll.3 | 73 - lib/libc/string/strcoll.c | 85 - lib/libc/string/strcpy.3 | 123 - lib/libc/string/strcpy.c | 50 - lib/libc/string/strcspn.3 | 85 - lib/libc/string/strcspn.c | 68 - lib/libc/string/strdup.3 | 65 - lib/libc/string/strdup.c | 54 - lib/libc/string/strerror.3 | 128 - lib/libc/string/strerror.c | 71 - lib/libc/string/string.3 | 156 - lib/libc/string/strlcat.c | 71 - lib/libc/string/strlcpy.3 | 157 - lib/libc/string/strlcpy.c | 68 - lib/libc/string/strlen.3 | 71 - lib/libc/string/strlen.c | 50 - lib/libc/string/strmode.3 | 151 - lib/libc/string/strmode.c | 152 - lib/libc/string/strncat.c | 68 - lib/libc/string/strncmp.c | 57 - lib/libc/string/strncpy.c | 68 - lib/libc/string/strpbrk.3 | 80 - lib/libc/string/strpbrk.c | 57 - lib/libc/string/strrchr.3 | 91 - lib/libc/string/strrchr.c | 2 - lib/libc/string/strsep.3 | 110 - lib/libc/string/strsep.c | 80 - lib/libc/string/strsignal.c | 72 - lib/libc/string/strspn.3 | 80 - lib/libc/string/strspn.c | 61 - lib/libc/string/strstr.3 | 89 - lib/libc/string/strstr.c | 65 - lib/libc/string/strtok.3 | 169 - lib/libc/string/strtok.c | 163 - lib/libc/string/strxfrm.3 | 97 - lib/libc/string/strxfrm.c | 85 - lib/libc/string/swab.3 | 66 - lib/libc/string/swab.c | 65 - lib/libc/sys/Makefile.inc | 153 - lib/libc/sys/__error.c | 47 - lib/libc/sys/_exit.2 | 120 - lib/libc/sys/accept.2 | 202 - lib/libc/sys/access.2 | 135 - lib/libc/sys/acct.2 | 115 - lib/libc/sys/adjtime.2 | 112 - lib/libc/sys/aio_cancel.2 | 109 - lib/libc/sys/aio_error.2 | 93 - lib/libc/sys/aio_read.2 | 200 - lib/libc/sys/aio_return.2 | 95 - lib/libc/sys/aio_suspend.2 | 105 - lib/libc/sys/aio_waitcomplete.2 | 129 - lib/libc/sys/aio_write.2 | 192 - lib/libc/sys/bind.2 | 147 - lib/libc/sys/brk.2 | 150 - lib/libc/sys/chdir.2 | 133 - lib/libc/sys/chflags.2 | 169 - lib/libc/sys/chmod.2 | 228 - lib/libc/sys/chown.2 | 169 - lib/libc/sys/chroot.2 | 125 - lib/libc/sys/clock_gettime.2 | 124 - lib/libc/sys/close.2 | 157 - lib/libc/sys/connect.2 | 172 - lib/libc/sys/dup.2 | 204 - lib/libc/sys/execve.2 | 289 - lib/libc/sys/fcntl.2 | 531 -- lib/libc/sys/fhopen.2 | 139 - lib/libc/sys/flock.2 | 172 - lib/libc/sys/fork.2 | 127 - lib/libc/sys/fsync.2 | 104 - lib/libc/sys/ftruncate.c | 68 - lib/libc/sys/getdirentries.2 | 204 - lib/libc/sys/getdtablesize.2 | 61 - lib/libc/sys/getfh.2 | 95 - lib/libc/sys/getfsstat.2 | 172 - lib/libc/sys/getgid.2 | 83 - lib/libc/sys/getgroups.2 | 96 - lib/libc/sys/getitimer.2 | 177 - lib/libc/sys/getlogin.2 | 186 - lib/libc/sys/getpeername.2 | 114 - lib/libc/sys/getpgrp.2 | 123 - lib/libc/sys/getpid.2 | 80 - lib/libc/sys/getpriority.2 | 143 - lib/libc/sys/getrlimit.2 | 188 - lib/libc/sys/getrusage.2 | 177 - lib/libc/sys/getsid.2 | 77 - lib/libc/sys/getsockname.2 | 113 - lib/libc/sys/getsockopt.2 | 397 - lib/libc/sys/gettimeofday.2 | 132 - lib/libc/sys/getuid.2 | 92 - lib/libc/sys/intro.2 | 718 -- lib/libc/sys/ioctl.2 | 144 - lib/libc/sys/issetugid.2 | 99 - lib/libc/sys/jail.2 | 105 - lib/libc/sys/kill.2 | 142 - lib/libc/sys/kldfind.2 | 74 - lib/libc/sys/kldfirstmod.2 | 67 - lib/libc/sys/kldload.2 | 83 - lib/libc/sys/kldnext.2 | 70 - lib/libc/sys/kldstat.2 | 116 - lib/libc/sys/kldunload.2 | 78 - lib/libc/sys/ktrace.2 | 167 - lib/libc/sys/link.2 | 168 - lib/libc/sys/listen.2 | 142 - lib/libc/sys/lseek.2 | 142 - lib/libc/sys/lseek.c | 69 - lib/libc/sys/madvise.2 | 160 - lib/libc/sys/mincore.2 | 88 - lib/libc/sys/minherit.2 | 94 - lib/libc/sys/mkdir.2 | 110 - lib/libc/sys/mkfifo.2 | 121 - lib/libc/sys/mknod.2 | 125 - lib/libc/sys/mlock.2 | 173 - lib/libc/sys/mmap.2 | 299 - lib/libc/sys/mmap.c | 59 - lib/libc/sys/mount.2 | 324 - lib/libc/sys/mprotect.2 | 88 - lib/libc/sys/msync.2 | 101 - lib/libc/sys/munmap.2 | 83 - lib/libc/sys/nanosleep.2 | 104 - lib/libc/sys/nfssvc.2 | 252 - lib/libc/sys/open.2 | 301 - lib/libc/sys/pathconf.2 | 165 - lib/libc/sys/pipe.2 | 123 - lib/libc/sys/poll.2 | 190 - lib/libc/sys/pread.c | 54 - lib/libc/sys/profil.2 | 136 - lib/libc/sys/ptrace.2 | 312 - lib/libc/sys/pwrite.c | 54 - lib/libc/sys/quotactl.2 | 222 - lib/libc/sys/read.2 | 269 - lib/libc/sys/readlink.2 | 96 - lib/libc/sys/reboot.2 | 164 - lib/libc/sys/recv.2 | 294 - lib/libc/sys/rename.2 | 199 - lib/libc/sys/revoke.2 | 108 - lib/libc/sys/rfork.2 | 147 - lib/libc/sys/rmdir.2 | 105 - lib/libc/sys/rtprio.2 | 115 - lib/libc/sys/sched_get_priority_max.2 | 121 - lib/libc/sys/sched_setparam.2 | 172 - lib/libc/sys/sched_setscheduler.2 | 167 - lib/libc/sys/sched_yield.2 | 59 - lib/libc/sys/select.2 | 199 - lib/libc/sys/semctl.2 | 177 - lib/libc/sys/semget.2 | 138 - lib/libc/sys/semop.2 | 192 - lib/libc/sys/send.2 | 198 - lib/libc/sys/sendfile.2 | 159 - lib/libc/sys/setgroups.2 | 84 - lib/libc/sys/setpgid.2 | 91 - lib/libc/sys/setregid.2 | 93 - lib/libc/sys/setresuid.2 | 81 - lib/libc/sys/setreuid.2 | 91 - lib/libc/sys/setsid.2 | 83 - lib/libc/sys/setuid.2 | 161 - lib/libc/sys/shmat.2 | 111 - lib/libc/sys/shmctl.2 | 137 - lib/libc/sys/shmget.2 | 139 - lib/libc/sys/shutdown.2 | 100 - lib/libc/sys/sigaction.2 | 578 -- lib/libc/sys/sigaltstack.2 | 165 - lib/libc/sys/sigpending.2 | 73 - lib/libc/sys/sigprocmask.2 | 121 - lib/libc/sys/sigreturn.2 | 113 - lib/libc/sys/sigstack.2 | 52 - lib/libc/sys/sigsuspend.2 | 80 - lib/libc/sys/socket.2 | 300 - lib/libc/sys/socketpair.2 | 92 - lib/libc/sys/stat.2 | 284 - lib/libc/sys/statfs.2 | 183 - lib/libc/sys/swapon.2 | 112 - lib/libc/sys/symlink.2 | 137 - lib/libc/sys/sync.2 | 76 - lib/libc/sys/sysarch.2 | 79 - lib/libc/sys/syscall.2 | 77 - lib/libc/sys/truncate.2 | 129 - lib/libc/sys/truncate.c | 54 - lib/libc/sys/umask.2 | 88 - lib/libc/sys/undelete.2 | 104 - lib/libc/sys/unlink.2 | 119 - lib/libc/sys/utimes.2 | 187 - lib/libc/sys/vfork.2 | 130 - lib/libc/sys/wait.2 | 299 - lib/libc/sys/write.2 | 291 - lib/libc/xdr/Makefile.inc | 43 - lib/libc/xdr/xdr.3 | 837 --- lib/libc/xdr/xdr.c | 775 -- lib/libc/xdr/xdr_array.c | 155 - lib/libc/xdr/xdr_float.c | 314 - lib/libc/xdr/xdr_mem.c | 242 - lib/libc/xdr/xdr_rec.c | 596 -- lib/libc/xdr/xdr_reference.c | 136 - lib/libc/xdr/xdr_sizeof.c | 163 - lib/libc/xdr/xdr_stdio.c | 189 - lib/libc/yp/Makefile.inc | 17 - lib/libc/yp/xdryp.c | 119 - lib/libc/yp/yplib.c | 1121 --- 1189 files changed, 211791 deletions(-) delete mode 100644 lib/libc/Makefile delete mode 100644 lib/libc/Makefile.inc delete mode 100644 lib/libc/alpha/Makefile.inc delete mode 100644 lib/libc/alpha/SYS.h delete mode 100644 lib/libc/alpha/gen/Makefile.inc delete mode 100644 lib/libc/alpha/gen/_setjmp.S delete mode 100644 lib/libc/alpha/gen/divrem.m4 delete mode 100644 lib/libc/alpha/gen/fabs.S delete mode 100644 lib/libc/alpha/gen/flt_rounds.c delete mode 100644 lib/libc/alpha/gen/fpgetmask.c delete mode 100644 lib/libc/alpha/gen/fpgetround.c delete mode 100644 lib/libc/alpha/gen/fpgetsticky.c delete mode 100644 lib/libc/alpha/gen/fpsetmask.c delete mode 100644 lib/libc/alpha/gen/fpsetround.c delete mode 100644 lib/libc/alpha/gen/fpsetsticky.c delete mode 100644 lib/libc/alpha/gen/frexp.c delete mode 100644 lib/libc/alpha/gen/infinity.c delete mode 100644 lib/libc/alpha/gen/isinf.c delete mode 100644 lib/libc/alpha/gen/ldexp.c delete mode 100644 lib/libc/alpha/gen/modf.c delete mode 100644 lib/libc/alpha/gen/setjmp.S delete mode 100644 lib/libc/alpha/gen/sigsetjmp.S delete mode 100644 lib/libc/alpha/net/Makefile.inc delete mode 100644 lib/libc/alpha/net/byte_swap_2.S delete mode 100644 lib/libc/alpha/net/byte_swap_4.S delete mode 100644 lib/libc/alpha/net/htonl.S delete mode 100644 lib/libc/alpha/net/htons.S delete mode 100644 lib/libc/alpha/net/ntohl.S delete mode 100644 lib/libc/alpha/net/ntohs.S delete mode 100644 lib/libc/alpha/stdlib/Makefile.inc delete mode 100644 lib/libc/alpha/string/Makefile.inc delete mode 100644 lib/libc/alpha/string/bcopy.S delete mode 100644 lib/libc/alpha/string/bzero.S delete mode 100644 lib/libc/alpha/string/ffs.S delete mode 100644 lib/libc/alpha/string/memcpy.S delete mode 100644 lib/libc/alpha/string/memmove.S delete mode 100644 lib/libc/alpha/sys/Makefile.inc delete mode 100644 lib/libc/alpha/sys/Ovfork.S delete mode 100644 lib/libc/alpha/sys/brk.S delete mode 100644 lib/libc/alpha/sys/cerror.S delete mode 100644 lib/libc/alpha/sys/exect.S delete mode 100644 lib/libc/alpha/sys/fork.S delete mode 100644 lib/libc/alpha/sys/pipe.S delete mode 100644 lib/libc/alpha/sys/ptrace.S delete mode 100644 lib/libc/alpha/sys/sbrk.S delete mode 100644 lib/libc/alpha/sys/setlogin.S delete mode 100644 lib/libc/alpha/sys/sigreturn.S delete mode 100644 lib/libc/alpha/sys/syscall.S delete mode 100644 lib/libc/amd64/SYS.h delete mode 100644 lib/libc/amd64/gen/Makefile.inc delete mode 100644 lib/libc/amd64/gen/_setjmp.S delete mode 100644 lib/libc/amd64/gen/frexp.c delete mode 100644 lib/libc/amd64/gen/infinity.c delete mode 100644 lib/libc/amd64/gen/isinf.c delete mode 100644 lib/libc/amd64/gen/ldexp.c delete mode 100644 lib/libc/amd64/gen/setjmp.S delete mode 100644 lib/libc/amd64/gen/sigsetjmp.S delete mode 100644 lib/libc/amd64/net/Makefile.inc delete mode 100644 lib/libc/amd64/net/htonl.S delete mode 100644 lib/libc/amd64/net/htons.S delete mode 100644 lib/libc/amd64/net/ntohl.S delete mode 100644 lib/libc/amd64/net/ntohs.S delete mode 100644 lib/libc/amd64/sys/Makefile.inc delete mode 100644 lib/libc/amd64/sys/brk.S delete mode 100644 lib/libc/amd64/sys/cerror.S delete mode 100644 lib/libc/amd64/sys/exect.S delete mode 100644 lib/libc/amd64/sys/pipe.S delete mode 100644 lib/libc/amd64/sys/ptrace.S delete mode 100644 lib/libc/amd64/sys/reboot.S delete mode 100644 lib/libc/amd64/sys/sbrk.S delete mode 100644 lib/libc/amd64/sys/setlogin.S delete mode 100644 lib/libc/amd64/sys/sigreturn.S delete mode 100644 lib/libc/amd64/sys/vfork.S delete mode 100644 lib/libc/compat-43/Makefile.inc delete mode 100644 lib/libc/compat-43/creat.2 delete mode 100644 lib/libc/compat-43/creat.c delete mode 100644 lib/libc/compat-43/gethostid.3 delete mode 100644 lib/libc/compat-43/gethostid.c delete mode 100644 lib/libc/compat-43/getwd.c delete mode 100644 lib/libc/compat-43/killpg.2 delete mode 100644 lib/libc/compat-43/killpg.c delete mode 100644 lib/libc/compat-43/sethostid.c delete mode 100644 lib/libc/compat-43/setpgrp.c delete mode 100644 lib/libc/compat-43/setrgid.c delete mode 100644 lib/libc/compat-43/setruid.3 delete mode 100644 lib/libc/compat-43/setruid.c delete mode 100644 lib/libc/compat-43/sigblock.2 delete mode 100644 lib/libc/compat-43/sigcompat.c delete mode 100644 lib/libc/compat-43/sigpause.2 delete mode 100644 lib/libc/compat-43/sigsetmask.2 delete mode 100644 lib/libc/compat-43/sigvec.2 delete mode 100644 lib/libc/db/Makefile.inc delete mode 100644 lib/libc/db/README delete mode 100644 lib/libc/db/btree/Makefile.inc delete mode 100644 lib/libc/db/btree/bt_close.c delete mode 100644 lib/libc/db/btree/bt_conv.c delete mode 100644 lib/libc/db/btree/bt_debug.c delete mode 100644 lib/libc/db/btree/bt_delete.c delete mode 100644 lib/libc/db/btree/bt_get.c delete mode 100644 lib/libc/db/btree/bt_open.c delete mode 100644 lib/libc/db/btree/bt_overflow.c delete mode 100644 lib/libc/db/btree/bt_page.c delete mode 100644 lib/libc/db/btree/bt_put.c delete mode 100644 lib/libc/db/btree/bt_search.c delete mode 100644 lib/libc/db/btree/bt_seq.c delete mode 100644 lib/libc/db/btree/bt_split.c delete mode 100644 lib/libc/db/btree/bt_utils.c delete mode 100644 lib/libc/db/btree/btree.h delete mode 100644 lib/libc/db/btree/extern.h delete mode 100644 lib/libc/db/changelog delete mode 100644 lib/libc/db/db/Makefile.inc delete mode 100644 lib/libc/db/db/db.c delete mode 100644 lib/libc/db/docs/hash.usenix.ps delete mode 100644 lib/libc/db/docs/libtp.usenix.ps delete mode 100644 lib/libc/db/hash/Makefile.inc delete mode 100644 lib/libc/db/hash/README delete mode 100644 lib/libc/db/hash/extern.h delete mode 100644 lib/libc/db/hash/hash.c delete mode 100644 lib/libc/db/hash/hash.h delete mode 100644 lib/libc/db/hash/hash_bigkey.c delete mode 100644 lib/libc/db/hash/hash_buf.c delete mode 100644 lib/libc/db/hash/hash_func.c delete mode 100644 lib/libc/db/hash/hash_log2.c delete mode 100644 lib/libc/db/hash/hash_page.c delete mode 100644 lib/libc/db/hash/hsearch.c delete mode 100644 lib/libc/db/hash/ndbm.c delete mode 100644 lib/libc/db/hash/page.h delete mode 100644 lib/libc/db/hash/search.h delete mode 100644 lib/libc/db/man/Makefile.inc delete mode 100644 lib/libc/db/man/btree.3 delete mode 100644 lib/libc/db/man/dbopen.3 delete mode 100644 lib/libc/db/man/hash.3 delete mode 100644 lib/libc/db/man/mpool.3 delete mode 100644 lib/libc/db/man/recno.3 delete mode 100644 lib/libc/db/mpool/Makefile.inc delete mode 100644 lib/libc/db/mpool/README delete mode 100644 lib/libc/db/mpool/mpool.c delete mode 100644 lib/libc/db/mpool/mpool.libtp delete mode 100644 lib/libc/db/recno/Makefile.inc delete mode 100644 lib/libc/db/recno/extern.h delete mode 100644 lib/libc/db/recno/rec_close.c delete mode 100644 lib/libc/db/recno/rec_delete.c delete mode 100644 lib/libc/db/recno/rec_get.c delete mode 100644 lib/libc/db/recno/rec_open.c delete mode 100644 lib/libc/db/recno/rec_put.c delete mode 100644 lib/libc/db/recno/rec_search.c delete mode 100644 lib/libc/db/recno/rec_seq.c delete mode 100644 lib/libc/db/recno/rec_utils.c delete mode 100644 lib/libc/db/recno/recno.h delete mode 100644 lib/libc/db/test/Makefile delete mode 100644 lib/libc/db/test/README delete mode 100644 lib/libc/db/test/btree.tests/main.c delete mode 100644 lib/libc/db/test/dbtest.c delete mode 100644 lib/libc/db/test/hash.tests/driver2.c delete mode 100644 lib/libc/db/test/hash.tests/makedb.sh delete mode 100644 lib/libc/db/test/hash.tests/tcreat3.c delete mode 100644 lib/libc/db/test/hash.tests/tdel.c delete mode 100644 lib/libc/db/test/hash.tests/testit delete mode 100644 lib/libc/db/test/hash.tests/thash4.c delete mode 100644 lib/libc/db/test/hash.tests/tread2.c delete mode 100644 lib/libc/db/test/hash.tests/tseq.c delete mode 100644 lib/libc/db/test/hash.tests/tverify.c delete mode 100644 lib/libc/db/test/run.test delete mode 100644 lib/libc/gen/Makefile.inc delete mode 100644 lib/libc/gen/__xuname.c delete mode 100644 lib/libc/gen/_rand48.c delete mode 100644 lib/libc/gen/_spinlock_stub.c delete mode 100644 lib/libc/gen/alarm.3 delete mode 100644 lib/libc/gen/alarm.c delete mode 100644 lib/libc/gen/arc4random.3 delete mode 100644 lib/libc/gen/arc4random.c delete mode 100644 lib/libc/gen/assert.c delete mode 100644 lib/libc/gen/clock.3 delete mode 100644 lib/libc/gen/clock.c delete mode 100644 lib/libc/gen/closedir.c delete mode 100644 lib/libc/gen/confstr.3 delete mode 100644 lib/libc/gen/confstr.c delete mode 100644 lib/libc/gen/crypt.c delete mode 100644 lib/libc/gen/ctermid.3 delete mode 100644 lib/libc/gen/ctermid.c delete mode 100644 lib/libc/gen/daemon.3 delete mode 100644 lib/libc/gen/daemon.c delete mode 100644 lib/libc/gen/devname.3 delete mode 100644 lib/libc/gen/devname.c delete mode 100644 lib/libc/gen/directory.3 delete mode 100644 lib/libc/gen/disklabel.c delete mode 100644 lib/libc/gen/dladdr.3 delete mode 100644 lib/libc/gen/dlfcn.c delete mode 100644 lib/libc/gen/dllockinit.3 delete mode 100644 lib/libc/gen/dlopen.3 delete mode 100644 lib/libc/gen/drand48.c delete mode 100644 lib/libc/gen/erand48.c delete mode 100644 lib/libc/gen/err.3 delete mode 100644 lib/libc/gen/err.c delete mode 100644 lib/libc/gen/errlst.c delete mode 100644 lib/libc/gen/exec.3 delete mode 100644 lib/libc/gen/exec.c delete mode 100644 lib/libc/gen/fnmatch.3 delete mode 100644 lib/libc/gen/fnmatch.c delete mode 100644 lib/libc/gen/frexp.3 delete mode 100644 lib/libc/gen/fstab.c delete mode 100644 lib/libc/gen/ftok.3 delete mode 100644 lib/libc/gen/ftok.c delete mode 100644 lib/libc/gen/fts-compat.c delete mode 100644 lib/libc/gen/fts-compat.h delete mode 100644 lib/libc/gen/fts.3 delete mode 100644 lib/libc/gen/fts.c delete mode 100644 lib/libc/gen/getbootfile.3 delete mode 100644 lib/libc/gen/getbootfile.c delete mode 100644 lib/libc/gen/getbsize.3 delete mode 100644 lib/libc/gen/getbsize.c delete mode 100644 lib/libc/gen/getcap.3 delete mode 100644 lib/libc/gen/getcap.c delete mode 100644 lib/libc/gen/getcwd.3 delete mode 100644 lib/libc/gen/getcwd.c delete mode 100644 lib/libc/gen/getdiskbyname.3 delete mode 100644 lib/libc/gen/getdomainname.3 delete mode 100644 lib/libc/gen/getdomainname.c delete mode 100644 lib/libc/gen/getfsent.3 delete mode 100644 lib/libc/gen/getgrent.3 delete mode 100644 lib/libc/gen/getgrent.c delete mode 100644 lib/libc/gen/getgrouplist.3 delete mode 100644 lib/libc/gen/getgrouplist.c delete mode 100644 lib/libc/gen/gethostname.3 delete mode 100644 lib/libc/gen/gethostname.c delete mode 100644 lib/libc/gen/getloadavg.3 delete mode 100644 lib/libc/gen/getloadavg.c delete mode 100644 lib/libc/gen/getlogin.c delete mode 100644 lib/libc/gen/getmntinfo.3 delete mode 100644 lib/libc/gen/getmntinfo.c delete mode 100644 lib/libc/gen/getnetgrent.3 delete mode 100644 lib/libc/gen/getnetgrent.c delete mode 100644 lib/libc/gen/getobjformat.3 delete mode 100644 lib/libc/gen/getobjformat.c delete mode 100644 lib/libc/gen/getosreldate.c delete mode 100644 lib/libc/gen/getpagesize.3 delete mode 100644 lib/libc/gen/getpagesize.c delete mode 100644 lib/libc/gen/getpass.3 delete mode 100644 lib/libc/gen/getpass.c delete mode 100644 lib/libc/gen/getpwent.3 delete mode 100644 lib/libc/gen/getpwent.c delete mode 100644 lib/libc/gen/getttyent.3 delete mode 100644 lib/libc/gen/getttyent.c delete mode 100644 lib/libc/gen/getusershell.3 delete mode 100644 lib/libc/gen/getusershell.c delete mode 100644 lib/libc/gen/getvfsbyname.3 delete mode 100644 lib/libc/gen/getvfsbyname.c delete mode 100644 lib/libc/gen/getvfsent.3 delete mode 100644 lib/libc/gen/getvfsent.c delete mode 100644 lib/libc/gen/glob.3 delete mode 100644 lib/libc/gen/glob.c delete mode 100644 lib/libc/gen/initgroups.3 delete mode 100644 lib/libc/gen/initgroups.c delete mode 100644 lib/libc/gen/isatty.c delete mode 100644 lib/libc/gen/isinf.3 delete mode 100644 lib/libc/gen/jrand48.c delete mode 100644 lib/libc/gen/lcong48.c delete mode 100644 lib/libc/gen/ldexp.3 delete mode 100644 lib/libc/gen/lockf.3 delete mode 100644 lib/libc/gen/lockf.c delete mode 100644 lib/libc/gen/lrand48.c delete mode 100644 lib/libc/gen/modf.3 delete mode 100644 lib/libc/gen/mrand48.c delete mode 100644 lib/libc/gen/msgctl.3 delete mode 100644 lib/libc/gen/msgctl.c delete mode 100644 lib/libc/gen/msgget.3 delete mode 100644 lib/libc/gen/msgget.c delete mode 100644 lib/libc/gen/msgrcv.3 delete mode 100644 lib/libc/gen/msgrcv.c delete mode 100644 lib/libc/gen/msgsnd.3 delete mode 100644 lib/libc/gen/msgsnd.c delete mode 100644 lib/libc/gen/nice.3 delete mode 100644 lib/libc/gen/nice.c delete mode 100644 lib/libc/gen/nlist.3 delete mode 100644 lib/libc/gen/nlist.c delete mode 100644 lib/libc/gen/nrand48.c delete mode 100644 lib/libc/gen/ntp_gettime.c delete mode 100644 lib/libc/gen/opendir.c delete mode 100644 lib/libc/gen/pause.3 delete mode 100644 lib/libc/gen/pause.c delete mode 100644 lib/libc/gen/popen.3 delete mode 100644 lib/libc/gen/popen.c delete mode 100644 lib/libc/gen/psignal.3 delete mode 100644 lib/libc/gen/psignal.c delete mode 100644 lib/libc/gen/pw_scan.c delete mode 100644 lib/libc/gen/pw_scan.h delete mode 100644 lib/libc/gen/pwcache.3 delete mode 100644 lib/libc/gen/pwcache.c delete mode 100644 lib/libc/gen/raise.3 delete mode 100644 lib/libc/gen/raise.c delete mode 100644 lib/libc/gen/rand48.3 delete mode 100644 lib/libc/gen/rand48.h delete mode 100644 lib/libc/gen/readdir.c delete mode 100644 lib/libc/gen/rewinddir.c delete mode 100644 lib/libc/gen/scandir.3 delete mode 100644 lib/libc/gen/scandir.c delete mode 100644 lib/libc/gen/seed48.c delete mode 100644 lib/libc/gen/seekdir.c delete mode 100644 lib/libc/gen/sem_destroy.3 delete mode 100644 lib/libc/gen/sem_getvalue.3 delete mode 100644 lib/libc/gen/sem_init.3 delete mode 100644 lib/libc/gen/sem_open.3 delete mode 100644 lib/libc/gen/sem_post.3 delete mode 100644 lib/libc/gen/sem_wait.3 delete mode 100644 lib/libc/gen/semconfig.c delete mode 100644 lib/libc/gen/semctl.c delete mode 100644 lib/libc/gen/semget.c delete mode 100644 lib/libc/gen/semop.c delete mode 100644 lib/libc/gen/setdomainname.c delete mode 100644 lib/libc/gen/setflags.3 delete mode 100644 lib/libc/gen/setflags.c delete mode 100644 lib/libc/gen/setflagsbyname.3 delete mode 100644 lib/libc/gen/setflagsbyname.c delete mode 100644 lib/libc/gen/sethostname.c delete mode 100644 lib/libc/gen/setjmp.3 delete mode 100644 lib/libc/gen/setjmperr.c delete mode 100644 lib/libc/gen/setmode.3 delete mode 100644 lib/libc/gen/setmode.c delete mode 100644 lib/libc/gen/setproctitle.3 delete mode 100644 lib/libc/gen/setproctitle.c delete mode 100644 lib/libc/gen/shmat.c delete mode 100644 lib/libc/gen/shmctl.c delete mode 100644 lib/libc/gen/shmdt.c delete mode 100644 lib/libc/gen/shmget.c delete mode 100644 lib/libc/gen/siginterrupt.3 delete mode 100644 lib/libc/gen/siginterrupt.c delete mode 100644 lib/libc/gen/siglist.c delete mode 100644 lib/libc/gen/signal.3 delete mode 100644 lib/libc/gen/signal.c delete mode 100644 lib/libc/gen/sigsetops.3 delete mode 100644 lib/libc/gen/sigsetops.c delete mode 100644 lib/libc/gen/sleep.3 delete mode 100644 lib/libc/gen/sleep.c delete mode 100644 lib/libc/gen/srand48.c delete mode 100644 lib/libc/gen/stringlist.3 delete mode 100644 lib/libc/gen/stringlist.c delete mode 100644 lib/libc/gen/strtofflags.3 delete mode 100644 lib/libc/gen/strtofflags.c delete mode 100644 lib/libc/gen/sysconf.3 delete mode 100644 lib/libc/gen/sysconf.c delete mode 100644 lib/libc/gen/sysctl.3 delete mode 100644 lib/libc/gen/sysctl.c delete mode 100644 lib/libc/gen/sysctlbyname.c delete mode 100644 lib/libc/gen/syslog.3 delete mode 100644 lib/libc/gen/syslog.c delete mode 100644 lib/libc/gen/tcgetpgrp.3 delete mode 100644 lib/libc/gen/tcsendbreak.3 delete mode 100644 lib/libc/gen/tcsetattr.3 delete mode 100644 lib/libc/gen/tcsetpgrp.3 delete mode 100644 lib/libc/gen/telldir.c delete mode 100644 lib/libc/gen/termios.c delete mode 100644 lib/libc/gen/time.3 delete mode 100644 lib/libc/gen/time.c delete mode 100644 lib/libc/gen/times.3 delete mode 100644 lib/libc/gen/times.c delete mode 100644 lib/libc/gen/timezone.3 delete mode 100644 lib/libc/gen/timezone.c delete mode 100644 lib/libc/gen/ttyname.3 delete mode 100644 lib/libc/gen/ttyname.c delete mode 100644 lib/libc/gen/ttyslot.c delete mode 100644 lib/libc/gen/tzset.3 delete mode 100644 lib/libc/gen/ualarm.3 delete mode 100644 lib/libc/gen/ualarm.c delete mode 100644 lib/libc/gen/uname.3 delete mode 100644 lib/libc/gen/uname.c delete mode 100644 lib/libc/gen/unvis.3 delete mode 100644 lib/libc/gen/unvis.c delete mode 100644 lib/libc/gen/usleep.3 delete mode 100644 lib/libc/gen/usleep.c delete mode 100644 lib/libc/gen/utime.3 delete mode 100644 lib/libc/gen/utime.c delete mode 100644 lib/libc/gen/valloc.3 delete mode 100644 lib/libc/gen/valloc.c delete mode 100644 lib/libc/gen/vis.3 delete mode 100644 lib/libc/gen/vis.c delete mode 100644 lib/libc/gen/wait.c delete mode 100644 lib/libc/gen/wait3.c delete mode 100644 lib/libc/gen/waitpid.c delete mode 100644 lib/libc/gmon/Makefile.inc delete mode 100644 lib/libc/gmon/gmon.c delete mode 100644 lib/libc/gmon/mcount.c delete mode 100644 lib/libc/gmon/moncontrol.3 delete mode 100644 lib/libc/i386/DEFS.h delete mode 100644 lib/libc/i386/SYS.h delete mode 100644 lib/libc/i386/gen/Makefile.inc delete mode 100644 lib/libc/i386/gen/_setjmp.S delete mode 100644 lib/libc/i386/gen/alloca.S delete mode 100644 lib/libc/i386/gen/fabs.S delete mode 100644 lib/libc/i386/gen/frexp.c delete mode 100644 lib/libc/i386/gen/infinity.c delete mode 100644 lib/libc/i386/gen/isinf.c delete mode 100644 lib/libc/i386/gen/ldexp.c delete mode 100644 lib/libc/i386/gen/modf.S delete mode 100644 lib/libc/i386/gen/setjmp.S delete mode 100644 lib/libc/i386/gen/sigsetjmp.S delete mode 100644 lib/libc/i386/net/Makefile.inc delete mode 100644 lib/libc/i386/net/htonl.S delete mode 100644 lib/libc/i386/net/htons.S delete mode 100644 lib/libc/i386/net/ntohl.S delete mode 100644 lib/libc/i386/net/ntohs.S delete mode 100644 lib/libc/i386/stdlib/Makefile.inc delete mode 100644 lib/libc/i386/stdlib/abs.S delete mode 100644 lib/libc/i386/stdlib/div.S delete mode 100644 lib/libc/i386/stdlib/labs.S delete mode 100644 lib/libc/i386/stdlib/ldiv.S delete mode 100644 lib/libc/i386/string/Makefile.inc delete mode 100644 lib/libc/i386/string/bcmp.S delete mode 100644 lib/libc/i386/string/bcopy.S delete mode 100644 lib/libc/i386/string/bzero.S delete mode 100644 lib/libc/i386/string/ffs.S delete mode 100644 lib/libc/i386/string/index.S delete mode 100644 lib/libc/i386/string/memchr.S delete mode 100644 lib/libc/i386/string/memcmp.S delete mode 100644 lib/libc/i386/string/memcpy.S delete mode 100644 lib/libc/i386/string/memmove.S delete mode 100644 lib/libc/i386/string/memset.S delete mode 100644 lib/libc/i386/string/rindex.S delete mode 100644 lib/libc/i386/string/strcat.S delete mode 100644 lib/libc/i386/string/strchr.S delete mode 100644 lib/libc/i386/string/strcmp.S delete mode 100644 lib/libc/i386/string/strcpy.S delete mode 100644 lib/libc/i386/string/strlen.S delete mode 100644 lib/libc/i386/string/strncmp.S delete mode 100644 lib/libc/i386/string/strrchr.S delete mode 100644 lib/libc/i386/string/swab.S delete mode 100644 lib/libc/i386/sys/Makefile.inc delete mode 100644 lib/libc/i386/sys/Ovfork.S delete mode 100644 lib/libc/i386/sys/brk.S delete mode 100644 lib/libc/i386/sys/cerror.S delete mode 100644 lib/libc/i386/sys/exect.S delete mode 100644 lib/libc/i386/sys/fork.S delete mode 100644 lib/libc/i386/sys/i386_get_ioperm.2 delete mode 100644 lib/libc/i386/sys/i386_get_ioperm.c delete mode 100644 lib/libc/i386/sys/i386_get_ldt.2 delete mode 100644 lib/libc/i386/sys/i386_get_ldt.c delete mode 100644 lib/libc/i386/sys/i386_set_ioperm.c delete mode 100644 lib/libc/i386/sys/i386_set_ldt.c delete mode 100644 lib/libc/i386/sys/i386_vm86.2 delete mode 100644 lib/libc/i386/sys/i386_vm86.c delete mode 100644 lib/libc/i386/sys/pipe.S delete mode 100644 lib/libc/i386/sys/ptrace.S delete mode 100644 lib/libc/i386/sys/reboot.S delete mode 100644 lib/libc/i386/sys/rfork.S delete mode 100644 lib/libc/i386/sys/sbrk.S delete mode 100644 lib/libc/i386/sys/setlogin.S delete mode 100644 lib/libc/i386/sys/sigreturn.S delete mode 100644 lib/libc/i386/sys/syscall.S delete mode 100644 lib/libc/include/libc_private.h delete mode 100644 lib/libc/include/spinlock.h delete mode 100644 lib/libc/locale/Makefile.inc delete mode 100644 lib/libc/locale/ansi.c delete mode 100644 lib/libc/locale/big5.c delete mode 100644 lib/libc/locale/collate.c delete mode 100644 lib/libc/locale/collate.h delete mode 100644 lib/libc/locale/collcmp.c delete mode 100644 lib/libc/locale/ctype.3 delete mode 100644 lib/libc/locale/euc.4 delete mode 100644 lib/libc/locale/euc.5 delete mode 100644 lib/libc/locale/euc.c delete mode 100644 lib/libc/locale/frune.c delete mode 100644 lib/libc/locale/isalnum.3 delete mode 100644 lib/libc/locale/isalpha.3 delete mode 100644 lib/libc/locale/isascii.3 delete mode 100644 lib/libc/locale/isblank.3 delete mode 100644 lib/libc/locale/iscntrl.3 delete mode 100644 lib/libc/locale/isctype.c delete mode 100644 lib/libc/locale/isdigit.3 delete mode 100644 lib/libc/locale/isgraph.3 delete mode 100644 lib/libc/locale/islower.3 delete mode 100644 lib/libc/locale/isprint.3 delete mode 100644 lib/libc/locale/ispunct.3 delete mode 100644 lib/libc/locale/isspace.3 delete mode 100644 lib/libc/locale/isupper.3 delete mode 100644 lib/libc/locale/isxdigit.3 delete mode 100644 lib/libc/locale/lconv.c delete mode 100644 lib/libc/locale/localeconv.c delete mode 100644 lib/libc/locale/mbrune.3 delete mode 100644 lib/libc/locale/mbrune.c delete mode 100644 lib/libc/locale/mskanji.c delete mode 100644 lib/libc/locale/multibyte.3 delete mode 100644 lib/libc/locale/nomacros.c delete mode 100644 lib/libc/locale/none.c delete mode 100644 lib/libc/locale/rune.3 delete mode 100644 lib/libc/locale/rune.c delete mode 100644 lib/libc/locale/runetype.c delete mode 100644 lib/libc/locale/setinvalidrune.c delete mode 100644 lib/libc/locale/setlocale.3 delete mode 100644 lib/libc/locale/setlocale.c delete mode 100644 lib/libc/locale/setlocale.h delete mode 100644 lib/libc/locale/setrunelocale.c delete mode 100644 lib/libc/locale/table.c delete mode 100644 lib/libc/locale/toascii.3 delete mode 100644 lib/libc/locale/tolower.3 delete mode 100644 lib/libc/locale/tolower.c delete mode 100644 lib/libc/locale/toupper.3 delete mode 100644 lib/libc/locale/toupper.c delete mode 100644 lib/libc/locale/utf2.4 delete mode 100644 lib/libc/locale/utf2.5 delete mode 100644 lib/libc/locale/utf2.c delete mode 100644 lib/libc/mips/:errfix delete mode 100644 lib/libc/mips/Makefile.inc delete mode 100644 lib/libc/mips/SYS.h delete mode 100644 lib/libc/mips/gen/Makefile.inc delete mode 100644 lib/libc/mips/gen/_setjmp.S delete mode 100644 lib/libc/mips/gen/fabs.S delete mode 100644 lib/libc/mips/gen/flt_rounds.c delete mode 100644 lib/libc/mips/gen/fpgetmask.c delete mode 100644 lib/libc/mips/gen/fpgetround.c delete mode 100644 lib/libc/mips/gen/fpgetsticky.c delete mode 100644 lib/libc/mips/gen/fpsetmask.c delete mode 100644 lib/libc/mips/gen/fpsetround.c delete mode 100644 lib/libc/mips/gen/fpsetsticky.c delete mode 100644 lib/libc/mips/gen/frexp.c delete mode 100644 lib/libc/mips/gen/infinity.c delete mode 100644 lib/libc/mips/gen/isinf.S delete mode 100644 lib/libc/mips/gen/ldexp.S delete mode 100644 lib/libc/mips/gen/modf.S delete mode 100644 lib/libc/mips/gen/setjmp.S delete mode 100644 lib/libc/mips/gen/sigsetjmp.S delete mode 100644 lib/libc/mips/net/Makefile.inc delete mode 100644 lib/libc/mips/net/htonl.S delete mode 100644 lib/libc/mips/net/htons.S delete mode 100644 lib/libc/mips/stdlib/Makefile.inc delete mode 100644 lib/libc/mips/string/Makefile.inc delete mode 100644 lib/libc/mips/string/bcmp.S delete mode 100644 lib/libc/mips/string/bcopy.S delete mode 100644 lib/libc/mips/string/bzero.S delete mode 100644 lib/libc/mips/string/ffs.S delete mode 100644 lib/libc/mips/string/index.S delete mode 100644 lib/libc/mips/string/rindex.S delete mode 100644 lib/libc/mips/string/strcmp.S delete mode 100644 lib/libc/mips/string/strlen.S delete mode 100644 lib/libc/mips/sys/Makefile.inc delete mode 100644 lib/libc/mips/sys/Ovfork.S delete mode 100644 lib/libc/mips/sys/brk.S delete mode 100644 lib/libc/mips/sys/cerror.S delete mode 100644 lib/libc/mips/sys/exect.S delete mode 100644 lib/libc/mips/sys/fork.S delete mode 100644 lib/libc/mips/sys/pipe.S delete mode 100644 lib/libc/mips/sys/ptrace.S delete mode 100644 lib/libc/mips/sys/sbrk.S delete mode 100644 lib/libc/mips/sys/setlogin.S delete mode 100644 lib/libc/mips/sys/sigpending.S delete mode 100644 lib/libc/mips/sys/sigprocmask.S delete mode 100644 lib/libc/mips/sys/sigreturn.S delete mode 100644 lib/libc/mips/sys/sigsuspend.S delete mode 100644 lib/libc/mips/sys/syscall.S delete mode 100644 lib/libc/mipseb/Makefile.inc delete mode 100644 lib/libc/mipseb/SYS.h delete mode 100644 lib/libc/mipseb/gen/Makefile.inc delete mode 100644 lib/libc/mipseb/net/Makefile.inc delete mode 100644 lib/libc/mipseb/stdlib/Makefile.inc delete mode 100644 lib/libc/mipseb/string/Makefile.inc delete mode 100644 lib/libc/mipseb/sys/Makefile.inc delete mode 100644 lib/libc/mipsel/Makefile.inc delete mode 100644 lib/libc/mipsel/SYS.h delete mode 100644 lib/libc/mipsel/gen/Makefile.inc delete mode 100644 lib/libc/mipsel/net/Makefile.inc delete mode 100644 lib/libc/mipsel/stdlib/Makefile.inc delete mode 100644 lib/libc/mipsel/string/Makefile.inc delete mode 100644 lib/libc/mipsel/sys/Makefile.inc delete mode 100644 lib/libc/net/Makefile.inc delete mode 100644 lib/libc/net/addr2ascii.3 delete mode 100644 lib/libc/net/addr2ascii.c delete mode 100644 lib/libc/net/ascii2addr.c delete mode 100644 lib/libc/net/base64.c delete mode 100644 lib/libc/net/byteorder.3 delete mode 100644 lib/libc/net/ether_addr.c delete mode 100644 lib/libc/net/ethers.3 delete mode 100644 lib/libc/net/getaddrinfo.3 delete mode 100644 lib/libc/net/getaddrinfo.c delete mode 100644 lib/libc/net/gethostbydns.c delete mode 100644 lib/libc/net/gethostbyht.c delete mode 100644 lib/libc/net/gethostbyname.3 delete mode 100644 lib/libc/net/gethostbynis.c delete mode 100644 lib/libc/net/gethostnamadr.c delete mode 100644 lib/libc/net/getipnodebyname.3 delete mode 100644 lib/libc/net/getnameinfo.3 delete mode 100644 lib/libc/net/getnameinfo.c delete mode 100644 lib/libc/net/getnetbydns.c delete mode 100644 lib/libc/net/getnetbyht.c delete mode 100644 lib/libc/net/getnetbynis.c delete mode 100644 lib/libc/net/getnetent.3 delete mode 100644 lib/libc/net/getnetnamadr.c delete mode 100644 lib/libc/net/getproto.c delete mode 100644 lib/libc/net/getprotoent.3 delete mode 100644 lib/libc/net/getprotoent.c delete mode 100644 lib/libc/net/getprotoname.c delete mode 100644 lib/libc/net/getservbyname.c delete mode 100644 lib/libc/net/getservbyport.c delete mode 100644 lib/libc/net/getservent.3 delete mode 100644 lib/libc/net/getservent.c delete mode 100644 lib/libc/net/herror.c delete mode 100644 lib/libc/net/if_indextoname.3 delete mode 100644 lib/libc/net/ifname.c delete mode 100644 lib/libc/net/inet.3 delete mode 100644 lib/libc/net/inet6_option_space.3 delete mode 100644 lib/libc/net/inet6_rthdr_space.3 delete mode 100644 lib/libc/net/inet_addr.c delete mode 100644 lib/libc/net/inet_lnaof.c delete mode 100644 lib/libc/net/inet_makeaddr.c delete mode 100644 lib/libc/net/inet_net_ntop.c delete mode 100644 lib/libc/net/inet_net_pton.c delete mode 100644 lib/libc/net/inet_neta.c delete mode 100644 lib/libc/net/inet_netof.c delete mode 100644 lib/libc/net/inet_network.c delete mode 100644 lib/libc/net/inet_ntoa.c delete mode 100644 lib/libc/net/inet_ntop.c delete mode 100644 lib/libc/net/inet_pton.c delete mode 100644 lib/libc/net/ip6opt.c delete mode 100644 lib/libc/net/iso_addr.3 delete mode 100644 lib/libc/net/iso_addr.c delete mode 100644 lib/libc/net/linkaddr.3 delete mode 100644 lib/libc/net/linkaddr.c delete mode 100644 lib/libc/net/map_v4v6.c delete mode 100644 lib/libc/net/name6.c delete mode 100644 lib/libc/net/ns.3 delete mode 100644 lib/libc/net/ns_addr.c delete mode 100644 lib/libc/net/ns_name.c delete mode 100644 lib/libc/net/ns_netint.c delete mode 100644 lib/libc/net/ns_ntoa.c delete mode 100644 lib/libc/net/ns_parse.c delete mode 100644 lib/libc/net/ns_print.c delete mode 100644 lib/libc/net/ns_ttl.c delete mode 100644 lib/libc/net/nsap_addr.c delete mode 100644 lib/libc/net/rcmd.3 delete mode 100644 lib/libc/net/rcmd.c delete mode 100644 lib/libc/net/recv.c delete mode 100644 lib/libc/net/res_comp.c delete mode 100644 lib/libc/net/res_config.h delete mode 100644 lib/libc/net/res_data.c delete mode 100644 lib/libc/net/res_debug.c delete mode 100644 lib/libc/net/res_init.c delete mode 100644 lib/libc/net/res_mkquery.c delete mode 100644 lib/libc/net/res_mkupdate.c delete mode 100644 lib/libc/net/res_query.c delete mode 100644 lib/libc/net/res_send.c delete mode 100644 lib/libc/net/res_update.c delete mode 100644 lib/libc/net/resolver.3 delete mode 100644 lib/libc/net/rthdr.c delete mode 100644 lib/libc/net/send.c delete mode 100644 lib/libc/net/vars.c delete mode 100644 lib/libc/nls/Makefile.inc delete mode 100644 lib/libc/nls/catclose.3 delete mode 100644 lib/libc/nls/catclose.c delete mode 100644 lib/libc/nls/catgets.3 delete mode 100644 lib/libc/nls/catgets.c delete mode 100644 lib/libc/nls/catopen.3 delete mode 100644 lib/libc/nls/catopen.c delete mode 100644 lib/libc/nls/msgcat.c delete mode 100644 lib/libc/nls/msgcat.h delete mode 100644 lib/libc/posix1e/Makefile delete mode 100644 lib/libc/posix1e/acl.3 delete mode 100644 lib/libc/posix1e/acl_delete.3 delete mode 100644 lib/libc/posix1e/acl_delete.c delete mode 100644 lib/libc/posix1e/acl_dup.3 delete mode 100644 lib/libc/posix1e/acl_free.3 delete mode 100644 lib/libc/posix1e/acl_free.c delete mode 100644 lib/libc/posix1e/acl_from_text.3 delete mode 100644 lib/libc/posix1e/acl_from_text.c delete mode 100644 lib/libc/posix1e/acl_get.3 delete mode 100644 lib/libc/posix1e/acl_get.c delete mode 100644 lib/libc/posix1e/acl_init.3 delete mode 100644 lib/libc/posix1e/acl_init.c delete mode 100644 lib/libc/posix1e/acl_set.3 delete mode 100644 lib/libc/posix1e/acl_set.c delete mode 100644 lib/libc/posix1e/acl_support.c delete mode 100644 lib/libc/posix1e/acl_support.h delete mode 100644 lib/libc/posix1e/acl_to_text.3 delete mode 100644 lib/libc/posix1e/acl_to_text.c delete mode 100644 lib/libc/posix1e/acl_valid.3 delete mode 100644 lib/libc/posix1e/acl_valid.c delete mode 100644 lib/libc/posix1e/posix1e.3 delete mode 100644 lib/libc/quad/Makefile.inc delete mode 100644 lib/libc/quad/TESTS/Makefile delete mode 100644 lib/libc/quad/TESTS/divrem.c delete mode 100644 lib/libc/quad/TESTS/mul.c delete mode 100644 lib/libc/quad/adddi3.c delete mode 100644 lib/libc/quad/anddi3.c delete mode 100644 lib/libc/quad/ashldi3.c delete mode 100644 lib/libc/quad/ashrdi3.c delete mode 100644 lib/libc/quad/cmpdi2.c delete mode 100644 lib/libc/quad/divdi3.c delete mode 100644 lib/libc/quad/fixdfdi.c delete mode 100644 lib/libc/quad/fixsfdi.c delete mode 100644 lib/libc/quad/fixunsdfdi.c delete mode 100644 lib/libc/quad/fixunssfdi.c delete mode 100644 lib/libc/quad/floatdidf.c delete mode 100644 lib/libc/quad/floatdisf.c delete mode 100644 lib/libc/quad/floatunsdidf.c delete mode 100644 lib/libc/quad/iordi3.c delete mode 100644 lib/libc/quad/lshldi3.c delete mode 100644 lib/libc/quad/lshrdi3.c delete mode 100644 lib/libc/quad/moddi3.c delete mode 100644 lib/libc/quad/muldi3.c delete mode 100644 lib/libc/quad/negdi2.c delete mode 100644 lib/libc/quad/notdi2.c delete mode 100644 lib/libc/quad/qdivrem.c delete mode 100644 lib/libc/quad/quad.h delete mode 100644 lib/libc/quad/subdi3.c delete mode 100644 lib/libc/quad/ucmpdi2.c delete mode 100644 lib/libc/quad/udivdi3.c delete mode 100644 lib/libc/quad/umoddi3.c delete mode 100644 lib/libc/quad/xordi3.c delete mode 100644 lib/libc/regex/COPYRIGHT delete mode 100644 lib/libc/regex/Makefile.inc delete mode 100644 lib/libc/regex/WHATSNEW delete mode 100644 lib/libc/regex/cclass.h delete mode 100644 lib/libc/regex/cname.h delete mode 100644 lib/libc/regex/engine.c delete mode 100644 lib/libc/regex/re_format.7 delete mode 100644 lib/libc/regex/regcomp.c delete mode 100644 lib/libc/regex/regerror.c delete mode 100644 lib/libc/regex/regex.3 delete mode 100644 lib/libc/regex/regex2.h delete mode 100644 lib/libc/regex/regexec.c delete mode 100644 lib/libc/regex/regfree.c delete mode 100644 lib/libc/regex/utils.h delete mode 100644 lib/libc/rpc/DISCLAIMER delete mode 100644 lib/libc/rpc/Makefile.inc delete mode 100644 lib/libc/rpc/PSD.doc/nfs.rfc.ms delete mode 100644 lib/libc/rpc/PSD.doc/rpc.prog.ms delete mode 100644 lib/libc/rpc/PSD.doc/rpc.rfc.ms delete mode 100644 lib/libc/rpc/PSD.doc/rpcgen.ms delete mode 100644 lib/libc/rpc/PSD.doc/xdr.nts.ms delete mode 100644 lib/libc/rpc/PSD.doc/xdr.rfc.ms delete mode 100644 lib/libc/rpc/README delete mode 100644 lib/libc/rpc/auth_des.c delete mode 100644 lib/libc/rpc/auth_none.c delete mode 100644 lib/libc/rpc/auth_time.c delete mode 100644 lib/libc/rpc/auth_unix.c delete mode 100644 lib/libc/rpc/authdes_prot.c delete mode 100644 lib/libc/rpc/authunix_prot.c delete mode 100644 lib/libc/rpc/bindresvport.3 delete mode 100644 lib/libc/rpc/bindresvport.c delete mode 100644 lib/libc/rpc/clnt_generic.c delete mode 100644 lib/libc/rpc/clnt_perror.c delete mode 100644 lib/libc/rpc/clnt_raw.c delete mode 100644 lib/libc/rpc/clnt_simple.c delete mode 100644 lib/libc/rpc/clnt_tcp.c delete mode 100644 lib/libc/rpc/clnt_udp.c delete mode 100644 lib/libc/rpc/clnt_unix.c delete mode 100644 lib/libc/rpc/crypt_client.c delete mode 100644 lib/libc/rpc/des_crypt.3 delete mode 100644 lib/libc/rpc/des_crypt.c delete mode 100644 lib/libc/rpc/des_soft.c delete mode 100644 lib/libc/rpc/get_myaddress.c delete mode 100644 lib/libc/rpc/getpublickey.c delete mode 100644 lib/libc/rpc/getrpcent.3 delete mode 100644 lib/libc/rpc/getrpcent.c delete mode 100644 lib/libc/rpc/getrpcport.3 delete mode 100644 lib/libc/rpc/getrpcport.c delete mode 100644 lib/libc/rpc/key_call.c delete mode 100644 lib/libc/rpc/key_prot_xdr.c delete mode 100644 lib/libc/rpc/netname.c delete mode 100644 lib/libc/rpc/netnamer.c delete mode 100644 lib/libc/rpc/pmap_clnt.c delete mode 100644 lib/libc/rpc/pmap_getmaps.c delete mode 100644 lib/libc/rpc/pmap_getport.c delete mode 100644 lib/libc/rpc/pmap_prot.c delete mode 100644 lib/libc/rpc/pmap_prot2.c delete mode 100644 lib/libc/rpc/pmap_rmt.c delete mode 100644 lib/libc/rpc/publickey.3 delete mode 100644 lib/libc/rpc/publickey.5 delete mode 100644 lib/libc/rpc/rpc.3 delete mode 100644 lib/libc/rpc/rpc.5 delete mode 100644 lib/libc/rpc/rpc_callmsg.c delete mode 100644 lib/libc/rpc/rpc_commondata.c delete mode 100644 lib/libc/rpc/rpc_dtablesize.c delete mode 100644 lib/libc/rpc/rpc_prot.c delete mode 100644 lib/libc/rpc/rpc_secure.3 delete mode 100644 lib/libc/rpc/rpcdname.c delete mode 100644 lib/libc/rpc/rstat.1 delete mode 100644 lib/libc/rpc/rstat_svc.8 delete mode 100644 lib/libc/rpc/rtime.3 delete mode 100644 lib/libc/rpc/rtime.c delete mode 100644 lib/libc/rpc/svc.c delete mode 100644 lib/libc/rpc/svc_auth.c delete mode 100644 lib/libc/rpc/svc_auth_des.c delete mode 100644 lib/libc/rpc/svc_auth_unix.c delete mode 100644 lib/libc/rpc/svc_raw.c delete mode 100644 lib/libc/rpc/svc_run.c delete mode 100644 lib/libc/rpc/svc_simple.c delete mode 100644 lib/libc/rpc/svc_tcp.c delete mode 100644 lib/libc/rpc/svc_udp.c delete mode 100644 lib/libc/rpc/svc_unix.c delete mode 100644 lib/libc/stdio/Makefile.inc delete mode 100644 lib/libc/stdio/_flock_stub.c delete mode 100644 lib/libc/stdio/asprintf.c delete mode 100644 lib/libc/stdio/clrerr.c delete mode 100644 lib/libc/stdio/fclose.3 delete mode 100644 lib/libc/stdio/fclose.c delete mode 100644 lib/libc/stdio/fdopen.c delete mode 100644 lib/libc/stdio/feof.c delete mode 100644 lib/libc/stdio/ferror.3 delete mode 100644 lib/libc/stdio/ferror.c delete mode 100644 lib/libc/stdio/fflush.3 delete mode 100644 lib/libc/stdio/fflush.c delete mode 100644 lib/libc/stdio/fgetc.c delete mode 100644 lib/libc/stdio/fgetln.3 delete mode 100644 lib/libc/stdio/fgetln.c delete mode 100644 lib/libc/stdio/fgetpos.c delete mode 100644 lib/libc/stdio/fgets.3 delete mode 100644 lib/libc/stdio/fgets.c delete mode 100644 lib/libc/stdio/fileno.c delete mode 100644 lib/libc/stdio/findfp.c delete mode 100644 lib/libc/stdio/flags.c delete mode 100644 lib/libc/stdio/floatio.h delete mode 100644 lib/libc/stdio/fopen.3 delete mode 100644 lib/libc/stdio/fopen.c delete mode 100644 lib/libc/stdio/fprintf.c delete mode 100644 lib/libc/stdio/fpurge.c delete mode 100644 lib/libc/stdio/fputc.c delete mode 100644 lib/libc/stdio/fputs.3 delete mode 100644 lib/libc/stdio/fputs.c delete mode 100644 lib/libc/stdio/fread.3 delete mode 100644 lib/libc/stdio/fread.c delete mode 100644 lib/libc/stdio/freopen.c delete mode 100644 lib/libc/stdio/fscanf.c delete mode 100644 lib/libc/stdio/fseek.3 delete mode 100644 lib/libc/stdio/fseek.c delete mode 100644 lib/libc/stdio/fsetpos.c delete mode 100644 lib/libc/stdio/ftell.c delete mode 100644 lib/libc/stdio/funopen.3 delete mode 100644 lib/libc/stdio/funopen.c delete mode 100644 lib/libc/stdio/fvwrite.c delete mode 100644 lib/libc/stdio/fvwrite.h delete mode 100644 lib/libc/stdio/fwalk.c delete mode 100644 lib/libc/stdio/fwrite.c delete mode 100644 lib/libc/stdio/getc.3 delete mode 100644 lib/libc/stdio/getc.c delete mode 100644 lib/libc/stdio/getchar.c delete mode 100644 lib/libc/stdio/gets.c delete mode 100644 lib/libc/stdio/getw.c delete mode 100644 lib/libc/stdio/glue.h delete mode 100644 lib/libc/stdio/local.h delete mode 100644 lib/libc/stdio/makebuf.c delete mode 100644 lib/libc/stdio/mktemp.3 delete mode 100644 lib/libc/stdio/mktemp.c delete mode 100644 lib/libc/stdio/perror.c delete mode 100644 lib/libc/stdio/printf.3 delete mode 100644 lib/libc/stdio/printf.c delete mode 100644 lib/libc/stdio/putc.3 delete mode 100644 lib/libc/stdio/putc.c delete mode 100644 lib/libc/stdio/putchar.c delete mode 100644 lib/libc/stdio/puts.c delete mode 100644 lib/libc/stdio/putw.c delete mode 100644 lib/libc/stdio/refill.c delete mode 100644 lib/libc/stdio/remove.3 delete mode 100644 lib/libc/stdio/remove.c delete mode 100644 lib/libc/stdio/rewind.c delete mode 100644 lib/libc/stdio/rget.c delete mode 100644 lib/libc/stdio/scanf.3 delete mode 100644 lib/libc/stdio/scanf.c delete mode 100644 lib/libc/stdio/setbuf.3 delete mode 100644 lib/libc/stdio/setbuf.c delete mode 100644 lib/libc/stdio/setbuffer.c delete mode 100644 lib/libc/stdio/setvbuf.c delete mode 100644 lib/libc/stdio/snprintf.c delete mode 100644 lib/libc/stdio/sprintf.c delete mode 100644 lib/libc/stdio/sscanf.c delete mode 100644 lib/libc/stdio/stdio.3 delete mode 100644 lib/libc/stdio/stdio.c delete mode 100644 lib/libc/stdio/tempnam.c delete mode 100644 lib/libc/stdio/tmpfile.c delete mode 100644 lib/libc/stdio/tmpnam.3 delete mode 100644 lib/libc/stdio/tmpnam.c delete mode 100644 lib/libc/stdio/ungetc.3 delete mode 100644 lib/libc/stdio/ungetc.c delete mode 100644 lib/libc/stdio/vasprintf.c delete mode 100644 lib/libc/stdio/vfprintf.c delete mode 100644 lib/libc/stdio/vfscanf.c delete mode 100644 lib/libc/stdio/vprintf.c delete mode 100644 lib/libc/stdio/vscanf.c delete mode 100644 lib/libc/stdio/vsnprintf.c delete mode 100644 lib/libc/stdio/vsprintf.c delete mode 100644 lib/libc/stdio/vsscanf.c delete mode 100644 lib/libc/stdio/wbuf.c delete mode 100644 lib/libc/stdio/wsetup.c delete mode 100644 lib/libc/stdlib/Makefile.inc delete mode 100644 lib/libc/stdlib/abort.3 delete mode 100644 lib/libc/stdlib/abort.c delete mode 100644 lib/libc/stdlib/abs.3 delete mode 100644 lib/libc/stdlib/abs.c delete mode 100644 lib/libc/stdlib/alloca.3 delete mode 100644 lib/libc/stdlib/atexit.3 delete mode 100644 lib/libc/stdlib/atexit.c delete mode 100644 lib/libc/stdlib/atexit.h delete mode 100644 lib/libc/stdlib/atof.3 delete mode 100644 lib/libc/stdlib/atof.c delete mode 100644 lib/libc/stdlib/atoi.3 delete mode 100644 lib/libc/stdlib/atoi.c delete mode 100644 lib/libc/stdlib/atol.3 delete mode 100644 lib/libc/stdlib/atol.c delete mode 100644 lib/libc/stdlib/bsearch.3 delete mode 100644 lib/libc/stdlib/bsearch.c delete mode 100644 lib/libc/stdlib/calloc.c delete mode 100644 lib/libc/stdlib/div.3 delete mode 100644 lib/libc/stdlib/div.c delete mode 100644 lib/libc/stdlib/exit.3 delete mode 100644 lib/libc/stdlib/exit.c delete mode 100644 lib/libc/stdlib/getenv.3 delete mode 100644 lib/libc/stdlib/getenv.c delete mode 100644 lib/libc/stdlib/getopt.3 delete mode 100644 lib/libc/stdlib/getopt.c delete mode 100644 lib/libc/stdlib/getsubopt.3 delete mode 100644 lib/libc/stdlib/getsubopt.c delete mode 100644 lib/libc/stdlib/heapsort.c delete mode 100644 lib/libc/stdlib/labs.3 delete mode 100644 lib/libc/stdlib/labs.c delete mode 100644 lib/libc/stdlib/ldiv.3 delete mode 100644 lib/libc/stdlib/ldiv.c delete mode 100644 lib/libc/stdlib/malloc.3 delete mode 100644 lib/libc/stdlib/malloc.c delete mode 100644 lib/libc/stdlib/memory.3 delete mode 100644 lib/libc/stdlib/merge.c delete mode 100644 lib/libc/stdlib/netbsd_strtod.c delete mode 100644 lib/libc/stdlib/putenv.c delete mode 100644 lib/libc/stdlib/qsort.3 delete mode 100644 lib/libc/stdlib/qsort.c delete mode 100644 lib/libc/stdlib/radixsort.3 delete mode 100644 lib/libc/stdlib/radixsort.c delete mode 100644 lib/libc/stdlib/rand.3 delete mode 100644 lib/libc/stdlib/rand.c delete mode 100644 lib/libc/stdlib/random.3 delete mode 100644 lib/libc/stdlib/random.c delete mode 100644 lib/libc/stdlib/reallocf.c delete mode 100644 lib/libc/stdlib/realpath.3 delete mode 100644 lib/libc/stdlib/realpath.c delete mode 100644 lib/libc/stdlib/setenv.c delete mode 100644 lib/libc/stdlib/strhash.c delete mode 100644 lib/libc/stdlib/strtod.3 delete mode 100644 lib/libc/stdlib/strtod.c delete mode 100644 lib/libc/stdlib/strtol.3 delete mode 100644 lib/libc/stdlib/strtol.c delete mode 100644 lib/libc/stdlib/strtoll.c delete mode 100644 lib/libc/stdlib/strtoq.c delete mode 100644 lib/libc/stdlib/strtoul.3 delete mode 100644 lib/libc/stdlib/strtoul.c delete mode 100644 lib/libc/stdlib/strtoull.c delete mode 100644 lib/libc/stdlib/strtouq.c delete mode 100644 lib/libc/stdlib/system.3 delete mode 100644 lib/libc/stdlib/system.c delete mode 100644 lib/libc/stdtime/Makefile.inc delete mode 100644 lib/libc/stdtime/asctime.c delete mode 100644 lib/libc/stdtime/ctime.3 delete mode 100644 lib/libc/stdtime/difftime.c delete mode 100644 lib/libc/stdtime/localtime.c delete mode 100644 lib/libc/stdtime/private.h delete mode 100644 lib/libc/stdtime/strftime.3 delete mode 100644 lib/libc/stdtime/strftime.c delete mode 100644 lib/libc/stdtime/strptime.3 delete mode 100644 lib/libc/stdtime/strptime.c delete mode 100644 lib/libc/stdtime/time2posix.3 delete mode 100644 lib/libc/stdtime/timelocal.c delete mode 100644 lib/libc/stdtime/timelocal.h delete mode 100644 lib/libc/stdtime/tzfile.5 delete mode 100644 lib/libc/stdtime/tzfile.h delete mode 100644 lib/libc/string/Makefile.inc delete mode 100644 lib/libc/string/bcmp.3 delete mode 100644 lib/libc/string/bcmp.c delete mode 100644 lib/libc/string/bcopy.3 delete mode 100644 lib/libc/string/bcopy.c delete mode 100644 lib/libc/string/bstring.3 delete mode 100644 lib/libc/string/bzero.3 delete mode 100644 lib/libc/string/bzero.c delete mode 100644 lib/libc/string/ffs.3 delete mode 100644 lib/libc/string/ffs.c delete mode 100644 lib/libc/string/index.3 delete mode 100644 lib/libc/string/index.c delete mode 100644 lib/libc/string/memccpy.3 delete mode 100644 lib/libc/string/memccpy.c delete mode 100644 lib/libc/string/memchr.3 delete mode 100644 lib/libc/string/memchr.c delete mode 100644 lib/libc/string/memcmp.3 delete mode 100644 lib/libc/string/memcmp.c delete mode 100644 lib/libc/string/memcpy.3 delete mode 100644 lib/libc/string/memcpy.c delete mode 100644 lib/libc/string/memmove.3 delete mode 100644 lib/libc/string/memmove.c delete mode 100644 lib/libc/string/memset.3 delete mode 100644 lib/libc/string/memset.c delete mode 100644 lib/libc/string/rindex.3 delete mode 100644 lib/libc/string/rindex.c delete mode 100644 lib/libc/string/strcasecmp.3 delete mode 100644 lib/libc/string/strcasecmp.c delete mode 100644 lib/libc/string/strcat.3 delete mode 100644 lib/libc/string/strcat.c delete mode 100644 lib/libc/string/strchr.3 delete mode 100644 lib/libc/string/strchr.c delete mode 100644 lib/libc/string/strcmp.3 delete mode 100644 lib/libc/string/strcmp.c delete mode 100644 lib/libc/string/strcoll.3 delete mode 100644 lib/libc/string/strcoll.c delete mode 100644 lib/libc/string/strcpy.3 delete mode 100644 lib/libc/string/strcpy.c delete mode 100644 lib/libc/string/strcspn.3 delete mode 100644 lib/libc/string/strcspn.c delete mode 100644 lib/libc/string/strdup.3 delete mode 100644 lib/libc/string/strdup.c delete mode 100644 lib/libc/string/strerror.3 delete mode 100644 lib/libc/string/strerror.c delete mode 100644 lib/libc/string/string.3 delete mode 100644 lib/libc/string/strlcat.c delete mode 100644 lib/libc/string/strlcpy.3 delete mode 100644 lib/libc/string/strlcpy.c delete mode 100644 lib/libc/string/strlen.3 delete mode 100644 lib/libc/string/strlen.c delete mode 100644 lib/libc/string/strmode.3 delete mode 100644 lib/libc/string/strmode.c delete mode 100644 lib/libc/string/strncat.c delete mode 100644 lib/libc/string/strncmp.c delete mode 100644 lib/libc/string/strncpy.c delete mode 100644 lib/libc/string/strpbrk.3 delete mode 100644 lib/libc/string/strpbrk.c delete mode 100644 lib/libc/string/strrchr.3 delete mode 100644 lib/libc/string/strrchr.c delete mode 100644 lib/libc/string/strsep.3 delete mode 100644 lib/libc/string/strsep.c delete mode 100644 lib/libc/string/strsignal.c delete mode 100644 lib/libc/string/strspn.3 delete mode 100644 lib/libc/string/strspn.c delete mode 100644 lib/libc/string/strstr.3 delete mode 100644 lib/libc/string/strstr.c delete mode 100644 lib/libc/string/strtok.3 delete mode 100644 lib/libc/string/strtok.c delete mode 100644 lib/libc/string/strxfrm.3 delete mode 100644 lib/libc/string/strxfrm.c delete mode 100644 lib/libc/string/swab.3 delete mode 100644 lib/libc/string/swab.c delete mode 100644 lib/libc/sys/Makefile.inc delete mode 100644 lib/libc/sys/__error.c delete mode 100644 lib/libc/sys/_exit.2 delete mode 100644 lib/libc/sys/accept.2 delete mode 100644 lib/libc/sys/access.2 delete mode 100644 lib/libc/sys/acct.2 delete mode 100644 lib/libc/sys/adjtime.2 delete mode 100644 lib/libc/sys/aio_cancel.2 delete mode 100644 lib/libc/sys/aio_error.2 delete mode 100644 lib/libc/sys/aio_read.2 delete mode 100644 lib/libc/sys/aio_return.2 delete mode 100644 lib/libc/sys/aio_suspend.2 delete mode 100644 lib/libc/sys/aio_waitcomplete.2 delete mode 100644 lib/libc/sys/aio_write.2 delete mode 100644 lib/libc/sys/bind.2 delete mode 100644 lib/libc/sys/brk.2 delete mode 100644 lib/libc/sys/chdir.2 delete mode 100644 lib/libc/sys/chflags.2 delete mode 100644 lib/libc/sys/chmod.2 delete mode 100644 lib/libc/sys/chown.2 delete mode 100644 lib/libc/sys/chroot.2 delete mode 100644 lib/libc/sys/clock_gettime.2 delete mode 100644 lib/libc/sys/close.2 delete mode 100644 lib/libc/sys/connect.2 delete mode 100644 lib/libc/sys/dup.2 delete mode 100644 lib/libc/sys/execve.2 delete mode 100644 lib/libc/sys/fcntl.2 delete mode 100644 lib/libc/sys/fhopen.2 delete mode 100644 lib/libc/sys/flock.2 delete mode 100644 lib/libc/sys/fork.2 delete mode 100644 lib/libc/sys/fsync.2 delete mode 100644 lib/libc/sys/ftruncate.c delete mode 100644 lib/libc/sys/getdirentries.2 delete mode 100644 lib/libc/sys/getdtablesize.2 delete mode 100644 lib/libc/sys/getfh.2 delete mode 100644 lib/libc/sys/getfsstat.2 delete mode 100644 lib/libc/sys/getgid.2 delete mode 100644 lib/libc/sys/getgroups.2 delete mode 100644 lib/libc/sys/getitimer.2 delete mode 100644 lib/libc/sys/getlogin.2 delete mode 100644 lib/libc/sys/getpeername.2 delete mode 100644 lib/libc/sys/getpgrp.2 delete mode 100644 lib/libc/sys/getpid.2 delete mode 100644 lib/libc/sys/getpriority.2 delete mode 100644 lib/libc/sys/getrlimit.2 delete mode 100644 lib/libc/sys/getrusage.2 delete mode 100644 lib/libc/sys/getsid.2 delete mode 100644 lib/libc/sys/getsockname.2 delete mode 100644 lib/libc/sys/getsockopt.2 delete mode 100644 lib/libc/sys/gettimeofday.2 delete mode 100644 lib/libc/sys/getuid.2 delete mode 100644 lib/libc/sys/intro.2 delete mode 100644 lib/libc/sys/ioctl.2 delete mode 100644 lib/libc/sys/issetugid.2 delete mode 100644 lib/libc/sys/jail.2 delete mode 100644 lib/libc/sys/kill.2 delete mode 100644 lib/libc/sys/kldfind.2 delete mode 100644 lib/libc/sys/kldfirstmod.2 delete mode 100644 lib/libc/sys/kldload.2 delete mode 100644 lib/libc/sys/kldnext.2 delete mode 100644 lib/libc/sys/kldstat.2 delete mode 100644 lib/libc/sys/kldunload.2 delete mode 100644 lib/libc/sys/ktrace.2 delete mode 100644 lib/libc/sys/link.2 delete mode 100644 lib/libc/sys/listen.2 delete mode 100644 lib/libc/sys/lseek.2 delete mode 100644 lib/libc/sys/lseek.c delete mode 100644 lib/libc/sys/madvise.2 delete mode 100644 lib/libc/sys/mincore.2 delete mode 100644 lib/libc/sys/minherit.2 delete mode 100644 lib/libc/sys/mkdir.2 delete mode 100644 lib/libc/sys/mkfifo.2 delete mode 100644 lib/libc/sys/mknod.2 delete mode 100644 lib/libc/sys/mlock.2 delete mode 100644 lib/libc/sys/mmap.2 delete mode 100644 lib/libc/sys/mmap.c delete mode 100644 lib/libc/sys/mount.2 delete mode 100644 lib/libc/sys/mprotect.2 delete mode 100644 lib/libc/sys/msync.2 delete mode 100644 lib/libc/sys/munmap.2 delete mode 100644 lib/libc/sys/nanosleep.2 delete mode 100644 lib/libc/sys/nfssvc.2 delete mode 100644 lib/libc/sys/open.2 delete mode 100644 lib/libc/sys/pathconf.2 delete mode 100644 lib/libc/sys/pipe.2 delete mode 100644 lib/libc/sys/poll.2 delete mode 100644 lib/libc/sys/pread.c delete mode 100644 lib/libc/sys/profil.2 delete mode 100644 lib/libc/sys/ptrace.2 delete mode 100644 lib/libc/sys/pwrite.c delete mode 100644 lib/libc/sys/quotactl.2 delete mode 100644 lib/libc/sys/read.2 delete mode 100644 lib/libc/sys/readlink.2 delete mode 100644 lib/libc/sys/reboot.2 delete mode 100644 lib/libc/sys/recv.2 delete mode 100644 lib/libc/sys/rename.2 delete mode 100644 lib/libc/sys/revoke.2 delete mode 100644 lib/libc/sys/rfork.2 delete mode 100644 lib/libc/sys/rmdir.2 delete mode 100644 lib/libc/sys/rtprio.2 delete mode 100644 lib/libc/sys/sched_get_priority_max.2 delete mode 100644 lib/libc/sys/sched_setparam.2 delete mode 100644 lib/libc/sys/sched_setscheduler.2 delete mode 100644 lib/libc/sys/sched_yield.2 delete mode 100644 lib/libc/sys/select.2 delete mode 100644 lib/libc/sys/semctl.2 delete mode 100644 lib/libc/sys/semget.2 delete mode 100644 lib/libc/sys/semop.2 delete mode 100644 lib/libc/sys/send.2 delete mode 100644 lib/libc/sys/sendfile.2 delete mode 100644 lib/libc/sys/setgroups.2 delete mode 100644 lib/libc/sys/setpgid.2 delete mode 100644 lib/libc/sys/setregid.2 delete mode 100644 lib/libc/sys/setresuid.2 delete mode 100644 lib/libc/sys/setreuid.2 delete mode 100644 lib/libc/sys/setsid.2 delete mode 100644 lib/libc/sys/setuid.2 delete mode 100644 lib/libc/sys/shmat.2 delete mode 100644 lib/libc/sys/shmctl.2 delete mode 100644 lib/libc/sys/shmget.2 delete mode 100644 lib/libc/sys/shutdown.2 delete mode 100644 lib/libc/sys/sigaction.2 delete mode 100644 lib/libc/sys/sigaltstack.2 delete mode 100644 lib/libc/sys/sigpending.2 delete mode 100644 lib/libc/sys/sigprocmask.2 delete mode 100644 lib/libc/sys/sigreturn.2 delete mode 100644 lib/libc/sys/sigstack.2 delete mode 100644 lib/libc/sys/sigsuspend.2 delete mode 100644 lib/libc/sys/socket.2 delete mode 100644 lib/libc/sys/socketpair.2 delete mode 100644 lib/libc/sys/stat.2 delete mode 100644 lib/libc/sys/statfs.2 delete mode 100644 lib/libc/sys/swapon.2 delete mode 100644 lib/libc/sys/symlink.2 delete mode 100644 lib/libc/sys/sync.2 delete mode 100644 lib/libc/sys/sysarch.2 delete mode 100644 lib/libc/sys/syscall.2 delete mode 100644 lib/libc/sys/truncate.2 delete mode 100644 lib/libc/sys/truncate.c delete mode 100644 lib/libc/sys/umask.2 delete mode 100644 lib/libc/sys/undelete.2 delete mode 100644 lib/libc/sys/unlink.2 delete mode 100644 lib/libc/sys/utimes.2 delete mode 100644 lib/libc/sys/vfork.2 delete mode 100644 lib/libc/sys/wait.2 delete mode 100644 lib/libc/sys/write.2 delete mode 100644 lib/libc/xdr/Makefile.inc delete mode 100644 lib/libc/xdr/xdr.3 delete mode 100644 lib/libc/xdr/xdr.c delete mode 100644 lib/libc/xdr/xdr_array.c delete mode 100644 lib/libc/xdr/xdr_float.c delete mode 100644 lib/libc/xdr/xdr_mem.c delete mode 100644 lib/libc/xdr/xdr_rec.c delete mode 100644 lib/libc/xdr/xdr_reference.c delete mode 100644 lib/libc/xdr/xdr_sizeof.c delete mode 100644 lib/libc/xdr/xdr_stdio.c delete mode 100644 lib/libc/yp/Makefile.inc delete mode 100644 lib/libc/yp/xdryp.c delete mode 100644 lib/libc/yp/yplib.c (limited to 'lib/libc') diff --git a/lib/libc/Makefile b/lib/libc/Makefile deleted file mode 100644 index 8a2afa8..0000000 --- a/lib/libc/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -# @(#)Makefile 8.2 (Berkeley) 2/3/94 -# $FreeBSD$ -# -# All library objects contain rcsid strings by default; they may be -# excluded as a space-saving measure. To produce a library that does -# not contain these strings, delete -DLIBC_RCS and -DSYSLIBC_RCS -# from CFLAGS below. To remove these strings from just the system call -# stubs, remove just -DSYSLIBC_RCS from CFLAGS. -LIB=c -SHLIB_MAJOR= 4 -SHLIB_MINOR= 0 -CFLAGS+=-DLIBC_RCS -DSYSLIBC_RCS -I${.CURDIR}/include -AINC= -I${.CURDIR}/${MACHINE_ARCH} -CLEANFILES+=tags -INSTALL_PIC_ARCHIVE= yes -PRECIOUSLIB= yes - -# -# Don't bother hiding any syscalls (like libc_r does). -# -HIDDEN_SYSCALLS= - -# -# Include make rules that are shared with libc_r. -# -.include "${.CURDIR}/Makefile.inc" - -KQSRCS= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c iordi3.c \ - lshldi3.c lshrdi3.c moddi3.c muldi3.c negdi2.c notdi2.c qdivrem.c \ - subdi3.c ucmpdi2.c udivdi3.c umoddi3.c xordi3.c -KSRCS= bcmp.c ffs.c index.c mcount.c rindex.c strcat.c strcmp.c strcpy.c \ - strlen.c strncpy.c - -libkern: libkern.gen libkern.${MACHINE_ARCH} - -libkern.gen: ${KQSRCS} ${KSRCS} - cp -p ${.CURDIR}/quad/quad.h ${.ALLSRC} ${DESTDIR}/sys/libkern - -libkern.${MACHINE_ARCH}:: ${KMSRCS} -.if defined(KMSRCS) && !empty(KMSRCS) - cp -p ${.ALLSRC} ${DESTDIR}/sys/libkern/${MACHINE_ARCH} -.endif - -.include diff --git a/lib/libc/Makefile.inc b/lib/libc/Makefile.inc deleted file mode 100644 index 318ca70..0000000 --- a/lib/libc/Makefile.inc +++ /dev/null @@ -1,56 +0,0 @@ -# $FreeBSD$ -# -# This file contains make rules that are shared by libc and libc_r. -# -# Define (empty) variables so that make doesn't give substitution -# errors if the included makefiles don't change these: -MDSRCS= -MISRCS= -MDASM= -MIASM= -NOASM= - -# -# If there is a machine dependent makefile, use it: -# -.if exists(${.CURDIR}/../libc/${MACHINE_ARCH}/Makefile.inc) -.include "${.CURDIR}/../libc/${MACHINE_ARCH}/Makefile.inc" -.endif - -.include "${.CURDIR}/../libc/db/Makefile.inc" -.include "${.CURDIR}/../libc/compat-43/Makefile.inc" -.include "${.CURDIR}/../libc/gen/Makefile.inc" -.include "${.CURDIR}/../libc/gmon/Makefile.inc" -.include "${.CURDIR}/../libc/locale/Makefile.inc" -.include "${.CURDIR}/../libc/net/Makefile.inc" -.include "${.CURDIR}/../libc/nls/Makefile.inc" -.if !defined(NO_QUAD) -.include "${.CURDIR}/../libc/quad/Makefile.inc" -.endif -.include "${.CURDIR}/../libc/regex/Makefile.inc" -.include "${.CURDIR}/../libc/stdio/Makefile.inc" -.include "${.CURDIR}/../libc/stdlib/Makefile.inc" -.include "${.CURDIR}/../libc/stdtime/Makefile.inc" -.include "${.CURDIR}/../libc/string/Makefile.inc" -.include "${.CURDIR}/../libc/sys/Makefile.inc" -.include "${.CURDIR}/../libc/rpc/Makefile.inc" -.include "${.CURDIR}/../libc/xdr/Makefile.inc" -.if !defined(NO_YP_LIBC) -CFLAGS+= -DYP -.include "${.CURDIR}/../libc/yp/Makefile.inc" -.endif - -# If there are no machine dependent sources, append all the -# machine-independent sources: -.if empty(MDSRCS) -SRCS+= ${MISRCS} -.else -# Append machine-dependent sources, then append machine-independent sources -# for which there is no machine-dependent variant. -SRCS+= ${MDSRCS} -.for _src in ${MISRCS} -.if ${MDSRCS:R:M${_src:R}} == "" -SRCS+= ${_src} -.endif -.endfor -.endif diff --git a/lib/libc/alpha/Makefile.inc b/lib/libc/alpha/Makefile.inc deleted file mode 100644 index 5a4d48e..0000000 --- a/lib/libc/alpha/Makefile.inc +++ /dev/null @@ -1,9 +0,0 @@ -# $FreeBSD$ -# -# Machine dependent definitions for the alpha architecture. -# - -# -# Alpha is 64-bit, so it doesn't need quad functions: -# -NO_QUAD=1 diff --git a/lib/libc/alpha/SYS.h b/lib/libc/alpha/SYS.h deleted file mode 100644 index 923300b..0000000 --- a/lib/libc/alpha/SYS.h +++ /dev/null @@ -1,132 +0,0 @@ -/* $FreeBSD$ */ -/* From: NetBSD: SYS.h,v 1.5 1997/05/02 18:15:15 kleink Exp */ - -/* - * Copyright (c) 1994, 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include -#ifdef __NETBSD_SYSCALLS -#include -#else -#include -#endif - -#define CALLSYS_ERROR(name) \ - CALLSYS_NOERROR(name); \ - br gp, LLABEL(name,0); \ -LLABEL(name,0): \ - LDGP(gp); \ - beq a3, LLABEL(name,1); \ - jmp zero, .cerror; \ -LLABEL(name,1): - - -#define SYSCALL(name) \ -LEAF(__CONCAT(_,name),0); /* XXX # of args? */ \ - WEAK_ALIAS(name, __CONCAT(_,name)); \ - CALLSYS_ERROR(name) - -#define SYSCALL_NOERROR(name) \ -LEAF(name,0); /* XXX # of args? */ \ - CALLSYS_NOERROR(name) - - -#define RSYSCALL(name) \ - SYSCALL(name); \ - RET; \ -END(__CONCAT(_,name)) - -#define RSYSCALL_NOERROR(name) \ - SYSCALL_NOERROR(name); \ - RET; \ -END(name) - - -#define PSEUDO(label,name) \ -LEAF(__CONCAT(_,label),0); /* XXX # of args? */ \ - WEAK_ALIAS(label, __CONCAT(_,label)); \ - CALLSYS_ERROR(name); \ - RET; \ -END(__CONCAT(_,label)); - -#define PSEUDO_NOERROR(label,name) \ -LEAF(label,0); /* XXX # of args? */ \ - CALLSYS_NOERROR(name); \ - RET; \ -END(label); - -/* - * Design note: - * - * The macros PSYSCALL() and PRSYSCALL() are intended for use where a - * syscall needs to be renamed in the threaded library. When building - * a normal library, they default to the traditional SYSCALL() and - * RSYSCALL(). This avoids the need to #ifdef _THREAD_SAFE everywhere - * that the renamed function needs to be called. - */ -#ifdef _THREAD_SAFE -/* - * For the thread_safe versions, we prepend _thread_sys_ to the function - * name so that the 'C' wrapper can go around the real name. - */ -#define PCALL(name) \ - CALL(___CONCAT(_thread_sys_,name)) - -#define PLEAF(name, args) \ -LEAF(___CONCAT(_thread_sys_,name),args) - -#define PEND(name) \ -END(___CONCAT(_thread_sys_,name)) - -#define PSYSCALL(name) \ -PLEAF(name,0); /* XXX # of args? */ \ - CALLSYS_ERROR(name) - -#define PRSYSCALL(name) \ -PLEAF(name,0); /* XXX # of args? */ \ - CALLSYS_ERROR(name) \ - RET; \ -PEND(name) - -#define PPSEUDO(label,name) \ -PLEAF(label,0); /* XXX # of args? */ \ - CALLSYS_ERROR(name); \ - RET; \ -PEND(label) - -#else -/* - * The non-threaded library defaults to traditional syscalls where - * the function name matches the syscall name. - */ -#define PSYSCALL(x) SYSCALL(x) -#define PRSYSCALL(x) RSYSCALL(x) -#define PPSEUDO(x,y) PSEUDO(x,y) -#define PLEAF(x,y) LEAF(x,y) -#define PEND(x) END(x) -#define PCALL(x) CALL(x) -#endif diff --git a/lib/libc/alpha/gen/Makefile.inc b/lib/libc/alpha/gen/Makefile.inc deleted file mode 100644 index 4e7fb35..0000000 --- a/lib/libc/alpha/gen/Makefile.inc +++ /dev/null @@ -1,45 +0,0 @@ -# $FreeBSD$ - -SRCS+= _setjmp.S fabs.S frexp.c infinity.c isinf.c ldexp.c modf.c setjmp.S -SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ - fpsetround.c fpsetsticky.c - -SRCS+= sigsetjmp.S -SRCS+= __divqu.S __divq.S __divlu.S __divl.S -SRCS+= __remqu.S __remq.S __remlu.S __reml.S - -CLEANFILES+= __divqu.S __divq.S __divlu.S __divl.S -CLEANFILES+= __remqu.S __remq.S __remlu.S __reml.S - - -__divqu.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4 - m4 -DNAME=__divqu -DOP=div -DS=false -DWORDSIZE=64 \ - ${.ALLSRC} > ${.TARGET} - -__divq.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4 - m4 -DNAME=__divq -DOP=div -DS=true -DWORDSIZE=64 \ - ${.ALLSRC} > ${.TARGET} - -__divlu.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4 - m4 -DNAME=__divlu -DOP=div -DS=false -DWORDSIZE=32 \ - ${.ALLSRC} > ${.TARGET} - -__divl.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4 - m4 -DNAME=__divl -DOP=div -DS=true -DWORDSIZE=32 \ - ${.ALLSRC} > ${.TARGET} - -__remqu.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4 - m4 -DNAME=__remqu -DOP=rem -DS=false -DWORDSIZE=64 \ - ${.ALLSRC} > ${.TARGET} - -__remq.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4 - m4 -DNAME=__remq -DOP=rem -DS=true -DWORDSIZE=64 \ - ${.ALLSRC} > ${.TARGET} - -__remlu.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4 - m4 -DNAME=__remlu -DOP=rem -DS=false -DWORDSIZE=32 \ - ${.ALLSRC} > ${.TARGET} - -__reml.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4 - m4 -DNAME=__reml -DOP=rem -DS=true -DWORDSIZE=32 \ - ${.ALLSRC} > ${.TARGET} diff --git a/lib/libc/alpha/gen/_setjmp.S b/lib/libc/alpha/gen/_setjmp.S deleted file mode 100644 index 0d032e7..0000000 --- a/lib/libc/alpha/gen/_setjmp.S +++ /dev/null @@ -1,134 +0,0 @@ -/* $NetBSD: _setjmp.S,v 1.2 1996/10/17 03:08:03 cgd Exp $ */ - -/* - * Copyright (c) 1994, 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - * - * $FreeBSD$ - */ - -#include - -/* - * 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. - */ - - .set noreorder - -LEAF(_setjmp, 1) - LDGP(pv) - stq ra, (2 * 8)(a0) /* sc_pc = return address */ - stq s0, (( 9 + 4) * 8)(a0) /* saved bits of sc_regs */ - stq s1, ((10 + 4) * 8)(a0) - stq s2, ((11 + 4) * 8)(a0) - stq s3, ((12 + 4) * 8)(a0) - stq s4, ((13 + 4) * 8)(a0) - stq s5, ((14 + 4) * 8)(a0) - stq s6, ((15 + 4) * 8)(a0) - stq ra, ((26 + 4) * 8)(a0) - stq sp, ((30 + 4) * 8)(a0) - ldiq t0, 0xacedbadd /* sigcontext magic number */ - stq t0, ((31 + 4) * 8)(a0) /* magic in sc_regs[31] */ - /* Too bad we can't check if we actually used FP */ - ldiq t0, 1 - stq t0, (36 * 8)(a0) /* say we've used FP. */ - stt fs0, ((2 + 37) * 8)(a0) /* saved bits of sc_fpregs */ - stt fs1, ((3 + 37) * 8)(a0) - stt fs2, ((4 + 37) * 8)(a0) - stt fs3, ((5 + 37) * 8)(a0) - stt fs4, ((6 + 37) * 8)(a0) - stt fs5, ((7 + 37) * 8)(a0) - stt fs6, ((8 + 37) * 8)(a0) - stt fs7, ((9 + 37) * 8)(a0) - mf_fpcr ft0 /* get FP control reg */ - stt ft0, (69 * 8)(a0) /* and store it in sc_fpcr */ - stq zero, (70 * 8)(a0) /* FP software control XXX */ - stq zero, (71 * 8)(a0) /* sc_reserved[0] */ - stq zero, (72 * 8)(a0) /* sc_reserved[1] */ - stq zero, (73 * 8)(a0) /* sc_xxx[0] */ - stq zero, (74 * 8)(a0) /* sc_xxx[1] */ - stq zero, (75 * 8)(a0) /* sc_xxx[2] */ - stq zero, (76 * 8)(a0) /* sc_xxx[3] */ - stq zero, (77 * 8)(a0) /* sc_xxx[4] */ - stq zero, (78 * 8)(a0) /* sc_xxx[5] */ - stq zero, (79 * 8)(a0) /* sc_xxx[6] */ - stq zero, (80 * 8)(a0) /* sc_xxx[7] */ - - mov zero, v0 /* return zero */ - RET -END(_setjmp) - -#ifdef _THREAD_SAFE -LEAF(___longjmp, 2) -#else -XLEAF(___longjmp, 2) -LEAF(_longjmp, 2) -#endif - LDGP(pv) - ldq t0, ((31 + 4) * 8)(a0) /* magic in sc_regs[31] */ - ldiq t1, 0xacedbadd - cmpeq t0, t1, t0 - beq t0, botch /* If the magic was bad, punt */ - - ldq ra, (2 * 8)(a0) /* sc_pc = return address */ - ldq s0, (( 9 + 4) * 8)(a0) /* saved bits of sc_regs */ - ldq s1, ((10 + 4) * 8)(a0) - ldq s2, ((11 + 4) * 8)(a0) - ldq s3, ((12 + 4) * 8)(a0) - ldq s4, ((13 + 4) * 8)(a0) - ldq s5, ((14 + 4) * 8)(a0) - ldq s6, ((15 + 4) * 8)(a0) - /* ldq ra, ((26 + 4) * 8)(a0) set above */ - ldq sp, ((30 + 4) * 8)(a0) - ldt fs0, ((2 + 37) * 8)(a0) /* saved bits of sc_fpregs */ - ldt fs1, ((3 + 37) * 8)(a0) - ldt fs2, ((4 + 37) * 8)(a0) - ldt fs3, ((5 + 37) * 8)(a0) - ldt fs4, ((6 + 37) * 8)(a0) - ldt fs5, ((7 + 37) * 8)(a0) - ldt fs6, ((8 + 37) * 8)(a0) - ldt fs7, ((9 + 37) * 8)(a0) - ldt ft0, (69 * 8)(a0) /* get sc_fpcr */ - mt_fpcr ft0 /* and restore it. */ - - mov a1, v0 /* return second arg */ - RET - -botch: - CALL(longjmperror) - CALL(abort) - RET /* "can't" get here... */ -#ifdef _THREAD_SAFE -END(___longjmp) -#else -END(_longjmp) -#endif diff --git a/lib/libc/alpha/gen/divrem.m4 b/lib/libc/alpha/gen/divrem.m4 deleted file mode 100644 index 9fab00a..0000000 --- a/lib/libc/alpha/gen/divrem.m4 +++ /dev/null @@ -1,197 +0,0 @@ -/* $NetBSD: divrem.m4,v 1.7 1996/10/17 03:08:04 cgd Exp $ */ - -/* - * Copyright (c) 1994, 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -/* - * Division and remainder. - * - * The use of m4 is modeled after the sparc code, but the algorithm is - * simple binary long division. - * - * Note that the loops could probably benefit from unrolling. - */ - -/* - * M4 Parameters - * NAME name of function to generate - * OP OP=div: t10 / t11 -> t12; OP=rem: t10 % t11 -> t12 - * S S=true: signed; S=false: unsigned - * WORDSIZE total number of bits - */ - -define(A, `t10') -define(B, `t11') -define(RESULT, `t12') - -define(BIT, `t0') -define(I, `t1') -define(CC, `t2') -define(T_0, `t3') -ifelse(S, `true', `define(NEG, `t4')') - -#include - -NESTED(NAME, 0, 0, t9, 0, 0) /* Get the right ra */ - lda sp, -64(sp) - stq BIT, 0(sp) - stq I, 8(sp) - stq CC, 16(sp) - stq T_0, 24(sp) -ifelse(S, `true', -` stq NEG, 32(sp)') - stq A, 40(sp) - stq B, 48(sp) - mov zero, RESULT /* Initialize result to zero */ - -ifelse(S, `true', -` - /* Compute sign of result. If either is negative, this is easy. */ - or A, B, NEG /* not the sign, but... */ - srl NEG, WORDSIZE - 1, NEG /* rather, or of high bits */ - blbc NEG, Ldoit /* neither negative? do it! */ - -ifelse(OP, `div', -` xor A, B, NEG /* THIS is the sign! */ -', ` mov A, NEG /* sign follows A. */ -') - srl NEG, WORDSIZE - 1, NEG /* make negation the low bit. */ - - srl A, WORDSIZE - 1, I /* is A negative? */ - blbc I, LnegB /* no. */ - /* A is negative; flip it. */ -ifelse(WORDSIZE, `32', ` - /* top 32 bits may be random junk */ - zap A, 0xf0, A -') - subq zero, A, A - srl B, WORDSIZE - 1, I /* is B negative? */ - blbc I, Ldoit /* no. */ -LnegB: - /* B is definitely negative, no matter how we got here. */ -ifelse(WORDSIZE, `32', ` - /* top 32 bits may be random junk */ - zap B, 0xf0, B -') - subq zero, B, B -Ldoit: -') -ifelse(WORDSIZE, `32', ` - /* - * Clear the top 32 bits of each operand, as they may - * sign extension (if negated above), or random junk. - */ - zap A, 0xf0, A - zap B, 0xf0, B -') - - /* kill the special cases. */ - beq B, Ldotrap /* division by zero! */ - - cmpult A, B, CC /* A < B? */ - /* RESULT is already zero, from above. A is untouched. */ - bne CC, Lret_result - - cmpeq A, B, CC /* A == B? */ - cmovne CC, 1, RESULT - cmovne CC, zero, A - bne CC, Lret_result - - /* - * Find out how many bits of zeros are at the beginning of the divisor. - */ -LBbits: - ldiq T_0, 1 /* I = 0; BIT = 1< - -LEAF(fabs, 1) - cpys fzero, fa0, fv0 - RET -END(fabs) diff --git a/lib/libc/alpha/gen/flt_rounds.c b/lib/libc/alpha/gen/flt_rounds.c deleted file mode 100644 index b6246c9..0000000 --- a/lib/libc/alpha/gen/flt_rounds.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $FreeBSD$ */ -/* From: NetBSD: flt_rounds.c,v 1.2 1997/07/18 00:30:30 thorpej Exp */ - -/* - * Copyright (c) 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christopher G. Demetriou - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (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 -#include - -static const int map[] = { - 0, /* round to zero */ - 3, /* round to negative infinity */ - 1, /* round to nearest */ - 2 /* round to positive infinity */ -}; - -int -__flt_rounds() -{ - double fpcrval; - u_int64_t old; - - __asm__("trapb"); - __asm__("mf_fpcr %0" : "=f" (fpcrval)); - __asm__("trapb"); - old = *(u_int64_t *)&fpcrval; - - return map[(old >> 58) & 0x3]; -} diff --git a/lib/libc/alpha/gen/fpgetmask.c b/lib/libc/alpha/gen/fpgetmask.c deleted file mode 100644 index 516ae98..0000000 --- a/lib/libc/alpha/gen/fpgetmask.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $NetBSD: fpgetmask.c,v 1.1 1995/04/29 05:10:55 cgd Exp $ */ - -/* - * Copyright (c) 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christopher G. Demetriou - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (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 -#include -#include - -struct params { - u_int64_t mask; -}; - -fp_except -fpgetmask() -{ - struct params p; - - sysarch(ALPHA_GET_FPMASK, (char *) &p); - return((fp_except) p.mask); -} diff --git a/lib/libc/alpha/gen/fpgetround.c b/lib/libc/alpha/gen/fpgetround.c deleted file mode 100644 index 46976c2..0000000 --- a/lib/libc/alpha/gen/fpgetround.c +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: fpgetround.c,v 1.1 1995/04/29 05:09:55 cgd Exp $ */ - -/* - * Copyright (c) 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christopher G. Demetriou - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (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 -#include -#include - -fp_rnd -fpgetround() -{ - double fpcrval; - u_int64_t old; - - GET_FPCR(fpcrval); - old = *(u_int64_t *)&fpcrval; - - return ((old & FPCR_DYN_MASK) >> FPCR_DYN_SHIFT); -} diff --git a/lib/libc/alpha/gen/fpgetsticky.c b/lib/libc/alpha/gen/fpgetsticky.c deleted file mode 100644 index c0ff4d7..0000000 --- a/lib/libc/alpha/gen/fpgetsticky.c +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: fpgetsticky.c,v 1.1 1995/04/29 05:10:59 cgd Exp $ */ - -/* - * Copyright (c) 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christopher G. Demetriou - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (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 -#include -#include - -fp_except -fpgetsticky() -{ - double fpcrval; - u_int64_t old; - - GET_FPCR(fpcrval); - old = *(u_int64_t *)&fpcrval; - return (((old >> IEEE_STATUS_TO_FPCR_SHIFT) & IEEE_STATUS_MASK) - >> IEEE_STATUS_TO_EXCSUM_SHIFT); -} diff --git a/lib/libc/alpha/gen/fpsetmask.c b/lib/libc/alpha/gen/fpsetmask.c deleted file mode 100644 index 05201ce..0000000 --- a/lib/libc/alpha/gen/fpsetmask.c +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: fpsetmask.c,v 1.1 1995/04/29 05:11:01 cgd Exp $ */ - -/* - * Copyright (c) 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christopher G. Demetriou - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (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 -#include -#include - -struct params { - u_int64_t mask; -}; - -fp_except -fpsetmask(mask) - fp_except mask; -{ - struct params p; - - p.mask = (u_int64_t) mask; - sysarch(ALPHA_SET_FPMASK, (char *) &p); - return ((fp_except) p.mask); -} diff --git a/lib/libc/alpha/gen/fpsetround.c b/lib/libc/alpha/gen/fpsetround.c deleted file mode 100644 index 0d8f40a..0000000 --- a/lib/libc/alpha/gen/fpsetround.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: fpsetround.c,v 1.1 1995/04/29 05:09:57 cgd Exp $ */ - -/* - * Copyright (c) 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christopher G. Demetriou - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (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 -#include -#include - -fp_rnd -fpsetround(rnd_dir) - fp_rnd rnd_dir; -{ - double fpcrval; - u_int64_t old, new; - - GET_FPCR(fpcrval); - old = *(u_int64_t *)&fpcrval; - - new = old & (~FPCR_DYN_MASK); - new |= ((long) rnd_dir << FPCR_DYN_SHIFT) & FPCR_DYN_MASK; - - *(u_int64_t *)&fpcrval = new; - SET_FPCR(fpcrval); - - return ((old & FPCR_DYN_MASK) >> FPCR_DYN_SHIFT); -} diff --git a/lib/libc/alpha/gen/fpsetsticky.c b/lib/libc/alpha/gen/fpsetsticky.c deleted file mode 100644 index ae0d742..0000000 --- a/lib/libc/alpha/gen/fpsetsticky.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: fpsetsticky.c,v 1.1 1995/04/29 05:11:04 cgd Exp $ */ - -/* - * Copyright (c) 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christopher G. Demetriou - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (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 -#include -#include - -fp_except -fpsetsticky(sticky) - fp_except sticky; -{ - double fpcrval; - u_int64_t old,new ; - - GET_FPCR(fpcrval); - old = *(u_int64_t *)&fpcrval; - new = old & ~ (IEEE_STATUS_MASK << IEEE_STATUS_TO_FPCR_SHIFT); - new |= ((sticky << IEEE_STATUS_TO_EXCSUM_SHIFT) & IEEE_STATUS_MASK) - << IEEE_STATUS_TO_FPCR_SHIFT; - *(u_int64_t *)&fpcrval = new; - SET_FPCR(fpcrval); - - return (((old >> IEEE_STATUS_TO_FPCR_SHIFT) & IEEE_STATUS_MASK) - >> IEEE_STATUS_TO_EXCSUM_SHIFT); -} diff --git a/lib/libc/alpha/gen/frexp.c b/lib/libc/alpha/gen/frexp.c deleted file mode 100644 index b05f2ac..0000000 --- a/lib/libc/alpha/gen/frexp.c +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: frexp.c,v 1.1 1995/02/10 17:50:22 cgd Exp $ */ - -/* - * Copyright (c) 1994, 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include -#include -#include - -double -frexp(value, eptr) - double value; - int *eptr; -{ - union doub { - double v; - struct ieee_double s; - } u; - - if (value) { - u.v = value; - *eptr = u.s.dbl_exp - (DBL_EXP_BIAS - 1); - u.s.dbl_exp = DBL_EXP_BIAS - 1; - return(u.v); - } else { - *eptr = 0; - return((double)0); - } -} diff --git a/lib/libc/alpha/gen/infinity.c b/lib/libc/alpha/gen/infinity.c deleted file mode 100644 index 194a9f2..0000000 --- a/lib/libc/alpha/gen/infinity.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $NetBSD: infinity.c,v 1.1 1995/02/10 17:50:23 cgd Exp $ */ - -/* - * Copyright (c) 1994, 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include - -/* bytes for +Infinity on an Alpha (IEEE double format) */ -char __infinity[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }; diff --git a/lib/libc/alpha/gen/isinf.c b/lib/libc/alpha/gen/isinf.c deleted file mode 100644 index 11ab3ce..0000000 --- a/lib/libc/alpha/gen/isinf.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: isinf.c,v 1.1 1995/02/10 17:50:23 cgd Exp $ */ - -/* - * Copyright (c) 1994, 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include -#include -#include - -int -isnan(d) - double d; -{ - register struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - (p->dbl_frach || p->dbl_fracl)); -} - -int -isinf(d) - double d; -{ - register struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - !p->dbl_frach && !p->dbl_fracl); -} diff --git a/lib/libc/alpha/gen/ldexp.c b/lib/libc/alpha/gen/ldexp.c deleted file mode 100644 index 0cb9938..0000000 --- a/lib/libc/alpha/gen/ldexp.c +++ /dev/null @@ -1,134 +0,0 @@ -/* $NetBSD: ldexp.c,v 1.1 1995/02/10 17:50:24 cgd Exp $ */ - -/* - * Copyright (c) 1994, 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include -#include -#include -#include - -/* - * double ldexp(double val, int exp) - * returns: val * (2**exp) - */ -double -ldexp(val, exp) - double val; - int exp; -{ - register int oldexp, newexp, mulexp; - union doub { - double v; - struct ieee_double s; - } u, mul; - - /* - * If input is zero, or no change, just return input. - * Likewise, if input is Inf or NaN, just return it. - */ - u.v = val; - oldexp = u.s.dbl_exp; - if (val == 0 || exp == 0 || oldexp == DBL_EXP_INFNAN) - return (val); - - /* - * Compute new exponent and check for over/under flow. - * Underflow, unfortunately, could mean switching to denormal. - * If result out of range, set ERANGE and return 0 if too small - * or Inf if too big, with the same sign as the input value. - */ - newexp = oldexp + exp; - if (newexp >= DBL_EXP_INFNAN) { - /* u.s.dbl_sign = val < 0; -- already set */ - u.s.dbl_exp = DBL_EXP_INFNAN; - u.s.dbl_frach = u.s.dbl_fracl = 0; - errno = ERANGE; - return (u.v); /* Inf */ - } - if (newexp <= 0) { - /* - * The output number is either a denormal or underflows - * (see comments in machine/ieee.h). - */ - if (newexp <= -DBL_FRACBITS) { - /* u.s.dbl_sign = val < 0; -- already set */ - u.s.dbl_exp = 0; - u.s.dbl_frach = u.s.dbl_fracl = 0; - errno = ERANGE; - return (u.v); /* zero */ - } - /* - * We are going to produce a denorm. Our `exp' argument - * might be as small as -2097, and we cannot compute - * 2^-2097, so we may have to do this as many as three - * steps (not just two, as for positive `exp's below). - */ - mul.v = 0; - while (exp <= -DBL_EXP_BIAS) { - mul.s.dbl_exp = 1; - val *= mul.v; - exp += DBL_EXP_BIAS - 1; - } - mul.s.dbl_exp = exp + DBL_EXP_BIAS; - val *= mul.v; - return (val); - } - - /* - * Newexp is positive. - * - * If oldexp is zero, we are starting with a denorm, and simply - * adjusting the exponent will produce bogus answers. We need - * to fix that first. - */ - if (oldexp == 0) { - /* - * Multiply by 2^mulexp to make the number normalizable. - * We cannot multiply by more than 2^1023, but `exp' - * argument might be as large as 2046. A single - * adjustment, however, will normalize the number even - * for huge `exp's, and then we can use exponent - * arithmetic just as for normal `double's. - */ - mulexp = exp <= DBL_EXP_BIAS ? exp : DBL_EXP_BIAS; - mul.v = 0; - mul.s.dbl_exp = mulexp + DBL_EXP_BIAS; - val *= mul.v; - if (mulexp == exp) - return (val); - u.v = val; - newexp -= mulexp; - } - - /* - * Both oldexp and newexp are positive; just replace the - * old exponent with the new one. - */ - u.s.dbl_exp = newexp; - return (u.v); -} diff --git a/lib/libc/alpha/gen/modf.c b/lib/libc/alpha/gen/modf.c deleted file mode 100644 index 47de384..0000000 --- a/lib/libc/alpha/gen/modf.c +++ /dev/null @@ -1,104 +0,0 @@ -/* $NetBSD: modf.c,v 1.1 1995/02/10 17:50:25 cgd Exp $ */ - -/* - * Copyright (c) 1994, 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include -#include -#include -#include - -/* - * double modf(double val, double *iptr) - * returns: f and i such that |f| < 1.0, (f + i) = val, and - * sign(f) == sign(i) == sign(val). - * - * Beware signedness when doing subtraction, and also operand size! - */ -double -modf(val, iptr) - double val, *iptr; -{ - union doub { - double v; - struct ieee_double s; - } u, v; - u_int64_t frac; - - /* - * If input is Inf or NaN, return it and leave i alone. - */ - u.v = val; - if (u.s.dbl_exp == DBL_EXP_INFNAN) - return (u.v); - - /* - * If input can't have a fractional part, return - * (appropriately signed) zero, and make i be the input. - */ - if ((int)u.s.dbl_exp - DBL_EXP_BIAS > DBL_FRACBITS - 1) { - *iptr = u.v; - v.v = 0.0; - v.s.dbl_sign = u.s.dbl_sign; - return (v.v); - } - - /* - * If |input| < 1.0, return it, and set i to the appropriately - * signed zero. - */ - if (u.s.dbl_exp < DBL_EXP_BIAS) { - v.v = 0.0; - v.s.dbl_sign = u.s.dbl_sign; - *iptr = v.v; - return (u.v); - } - - /* - * There can be a fractional part of the input. - * If you look at the math involved for a few seconds, it's - * plain to see that the integral part is the input, with the - * low (DBL_FRACBITS - (exponent - DBL_EXP_BIAS)) bits zeroed, - * the the fractional part is the part with the rest of the - * bits zeroed. Just zeroing the high bits to get the - * fractional part would yield a fraction in need of - * normalization. Therefore, we take the easy way out, and - * just use subtraction to get the fractional part. - */ - v.v = u.v; - /* Zero the low bits of the fraction, the sleazy way. */ - frac = ((u_int64_t)v.s.dbl_frach << 32) + v.s.dbl_fracl; - frac >>= DBL_FRACBITS - (u.s.dbl_exp - DBL_EXP_BIAS); - frac <<= DBL_FRACBITS - (u.s.dbl_exp - DBL_EXP_BIAS); - v.s.dbl_fracl = frac & 0xffffffff; - v.s.dbl_frach = frac >> 32; - *iptr = v.v; - - u.v -= v.v; - u.s.dbl_sign = v.s.dbl_sign; - return (u.v); -} diff --git a/lib/libc/alpha/gen/setjmp.S b/lib/libc/alpha/gen/setjmp.S deleted file mode 100644 index 04202ce..0000000 --- a/lib/libc/alpha/gen/setjmp.S +++ /dev/null @@ -1,136 +0,0 @@ -/* $NetBSD: setjmp.S,v 1.3 1997/12/05 02:06:27 thorpej Exp $ */ - -/* - * Copyright (c) 1994, 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - * - * $FreeBSD$ - */ - -#include "SYS.h" - -/* - * 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, - * and the previous signal state. - */ - - .set noreorder - -LEAF(setjmp, 1) - LDGP(pv) - stq ra, (2 * 8)(a0) /* sc_pc = return address */ - stq s0, (( 9 + 4) * 8)(a0) /* saved bits of sc_regs */ - stq s1, ((10 + 4) * 8)(a0) - stq s2, ((11 + 4) * 8)(a0) - stq s3, ((12 + 4) * 8)(a0) - stq s4, ((13 + 4) * 8)(a0) - stq s5, ((14 + 4) * 8)(a0) - stq s6, ((15 + 4) * 8)(a0) - stq ra, ((26 + 4) * 8)(a0) - stq sp, ((30 + 4) * 8)(a0) - - /* - * get signal information - */ - mov a0, s0 /* squirrel away ptr to sc */ - - /* see what's blocked */ - lda a2, (71 * 8)(a0) /* oset: sc_reserved */ - mov zero, a1 /* set: NULL */ - addq a1, 1, a0 /* how: SIG_BLOCK */ - PCALL(sigprocmask) /* see what's blocked */ - - lda sp, -24(sp) /* sizeof struct sigaltstack */ - mov zero, a0 - mov sp, a1 - PCALL(sigaltstack) - ldl t0, 16(sp) /* offset of ss_flags */ - lda sp, 24(sp) /* sizeof struct sigaltstack */ - ldq ra, ((26 + 4) * 8)(s0) /* restore return address */ - blt v0, botch /* check for error */ - and t0, 0x1, t0 /* get SA_ONSTACK flag */ - stq t0, (0 * 8)(s0) /* and save it in sc_onstack */ - /* - * Restore old s0 and a0, and continue saving registers - */ - mov s0, a0 - ldq s0, (( 9 + 4) * 8)(a0) - - ldiq t0, 0xacedbade /* sigcontext magic number */ - stq t0, ((31 + 4) * 8)(a0) /* magic in sc_regs[31] */ - /* Too bad we can't check if we actually used FP */ - ldiq t0, 1 - stq t0, (36 * 8)(a0) /* say we've used FP. */ - stt fs0, ((2 + 37) * 8)(a0) /* saved bits of sc_fpregs */ - stt fs1, ((3 + 37) * 8)(a0) - stt fs2, ((4 + 37) * 8)(a0) - stt fs3, ((5 + 37) * 8)(a0) - stt fs4, ((6 + 37) * 8)(a0) - stt fs5, ((7 + 37) * 8)(a0) - stt fs6, ((8 + 37) * 8)(a0) - stt fs7, ((9 + 37) * 8)(a0) - mf_fpcr ft0 /* get FP control reg */ - stt ft0, (69 * 8)(a0) /* and store it in sc_fpcr */ - stq zero, (70 * 8)(a0) /* FP software control XXX */ - stq zero, (71 * 8)(a0) /* sc_reserved[0] */ - stq zero, (72 * 8)(a0) /* sc_reserved[1] */ - stq zero, (73 * 8)(a0) /* sc_xxx[0] */ - stq zero, (74 * 8)(a0) /* sc_xxx[1] */ - stq zero, (75 * 8)(a0) /* sc_xxx[2] */ - stq zero, (76 * 8)(a0) /* sc_xxx[3] */ - stq zero, (77 * 8)(a0) /* sc_xxx[4] */ - stq zero, (78 * 8)(a0) /* sc_xxx[5] */ - stq zero, (79 * 8)(a0) /* sc_xxx[6] */ - stq zero, (80 * 8)(a0) /* sc_xxx[7] */ - - mov zero, v0 /* return zero */ - RET -END(setjmp) - -#ifdef _THREAD_SAFE -LEAF(__longjmp, 2) -#else -XLEAF(__longjmp, 2) -LEAF(longjmp, 2) -#endif - LDGP(pv) - stq a1, (( 0 + 4) * 8)(a0) /* save return value */ - PCALL(sigreturn) /* use sigreturn to return */ - -botch: - CALL(longjmperror) - CALL(abort) - RET /* "can't" get here... */ -#ifdef _THREAD_SAFE -END(__longjmp) -#else -END(longjmp) -#endif diff --git a/lib/libc/alpha/gen/sigsetjmp.S b/lib/libc/alpha/gen/sigsetjmp.S deleted file mode 100644 index a5acd8a..0000000 --- a/lib/libc/alpha/gen/sigsetjmp.S +++ /dev/null @@ -1,73 +0,0 @@ -/* $NetBSD: sigsetjmp.S,v 1.2 1996/10/17 03:08:07 cgd Exp $ */ - -/* - * Copyright (c) 1994, 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - * - * $FreeBSD$ - */ - -#include - -/* - * C library -- sigsetjmp, siglongjmp - * - * siglongjmp(a,v) - * will generate a "return(v)" from - * the last call to - * sigsetjmp(a, mask) - * by restoring registers from the stack. - * If `mask' is non-zero, the previous signal - * state will be restored. - */ - - .set noreorder - -LEAF(sigsetjmp, 2) - LDGP(pv) - stq a1, (81 * 8)(a0) /* save the mask */ - bne a1, Lsavesig /* if !zero, save signals */ - jmp zero, _setjmp /* else don't. */ -Lsavesig: - jmp zero, setjmp -END(sigsetjmp) - -#ifdef _THREAD_SAFE -LEAF(__siglongjmp, 2) -#else -XLEAF(__siglongjmp, 2) -LEAF(siglongjmp, 2) -#endif - LDGP(pv) - ldq t0, (81 * 8)(a0) /* get the mask */ - bne t0, Lrestoresig /* if !zero, restore signals */ - jmp zero, _longjmp -Lrestoresig: - jmp zero, longjmp -#ifdef _THREAD_SAFE -END(__siglongjmp) -#else -END(siglongjmp) -#endif \ No newline at end of file diff --git a/lib/libc/alpha/net/Makefile.inc b/lib/libc/alpha/net/Makefile.inc deleted file mode 100644 index b717813..0000000 --- a/lib/libc/alpha/net/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $FreeBSD$ - -SRCS+= htonl.S htons.S ntohl.S ntohs.S diff --git a/lib/libc/alpha/net/byte_swap_2.S b/lib/libc/alpha/net/byte_swap_2.S deleted file mode 100644 index fab3c58..0000000 --- a/lib/libc/alpha/net/byte_swap_2.S +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: byte_swap_2.S,v 1.2 1996/10/17 03:08:08 cgd Exp $ */ - -/* - * Copyright (c) 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include - -#ifndef NAME -#define NAME byte_swap_2 -#endif - -/* - * Byte-swap a 2-byte quantity. (Convert 0x0123 to 0x2301.) - * - * Argument is an unsigned 2-byte integer (u_int16_t). - */ -LEAF(NAME, 1) /* a0 contains 0x0123 */ - extbl a0, 0, t0 /* t0 = 0x 23 */ - extbl a0, 1, t1 /* t1 = 0x 01 */ - sll t0, 8, t0 /* t1 = 0x23 */ - or t0, t1, v0 /* v0 = 0x2301 */ - RET -END(NAME) diff --git a/lib/libc/alpha/net/byte_swap_4.S b/lib/libc/alpha/net/byte_swap_4.S deleted file mode 100644 index 8dbb83c..0000000 --- a/lib/libc/alpha/net/byte_swap_4.S +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: byte_swap_4.S,v 1.2 1996/10/17 03:08:09 cgd Exp $ */ - -/* - * Copyright (c) 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include - -#ifndef NAME -#define NAME byte_swap_4 -#endif - -/* - * Byte-swap a 4-byte quantity. (Convert 0x01234567 to 0x67452301.) - * - * Argument is an unsigned 4-byte integer (u_int32_t). - */ -LEAF(NAME, 1) /* a0 contains 0x01234567 */ - extbl a0, 0, t0 /* t0 = 0x 67 */ - extbl a0, 1, t1 /* t1 = 0x 45 */ - extbl a0, 2, t2 /* t2 = 0x 23 */ - extbl a0, 3, t3 /* t3 = 0x 01 */ - sll t0, 24, t0 /* t0 = 0x67 */ - sll t1, 16, t1 /* t1 = 0x 45 */ - sll t2, 8, t2 /* t2 = 0x 23 */ - or t3, t0, v0 /* v0 = 0x67 01 */ - or t1, t2, t1 /* t1 = 0x 4523 */ - or t1, v0, v0 /* v0 = 0x67452301 */ - RET -END(NAME) diff --git a/lib/libc/alpha/net/htonl.S b/lib/libc/alpha/net/htonl.S deleted file mode 100644 index bacab1e..0000000 --- a/lib/libc/alpha/net/htonl.S +++ /dev/null @@ -1,32 +0,0 @@ -/* $NetBSD: htonl.S,v 1.1 1996/04/17 22:36:52 cgd Exp $ */ - -/* - * Copyright (c) 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#define NAME htonl - -#include "byte_swap_4.S" diff --git a/lib/libc/alpha/net/htons.S b/lib/libc/alpha/net/htons.S deleted file mode 100644 index fb08222..0000000 --- a/lib/libc/alpha/net/htons.S +++ /dev/null @@ -1,32 +0,0 @@ -/* $NetBSD: htons.S,v 1.1 1996/04/17 22:36:54 cgd Exp $ */ - -/* - * Copyright (c) 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#define NAME htons - -#include "byte_swap_2.S" diff --git a/lib/libc/alpha/net/ntohl.S b/lib/libc/alpha/net/ntohl.S deleted file mode 100644 index b571647..0000000 --- a/lib/libc/alpha/net/ntohl.S +++ /dev/null @@ -1,32 +0,0 @@ -/* $NetBSD: ntohl.S,v 1.1 1996/04/17 22:36:57 cgd Exp $ */ - -/* - * Copyright (c) 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#define NAME ntohl - -#include "byte_swap_4.S" diff --git a/lib/libc/alpha/net/ntohs.S b/lib/libc/alpha/net/ntohs.S deleted file mode 100644 index 6db9961..0000000 --- a/lib/libc/alpha/net/ntohs.S +++ /dev/null @@ -1,32 +0,0 @@ -/* $NetBSD: ntohs.S,v 1.1 1996/04/17 22:37:02 cgd Exp $ */ - -/* - * Copyright (c) 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#define NAME ntohs - -#include "byte_swap_2.S" diff --git a/lib/libc/alpha/stdlib/Makefile.inc b/lib/libc/alpha/stdlib/Makefile.inc deleted file mode 100644 index dda8c76..0000000 --- a/lib/libc/alpha/stdlib/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $FreeBSD$ - -MDSRCS+= abs.c div.c labs.c ldiv.c diff --git a/lib/libc/alpha/string/Makefile.inc b/lib/libc/alpha/string/Makefile.inc deleted file mode 100644 index 7bbcc8d..0000000 --- a/lib/libc/alpha/string/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $FreeBSD$ - -MDSRCS+= bcopy.S bzero.S ffs.S memcpy.S memmove.S diff --git a/lib/libc/alpha/string/bcopy.S b/lib/libc/alpha/string/bcopy.S deleted file mode 100644 index 6a45ad6..0000000 --- a/lib/libc/alpha/string/bcopy.S +++ /dev/null @@ -1,288 +0,0 @@ -/* $NetBSD: bcopy.S,v 1.3 1996/10/17 03:08:11 cgd Exp $ */ - -/* - * Copyright (c) 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Trevor Blackwell. Support for use as memcpy() and memmove() - * added by Chris Demetriou. - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include - -#if defined(MEMCOPY) || defined(MEMMOVE) -#ifdef MEMCOPY -#define FUNCTION memcpy -#else -#define FUNCTION memmove -#endif -#define SRCREG a1 -#define DSTREG a0 -#else /* !(defined(MEMCOPY) || defined(MEMMOVE)) */ -#define FUNCTION bcopy -#define SRCREG a0 -#define DSTREG a1 -#endif /* !(defined(MEMCOPY) || defined(MEMMOVE)) */ - -#define SIZEREG a2 - -/* - * Copy bytes. - * - * void bcopy(char *from, char *to, size_t len); - * char *memcpy(void *to, const void *from, size_t len); - * char *memmove(void *to, const void *from, size_t len); - * - * No matter how invoked, the source and destination registers - * for calculation. There's no point in copying them to "working" - * registers, since the code uses their values "in place," and - * copying them would be slower. - */ - -LEAF(FUNCTION,3) - -#if defined(MEMCOPY) || defined(MEMMOVE) - /* set up return value, while we still can */ - mov DSTREG,v0 -#endif - - /* Check for negative length */ - ble SIZEREG,bcopy_done - - /* Check for overlap */ - subq DSTREG,SRCREG,t5 - cmpult t5,SIZEREG,t5 - bne t5,bcopy_overlap - - /* a3 = end address */ - addq SRCREG,SIZEREG,a3 - - /* Get the first word */ - ldq_u t2,0(SRCREG) - - /* Do they have the same alignment? */ - xor SRCREG,DSTREG,t0 - and t0,7,t0 - and DSTREG,7,t1 - bne t0,bcopy_different_alignment - - /* src & dst have same alignment */ - beq t1,bcopy_all_aligned - - ldq_u t3,0(DSTREG) - addq SIZEREG,t1,SIZEREG - mskqh t2,SRCREG,t2 - mskql t3,SRCREG,t3 - or t2,t3,t2 - - /* Dst is 8-byte aligned */ - -bcopy_all_aligned: - /* If less than 8 bytes,skip loop */ - subq SIZEREG,1,t0 - and SIZEREG,7,SIZEREG - bic t0,7,t0 - beq t0,bcopy_samealign_lp_end - -bcopy_samealign_lp: - stq_u t2,0(DSTREG) - addq DSTREG,8,DSTREG - ldq_u t2,8(SRCREG) - subq t0,8,t0 - addq SRCREG,8,SRCREG - bne t0,bcopy_samealign_lp - -bcopy_samealign_lp_end: - /* If we're done, exit */ - bne SIZEREG,bcopy_small_left - stq_u t2,0(DSTREG) - RET - -bcopy_small_left: - mskql t2,SIZEREG,t4 - ldq_u t3,0(DSTREG) - mskqh t3,SIZEREG,t3 - or t4,t3,t4 - stq_u t4,0(DSTREG) - RET - -bcopy_different_alignment: - /* - * this is the fun part - */ - addq SRCREG,SIZEREG,a3 - cmpule SIZEREG,8,t0 - bne t0,bcopy_da_finish - - beq t1,bcopy_da_noentry - - /* Do the initial partial word */ - subq zero,DSTREG,t0 - and t0,7,t0 - ldq_u t3,7(SRCREG) - extql t2,SRCREG,t2 - extqh t3,SRCREG,t3 - or t2,t3,t5 - insql t5,DSTREG,t5 - ldq_u t6,0(DSTREG) - mskql t6,DSTREG,t6 - or t5,t6,t5 - stq_u t5,0(DSTREG) - addq SRCREG,t0,SRCREG - addq DSTREG,t0,DSTREG - subq SIZEREG,t0,SIZEREG - ldq_u t2,0(SRCREG) - -bcopy_da_noentry: - subq SIZEREG,1,t0 - bic t0,7,t0 - and SIZEREG,7,SIZEREG - beq t0,bcopy_da_finish2 - -bcopy_da_lp: - ldq_u t3,7(SRCREG) - addq SRCREG,8,SRCREG - extql t2,SRCREG,t4 - extqh t3,SRCREG,t5 - subq t0,8,t0 - or t4,t5,t5 - stq t5,0(DSTREG) - addq DSTREG,8,DSTREG - beq t0,bcopy_da_finish1 - ldq_u t2,7(SRCREG) - addq SRCREG,8,SRCREG - extql t3,SRCREG,t4 - extqh t2,SRCREG,t5 - subq t0,8,t0 - or t4,t5,t5 - stq t5,0(DSTREG) - addq DSTREG,8,DSTREG - bne t0,bcopy_da_lp - -bcopy_da_finish2: - /* Do the last new word */ - mov t2,t3 - -bcopy_da_finish1: - /* Do the last partial word */ - ldq_u t2,-1(a3) - extql t3,SRCREG,t3 - extqh t2,SRCREG,t2 - or t2,t3,t2 - br zero,bcopy_samealign_lp_end - -bcopy_da_finish: - /* Do the last word in the next source word */ - ldq_u t3,-1(a3) - extql t2,SRCREG,t2 - extqh t3,SRCREG,t3 - or t2,t3,t2 - insqh t2,DSTREG,t3 - insql t2,DSTREG,t2 - lda t4,-1(zero) - mskql t4,SIZEREG,t5 - cmovne t5,t5,t4 - insqh t4,DSTREG,t5 - insql t4,DSTREG,t4 - addq DSTREG,SIZEREG,a4 - ldq_u t6,0(DSTREG) - ldq_u t7,-1(a4) - bic t6,t4,t6 - bic t7,t5,t7 - and t2,t4,t2 - and t3,t5,t3 - or t2,t6,t2 - or t3,t7,t3 - stq_u t3,-1(a4) - stq_u t2,0(DSTREG) - RET - -bcopy_overlap: - /* - * Basically equivalent to previous case, only backwards. - * Not quite as highly optimized - */ - addq SRCREG,SIZEREG,a3 - addq DSTREG,SIZEREG,a4 - - /* less than 8 bytes - don't worry about overlap */ - cmpule SIZEREG,8,t0 - bne t0,bcopy_ov_short - - /* Possibly do a partial first word */ - and a4,7,t4 - beq t4,bcopy_ov_nostart2 - subq a3,t4,a3 - subq a4,t4,a4 - ldq_u t1,0(a3) - subq SIZEREG,t4,SIZEREG - ldq_u t2,7(a3) - ldq t3,0(a4) - extql t1,a3,t1 - extqh t2,a3,t2 - or t1,t2,t1 - mskqh t3,t4,t3 - mskql t1,t4,t1 - or t1,t3,t1 - stq t1,0(a4) - -bcopy_ov_nostart2: - bic SIZEREG,7,t4 - and SIZEREG,7,SIZEREG - beq t4,bcopy_ov_lp_end - -bcopy_ov_lp: - /* This could be more pipelined, but it doesn't seem worth it */ - ldq_u t0,-8(a3) - subq a4,8,a4 - ldq_u t1,-1(a3) - subq a3,8,a3 - extql t0,a3,t0 - extqh t1,a3,t1 - subq t4,8,t4 - or t0,t1,t0 - stq t0,0(a4) - bne t4,bcopy_ov_lp - -bcopy_ov_lp_end: - beq SIZEREG,bcopy_done - - ldq_u t0,0(SRCREG) - ldq_u t1,7(SRCREG) - ldq_u t2,0(DSTREG) - extql t0,SRCREG,t0 - extqh t1,SRCREG,t1 - or t0,t1,t0 - insql t0,DSTREG,t0 - mskql t2,DSTREG,t2 - or t2,t0,t2 - stq_u t2,0(DSTREG) - -bcopy_done: - RET - -bcopy_ov_short: - ldq_u t2,0(SRCREG) - br zero,bcopy_da_finish - - END(FUNCTION) diff --git a/lib/libc/alpha/string/bzero.S b/lib/libc/alpha/string/bzero.S deleted file mode 100644 index 9897344..0000000 --- a/lib/libc/alpha/string/bzero.S +++ /dev/null @@ -1,110 +0,0 @@ -/* $NetBSD: bzero.S,v 1.2 1996/10/17 03:08:12 cgd Exp $ */ - -/* - * Copyright (c) 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Trevor Blackwell - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include - -LEAF(bzero,2) - ble a1,bzero_done - bic a1,63,t3 /* t3 is # bytes to do 64 bytes at a time */ - - /* If nothing in first word, ignore it */ - subq zero,a0,t0 - and t0,7,t0 /* t0 = (0-size)%8 */ - beq t0,bzero_nostart1 - - cmpult a1,t0,t1 /* if size > size%8 goto noshort */ - beq t1,bzero_noshort - - /* - * The whole thing is less than a word. - * Mask off 1..7 bytes, and finish. - */ - ldq_u t2,0(a0) - lda t0,-1(zero) /* t0=-1 */ - mskql t0,a1,t0 /* Get ff in bytes (a0%8)..((a0+a1-1)%8) */ - insql t0,a0,t0 - bic t2,t0,t2 /* zero those bytes in word */ - stq_u t2,0(a0) - RET - -bzero_noshort: - /* Handle the first partial word */ - ldq_u t2,0(a0) - subq a1,t0,a1 - mskql t2,a0,t2 /* zero bytes (a0%8)..7 in word */ - stq_u t2,0(a0) - - addq a0,t0,a0 /* round a0 up to next word */ - bic a1,63,t3 /* recalc t3 (# bytes to do 64 bytes at a - time) */ - -bzero_nostart1: - /* - * Loop, zeroing 64 bytes at a time - */ - beq t3,bzero_lp_done -bzero_lp: - stq zero,0(a0) - stq zero,8(a0) - stq zero,16(a0) - stq zero,24(a0) - subq t3,64,t3 - stq zero,32(a0) - stq zero,40(a0) - stq zero,48(a0) - stq zero,56(a0) - addq a0,64,a0 - bne t3,bzero_lp - -bzero_lp_done: - /* - * Handle the last 0..7 words. - * We mask off the low bits, so we don't need an extra - * compare instruction for the loop (just a bne. heh-heh) - */ - and a1,0x38,t4 - beq t4,bzero_finish_lp_done -bzero_finish_lp: - stq zero,0(a0) - subq t4,8,t4 - addq a0,8,a0 - bne t4,bzero_finish_lp - - /* Do the last partial word */ -bzero_finish_lp_done: - and a1,7,t5 /* 0..7 bytes left */ - beq t5,bzero_done /* mskqh won't change t0 if t5==0, but I - don't want to touch, say, a new VM page */ - ldq t0,0(a0) - mskqh t0,t5,t0 - stq t0,0(a0) -bzero_done: - RET - - END(bzero) diff --git a/lib/libc/alpha/string/ffs.S b/lib/libc/alpha/string/ffs.S deleted file mode 100644 index 4c30a16..0000000 --- a/lib/libc/alpha/string/ffs.S +++ /dev/null @@ -1,91 +0,0 @@ -/* $NetBSD: ffs.S,v 1.3 1996/10/17 03:08:13 cgd Exp $ */ - -/* - * Copyright (c) 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christopher G. Demetriou - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (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 - -LEAF(ffs, 1) - addl a0, 0, t0 - beq t0, Lallzero - - /* - * Initialize return value (v0), and set up t1 so that it - * contains the mask with only the lowest bit set. - */ - subl zero, t0, t1 - ldil v0, 1 - and t0, t1, t1 - - and t1, 0xff, t2 - bne t2, Ldo8 - - /* - * If lower 16 bits empty, add 16 to result and use upper 16. - */ - zapnot t1, 0x03, t3 - bne t3, Ldo16 - sra t1, 16, t1 - addl v0, 16, v0 - -Ldo16: - /* - * If lower 8 bits empty, add 8 to result and use upper 8. - */ - and t1, 0xff, t4 - bne t4, Ldo8 - sra t1, 8, t1 - addl v0, 8, v0 - -Ldo8: - and t1, 0x0f, t5 /* lower 4 of 8 empty? */ - and t1, 0x33, t6 /* lower 2 of each 4 empty? */ - and t1, 0x55, t7 /* lower 1 of each 2 empty? */ - - /* If lower 4 bits empty, add 4 to result. */ - bne t5, Ldo4 - addl v0, 4, v0 - -Ldo4: /* If lower 2 bits of each 4 empty, add 2 to result. */ - bne t6, Ldo2 - addl v0, 2, v0 - -Ldo2: /* If lower bit of each 2 empty, add 1 to result. */ - bne t7, Ldone - addl v0, 1, v0 - -Ldone: - RET - -Lallzero: - bis zero, zero, v0 - RET -END(ffs) diff --git a/lib/libc/alpha/string/memcpy.S b/lib/libc/alpha/string/memcpy.S deleted file mode 100644 index 7f5527d..0000000 --- a/lib/libc/alpha/string/memcpy.S +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: memcpy.S,v 1.1 1995/08/13 00:40:47 cgd Exp $ */ - -#define MEMCOPY -#include "bcopy.S" diff --git a/lib/libc/alpha/string/memmove.S b/lib/libc/alpha/string/memmove.S deleted file mode 100644 index 4e632d2..0000000 --- a/lib/libc/alpha/string/memmove.S +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: memmove.S,v 1.1 1995/08/13 00:40:48 cgd Exp $ */ - -#define MEMMOVE -#include "bcopy.S" diff --git a/lib/libc/alpha/sys/Makefile.inc b/lib/libc/alpha/sys/Makefile.inc deleted file mode 100644 index 014d32a..0000000 --- a/lib/libc/alpha/sys/Makefile.inc +++ /dev/null @@ -1,17 +0,0 @@ -# $FreeBSD$ - -MDASM+= Ovfork.S brk.S cerror.S exect.S fork.S pipe.S ptrace.S \ - sbrk.S setlogin.S sigreturn.S syscall.S - -# Don't generate default code for these syscalls: -NOASM= __semctl.o break.o exit.o ftruncate.o getdomainname.o getlogin.o \ - lseek.o mlockall.o mmap.o msgctl.o msgget.o msgrcv.o msgsnd.o \ - munlockall.o openbsd_poll.o pread.o pwrite.o semconfig.o semget.o \ - semop.o setdomainname.o shmat.o shmctl.o shmdt.o shmget.o sstk.o \ - thr_sleep.o thr_wakeup.o truncate.o uname.o vfork.o yield.o - -PSEUDO= _getlogin.o - -# Pseudo syscalls that are renamed as _thread_sys_{pseudo} when -# building libc_r. -PSEUDOR= _exit.o diff --git a/lib/libc/alpha/sys/Ovfork.S b/lib/libc/alpha/sys/Ovfork.S deleted file mode 100644 index d8dd3e8..0000000 --- a/lib/libc/alpha/sys/Ovfork.S +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: Ovfork.S,v 1.1 1995/02/10 17:50:29 cgd Exp $ */ - -/* - * Copyright (c) 1994, 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include "SYS.h" - -PSYSCALL(vfork) - cmovne a4, zero, v0 /* a4 (rv[1]) != 0, child */ - RET -PEND(vfork) diff --git a/lib/libc/alpha/sys/brk.S b/lib/libc/alpha/sys/brk.S deleted file mode 100644 index 7dc3a40..0000000 --- a/lib/libc/alpha/sys/brk.S +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: brk.S,v 1.4 1996/10/17 03:08:15 cgd Exp $ */ - -/* - * Copyright (c) 1994, 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include "SYS.h" - - .globl _end -IMPORT(curbrk, 8) - - .data -EXPORT(minbrk) - .quad _end - - .text -LEAF(brk, 1) - br pv, L1 /* XXX profiling */ -L1: LDGP(pv) - ldq v0, minbrk - cmpult a0, v0, t0 - cmovne t0, v0, a0 - CALLSYS_ERROR(break) - stq a0, curbrk - mov zero, v0 - RET -END(brk) diff --git a/lib/libc/alpha/sys/cerror.S b/lib/libc/alpha/sys/cerror.S deleted file mode 100644 index e5b18f7..0000000 --- a/lib/libc/alpha/sys/cerror.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $FreeBSD$ */ -/* From: NetBSD: cerror.S,v 1.4 1996/11/08 00:52:46 cgd Exp */ - -/* - * Copyright (c) 1994, 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include "SYS.h" - -#define FRAME_SIZE 16 -#define FRAME_RA_OFFSET 0 -#define FRAME_V0_OFFSET 8 - -NESTED(.cerror, 0, FRAME_SIZE, ra, IM_RA|IM_V0, 0) - br t0, L1 -L1: LDGP(t0) - - lda sp, -FRAME_SIZE(sp) - stq ra, FRAME_RA_OFFSET(sp) - stq v0, FRAME_V0_OFFSET(sp) - - CALL(__error) - - ldq t0, FRAME_V0_OFFSET(sp) - stl t0, 0(v0) - - ldiq v0, -1 - ldq ra, FRAME_RA_OFFSET(sp) - lda sp, FRAME_SIZE(sp) - RET -END(.cerror) diff --git a/lib/libc/alpha/sys/exect.S b/lib/libc/alpha/sys/exect.S deleted file mode 100644 index 345efb2..0000000 --- a/lib/libc/alpha/sys/exect.S +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: exect.S,v 1.2 1996/10/17 03:08:18 cgd Exp $ */ - -/* - * Copyright (c) 1994, 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include "SYS.h" - -LEAF(exect, 3) - CALLSYS_ERROR(execve) - RET -END(exect) diff --git a/lib/libc/alpha/sys/fork.S b/lib/libc/alpha/sys/fork.S deleted file mode 100644 index a8fa754..0000000 --- a/lib/libc/alpha/sys/fork.S +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: fork.S,v 1.1 1995/02/10 17:50:34 cgd Exp $ */ - -/* - * Copyright (c) 1994, 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include "SYS.h" - -PSYSCALL(fork) - cmovne a4, zero, v0 /* a4 (rv[1]) != 0, child */ - RET -PEND(fork) diff --git a/lib/libc/alpha/sys/pipe.S b/lib/libc/alpha/sys/pipe.S deleted file mode 100644 index 76f44c2..0000000 --- a/lib/libc/alpha/sys/pipe.S +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: pipe.S,v 1.1 1995/02/10 17:50:35 cgd Exp $ */ - -/* - * Copyright (c) 1994, 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include "SYS.h" - -PSYSCALL(pipe) - stl v0, 0(a0) - stl a4, 4(a0) - mov zero, v0 - RET -PEND(pipe) diff --git a/lib/libc/alpha/sys/ptrace.S b/lib/libc/alpha/sys/ptrace.S deleted file mode 100644 index 931b43f..0000000 --- a/lib/libc/alpha/sys/ptrace.S +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: ptrace.S,v 1.4 1996/11/08 00:51:24 cgd Exp $ */ - -/* - * Copyright (c) 1994, 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include "SYS.h" - -LEAF(ptrace, 4) - LDGP(pv) - stl zero, errno - CALLSYS_ERROR(ptrace) - RET -END(ptrace) diff --git a/lib/libc/alpha/sys/sbrk.S b/lib/libc/alpha/sys/sbrk.S deleted file mode 100644 index 5f4e15a..0000000 --- a/lib/libc/alpha/sys/sbrk.S +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: sbrk.S,v 1.4 1996/10/17 03:08:20 cgd Exp $ */ - -/* - * Copyright (c) 1994, 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include "SYS.h" - - .globl _end - - .data -EXPORT(curbrk) - .quad _end - - .text -LEAF(sbrk, 1) - br pv, L1 /* XXX profiling */ -L1: LDGP(pv) - ldq a1, curbrk - beq a0, L2 - addq a0, a1, a0 - CALLSYS_ERROR(break) - stq a0, curbrk -L2: - mov a1, v0 - RET -END(sbrk) diff --git a/lib/libc/alpha/sys/setlogin.S b/lib/libc/alpha/sys/setlogin.S deleted file mode 100644 index 9657cb1..0000000 --- a/lib/libc/alpha/sys/setlogin.S +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: setlogin.S,v 1.1 1995/02/10 17:50:39 cgd Exp $ */ - -/* - * Copyright (c) 1994, 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include "SYS.h" - -IMPORT(_logname_valid, 4) /* in getlogin() */ - -SYSCALL(setlogin) - stl zero, _logname_valid /* clear it */ - RET -END(setlogin) diff --git a/lib/libc/alpha/sys/sigreturn.S b/lib/libc/alpha/sys/sigreturn.S deleted file mode 100644 index a186be6..0000000 --- a/lib/libc/alpha/sys/sigreturn.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: sigreturn.S,v 1.1 1995/02/10 17:50:42 cgd Exp $ */ - -/* - * Copyright (c) 1994, 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include "SYS.h" - -/* - * We must preserve the state of the registers as the user has set them up. - * However, that doesn't involve any special work on the Alpha. - * (XXX PROFILING) - */ - -PRSYSCALL(sigreturn) diff --git a/lib/libc/alpha/sys/syscall.S b/lib/libc/alpha/sys/syscall.S deleted file mode 100644 index 2ccf4d3..0000000 --- a/lib/libc/alpha/sys/syscall.S +++ /dev/null @@ -1,32 +0,0 @@ -/* $NetBSD: syscall.S,v 1.1 1995/02/10 17:50:44 cgd Exp $ */ - -/* - * Copyright (c) 1994, 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include "SYS.h" - -RSYSCALL(syscall) diff --git a/lib/libc/amd64/SYS.h b/lib/libc/amd64/SYS.h deleted file mode 100644 index cadbecb..0000000 --- a/lib/libc/amd64/SYS.h +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)SYS.h 5.5 (Berkeley) 5/7/91 - * - * $FreeBSD$ - */ - -#include -#include "DEFS.h" - -#define SYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \ - ENTRY(__CONCAT(_,x)); \ - .weak CNAME(x); \ - .set CNAME(x),CNAME(__CONCAT(_,x)); \ - lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b - -#define RSYSCALL(x) SYSCALL(x); ret - -#define PSEUDO(x,y) ENTRY(__CONCAT(_,x)); \ - .weak CNAME(x); \ - .set CNAME(x),CNAME(__CONCAT(_,x)); \ - lea __CONCAT(SYS_,y), %eax; KERNCALL; ret - -/* gas messes up offset -- although we don't currently need it, do for BCS */ -#define LCALL(x,y) .byte 0x9a ; .long y; .word x - -/* - * Design note: - * - * The macros PSYSCALL() and PRSYSCALL() are intended for use where a - * syscall needs to be renamed in the threaded library. When building - * a normal library, they default to the traditional SYSCALL() and - * RSYSCALL(). This avoids the need to #ifdef _THREAD_SAFE everywhere - * that the renamed function needs to be called. - */ -#ifdef _THREAD_SAFE -/* - * For the thread_safe versions, we prepend _thread_sys_ to the function - * name so that the 'C' wrapper can go around the real name. - */ -#define PSYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \ - ENTRY(__CONCAT(_thread_sys_,x)); \ - lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b -#define PRSYSCALL(x) PSYSCALL(x); ret -#define PPSEUDO(x,y) ENTRY(__CONCAT(_thread_sys_,x)); \ - lea __CONCAT(SYS_,y), %eax; KERNCALL; ret -#else -/* - * The non-threaded library defaults to traditional syscalls where - * the function name matches the syscall name. - */ -#define PSYSCALL(x) SYSCALL(x) -#define PRSYSCALL(x) RSYSCALL(x) -#define PPSEUDO(x,y) PSEUDO(x,y) -#endif - -#ifdef __ELF__ -#define KERNCALL int $0x80 /* Faster */ -#else -#define KERNCALL LCALL(7,0) /* The old way */ -#endif diff --git a/lib/libc/amd64/gen/Makefile.inc b/lib/libc/amd64/gen/Makefile.inc deleted file mode 100644 index f2506fd..0000000 --- a/lib/libc/amd64/gen/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 -# $FreeBSD$ - -SRCS+= _setjmp.S alloca.S fabs.S frexp.c infinity.c isinf.c ldexp.c modf.S \ - setjmp.S sigsetjmp.S diff --git a/lib/libc/amd64/gen/_setjmp.S b/lib/libc/amd64/gen/_setjmp.S deleted file mode 100644 index 9c66308..0000000 --- a/lib/libc/amd64/gen/_setjmp.S +++ /dev/null @@ -1,89 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS 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 environment 'a'. - * The previous signal state is NOT restored. - */ - -#include "DEFS.h" - -ENTRY(_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) - fnstcw 24(%eax) - xorl %eax,%eax - ret - -#ifdef _THREAD_SAFE -ENTRY(___longjmp) -#else -ALTENTRY(___longjmp) -ENTRY(_longjmp) -#endif - 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 - fninit - fldcw 24(%edx) - testl %eax,%eax - jnz 1f - incl %eax -1: movl %ecx,0(%esp) - ret diff --git a/lib/libc/amd64/gen/frexp.c b/lib/libc/amd64/gen/frexp.c deleted file mode 100644 index 4834f17..0000000 --- a/lib/libc/amd64/gen/frexp.c +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) -static const char rcsid[] = "$FreeBSD$"; -#endif /* LIBC_RCS and not lint */ - -#include -#include - -double -frexp(value, eptr) - double value; - int *eptr; -{ - union { - double v; - struct { - u_int u_mant2 : 32; - u_int u_mant1 : 20; - u_int u_exp : 11; - u_int u_sign : 1; - } s; - } u; - - if (value) { - u.v = value; - *eptr = u.s.u_exp - 1022; - u.s.u_exp = 1022; - return(u.v); - } else { - *eptr = 0; - return((double)0); - } -} diff --git a/lib/libc/amd64/gen/infinity.c b/lib/libc/amd64/gen/infinity.c deleted file mode 100644 index ac92d46..0000000 --- a/lib/libc/amd64/gen/infinity.c +++ /dev/null @@ -1,9 +0,0 @@ -/* - * infinity.c - * $FreeBSD$ - */ - -#include - -/* bytes for +Infinity on a 387 */ -char __infinity[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }; diff --git a/lib/libc/amd64/gen/isinf.c b/lib/libc/amd64/gen/isinf.c deleted file mode 100644 index b2b63a8..0000000 --- a/lib/libc/amd64/gen/isinf.c +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) -static const char rcsid[] = "$FreeBSD$"; -#endif /* LIBC_RCS and not lint */ - -#include - -int -isnan(d) - double d; -{ - register struct IEEEdp { - u_int manl : 32; - u_int manh : 20; - u_int exp : 11; - u_int sign : 1; - } *p = (struct IEEEdp *)&d; - - return(p->exp == 2047 && (p->manh || p->manl)); -} - -int -isinf(d) - double d; -{ - register struct IEEEdp { - u_int manl : 32; - u_int manh : 20; - u_int exp : 11; - u_int sign : 1; - } *p = (struct IEEEdp *)&d; - - return(p->exp == 2047 && !p->manh && !p->manl); -} diff --git a/lib/libc/amd64/gen/ldexp.c b/lib/libc/amd64/gen/ldexp.c deleted file mode 100644 index e7e58f0..0000000 --- a/lib/libc/amd64/gen/ldexp.c +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Sean Eric Fagan. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) -static const char rcsid[] = "$FreeBSD$"; -#endif /* LIBC_RCS and not lint */ - -/* - * ldexp(value, exp): return value * (2 ** exp). - * - * Written by Sean Eric Fagan (sef@kithrup.COM) - * Sun Mar 11 20:27:09 PST 1990 - */ - -/* - * We do the conversion in C to let gcc optimize it away, if possible. - * The "fxch ; fstp" stuff is because value is still on the stack - * (stupid 8087!). - */ -double -ldexp (double value, int exp) -{ - double temp, texp, temp2; - texp = exp; -#ifdef __GNUC__ -#if __GNUC__ >= 2 - asm ("fscale " - : "=u" (temp2), "=t" (temp) - : "0" (texp), "1" (value)); -#else - asm ("fscale ; fxch %%st(1) ; fstp%L1 %1 " - : "=f" (temp), "=0" (temp2) - : "0" (texp), "f" (value)); -#endif -#else -error unknown asm -#endif - return (temp); -} diff --git a/lib/libc/amd64/gen/setjmp.S b/lib/libc/amd64/gen/setjmp.S deleted file mode 100644 index 39e9c21..0000000 --- a/lib/libc/amd64/gen/setjmp.S +++ /dev/null @@ -1,116 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS 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 environment 'a'. - * The previous signal state is restored. - */ - -#include "DEFS.h" -#include "SYS.h" - -ENTRY(setjmp) - movl 4(%esp),%ecx - PIC_PROLOGUE - leal 28(%ecx), %eax - pushl %eax /* (sigset_t*)oset */ - pushl $0 /* (sigset_t*)set */ - pushl $1 /* SIG_BLOCK */ -#ifdef _THREAD_SAFE - call PIC_PLT(CNAME(_thread_sys_sigprocmask)) -#else - call PIC_PLT(CNAME(sigprocmask)) -#endif - addl $12,%esp - PIC_EPILOGUE - movl 4(%esp),%ecx - movl 0(%esp),%edx - movl %edx, 0(%ecx) - movl %ebx, 4(%ecx) - movl %esp, 8(%ecx) - movl %ebp,12(%ecx) - movl %esi,16(%ecx) - movl %edi,20(%ecx) - fnstcw 24(%ecx) - xorl %eax,%eax - ret - -#ifdef _THREAD_SAFE -ENTRY(__longjmp) -#else -ALTENTRY(__longjmp) -ENTRY(longjmp) -#endif - movl 4(%esp),%edx - PIC_PROLOGUE - pushl $0 /* (sigset_t*)oset */ - leal 28(%edx), %eax - pushl %eax /* (sigset_t*)set */ - pushl $3 /* SIG_SETMASK */ -#ifdef _THREAD_SAFE - call PIC_PLT(CNAME(_thread_sys_sigprocmask)) -#else - call PIC_PLT(CNAME(sigprocmask)) -#endif - addl $12,%esp - PIC_EPILOGUE - 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 - fninit - fldcw 24(%edx) - testl %eax,%eax - jnz 1f - incl %eax -1: movl %ecx,0(%esp) - ret diff --git a/lib/libc/amd64/gen/sigsetjmp.S b/lib/libc/amd64/gen/sigsetjmp.S deleted file mode 100644 index 13c0dc7..0000000 --- a/lib/libc/amd64/gen/sigsetjmp.S +++ /dev/null @@ -1,127 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" -#include "SYS.h" - -/*- - * TODO: - * Rename sigsetjmp to __sigsetjmp and siglongjmp to __siglongjmp, - * remove the other *jmp functions and define everything in terms - * of the renamed functions. This requires compiler support for - * the renamed functions (introduced in gcc-2.5.3; previous versions - * only supported *jmp with 0 or 1 leading underscores). - * - * Use sigprocmask() instead of sigblock() and sigsetmask(), and - * check for and handle errors. - * - * Restore _all_ the registers and the signal mask atomically. Can - * use sigreturn() if sigreturn() works. - */ - -ENTRY(sigsetjmp) - movl 8(%esp),%eax - movl 4(%esp),%ecx - movl %eax,44(%ecx) - testl %eax,%eax - jz 2f - PIC_PROLOGUE - leal 28(%ecx), %eax - pushl %eax /* (sigset_t*)oset */ - pushl $0 /* (sigset_t*)set */ - pushl $1 /* SIG_BLOCK */ -#ifdef _THREAD_SAFE - call PIC_PLT(CNAME(_thread_sys_sigprocmask)) -#else - call PIC_PLT(CNAME(sigprocmask)) -#endif - addl $12,%esp - PIC_EPILOGUE - movl 4(%esp),%ecx -2: movl 0(%esp),%edx - movl %edx, 0(%ecx) - movl %ebx, 4(%ecx) - movl %esp, 8(%ecx) - movl %ebp,12(%ecx) - movl %esi,16(%ecx) - movl %edi,20(%ecx) - fnstcw 24(%ecx) - xorl %eax,%eax - ret - -#ifdef _THREAD_SAFE -ENTRY(__siglongjmp) -#else -ALTENTRY(__siglongjmp) -ENTRY(siglongjmp) -#endif - movl 4(%esp),%edx - cmpl $0,44(%edx) - jz 2f - PIC_PROLOGUE - pushl $0 /* (sigset_t*)oset */ - leal 28(%edx), %eax - pushl %eax /* (sigset_t*)set */ - pushl $3 /* SIG_SETMASK */ -#ifdef _THREAD_SAFE - call PIC_PLT(CNAME(_thread_sys_sigprocmask)) -#else - call PIC_PLT(CNAME(sigprocmask)) -#endif - addl $12,%esp - PIC_EPILOGUE - movl 4(%esp),%edx -2: 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 - fninit - fldcw 24(%edx) - testl %eax,%eax - jnz 1f - incl %eax -1: movl %ecx,0(%esp) - ret diff --git a/lib/libc/amd64/net/Makefile.inc b/lib/libc/amd64/net/Makefile.inc deleted file mode 100644 index 96e559b..0000000 --- a/lib/libc/amd64/net/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 -# $FreeBSD$ - -SRCS+= htonl.S htons.S ntohl.S ntohs.S diff --git a/lib/libc/amd64/net/htonl.S b/lib/libc/amd64/net/htonl.S deleted file mode 100644 index 48f1ca8..0000000 --- a/lib/libc/amd64/net/htonl.S +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -/* netorder = htonl(hostorder) */ - -#include "DEFS.h" - -ENTRY(htonl) - movl 4(%esp),%eax - xchgb %al,%ah - roll $16,%eax - xchgb %al,%ah - ret diff --git a/lib/libc/amd64/net/htons.S b/lib/libc/amd64/net/htons.S deleted file mode 100644 index 68f2b5a..0000000 --- a/lib/libc/amd64/net/htons.S +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -/* netorder = htons(hostorder) */ - -#include "DEFS.h" - -ENTRY(htons) - movzwl 4(%esp),%eax - xchgb %al,%ah - ret diff --git a/lib/libc/amd64/net/ntohl.S b/lib/libc/amd64/net/ntohl.S deleted file mode 100644 index 7be9dee..0000000 --- a/lib/libc/amd64/net/ntohl.S +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -/* hostorder = ntohl(netorder) */ - -#include "DEFS.h" - -ENTRY(ntohl) - movl 4(%esp),%eax - xchgb %al,%ah - roll $16,%eax - xchgb %al,%ah - ret diff --git a/lib/libc/amd64/net/ntohs.S b/lib/libc/amd64/net/ntohs.S deleted file mode 100644 index 0f1d228..0000000 --- a/lib/libc/amd64/net/ntohs.S +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -/* hostorder = ntohs(netorder) */ - -#include "DEFS.h" - -ENTRY(ntohs) - movzwl 4(%esp),%eax - xchgb %al,%ah - ret diff --git a/lib/libc/amd64/sys/Makefile.inc b/lib/libc/amd64/sys/Makefile.inc deleted file mode 100644 index c1c3d2d..0000000 --- a/lib/libc/amd64/sys/Makefile.inc +++ /dev/null @@ -1,28 +0,0 @@ -# from: Makefile.inc,v 1.1 1993/09/03 19:04:23 jtc Exp -# $FreeBSD$ - -SRCS+= i386_get_ioperm.c i386_get_ldt.c i386_set_ioperm.c i386_set_ldt.c \ - i386_vm86.c - -MDASM= Ovfork.S brk.S cerror.S exect.S fork.S pipe.S ptrace.S reboot.S \ - rfork.S sbrk.S setlogin.S sigreturn.S syscall.S - -# Don't generate default code for these syscalls: -NOASM= __semctl.o break.o exit.o ftruncate.o getdomainname.o getlogin.o \ - lseek.o mlockall.o mmap.o msgctl.o msgget.o msgrcv.o msgsnd.o \ - munlockall.o openbsd_poll.o pread.o pwrite.o semconfig.o semget.o \ - semop.o setdomainname.o shmat.o shmctl.o shmdt.o shmget.o sstk.o \ - thr_sleep.o thr_wakeup.o truncate.o uname.o vfork.o yield.o - -PSEUDO= _getlogin.o - -# Pseudo syscalls that are renamed as _thread_sys_{pseudo} when -# building libc_r. -PSEUDOR= _exit.o - -.if ${LIB} == "c" -MAN2+= i386_get_ioperm.2 i386_get_ldt.2 i386_vm86.2 - -MLINKS+=i386_get_ioperm.2 i386_set_ioperm.2 -MLINKS+=i386_get_ldt.2 i386_set_ldt.2 -.endif diff --git a/lib/libc/amd64/sys/brk.S b/lib/libc/amd64/sys/brk.S deleted file mode 100644 index 5726675..0000000 --- a/lib/libc/amd64/sys/brk.S +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - - .globl HIDENAME(curbrk) - .globl HIDENAME(minbrk) -ENTRY(_brk) - jmp ok - -ENTRY(brk) -#ifdef PIC - movl 4(%esp),%eax - PIC_PROLOGUE - movl PIC_GOT(HIDENAME(curbrk)),%edx # set up GOT addressing - movl PIC_GOT(HIDENAME(minbrk)),%ecx # - PIC_EPILOGUE - cmpl %eax,(%ecx) - jbe ok - movl (%ecx),%eax - movl %eax,4(%esp) -ok: - lea SYS_break,%eax - KERNCALL - jb err - movl 4(%esp),%eax - movl %eax,(%edx) - movl $0,%eax - ret -err: - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) - -#else - - movl 4(%esp),%eax - cmpl %eax,HIDENAME(minbrk) - jbe ok - movl HIDENAME(minbrk),%eax - movl %eax,4(%esp) -ok: - lea SYS_break,%eax - KERNCALL - jb err - movl 4(%esp),%eax - movl %eax,HIDENAME(curbrk) - movl $0,%eax - ret -err: - jmp HIDENAME(cerror) -#endif diff --git a/lib/libc/amd64/sys/cerror.S b/lib/libc/amd64/sys/cerror.S deleted file mode 100644 index 31c3622..0000000 --- a/lib/libc/amd64/sys/cerror.S +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - - .globl HIDENAME(cerror) - - /* - * The __error() function is thread aware. For non-threaded - * programs and the initial threaded in threaded programs, - * it returns a pointer to the global errno variable. - */ - .globl CNAME(__error) - .type CNAME(__error),@function -HIDENAME(cerror): - pushl %eax -#ifdef PIC - /* The caller must execute the PIC prologue before jumping to cerror. */ - call PIC_PLT(CNAME(__error)) - popl %ecx - PIC_EPILOGUE -#else - call CNAME(__error) - popl %ecx -#endif - movl %ecx,(%eax) - movl $-1,%eax - movl $-1,%edx - ret - diff --git a/lib/libc/amd64/sys/exect.S b/lib/libc/amd64/sys/exect.S deleted file mode 100644 index 9f90060..0000000 --- a/lib/libc/amd64/sys/exect.S +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" -#include - -ENTRY(exect) - lea SYS_execve,%eax - pushf - popl %edx - orl $ PSL_T,%edx - pushl %edx - popf - KERNCALL - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) /* exect(file, argv, env); */ diff --git a/lib/libc/amd64/sys/pipe.S b/lib/libc/amd64/sys/pipe.S deleted file mode 100644 index 1684611..0000000 --- a/lib/libc/amd64/sys/pipe.S +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - -PSYSCALL(pipe) - movl 4(%esp),%ecx - movl %eax,(%ecx) - movl %edx,4(%ecx) - movl $0,%eax - ret diff --git a/lib/libc/amd64/sys/ptrace.S b/lib/libc/amd64/sys/ptrace.S deleted file mode 100644 index 7f5e149..0000000 --- a/lib/libc/amd64/sys/ptrace.S +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - -ENTRY(ptrace) - xorl %eax,%eax -#ifdef PIC - PIC_PROLOGUE - movl PIC_GOT(CNAME(errno)),%edx - movl %eax,(%edx) - PIC_EPILOGUE -#else - movl %eax,CNAME(errno) -#endif - lea SYS_ptrace,%eax - KERNCALL - jb err - ret -err: - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) diff --git a/lib/libc/amd64/sys/reboot.S b/lib/libc/amd64/sys/reboot.S deleted file mode 100644 index 4e39068..0000000 --- a/lib/libc/amd64/sys/reboot.S +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - -SYSCALL(reboot) - iret diff --git a/lib/libc/amd64/sys/sbrk.S b/lib/libc/amd64/sys/sbrk.S deleted file mode 100644 index f7aae35..0000000 --- a/lib/libc/amd64/sys/sbrk.S +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - - .globl CNAME(end) - .globl HIDENAME(minbrk) - .globl HIDENAME(curbrk) - - .data -HIDENAME(minbrk): .long CNAME(end) -HIDENAME(curbrk): .long CNAME(end) - .text - -ENTRY(sbrk) -#ifdef PIC - movl 4(%esp),%ecx - PIC_PROLOGUE - movl PIC_GOT(HIDENAME(curbrk)),%edx - movl (%edx),%eax - PIC_EPILOGUE - testl %ecx,%ecx - jz back - addl %eax,4(%esp) - lea SYS_break,%eax - KERNCALL - jb err - PIC_PROLOGUE - movl PIC_GOT(HIDENAME(curbrk)),%edx - movl (%edx),%eax - addl %ecx,(%edx) - PIC_EPILOGUE -back: - ret -err: - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) - -#else /* !PIC */ - - movl 4(%esp),%ecx - movl HIDENAME(curbrk),%eax - testl %ecx,%ecx - jz back - addl %eax,4(%esp) - lea SYS_break,%eax - KERNCALL - jb err - movl HIDENAME(curbrk),%eax - addl %ecx,HIDENAME(curbrk) -back: - ret -err: - jmp HIDENAME(cerror) -#endif /* PIC */ diff --git a/lib/libc/amd64/sys/setlogin.S b/lib/libc/amd64/sys/setlogin.S deleted file mode 100644 index a4d74b0..0000000 --- a/lib/libc/amd64/sys/setlogin.S +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 1991 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "SYS.h" - -.globl CNAME(_logname_valid) /* in getlogin() */ - -SYSCALL(setlogin) -#ifdef PIC - PIC_PROLOGUE - pushl %eax - movl PIC_GOT(CNAME(_logname_valid)),%eax - movl $0,(%eax) - popl %eax - PIC_EPILOGUE -#else - movl $0,CNAME(_logname_valid) -#endif - ret /* setlogin(name) */ diff --git a/lib/libc/amd64/sys/sigreturn.S b/lib/libc/amd64/sys/sigreturn.S deleted file mode 100644 index 7405c34..0000000 --- a/lib/libc/amd64/sys/sigreturn.S +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - -/* - * NOTE: If the profiling ENTRY() code ever changes any registers, they - * must be saved. On FreeBSD, this is not the case. - */ - -PSYSCALL(sigreturn) - ret diff --git a/lib/libc/amd64/sys/vfork.S b/lib/libc/amd64/sys/vfork.S deleted file mode 100644 index 30d7fd1..0000000 --- a/lib/libc/amd64/sys/vfork.S +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "DEFS.h" -#include "SYS.h" - -/* - * pid = vfork(); - * - * %edx == 0 in parent process, %edx == 1 in child process. - * %eax == pid of child in parent, %eax == pid of parent in child. - * - */ - -#ifdef _THREAD_SAFE -ENTRY(_thread_sys_vfork) -#else -ENTRY(vfork) -#endif - popl %ecx /* my rta into ecx */ - lea SYS_vfork,%eax - KERNCALL - jb 2f - cmpl $0,%edx /* parent process? */ - je 1f /* yes */ - movl $0,%eax -1: - jmp %ecx -2: - pushl %ecx - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) diff --git a/lib/libc/compat-43/Makefile.inc b/lib/libc/compat-43/Makefile.inc deleted file mode 100644 index e901882..0000000 --- a/lib/libc/compat-43/Makefile.inc +++ /dev/null @@ -1,16 +0,0 @@ -# @(#)Makefile.inc 8.1 (Berkeley) 6/2/93 -# $FreeBSD$ - -# compat-43 sources -.PATH: ${.CURDIR}/../libc/${MACHINE_ARCH}/compat-43 ${.CURDIR}/../libc/compat-43 - -SRCS+= creat.c gethostid.c getwd.c killpg.c sethostid.c setpgrp.c \ - setrgid.c setruid.c sigcompat.c - -.if ${LIB} == "c" -MAN2+= creat.2 killpg.2 sigblock.2 sigpause.2 sigsetmask.2 sigvec.2 -MAN3+= gethostid.3 setruid.3 - -MLINKS+=gethostid.3 sethostid.3 -MLINKS+=setruid.3 setrgid.3 -.endif diff --git a/lib/libc/compat-43/creat.2 b/lib/libc/compat-43/creat.2 deleted file mode 100644 index 7e9f099..0000000 --- a/lib/libc/compat-43/creat.2 +++ /dev/null @@ -1,62 +0,0 @@ -.\" Copyright (c) 1989, 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. -.\" -.\" @(#)creat.2 8.1 (Berkeley) 6/2/93 -.\" $FreeBSD$ -.\" -.Dd June 2, 1993 -.Dt CREAT 2 -.Os BSD 4 -.Sh NAME -.Nm creat -.Nd create a new file -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn creat "const char *path" "mode_t mode" -.Sh DESCRIPTION -.Bf -symbolic -This interface is made obsolete by: -.Ef -.Xr open 2 . -.Pp -.Fn Creat -is the same as: -.Bd -literal -offset indent -open(path, O_CREAT | O_TRUNC | O_WRONLY, mode); -.Ed -.Sh SEE ALSO -.Xr open 2 -.Sh HISTORY -The -.Fn creat -function call appeared in -.At v6 . diff --git a/lib/libc/compat-43/creat.c b/lib/libc/compat-43/creat.c deleted file mode 100644 index 42759e7..0000000 --- a/lib/libc/compat-43/creat.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)creat.c 8.1 (Berkeley) 6/2/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -int -#if __STDC__ -__creat(const char *path, mode_t mode) -#else -__creat(path, mode) - char *path; - mode_t mode; -#endif -{ - return(_open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)); -} - -#ifndef _THREAD_SAFE -__weak_reference(__creat, creat); -#endif diff --git a/lib/libc/compat-43/gethostid.3 b/lib/libc/compat-43/gethostid.3 deleted file mode 100644 index df3644c..0000000 --- a/lib/libc/compat-43/gethostid.3 +++ /dev/null @@ -1,76 +0,0 @@ -.\" Copyright (c) 1983, 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. -.\" -.\" @(#)gethostid.3 8.1 (Berkeley) 6/2/93 -.\" $FreeBSD$ -.\" -.Dd June 2, 1993 -.Dt GETHOSTID 3 -.Os BSD 4.2 -.Sh NAME -.Nm gethostid , -.Nm sethostid -.Nd get/set unique identifier of current host -.Sh SYNOPSIS -.Fd #include -.Ft long -.Fn gethostid void -.Ft void -.Fn sethostid "long hostid" -.Sh DESCRIPTION -.Fn Sethostid -establishes a 32-bit identifier for the -current processor that is intended to be unique among all -UNIX systems in existence. This is normally a DARPA Internet -address for the local machine. This call is allowed only to the -super-user and is normally performed at boot time. -.Pp -.Fn Gethostid -returns the 32-bit identifier for the current processor. -.Pp -This function has been deprecated. -The hostid should be set or retrieved by use of -.Xr sysctl 3 . -.Sh SEE ALSO -.Xr gethostname 3 , -.Xr sysctl 3 , -.Xr sysctl 8 . -.Sh BUGS -32 bits for the identifier is too small. -.Sh HISTORY -The -.Fn gethostid -and -.Fn sethostid -syscalls appeared in -.Bx 4.2 -and were dropped in -.Bx 4.4 . diff --git a/lib/libc/compat-43/gethostid.c b/lib/libc/compat-43/gethostid.c deleted file mode 100644 index c4caff6..0000000 --- a/lib/libc/compat-43/gethostid.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)gethostid.c 8.1 (Berkeley) 6/2/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#if __STDC__ -long -gethostid(void) -#else -long -gethostid() -#endif -{ - int mib[2]; - size_t size; - long value; - - mib[0] = CTL_KERN; - mib[1] = KERN_HOSTID; - size = sizeof value; - if (sysctl(mib, 2, &value, &size, NULL, 0) == -1) - return (-1); - return (value); -} diff --git a/lib/libc/compat-43/getwd.c b/lib/libc/compat-43/getwd.c deleted file mode 100644 index 9f0e633..0000000 --- a/lib/libc/compat-43/getwd.c +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getwd.c 8.1 (Berkeley) 6/2/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include - -char * -getwd(buf) - char *buf; -{ - char *p; - - if ( (p = getcwd(buf, MAXPATHLEN)) ) - return(p); - (void)strcpy(buf, strerror(errno)); - return((char *)NULL); -} diff --git a/lib/libc/compat-43/killpg.2 b/lib/libc/compat-43/killpg.2 deleted file mode 100644 index 365ab4b..0000000 --- a/lib/libc/compat-43/killpg.2 +++ /dev/null @@ -1,97 +0,0 @@ -.\" Copyright (c) 1980, 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. -.\" -.\" @(#)killpg.2 8.1 (Berkeley) 6/2/93 -.\" $FreeBSD$ -.\" -.Dd June 2, 1993 -.Dt KILLPG 2 -.Os BSD 4 -.Sh NAME -.Nm killpg -.Nd send signal to a process group -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Ft int -.Fn killpg "pid_t pgrp" "int sig" -.Sh DESCRIPTION -.Fn Killpg -sends the signal -.Fa sig -to the process group -.Fa pgrp . -See -.Xr sigaction 2 -for a list of signals. -If -.Fa pgrp -is 0, -.Fn killpg -sends the signal to the sending process's process group. -.Pp -The sending process and members of the process group must -have the same effective user ID, or -the sender must be the super-user. -As a single special case the continue signal SIGCONT may be sent -to any process that is a descendant of the current process. -.Sh RETURN VALUES -Upon successful completion, a value of 0 is returned. Otherwise, -a value of -1 is returned and the global variable -.Va errno -is set to indicate the error. -.Sh ERRORS -.Fn Killpg -will fail and no signal will be sent if: -.Bl -tag -width Er -.It Bq Er EINVAL -.Fa Sig -is not a valid signal number. -.It Bq Er ESRCH -No process can be found in the process group specified by -.Fa pgrp . -.It Bq Er ESRCH -The process group was given as 0 -but the sending process does not have a process group. -.It Bq Er EPERM -The sending process is not the super-user and one or more -of the target processes has an effective user ID different from that -of the sending process. -.El -.Sh SEE ALSO -.Xr getpgrp 2 , -.Xr kill 2 , -.Xr sigaction 2 -.Sh HISTORY -The -.Fn killpg -function call appeared in -.Bx 4.0 . diff --git a/lib/libc/compat-43/killpg.c b/lib/libc/compat-43/killpg.c deleted file mode 100644 index ac3ba6e..0000000 --- a/lib/libc/compat-43/killpg.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)killpg.c 8.1 (Berkeley) 6/2/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -/* - * Backwards-compatible killpg(). - */ -int -#if __STDC__ -killpg(pid_t pgid, int sig) -#else -killpg(pgid, sig) - pid_t pgid; - int sig; -#endif -{ - if (pgid == 1) { - errno = ESRCH; - return (-1); - } - return (kill(-pgid, sig)); -} diff --git a/lib/libc/compat-43/sethostid.c b/lib/libc/compat-43/sethostid.c deleted file mode 100644 index 8122c81..0000000 --- a/lib/libc/compat-43/sethostid.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)sethostid.c 8.1 (Berkeley) 6/2/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#if __STDC__ -long -sethostid(long hostid) -#else -long -sethostid(hostid) - long hostid; -#endif -{ - int mib[2]; - - mib[0] = CTL_KERN; - mib[1] = KERN_HOSTID; - if (sysctl(mib, 2, NULL, NULL, &hostid, sizeof hostid) == -1) - return (-1); - return (0); -} diff --git a/lib/libc/compat-43/setpgrp.c b/lib/libc/compat-43/setpgrp.c deleted file mode 100644 index dc0dd3f..0000000 --- a/lib/libc/compat-43/setpgrp.c +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)setpgrp.c 8.1 (Berkeley) 6/2/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -int -#if __STDC__ -setpgrp(pid_t pid, pid_t pgid) -#else -setpgrp(pid, pgid) - pid_t pid, pgid; -#endif -{ - return(setpgid(pid, pgid)); -} diff --git a/lib/libc/compat-43/setrgid.c b/lib/libc/compat-43/setrgid.c deleted file mode 100644 index 1d86642..0000000 --- a/lib/libc/compat-43/setrgid.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)setrgid.c 8.1 (Berkeley) 6/2/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -int -#ifdef __STDC__ -setrgid(gid_t rgid) -#else -setrgid(rgid) - int rgid; -#endif -{ - - return (setregid(rgid, -1)); -} diff --git a/lib/libc/compat-43/setruid.3 b/lib/libc/compat-43/setruid.3 deleted file mode 100644 index 843a59f..0000000 --- a/lib/libc/compat-43/setruid.3 +++ /dev/null @@ -1,80 +0,0 @@ -.\" Copyright (c) 1983, 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. -.\" -.\" @(#)setruid.3 8.1 (Berkeley) 6/2/93 -.\" $FreeBSD$ -.\" -.Dd June 2, 1993 -.Dt SETRUID 3 -.Os BSD 4.2 -.Sh NAME -.Nm setruid , -.Nm setrgid -.Nd set user and group ID -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn setruid "uid_t ruid" -.Ft int -.Fn setrgid "gid_t rgid" -.Sh DESCRIPTION -The -.Fn setruid -function -.Pq Fn setrgid -sets the real user ID (group ID) of the -current process. -.Sh RETURN VALUES -Upon success, these functions return 0; -otherwise \-1 is returned. -.Pp -If the user is not the super user, or the uid -specified is not the real or effective ID, these -functions return \-1. -.Pp -The use of these calls is not portable. -Their use is discouraged; they will be removed in the future. -.Sh SEE ALSO -.Xr getgid 2 , -.Xr getuid 2 , -.Xr setegid 2 , -.Xr seteuid 2 , -.Xr setgid 2 , -.Xr setuid 2 -.Sh HISTORY -The -.Fn setruid -and -.Fn setrgid -syscalls appeared in -.Bx 4.2 -and were dropped in -.Bx 4.4 . diff --git a/lib/libc/compat-43/setruid.c b/lib/libc/compat-43/setruid.c deleted file mode 100644 index 1551abb..0000000 --- a/lib/libc/compat-43/setruid.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)setruid.c 8.1 (Berkeley) 6/2/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -int -#ifdef __STDC__ -setruid(uid_t ruid) -#else -setruid(ruid) - int ruid; -#endif -{ - - return (setreuid(ruid, -1)); -} diff --git a/lib/libc/compat-43/sigblock.2 b/lib/libc/compat-43/sigblock.2 deleted file mode 100644 index f7809b8..0000000 --- a/lib/libc/compat-43/sigblock.2 +++ /dev/null @@ -1,85 +0,0 @@ -.\" Copyright (c) 1983, 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. -.\" -.\" @(#)sigblock.2 8.1 (Berkeley) 6/2/93 -.\" $FreeBSD$ -.\" -.Dd June 2, 1993 -.Dt SIGBLOCK 2 -.Os BSD 4.2 -.Sh NAME -.Nm sigblock -.Nd block signals -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn sigblock "int mask" -.Ft int -.Fn sigmask signum -.Sh DESCRIPTION -.Bf -symbolic -This interface is made obsolete by: -.Ef -.Xr sigprocmask 2 . -.Pp -.Fn Sigblock -adds the signals specified in -.Fa mask -to the set of signals currently -being blocked from delivery. -Signals are blocked if the -corresponding bit in -.Fa mask -is a 1; the macro -.Fn sigmask -is provided to construct the mask for a given -.Fa signum . -.Pp -It is not possible to block -.Dv SIGKILL -or -.Dv SIGSTOP ; -this restriction is silently -imposed by the system. -.Sh RETURN VALUES -The previous set of masked signals is returned. -.Sh SEE ALSO -.Xr kill 2 , -.Xr sigaction 2 , -.Xr sigprocmask 2 , -.Xr sigsetmask 2 , -.Xr sigsetops 3 -.Sh HISTORY -The -.Fn sigblock -function call appeared in -.Bx 4.2 -and has been deprecated. diff --git a/lib/libc/compat-43/sigcompat.c b/lib/libc/compat-43/sigcompat.c deleted file mode 100644 index 9401e73..0000000 --- a/lib/libc/compat-43/sigcompat.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)sigcompat.c 8.1 (Berkeley) 6/2/93"; -#endif -static const char rcsid[] = - "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -int -sigvec(signo, sv, osv) - int signo; - struct sigvec *sv, *osv; -{ - struct sigaction sa, osa; - struct sigaction *sap, *osap; - int ret; - - if (sv != NULL) { - sa.sa_handler = sv->sv_handler; - sa.sa_flags = sv->sv_flags ^ SV_INTERRUPT; - sigemptyset(&sa.sa_mask); - sa.sa_mask.__bits[0] = sv->sv_mask; - sap = &sa; - } else - sap = NULL; - osap = osv != NULL ? &osa : NULL; - ret = sigaction(signo, sap, osap); - if (ret == 0 && osv != NULL) { - osv->sv_handler = osa.sa_handler; - osv->sv_flags = osa.sa_flags ^ SV_INTERRUPT; - osv->sv_mask = osa.sa_mask.__bits[0]; - } - return (ret); -} - -int -sigsetmask(mask) - int mask; -{ - sigset_t set, oset; - int n; - - sigemptyset(&set); - set.__bits[0] = mask; - n = sigprocmask(SIG_SETMASK, &set, &oset); - if (n) - return (n); - return (oset.__bits[0]); -} - -int -sigblock(mask) - int mask; -{ - sigset_t set, oset; - int n; - - sigemptyset(&set); - set.__bits[0] = mask; - n = sigprocmask(SIG_BLOCK, &set, &oset); - if (n) - return (n); - return (oset.__bits[0]); -} - -int -sigpause(mask) - int mask; -{ - sigset_t set; - - sigemptyset(&set); - set.__bits[0] = mask; - return (_sigsuspend(&set)); -} diff --git a/lib/libc/compat-43/sigpause.2 b/lib/libc/compat-43/sigpause.2 deleted file mode 100644 index 166fda3..0000000 --- a/lib/libc/compat-43/sigpause.2 +++ /dev/null @@ -1,75 +0,0 @@ -.\" Copyright (c) 1983, 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. -.\" -.\" @(#)sigpause.2 8.1 (Berkeley) 6/2/93 -.\" $FreeBSD$ -.\" -.Dd June 2, 1993 -.Dt SIGPAUSE 2 -.Os BSD 4 -.Sh NAME -.Nm sigpause -.Nd atomically release blocked signals and wait for interrupt -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn sigpause "int sigmask" -.Sh DESCRIPTION -.Sy This interface is made obsolete by -.Xr sigsuspend 2 . -.Pp -.Fn Sigpause -assigns -.Fa sigmask -to the set of masked signals -and then waits for a signal to arrive; -on return the set of masked signals is restored. -.Fa Sigmask -is usually 0 to indicate that no -signals are to be blocked. -.Fn Sigpause -always terminates by being interrupted, returning -1 with -.Va errno -set to -.Dv EINTR -.Sh SEE ALSO -.Xr kill 2 , -.Xr sigaction 2 , -.Xr sigblock 2 , -.Xr sigprocmask 2 , -.Xr sigsuspend 2 , -.Xr sigvec 2 -.Sh HISTORY -The -.Fn sigpause -function call appeared in -.Bx 4.2 -and has been deprecated. diff --git a/lib/libc/compat-43/sigsetmask.2 b/lib/libc/compat-43/sigsetmask.2 deleted file mode 100644 index f5412f1..0000000 --- a/lib/libc/compat-43/sigsetmask.2 +++ /dev/null @@ -1,83 +0,0 @@ -.\" Copyright (c) 1983, 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. -.\" -.\" @(#)sigsetmask.2 8.1 (Berkeley) 6/2/93 -.\" $FreeBSD$ -.\" -.Dd June 2, 1993 -.Dt SIGSETMASK 2 -.Os BSD 4.2 -.Sh NAME -.Nm sigsetmask -.Nd set current signal mask -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn sigsetmask "int mask" -.Fn sigmask signum -.Sh DESCRIPTION -.Bf -symbolic -This interface is made obsolete by: -.Ef -.Xr sigprocmask 2 . -.Pp -.Fn Sigsetmask -sets the current signal mask. Signals -are blocked from delivery if the -corresponding bit in -.Fa mask -is a 1; the macro -.Fn sigmask -is provided to construct the mask for a given -.Fa signum . -.Pp -The system -quietly disallows -.Dv SIGKILL -or -.Dv SIGSTOP -to be blocked. -.Sh RETURN VALUES -The previous set of masked signals is returned. -.Sh SEE ALSO -.Xr kill 2 , -.Xr sigaction 2 , -.Xr sigblock 2 , -.Xr sigprocmask 2 , -.Xr sigsuspend 2 , -.Xr sigvec 2 , -.Xr sigsetops 3 -.Sh HISTORY -The -.Fn sigsetmask -function call appeared in -.Bx 4.2 -and has been deprecated. diff --git a/lib/libc/compat-43/sigvec.2 b/lib/libc/compat-43/sigvec.2 deleted file mode 100644 index f144efa..0000000 --- a/lib/libc/compat-43/sigvec.2 +++ /dev/null @@ -1,327 +0,0 @@ -.\" Copyright (c) 1980, 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. -.\" -.\" @(#)sigvec.2 8.2 (Berkeley) 4/19/94 -.\" $FreeBSD$ -.\" -.Dd April 19, 1994 -.Dt SIGVEC 2 -.Os BSD 4 -.Sh NAME -.Nm sigvec -.Nd software signal facilities -.Sh SYNOPSIS -.Fd #include -.Bd -literal -struct sigvec { - void (*sv_handler)(); - int sv_mask; - int sv_flags; -}; -.Ed -.Ft int -.Fn sigvec "int sig" "struct sigvec *vec" "struct sigvec *ovec" -.Sh DESCRIPTION -.Bf -symbolic -This interface is made obsolete by sigaction(2). -.Ef -.Pp -The system defines a set of signals that may be delivered to a process. -Signal delivery resembles the occurrence of a hardware interrupt: -the signal is blocked from further occurrence, the current process -context is saved, and a new one is built. A process may specify a -.Em handler -to which a signal is delivered, or specify that a signal is to be -.Em blocked -or -.Em ignored . -A process may also specify that a default action is to be taken -by the system when a signal occurs. -Normally, signal handlers execute on the current stack -of the process. This may be changed, on a per-handler basis, -so that signals are taken on a special -.Em "signal stack" . -.Pp -All signals have the same -.Em priority . -Signal routines execute with the signal that caused their -invocation -.Em blocked , -but other signals may yet occur. -A global -.Em "signal mask" -defines the set of signals currently blocked from delivery -to a process. The signal mask for a process is initialized -from that of its parent (normally 0). It -may be changed with a -.Xr sigblock 2 -or -.Xr sigsetmask 2 -call, or when a signal is delivered to the process. -.Pp -When a signal -condition arises for a process, the signal is added to a set of -signals pending for the process. If the signal is not currently -.Em blocked -by the process then it is delivered to the process. When a signal -is delivered, the current state of the process is saved, -a new signal mask is calculated (as described below), -and the signal handler is invoked. The call to the handler -is arranged so that if the signal handling routine returns -normally the process will resume execution in the context -from before the signal's delivery. -If the process wishes to resume in a different context, then it -must arrange to restore the previous context itself. -.Pp -When a signal is delivered to a process a new signal mask is -installed for the duration of the process' signal handler -(or until a -.Xr sigblock 2 -or -.Xr sigsetmask 2 -call is made). -This mask is formed by taking the current signal mask, -adding the signal to be delivered, and -.Em or Ns 'ing -in the signal mask associated with the handler to be invoked. -.Pp -.Fn Sigvec -assigns a handler for a specific signal. If -.Fa vec -is non-zero, it -specifies a handler routine and mask -to be used when delivering the specified signal. -Further, if the -.Dv SV_ONSTACK -bit is set in -.Fa sv_flags , -the system will deliver the signal to the process on a -.Em "signal stack" , -specified with -.Xr sigaltstack 2 . -If -.Fa ovec -is non-zero, the previous handling information for the signal -is returned to the user. -.Pp -The following is a list of all signals -with names as in the include file -.Aq Pa signal.h : -.Bl -column SIGVTALARMXX "create core imagexxx" -.It Sy " NAME " " Default Action " " Description" -.It Dv SIGHUP No " terminate process" " terminal line hangup" -.It Dv SIGINT No " terminate process" " interrupt program" -.It Dv SIGQUIT No " create core image" " quit program" -.It Dv SIGILL No " create core image" " illegal instruction" -.It Dv SIGTRAP No " create core image" " trace trap" -.It Dv SIGABRT No " create core image" Xr abort 3 -call (formerly -.Dv SIGIOT ) -.It Dv SIGEMT No " create core image" " emulate instruction executed" -.It Dv SIGFPE No " create core image" " floating-point exception" -.It Dv SIGKILL No " terminate process" " kill program" -.It Dv SIGBUS No " create core image" " bus error" -.It Dv SIGSEGV No " create core image" " segmentation violation" -.It Dv SIGSYS No " create core image" " non-existent system call invoked" -.It Dv SIGPIPE No " terminate process" " write on a pipe with no reader" -.It Dv SIGALRM No " terminate process" " real-time timer expired" -.It Dv SIGTERM No " terminate process" " software termination signal" -.It Dv SIGURG No " discard signal" " urgent condition present on socket" -.It Dv SIGSTOP No " stop process" " stop (cannot be caught or ignored)" -.It Dv SIGTSTP No " stop process" " stop signal generated from keyboard" -.It Dv SIGCONT No " discard signal" " continue after stop" -.It Dv SIGCHLD No " discard signal" " child status has changed" -.It Dv SIGTTIN No " stop process" " background read attempted from control terminal" -.It Dv SIGTTOU No " stop process" " background write attempted to control terminal" -.It Dv SIGIO No " discard signal" Tn " I/O" -is possible on a descriptor (see -.Xr fcntl 2 ) -.It Dv SIGXCPU No " terminate process" " cpu time limit exceeded (see" -.Xr setrlimit 2 ) -.It Dv SIGXFSZ No " terminate process" " file size limit exceeded (see" -.Xr setrlimit 2 ) -.It Dv SIGVTALRM No " terminate process" " virtual time alarm (see" -.Xr setitimer 2 ) -.It Dv SIGPROF No " terminate process" " profiling timer alarm (see" -.Xr setitimer 2 ) -.It Dv SIGWINCH No " discard signal" " Window size change" -.It Dv SIGINFO No " discard signal" " status request from keyboard" -.It Dv SIGUSR1 No " terminate process" " User defined signal 1" -.It Dv SIGUSR2 No " terminate process" " User defined signal 2" -.El -.Pp -Once a signal handler is installed, it remains installed -until another -.Fn sigvec -call is made, or an -.Xr execve 2 -is performed. -A signal-specific default action may be reset by -setting -.Fa sv_handler -to -.Dv SIG_DFL . -The defaults are process termination, possibly with core dump; -no action; stopping the process; or continuing the process. -See the above signal list for each signal's default action. -If -.Fa sv_handler -is -.Dv SIG_IGN -current and pending instances -of the signal are ignored and discarded. -.Pp -If a signal is caught during the system calls listed below, -the call is normally restarted. -The call can be forced to terminate prematurely with an -.Dv EINTR -error return by setting the -.Dv SV_INTERRUPT -bit in -.Fa sv_flags . -The affected system calls include -.Xr read 2 , -.Xr write 2 , -.Xr sendto 2 , -.Xr recvfrom 2 , -.Xr sendmsg 2 -and -.Xr recvmsg 2 -on a communications channel or a slow device (such as a terminal, -but not a regular file) -and during a -.Xr wait 2 -or -.Xr ioctl 2 . -However, calls that have already committed are not restarted, -but instead return a partial success (for example, a short read count). -.Pp -After a -.Xr fork 2 -or -.Xr vfork 2 -all signals, the signal mask, the signal stack, -and the restart/interrupt flags are inherited by the child. -.Pp -.Xr Execve 2 -reinstates the default -action for all signals which were caught and -resets all signals to be caught on the user stack. -Ignored signals remain ignored; -the signal mask remains the same; -signals that interrupt system calls continue to do so. -.Sh NOTES -The mask specified in -.Fa vec -is not allowed to block -.Dv SIGKILL -or -.Dv SIGSTOP . -This is done silently by the system. -.Pp -The -.Dv SV_INTERRUPT -flag is not available in -.Bx 4.2 , -hence it should not be used if backward compatibility is needed. -.Sh RETURN VALUES -A 0 value indicated that the call succeeded. A \-1 return value -indicates an error occurred and -.Va errno -is set to indicated the reason. -.Sh ERRORS -.Fn Sigvec -will fail and no new signal handler will be installed if one -of the following occurs: -.Bl -tag -width [EINVAL] -.It Bq Er EFAULT -Either -.Fa vec -or -.Fa ovec -points to memory that is not a valid part of the process -address space. -.It Bq Er EINVAL -.Fa Sig -is not a valid signal number. -.It Bq Er EINVAL -An attempt is made to ignore or supply a handler for -.Dv SIGKILL -or -.Dv SIGSTOP . -.El -.Sh SEE ALSO -.Xr kill 1 , -.Xr kill 2 , -.Xr ptrace 2 , -.Xr sigaction 2 , -.Xr sigaltstack 2 , -.Xr sigblock 2 , -.Xr sigpause 2 , -.Xr sigprocmask 2 , -.Xr sigsetmask 2 , -.Xr sigsuspend 2 , -.Xr setjmp 3 , -.Xr siginterrupt 3 , -.Xr signal 3 , -.Xr sigsetops 3 , -.Xr tty 4 -.Sh EXAMPLE -On the -.Tn VAX\-11 -The handler routine can be declared: -.Bd -literal -offset indent -void handler(sig, code, scp) -int sig, code; -struct sigcontext *scp; -.Ed -.Pp -Here -.Fa sig -is the signal number, into which the hardware faults and traps are -mapped as defined below. -.Fa Code -is a parameter that is either a constant -as given below or, for compatibility mode faults, the code provided by -the hardware (Compatibility mode faults are distinguished from the -other -.Dv SIGILL -traps by having -.Dv PSL_CM -set in the psl). -.Fa Scp -is a pointer to the -.Fa sigcontext -structure (defined in -.Aq Pa signal.h ) , -used to restore the context from before the signal. -.Sh BUGS -This manual page is still confusing. diff --git a/lib/libc/db/Makefile.inc b/lib/libc/db/Makefile.inc deleted file mode 100644 index 8bd4dd6..0000000 --- a/lib/libc/db/Makefile.inc +++ /dev/null @@ -1,11 +0,0 @@ -# from @(#)Makefile.inc 8.2 (Berkeley) 2/21/94 -# $FreeBSD$ -# -CFLAGS+=-D__DBINTERFACE_PRIVATE - -.include "${.CURDIR}/../libc/db/btree/Makefile.inc" -.include "${.CURDIR}/../libc/db/db/Makefile.inc" -.include "${.CURDIR}/../libc/db/hash/Makefile.inc" -.include "${.CURDIR}/../libc/db/man/Makefile.inc" -.include "${.CURDIR}/../libc/db/mpool/Makefile.inc" -.include "${.CURDIR}/../libc/db/recno/Makefile.inc" diff --git a/lib/libc/db/README b/lib/libc/db/README deleted file mode 100644 index bed2c92..0000000 --- a/lib/libc/db/README +++ /dev/null @@ -1,40 +0,0 @@ -# @(#)README 8.27 (Berkeley) 9/1/94 - -This is version 1.85 of the Berkeley DB code. - -For information on compiling and installing this software, see the file -PORT/README. - -Newer versions of this software will periodically be made available by -anonymous ftp from ftp.cs.berkeley.edu. An archive in compressed format -is in ucb/4bsd/db.tar.Z, or in gzip format in ucb/4bsd/db.tar.gz. If -you'd like to receive announcements of future releases of this software, -send email to the contact address below. - -Email questions may be addressed to Keith Bostic at bostic@cs.berkeley.edu. - -============================================ -Distribution contents: - -Makefile.inc Ignore this, it's the 4.4BSD subsystem Makefile. -PORT The per OS/architecture directories to use to build - libdb.a, if you're not running 4.4BSD. See the file - PORT/README for more information. -README This file. -btree The B+tree routines. -changelog List of changes, per version. -db The dbopen(3) interface routine. -docs Various USENIX papers, and the formatted manual pages. -hash The extended linear hashing routines. -man The unformatted manual pages. -mpool The memory pool routines. -recno The fixed/variable length record routines. -test Test package. - -============================================ -Debugging: - -If you're running a memory checker (e.g. Purify) on DB, make sure that -you recompile it with "-DPURIFY" in the CFLAGS, first. By default, -allocated pages are not initialized by the DB code, and they will show -up as reads of uninitialized memory in the buffer write routines. diff --git a/lib/libc/db/btree/Makefile.inc b/lib/libc/db/btree/Makefile.inc deleted file mode 100644 index 33c630f..0000000 --- a/lib/libc/db/btree/Makefile.inc +++ /dev/null @@ -1,8 +0,0 @@ -# from @(#)Makefile.inc 8.2 (Berkeley) 7/14/94 -# $FreeBSD$ - -.PATH: ${.CURDIR}/../libc/db/btree - -SRCS+= bt_close.c bt_conv.c bt_debug.c bt_delete.c bt_get.c bt_open.c \ - bt_overflow.c bt_page.c bt_put.c bt_search.c bt_seq.c bt_split.c \ - bt_utils.c diff --git a/lib/libc/db/btree/bt_close.c b/lib/libc/db/btree/bt_close.c deleted file mode 100644 index c5e0d52..0000000 --- a/lib/libc/db/btree/bt_close.c +++ /dev/null @@ -1,184 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_close.c 8.7 (Berkeley) 8/17/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include -#include - -#include -#include "btree.h" - -static int bt_meta __P((BTREE *)); - -/* - * BT_CLOSE -- Close a btree. - * - * Parameters: - * dbp: pointer to access method - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__bt_close(dbp) - DB *dbp; -{ - BTREE *t; - int fd; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* Sync the tree. */ - if (__bt_sync(dbp, 0) == RET_ERROR) - return (RET_ERROR); - - /* Close the memory pool. */ - if (mpool_close(t->bt_mp) == RET_ERROR) - return (RET_ERROR); - - /* Free random memory. */ - if (t->bt_cursor.key.data != NULL) { - free(t->bt_cursor.key.data); - t->bt_cursor.key.size = 0; - t->bt_cursor.key.data = NULL; - } - if (t->bt_rkey.data) { - free(t->bt_rkey.data); - t->bt_rkey.size = 0; - t->bt_rkey.data = NULL; - } - if (t->bt_rdata.data) { - free(t->bt_rdata.data); - t->bt_rdata.size = 0; - t->bt_rdata.data = NULL; - } - - fd = t->bt_fd; - free(t); - free(dbp); - return (_close(fd) ? RET_ERROR : RET_SUCCESS); -} - -/* - * BT_SYNC -- sync the btree to disk. - * - * Parameters: - * dbp: pointer to access method - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -int -__bt_sync(dbp, flags) - const DB *dbp; - u_int flags; -{ - BTREE *t; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* Sync doesn't currently take any flags. */ - if (flags != 0) { - errno = EINVAL; - return (RET_ERROR); - } - - if (F_ISSET(t, B_INMEM | B_RDONLY) || !F_ISSET(t, B_MODIFIED)) - return (RET_SUCCESS); - - if (F_ISSET(t, B_METADIRTY) && bt_meta(t) == RET_ERROR) - return (RET_ERROR); - - if ((status = mpool_sync(t->bt_mp)) == RET_SUCCESS) - F_CLR(t, B_MODIFIED); - - return (status); -} - -/* - * BT_META -- write the tree meta data to disk. - * - * Parameters: - * t: tree - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -static int -bt_meta(t) - BTREE *t; -{ - BTMETA m; - void *p; - - if ((p = mpool_get(t->bt_mp, P_META, 0)) == NULL) - return (RET_ERROR); - - /* Fill in metadata. */ - m.magic = BTREEMAGIC; - m.version = BTREEVERSION; - m.psize = t->bt_psize; - m.free = t->bt_free; - m.nrecs = t->bt_nrecs; - m.flags = F_ISSET(t, SAVEMETA); - - memmove(p, &m, sizeof(BTMETA)); - mpool_put(t->bt_mp, p, MPOOL_DIRTY); - return (RET_SUCCESS); -} diff --git a/lib/libc/db/btree/bt_conv.c b/lib/libc/db/btree/bt_conv.c deleted file mode 100644 index 1cb208b1..0000000 --- a/lib/libc/db/btree/bt_conv.c +++ /dev/null @@ -1,221 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)bt_conv.c 8.5 (Berkeley) 8/17/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include - -#include -#include "btree.h" - -static void mswap __P((PAGE *)); - -/* - * __BT_BPGIN, __BT_BPGOUT -- - * Convert host-specific number layout to/from the host-independent - * format stored on disk. - * - * Parameters: - * t: tree - * pg: page number - * h: page to convert - */ -void -__bt_pgin(t, pg, pp) - void *t; - pgno_t pg; - void *pp; -{ - PAGE *h; - indx_t i, top; - u_char flags; - char *p; - - if (!F_ISSET(((BTREE *)t), B_NEEDSWAP)) - return; - if (pg == P_META) { - mswap(pp); - return; - } - - h = pp; - M_32_SWAP(h->pgno); - M_32_SWAP(h->prevpg); - M_32_SWAP(h->nextpg); - M_32_SWAP(h->flags); - M_16_SWAP(h->lower); - M_16_SWAP(h->upper); - - top = NEXTINDEX(h); - if ((h->flags & P_TYPE) == P_BINTERNAL) - for (i = 0; i < top; i++) { - M_16_SWAP(h->linp[i]); - p = (char *)GETBINTERNAL(h, i); - P_32_SWAP(p); - p += sizeof(u_int32_t); - P_32_SWAP(p); - p += sizeof(pgno_t); - if (*(u_char *)p & P_BIGKEY) { - p += sizeof(u_char); - P_32_SWAP(p); - p += sizeof(pgno_t); - P_32_SWAP(p); - } - } - else if ((h->flags & P_TYPE) == P_BLEAF) - for (i = 0; i < top; i++) { - M_16_SWAP(h->linp[i]); - p = (char *)GETBLEAF(h, i); - P_32_SWAP(p); - p += sizeof(u_int32_t); - P_32_SWAP(p); - p += sizeof(u_int32_t); - flags = *(u_char *)p; - if (flags & (P_BIGKEY | P_BIGDATA)) { - p += sizeof(u_char); - if (flags & P_BIGKEY) { - P_32_SWAP(p); - p += sizeof(pgno_t); - P_32_SWAP(p); - } - if (flags & P_BIGDATA) { - p += sizeof(u_int32_t); - P_32_SWAP(p); - p += sizeof(pgno_t); - P_32_SWAP(p); - } - } - } -} - -void -__bt_pgout(t, pg, pp) - void *t; - pgno_t pg; - void *pp; -{ - PAGE *h; - indx_t i, top; - u_char flags; - char *p; - - if (!F_ISSET(((BTREE *)t), B_NEEDSWAP)) - return; - if (pg == P_META) { - mswap(pp); - return; - } - - h = pp; - top = NEXTINDEX(h); - if ((h->flags & P_TYPE) == P_BINTERNAL) - for (i = 0; i < top; i++) { - p = (char *)GETBINTERNAL(h, i); - P_32_SWAP(p); - p += sizeof(u_int32_t); - P_32_SWAP(p); - p += sizeof(pgno_t); - if (*(u_char *)p & P_BIGKEY) { - p += sizeof(u_char); - P_32_SWAP(p); - p += sizeof(pgno_t); - P_32_SWAP(p); - } - M_16_SWAP(h->linp[i]); - } - else if ((h->flags & P_TYPE) == P_BLEAF) - for (i = 0; i < top; i++) { - p = (char *)GETBLEAF(h, i); - P_32_SWAP(p); - p += sizeof(u_int32_t); - P_32_SWAP(p); - p += sizeof(u_int32_t); - flags = *(u_char *)p; - if (flags & (P_BIGKEY | P_BIGDATA)) { - p += sizeof(u_char); - if (flags & P_BIGKEY) { - P_32_SWAP(p); - p += sizeof(pgno_t); - P_32_SWAP(p); - } - if (flags & P_BIGDATA) { - p += sizeof(u_int32_t); - P_32_SWAP(p); - p += sizeof(pgno_t); - P_32_SWAP(p); - } - } - M_16_SWAP(h->linp[i]); - } - - M_32_SWAP(h->pgno); - M_32_SWAP(h->prevpg); - M_32_SWAP(h->nextpg); - M_32_SWAP(h->flags); - M_16_SWAP(h->lower); - M_16_SWAP(h->upper); -} - -/* - * MSWAP -- Actually swap the bytes on the meta page. - * - * Parameters: - * p: page to convert - */ -static void -mswap(pg) - PAGE *pg; -{ - char *p; - - p = (char *)pg; - P_32_SWAP(p); /* magic */ - p += sizeof(u_int32_t); - P_32_SWAP(p); /* version */ - p += sizeof(u_int32_t); - P_32_SWAP(p); /* psize */ - p += sizeof(u_int32_t); - P_32_SWAP(p); /* free */ - p += sizeof(u_int32_t); - P_32_SWAP(p); /* nrecs */ - p += sizeof(u_int32_t); - P_32_SWAP(p); /* flags */ - p += sizeof(u_int32_t); -} diff --git a/lib/libc/db/btree/bt_debug.c b/lib/libc/db/btree/bt_debug.c deleted file mode 100644 index 3aefbe7..0000000 --- a/lib/libc/db/btree/bt_debug.c +++ /dev/null @@ -1,329 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)bt_debug.c 8.5 (Berkeley) 8/17/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "btree.h" - -#ifdef DEBUG -/* - * BT_DUMP -- Dump the tree - * - * Parameters: - * dbp: pointer to the DB - */ -void -__bt_dump(dbp) - DB *dbp; -{ - BTREE *t; - PAGE *h; - pgno_t i; - char *sep; - - t = dbp->internal; - (void)fprintf(stderr, "%s: pgsz %d", - F_ISSET(t, B_INMEM) ? "memory" : "disk", t->bt_psize); - if (F_ISSET(t, R_RECNO)) - (void)fprintf(stderr, " keys %lu", t->bt_nrecs); -#undef X -#define X(flag, name) \ - if (F_ISSET(t, flag)) { \ - (void)fprintf(stderr, "%s%s", sep, name); \ - sep = ", "; \ - } - if (t->flags != 0) { - sep = " flags ("; - X(R_FIXLEN, "FIXLEN"); - X(B_INMEM, "INMEM"); - X(B_NODUPS, "NODUPS"); - X(B_RDONLY, "RDONLY"); - X(R_RECNO, "RECNO"); - X(B_METADIRTY,"METADIRTY"); - (void)fprintf(stderr, ")\n"); - } -#undef X - - for (i = P_ROOT; (h = mpool_get(t->bt_mp, i, 0)) != NULL; ++i) { - __bt_dpage(h); - (void)mpool_put(t->bt_mp, h, 0); - } -} - -/* - * BT_DMPAGE -- Dump the meta page - * - * Parameters: - * h: pointer to the PAGE - */ -void -__bt_dmpage(h) - PAGE *h; -{ - BTMETA *m; - char *sep; - - m = (BTMETA *)h; - (void)fprintf(stderr, "magic %lx\n", m->magic); - (void)fprintf(stderr, "version %lu\n", m->version); - (void)fprintf(stderr, "psize %lu\n", m->psize); - (void)fprintf(stderr, "free %lu\n", m->free); - (void)fprintf(stderr, "nrecs %lu\n", m->nrecs); - (void)fprintf(stderr, "flags %lu", m->flags); -#undef X -#define X(flag, name) \ - if (m->flags & flag) { \ - (void)fprintf(stderr, "%s%s", sep, name); \ - sep = ", "; \ - } - if (m->flags) { - sep = " ("; - X(B_NODUPS, "NODUPS"); - X(R_RECNO, "RECNO"); - (void)fprintf(stderr, ")"); - } -} - -/* - * BT_DNPAGE -- Dump the page - * - * Parameters: - * n: page number to dump. - */ -void -__bt_dnpage(dbp, pgno) - DB *dbp; - pgno_t pgno; -{ - BTREE *t; - PAGE *h; - - t = dbp->internal; - if ((h = mpool_get(t->bt_mp, pgno, 0)) != NULL) { - __bt_dpage(h); - (void)mpool_put(t->bt_mp, h, 0); - } -} - -/* - * BT_DPAGE -- Dump the page - * - * Parameters: - * h: pointer to the PAGE - */ -void -__bt_dpage(h) - PAGE *h; -{ - BINTERNAL *bi; - BLEAF *bl; - RINTERNAL *ri; - RLEAF *rl; - indx_t cur, top; - char *sep; - - (void)fprintf(stderr, " page %d: (", h->pgno); -#undef X -#define X(flag, name) \ - if (h->flags & flag) { \ - (void)fprintf(stderr, "%s%s", sep, name); \ - sep = ", "; \ - } - sep = ""; - X(P_BINTERNAL, "BINTERNAL") /* types */ - X(P_BLEAF, "BLEAF") - X(P_RINTERNAL, "RINTERNAL") /* types */ - X(P_RLEAF, "RLEAF") - X(P_OVERFLOW, "OVERFLOW") - X(P_PRESERVE, "PRESERVE"); - (void)fprintf(stderr, ")\n"); -#undef X - - (void)fprintf(stderr, "\tprev %2d next %2d", h->prevpg, h->nextpg); - if (h->flags & P_OVERFLOW) - return; - - top = NEXTINDEX(h); - (void)fprintf(stderr, " lower %3d upper %3d nextind %d\n", - h->lower, h->upper, top); - for (cur = 0; cur < top; cur++) { - (void)fprintf(stderr, "\t[%03d] %4d ", cur, h->linp[cur]); - switch (h->flags & P_TYPE) { - case P_BINTERNAL: - bi = GETBINTERNAL(h, cur); - (void)fprintf(stderr, - "size %03d pgno %03d", bi->ksize, bi->pgno); - if (bi->flags & P_BIGKEY) - (void)fprintf(stderr, " (indirect)"); - else if (bi->ksize) - (void)fprintf(stderr, - " {%.*s}", (int)bi->ksize, bi->bytes); - break; - case P_RINTERNAL: - ri = GETRINTERNAL(h, cur); - (void)fprintf(stderr, "entries %03d pgno %03d", - ri->nrecs, ri->pgno); - break; - case P_BLEAF: - bl = GETBLEAF(h, cur); - if (bl->flags & P_BIGKEY) - (void)fprintf(stderr, - "big key page %lu size %u/", - *(pgno_t *)bl->bytes, - *(u_int32_t *)(bl->bytes + sizeof(pgno_t))); - else if (bl->ksize) - (void)fprintf(stderr, "%s/", bl->bytes); - if (bl->flags & P_BIGDATA) - (void)fprintf(stderr, - "big data page %lu size %u", - *(pgno_t *)(bl->bytes + bl->ksize), - *(u_int32_t *)(bl->bytes + bl->ksize + - sizeof(pgno_t))); - else if (bl->dsize) - (void)fprintf(stderr, "%.*s", - (int)bl->dsize, bl->bytes + bl->ksize); - break; - case P_RLEAF: - rl = GETRLEAF(h, cur); - if (rl->flags & P_BIGDATA) - (void)fprintf(stderr, - "big data page %lu size %u", - *(pgno_t *)rl->bytes, - *(u_int32_t *)(rl->bytes + sizeof(pgno_t))); - else if (rl->dsize) - (void)fprintf(stderr, - "%.*s", (int)rl->dsize, rl->bytes); - break; - } - (void)fprintf(stderr, "\n"); - } -} -#endif - -#ifdef STATISTICS -/* - * BT_STAT -- Gather/print the tree statistics - * - * Parameters: - * dbp: pointer to the DB - */ -void -__bt_stat(dbp) - DB *dbp; -{ - extern u_long bt_cache_hit, bt_cache_miss, bt_pfxsaved, bt_rootsplit; - extern u_long bt_sortsplit, bt_split; - BTREE *t; - PAGE *h; - pgno_t i, pcont, pinternal, pleaf; - u_long ifree, lfree, nkeys; - int levels; - - t = dbp->internal; - pcont = pinternal = pleaf = 0; - nkeys = ifree = lfree = 0; - for (i = P_ROOT; (h = mpool_get(t->bt_mp, i, 0)) != NULL; ++i) { - switch (h->flags & P_TYPE) { - case P_BINTERNAL: - case P_RINTERNAL: - ++pinternal; - ifree += h->upper - h->lower; - break; - case P_BLEAF: - case P_RLEAF: - ++pleaf; - lfree += h->upper - h->lower; - nkeys += NEXTINDEX(h); - break; - case P_OVERFLOW: - ++pcont; - break; - } - (void)mpool_put(t->bt_mp, h, 0); - } - - /* Count the levels of the tree. */ - for (i = P_ROOT, levels = 0 ;; ++levels) { - h = mpool_get(t->bt_mp, i, 0); - if (h->flags & (P_BLEAF|P_RLEAF)) { - if (levels == 0) - levels = 1; - (void)mpool_put(t->bt_mp, h, 0); - break; - } - i = F_ISSET(t, R_RECNO) ? - GETRINTERNAL(h, 0)->pgno : - GETBINTERNAL(h, 0)->pgno; - (void)mpool_put(t->bt_mp, h, 0); - } - - (void)fprintf(stderr, "%d level%s with %ld keys", - levels, levels == 1 ? "" : "s", nkeys); - if (F_ISSET(t, R_RECNO)) - (void)fprintf(stderr, " (%ld header count)", t->bt_nrecs); - (void)fprintf(stderr, - "\n%lu pages (leaf %ld, internal %ld, overflow %ld)\n", - pinternal + pleaf + pcont, pleaf, pinternal, pcont); - (void)fprintf(stderr, "%ld cache hits, %ld cache misses\n", - bt_cache_hit, bt_cache_miss); - (void)fprintf(stderr, "%ld splits (%ld root splits, %ld sort splits)\n", - bt_split, bt_rootsplit, bt_sortsplit); - pleaf *= t->bt_psize - BTDATAOFF; - if (pleaf) - (void)fprintf(stderr, - "%.0f%% leaf fill (%ld bytes used, %ld bytes free)\n", - ((double)(pleaf - lfree) / pleaf) * 100, - pleaf - lfree, lfree); - pinternal *= t->bt_psize - BTDATAOFF; - if (pinternal) - (void)fprintf(stderr, - "%.0f%% internal fill (%ld bytes used, %ld bytes free\n", - ((double)(pinternal - ifree) / pinternal) * 100, - pinternal - ifree, ifree); - if (bt_pfxsaved) - (void)fprintf(stderr, "prefix checking removed %lu bytes.\n", - bt_pfxsaved); -} -#endif diff --git a/lib/libc/db/btree/bt_delete.c b/lib/libc/db/btree/bt_delete.c deleted file mode 100644 index ece1ab6..0000000 --- a/lib/libc/db/btree/bt_delete.c +++ /dev/null @@ -1,657 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)bt_delete.c 8.13 (Berkeley) 7/28/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "btree.h" - -static int __bt_bdelete __P((BTREE *, const DBT *)); -static int __bt_curdel __P((BTREE *, const DBT *, PAGE *, u_int)); -static int __bt_pdelete __P((BTREE *, PAGE *)); -static int __bt_relink __P((BTREE *, PAGE *)); -static int __bt_stkacq __P((BTREE *, PAGE **, CURSOR *)); - -/* - * __bt_delete - * Delete the item(s) referenced by a key. - * - * Return RET_SPECIAL if the key is not found. - */ -int -__bt_delete(dbp, key, flags) - const DB *dbp; - const DBT *key; - u_int flags; -{ - BTREE *t; - CURSOR *c; - PAGE *h; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* Check for change to a read-only tree. */ - if (F_ISSET(t, B_RDONLY)) { - errno = EPERM; - return (RET_ERROR); - } - - switch (flags) { - case 0: - status = __bt_bdelete(t, key); - break; - case R_CURSOR: - /* - * If flags is R_CURSOR, delete the cursor. Must already - * have started a scan and not have already deleted it. - */ - c = &t->bt_cursor; - if (F_ISSET(c, CURS_INIT)) { - if (F_ISSET(c, CURS_ACQUIRE | CURS_AFTER | CURS_BEFORE)) - return (RET_SPECIAL); - if ((h = mpool_get(t->bt_mp, c->pg.pgno, 0)) == NULL) - return (RET_ERROR); - - /* - * If the page is about to be emptied, we'll need to - * delete it, which means we have to acquire a stack. - */ - if (NEXTINDEX(h) == 1) - if (__bt_stkacq(t, &h, &t->bt_cursor)) - return (RET_ERROR); - - status = __bt_dleaf(t, NULL, h, c->pg.index); - - if (NEXTINDEX(h) == 0 && status == RET_SUCCESS) { - if (__bt_pdelete(t, h)) - return (RET_ERROR); - } else - mpool_put(t->bt_mp, - h, status == RET_SUCCESS ? MPOOL_DIRTY : 0); - break; - } - /* FALLTHROUGH */ - default: - errno = EINVAL; - return (RET_ERROR); - } - if (status == RET_SUCCESS) - F_SET(t, B_MODIFIED); - return (status); -} - -/* - * __bt_stkacq -- - * Acquire a stack so we can delete a cursor entry. - * - * Parameters: - * t: tree - * hp: pointer to current, pinned PAGE pointer - * c: pointer to the cursor - * - * Returns: - * 0 on success, 1 on failure - */ -static int -__bt_stkacq(t, hp, c) - BTREE *t; - PAGE **hp; - CURSOR *c; -{ - BINTERNAL *bi; - EPG *e; - EPGNO *parent; - PAGE *h; - indx_t index; - pgno_t pgno; - recno_t nextpg, prevpg; - int exact, level; - - /* - * Find the first occurrence of the key in the tree. Toss the - * currently locked page so we don't hit an already-locked page. - */ - h = *hp; - mpool_put(t->bt_mp, h, 0); - if ((e = __bt_search(t, &c->key, &exact)) == NULL) - return (1); - h = e->page; - - /* See if we got it in one shot. */ - if (h->pgno == c->pg.pgno) - goto ret; - - /* - * Move right, looking for the page. At each move we have to move - * up the stack until we don't have to move to the next page. If - * we have to change pages at an internal level, we have to fix the - * stack back up. - */ - while (h->pgno != c->pg.pgno) { - if ((nextpg = h->nextpg) == P_INVALID) - break; - mpool_put(t->bt_mp, h, 0); - - /* Move up the stack. */ - for (level = 0; (parent = BT_POP(t)) != NULL; ++level) { - /* Get the parent page. */ - if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) - return (1); - - /* Move to the next index. */ - if (parent->index != NEXTINDEX(h) - 1) { - index = parent->index + 1; - BT_PUSH(t, h->pgno, index); - break; - } - mpool_put(t->bt_mp, h, 0); - } - - /* Restore the stack. */ - while (level--) { - /* Push the next level down onto the stack. */ - bi = GETBINTERNAL(h, index); - pgno = bi->pgno; - BT_PUSH(t, pgno, 0); - - /* Lose the currently pinned page. */ - mpool_put(t->bt_mp, h, 0); - - /* Get the next level down. */ - if ((h = mpool_get(t->bt_mp, pgno, 0)) == NULL) - return (1); - index = 0; - } - mpool_put(t->bt_mp, h, 0); - if ((h = mpool_get(t->bt_mp, nextpg, 0)) == NULL) - return (1); - } - - if (h->pgno == c->pg.pgno) - goto ret; - - /* Reacquire the original stack. */ - mpool_put(t->bt_mp, h, 0); - if ((e = __bt_search(t, &c->key, &exact)) == NULL) - return (1); - h = e->page; - - /* - * Move left, looking for the page. At each move we have to move - * up the stack until we don't have to change pages to move to the - * next page. If we have to change pages at an internal level, we - * have to fix the stack back up. - */ - while (h->pgno != c->pg.pgno) { - if ((prevpg = h->prevpg) == P_INVALID) - break; - mpool_put(t->bt_mp, h, 0); - - /* Move up the stack. */ - for (level = 0; (parent = BT_POP(t)) != NULL; ++level) { - /* Get the parent page. */ - if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) - return (1); - - /* Move to the next index. */ - if (parent->index != 0) { - index = parent->index - 1; - BT_PUSH(t, h->pgno, index); - break; - } - mpool_put(t->bt_mp, h, 0); - } - - /* Restore the stack. */ - while (level--) { - /* Push the next level down onto the stack. */ - bi = GETBINTERNAL(h, index); - pgno = bi->pgno; - - /* Lose the currently pinned page. */ - mpool_put(t->bt_mp, h, 0); - - /* Get the next level down. */ - if ((h = mpool_get(t->bt_mp, pgno, 0)) == NULL) - return (1); - - index = NEXTINDEX(h) - 1; - BT_PUSH(t, pgno, index); - } - mpool_put(t->bt_mp, h, 0); - if ((h = mpool_get(t->bt_mp, prevpg, 0)) == NULL) - return (1); - } - - -ret: mpool_put(t->bt_mp, h, 0); - return ((*hp = mpool_get(t->bt_mp, c->pg.pgno, 0)) == NULL); -} - -/* - * __bt_bdelete -- - * Delete all key/data pairs matching the specified key. - * - * Parameters: - * t: tree - * key: key to delete - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. - */ -static int -__bt_bdelete(t, key) - BTREE *t; - const DBT *key; -{ - EPG *e; - PAGE *h; - int deleted, exact, redo; - - deleted = 0; - - /* Find any matching record; __bt_search pins the page. */ -loop: if ((e = __bt_search(t, key, &exact)) == NULL) - return (deleted ? RET_SUCCESS : RET_ERROR); - if (!exact) { - mpool_put(t->bt_mp, e->page, 0); - return (deleted ? RET_SUCCESS : RET_SPECIAL); - } - - /* - * Delete forward, then delete backward, from the found key. If - * there are duplicates and we reach either side of the page, do - * the key search again, so that we get them all. - */ - redo = 0; - h = e->page; - do { - if (__bt_dleaf(t, key, h, e->index)) { - mpool_put(t->bt_mp, h, 0); - return (RET_ERROR); - } - if (F_ISSET(t, B_NODUPS)) { - if (NEXTINDEX(h) == 0) { - if (__bt_pdelete(t, h)) - return (RET_ERROR); - } else - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - return (RET_SUCCESS); - } - deleted = 1; - } while (e->index < NEXTINDEX(h) && __bt_cmp(t, key, e) == 0); - - /* Check for right-hand edge of the page. */ - if (e->index == NEXTINDEX(h)) - redo = 1; - - /* Delete from the key to the beginning of the page. */ - while (e->index-- > 0) { - if (__bt_cmp(t, key, e) != 0) - break; - if (__bt_dleaf(t, key, h, e->index) == RET_ERROR) { - mpool_put(t->bt_mp, h, 0); - return (RET_ERROR); - } - if (e->index == 0) - redo = 1; - } - - /* Check for an empty page. */ - if (NEXTINDEX(h) == 0) { - if (__bt_pdelete(t, h)) - return (RET_ERROR); - goto loop; - } - - /* Put the page. */ - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - - if (redo) - goto loop; - return (RET_SUCCESS); -} - -/* - * __bt_pdelete -- - * Delete a single page from the tree. - * - * Parameters: - * t: tree - * h: leaf page - * - * Returns: - * RET_SUCCESS, RET_ERROR. - * - * Side-effects: - * mpool_put's the page - */ -static int -__bt_pdelete(t, h) - BTREE *t; - PAGE *h; -{ - BINTERNAL *bi; - PAGE *pg; - EPGNO *parent; - indx_t cnt, index, *ip, offset; - u_int32_t nksize; - char *from; - - /* - * Walk the parent page stack -- a LIFO stack of the pages that were - * traversed when we searched for the page where the delete occurred. - * Each stack entry is a page number and a page index offset. The - * offset is for the page traversed on the search. We've just deleted - * a page, so we have to delete the key from the parent page. - * - * If the delete from the parent page makes it empty, this process may - * continue all the way up the tree. We stop if we reach the root page - * (which is never deleted, it's just not worth the effort) or if the - * delete does not empty the page. - */ - while ((parent = BT_POP(t)) != NULL) { - /* Get the parent page. */ - if ((pg = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) - return (RET_ERROR); - - index = parent->index; - bi = GETBINTERNAL(pg, index); - - /* Free any overflow pages. */ - if (bi->flags & P_BIGKEY && - __ovfl_delete(t, bi->bytes) == RET_ERROR) { - mpool_put(t->bt_mp, pg, 0); - return (RET_ERROR); - } - - /* - * Free the parent if it has only the one key and it's not the - * root page. If it's the rootpage, turn it back into an empty - * leaf page. - */ - if (NEXTINDEX(pg) == 1) - if (pg->pgno == P_ROOT) { - pg->lower = BTDATAOFF; - pg->upper = t->bt_psize; - pg->flags = P_BLEAF; - } else { - if (__bt_relink(t, pg) || __bt_free(t, pg)) - return (RET_ERROR); - continue; - } - else { - /* Pack remaining key items at the end of the page. */ - nksize = NBINTERNAL(bi->ksize); - from = (char *)pg + pg->upper; - memmove(from + nksize, from, (char *)bi - from); - pg->upper += nksize; - - /* Adjust indices' offsets, shift the indices down. */ - offset = pg->linp[index]; - for (cnt = index, ip = &pg->linp[0]; cnt--; ++ip) - if (ip[0] < offset) - ip[0] += nksize; - for (cnt = NEXTINDEX(pg) - index; --cnt; ++ip) - ip[0] = ip[1] < offset ? ip[1] + nksize : ip[1]; - pg->lower -= sizeof(indx_t); - } - - mpool_put(t->bt_mp, pg, MPOOL_DIRTY); - break; - } - - /* Free the leaf page, as long as it wasn't the root. */ - if (h->pgno == P_ROOT) { - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - return (RET_SUCCESS); - } - return (__bt_relink(t, h) || __bt_free(t, h)); -} - -/* - * __bt_dleaf -- - * Delete a single record from a leaf page. - * - * Parameters: - * t: tree - * key: referenced key - * h: page - * index: index on page to delete - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -int -__bt_dleaf(t, key, h, index) - BTREE *t; - const DBT *key; - PAGE *h; - u_int index; -{ - BLEAF *bl; - indx_t cnt, *ip, offset; - u_int32_t nbytes; - void *to; - char *from; - - /* If this record is referenced by the cursor, delete the cursor. */ - if (F_ISSET(&t->bt_cursor, CURS_INIT) && - !F_ISSET(&t->bt_cursor, CURS_ACQUIRE) && - t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index == index && - __bt_curdel(t, key, h, index)) - return (RET_ERROR); - - /* If the entry uses overflow pages, make them available for reuse. */ - to = bl = GETBLEAF(h, index); - if (bl->flags & P_BIGKEY && __ovfl_delete(t, bl->bytes) == RET_ERROR) - return (RET_ERROR); - if (bl->flags & P_BIGDATA && - __ovfl_delete(t, bl->bytes + bl->ksize) == RET_ERROR) - return (RET_ERROR); - - /* Pack the remaining key/data items at the end of the page. */ - nbytes = NBLEAF(bl); - from = (char *)h + h->upper; - memmove(from + nbytes, from, (char *)to - from); - h->upper += nbytes; - - /* Adjust the indices' offsets, shift the indices down. */ - offset = h->linp[index]; - for (cnt = index, ip = &h->linp[0]; cnt--; ++ip) - if (ip[0] < offset) - ip[0] += nbytes; - for (cnt = NEXTINDEX(h) - index; --cnt; ++ip) - ip[0] = ip[1] < offset ? ip[1] + nbytes : ip[1]; - h->lower -= sizeof(indx_t); - - /* If the cursor is on this page, adjust it as necessary. */ - if (F_ISSET(&t->bt_cursor, CURS_INIT) && - !F_ISSET(&t->bt_cursor, CURS_ACQUIRE) && - t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index > index) - --t->bt_cursor.pg.index; - - return (RET_SUCCESS); -} - -/* - * __bt_curdel -- - * Delete the cursor. - * - * Parameters: - * t: tree - * key: referenced key (or NULL) - * h: page - * index: index on page to delete - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -static int -__bt_curdel(t, key, h, index) - BTREE *t; - const DBT *key; - PAGE *h; - u_int index; -{ - CURSOR *c; - EPG e; - PAGE *pg; - int curcopy, status; - - /* - * If there are duplicates, move forward or backward to one. - * Otherwise, copy the key into the cursor area. - */ - c = &t->bt_cursor; - F_CLR(c, CURS_AFTER | CURS_BEFORE | CURS_ACQUIRE); - - curcopy = 0; - if (!F_ISSET(t, B_NODUPS)) { - /* - * We're going to have to do comparisons. If we weren't - * provided a copy of the key, i.e. the user is deleting - * the current cursor position, get one. - */ - if (key == NULL) { - e.page = h; - e.index = index; - if ((status = __bt_ret(t, &e, - &c->key, &c->key, NULL, NULL, 1)) != RET_SUCCESS) - return (status); - curcopy = 1; - key = &c->key; - } - /* Check previous key, if not at the beginning of the page. */ - if (index > 0) { - e.page = h; - e.index = index - 1; - if (__bt_cmp(t, key, &e) == 0) { - F_SET(c, CURS_BEFORE); - goto dup2; - } - } - /* Check next key, if not at the end of the page. */ - if (index < NEXTINDEX(h) - 1) { - e.page = h; - e.index = index + 1; - if (__bt_cmp(t, key, &e) == 0) { - F_SET(c, CURS_AFTER); - goto dup2; - } - } - /* Check previous key if at the beginning of the page. */ - if (index == 0 && h->prevpg != P_INVALID) { - if ((pg = mpool_get(t->bt_mp, h->prevpg, 0)) == NULL) - return (RET_ERROR); - e.page = pg; - e.index = NEXTINDEX(pg) - 1; - if (__bt_cmp(t, key, &e) == 0) { - F_SET(c, CURS_BEFORE); - goto dup1; - } - mpool_put(t->bt_mp, pg, 0); - } - /* Check next key if at the end of the page. */ - if (index == NEXTINDEX(h) - 1 && h->nextpg != P_INVALID) { - if ((pg = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL) - return (RET_ERROR); - e.page = pg; - e.index = 0; - if (__bt_cmp(t, key, &e) == 0) { - F_SET(c, CURS_AFTER); -dup1: mpool_put(t->bt_mp, pg, 0); -dup2: c->pg.pgno = e.page->pgno; - c->pg.index = e.index; - return (RET_SUCCESS); - } - mpool_put(t->bt_mp, pg, 0); - } - } - e.page = h; - e.index = index; - if (curcopy || (status = - __bt_ret(t, &e, &c->key, &c->key, NULL, NULL, 1)) == RET_SUCCESS) { - F_SET(c, CURS_ACQUIRE); - return (RET_SUCCESS); - } - return (status); -} - -/* - * __bt_relink -- - * Link around a deleted page. - * - * Parameters: - * t: tree - * h: page to be deleted - */ -static int -__bt_relink(t, h) - BTREE *t; - PAGE *h; -{ - PAGE *pg; - - if (h->nextpg != P_INVALID) { - if ((pg = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL) - return (RET_ERROR); - pg->prevpg = h->prevpg; - mpool_put(t->bt_mp, pg, MPOOL_DIRTY); - } - if (h->prevpg != P_INVALID) { - if ((pg = mpool_get(t->bt_mp, h->prevpg, 0)) == NULL) - return (RET_ERROR); - pg->nextpg = h->nextpg; - mpool_put(t->bt_mp, pg, MPOOL_DIRTY); - } - return (0); -} diff --git a/lib/libc/db/btree/bt_get.c b/lib/libc/db/btree/bt_get.c deleted file mode 100644 index 74824c7..0000000 --- a/lib/libc/db/btree/bt_get.c +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)bt_get.c 8.6 (Berkeley) 7/20/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "btree.h" - -/* - * __BT_GET -- Get a record from the btree. - * - * Parameters: - * dbp: pointer to access method - * key: key to find - * data: data to return - * flag: currently unused - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. - */ -int -__bt_get(dbp, key, data, flags) - const DB *dbp; - const DBT *key; - DBT *data; - u_int flags; -{ - BTREE *t; - EPG *e; - int exact, status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* Get currently doesn't take any flags. */ - if (flags) { - errno = EINVAL; - return (RET_ERROR); - } - - if ((e = __bt_search(t, key, &exact)) == NULL) - return (RET_ERROR); - if (!exact) { - mpool_put(t->bt_mp, e->page, 0); - return (RET_SPECIAL); - } - - status = __bt_ret(t, e, NULL, NULL, data, &t->bt_rdata, 0); - - /* - * If the user is doing concurrent access, we copied the - * key/data, toss the page. - */ - if (F_ISSET(t, B_DB_LOCK)) - mpool_put(t->bt_mp, e->page, 0); - else - t->bt_pinned = e->page; - return (status); -} diff --git a/lib/libc/db/btree/bt_open.c b/lib/libc/db/btree/bt_open.c deleted file mode 100644 index e838f25..0000000 --- a/lib/libc/db/btree/bt_open.c +++ /dev/null @@ -1,447 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_open.c 8.10 (Berkeley) 8/17/94"; -#endif /* LIBC_SCCS and not lint */ - -/* - * Implementation of btree access method for 4.4BSD. - * - * The design here was originally based on that of the btree access method - * used in the Postgres database system at UC Berkeley. This implementation - * is wholly independent of the Postgres code. - */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "btree.h" - -#ifdef DEBUG -#undef MINPSIZE -#define MINPSIZE 128 -#endif - -static int byteorder __P((void)); -static int nroot __P((BTREE *)); -static int tmp __P((void)); - -/* - * __BT_OPEN -- Open a btree. - * - * Creates and fills a DB struct, and calls the routine that actually - * opens the btree. - * - * Parameters: - * fname: filename (NULL for in-memory trees) - * flags: open flag bits - * mode: open permission bits - * b: BTREEINFO pointer - * - * Returns: - * NULL on failure, pointer to DB on success. - * - */ -DB * -__bt_open(fname, flags, mode, openinfo, dflags) - const char *fname; - int flags, mode, dflags; - const BTREEINFO *openinfo; -{ - struct stat sb; - BTMETA m; - BTREE *t; - BTREEINFO b; - DB *dbp; - pgno_t ncache; - ssize_t nr; - int machine_lorder; - - t = NULL; - - /* - * Intention is to make sure all of the user's selections are okay - * here and then use them without checking. Can't be complete, since - * we don't know the right page size, lorder or flags until the backing - * file is opened. Also, the file's page size can cause the cachesize - * to change. - */ - machine_lorder = byteorder(); - if (openinfo) { - b = *openinfo; - - /* Flags: R_DUP. */ - if (b.flags & ~(R_DUP)) - goto einval; - - /* - * Page size must be indx_t aligned and >= MINPSIZE. Default - * page size is set farther on, based on the underlying file - * transfer size. - */ - if (b.psize && - (b.psize < MINPSIZE || b.psize > MAX_PAGE_OFFSET + 1 || - b.psize & (sizeof(indx_t) - 1) )) - goto einval; - - /* Minimum number of keys per page; absolute minimum is 2. */ - if (b.minkeypage) { - if (b.minkeypage < 2) - goto einval; - } else - b.minkeypage = DEFMINKEYPAGE; - - /* If no comparison, use default comparison and prefix. */ - if (b.compare == NULL) { - b.compare = __bt_defcmp; - if (b.prefix == NULL) - b.prefix = __bt_defpfx; - } - - if (b.lorder == 0) - b.lorder = machine_lorder; - } else { - b.compare = __bt_defcmp; - b.cachesize = 0; - b.flags = 0; - b.lorder = machine_lorder; - b.minkeypage = DEFMINKEYPAGE; - b.prefix = __bt_defpfx; - b.psize = 0; - } - - /* Check for the ubiquitous PDP-11. */ - if (b.lorder != BIG_ENDIAN && b.lorder != LITTLE_ENDIAN) - goto einval; - - /* Allocate and initialize DB and BTREE structures. */ - if ((t = (BTREE *)malloc(sizeof(BTREE))) == NULL) - goto err; - memset(t, 0, sizeof(BTREE)); - t->bt_fd = -1; /* Don't close unopened fd on error. */ - t->bt_lorder = b.lorder; - t->bt_order = NOT; - t->bt_cmp = b.compare; - t->bt_pfx = b.prefix; - t->bt_rfd = -1; - - if ((t->bt_dbp = dbp = (DB *)malloc(sizeof(DB))) == NULL) - goto err; - memset(t->bt_dbp, 0, sizeof(DB)); - if (t->bt_lorder != machine_lorder) - F_SET(t, B_NEEDSWAP); - - dbp->type = DB_BTREE; - dbp->internal = t; - dbp->close = __bt_close; - dbp->del = __bt_delete; - dbp->fd = __bt_fd; - dbp->get = __bt_get; - dbp->put = __bt_put; - dbp->seq = __bt_seq; - dbp->sync = __bt_sync; - - /* - * If no file name was supplied, this is an in-memory btree and we - * open a backing temporary file. Otherwise, it's a disk-based tree. - */ - if (fname) { - switch (flags & O_ACCMODE) { - case O_RDONLY: - F_SET(t, B_RDONLY); - break; - case O_RDWR: - break; - case O_WRONLY: - default: - goto einval; - } - - if ((t->bt_fd = _open(fname, flags, mode)) < 0) - goto err; - - } else { - if ((flags & O_ACCMODE) != O_RDWR) - goto einval; - if ((t->bt_fd = tmp()) == -1) - goto err; - F_SET(t, B_INMEM); - } - - if (_fcntl(t->bt_fd, F_SETFD, 1) == -1) - goto err; - - if (fstat(t->bt_fd, &sb)) - goto err; - if (sb.st_size) { - if ((nr = _read(t->bt_fd, &m, sizeof(BTMETA))) < 0) - goto err; - if (nr != sizeof(BTMETA)) - goto eftype; - - /* - * Read in the meta-data. This can change the notion of what - * the lorder, page size and flags are, and, when the page size - * changes, the cachesize value can change too. If the user - * specified the wrong byte order for an existing database, we - * don't bother to return an error, we just clear the NEEDSWAP - * bit. - */ - if (m.magic == BTREEMAGIC) - F_CLR(t, B_NEEDSWAP); - else { - F_SET(t, B_NEEDSWAP); - M_32_SWAP(m.magic); - M_32_SWAP(m.version); - M_32_SWAP(m.psize); - M_32_SWAP(m.free); - M_32_SWAP(m.nrecs); - M_32_SWAP(m.flags); - } - if (m.magic != BTREEMAGIC || m.version != BTREEVERSION) - goto eftype; - if (m.psize < MINPSIZE || m.psize > MAX_PAGE_OFFSET + 1 || - m.psize & (sizeof(indx_t) - 1) ) - goto eftype; - if (m.flags & ~SAVEMETA) - goto eftype; - b.psize = m.psize; - F_SET(t, m.flags); - t->bt_free = m.free; - t->bt_nrecs = m.nrecs; - } else { - /* - * Set the page size to the best value for I/O to this file. - * Don't overflow the page offset type. - */ - if (b.psize == 0) { - b.psize = sb.st_blksize; - if (b.psize < MINPSIZE) - b.psize = MINPSIZE; - if (b.psize > MAX_PAGE_OFFSET + 1) - b.psize = MAX_PAGE_OFFSET + 1; - } - - /* Set flag if duplicates permitted. */ - if (!(b.flags & R_DUP)) - F_SET(t, B_NODUPS); - - t->bt_free = P_INVALID; - t->bt_nrecs = 0; - F_SET(t, B_METADIRTY); - } - - t->bt_psize = b.psize; - - /* Set the cache size; must be a multiple of the page size. */ - if (b.cachesize && b.cachesize & (b.psize - 1) ) - b.cachesize += (~b.cachesize & (b.psize - 1) ) + 1; - if (b.cachesize < b.psize * MINCACHE) - b.cachesize = b.psize * MINCACHE; - - /* Calculate number of pages to cache. */ - ncache = (b.cachesize + t->bt_psize - 1) / t->bt_psize; - - /* - * The btree data structure requires that at least two keys can fit on - * a page, but other than that there's no fixed requirement. The user - * specified a minimum number per page, and we translated that into the - * number of bytes a key/data pair can use before being placed on an - * overflow page. This calculation includes the page header, the size - * of the index referencing the leaf item and the size of the leaf item - * structure. Also, don't let the user specify a minkeypage such that - * a key/data pair won't fit even if both key and data are on overflow - * pages. - */ - t->bt_ovflsize = (t->bt_psize - BTDATAOFF) / b.minkeypage - - (sizeof(indx_t) + NBLEAFDBT(0, 0)); - if (t->bt_ovflsize < NBLEAFDBT(NOVFLSIZE, NOVFLSIZE) + sizeof(indx_t)) - t->bt_ovflsize = - NBLEAFDBT(NOVFLSIZE, NOVFLSIZE) + sizeof(indx_t); - - /* Initialize the buffer pool. */ - if ((t->bt_mp = - mpool_open(NULL, t->bt_fd, t->bt_psize, ncache)) == NULL) - goto err; - if (!F_ISSET(t, B_INMEM)) - mpool_filter(t->bt_mp, __bt_pgin, __bt_pgout, t); - - /* Create a root page if new tree. */ - if (nroot(t) == RET_ERROR) - goto err; - - /* Global flags. */ - if (dflags & DB_LOCK) - F_SET(t, B_DB_LOCK); - if (dflags & DB_SHMEM) - F_SET(t, B_DB_SHMEM); - if (dflags & DB_TXN) - F_SET(t, B_DB_TXN); - - return (dbp); - -einval: errno = EINVAL; - goto err; - -eftype: errno = EFTYPE; - goto err; - -err: if (t) { - if (t->bt_dbp) - free(t->bt_dbp); - if (t->bt_fd != -1) - (void)_close(t->bt_fd); - free(t); - } - return (NULL); -} - -/* - * NROOT -- Create the root of a new tree. - * - * Parameters: - * t: tree - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -static int -nroot(t) - BTREE *t; -{ - PAGE *meta, *root; - pgno_t npg; - - if ((meta = mpool_get(t->bt_mp, 0, 0)) != NULL) { - mpool_put(t->bt_mp, meta, 0); - return (RET_SUCCESS); - } - if (errno != EINVAL) /* It's OK to not exist. */ - return (RET_ERROR); - errno = 0; - - if ((meta = mpool_new(t->bt_mp, &npg)) == NULL) - return (RET_ERROR); - - if ((root = mpool_new(t->bt_mp, &npg)) == NULL) - return (RET_ERROR); - - if (npg != P_ROOT) - return (RET_ERROR); - root->pgno = npg; - root->prevpg = root->nextpg = P_INVALID; - root->lower = BTDATAOFF; - root->upper = t->bt_psize; - root->flags = P_BLEAF; - memset(meta, 0, t->bt_psize); - mpool_put(t->bt_mp, meta, MPOOL_DIRTY); - mpool_put(t->bt_mp, root, MPOOL_DIRTY); - return (RET_SUCCESS); -} - -static int -tmp() -{ - sigset_t set, oset; - int fd; - char *envtmp = NULL; - char path[MAXPATHLEN]; - - if (issetugid() == 0) - envtmp = getenv("TMPDIR"); - (void)snprintf(path, - sizeof(path), "%s/bt.XXXXXX", envtmp ? envtmp : "/tmp"); - - (void)sigfillset(&set); - (void)sigprocmask(SIG_BLOCK, &set, &oset); - if ((fd = mkstemp(path)) != -1) - (void)unlink(path); - (void)sigprocmask(SIG_SETMASK, &oset, NULL); - return(fd); -} - -static int -byteorder() -{ - u_int32_t x; - u_char *p; - - x = 0x01020304; - p = (u_char *)&x; - switch (*p) { - case 1: - return (BIG_ENDIAN); - case 4: - return (LITTLE_ENDIAN); - default: - return (0); - } -} - -int -__bt_fd(dbp) - const DB *dbp; -{ - BTREE *t; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* In-memory database can't have a file descriptor. */ - if (F_ISSET(t, B_INMEM)) { - errno = ENOENT; - return (-1); - } - return (t->bt_fd); -} diff --git a/lib/libc/db/btree/bt_overflow.c b/lib/libc/db/btree/bt_overflow.c deleted file mode 100644 index db28a22..0000000 --- a/lib/libc/db/btree/bt_overflow.c +++ /dev/null @@ -1,228 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)bt_overflow.c 8.5 (Berkeley) 7/16/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "btree.h" - -/* - * Big key/data code. - * - * Big key and data entries are stored on linked lists of pages. The initial - * reference is byte string stored with the key or data and is the page number - * and size. The actual record is stored in a chain of pages linked by the - * nextpg field of the PAGE header. - * - * The first page of the chain has a special property. If the record is used - * by an internal page, it cannot be deleted and the P_PRESERVE bit will be set - * in the header. - * - * XXX - * A single DBT is written to each chain, so a lot of space on the last page - * is wasted. This is a fairly major bug for some data sets. - */ - -/* - * __OVFL_GET -- Get an overflow key/data item. - * - * Parameters: - * t: tree - * p: pointer to { pgno_t, u_int32_t } - * buf: storage address - * bufsz: storage size - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__ovfl_get(t, p, ssz, buf, bufsz) - BTREE *t; - void *p; - size_t *ssz; - void **buf; - size_t *bufsz; -{ - PAGE *h; - pgno_t pg; - size_t nb, plen; - u_int32_t sz; - - memmove(&pg, p, sizeof(pgno_t)); - memmove(&sz, (char *)p + sizeof(pgno_t), sizeof(u_int32_t)); - *ssz = sz; - -#ifdef DEBUG - if (pg == P_INVALID || sz == 0) - abort(); -#endif - /* Make the buffer bigger as necessary. */ - if (*bufsz < sz) { - *buf = (char *)(*buf == NULL ? malloc(sz) : reallocf(*buf, sz)); - if (*buf == NULL) - return (RET_ERROR); - *bufsz = sz; - } - - /* - * Step through the linked list of pages, copying the data on each one - * into the buffer. Never copy more than the data's length. - */ - plen = t->bt_psize - BTDATAOFF; - for (p = *buf;; p = (char *)p + nb, pg = h->nextpg) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - - nb = MIN(sz, plen); - memmove(p, (char *)h + BTDATAOFF, nb); - mpool_put(t->bt_mp, h, 0); - - if ((sz -= nb) == 0) - break; - } - return (RET_SUCCESS); -} - -/* - * __OVFL_PUT -- Store an overflow key/data item. - * - * Parameters: - * t: tree - * data: DBT to store - * pgno: storage page number - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__ovfl_put(t, dbt, pg) - BTREE *t; - const DBT *dbt; - pgno_t *pg; -{ - PAGE *h, *last; - void *p; - pgno_t npg; - size_t nb, plen; - u_int32_t sz; - - /* - * Allocate pages and copy the key/data record into them. Store the - * number of the first page in the chain. - */ - plen = t->bt_psize - BTDATAOFF; - for (last = NULL, p = dbt->data, sz = dbt->size;; - p = (char *)p + plen, last = h) { - if ((h = __bt_new(t, &npg)) == NULL) - return (RET_ERROR); - - h->pgno = npg; - h->nextpg = h->prevpg = P_INVALID; - h->flags = P_OVERFLOW; - h->lower = h->upper = 0; - - nb = MIN(sz, plen); - memmove((char *)h + BTDATAOFF, p, nb); - - if (last) { - last->nextpg = h->pgno; - mpool_put(t->bt_mp, last, MPOOL_DIRTY); - } else - *pg = h->pgno; - - if ((sz -= nb) == 0) { - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - break; - } - } - return (RET_SUCCESS); -} - -/* - * __OVFL_DELETE -- Delete an overflow chain. - * - * Parameters: - * t: tree - * p: pointer to { pgno_t, u_int32_t } - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__ovfl_delete(t, p) - BTREE *t; - void *p; -{ - PAGE *h; - pgno_t pg; - size_t plen; - u_int32_t sz; - - memmove(&pg, p, sizeof(pgno_t)); - memmove(&sz, (char *)p + sizeof(pgno_t), sizeof(u_int32_t)); - -#ifdef DEBUG - if (pg == P_INVALID || sz == 0) - abort(); -#endif - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - - /* Don't delete chains used by internal pages. */ - if (h->flags & P_PRESERVE) { - mpool_put(t->bt_mp, h, 0); - return (RET_SUCCESS); - } - - /* Step through the chain, calling the free routine for each page. */ - for (plen = t->bt_psize - BTDATAOFF;; sz -= plen) { - pg = h->nextpg; - __bt_free(t, h); - if (sz <= plen) - break; - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - } - return (RET_SUCCESS); -} diff --git a/lib/libc/db/btree/bt_page.c b/lib/libc/db/btree/bt_page.c deleted file mode 100644 index ce9cbf1..0000000 --- a/lib/libc/db/btree/bt_page.c +++ /dev/null @@ -1,100 +0,0 @@ -/*- - * Copyright (c) 1990, 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_page.c 8.3 (Berkeley) 7/14/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include - -#include -#include "btree.h" - -/* - * __bt_free -- - * Put a page on the freelist. - * - * Parameters: - * t: tree - * h: page to free - * - * Returns: - * RET_ERROR, RET_SUCCESS - * - * Side-effect: - * mpool_put's the page. - */ -int -__bt_free(t, h) - BTREE *t; - PAGE *h; -{ - /* Insert the page at the head of the free list. */ - h->prevpg = P_INVALID; - h->nextpg = t->bt_free; - t->bt_free = h->pgno; - F_SET(t, B_METADIRTY); - - /* Make sure the page gets written back. */ - return (mpool_put(t->bt_mp, h, MPOOL_DIRTY)); -} - -/* - * __bt_new -- - * Get a new page, preferably from the freelist. - * - * Parameters: - * t: tree - * npg: storage for page number. - * - * Returns: - * Pointer to a page, NULL on error. - */ -PAGE * -__bt_new(t, npg) - BTREE *t; - pgno_t *npg; -{ - PAGE *h; - - if (t->bt_free != P_INVALID && - (h = mpool_get(t->bt_mp, t->bt_free, 0)) != NULL) { - *npg = t->bt_free; - t->bt_free = h->nextpg; - F_SET(t, B_METADIRTY); - return (h); - } - return (mpool_new(t->bt_mp, npg)); -} diff --git a/lib/libc/db/btree/bt_put.c b/lib/libc/db/btree/bt_put.c deleted file mode 100644 index 952be09..0000000 --- a/lib/libc/db/btree/bt_put.c +++ /dev/null @@ -1,320 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)bt_put.c 8.8 (Berkeley) 7/26/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include - -#include -#include "btree.h" - -static EPG *bt_fast __P((BTREE *, const DBT *, const DBT *, int *)); - -/* - * __BT_PUT -- Add a btree item to the tree. - * - * Parameters: - * dbp: pointer to access method - * key: key - * data: data - * flag: R_NOOVERWRITE - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key is already in the - * tree and R_NOOVERWRITE specified. - */ -int -__bt_put(dbp, key, data, flags) - const DB *dbp; - DBT *key; - const DBT *data; - u_int flags; -{ - BTREE *t; - DBT tkey, tdata; - EPG *e; - PAGE *h; - indx_t index, nxtindex; - pgno_t pg; - u_int32_t nbytes; - int dflags, exact, status; - char *dest, db[NOVFLSIZE], kb[NOVFLSIZE]; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* Check for change to a read-only tree. */ - if (F_ISSET(t, B_RDONLY)) { - errno = EPERM; - return (RET_ERROR); - } - - switch (flags) { - case 0: - case R_NOOVERWRITE: - break; - case R_CURSOR: - /* - * If flags is R_CURSOR, put the cursor. Must already - * have started a scan and not have already deleted it. - */ - if (F_ISSET(&t->bt_cursor, CURS_INIT) && - !F_ISSET(&t->bt_cursor, - CURS_ACQUIRE | CURS_AFTER | CURS_BEFORE)) - break; - /* FALLTHROUGH */ - default: - errno = EINVAL; - return (RET_ERROR); - } - - /* - * If the key/data pair won't fit on a page, store it on overflow - * pages. Only put the key on the overflow page if the pair are - * still too big after moving the data to an overflow page. - * - * XXX - * If the insert fails later on, the overflow pages aren't recovered. - */ - dflags = 0; - if (key->size + data->size > t->bt_ovflsize) { - if (key->size > t->bt_ovflsize) { -storekey: if (__ovfl_put(t, key, &pg) == RET_ERROR) - return (RET_ERROR); - tkey.data = kb; - tkey.size = NOVFLSIZE; - memmove(kb, &pg, sizeof(pgno_t)); - memmove(kb + sizeof(pgno_t), - &key->size, sizeof(u_int32_t)); - dflags |= P_BIGKEY; - key = &tkey; - } - if (key->size + data->size > t->bt_ovflsize) { - if (__ovfl_put(t, data, &pg) == RET_ERROR) - return (RET_ERROR); - tdata.data = db; - tdata.size = NOVFLSIZE; - memmove(db, &pg, sizeof(pgno_t)); - memmove(db + sizeof(pgno_t), - &data->size, sizeof(u_int32_t)); - dflags |= P_BIGDATA; - data = &tdata; - } - if (key->size + data->size > t->bt_ovflsize) - goto storekey; - } - - /* Replace the cursor. */ - if (flags == R_CURSOR) { - if ((h = mpool_get(t->bt_mp, t->bt_cursor.pg.pgno, 0)) == NULL) - return (RET_ERROR); - index = t->bt_cursor.pg.index; - goto delete; - } - - /* - * Find the key to delete, or, the location at which to insert. - * Bt_fast and __bt_search both pin the returned page. - */ - if (t->bt_order == NOT || (e = bt_fast(t, key, data, &exact)) == NULL) - if ((e = __bt_search(t, key, &exact)) == NULL) - return (RET_ERROR); - h = e->page; - index = e->index; - - /* - * Add the key/data pair to the tree. If an identical key is already - * in the tree, and R_NOOVERWRITE is set, an error is returned. If - * R_NOOVERWRITE is not set, the key is either added (if duplicates are - * permitted) or an error is returned. - */ - switch (flags) { - case R_NOOVERWRITE: - if (!exact) - break; - mpool_put(t->bt_mp, h, 0); - return (RET_SPECIAL); - default: - if (!exact || !F_ISSET(t, B_NODUPS)) - break; - /* - * !!! - * Note, the delete may empty the page, so we need to put a - * new entry into the page immediately. - */ -delete: if (__bt_dleaf(t, key, h, index) == RET_ERROR) { - mpool_put(t->bt_mp, h, 0); - return (RET_ERROR); - } - break; - } - - /* - * If not enough room, or the user has put a ceiling on the number of - * keys permitted in the page, split the page. The split code will - * insert the key and data and unpin the current page. If inserting - * into the offset array, shift the pointers up. - */ - nbytes = NBLEAFDBT(key->size, data->size); - if (h->upper - h->lower < nbytes + sizeof(indx_t)) { - if ((status = __bt_split(t, h, key, - data, dflags, nbytes, index)) != RET_SUCCESS) - return (status); - goto success; - } - - if (index < (nxtindex = NEXTINDEX(h))) - memmove(h->linp + index + 1, h->linp + index, - (nxtindex - index) * sizeof(indx_t)); - h->lower += sizeof(indx_t); - - h->linp[index] = h->upper -= nbytes; - dest = (char *)h + h->upper; - WR_BLEAF(dest, key, data, dflags); - - /* If the cursor is on this page, adjust it as necessary. */ - if (F_ISSET(&t->bt_cursor, CURS_INIT) && - !F_ISSET(&t->bt_cursor, CURS_ACQUIRE) && - t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index >= index) - ++t->bt_cursor.pg.index; - - if (t->bt_order == NOT) - if (h->nextpg == P_INVALID) { - if (index == NEXTINDEX(h) - 1) { - t->bt_order = FORWARD; - t->bt_last.index = index; - t->bt_last.pgno = h->pgno; - } - } else if (h->prevpg == P_INVALID) { - if (index == 0) { - t->bt_order = BACK; - t->bt_last.index = 0; - t->bt_last.pgno = h->pgno; - } - } - - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - -success: - if (flags == R_SETCURSOR) - __bt_setcur(t, e->page->pgno, e->index); - - F_SET(t, B_MODIFIED); - return (RET_SUCCESS); -} - -#ifdef STATISTICS -u_long bt_cache_hit, bt_cache_miss; -#endif - -/* - * BT_FAST -- Do a quick check for sorted data. - * - * Parameters: - * t: tree - * key: key to insert - * - * Returns: - * EPG for new record or NULL if not found. - */ -static EPG * -bt_fast(t, key, data, exactp) - BTREE *t; - const DBT *key, *data; - int *exactp; -{ - PAGE *h; - u_int32_t nbytes; - int cmp; - - if ((h = mpool_get(t->bt_mp, t->bt_last.pgno, 0)) == NULL) { - t->bt_order = NOT; - return (NULL); - } - t->bt_cur.page = h; - t->bt_cur.index = t->bt_last.index; - - /* - * If won't fit in this page or have too many keys in this page, - * have to search to get split stack. - */ - nbytes = NBLEAFDBT(key->size, data->size); - if (h->upper - h->lower < nbytes + sizeof(indx_t)) - goto miss; - - if (t->bt_order == FORWARD) { - if (t->bt_cur.page->nextpg != P_INVALID) - goto miss; - if (t->bt_cur.index != NEXTINDEX(h) - 1) - goto miss; - if ((cmp = __bt_cmp(t, key, &t->bt_cur)) < 0) - goto miss; - t->bt_last.index = cmp ? ++t->bt_cur.index : t->bt_cur.index; - } else { - if (t->bt_cur.page->prevpg != P_INVALID) - goto miss; - if (t->bt_cur.index != 0) - goto miss; - if ((cmp = __bt_cmp(t, key, &t->bt_cur)) > 0) - goto miss; - t->bt_last.index = 0; - } - *exactp = cmp == 0; -#ifdef STATISTICS - ++bt_cache_hit; -#endif - return (&t->bt_cur); - -miss: -#ifdef STATISTICS - ++bt_cache_miss; -#endif - t->bt_order = NOT; - mpool_put(t->bt_mp, h, 0); - return (NULL); -} diff --git a/lib/libc/db/btree/bt_search.c b/lib/libc/db/btree/bt_search.c deleted file mode 100644 index 485afcb..0000000 --- a/lib/libc/db/btree/bt_search.c +++ /dev/null @@ -1,213 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)bt_search.c 8.8 (Berkeley) 7/31/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include - -#include -#include "btree.h" - -static int __bt_snext __P((BTREE *, PAGE *, const DBT *, int *)); -static int __bt_sprev __P((BTREE *, PAGE *, const DBT *, int *)); - -/* - * __bt_search -- - * Search a btree for a key. - * - * Parameters: - * t: tree to search - * key: key to find - * exactp: pointer to exact match flag - * - * Returns: - * The EPG for matching record, if any, or the EPG for the location - * of the key, if it were inserted into the tree, is entered into - * the bt_cur field of the tree. A pointer to the field is returned. - */ -EPG * -__bt_search(t, key, exactp) - BTREE *t; - const DBT *key; - int *exactp; -{ - PAGE *h; - indx_t base, index, lim; - pgno_t pg; - int cmp; - - BT_CLR(t); - for (pg = P_ROOT;;) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (NULL); - - /* Do a binary search on the current page. */ - t->bt_cur.page = h; - for (base = 0, lim = NEXTINDEX(h); lim; lim >>= 1) { - t->bt_cur.index = index = base + (lim >> 1); - if ((cmp = __bt_cmp(t, key, &t->bt_cur)) == 0) { - if (h->flags & P_BLEAF) { - *exactp = 1; - return (&t->bt_cur); - } - goto next; - } - if (cmp > 0) { - base = index + 1; - --lim; - } - } - - /* - * If it's a leaf page, we're almost done. If no duplicates - * are allowed, or we have an exact match, we're done. Else, - * it's possible that there were matching keys on this page, - * which later deleted, and we're on a page with no matches - * while there are matches on other pages. If at the start or - * end of a page, check the adjacent page. - */ - if (h->flags & P_BLEAF) { - if (!F_ISSET(t, B_NODUPS)) { - if (base == 0 && - h->prevpg != P_INVALID && - __bt_sprev(t, h, key, exactp)) - return (&t->bt_cur); - if (base == NEXTINDEX(h) && - h->nextpg != P_INVALID && - __bt_snext(t, h, key, exactp)) - return (&t->bt_cur); - } - *exactp = 0; - t->bt_cur.index = base; - return (&t->bt_cur); - } - - /* - * No match found. Base is the smallest index greater than - * key and may be zero or a last + 1 index. If it's non-zero, - * decrement by one, and record the internal page which should - * be a parent page for the key. If a split later occurs, the - * inserted page will be to the right of the saved page. - */ - index = base ? base - 1 : base; - -next: BT_PUSH(t, h->pgno, index); - pg = GETBINTERNAL(h, index)->pgno; - mpool_put(t->bt_mp, h, 0); - } -} - -/* - * __bt_snext -- - * Check for an exact match after the key. - * - * Parameters: - * t: tree - * h: current page - * key: key - * exactp: pointer to exact match flag - * - * Returns: - * If an exact match found. - */ -static int -__bt_snext(t, h, key, exactp) - BTREE *t; - PAGE *h; - const DBT *key; - int *exactp; -{ - EPG e; - - /* - * Get the next page. The key is either an exact - * match, or not as good as the one we already have. - */ - if ((e.page = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL) - return (0); - e.index = 0; - if (__bt_cmp(t, key, &e) == 0) { - mpool_put(t->bt_mp, h, 0); - t->bt_cur = e; - *exactp = 1; - return (1); - } - mpool_put(t->bt_mp, e.page, 0); - return (0); -} - -/* - * __bt_sprev -- - * Check for an exact match before the key. - * - * Parameters: - * t: tree - * h: current page - * key: key - * exactp: pointer to exact match flag - * - * Returns: - * If an exact match found. - */ -static int -__bt_sprev(t, h, key, exactp) - BTREE *t; - PAGE *h; - const DBT *key; - int *exactp; -{ - EPG e; - - /* - * Get the previous page. The key is either an exact - * match, or not as good as the one we already have. - */ - if ((e.page = mpool_get(t->bt_mp, h->prevpg, 0)) == NULL) - return (0); - e.index = NEXTINDEX(e.page) - 1; - if (__bt_cmp(t, key, &e) == 0) { - mpool_put(t->bt_mp, h, 0); - t->bt_cur = e; - *exactp = 1; - return (1); - } - mpool_put(t->bt_mp, e.page, 0); - return (0); -} diff --git a/lib/libc/db/btree/bt_seq.c b/lib/libc/db/btree/bt_seq.c deleted file mode 100644 index 76e6275..0000000 --- a/lib/libc/db/btree/bt_seq.c +++ /dev/null @@ -1,460 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)bt_seq.c 8.7 (Berkeley) 7/20/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include - -#include -#include "btree.h" - -static int __bt_first __P((BTREE *, const DBT *, EPG *, int *)); -static int __bt_seqadv __P((BTREE *, EPG *, int)); -static int __bt_seqset __P((BTREE *, EPG *, DBT *, int)); - -/* - * Sequential scan support. - * - * The tree can be scanned sequentially, starting from either end of the - * tree or from any specific key. A scan request before any scanning is - * done is initialized as starting from the least node. - */ - -/* - * __bt_seq -- - * Btree sequential scan interface. - * - * Parameters: - * dbp: pointer to access method - * key: key for positioning and return value - * data: data return value - * flags: R_CURSOR, R_FIRST, R_LAST, R_NEXT, R_PREV. - * - * Returns: - * RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key. - */ -int -__bt_seq(dbp, key, data, flags) - const DB *dbp; - DBT *key, *data; - u_int flags; -{ - BTREE *t; - EPG e; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* - * If scan unitialized as yet, or starting at a specific record, set - * the scan to a specific key. Both __bt_seqset and __bt_seqadv pin - * the page the cursor references if they're successful. - */ - switch (flags) { - case R_NEXT: - case R_PREV: - if (F_ISSET(&t->bt_cursor, CURS_INIT)) { - status = __bt_seqadv(t, &e, flags); - break; - } - /* FALLTHROUGH */ - case R_FIRST: - case R_LAST: - case R_CURSOR: - status = __bt_seqset(t, &e, key, flags); - break; - default: - errno = EINVAL; - return (RET_ERROR); - } - - if (status == RET_SUCCESS) { - __bt_setcur(t, e.page->pgno, e.index); - - status = - __bt_ret(t, &e, key, &t->bt_rkey, data, &t->bt_rdata, 0); - - /* - * If the user is doing concurrent access, we copied the - * key/data, toss the page. - */ - if (F_ISSET(t, B_DB_LOCK)) - mpool_put(t->bt_mp, e.page, 0); - else - t->bt_pinned = e.page; - } - return (status); -} - -/* - * __bt_seqset -- - * Set the sequential scan to a specific key. - * - * Parameters: - * t: tree - * ep: storage for returned key - * key: key for initial scan position - * flags: R_CURSOR, R_FIRST, R_LAST, R_NEXT, R_PREV - * - * Side effects: - * Pins the page the cursor references. - * - * Returns: - * RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key. - */ -static int -__bt_seqset(t, ep, key, flags) - BTREE *t; - EPG *ep; - DBT *key; - int flags; -{ - PAGE *h; - pgno_t pg; - int exact; - - /* - * Find the first, last or specific key in the tree and point the - * cursor at it. The cursor may not be moved until a new key has - * been found. - */ - switch (flags) { - case R_CURSOR: /* Keyed scan. */ - /* - * Find the first instance of the key or the smallest key - * which is greater than or equal to the specified key. - */ - if (key->data == NULL || key->size == 0) { - errno = EINVAL; - return (RET_ERROR); - } - return (__bt_first(t, key, ep, &exact)); - case R_FIRST: /* First record. */ - case R_NEXT: - /* Walk down the left-hand side of the tree. */ - for (pg = P_ROOT;;) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - - /* Check for an empty tree. */ - if (NEXTINDEX(h) == 0) { - mpool_put(t->bt_mp, h, 0); - return (RET_SPECIAL); - } - - if (h->flags & (P_BLEAF | P_RLEAF)) - break; - pg = GETBINTERNAL(h, 0)->pgno; - mpool_put(t->bt_mp, h, 0); - } - ep->page = h; - ep->index = 0; - break; - case R_LAST: /* Last record. */ - case R_PREV: - /* Walk down the right-hand side of the tree. */ - for (pg = P_ROOT;;) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - - /* Check for an empty tree. */ - if (NEXTINDEX(h) == 0) { - mpool_put(t->bt_mp, h, 0); - return (RET_SPECIAL); - } - - if (h->flags & (P_BLEAF | P_RLEAF)) - break; - pg = GETBINTERNAL(h, NEXTINDEX(h) - 1)->pgno; - mpool_put(t->bt_mp, h, 0); - } - - ep->page = h; - ep->index = NEXTINDEX(h) - 1; - break; - } - return (RET_SUCCESS); -} - -/* - * __bt_seqadvance -- - * Advance the sequential scan. - * - * Parameters: - * t: tree - * flags: R_NEXT, R_PREV - * - * Side effects: - * Pins the page the new key/data record is on. - * - * Returns: - * RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key. - */ -static int -__bt_seqadv(t, ep, flags) - BTREE *t; - EPG *ep; - int flags; -{ - CURSOR *c; - PAGE *h; - indx_t index; - pgno_t pg; - int exact; - - /* - * There are a couple of states that we can be in. The cursor has - * been initialized by the time we get here, but that's all we know. - */ - c = &t->bt_cursor; - - /* - * The cursor was deleted where there weren't any duplicate records, - * so the key was saved. Find out where that key would go in the - * current tree. It doesn't matter if the returned key is an exact - * match or not -- if it's an exact match, the record was added after - * the delete so we can just return it. If not, as long as there's - * a record there, return it. - */ - if (F_ISSET(c, CURS_ACQUIRE)) - return (__bt_first(t, &c->key, ep, &exact)); - - /* Get the page referenced by the cursor. */ - if ((h = mpool_get(t->bt_mp, c->pg.pgno, 0)) == NULL) - return (RET_ERROR); - - /* - * Find the next/previous record in the tree and point the cursor at - * it. The cursor may not be moved until a new key has been found. - */ - switch (flags) { - case R_NEXT: /* Next record. */ - /* - * The cursor was deleted in duplicate records, and moved - * forward to a record that has yet to be returned. Clear - * that flag, and return the record. - */ - if (F_ISSET(c, CURS_AFTER)) - goto usecurrent; - index = c->pg.index; - if (++index == NEXTINDEX(h)) { - pg = h->nextpg; - mpool_put(t->bt_mp, h, 0); - if (pg == P_INVALID) - return (RET_SPECIAL); - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - index = 0; - } - break; - case R_PREV: /* Previous record. */ - /* - * The cursor was deleted in duplicate records, and moved - * backward to a record that has yet to be returned. Clear - * that flag, and return the record. - */ - if (F_ISSET(c, CURS_BEFORE)) { -usecurrent: F_CLR(c, CURS_AFTER | CURS_BEFORE); - ep->page = h; - ep->index = c->pg.index; - return (RET_SUCCESS); - } - index = c->pg.index; - if (index == 0) { - pg = h->prevpg; - mpool_put(t->bt_mp, h, 0); - if (pg == P_INVALID) - return (RET_SPECIAL); - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - index = NEXTINDEX(h) - 1; - } else - --index; - break; - } - - ep->page = h; - ep->index = index; - return (RET_SUCCESS); -} - -/* - * __bt_first -- - * Find the first entry. - * - * Parameters: - * t: the tree - * key: the key - * erval: return EPG - * exactp: pointer to exact match flag - * - * Returns: - * The first entry in the tree greater than or equal to key, - * or RET_SPECIAL if no such key exists. - */ -static int -__bt_first(t, key, erval, exactp) - BTREE *t; - const DBT *key; - EPG *erval; - int *exactp; -{ - PAGE *h; - EPG *ep, save; - pgno_t pg; - - /* - * Find any matching record; __bt_search pins the page. - * - * If it's an exact match and duplicates are possible, walk backwards - * in the tree until we find the first one. Otherwise, make sure it's - * a valid key (__bt_search may return an index just past the end of a - * page) and return it. - */ - if ((ep = __bt_search(t, key, exactp)) == NULL) - return (0); - if (*exactp) { - if (F_ISSET(t, B_NODUPS)) { - *erval = *ep; - return (RET_SUCCESS); - } - - /* - * Walk backwards, as long as the entry matches and there are - * keys left in the tree. Save a copy of each match in case - * we go too far. - */ - save = *ep; - h = ep->page; - do { - if (save.page->pgno != ep->page->pgno) { - mpool_put(t->bt_mp, save.page, 0); - save = *ep; - } else - save.index = ep->index; - - /* - * Don't unpin the page the last (or original) match - * was on, but make sure it's unpinned if an error - * occurs. - */ - if (ep->index == 0) { - if (h->prevpg == P_INVALID) - break; - if (h->pgno != save.page->pgno) - mpool_put(t->bt_mp, h, 0); - if ((h = mpool_get(t->bt_mp, - h->prevpg, 0)) == NULL) { - if (h->pgno == save.page->pgno) - mpool_put(t->bt_mp, - save.page, 0); - return (RET_ERROR); - } - ep->page = h; - ep->index = NEXTINDEX(h); - } - --ep->index; - } while (__bt_cmp(t, key, ep) == 0); - - /* - * Reach here with the last page that was looked at pinned, - * which may or may not be the same as the last (or original) - * match page. If it's not useful, release it. - */ - if (h->pgno != save.page->pgno) - mpool_put(t->bt_mp, h, 0); - - *erval = save; - return (RET_SUCCESS); - } - - /* If at the end of a page, find the next entry. */ - if (ep->index == NEXTINDEX(ep->page)) { - h = ep->page; - pg = h->nextpg; - mpool_put(t->bt_mp, h, 0); - if (pg == P_INVALID) - return (RET_SPECIAL); - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - ep->index = 0; - ep->page = h; - } - *erval = *ep; - return (RET_SUCCESS); -} - -/* - * __bt_setcur -- - * Set the cursor to an entry in the tree. - * - * Parameters: - * t: the tree - * pgno: page number - * index: page index - */ -void -__bt_setcur(t, pgno, index) - BTREE *t; - pgno_t pgno; - u_int index; -{ - /* Lose any already deleted key. */ - if (t->bt_cursor.key.data != NULL) { - free(t->bt_cursor.key.data); - t->bt_cursor.key.size = 0; - t->bt_cursor.key.data = NULL; - } - F_CLR(&t->bt_cursor, CURS_ACQUIRE | CURS_AFTER | CURS_BEFORE); - - /* Update the cursor. */ - t->bt_cursor.pg.pgno = pgno; - t->bt_cursor.pg.index = index; - F_SET(&t->bt_cursor, CURS_INIT); -} diff --git a/lib/libc/db/btree/bt_split.c b/lib/libc/db/btree/bt_split.c deleted file mode 100644 index c7779b8..0000000 --- a/lib/libc/db/btree/bt_split.c +++ /dev/null @@ -1,828 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)bt_split.c 8.9 (Berkeley) 7/26/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include - -#include -#include "btree.h" - -static int bt_broot __P((BTREE *, PAGE *, PAGE *, PAGE *)); -static PAGE *bt_page - __P((BTREE *, PAGE *, PAGE **, PAGE **, indx_t *, size_t)); -static int bt_preserve __P((BTREE *, pgno_t)); -static PAGE *bt_psplit - __P((BTREE *, PAGE *, PAGE *, PAGE *, indx_t *, size_t)); -static PAGE *bt_root - __P((BTREE *, PAGE *, PAGE **, PAGE **, indx_t *, size_t)); -static int bt_rroot __P((BTREE *, PAGE *, PAGE *, PAGE *)); -static recno_t rec_total __P((PAGE *)); - -#ifdef STATISTICS -u_long bt_rootsplit, bt_split, bt_sortsplit, bt_pfxsaved; -#endif - -/* - * __BT_SPLIT -- Split the tree. - * - * Parameters: - * t: tree - * sp: page to split - * key: key to insert - * data: data to insert - * flags: BIGKEY/BIGDATA flags - * ilen: insert length - * skip: index to leave open - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__bt_split(t, sp, key, data, flags, ilen, argskip) - BTREE *t; - PAGE *sp; - const DBT *key, *data; - int flags; - size_t ilen; - u_int32_t argskip; -{ - BINTERNAL *bi; - BLEAF *bl, *tbl; - DBT a, b; - EPGNO *parent; - PAGE *h, *l, *r, *lchild, *rchild; - indx_t nxtindex; - u_int16_t skip; - u_int32_t n, nbytes, nksize; - int parentsplit; - char *dest; - - /* - * Split the page into two pages, l and r. The split routines return - * a pointer to the page into which the key should be inserted and with - * skip set to the offset which should be used. Additionally, l and r - * are pinned. - */ - skip = argskip; - h = sp->pgno == P_ROOT ? - bt_root(t, sp, &l, &r, &skip, ilen) : - bt_page(t, sp, &l, &r, &skip, ilen); - if (h == NULL) - return (RET_ERROR); - - /* - * Insert the new key/data pair into the leaf page. (Key inserts - * always cause a leaf page to split first.) - */ - h->linp[skip] = h->upper -= ilen; - dest = (char *)h + h->upper; - if (F_ISSET(t, R_RECNO)) - WR_RLEAF(dest, data, flags) - else - WR_BLEAF(dest, key, data, flags) - - /* If the root page was split, make it look right. */ - if (sp->pgno == P_ROOT && - (F_ISSET(t, R_RECNO) ? - bt_rroot(t, sp, l, r) : bt_broot(t, sp, l, r)) == RET_ERROR) - goto err2; - - /* - * Now we walk the parent page stack -- a LIFO stack of the pages that - * were traversed when we searched for the page that split. Each stack - * entry is a page number and a page index offset. The offset is for - * the page traversed on the search. We've just split a page, so we - * have to insert a new key into the parent page. - * - * If the insert into the parent page causes it to split, may have to - * continue splitting all the way up the tree. We stop if the root - * splits or the page inserted into didn't have to split to hold the - * new key. Some algorithms replace the key for the old page as well - * as the new page. We don't, as there's no reason to believe that the - * first key on the old page is any better than the key we have, and, - * in the case of a key being placed at index 0 causing the split, the - * key is unavailable. - * - * There are a maximum of 5 pages pinned at any time. We keep the left - * and right pages pinned while working on the parent. The 5 are the - * two children, left parent and right parent (when the parent splits) - * and the root page or the overflow key page when calling bt_preserve. - * This code must make sure that all pins are released other than the - * root page or overflow page which is unlocked elsewhere. - */ - while ((parent = BT_POP(t)) != NULL) { - lchild = l; - rchild = r; - - /* Get the parent page. */ - if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) - goto err2; - - /* - * The new key goes ONE AFTER the index, because the split - * was to the right. - */ - skip = parent->index + 1; - - /* - * Calculate the space needed on the parent page. - * - * Prefix trees: space hack when inserting into BINTERNAL - * pages. Retain only what's needed to distinguish between - * the new entry and the LAST entry on the page to its left. - * If the keys compare equal, retain the entire key. Note, - * we don't touch overflow keys, and the entire key must be - * retained for the next-to-left most key on the leftmost - * page of each level, or the search will fail. Applicable - * ONLY to internal pages that have leaf pages as children. - * Further reduction of the key between pairs of internal - * pages loses too much information. - */ - switch (rchild->flags & P_TYPE) { - case P_BINTERNAL: - bi = GETBINTERNAL(rchild, 0); - nbytes = NBINTERNAL(bi->ksize); - break; - case P_BLEAF: - bl = GETBLEAF(rchild, 0); - nbytes = NBINTERNAL(bl->ksize); - if (t->bt_pfx && !(bl->flags & P_BIGKEY) && - (h->prevpg != P_INVALID || skip > 1)) { - tbl = GETBLEAF(lchild, NEXTINDEX(lchild) - 1); - a.size = tbl->ksize; - a.data = tbl->bytes; - b.size = bl->ksize; - b.data = bl->bytes; - nksize = t->bt_pfx(&a, &b); - n = NBINTERNAL(nksize); - if (n < nbytes) { -#ifdef STATISTICS - bt_pfxsaved += nbytes - n; -#endif - nbytes = n; - } else - nksize = 0; - } else - nksize = 0; - break; - case P_RINTERNAL: - case P_RLEAF: - nbytes = NRINTERNAL; - break; - default: - abort(); - } - - /* Split the parent page if necessary or shift the indices. */ - if (h->upper - h->lower < nbytes + sizeof(indx_t)) { - sp = h; - h = h->pgno == P_ROOT ? - bt_root(t, h, &l, &r, &skip, nbytes) : - bt_page(t, h, &l, &r, &skip, nbytes); - if (h == NULL) - goto err1; - parentsplit = 1; - } else { - if (skip < (nxtindex = NEXTINDEX(h))) - memmove(h->linp + skip + 1, h->linp + skip, - (nxtindex - skip) * sizeof(indx_t)); - h->lower += sizeof(indx_t); - parentsplit = 0; - } - - /* Insert the key into the parent page. */ - switch (rchild->flags & P_TYPE) { - case P_BINTERNAL: - h->linp[skip] = h->upper -= nbytes; - dest = (char *)h + h->linp[skip]; - memmove(dest, bi, nbytes); - ((BINTERNAL *)dest)->pgno = rchild->pgno; - break; - case P_BLEAF: - h->linp[skip] = h->upper -= nbytes; - dest = (char *)h + h->linp[skip]; - WR_BINTERNAL(dest, nksize ? nksize : bl->ksize, - rchild->pgno, bl->flags & P_BIGKEY); - memmove(dest, bl->bytes, nksize ? nksize : bl->ksize); - if (bl->flags & P_BIGKEY && - bt_preserve(t, *(pgno_t *)bl->bytes) == RET_ERROR) - goto err1; - break; - case P_RINTERNAL: - /* - * Update the left page count. If split - * added at index 0, fix the correct page. - */ - if (skip > 0) - dest = (char *)h + h->linp[skip - 1]; - else - dest = (char *)l + l->linp[NEXTINDEX(l) - 1]; - ((RINTERNAL *)dest)->nrecs = rec_total(lchild); - ((RINTERNAL *)dest)->pgno = lchild->pgno; - - /* Update the right page count. */ - h->linp[skip] = h->upper -= nbytes; - dest = (char *)h + h->linp[skip]; - ((RINTERNAL *)dest)->nrecs = rec_total(rchild); - ((RINTERNAL *)dest)->pgno = rchild->pgno; - break; - case P_RLEAF: - /* - * Update the left page count. If split - * added at index 0, fix the correct page. - */ - if (skip > 0) - dest = (char *)h + h->linp[skip - 1]; - else - dest = (char *)l + l->linp[NEXTINDEX(l) - 1]; - ((RINTERNAL *)dest)->nrecs = NEXTINDEX(lchild); - ((RINTERNAL *)dest)->pgno = lchild->pgno; - - /* Update the right page count. */ - h->linp[skip] = h->upper -= nbytes; - dest = (char *)h + h->linp[skip]; - ((RINTERNAL *)dest)->nrecs = NEXTINDEX(rchild); - ((RINTERNAL *)dest)->pgno = rchild->pgno; - break; - default: - abort(); - } - - /* Unpin the held pages. */ - if (!parentsplit) { - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - break; - } - - /* If the root page was split, make it look right. */ - if (sp->pgno == P_ROOT && - (F_ISSET(t, R_RECNO) ? - bt_rroot(t, sp, l, r) : bt_broot(t, sp, l, r)) == RET_ERROR) - goto err1; - - mpool_put(t->bt_mp, lchild, MPOOL_DIRTY); - mpool_put(t->bt_mp, rchild, MPOOL_DIRTY); - } - - /* Unpin the held pages. */ - mpool_put(t->bt_mp, l, MPOOL_DIRTY); - mpool_put(t->bt_mp, r, MPOOL_DIRTY); - - /* Clear any pages left on the stack. */ - return (RET_SUCCESS); - - /* - * If something fails in the above loop we were already walking back - * up the tree and the tree is now inconsistent. Nothing much we can - * do about it but release any memory we're holding. - */ -err1: mpool_put(t->bt_mp, lchild, MPOOL_DIRTY); - mpool_put(t->bt_mp, rchild, MPOOL_DIRTY); - -err2: mpool_put(t->bt_mp, l, 0); - mpool_put(t->bt_mp, r, 0); - __dbpanic(t->bt_dbp); - return (RET_ERROR); -} - -/* - * BT_PAGE -- Split a non-root page of a btree. - * - * Parameters: - * t: tree - * h: root page - * lp: pointer to left page pointer - * rp: pointer to right page pointer - * skip: pointer to index to leave open - * ilen: insert length - * - * Returns: - * Pointer to page in which to insert or NULL on error. - */ -static PAGE * -bt_page(t, h, lp, rp, skip, ilen) - BTREE *t; - PAGE *h, **lp, **rp; - indx_t *skip; - size_t ilen; -{ - PAGE *l, *r, *tp; - pgno_t npg; - -#ifdef STATISTICS - ++bt_split; -#endif - /* Put the new right page for the split into place. */ - if ((r = __bt_new(t, &npg)) == NULL) - return (NULL); - r->pgno = npg; - r->lower = BTDATAOFF; - r->upper = t->bt_psize; - r->nextpg = h->nextpg; - r->prevpg = h->pgno; - r->flags = h->flags & P_TYPE; - - /* - * If we're splitting the last page on a level because we're appending - * a key to it (skip is NEXTINDEX()), it's likely that the data is - * sorted. Adding an empty page on the side of the level is less work - * and can push the fill factor much higher than normal. If we're - * wrong it's no big deal, we'll just do the split the right way next - * time. It may look like it's equally easy to do a similar hack for - * reverse sorted data, that is, split the tree left, but it's not. - * Don't even try. - */ - if (h->nextpg == P_INVALID && *skip == NEXTINDEX(h)) { -#ifdef STATISTICS - ++bt_sortsplit; -#endif - h->nextpg = r->pgno; - r->lower = BTDATAOFF + sizeof(indx_t); - *skip = 0; - *lp = h; - *rp = r; - return (r); - } - - /* Put the new left page for the split into place. */ - if ((l = (PAGE *)malloc(t->bt_psize)) == NULL) { - mpool_put(t->bt_mp, r, 0); - return (NULL); - } -#ifdef PURIFY - memset(l, 0xff, t->bt_psize); -#endif - l->pgno = h->pgno; - l->nextpg = r->pgno; - l->prevpg = h->prevpg; - l->lower = BTDATAOFF; - l->upper = t->bt_psize; - l->flags = h->flags & P_TYPE; - - /* Fix up the previous pointer of the page after the split page. */ - if (h->nextpg != P_INVALID) { - if ((tp = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL) { - free(l); - /* XXX mpool_free(t->bt_mp, r->pgno); */ - return (NULL); - } - tp->prevpg = r->pgno; - mpool_put(t->bt_mp, tp, MPOOL_DIRTY); - } - - /* - * Split right. The key/data pairs aren't sorted in the btree page so - * it's simpler to copy the data from the split page onto two new pages - * instead of copying half the data to the right page and compacting - * the left page in place. Since the left page can't change, we have - * to swap the original and the allocated left page after the split. - */ - tp = bt_psplit(t, h, l, r, skip, ilen); - - /* Move the new left page onto the old left page. */ - memmove(h, l, t->bt_psize); - if (tp == l) - tp = h; - free(l); - - *lp = h; - *rp = r; - return (tp); -} - -/* - * BT_ROOT -- Split the root page of a btree. - * - * Parameters: - * t: tree - * h: root page - * lp: pointer to left page pointer - * rp: pointer to right page pointer - * skip: pointer to index to leave open - * ilen: insert length - * - * Returns: - * Pointer to page in which to insert or NULL on error. - */ -static PAGE * -bt_root(t, h, lp, rp, skip, ilen) - BTREE *t; - PAGE *h, **lp, **rp; - indx_t *skip; - size_t ilen; -{ - PAGE *l, *r, *tp; - pgno_t lnpg, rnpg; - -#ifdef STATISTICS - ++bt_split; - ++bt_rootsplit; -#endif - /* Put the new left and right pages for the split into place. */ - if ((l = __bt_new(t, &lnpg)) == NULL || - (r = __bt_new(t, &rnpg)) == NULL) - return (NULL); - l->pgno = lnpg; - r->pgno = rnpg; - l->nextpg = r->pgno; - r->prevpg = l->pgno; - l->prevpg = r->nextpg = P_INVALID; - l->lower = r->lower = BTDATAOFF; - l->upper = r->upper = t->bt_psize; - l->flags = r->flags = h->flags & P_TYPE; - - /* Split the root page. */ - tp = bt_psplit(t, h, l, r, skip, ilen); - - *lp = l; - *rp = r; - return (tp); -} - -/* - * BT_RROOT -- Fix up the recno root page after it has been split. - * - * Parameters: - * t: tree - * h: root page - * l: left page - * r: right page - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -static int -bt_rroot(t, h, l, r) - BTREE *t; - PAGE *h, *l, *r; -{ - char *dest; - - /* Insert the left and right keys, set the header information. */ - h->linp[0] = h->upper = t->bt_psize - NRINTERNAL; - dest = (char *)h + h->upper; - WR_RINTERNAL(dest, - l->flags & P_RLEAF ? NEXTINDEX(l) : rec_total(l), l->pgno); - - h->linp[1] = h->upper -= NRINTERNAL; - dest = (char *)h + h->upper; - WR_RINTERNAL(dest, - r->flags & P_RLEAF ? NEXTINDEX(r) : rec_total(r), r->pgno); - - h->lower = BTDATAOFF + 2 * sizeof(indx_t); - - /* Unpin the root page, set to recno internal page. */ - h->flags &= ~P_TYPE; - h->flags |= P_RINTERNAL; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - - return (RET_SUCCESS); -} - -/* - * BT_BROOT -- Fix up the btree root page after it has been split. - * - * Parameters: - * t: tree - * h: root page - * l: left page - * r: right page - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -static int -bt_broot(t, h, l, r) - BTREE *t; - PAGE *h, *l, *r; -{ - BINTERNAL *bi; - BLEAF *bl; - u_int32_t nbytes; - char *dest; - - /* - * If the root page was a leaf page, change it into an internal page. - * We copy the key we split on (but not the key's data, in the case of - * a leaf page) to the new root page. - * - * The btree comparison code guarantees that the left-most key on any - * level of the tree is never used, so it doesn't need to be filled in. - */ - nbytes = NBINTERNAL(0); - h->linp[0] = h->upper = t->bt_psize - nbytes; - dest = (char *)h + h->upper; - WR_BINTERNAL(dest, 0, l->pgno, 0); - - switch (h->flags & P_TYPE) { - case P_BLEAF: - bl = GETBLEAF(r, 0); - nbytes = NBINTERNAL(bl->ksize); - h->linp[1] = h->upper -= nbytes; - dest = (char *)h + h->upper; - WR_BINTERNAL(dest, bl->ksize, r->pgno, 0); - memmove(dest, bl->bytes, bl->ksize); - - /* - * If the key is on an overflow page, mark the overflow chain - * so it isn't deleted when the leaf copy of the key is deleted. - */ - if (bl->flags & P_BIGKEY && - bt_preserve(t, *(pgno_t *)bl->bytes) == RET_ERROR) - return (RET_ERROR); - break; - case P_BINTERNAL: - bi = GETBINTERNAL(r, 0); - nbytes = NBINTERNAL(bi->ksize); - h->linp[1] = h->upper -= nbytes; - dest = (char *)h + h->upper; - memmove(dest, bi, nbytes); - ((BINTERNAL *)dest)->pgno = r->pgno; - break; - default: - abort(); - } - - /* There are two keys on the page. */ - h->lower = BTDATAOFF + 2 * sizeof(indx_t); - - /* Unpin the root page, set to btree internal page. */ - h->flags &= ~P_TYPE; - h->flags |= P_BINTERNAL; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - - return (RET_SUCCESS); -} - -/* - * BT_PSPLIT -- Do the real work of splitting the page. - * - * Parameters: - * t: tree - * h: page to be split - * l: page to put lower half of data - * r: page to put upper half of data - * pskip: pointer to index to leave open - * ilen: insert length - * - * Returns: - * Pointer to page in which to insert. - */ -static PAGE * -bt_psplit(t, h, l, r, pskip, ilen) - BTREE *t; - PAGE *h, *l, *r; - indx_t *pskip; - size_t ilen; -{ - BINTERNAL *bi; - BLEAF *bl; - CURSOR *c; - RLEAF *rl; - PAGE *rval; - void *src; - indx_t full, half, nxt, off, skip, top, used; - u_int32_t nbytes; - int bigkeycnt, isbigkey; - - /* - * Split the data to the left and right pages. Leave the skip index - * open. Additionally, make some effort not to split on an overflow - * key. This makes internal page processing faster and can save - * space as overflow keys used by internal pages are never deleted. - */ - bigkeycnt = 0; - skip = *pskip; - full = t->bt_psize - BTDATAOFF; - half = full / 2; - used = 0; - for (nxt = off = 0, top = NEXTINDEX(h); nxt < top; ++off) { - if (skip == off) { - nbytes = ilen; - isbigkey = 0; /* XXX: not really known. */ - } else - switch (h->flags & P_TYPE) { - case P_BINTERNAL: - src = bi = GETBINTERNAL(h, nxt); - nbytes = NBINTERNAL(bi->ksize); - isbigkey = bi->flags & P_BIGKEY; - break; - case P_BLEAF: - src = bl = GETBLEAF(h, nxt); - nbytes = NBLEAF(bl); - isbigkey = bl->flags & P_BIGKEY; - break; - case P_RINTERNAL: - src = GETRINTERNAL(h, nxt); - nbytes = NRINTERNAL; - isbigkey = 0; - break; - case P_RLEAF: - src = rl = GETRLEAF(h, nxt); - nbytes = NRLEAF(rl); - isbigkey = 0; - break; - default: - abort(); - } - - /* - * If the key/data pairs are substantial fractions of the max - * possible size for the page, it's possible to get situations - * where we decide to try and copy too much onto the left page. - * Make sure that doesn't happen. - */ - if (skip <= off && - used + nbytes + sizeof(indx_t) >= full || nxt == top - 1) { - --off; - break; - } - - /* Copy the key/data pair, if not the skipped index. */ - if (skip != off) { - ++nxt; - - l->linp[off] = l->upper -= nbytes; - memmove((char *)l + l->upper, src, nbytes); - } - - used += nbytes + sizeof(indx_t); - if (used >= half) { - if (!isbigkey || bigkeycnt == 3) - break; - else - ++bigkeycnt; - } - } - - /* - * Off is the last offset that's valid for the left page. - * Nxt is the first offset to be placed on the right page. - */ - l->lower += (off + 1) * sizeof(indx_t); - - /* - * If splitting the page that the cursor was on, the cursor has to be - * adjusted to point to the same record as before the split. If the - * cursor is at or past the skipped slot, the cursor is incremented by - * one. If the cursor is on the right page, it is decremented by the - * number of records split to the left page. - */ - c = &t->bt_cursor; - if (F_ISSET(c, CURS_INIT) && c->pg.pgno == h->pgno) { - if (c->pg.index >= skip) - ++c->pg.index; - if (c->pg.index < nxt) /* Left page. */ - c->pg.pgno = l->pgno; - else { /* Right page. */ - c->pg.pgno = r->pgno; - c->pg.index -= nxt; - } - } - - /* - * If the skipped index was on the left page, just return that page. - * Otherwise, adjust the skip index to reflect the new position on - * the right page. - */ - if (skip <= off) { - skip = 0; - rval = l; - } else { - rval = r; - *pskip -= nxt; - } - - for (off = 0; nxt < top; ++off) { - if (skip == nxt) { - ++off; - skip = 0; - } - switch (h->flags & P_TYPE) { - case P_BINTERNAL: - src = bi = GETBINTERNAL(h, nxt); - nbytes = NBINTERNAL(bi->ksize); - break; - case P_BLEAF: - src = bl = GETBLEAF(h, nxt); - nbytes = NBLEAF(bl); - break; - case P_RINTERNAL: - src = GETRINTERNAL(h, nxt); - nbytes = NRINTERNAL; - break; - case P_RLEAF: - src = rl = GETRLEAF(h, nxt); - nbytes = NRLEAF(rl); - break; - default: - abort(); - } - ++nxt; - r->linp[off] = r->upper -= nbytes; - memmove((char *)r + r->upper, src, nbytes); - } - r->lower += off * sizeof(indx_t); - - /* If the key is being appended to the page, adjust the index. */ - if (skip == top) - r->lower += sizeof(indx_t); - - return (rval); -} - -/* - * BT_PRESERVE -- Mark a chain of pages as used by an internal node. - * - * Chains of indirect blocks pointed to by leaf nodes get reclaimed when the - * record that references them gets deleted. Chains pointed to by internal - * pages never get deleted. This routine marks a chain as pointed to by an - * internal page. - * - * Parameters: - * t: tree - * pg: page number of first page in the chain. - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -static int -bt_preserve(t, pg) - BTREE *t; - pgno_t pg; -{ - PAGE *h; - - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - h->flags |= P_PRESERVE; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - return (RET_SUCCESS); -} - -/* - * REC_TOTAL -- Return the number of recno entries below a page. - * - * Parameters: - * h: page - * - * Returns: - * The number of recno entries below a page. - * - * XXX - * These values could be set by the bt_psplit routine. The problem is that the - * entry has to be popped off of the stack etc. or the values have to be passed - * all the way back to bt_split/bt_rroot and it's not very clean. - */ -static recno_t -rec_total(h) - PAGE *h; -{ - recno_t recs; - indx_t nxt, top; - - for (recs = 0, nxt = 0, top = NEXTINDEX(h); nxt < top; ++nxt) - recs += GETRINTERNAL(h, nxt)->nrecs; - return (recs); -} diff --git a/lib/libc/db/btree/bt_utils.c b/lib/libc/db/btree/bt_utils.c deleted file mode 100644 index 9c1438e..0000000 --- a/lib/libc/db/btree/bt_utils.c +++ /dev/null @@ -1,260 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)bt_utils.c 8.8 (Berkeley) 7/20/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "btree.h" - -/* - * __bt_ret -- - * Build return key/data pair. - * - * Parameters: - * t: tree - * e: key/data pair to be returned - * key: user's key structure (NULL if not to be filled in) - * rkey: memory area to hold key - * data: user's data structure (NULL if not to be filled in) - * rdata: memory area to hold data - * copy: always copy the key/data item - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -int -__bt_ret(t, e, key, rkey, data, rdata, copy) - BTREE *t; - EPG *e; - DBT *key, *rkey, *data, *rdata; - int copy; -{ - BLEAF *bl; - void *p; - - bl = GETBLEAF(e->page, e->index); - - /* - * We must copy big keys/data to make them contigous. Otherwise, - * leave the page pinned and don't copy unless the user specified - * concurrent access. - */ - if (key == NULL) - goto dataonly; - - if (bl->flags & P_BIGKEY) { - if (__ovfl_get(t, bl->bytes, - &key->size, &rkey->data, &rkey->size)) - return (RET_ERROR); - key->data = rkey->data; - } else if (copy || F_ISSET(t, B_DB_LOCK)) { - if (bl->ksize > rkey->size) { - p = (void *)(rkey->data == NULL ? - malloc(bl->ksize) : realloc(rkey->data, bl->ksize)); - if (p == NULL) - return (RET_ERROR); - rkey->data = p; - rkey->size = bl->ksize; - } - memmove(rkey->data, bl->bytes, bl->ksize); - key->size = bl->ksize; - key->data = rkey->data; - } else { - key->size = bl->ksize; - key->data = bl->bytes; - } - -dataonly: - if (data == NULL) - return (RET_SUCCESS); - - if (bl->flags & P_BIGDATA) { - if (__ovfl_get(t, bl->bytes + bl->ksize, - &data->size, &rdata->data, &rdata->size)) - return (RET_ERROR); - data->data = rdata->data; - } else if (copy || F_ISSET(t, B_DB_LOCK)) { - /* Use +1 in case the first record retrieved is 0 length. */ - if (bl->dsize + 1 > rdata->size) { - p = (void *)(rdata->data == NULL ? - malloc(bl->dsize + 1) : - realloc(rdata->data, bl->dsize + 1)); - if (p == NULL) - return (RET_ERROR); - rdata->data = p; - rdata->size = bl->dsize + 1; - } - memmove(rdata->data, bl->bytes + bl->ksize, bl->dsize); - data->size = bl->dsize; - data->data = rdata->data; - } else { - data->size = bl->dsize; - data->data = bl->bytes + bl->ksize; - } - - return (RET_SUCCESS); -} - -/* - * __BT_CMP -- Compare a key to a given record. - * - * Parameters: - * t: tree - * k1: DBT pointer of first arg to comparison - * e: pointer to EPG for comparison - * - * Returns: - * < 0 if k1 is < record - * = 0 if k1 is = record - * > 0 if k1 is > record - */ -int -__bt_cmp(t, k1, e) - BTREE *t; - const DBT *k1; - EPG *e; -{ - BINTERNAL *bi; - BLEAF *bl; - DBT k2; - PAGE *h; - void *bigkey; - - /* - * The left-most key on internal pages, at any level of the tree, is - * guaranteed by the following code to be less than any user key. - * This saves us from having to update the leftmost key on an internal - * page when the user inserts a new key in the tree smaller than - * anything we've yet seen. - */ - h = e->page; - if (e->index == 0 && h->prevpg == P_INVALID && !(h->flags & P_BLEAF)) - return (1); - - bigkey = NULL; - if (h->flags & P_BLEAF) { - bl = GETBLEAF(h, e->index); - if (bl->flags & P_BIGKEY) - bigkey = bl->bytes; - else { - k2.data = bl->bytes; - k2.size = bl->ksize; - } - } else { - bi = GETBINTERNAL(h, e->index); - if (bi->flags & P_BIGKEY) - bigkey = bi->bytes; - else { - k2.data = bi->bytes; - k2.size = bi->ksize; - } - } - - if (bigkey) { - if (__ovfl_get(t, bigkey, - &k2.size, &t->bt_rdata.data, &t->bt_rdata.size)) - return (RET_ERROR); - k2.data = t->bt_rdata.data; - } - return ((*t->bt_cmp)(k1, &k2)); -} - -/* - * __BT_DEFCMP -- Default comparison routine. - * - * Parameters: - * a: DBT #1 - * b: DBT #2 - * - * Returns: - * < 0 if a is < b - * = 0 if a is = b - * > 0 if a is > b - */ -int -__bt_defcmp(a, b) - const DBT *a, *b; -{ - register size_t len; - register u_char *p1, *p2; - - /* - * XXX - * If a size_t doesn't fit in an int, this routine can lose. - * What we need is a integral type which is guaranteed to be - * larger than a size_t, and there is no such thing. - */ - len = MIN(a->size, b->size); - for (p1 = a->data, p2 = b->data; len--; ++p1, ++p2) - if (*p1 != *p2) - return ((int)*p1 - (int)*p2); - return ((int)a->size - (int)b->size); -} - -/* - * __BT_DEFPFX -- Default prefix routine. - * - * Parameters: - * a: DBT #1 - * b: DBT #2 - * - * Returns: - * Number of bytes needed to distinguish b from a. - */ -size_t -__bt_defpfx(a, b) - const DBT *a, *b; -{ - register u_char *p1, *p2; - register size_t cnt, len; - - cnt = 1; - len = MIN(a->size, b->size); - for (p1 = a->data, p2 = b->data; len--; ++p1, ++p2, ++cnt) - if (*p1 != *p2) - return (cnt); - - /* a->size must be <= b->size, or they wouldn't be in this order. */ - return (a->size < b->size ? a->size + 1 : a->size); -} diff --git a/lib/libc/db/btree/btree.h b/lib/libc/db/btree/btree.h deleted file mode 100644 index 36d35c9..0000000 --- a/lib/libc/db/btree/btree.h +++ /dev/null @@ -1,383 +0,0 @@ -/*- - * Copyright (c) 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)btree.h 8.11 (Berkeley) 8/17/94 - */ - -/* Macros to set/clear/test flags. */ -#define F_SET(p, f) (p)->flags |= (f) -#define F_CLR(p, f) (p)->flags &= ~(f) -#define F_ISSET(p, f) ((p)->flags & (f)) - -#include - -#define DEFMINKEYPAGE (2) /* Minimum keys per page */ -#define MINCACHE (5) /* Minimum cached pages */ -#define MINPSIZE (512) /* Minimum page size */ - -/* - * Page 0 of a btree file contains a copy of the meta-data. This page is also - * used as an out-of-band page, i.e. page pointers that point to nowhere point - * to page 0. Page 1 is the root of the btree. - */ -#define P_INVALID 0 /* Invalid tree page number. */ -#define P_META 0 /* Tree metadata page number. */ -#define P_ROOT 1 /* Tree root page number. */ - -/* - * There are five page layouts in the btree: btree internal pages (BINTERNAL), - * btree leaf pages (BLEAF), recno internal pages (RINTERNAL), recno leaf pages - * (RLEAF) and overflow pages. All five page types have a page header (PAGE). - * This implementation requires that values within structures NOT be padded. - * (ANSI C permits random padding.) If your compiler pads randomly you'll have - * to do some work to get this package to run. - */ -typedef struct _page { - pgno_t pgno; /* this page's page number */ - pgno_t prevpg; /* left sibling */ - pgno_t nextpg; /* right sibling */ - -#define P_BINTERNAL 0x01 /* btree internal page */ -#define P_BLEAF 0x02 /* leaf page */ -#define P_OVERFLOW 0x04 /* overflow page */ -#define P_RINTERNAL 0x08 /* recno internal page */ -#define P_RLEAF 0x10 /* leaf page */ -#define P_TYPE 0x1f /* type mask */ -#define P_PRESERVE 0x20 /* never delete this chain of pages */ - u_int32_t flags; - - indx_t lower; /* lower bound of free space on page */ - indx_t upper; /* upper bound of free space on page */ - indx_t linp[1]; /* indx_t-aligned VAR. LENGTH DATA */ -} PAGE; - -/* First and next index. */ -#define BTDATAOFF \ - (sizeof(pgno_t) + sizeof(pgno_t) + sizeof(pgno_t) + \ - sizeof(u_int32_t) + sizeof(indx_t) + sizeof(indx_t)) -#define NEXTINDEX(p) (((p)->lower - BTDATAOFF) / sizeof(indx_t)) - -/* - * For pages other than overflow pages, there is an array of offsets into the - * rest of the page immediately following the page header. Each offset is to - * an item which is unique to the type of page. The h_lower offset is just - * past the last filled-in index. The h_upper offset is the first item on the - * page. Offsets are from the beginning of the page. - * - * If an item is too big to store on a single page, a flag is set and the item - * is a { page, size } pair such that the page is the first page of an overflow - * chain with size bytes of item. Overflow pages are simply bytes without any - * external structure. - * - * The page number and size fields in the items are pgno_t-aligned so they can - * be manipulated without copying. (This presumes that 32 bit items can be - * manipulated on this system.) - */ -#define LALIGN(n) (((n) + sizeof(pgno_t) - 1) & ~(sizeof(pgno_t) - 1)) -#define NOVFLSIZE (sizeof(pgno_t) + sizeof(u_int32_t)) - -/* - * For the btree internal pages, the item is a key. BINTERNALs are {key, pgno} - * pairs, such that the key compares less than or equal to all of the records - * on that page. For a tree without duplicate keys, an internal page with two - * consecutive keys, a and b, will have all records greater than or equal to a - * and less than b stored on the page associated with a. Duplicate keys are - * somewhat special and can cause duplicate internal and leaf page records and - * some minor modifications of the above rule. - */ -typedef struct _binternal { - u_int32_t ksize; /* key size */ - pgno_t pgno; /* page number stored on */ -#define P_BIGDATA 0x01 /* overflow data */ -#define P_BIGKEY 0x02 /* overflow key */ - u_char flags; - char bytes[1]; /* data */ -} BINTERNAL; - -/* Get the page's BINTERNAL structure at index indx. */ -#define GETBINTERNAL(pg, indx) \ - ((BINTERNAL *)((char *)(pg) + (pg)->linp[indx])) - -/* Get the number of bytes in the entry. */ -#define NBINTERNAL(len) \ - LALIGN(sizeof(u_int32_t) + sizeof(pgno_t) + sizeof(u_char) + (len)) - -/* Copy a BINTERNAL entry to the page. */ -#define WR_BINTERNAL(p, size, pgno, flags) { \ - *(u_int32_t *)p = size; \ - p += sizeof(u_int32_t); \ - *(pgno_t *)p = pgno; \ - p += sizeof(pgno_t); \ - *(u_char *)p = flags; \ - p += sizeof(u_char); \ -} - -/* - * For the recno internal pages, the item is a page number with the number of - * keys found on that page and below. - */ -typedef struct _rinternal { - recno_t nrecs; /* number of records */ - pgno_t pgno; /* page number stored below */ -} RINTERNAL; - -/* Get the page's RINTERNAL structure at index indx. */ -#define GETRINTERNAL(pg, indx) \ - ((RINTERNAL *)((char *)(pg) + (pg)->linp[indx])) - -/* Get the number of bytes in the entry. */ -#define NRINTERNAL \ - LALIGN(sizeof(recno_t) + sizeof(pgno_t)) - -/* Copy a RINTERAL entry to the page. */ -#define WR_RINTERNAL(p, nrecs, pgno) { \ - *(recno_t *)p = nrecs; \ - p += sizeof(recno_t); \ - *(pgno_t *)p = pgno; \ -} - -/* For the btree leaf pages, the item is a key and data pair. */ -typedef struct _bleaf { - u_int32_t ksize; /* size of key */ - u_int32_t dsize; /* size of data */ - u_char flags; /* P_BIGDATA, P_BIGKEY */ - char bytes[1]; /* data */ -} BLEAF; - -/* Get the page's BLEAF structure at index indx. */ -#define GETBLEAF(pg, indx) \ - ((BLEAF *)((char *)(pg) + (pg)->linp[indx])) - -/* Get the number of bytes in the entry. */ -#define NBLEAF(p) NBLEAFDBT((p)->ksize, (p)->dsize) - -/* Get the number of bytes in the user's key/data pair. */ -#define NBLEAFDBT(ksize, dsize) \ - LALIGN(sizeof(u_int32_t) + sizeof(u_int32_t) + sizeof(u_char) + \ - (ksize) + (dsize)) - -/* Copy a BLEAF entry to the page. */ -#define WR_BLEAF(p, key, data, flags) { \ - *(u_int32_t *)p = key->size; \ - p += sizeof(u_int32_t); \ - *(u_int32_t *)p = data->size; \ - p += sizeof(u_int32_t); \ - *(u_char *)p = flags; \ - p += sizeof(u_char); \ - memmove(p, key->data, key->size); \ - p += key->size; \ - memmove(p, data->data, data->size); \ -} - -/* For the recno leaf pages, the item is a data entry. */ -typedef struct _rleaf { - u_int32_t dsize; /* size of data */ - u_char flags; /* P_BIGDATA */ - char bytes[1]; -} RLEAF; - -/* Get the page's RLEAF structure at index indx. */ -#define GETRLEAF(pg, indx) \ - ((RLEAF *)((char *)(pg) + (pg)->linp[indx])) - -/* Get the number of bytes in the entry. */ -#define NRLEAF(p) NRLEAFDBT((p)->dsize) - -/* Get the number of bytes from the user's data. */ -#define NRLEAFDBT(dsize) \ - LALIGN(sizeof(u_int32_t) + sizeof(u_char) + (dsize)) - -/* Copy a RLEAF entry to the page. */ -#define WR_RLEAF(p, data, flags) { \ - *(u_int32_t *)p = data->size; \ - p += sizeof(u_int32_t); \ - *(u_char *)p = flags; \ - p += sizeof(u_char); \ - memmove(p, data->data, data->size); \ -} - -/* - * A record in the tree is either a pointer to a page and an index in the page - * or a page number and an index. These structures are used as a cursor, stack - * entry and search returns as well as to pass records to other routines. - * - * One comment about searches. Internal page searches must find the largest - * record less than key in the tree so that descents work. Leaf page searches - * must find the smallest record greater than key so that the returned index - * is the record's correct position for insertion. - */ -typedef struct _epgno { - pgno_t pgno; /* the page number */ - indx_t index; /* the index on the page */ -} EPGNO; - -typedef struct _epg { - PAGE *page; /* the (pinned) page */ - indx_t index; /* the index on the page */ -} EPG; - -/* - * About cursors. The cursor (and the page that contained the key/data pair - * that it referenced) can be deleted, which makes things a bit tricky. If - * there are no duplicates of the cursor key in the tree (i.e. B_NODUPS is set - * or there simply aren't any duplicates of the key) we copy the key that it - * referenced when it's deleted, and reacquire a new cursor key if the cursor - * is used again. If there are duplicates keys, we move to the next/previous - * key, and set a flag so that we know what happened. NOTE: if duplicate (to - * the cursor) keys are added to the tree during this process, it is undefined - * if they will be returned or not in a cursor scan. - * - * The flags determine the possible states of the cursor: - * - * CURS_INIT The cursor references *something*. - * CURS_ACQUIRE The cursor was deleted, and a key has been saved so that - * we can reacquire the right position in the tree. - * CURS_AFTER, CURS_BEFORE - * The cursor was deleted, and now references a key/data pair - * that has not yet been returned, either before or after the - * deleted key/data pair. - * XXX - * This structure is broken out so that we can eventually offer multiple - * cursors as part of the DB interface. - */ -typedef struct _cursor { - EPGNO pg; /* B: Saved tree reference. */ - DBT key; /* B: Saved key, or key.data == NULL. */ - recno_t rcursor; /* R: recno cursor (1-based) */ - -#define CURS_ACQUIRE 0x01 /* B: Cursor needs to be reacquired. */ -#define CURS_AFTER 0x02 /* B: Unreturned cursor after key. */ -#define CURS_BEFORE 0x04 /* B: Unreturned cursor before key. */ -#define CURS_INIT 0x08 /* RB: Cursor initialized. */ - u_int8_t flags; -} CURSOR; - -/* - * The metadata of the tree. The nrecs field is used only by the RECNO code. - * This is because the btree doesn't really need it and it requires that every - * put or delete call modify the metadata. - */ -typedef struct _btmeta { - u_int32_t magic; /* magic number */ - u_int32_t version; /* version */ - u_int32_t psize; /* page size */ - u_int32_t free; /* page number of first free page */ - u_int32_t nrecs; /* R: number of records */ - -#define SAVEMETA (B_NODUPS | R_RECNO) - u_int32_t flags; /* bt_flags & SAVEMETA */ -} BTMETA; - -/* The in-memory btree/recno data structure. */ -typedef struct _btree { - MPOOL *bt_mp; /* memory pool cookie */ - - DB *bt_dbp; /* pointer to enclosing DB */ - - EPG bt_cur; /* current (pinned) page */ - PAGE *bt_pinned; /* page pinned across calls */ - - CURSOR bt_cursor; /* cursor */ - -#define BT_PUSH(t, p, i) { \ - t->bt_sp->pgno = p; \ - t->bt_sp->index = i; \ - ++t->bt_sp; \ -} -#define BT_POP(t) (t->bt_sp == t->bt_stack ? NULL : --t->bt_sp) -#define BT_CLR(t) (t->bt_sp = t->bt_stack) - EPGNO bt_stack[50]; /* stack of parent pages */ - EPGNO *bt_sp; /* current stack pointer */ - - DBT bt_rkey; /* returned key */ - DBT bt_rdata; /* returned data */ - - int bt_fd; /* tree file descriptor */ - - pgno_t bt_free; /* next free page */ - u_int32_t bt_psize; /* page size */ - indx_t bt_ovflsize; /* cut-off for key/data overflow */ - int bt_lorder; /* byte order */ - /* sorted order */ - enum { NOT, BACK, FORWARD } bt_order; - EPGNO bt_last; /* last insert */ - - /* B: key comparison function */ - int (*bt_cmp) __P((const DBT *, const DBT *)); - /* B: prefix comparison function */ - size_t (*bt_pfx) __P((const DBT *, const DBT *)); - /* R: recno input function */ - int (*bt_irec) __P((struct _btree *, recno_t)); - - FILE *bt_rfp; /* R: record FILE pointer */ - int bt_rfd; /* R: record file descriptor */ - - caddr_t bt_cmap; /* R: current point in mapped space */ - caddr_t bt_smap; /* R: start of mapped space */ - caddr_t bt_emap; /* R: end of mapped space */ - size_t bt_msize; /* R: size of mapped region. */ - - recno_t bt_nrecs; /* R: number of records */ - size_t bt_reclen; /* R: fixed record length */ - u_char bt_bval; /* R: delimiting byte/pad character */ - -/* - * NB: - * B_NODUPS and R_RECNO are stored on disk, and may not be changed. - */ -#define B_INMEM 0x00001 /* in-memory tree */ -#define B_METADIRTY 0x00002 /* need to write metadata */ -#define B_MODIFIED 0x00004 /* tree modified */ -#define B_NEEDSWAP 0x00008 /* if byte order requires swapping */ -#define B_RDONLY 0x00010 /* read-only tree */ - -#define B_NODUPS 0x00020 /* no duplicate keys permitted */ -#define R_RECNO 0x00080 /* record oriented tree */ - -#define R_CLOSEFP 0x00040 /* opened a file pointer */ -#define R_EOF 0x00100 /* end of input file reached. */ -#define R_FIXLEN 0x00200 /* fixed length records */ -#define R_MEMMAPPED 0x00400 /* memory mapped file. */ -#define R_INMEM 0x00800 /* in-memory file */ -#define R_MODIFIED 0x01000 /* modified file */ -#define R_RDONLY 0x02000 /* read-only file */ - -#define B_DB_LOCK 0x04000 /* DB_LOCK specified. */ -#define B_DB_SHMEM 0x08000 /* DB_SHMEM specified. */ -#define B_DB_TXN 0x10000 /* DB_TXN specified. */ - u_int32_t flags; -} BTREE; - -#include "extern.h" diff --git a/lib/libc/db/btree/extern.h b/lib/libc/db/btree/extern.h deleted file mode 100644 index ebd9c54..0000000 --- a/lib/libc/db/btree/extern.h +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * Copyright (c) 1991, 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. - * - * @(#)extern.h 8.10 (Berkeley) 7/20/94 - */ - -int __bt_close __P((DB *)); -int __bt_cmp __P((BTREE *, const DBT *, EPG *)); -int __bt_crsrdel __P((BTREE *, EPGNO *)); -int __bt_defcmp __P((const DBT *, const DBT *)); -size_t __bt_defpfx __P((const DBT *, const DBT *)); -int __bt_delete __P((const DB *, const DBT *, u_int)); -int __bt_dleaf __P((BTREE *, const DBT *, PAGE *, u_int)); -int __bt_fd __P((const DB *)); -int __bt_free __P((BTREE *, PAGE *)); -int __bt_get __P((const DB *, const DBT *, DBT *, u_int)); -PAGE *__bt_new __P((BTREE *, pgno_t *)); -void __bt_pgin __P((void *, pgno_t, void *)); -void __bt_pgout __P((void *, pgno_t, void *)); -int __bt_push __P((BTREE *, pgno_t, int)); -int __bt_put __P((const DB *dbp, DBT *, const DBT *, u_int)); -int __bt_ret __P((BTREE *, EPG *, DBT *, DBT *, DBT *, DBT *, int)); -EPG *__bt_search __P((BTREE *, const DBT *, int *)); -int __bt_seq __P((const DB *, DBT *, DBT *, u_int)); -void __bt_setcur __P((BTREE *, pgno_t, u_int)); -int __bt_split __P((BTREE *, PAGE *, - const DBT *, const DBT *, int, size_t, u_int32_t)); -int __bt_sync __P((const DB *, u_int)); - -int __ovfl_delete __P((BTREE *, void *)); -int __ovfl_get __P((BTREE *, void *, size_t *, void **, size_t *)); -int __ovfl_put __P((BTREE *, const DBT *, pgno_t *)); - -#ifdef DEBUG -void __bt_dnpage __P((DB *, pgno_t)); -void __bt_dpage __P((PAGE *)); -void __bt_dump __P((DB *)); -#endif -#ifdef STATISTICS -void __bt_stat __P((DB *)); -#endif diff --git a/lib/libc/db/changelog b/lib/libc/db/changelog deleted file mode 100644 index 1540ca8..0000000 --- a/lib/libc/db/changelog +++ /dev/null @@ -1,103 +0,0 @@ -1.84 -> 1.85 - recno: #ifdef out use of mmap, it's not portable enough. - -1.83 -> 1.84 Thu Aug 18 15:46:07 EDT 1994 - recno: Rework fixed-length records so that closing and reopening - the file now works. Pad short records on input. Never do - signed comparison in recno input reading functions. - -1.82 -> 1.83 Tue Jul 26 15:33:44 EDT 1994 - btree: Rework cursor deletion code yet again; bugs with - deleting empty pages that only contained the cursor - record. - -1.81 -> 1.82 Sat Jul 16 11:01:50 EDT 1994 - btree: Fix bugs introduced by new cursor/deletion code. - Replace return kbuf/dbuf with real DBT's. - -1.80 -> 1.81 - btree: Fix bugs introduced by new cursor/deletion code. - all: Add #defines for Purify. - -1.79 -> 1.80 Wed Jul 13 22:41:54 EDT 1994 - btree Change deletion to coalesce empty pages. This is a major - change, cursors and duplicate pages all had to be reworked. - Return to a fixed stack. - recno: Affected by cursor changes. New cursor structures should - permit multiple cursors in the future. - -1.78 -> 1.79 Mon Jun 20 17:36:47 EDT 1994 - all: Minor cleanups of 1.78 for porting reasons; only - major change was inlining check of NULL pointer - so that __fix_realloc goes away. - -1.77 -> 1.78 Thu Jun 16 19:06:43 EDT 1994 - all: Move "standard" size typedef's into db.h. - -1.76 -> 1.77 Thu Jun 16 16:48:38 EDT 1994 - hash: Delete __init_ routine, has special meaning to OSF 2.0. - -1.74 -> 1.76 - all: Finish up the port to the Alpha. - -1.73 -> 1.74 - recno: Don't put the record if rec_search fails, in rec_rdelete. - Create fixed-length intermediate records past "end" of DB - correctly. - Realloc bug when reading in fixed records. - all: First cut at port to Alpha (64-bit architecture) using - 4.4BSD basic integral types typedef's. - Cast allocation pointers to shut up old compilers. - Rework PORT directory into OS/machine directories. - -1.72 -> 1.73 - btree: If enough duplicate records were inserted and then deleted - that internal pages had references to empty pages of the - duplicate keys, the search function ended up on the wrong - page. - -1.7 -> 1.72 12 Oct 1993 - hash: Support NET/2 hash formats. - -1.7 -> 1.71 16 Sep 1993 - btree/recno: - Fix bug in internal search routines that caused - return of invalid pointers. - -1.6 -> 1.7 07 Sep 1993 - hash: Fixed big key overflow bugs. - test: Portability hacks, rewrite test script, Makefile. - btree/recno: - Stop copying non-overflow key/data pairs. - PORT: Break PORT directory up into per architecture/OS - subdirectories. - -1.5 -> 1.6 06 Jun 1993 - hash: In PAIRFITS, the first comparison should look at (P)[2]. - The hash_realloc function was walking off the end of memory. - The overflow page number was wrong when bumping splitpoint. - -1.4 -> 1.5 23 May 1993 - hash: Set hash default fill factor dynamically. - recno: Fixed bug in sorted page splits. - Add page size parameter support. - Allow recno to specify the name of the underlying btree; - used for vi recovery. - btree/recno: - Support 64K pages. - btree/hash/recno: - Provide access to an underlying file descriptor. - Change sync routines to take a flag argument, recno - uses this to sync out the underlying btree. - -1.3 -> 1.4 10 May 1993 - recno: Delete the R_CURSORLOG flag from the recno interface. - Zero-length record fix for non-mmap reads. - Try and make SIZE_T_MAX test in open portable. - -1.2 -> 1.3 01 May 1993 - btree: Ignore user byte-order setting when reading already - existing database. Fixes to byte-order conversions. - -1.1 -> 1.2 15 Apr 1993 - No bug fixes, only compatibility hacks. diff --git a/lib/libc/db/db/Makefile.inc b/lib/libc/db/db/Makefile.inc deleted file mode 100644 index 03cb1a8..0000000 --- a/lib/libc/db/db/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 -# $FreeBSD$ - -.PATH: ${.CURDIR}/../libc/db/db - -SRCS+= db.c diff --git a/lib/libc/db/db/db.c b/lib/libc/db/db/db.c deleted file mode 100644 index a18f056..0000000 --- a/lib/libc/db/db/db.c +++ /dev/null @@ -1,99 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)db.c 8.4 (Berkeley) 2/21/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include - -#include - -DB * -dbopen(fname, flags, mode, type, openinfo) - const char *fname; - int flags, mode; - DBTYPE type; - const void *openinfo; -{ - -#define DB_FLAGS (DB_LOCK | DB_SHMEM | DB_TXN) -#define USE_OPEN_FLAGS \ - (O_CREAT | O_EXCL | O_EXLOCK | O_NONBLOCK | O_RDONLY | \ - O_RDWR | O_SHLOCK | O_TRUNC) - - if ((flags & ~(USE_OPEN_FLAGS | DB_FLAGS)) == 0) - switch (type) { - case DB_BTREE: - return (__bt_open(fname, flags & USE_OPEN_FLAGS, - mode, openinfo, flags & DB_FLAGS)); - case DB_HASH: - return (__hash_open(fname, flags & USE_OPEN_FLAGS, - mode, openinfo, flags & DB_FLAGS)); - case DB_RECNO: - return (__rec_open(fname, flags & USE_OPEN_FLAGS, - mode, openinfo, flags & DB_FLAGS)); - } - errno = EINVAL; - return (NULL); -} - -static int -__dberr() -{ - return (RET_ERROR); -} - -/* - * __DBPANIC -- Stop. - * - * Parameters: - * dbp: pointer to the DB structure. - */ -void -__dbpanic(dbp) - DB *dbp; -{ - /* The only thing that can succeed is a close. */ - dbp->del = (int (*)())__dberr; - dbp->fd = (int (*)())__dberr; - dbp->get = (int (*)())__dberr; - dbp->put = (int (*)())__dberr; - dbp->seq = (int (*)())__dberr; - dbp->sync = (int (*)())__dberr; -} diff --git a/lib/libc/db/docs/hash.usenix.ps b/lib/libc/db/docs/hash.usenix.ps deleted file mode 100644 index 3a0cf44..0000000 --- a/lib/libc/db/docs/hash.usenix.ps +++ /dev/null @@ -1,12209 +0,0 @@ -%!PS-Adobe-1.0 -%%Creator: utopia:margo (& Seltzer,608-13E,8072,) -%%Title: stdin (ditroff) -%%CreationDate: Tue Dec 11 15:06:45 1990 -%%EndComments -% @(#)psdit.pro 1.3 4/15/88 -% lib/psdit.pro -- prolog for psdit (ditroff) files -% Copyright (c) 1984, 1985 Adobe Systems Incorporated. All Rights Reserved. -% last edit: shore Sat Nov 23 20:28:03 1985 -% RCSID: $FreeBSD$ - -% Changed by Edward Wang (edward@ucbarpa.berkeley.edu) to handle graphics, -% 17 Feb, 87. - -/$DITroff 140 dict def $DITroff begin -/fontnum 1 def /fontsize 10 def /fontheight 10 def /fontslant 0 def -/xi{0 72 11 mul translate 72 resolution div dup neg scale 0 0 moveto - /fontnum 1 def /fontsize 10 def /fontheight 10 def /fontslant 0 def F - /pagesave save def}def -/PB{save /psv exch def currentpoint translate - resolution 72 div dup neg scale 0 0 moveto}def -/PE{psv restore}def -/arctoobig 90 def /arctoosmall .05 def -/m1 matrix def /m2 matrix def /m3 matrix def /oldmat matrix def -/tan{dup sin exch cos div}def -/point{resolution 72 div mul}def -/dround {transform round exch round exch itransform}def -/xT{/devname exch def}def -/xr{/mh exch def /my exch def /resolution exch def}def -/xp{}def -/xs{docsave restore end}def -/xt{}def -/xf{/fontname exch def /slotno exch def fontnames slotno get fontname eq not - {fonts slotno fontname findfont put fontnames slotno fontname put}if}def -/xH{/fontheight exch def F}def -/xS{/fontslant exch def F}def -/s{/fontsize exch def /fontheight fontsize def F}def -/f{/fontnum exch def F}def -/F{fontheight 0 le{/fontheight fontsize def}if - fonts fontnum get fontsize point 0 0 fontheight point neg 0 0 m1 astore - fontslant 0 ne{1 0 fontslant tan 1 0 0 m2 astore m3 concatmatrix}if - makefont setfont .04 fontsize point mul 0 dround pop setlinewidth}def -/X{exch currentpoint exch pop moveto show}def -/N{3 1 roll moveto show}def -/Y{exch currentpoint pop exch moveto show}def -/S{show}def -/ditpush{}def/ditpop{}def -/AX{3 -1 roll currentpoint exch pop moveto 0 exch ashow}def -/AN{4 2 roll moveto 0 exch ashow}def -/AY{3 -1 roll currentpoint pop exch moveto 0 exch ashow}def -/AS{0 exch ashow}def -/MX{currentpoint exch pop moveto}def -/MY{currentpoint pop exch moveto}def -/MXY{moveto}def -/cb{pop}def % action on unknown char -- nothing for now -/n{}def/w{}def -/p{pop showpage pagesave restore /pagesave save def}def -/Dt{/Dlinewidth exch def}def 1 Dt -/Ds{/Ddash exch def}def -1 Ds -/Di{/Dstipple exch def}def 1 Di -/Dsetlinewidth{2 Dlinewidth mul setlinewidth}def -/Dsetdash{Ddash 4 eq{[8 12]}{Ddash 16 eq{[32 36]} - {Ddash 20 eq{[32 12 8 12]}{[]}ifelse}ifelse}ifelse 0 setdash}def -/Dstroke{gsave Dsetlinewidth Dsetdash 1 setlinecap stroke grestore - currentpoint newpath moveto}def -/Dl{rlineto Dstroke}def -/arcellipse{/diamv exch def /diamh exch def oldmat currentmatrix pop - currentpoint translate 1 diamv diamh div scale /rad diamh 2 div def - currentpoint exch rad add exch rad -180 180 arc oldmat setmatrix}def -/Dc{dup arcellipse Dstroke}def -/De{arcellipse Dstroke}def -/Da{/endv exch def /endh exch def /centerv exch def /centerh exch def - /cradius centerv centerv mul centerh centerh mul add sqrt def - /eradius endv endv mul endh endh mul add sqrt def - /endang endv endh atan def - /startang centerv neg centerh neg atan def - /sweep startang endang sub dup 0 lt{360 add}if def - sweep arctoobig gt - {/midang startang sweep 2 div sub def /midrad cradius eradius add 2 div def - /midh midang cos midrad mul def /midv midang sin midrad mul def - midh neg midv neg endh endv centerh centerv midh midv Da - Da} - {sweep arctoosmall ge - {/controldelt 1 sweep 2 div cos sub 3 sweep 2 div sin mul div 4 mul def - centerv neg controldelt mul centerh controldelt mul - endv neg controldelt mul centerh add endh add - endh controldelt mul centerv add endv add - centerh endh add centerv endv add rcurveto Dstroke} - {centerh endh add centerv endv add rlineto Dstroke} - ifelse} - ifelse}def -/Dpatterns[ -[%cf[widthbits] -[8<0000000000000010>] -[8<0411040040114000>] -[8<0204081020408001>] -[8<0000103810000000>] -[8<6699996666999966>] -[8<0000800100001008>] -[8<81c36666c3810000>] -[8<0f0e0c0800000000>] -[8<0000000000000010>] -[8<0411040040114000>] -[8<0204081020408001>] -[8<0000001038100000>] -[8<6699996666999966>] -[8<0000800100001008>] -[8<81c36666c3810000>] -[8<0f0e0c0800000000>] -[8<0042660000246600>] -[8<0000990000990000>] -[8<0804020180402010>] -[8<2418814242811824>] -[8<6699996666999966>] -[8<8000000008000000>] -[8<00001c3e363e1c00>] -[8<0000000000000000>] -[32<00000040000000c00000004000000040000000e0000000000000000000000000>] -[32<00000000000060000000900000002000000040000000f0000000000000000000>] -[32<000000000000000000e0000000100000006000000010000000e0000000000000>] -[32<00000000000000002000000060000000a0000000f00000002000000000000000>] -[32<0000000e0000000000000000000000000000000f000000080000000e00000001>] -[32<0000090000000600000000000000000000000000000007000000080000000e00>] -[32<00010000000200000004000000040000000000000000000000000000000f0000>] -[32<0900000006000000090000000600000000000000000000000000000006000000>]] -[%ug -[8<0000020000000000>] -[8<0000020000002000>] -[8<0004020000002000>] -[8<0004020000402000>] -[8<0004060000402000>] -[8<0004060000406000>] -[8<0006060000406000>] -[8<0006060000606000>] -[8<00060e0000606000>] -[8<00060e000060e000>] -[8<00070e000060e000>] -[8<00070e000070e000>] -[8<00070e020070e000>] -[8<00070e020070e020>] -[8<04070e020070e020>] -[8<04070e024070e020>] -[8<04070e064070e020>] -[8<04070e064070e060>] -[8<06070e064070e060>] -[8<06070e066070e060>] -[8<06070f066070e060>] -[8<06070f066070f060>] -[8<060f0f066070f060>] -[8<060f0f0660f0f060>] -[8<060f0f0760f0f060>] -[8<060f0f0760f0f070>] -[8<0e0f0f0760f0f070>] -[8<0e0f0f07e0f0f070>] -[8<0e0f0f0fe0f0f070>] -[8<0e0f0f0fe0f0f0f0>] -[8<0f0f0f0fe0f0f0f0>] -[8<0f0f0f0ff0f0f0f0>] -[8<1f0f0f0ff0f0f0f0>] -[8<1f0f0f0ff1f0f0f0>] -[8<1f0f0f8ff1f0f0f0>] -[8<1f0f0f8ff1f0f0f8>] -[8<9f0f0f8ff1f0f0f8>] -[8<9f0f0f8ff9f0f0f8>] -[8<9f0f0f9ff9f0f0f8>] -[8<9f0f0f9ff9f0f0f9>] -[8<9f8f0f9ff9f0f0f9>] -[8<9f8f0f9ff9f8f0f9>] -[8<9f8f1f9ff9f8f0f9>] -[8<9f8f1f9ff9f8f1f9>] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8]] -[%mg -[8<8000000000000000>] -[8<0822080080228000>] -[8<0204081020408001>] -[8<40e0400000000000>] -[8<66999966>] -[8<8001000010080000>] -[8<81c36666c3810000>] -[8] -[16<07c00f801f003e007c00f800f001e003c007800f001f003e007c00f801f003e0>] -[16<1f000f8007c003e001f000f8007c003e001f800fc007e003f001f8007c003e00>] -[8] -[16<0040008001000200040008001000200040008000000100020004000800100020>] -[16<0040002000100008000400020001800040002000100008000400020001000080>] -[16<1fc03fe07df0f8f8f07de03fc01f800fc01fe03ff07df8f87df03fe01fc00f80>] -[8<80>] -[8<8040201000000000>] -[8<84cc000048cc0000>] -[8<9900009900000000>] -[8<08040201804020100800020180002010>] -[8<2418814242811824>] -[8<66999966>] -[8<8000000008000000>] -[8<70f8d8f870000000>] -[8<0814224180402010>] -[8] -[8<018245aa45820100>] -[8<221c224180808041>] -[8<88000000>] -[8<0855800080550800>] -[8<2844004482440044>] -[8<0810204080412214>] -[8<00>]]]def -/Dfill{ - transform /maxy exch def /maxx exch def - transform /miny exch def /minx exch def - minx maxx gt{/minx maxx /maxx minx def def}if - miny maxy gt{/miny maxy /maxy miny def def}if - Dpatterns Dstipple 1 sub get exch 1 sub get - aload pop /stip exch def /stipw exch def /stiph 128 def - /imatrix[stipw 0 0 stiph 0 0]def - /tmatrix[stipw 0 0 stiph 0 0]def - /minx minx cvi stiph idiv stiph mul def - /miny miny cvi stipw idiv stipw mul def - gsave eoclip 0 setgray - miny stiph maxy{ - tmatrix exch 5 exch put - minx stipw maxx{ - tmatrix exch 4 exch put tmatrix setmatrix - stipw stiph true imatrix {stip} imagemask - }for - }for - grestore -}def -/Dp{Dfill Dstroke}def -/DP{Dfill currentpoint newpath moveto}def -end - -/ditstart{$DITroff begin - /nfonts 60 def % NFONTS makedev/ditroff dependent! - /fonts[nfonts{0}repeat]def - /fontnames[nfonts{()}repeat]def -/docsave save def -}def - -% character outcalls -/oc{ - /pswid exch def /cc exch def /name exch def - /ditwid pswid fontsize mul resolution mul 72000 div def - /ditsiz fontsize resolution mul 72 div def - ocprocs name known{ocprocs name get exec}{name cb}ifelse -}def -/fractm [.65 0 0 .6 0 0] def -/fraction{ - /fden exch def /fnum exch def gsave /cf currentfont def - cf fractm makefont setfont 0 .3 dm 2 copy neg rmoveto - fnum show rmoveto currentfont cf setfont(\244)show setfont fden show - grestore ditwid 0 rmoveto -}def -/oce{grestore ditwid 0 rmoveto}def -/dm{ditsiz mul}def -/ocprocs 50 dict def ocprocs begin -(14){(1)(4)fraction}def -(12){(1)(2)fraction}def -(34){(3)(4)fraction}def -(13){(1)(3)fraction}def -(23){(2)(3)fraction}def -(18){(1)(8)fraction}def -(38){(3)(8)fraction}def -(58){(5)(8)fraction}def -(78){(7)(8)fraction}def -(sr){gsave 0 .06 dm rmoveto(\326)show oce}def -(is){gsave 0 .15 dm rmoveto(\362)show oce}def -(->){gsave 0 .02 dm rmoveto(\256)show oce}def -(<-){gsave 0 .02 dm rmoveto(\254)show oce}def -(==){gsave 0 .05 dm rmoveto(\272)show oce}def -(uc){gsave currentpoint 400 .009 dm mul add translate - 8 -8 scale ucseal oce}def -end - -% an attempt at a PostScript FONT to implement ditroff special chars -% this will enable us to -% cache the little buggers -% generate faster, more compact PS out of psdit -% confuse everyone (including myself)! -50 dict dup begin -/FontType 3 def -/FontName /DIThacks def -/FontMatrix [.001 0 0 .001 0 0] def -/FontBBox [-260 -260 900 900] def% a lie but ... -/Encoding 256 array def -0 1 255{Encoding exch /.notdef put}for -Encoding - dup 8#040/space put %space - dup 8#110/rc put %right ceil - dup 8#111/lt put %left top curl - dup 8#112/bv put %bold vert - dup 8#113/lk put %left mid curl - dup 8#114/lb put %left bot curl - dup 8#115/rt put %right top curl - dup 8#116/rk put %right mid curl - dup 8#117/rb put %right bot curl - dup 8#120/rf put %right floor - dup 8#121/lf put %left floor - dup 8#122/lc put %left ceil - dup 8#140/sq put %square - dup 8#141/bx put %box - dup 8#142/ci put %circle - dup 8#143/br put %box rule - dup 8#144/rn put %root extender - dup 8#145/vr put %vertical rule - dup 8#146/ob put %outline bullet - dup 8#147/bu put %bullet - dup 8#150/ru put %rule - dup 8#151/ul put %underline - pop -/DITfd 100 dict def -/BuildChar{0 begin - /cc exch def /fd exch def - /charname fd /Encoding get cc get def - /charwid fd /Metrics get charname get def - /charproc fd /CharProcs get charname get def - charwid 0 fd /FontBBox get aload pop setcachedevice - 2 setlinejoin 40 setlinewidth - newpath 0 0 moveto gsave charproc grestore - end}def -/BuildChar load 0 DITfd put -/CharProcs 50 dict def -CharProcs begin -/space{}def -/.notdef{}def -/ru{500 0 rls}def -/rn{0 840 moveto 500 0 rls}def -/vr{0 800 moveto 0 -770 rls}def -/bv{0 800 moveto 0 -1000 rls}def -/br{0 840 moveto 0 -1000 rls}def -/ul{0 -140 moveto 500 0 rls}def -/ob{200 250 rmoveto currentpoint newpath 200 0 360 arc closepath stroke}def -/bu{200 250 rmoveto currentpoint newpath 200 0 360 arc closepath fill}def -/sq{80 0 rmoveto currentpoint dround newpath moveto - 640 0 rlineto 0 640 rlineto -640 0 rlineto closepath stroke}def -/bx{80 0 rmoveto currentpoint dround newpath moveto - 640 0 rlineto 0 640 rlineto -640 0 rlineto closepath fill}def -/ci{500 360 rmoveto currentpoint newpath 333 0 360 arc - 50 setlinewidth stroke}def - -/lt{0 -200 moveto 0 550 rlineto currx 800 2cx s4 add exch s4 a4p stroke}def -/lb{0 800 moveto 0 -550 rlineto currx -200 2cx s4 add exch s4 a4p stroke}def -/rt{0 -200 moveto 0 550 rlineto currx 800 2cx s4 sub exch s4 a4p stroke}def -/rb{0 800 moveto 0 -500 rlineto currx -200 2cx s4 sub exch s4 a4p stroke}def -/lk{0 800 moveto 0 300 -300 300 s4 arcto pop pop 1000 sub - 0 300 4 2 roll s4 a4p 0 -200 lineto stroke}def -/rk{0 800 moveto 0 300 s2 300 s4 arcto pop pop 1000 sub - 0 300 4 2 roll s4 a4p 0 -200 lineto stroke}def -/lf{0 800 moveto 0 -1000 rlineto s4 0 rls}def -/rf{0 800 moveto 0 -1000 rlineto s4 neg 0 rls}def -/lc{0 -200 moveto 0 1000 rlineto s4 0 rls}def -/rc{0 -200 moveto 0 1000 rlineto s4 neg 0 rls}def -end - -/Metrics 50 dict def Metrics begin -/.notdef 0 def -/space 500 def -/ru 500 def -/br 0 def -/lt 416 def -/lb 416 def -/rt 416 def -/rb 416 def -/lk 416 def -/rk 416 def -/rc 416 def -/lc 416 def -/rf 416 def -/lf 416 def -/bv 416 def -/ob 350 def -/bu 350 def -/ci 750 def -/bx 750 def -/sq 750 def -/rn 500 def -/ul 500 def -/vr 0 def -end - -DITfd begin -/s2 500 def /s4 250 def /s3 333 def -/a4p{arcto pop pop pop pop}def -/2cx{2 copy exch}def -/rls{rlineto stroke}def -/currx{currentpoint pop}def -/dround{transform round exch round exch itransform} def -end -end -/DIThacks exch definefont pop -ditstart -(psc)xT -576 1 1 xr -1(Times-Roman)xf 1 f -2(Times-Italic)xf 2 f -3(Times-Bold)xf 3 f -4(Times-BoldItalic)xf 4 f -5(Helvetica)xf 5 f -6(Helvetica-Bold)xf 6 f -7(Courier)xf 7 f -8(Courier-Bold)xf 8 f -9(Symbol)xf 9 f -10(DIThacks)xf 10 f -10 s -1 f -xi -%%EndProlog - -%%Page: 1 1 -10 s 10 xH 0 xS 1 f -3 f -22 s -1249 626(A)N -1420(N)X -1547(ew)X -1796(H)X -1933(ashing)X -2467(P)X -2574(ackage)X -3136(for)X -3405(U)X -3532(N)X -3659(IX)X -2 f -20 s -3855 562(1)N -1 f -12 s -1607 779(Margo)N -1887(Seltzer)X -9 f -2179(-)X -1 f -2256(University)X -2686(of)X -2790(California,)X -3229(Berkeley)X -2015 875(Ozan)N -2242(Yigit)X -9 f -2464(-)X -1 f -2541(York)X -2762(University)X -3 f -2331 1086(ABSTRACT)N -1 f -10 s -1152 1222(UNIX)N -1385(support)X -1657(of)X -1756(disk)X -1921(oriented)X -2216(hashing)X -2497(was)X -2654(originally)X -2997(provided)X -3314(by)X -2 f -3426(dbm)X -1 f -3595([ATT79])X -3916(and)X -1152 1310(subsequently)N -1595(improved)X -1927(upon)X -2112(in)X -2 f -2199(ndbm)X -1 f -2402([BSD86].)X -2735(In)X -2826(AT&T)X -3068(System)X -3327(V,)X -3429(in-memory)X -3809(hashed)X -1152 1398(storage)N -1420(and)X -1572(access)X -1814(support)X -2090(was)X -2251(added)X -2479(in)X -2577(the)X -2 f -2711(hsearch)X -1 f -3000(library)X -3249(routines)X -3542([ATT85].)X -3907(The)X -1152 1486(result)N -1367(is)X -1457(a)X -1530(system)X -1789(with)X -1968(two)X -2125(incompatible)X -2580(hashing)X -2865(schemes,)X -3193(each)X -3377(with)X -3555(its)X -3666(own)X -3840(set)X -3965(of)X -1152 1574(shortcomings.)N -1152 1688(This)N -1316(paper)X -1517(presents)X -1802(the)X -1922(design)X -2152(and)X -2289(performance)X -2717(characteristics)X -3198(of)X -3286(a)X -3343(new)X -3498(hashing)X -3768(package)X -1152 1776(providing)N -1483(a)X -1539(superset)X -1822(of)X -1909(the)X -2027(functionality)X -2456(provided)X -2761(by)X -2 f -2861(dbm)X -1 f -3019(and)X -2 f -3155(hsearch)X -1 f -3409(.)X -3469(The)X -3614(new)X -3768(package)X -1152 1864(uses)N -1322(linear)X -1537(hashing)X -1818(to)X -1912(provide)X -2189(ef\256cient)X -2484(support)X -2755(of)X -2853(both)X -3026(memory)X -3324(based)X -3538(and)X -3685(disk)X -3849(based)X -1152 1952(hash)N -1319(tables)X -1526(with)X -1688(performance)X -2115(superior)X -2398(to)X -2480(both)X -2 f -2642(dbm)X -1 f -2800(and)X -2 f -2936(hsearch)X -1 f -3210(under)X -3413(most)X -3588(conditions.)X -3 f -1380 2128(Introduction)N -1 f -892 2260(Current)N -1196(UNIX)X -1456(systems)X -1768(offer)X -1984(two)X -2163(forms)X -2409(of)X -720 2348(hashed)N -973(data)X -1137(access.)X -2 f -1413(Dbm)X -1 f -1599(and)X -1745(its)X -1850(derivatives)X -2231(provide)X -720 2436(keyed)N -939(access)X -1171(to)X -1259(disk)X -1418(resident)X -1698(data)X -1858(while)X -2 f -2062(hsearch)X -1 f -2342(pro-)X -720 2524(vides)N -929(access)X -1175(for)X -1309(memory)X -1616(resident)X -1910(data.)X -2124(These)X -2356(two)X -720 2612(access)N -979(methods)X -1302(are)X -1453(incompatible)X -1923(in)X -2037(that)X -2209(memory)X -720 2700(resident)N -1011(hash)X -1195(tables)X -1419(may)X -1593(not)X -1731(be)X -1843(stored)X -2075(on)X -2191(disk)X -2360(and)X -720 2788(disk)N -884(resident)X -1169(tables)X -1387(cannot)X -1632(be)X -1739(read)X -1909(into)X -2063(memory)X -2360(and)X -720 2876(accessed)N -1022(using)X -1215(the)X -1333(in-memory)X -1709(routines.)X -2 f -892 2990(Dbm)N -1 f -1091(has)X -1241(several)X -1512(shortcomings.)X -2026(Since)X -2247(data)X -2423(is)X -720 3078(assumed)N -1032(to)X -1130(be)X -1242(disk)X -1411(resident,)X -1721(each)X -1905(access)X -2146(requires)X -2440(a)X -720 3166(system)N -963(call,)X -1120(and)X -1257(almost)X -1491(certainly,)X -1813(a)X -1869(disk)X -2022(operation.)X -2365(For)X -720 3254(extremely)N -1072(large)X -1264(databases,)X -1623(where)X -1851(caching)X -2131(is)X -2214(unlikely)X -720 3342(to)N -810(be)X -914(effective,)X -1244(this)X -1386(is)X -1466(acceptable,)X -1853(however,)X -2177(when)X -2378(the)X -720 3430(database)N -1022(is)X -1100(small)X -1298(\(i.e.)X -1447(the)X -1569(password)X -1896(\256le\),)X -2069(performance)X -720 3518(improvements)N -1204(can)X -1342(be)X -1443(obtained)X -1744(through)X -2018(caching)X -2293(pages)X -720 3606(of)N -818(the)X -947(database)X -1255(in)X -1348(memory.)X -1685(In)X -1782(addition,)X -2 f -2094(dbm)X -1 f -2262(cannot)X -720 3694(store)N -902(data)X -1062(items)X -1261(whose)X -1492(total)X -1660(key)X -1802(and)X -1943(data)X -2102(size)X -2252(exceed)X -720 3782(the)N -850(page)X -1034(size)X -1191(of)X -1290(the)X -1420(hash)X -1599(table.)X -1827(Similarly,)X -2176(if)X -2257(two)X -2409(or)X -720 3870(more)N -907(keys)X -1076(produce)X -1357(the)X -1477(same)X -1664(hash)X -1833(value)X -2029(and)X -2166(their)X -2334(total)X -720 3958(size)N -876(exceeds)X -1162(the)X -1291(page)X -1474(size,)X -1650(the)X -1779(table)X -1966(cannot)X -2210(store)X -2396(all)X -720 4046(the)N -838(colliding)X -1142(keys.)X -892 4160(The)N -1050(in-memory)X -2 f -1439(hsearch)X -1 f -1725(routines)X -2015(have)X -2199(different)X -720 4248(shortcomings.)N -1219(First,)X -1413(the)X -1539(notion)X -1771(of)X -1865(a)X -1928(single)X -2146(hash)X -2320(table)X -720 4336(is)N -807(embedded)X -1171(in)X -1266(the)X -1397(interface,)X -1732(preventing)X -2108(an)X -2217(applica-)X -720 4424(tion)N -902(from)X -1116(accessing)X -1482(multiple)X -1806(tables)X -2050(concurrently.)X -720 4512(Secondly,)N -1063(the)X -1186(routine)X -1438(to)X -1525(create)X -1743(a)X -1804(hash)X -1976(table)X -2157(requires)X -2440(a)X -720 4600(parameter)N -1066(which)X -1286(declares)X -1573(the)X -1694(size)X -1842(of)X -1932(the)X -2053(hash)X -2223(table.)X -2422(If)X -720 4688(this)N -856(size)X -1001(is)X -1074(set)X -1183(too)X -1305(low,)X -1465(performance)X -1892(degradation)X -2291(or)X -2378(the)X -720 4776(inability)N -1008(to)X -1092(add)X -1230(items)X -1425(to)X -1509(the)X -1628(table)X -1805(may)X -1964(result.)X -2223(In)X -2311(addi-)X -720 4864(tion,)N -2 f -910(hsearch)X -1 f -1210(requires)X -1515(that)X -1681(the)X -1825(application)X -2226(allocate)X -720 4952(memory)N -1037(for)X -1181(the)X -1329(key)X -1495(and)X -1661(data)X -1845(items.)X -2108(Lastly,)X -2378(the)X -2 f -720 5040(hsearch)N -1 f -1013(routines)X -1310(provide)X -1594(no)X -1713(interface)X -2034(to)X -2135(store)X -2329(hash)X -720 5128(tables)N -927(on)X -1027(disk.)X -16 s -720 5593 MXY -864 0 Dl -2 f -8 s -760 5648(1)N -1 f -9 s -5673(UNIX)Y -990(is)X -1056(a)X -1106(registered)X -1408(trademark)X -1718(of)X -1796(AT&T.)X -10 s -2878 2128(The)N -3032(goal)X -3199(of)X -3295(our)X -3431(work)X -3625(was)X -3779(to)X -3870(design)X -4108(and)X -4253(imple-)X -2706 2216(ment)N -2900(a)X -2970(new)X -3138(package)X -3436(that)X -3590(provides)X -3899(a)X -3968(superset)X -4264(of)X -4364(the)X -2706 2304(functionality)N -3144(of)X -3240(both)X -2 f -3411(dbm)X -1 f -3578(and)X -2 f -3723(hsearch)X -1 f -3977(.)X -4045(The)X -4198(package)X -2706 2392(had)N -2871(to)X -2982(overcome)X -3348(the)X -3495(interface)X -3826(shortcomings)X -4306(cited)X -2706 2480(above)N -2930(and)X -3078(its)X -3185(implementation)X -3719(had)X -3867(to)X -3961(provide)X -4238(perfor-)X -2706 2568(mance)N -2942(equal)X -3142(or)X -3235(superior)X -3524(to)X -3612(that)X -3758(of)X -3851(the)X -3975(existing)X -4253(imple-)X -2706 2656(mentations.)N -3152(In)X -3274(order)X -3498(to)X -3614(provide)X -3913(a)X -4003(compact)X -4329(disk)X -2706 2744(representation,)N -3224(graceful)X -3531(table)X -3729(growth,)X -4018(and)X -4176(expected)X -2706 2832(constant)N -3033(time)X -3234(performance,)X -3720(we)X -3873(selected)X -4191(Litwin's)X -2706 2920(linear)N -2923(hashing)X -3206(algorithm)X -3551([LAR88,)X -3872(LIT80].)X -4178(We)X -4324(then)X -2706 3008(enhanced)N -3037(the)X -3161(algorithm)X -3498(to)X -3586(handle)X -3826(page)X -4004(over\257ows)X -4346(and)X -2706 3096(large)N -2900(key)X -3049(handling)X -3362(with)X -3537(a)X -3606(single)X -3830(mechanism,)X -4248(named)X -2706 3184(buddy-in-waiting.)N -3 f -2975 3338(Existing)N -3274(UNIX)X -3499(Hashing)X -3802(Techniques)X -1 f -2878 3470(Over)N -3076(the)X -3210(last)X -3357(decade,)X -3637(several)X -3901(dynamic)X -4213(hashing)X -2706 3558(schemes)N -3000(have)X -3174(been)X -3348(developed)X -3700(for)X -3816(the)X -3936(UNIX)X -4159(timeshar-)X -2706 3646(ing)N -2856(system,)X -3146(starting)X -3433(with)X -3622(the)X -3767(inclusion)X -4107(of)X -2 f -4221(dbm)X -1 f -4359(,)X -4426(a)X -2706 3734(minimal)N -3008(database)X -3321(library)X -3571(written)X -3834(by)X -3950(Ken)X -4120(Thompson)X -2706 3822([THOM90],)N -3141(in)X -3248(the)X -3391(Seventh)X -3694(Edition)X -3974(UNIX)X -4220(system.)X -2706 3910(Since)N -2916(then,)X -3106(an)X -3214(extended)X -3536(version)X -3804(of)X -3903(the)X -4032(same)X -4228(library,)X -2 f -2706 3998(ndbm)N -1 f -2884(,)X -2933(and)X -3078(a)X -3142(public-domain)X -3637(clone)X -3839(of)X -3934(the)X -4060(latter,)X -2 f -4273(sdbm)X -1 f -4442(,)X -2706 4086(have)N -2902(been)X -3098(developed.)X -3491(Another)X -3797 0.1645(interface-compatible)AX -2706 4174(library)N -2 f -2950(gdbm)X -1 f -3128(,)X -3178(was)X -3333(recently)X -3622(made)X -3826(available)X -4145(as)X -4241(part)X -4395(of)X -2706 4262(the)N -2829(Free)X -2997(Software)X -3312(Foundation's)X -3759(\(FSF\))X -3970(software)X -4271(distri-)X -2706 4350(bution.)N -2878 4464(All)N -3017(of)X -3121(these)X -3323(implementations)X -3893(are)X -4029(based)X -4248(on)X -4364(the)X -2706 4552(idea)N -2871(of)X -2969(revealing)X -3299(just)X -3445(enough)X -3711(bits)X -3856(of)X -3953(a)X -4019(hash)X -4196(value)X -4400(to)X -2706 4640(locate)N -2920(a)X -2978(page)X -3151(in)X -3234(a)X -3291(single)X -3503(access.)X -3770(While)X -2 f -3987(dbm/ndbm)X -1 f -4346(and)X -2 f -2706 4728(sdbm)N -1 f -2908(map)X -3079(the)X -3210(hash)X -3390(value)X -3597(directly)X -3874(to)X -3968(a)X -4036(disk)X -4201(address,)X -2 f -2706 4816(gdbm)N -1 f -2921(uses)X -3096(the)X -3231(hash)X -3414(value)X -3624(to)X -3722(index)X -3936(into)X -4096(a)X -2 f -4168(directory)X -1 f -2706 4904([ENB88])N -3020(containing)X -3378(disk)X -3531(addresses.)X -2878 5018(The)N -2 f -3033(hsearch)X -1 f -3317(routines)X -3605(in)X -3697(System)X -3962(V)X -4049(are)X -4177(designed)X -2706 5106(to)N -2804(provide)X -3085(memory-resident)X -3669(hash)X -3852(tables.)X -4115(Since)X -4328(data)X -2706 5194(access)N -2948(does)X -3131(not)X -3269(require)X -3533(disk)X -3702(access,)X -3964(simple)X -4213(hashing)X -2706 5282(schemes)N -3010(which)X -3238(may)X -3408(require)X -3667(multiple)X -3964(probes)X -4209(into)X -4364(the)X -2706 5370(table)N -2889(are)X -3015(used.)X -3209(A)X -3294(more)X -3486(interesting)X -3851(version)X -4114(of)X -2 f -4208(hsearch)X -1 f -2706 5458(is)N -2784(a)X -2845(public)X -3070(domain)X -3335(library,)X -2 f -3594(dynahash)X -1 f -3901(,)X -3945(that)X -4089(implements)X -2706 5546(Larson's)N -3036(in-memory)X -3440(adaptation)X -3822([LAR88])X -4164(of)X -4279(linear)X -2706 5634(hashing)N -2975([LIT80].)X -3 f -720 5960(USENIX)N -9 f -1042(-)X -3 f -1106(Winter)X -1371('91)X -9 f -1498(-)X -3 f -1562(Dallas,)X -1815(TX)X -1 f -4424(1)X - -2 p -%%Page: 2 2 -10 s 10 xH 0 xS 1 f -3 f -432 258(A)N -510(New)X -682(Hashing)X -985(Package)X -1290(for)X -1413(UNIX)X -3663(Seltzer)X -3920(&)X -4007(Yigit)X -2 f -1074 538(dbm)N -1 f -1232(and)X -2 f -1368(ndbm)X -1 f -604 670(The)N -2 f -760(dbm)X -1 f -928(and)X -2 f -1074(ndbm)X -1 f -1282(library)X -1526(implementations)X -2089(are)X -432 758(based)N -667(on)X -799(the)X -949(same)X -1166(algorithm)X -1529(by)X -1661(Ken)X -1846(Thompson)X -432 846([THOM90,)N -824(TOR88,)X -1113(WAL84],)X -1452(but)X -1582(differ)X -1789(in)X -1879(their)X -2054(pro-)X -432 934(grammatic)N -801(interfaces.)X -1160(The)X -1311(latter)X -1502(is)X -1581(a)X -1643(modi\256ed)X -1952(version)X -432 1022(of)N -533(the)X -665(former)X -918(which)X -1148(adds)X -1328(support)X -1601(for)X -1728(multiple)X -2027(data-)X -432 1110(bases)N -634(to)X -724(be)X -828(open)X -1011(concurrently.)X -1484(The)X -1636(discussion)X -1996(of)X -2090(the)X -432 1198(algorithm)N -774(that)X -925(follows)X -1196(is)X -1280(applicable)X -1640(to)X -1732(both)X -2 f -1904(dbm)X -1 f -2072(and)X -2 f -432 1286(ndbm)N -1 f -610(.)X -604 1400(The)N -760(basic)X -956(structure)X -1268(of)X -2 f -1366(dbm)X -1 f -1535(calls)X -1712(for)X -1836(\256xed-sized)X -432 1488(disk)N -612(blocks)X -868(\(buckets\))X -1214(and)X -1377(an)X -2 f -1499(access)X -1 f -1755(function)X -2068(that)X -432 1576(maps)N -623(a)X -681(key)X -819(to)X -902(a)X -959(bucket.)X -1234(The)X -1380(interface)X -1683(routines)X -1962(use)X -2090(the)X -2 f -432 1664(access)N -1 f -673(function)X -970(to)X -1062(obtain)X -1292(the)X -1420(appropriate)X -1816(bucket)X -2060(in)X -2152(a)X -432 1752(single)N -643(disk)X -796(access.)X -604 1866(Within)N -869(the)X -2 f -1010(access)X -1 f -1263(function,)X -1593(a)X -1672(bit-randomizing)X -432 1954(hash)N -610(function)X -2 f -8 s -877 1929(2)N -1 f -10 s -940 1954(is)N -1024(used)X -1202(to)X -1294(convert)X -1565(a)X -1631(key)X -1777(into)X -1931(a)X -1997(32-bit)X -432 2042(hash)N -605(value.)X -825(Out)X -971(of)X -1064(these)X -1254(32)X -1359(bits,)X -1519(only)X -1686(as)X -1778(many)X -1981(bits)X -2121(as)X -432 2130(necessary)N -773(are)X -900(used)X -1075(to)X -1165(determine)X -1514(the)X -1639(particular)X -1974(bucket)X -432 2218(on)N -533(which)X -750(a)X -807(key)X -944(resides.)X -1228(An)X -1347(in-memory)X -1724(bitmap)X -1967(is)X -2041(used)X -432 2306(to)N -533(determine)X -893(how)X -1070(many)X -1287(bits)X -1441(are)X -1579(required.)X -1905(Each)X -2104(bit)X -432 2394(indicates)N -746(whether)X -1033(its)X -1136(associated)X -1494(bucket)X -1736(has)X -1871(been)X -2051(split)X -432 2482(yet)N -562(\(a)X -657(0)X -728(indicating)X -1079(that)X -1230(the)X -1359(bucket)X -1604(has)X -1742(not)X -1875(yet)X -2004(split\).)X -432 2570(The)N -590(use)X -730(of)X -830(the)X -961(hash)X -1141(function)X -1441(and)X -1590(the)X -1720(bitmap)X -1974(is)X -2059(best)X -432 2658(described)N -769(by)X -878(stepping)X -1177(through)X -1454(database)X -1759(creation)X -2046(with)X -432 2746(multiple)N -718(invocations)X -1107(of)X -1194(a)X -2 f -1250(store)X -1 f -1430(operation.)X -604 2860(Initially,)N -906(the)X -1033(hash)X -1209(table)X -1394(contains)X -1690(a)X -1755(single)X -1974(bucket)X -432 2948(\(bucket)N -711(0\),)X -836(the)X -972(bit)X -1094(map)X -1270(contains)X -1575(a)X -1649(single)X -1878(bit)X -2000(\(bit)X -2148(0)X -432 3036(corresponding)N -913(to)X -997(bucket)X -1233(0\),)X -1342(and)X -1480(0)X -1542(bits)X -1699(of)X -1788(a)X -1846(hash)X -2014(value)X -432 3124(are)N -560(examined)X -901(to)X -992(determine)X -1342(where)X -1568(a)X -1633(key)X -1778(is)X -1860(placed)X -2099(\(in)X -432 3212(bucket)N -670(0\).)X -801(When)X -1017(bucket)X -1255(0)X -1319(is)X -1396(full,)X -1551(its)X -1650(bit)X -1758(in)X -1844(the)X -1966(bitmap)X -432 3300(\(bit)N -564(0\))X -652(is)X -726(set,)X -856(and)X -993(its)X -1089(contents)X -1377(are)X -1497(split)X -1655(between)X -1943(buckets)X -432 3388(0)N -499(and)X -641(1,)X -727(by)X -833(considering)X -1233(the)X -1357(0)X -2 f -7 s -3356(th)Y -10 s -1 f -1480 3388(bit)N -1590(\(the)X -1741(lowest)X -1976(bit)X -2086(not)X -432 3476(previously)N -800(examined\))X -1169(of)X -1266(the)X -1393(hash)X -1569(value)X -1772(for)X -1895(each)X -2072(key)X -432 3564(within)N -668(the)X -798(bucket.)X -1064(Given)X -1292(a)X -1359(well-designed)X -1840(hash)X -2018(func-)X -432 3652(tion,)N -613(approximately)X -1112(half)X -1273(of)X -1376(the)X -1510(keys)X -1693(will)X -1853(have)X -2041(hash)X -432 3740(values)N -666(with)X -837(the)X -964(0)X -2 f -7 s -3708(th)Y -10 s -1 f -1090 3740(bit)N -1203(set.)X -1341(All)X -1471(such)X -1646(keys)X -1821(and)X -1965(associ-)X -432 3828(ated)N -586(data)X -740(are)X -859(moved)X -1097(to)X -1179(bucket)X -1413(1,)X -1493(and)X -1629(the)X -1747(rest)X -1883(remain)X -2126(in)X -432 3916(bucket)N -666(0.)X -604 4030(After)N -804(this)X -949(split,)X -1135(the)X -1262(\256le)X -1393(now)X -1560(contains)X -1856(two)X -2005(buck-)X -432 4118(ets,)N -562(and)X -699(the)X -818(bitmap)X -1061(contains)X -1349(three)X -1530(bits:)X -1687(the)X -1805(0)X -2 f -7 s -4086(th)Y -10 s -1 f -1922 4118(bit)N -2026(is)X -2099(set)X -432 4206(to)N -525(indicate)X -810(a)X -876(bucket)X -1120(0)X -1190(split)X -1357(when)X -1561(no)X -1671(bits)X -1816(of)X -1913(the)X -2041(hash)X -432 4294(value)N -648(are)X -789(considered,)X -1199(and)X -1357(two)X -1519(more)X -1726(unset)X -1937(bits)X -2094(for)X -432 4382(buckets)N -706(0)X -775(and)X -920(1.)X -1029(The)X -1183(placement)X -1542(of)X -1638(an)X -1742(incoming)X -2072(key)X -432 4470(now)N -604(requires)X -897(examination)X -1327(of)X -1428(the)X -1560(0)X -2 f -7 s -4438(th)Y -10 s -1 f -1691 4470(bit)N -1809(of)X -1910(the)X -2041(hash)X -432 4558(value,)N -667(and)X -824(the)X -963(key)X -1119(is)X -1212(placed)X -1462(either)X -1685(in)X -1787(bucket)X -2041(0)X -2121(or)X -432 4646(bucket)N -674(1.)X -782(If)X -864(either)X -1075(bucket)X -1317(0)X -1385(or)X -1480(bucket)X -1722(1)X -1790(\256lls)X -1937(up,)X -2064(it)X -2135(is)X -432 4734(split)N -598(as)X -693(before,)X -947(its)X -1050(bit)X -1162(is)X -1243(set)X -1360(in)X -1450(the)X -1576(bitmap,)X -1846(and)X -1990(a)X -2054(new)X -432 4822(set)N -541(of)X -628(unset)X -817(bits)X -952(are)X -1071(added)X -1283(to)X -1365(the)X -1483(bitmap.)X -604 4936(Each)N -791(time)X -959(we)X -1079(consider)X -1376(a)X -1437(new)X -1596(bit)X -1705(\(bit)X -1841(n\),)X -1953(we)X -2072(add)X -432 5024(2)N -2 f -7 s -4992(n)Y -9 f -509(+)X -1 f -540(1)X -10 s -595 5024(bits)N -737(to)X -826(the)X -951(bitmap)X -1199(and)X -1341(obtain)X -1567(2)X -2 f -7 s -4992(n)Y -9 f -1644(+)X -1 f -1675(1)X -10 s -1729 5024(more)N -1920(address-)X -432 5112(able)N -595(buckets)X -869(in)X -960(the)X -1087(\256le.)X -1258(As)X -1376(a)X -1441(result,)X -1668(the)X -1795(bitmap)X -2045(con-)X -432 5200(tains)N -618(the)X -751(previous)X -1062(2)X -2 f -7 s -5168(n)Y -9 f -1139(+)X -1 f -1170(1)X -2 f -10 s -9 f -5200(-)Y -1 f -1242(1)X -1317(bits)X -1467(\(1)X -2 f -9 f -1534(+)X -1 f -1578(2)X -2 f -9 f -(+)S -1 f -1662(4)X -2 f -9 f -(+)S -1 f -1746(...)X -2 f -9 f -(+)S -1 f -1850(2)X -2 f -7 s -5168(n)Y -10 s -1 f -1931 5200(\))N -1992(which)X -432 5288(trace)N -649(the)X -807(entire)X -2 f -1050(split)X -1247(history)X -1 f -1529(of)X -1656(the)X -1813(addressable)X -16 s -432 5433 MXY -864 0 Dl -2 f -8 s -472 5488(2)N -1 f -9 s -523 5513(This)N -670(bit-randomizing)X -1153(property)X -1416(is)X -1482(important)X -1780(to)X -1854(obtain)X -2052(radi-)X -432 5593(cally)N -599(different)X -874(hash)X -1033(values)X -1244(for)X -1355(nearly)X -1562(identical)X -1836(keys,)X -2012(which)X -432 5673(in)N -506(turn)X -640(avoids)X -846(clustering)X -1148(of)X -1226(such)X -1376(keys)X -1526(in)X -1600(a)X -1650(single)X -1840(bucket.)X -10 s -2418 538(buckets.)N -2590 652(Given)N -2809(a)X -2868(key)X -3007(and)X -3146(the)X -3267(bitmap)X -3512(created)X -3768(by)X -3871(this)X -4009(algo-)X -2418 740(rithm,)N -2638(we)X -2759(\256rst)X -2910(examine)X -3209(bit)X -3320(0)X -3386(of)X -3479(the)X -3603(bitmap)X -3851(\(the)X -4002(bit)X -4112(to)X -2418 828(consult)N -2673(when)X -2871(0)X -2934(bits)X -3072(of)X -3162(the)X -3283(hash)X -3453(value)X -3650(are)X -3772(being)X -3973(exam-)X -2418 916(ined\).)N -2631(If)X -2713(it)X -2785(is)X -2866(set)X -2982(\(indicating)X -3356(that)X -3503(the)X -3628(bucket)X -3869(split\),)X -4080(we)X -2418 1004(begin)N -2617(considering)X -3012(the)X -3131(bits)X -3267(of)X -3355(the)X -3473(32-bit)X -3684(hash)X -3851(value.)X -4085(As)X -2418 1092(bit)N -2525(n)X -2587(is)X -2662(revealed,)X -2977(a)X -3035(mask)X -3226(equal)X -3422(to)X -3506(2)X -2 f -7 s -1060(n)Y -9 f -3583(+)X -1 f -3614(1)X -2 f -10 s -9 f -1092(-)Y -1 f -3686(1)X -3748(will)X -3894(yield)X -4076(the)X -2418 1180(current)N -2675(bucket)X -2918(address.)X -3228(Adding)X -3496(2)X -2 f -7 s -1148(n)Y -9 f -3573(+)X -1 f -3604(1)X -2 f -10 s -9 f -1180(-)Y -1 f -3676(1)X -3744(to)X -3834(the)X -3960(bucket)X -2418 1268(address)N -2701(identi\256es)X -3035(which)X -3272(bit)X -3397(in)X -3500(the)X -3639(bitmap)X -3902(must)X -4098(be)X -2418 1356(checked.)N -2743(We)X -2876(continue)X -3173(revealing)X -3493(bits)X -3628(of)X -3715(the)X -3833(hash)X -4000(value)X -2418 1444(until)N -2591(all)X -2698(set)X -2814(bits)X -2955(in)X -3043(the)X -3167(bitmap)X -3415(are)X -3540(exhausted.)X -3907(The)X -4058(fol-)X -2418 1532(lowing)N -2682(algorithm,)X -3055(a)X -3133(simpli\256cation)X -3614(of)X -3723(the)X -3863(algorithm)X -2418 1620(due)N -2565(to)X -2658(Ken)X -2823(Thompson)X -3196([THOM90,)X -3590(TOR88],)X -3908(uses)X -4076(the)X -2418 1708(hash)N -2625(value)X -2839(and)X -2995(the)X -3133(bitmap)X -3395(to)X -3497(calculate)X -3823(the)X -3960(bucket)X -2418 1796(address)N -2679(as)X -2766(discussed)X -3093(above.)X -0(Courier)xf 0 f -1 f -0 f -8 s -2418 2095(hash)N -2608(=)X -2684 -0.4038(calchash\(key\);)AX -2418 2183(mask)N -2608(=)X -2684(0;)X -2418 2271(while)N -2646 -0.4018(\(isbitset\(\(hash)AX -3254(&)X -3330(mask\))X -3558(+)X -3634(mask\)\))X -2706 2359(mask)N -2896(=)X -2972(\(mask)X -3200(<<)X -3314(1\))X -3428(+)X -3504(1;)X -2418 2447(bucket)N -2684(=)X -2760(hash)X -2950(&)X -3026(mask;)X -2 f -10 s -3211 2812(sdbm)N -1 f -2590 2944(The)N -2 f -2738(sdbm)X -1 f -2930(library)X -3167(is)X -3243(a)X -3302(public-domain)X -3791(clone)X -3987(of)X -4076(the)X -2 f -2418 3032(ndbm)N -1 f -2638(library,)X -2914(developed)X -3286(by)X -3408(Ozan)X -3620(Yigit)X -3826(to)X -3929(provide)X -2 f -2418 3120(ndbm)N -1 f -2596('s)X -2692(functionality)X -3139(under)X -3359(some)X -3565(versions)X -3869(of)X -3973(UNIX)X -2418 3208(that)N -2559(exclude)X -2830(it)X -2894(for)X -3008(licensing)X -3317(reasons)X -3578([YIG89].)X -3895(The)X -4040(pro-)X -2418 3296(grammer)N -2735(interface,)X -3064(and)X -3207(the)X -3332(basic)X -3524(structure)X -3832(of)X -2 f -3926(sdbm)X -1 f -4121(is)X -2418 3384(identical)N -2733(to)X -2 f -2834(ndbm)X -1 f -3051(but)X -3192(internal)X -3476(details)X -3723(of)X -3828(the)X -2 f -3964(access)X -1 f -2418 3472(function,)N -2726(such)X -2894(as)X -2982(the)X -3101(calculation)X -3474(of)X -3561(the)X -3679(bucket)X -3913(address,)X -2418 3560(and)N -2563(the)X -2690(use)X -2825(of)X -2920(different)X -3225(hash)X -3400(functions)X -3726(make)X -3928(the)X -4054(two)X -2418 3648(incompatible)N -2856(at)X -2934(the)X -3052(database)X -3349(level.)X -2590 3762(The)N -2 f -2740(sdbm)X -1 f -2934(library)X -3173(is)X -3251(based)X -3458(on)X -3562(a)X -3622(simpli\256ed)X -3965(imple-)X -2418 3850(mentation)N -2778(of)X -2885(Larson's)X -3206(1978)X -2 f -3406(dynamic)X -3717(hashing)X -1 f -4009(algo-)X -2418 3938(rithm)N -2616(including)X -2943(the)X -2 f -3066(re\256nements)X -3461(and)X -3605(variations)X -1 f -3953(of)X -4044(sec-)X -2418 4026(tion)N -2562(5)X -2622([LAR78].)X -2956(Larson's)X -3257(original)X -3526(algorithm)X -3857(calls)X -4024(for)X -4138(a)X -2418 4114(forest)N -2635(of)X -2736(binary)X -2975(hash)X -3156(trees)X -3341(that)X -3494(are)X -3626(accessed)X -3941(by)X -4054(two)X -2418 4202(hash)N -2586(functions.)X -2925(The)X -3071(\256rst)X -3216(hash)X -3384(function)X -3672(selects)X -3907(a)X -3964(partic-)X -2418 4290(ular)N -2571(tree)X -2720(within)X -2952(the)X -3078(forest.)X -3309(The)X -3462(second)X -3713(hash)X -3887(function,)X -2418 4378(which)N -2659(is)X -2757(required)X -3070(to)X -3177(be)X -3297(a)X -3377(boolean)X -3675(pseudo-random)X -2418 4466(number)N -2687(generator)X -3015(that)X -3159(is)X -3236(seeded)X -3479(by)X -3583(the)X -3705(key,)X -3865(is)X -3942(used)X -4112(to)X -2418 4554(traverse)N -2733(the)X -2890(tree)X -3070(until)X -3275(internal)X -3579(\(split\))X -3829(nodes)X -4075(are)X -2418 4642(exhausted)N -2763(and)X -2903(an)X -3003(external)X -3286(\(non-split\))X -3648(node)X -3827(is)X -3903(reached.)X -2418 4730(The)N -2571(bucket)X -2813(addresses)X -3149(are)X -3276(stored)X -3500(directly)X -3772(in)X -3861(the)X -3986(exter-)X -2418 4818(nal)N -2536(nodes.)X -2590 4932(Larson's)N -2903(re\256nements)X -3309(are)X -3440(based)X -3655(on)X -3767(the)X -3897(observa-)X -2418 5020(tion)N -2570(that)X -2718(the)X -2844(nodes)X -3059(can)X -3199(be)X -3303(represented)X -3702(by)X -3809(a)X -3872(single)X -4090(bit)X -2418 5108(that)N -2569(is)X -2653(set)X -2773(for)X -2898(internal)X -3174(nodes)X -3392(and)X -3539(not)X -3672(set)X -3791(for)X -3915(external)X -2418 5196(nodes,)N -2652(resulting)X -2959(in)X -3048(a)X -3111(radix)X -3303(search)X -3536(trie.)X -3709(Figure)X -3944(1)X -4010(illus-)X -2418 5284(trates)N -2621(this.)X -2804(Nodes)X -3037(A)X -3123(and)X -3267(B)X -3348(are)X -3475(internal)X -3748(\(split\))X -3967(nodes,)X -2418 5372(thus)N -2573(having)X -2813(no)X -2915(bucket)X -3151(addresses)X -3480(associated)X -3831(with)X -3994(them.)X -2418 5460(Instead,)N -2693(the)X -2814(external)X -3096(nodes)X -3306(\(C,)X -3429(D,)X -3530(and)X -3669(E\))X -3768(each)X -3938(need)X -4112(to)X -2418 5548(refer)N -2594(to)X -2679(a)X -2738(bucket)X -2975(address.)X -3279(These)X -3494(bucket)X -3731(addresses)X -4062(can)X -2418 5636(be)N -2529(stored)X -2760(in)X -2857(the)X -2990(trie)X -3132(itself)X -3327(where)X -3559(the)X -3691(subtries)X -3974(would)X -3 f -432 5960(2)N -2970(USENIX)X -9 f -3292(-)X -3 f -3356(Winter)X -3621('91)X -9 f -3748(-)X -3 f -3812(Dallas,)X -4065(TX)X - -3 p -%%Page: 3 3 -0(Courier)xf 0 f -10 s 10 xH 0 xS 0 f -3 f -720 258(Seltzer)N -977(&)X -1064(Yigit)X -3278(A)X -3356(New)X -3528(Hashing)X -3831(Package)X -4136(for)X -4259(UNIX)X -1 f -720 538(live)N -862(if)X -933(they)X -1092(existed)X -1340([KNU68].)X -1709(For)X -1841(example,)X -2154(if)X -2224(nodes)X -2432(F)X -720 626(and)N -858(G)X -938(were)X -1117(the)X -1237(children)X -1522(of)X -1610(node)X -1787(C,)X -1881(the)X -2000(bucket)X -2235(address)X -720 714(L00)N -886(could)X -1101(reside)X -1330(in)X -1429(the)X -1563(bits)X -1714(that)X -1870(will)X -2030(eventually)X -2400(be)X -720 802(used)N -887(to)X -969(store)X -1145(nodes)X -1352(F)X -1416(and)X -1552(G)X -1630(and)X -1766(all)X -1866(their)X -2033(children.)X -10 f -720 890 -0.0930(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)AN -3 f -1894 2247(L1)N -784 1925(A)N -1431(E)X -1106 2247(D)N -1428 1281(C)N -1109 1603(B)N -1884 1930(L01)N -1879 1286(L00)N -1221 1814(1)N -903 2131(1)N -1221 1402(0)N -903 1714(0)N -1 Dt -1397 1821 MXY --8 -32 Dl --5 19 Dl --20 6 Dl -33 7 Dl --187 -182 Dl -1397 1322 MXY --33 7 Dl -20 6 Dl -5 19 Dl -8 -32 Dl --187 182 Dl -1069 1639 MXY --32 7 Dl -20 6 Dl -5 19 Dl -7 -32 Dl --186 182 Dl -1374 1891 MXY -185 Dc -1779 2133 MXY -0 161 Dl -322 0 Dl -0 -161 Dl --322 0 Dl -1811 MY -0 161 Dl -322 0 Dl -0 -161 Dl --322 0 Dl -1166 MY -0 161 Dl -322 0 Dl -0 -161 Dl --322 0 Dl -1052 2213 MXY -185 Dc -1569 MY -185 Dc -720 1881 MXY -185 Dc -1779 2213 MXY --28 -17 Dl -10 17 Dl --10 18 Dl -28 -18 Dl --543 0 Dl -1769 1891 MXY --28 -18 Dl -10 18 Dl --10 18 Dl -28 -18 Dl --201 0 Dl -1364 1247 MXY -185 Dc -1769 MX --28 -18 Dl -10 18 Dl --10 18 Dl -28 -18 Dl --201 0 Dl -1064 2143 MXY --7 -32 Dl --5 19 Dl --20 6 Dl -32 7 Dl --181 -181 Dl -3 Dt --1 Ds -8 s -720 2482(Figure)N -925(1:)X -1 f -1002(Radix)X -1179(search)X -1365(trie)X -1474(with)X -1612(internal)X -1831(nodes)X -2004(A)X -2074(and)X -2189(B,)X -2271(external)X -720 2570(nodes)N -891(C,)X -972(D,)X -1056(and)X -1170(E,)X -1247(and)X -1361(bucket)X -1553(addresses)X -1819(stored)X -1997(in)X -2069(the)X -2168(unused)X -2370(por-)X -720 2658(tion)N -836(of)X -905(the)X -999(trie.)X -10 s -10 f -720 2922 -0.0930(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)AN -1 f -892 3124(Further)N -1153(simpli\256cations)X -1647(of)X -1738(the)X -1860(above)X -2076([YIG89])X -2377(are)X -720 3212(possible.)N -1038(Using)X -1265(a)X -1337(single)X -1564(radix)X -1765(trie)X -1908(to)X -2006(avoid)X -2219(the)X -2352(\256rst)X -720 3300(hash)N -904(function,)X -1227(replacing)X -1562(the)X -1696(pseudo-random)X -2231(number)X -720 3388(generator)N -1052(with)X -1222(a)X -1286(well)X -1452(designed,)X -1785(bit-randomizing)X -2329(hash)X -720 3476(function,)N -1053(and)X -1215(using)X -1434(the)X -1578(portion)X -1855(of)X -1967(the)X -2110(hash)X -2302(value)X -720 3564(exposed)N -1021(during)X -1268(the)X -1404(trie)X -1549(traversal)X -1864(as)X -1969(a)X -2042(direct)X -2262(bucket)X -720 3652(address)N -990(results)X -1228(in)X -1319(an)X -2 f -1424(access)X -1 f -1663(function)X -1959(that)X -2108(works)X -2333(very)X -720 3740(similar)N -974(to)X -1068(Thompson's)X -1499(algorithm)X -1841(above.)X -2084(The)X -2240(follow-)X -720 3828(ing)N -847(algorithm)X -1183(uses)X -1346(the)X -1469(hash)X -1641(value)X -1840(to)X -1927(traverse)X -2206(a)X -2266(linear-)X -720 3916(ized)N -874(radix)X -1059(trie)X -2 f -8 s -1166 3891(3)N -1 f -10 s -1218 3916(starting)N -1478(at)X -1556(the)X -1674(0)X -2 f -7 s -3884(th)Y -10 s -1 f -1791 3916(bit.)N -0 f -8 s -720 4215(tbit)N -910(=)X -986(0;)X -1296(/*)X -1410(radix)X -1638(trie)X -1828(index)X -2056(*/)X -720 4303(hbit)N -910(=)X -986(0;)X -1296(/*)X -1410(hash)X -1600(bit)X -1752(index)X -2056(*/)X -720 4391(mask)N -910(=)X -986(0;)X -720 4479(hash)N -910(=)X -986 -0.4038(calchash\(key\);)AX -720 4655(for)N -872(\(mask)X -1100(=)X -1176(0;)X -910 4743 -0.4018(isbitset\(tbit\);)AN -910 4831(mask)N -1100(=)X -1176(\(mask)X -1404(<<)X -1518(1\))X -1632(+)X -1708(1\))X -1008 4919(if)N -1122(\(hash)X -1350(&)X -1426(\(1)X -1540(<<)X -1654 -0.4219(hbit++\)\)\))AX -1160 5007(/*)N -1274(right)X -1502(son)X -1692(*/)X -1160 5095(tbit)N -1350(=)X -1426(2)X -1502(*)X -1578(tbit)X -1768(+)X -1844(2;)X -1008 5183(else)N -1 f -16 s -720 5353 MXY -864 0 Dl -2 f -8 s -760 5408(3)N -1 f -9 s -818 5433(A)N -896(linearized)X -1206(radix)X -1380(trie)X -1502(is)X -1576(merely)X -1802(an)X -1895(array)X -2068(representation)X -720 5513(of)N -800(the)X -908(radix)X -1076(search)X -1280(trie)X -1396(described)X -1692(above.)X -1920(The)X -2052(children)X -2308(of)X -2388(the)X -720 5593(node)N -885(with)X -1038(index)X -1223(i)X -1267(can)X -1391(be)X -1483(found)X -1675(at)X -1751(the)X -1863(nodes)X -2055(indexed)X -2307(2*i+1)X -720 5673(and)N -842(2*i+2.)X -0 f -8 s -3146 538(/*)N -3260(left)X -3450(son)X -3678(*/)X -3146 626(tbit)N -3336(=)X -3412(2)X -3488(*)X -3564(tbit)X -3754(+)X -3830(1;)X -2706 802(bucket)N -2972(=)X -3048(hash)X -3238(&)X -3314(mask;)X -2 f -10 s -3495 1167(gdbm)N -1 f -2878 1299(The)N -3027(gdbm)X -3233(\(GNU)X -3458(data)X -3616(base)X -3783(manager\))X -4111(library)X -4349(is)X -4426(a)X -2706 1387(UNIX)N -2933(database)X -3236(manager)X -3539(written)X -3792(by)X -3897(Philip)X -4112(A.)X -4215(Nelson,)X -2706 1475(and)N -2848(made)X -3048(available)X -3364(as)X -3457(a)X -3518(part)X -3668(of)X -3760(the)X -3883(FSF)X -4040(software)X -4342(dis-)X -2706 1563(tribution.)N -3052(The)X -3207(gdbm)X -3419(library)X -3663(provides)X -3969(the)X -4097(same)X -4292(func-)X -2706 1651(tionality)N -3028(of)X -3151(the)X -2 f -3304(dbm)X -1 f -3442(/)X -2 f -3464(ndbm)X -1 f -3697(libraries)X -4015([NEL90])X -4360(but)X -2706 1739(attempts)N -3018(to)X -3121(avoid)X -3340(some)X -3550(of)X -3658(their)X -3846(shortcomings.)X -4337(The)X -2706 1827(gdbm)N -2918(library)X -3162(allows)X -3401(for)X -3525(arbitrary-length)X -4059(data,)X -4242(and)X -4387(its)X -2706 1915(database)N -3027(is)X -3124(a)X -3203(singular,)X -3524(non-sparse)X -2 f -8 s -3872 1890(4)N -1 f -10 s -3947 1915(\256le.)N -4112(The)X -4280(gdbm)X -2706 2003(library)N -2947(also)X -3103(includes)X -2 f -3396(dbm)X -1 f -3560(and)X -2 f -3702(ndbm)X -1 f -3906(compatible)X -4288(inter-)X -2706 2091(faces.)N -2878 2205(The)N -3025(gdbm)X -3229(library)X -3465(is)X -3540(based)X -3745(on)X -2 f -3847(extensible)X -4189(hashing)X -1 f -4442(,)X -2706 2293(a)N -2766(dynamic)X -3066(hashing)X -3339(algorithm)X -3674(by)X -3778(Fagin)X -3984(et)X -4066(al)X -4148([FAG79].)X -2706 2381(This)N -2881(algorithm)X -3225(differs)X -3467(from)X -3655(the)X -3785(previously)X -4155(discussed)X -2706 2469(algorithms)N -3069(in)X -3152(that)X -3293(it)X -3358(uses)X -3517(a)X -2 f -3574(directory)X -1 f -3889(that)X -4030(is)X -4103(a)X -4159(collapsed)X -2706 2557(representation)N -3192([ENB88])X -3517(of)X -3615(the)X -3744(radix)X -3940(search)X -4177(trie)X -4315(used)X -2706 2645(by)N -2 f -2806(sdbm)X -1 f -2975(.)X -10 f -2706 2733 -0.0930(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)AN -3 f -7 s -3572 3761(L1)N -1 Dt -3485 3738 MXY --20 -13 Dl -7 13 Dl --7 13 Dl -20 -13 Dl --400 0 Dl -3180 3027 MXY -136 Dc -2706 3494 MXY -136 Dc -2950 3264 MXY -136 Dc -3738 MY -136 Dc -3485 2968 MXY -0 118 Dl -238 0 Dl -0 -118 Dl --238 0 Dl -3442 MY -0 119 Dl -238 0 Dl -0 -119 Dl --238 0 Dl -3679 MY -0 119 Dl -238 0 Dl -0 -119 Dl --238 0 Dl -3187 3501 MXY -136 Dc -2963 3316 MXY --24 5 Dl -15 4 Dl -4 15 Dl -5 -24 Dl --137 134 Dl -3204 3083 MXY --24 5 Dl -15 4 Dl -3 14 Dl -6 -23 Dl --137 133 Dl -3204 3450 MXY --6 -24 Dl --3 14 Dl --15 5 Dl -24 5 Dl --137 -134 Dl -2842 3369(0)N -3075 3139(0)N -2842 3676(1)N -3075 3443(1)N -3562 3054(L00)N -3565 3528(L01)N -4197 2968 MXY -0 118 Dl -237 0 Dl -0 -118 Dl --237 0 Dl -3205 MY -0 119 Dl -237 0 Dl -0 -119 Dl --237 0 Dl -3561 MY -0 118 Dl -237 0 Dl -0 -118 Dl --237 0 Dl -3960 2909 MXY -0 237 Dl -118 0 Dl -0 -237 Dl --118 0 Dl -3146 MY -0 237 Dl -118 0 Dl -0 -237 Dl --118 0 Dl -3383 MY -0 237 Dl -118 0 Dl -0 -237 Dl --118 0 Dl -3620 MY -0 237 Dl -118 0 Dl -0 -237 Dl --118 0 Dl -4197 3027 MXY --21 -13 Dl -8 13 Dl --8 13 Dl -21 -13 Dl --119 0 Dl -4197 3264 MXY --21 -13 Dl -8 13 Dl --8 13 Dl -21 -13 Dl --119 0 Dl -3501 MY -59 0 Dl -0 89 Dl -4078 3738 MXY -59 0 Dl -0 -88 Dl -4197 3590 MXY --21 -13 Dl -8 13 Dl --8 13 Dl -21 -13 Dl --60 0 Dl -4197 3650 MXY --21 -13 Dl -8 13 Dl --8 13 Dl -21 -13 Dl --60 0 Dl -3991 3050(00)N -3991 3287(01)N -3991 3524(10)N -3991 3761(11)N -4269 3050(L00)N -4269 3287(L01)N -4283 3643(L1)N -3485 3501 MXY --20 -13 Dl -7 13 Dl --7 13 Dl -20 -13 Dl --155 0 Dl -3485 3027 MXY --20 -13 Dl -7 13 Dl --7 13 Dl -20 -13 Dl --163 0 Dl -2967 3687 MXY --5 -24 Dl --4 14 Dl --15 4 Dl -24 6 Dl --141 -141 Dl -3 Dt --1 Ds -8 s -2706 4033(Figure)N -2903(2:)X -1 f -2972(A)X -3034(radix)X -3181(search)X -3359(trie)X -3460(and)X -3568(a)X -3612(directory)X -3858(representing)X -4189(the)X -4283(trie.)X -10 s -10 f -2706 4209 -0.0930(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)AN -1 f -2878 4411(In)N -2968(this)X -3106(algorithm,)X -3460(a)X -3519(directory)X -3832(consists)X -4108(of)X -4198(a)X -4256(search)X -2706 4499(trie)N -2847(of)X -2947(depth)X -2 f -3158(n)X -1 f -3211(,)X -3264(containing)X -3635(2)X -2 f -7 s -4467(n)Y -10 s -1 f -3749 4499(bucket)N -3996(addresses)X -4337(\(i.e.)X -2706 4587(each)N -2897(element)X -3194(of)X -3304(the)X -3445(trie)X -3594(is)X -3689(a)X -3767(bucket)X -4023(address\).)X -4373(To)X -2706 4675(access)N -2935(the)X -3056(hash)X -3226(table,)X -3425(a)X -3483(32-bit)X -3696(hash)X -3865(value)X -4061(is)X -4136(calculated)X -2706 4763(and)N -2 f -2861(n)X -1 f -2953(bits)X -3107(of)X -3213(the)X -3350(value)X -3563(are)X -3701(used)X -3886(to)X -3986(index)X -4202(into)X -4364(the)X -2706 4851(directory)N -3018(to)X -3102(obtain)X -3324(a)X -3382(bucket)X -3618(address.)X -3921(It)X -3992(is)X -4067(important)X -4400(to)X -2706 4939(note)N -2866(that)X -3008(multiple)X -3296(entries)X -3532(of)X -3620(this)X -3756(directory)X -4067(may)X -4226(contain)X -2706 5027(the)N -2833(same)X -3026(bucket)X -3268(address)X -3537(as)X -3632(a)X -3696(result)X -3902(of)X -3997(directory)X -4315(dou-)X -2706 5115(bling)N -2903(during)X -3145(bucket)X -3392(splitting.)X -3706(Figure)X -3948(2)X -4021(illustrates)X -4364(the)X -2706 5203(relationship)N -3126(between)X -3436(a)X -3513(typical)X -3772(\(skewed\))X -4108(search)X -4355(trie)X -2706 5291(and)N -2850(its)X -2953(directory)X -3271(representation.)X -3774(The)X -3927(formation)X -4270(of)X -4364(the)X -2706 5379(directory)N -3016(shown)X -3245(in)X -3327(the)X -3445(\256gure)X -3652(is)X -3725(as)X -3812(follows.)X -16 s -2706 5593 MXY -864 0 Dl -2 f -8 s -2746 5648(4)N -1 f -9 s -2796 5673(It)N -2858(does)X -3008(not)X -3118(contain)X -3348(holes.)X -3 f -10 s -720 5960(USENIX)N -9 f -1042(-)X -3 f -1106(Winter)X -1371('91)X -9 f -1498(-)X -3 f -1562(Dallas,)X -1815(TX)X -4424(3)X - -4 p -%%Page: 4 4 -0(Courier)xf 0 f -10 s 10 xH 0 xS 0 f -3 f -432 258(A)N -510(New)X -682(Hashing)X -985(Package)X -1290(for)X -1413(UNIX)X -3663(Seltzer)X -3920(&)X -4007(Yigit)X -1 f -604 538(Initially,)N -937(there)X -1158(is)X -1271(one)X -1446(slot)X -1620(in)X -1741(the)X -1898(directory)X -432 626(addressing)N -802(a)X -865(single)X -1083(bucket.)X -1364(The)X -1515(depth)X -1719(of)X -1812(the)X -1936(trie)X -2069(is)X -2148(0)X -432 714(and)N -577(0)X -646(bits)X -790(of)X -886(each)X -1063(hash)X -1239(value)X -1442(are)X -1570(examined)X -1910(to)X -2000(deter-)X -432 802(mine)N -624(in)X -718(which)X -946(bucket)X -1192(to)X -1286(place)X -1488(a)X -1556(key;)X -1726(all)X -1837(keys)X -2015(go)X -2126(in)X -432 890(bucket)N -682(0.)X -797(When)X -1024(this)X -1174(bucket)X -1423(is)X -1511(full,)X -1677(its)X -1787(contents)X -2089(are)X -432 978(divided)N -698(between)X -992(L0)X -1107(and)X -1249(L1)X -1363(as)X -1455(was)X -1605(done)X -1786(in)X -1873(the)X -1996(previ-)X -432 1066(ously)N -664(discussed)X -1030(algorithms.)X -1471(After)X -1700(this)X -1874(split,)X -2090(the)X -432 1154(address)N -710(of)X -814(the)X -948(second)X -1207(bucket)X -1457(must)X -1648(be)X -1760(stored)X -1992(in)X -2090(the)X -432 1242(directory.)N -796(To)X -939(accommodate)X -1438(the)X -1589(new)X -1776(address,)X -2090(the)X -432 1330(directory)N -752(is)X -835(split)X -2 f -8 s -972 1305(5)N -1 f -10 s -1330(,)Y -1054(by)X -1163(doubling)X -1476(it,)X -1569(thus)X -1731(increasing)X -2090(the)X -432 1418(depth)N -630(of)X -717(the)X -835(directory)X -1145(by)X -1245(one.)X -604 1532(After)N -813(this)X -967(split,)X -1163(a)X -1237(single)X -1466(bit)X -1588(of)X -1693(the)X -1829(hash)X -2014(value)X -432 1620(needs)N -663(to)X -773(be)X -896(examined)X -1255(to)X -1364(decide)X -1621(whether)X -1927(the)X -2072(key)X -432 1708(belongs)N -711(to)X -803(L0)X -922(or)X -1019(L1.)X -1158(Once)X -1358(one)X -1504(of)X -1601(these)X -1795(buckets)X -2069(\256lls)X -432 1796(\(L0)N -578(for)X -702(example\),)X -1051(it)X -1125(is)X -1208(split)X -1375(as)X -1472(before,)X -1728(and)X -1873(the)X -2000(direc-)X -432 1884(tory)N -585(is)X -662(split)X -823(again)X -1021(to)X -1107(make)X -1305(room)X -1498(for)X -1615(the)X -1736(address)X -2000(of)X -2090(the)X -432 1972(third)N -618(bucket.)X -927(This)X -1104(splitting)X -1400(causes)X -1645(the)X -1778(addresses)X -2121(of)X -432 2060(the)N -567(non-splitting)X -1012(bucket)X -1263(\(L1\))X -1443(to)X -1541(be)X -1653(duplicated.)X -2063(The)X -432 2148(directory)N -766(now)X -948(has)X -1099(four)X -1277(entries,)X -1555(a)X -1635(depth)X -1857(of)X -1968(2,)X -2072(and)X -432 2236(indexes)N -700(the)X -821(buckets)X -1089(L00,)X -1261(L01)X -1413(and)X -1552(L1,)X -1684(as)X -1774(shown)X -2006(in)X -2090(the)X -432 2324(Figure)N -661(2.)X -604 2438(The)N -756(crucial)X -1002(part)X -1154(of)X -1247(the)X -1371(algorithm)X -1708(is)X -1787(the)X -1911(observa-)X -432 2526(tion)N -580(that)X -724(L1)X -837(is)X -914(addressed)X -1255(twice)X -1453(in)X -1539(the)X -1661(directory.)X -1995(If)X -2073(this)X -432 2614(bucket)N -679(were)X -869(to)X -964(split)X -1134(now,)X -1324(the)X -1454(directory)X -1776(already)X -2045(con-)X -432 2702(tains)N -611(room)X -808(to)X -898(hold)X -1067(the)X -1192(address)X -1460(of)X -1554(the)X -1679(new)X -1840(bucket.)X -2121(In)X -432 2790(general,)N -711(the)X -831(relationship)X -1231(between)X -1521(the)X -1641(directory)X -1953(and)X -2090(the)X -432 2878(number)N -704(of)X -798(bucket)X -1039(addresses)X -1374(contained)X -1713(therein)X -1962(is)X -2041(used)X -432 2966(to)N -517(decide)X -750(when)X -947(to)X -1031(split)X -1190(the)X -1310(directory.)X -1662(Each)X -1845(bucket)X -2081(has)X -432 3054(a)N -505(depth,)X -740(\()X -2 f -767(n)X -7 s -3070(b)Y -10 s -1 f -848 3054(\),)N -932(associated)X -1299(with)X -1478(it)X -1558(and)X -1710(appears)X -1992(in)X -2090(the)X -432 3142(directory)N -744(exactly)X -998(2)X -2 f -7 s -3106(n)Y -9 f -1075(-)X -2 f -1106(n)X -4 s -3110(b)Y -7 s -1 f -10 s -1181 3142(times.)N -1396(When)X -1610(a)X -1668(bucket)X -1904(splits,)X -2113(its)X -432 3230(depth)N -638(increases)X -961(by)X -1069(one.)X -1253(The)X -1406(directory)X -1724(must)X -1907(split)X -2072(any)X -432 3318(time)N -602(a)X -665(bucket's)X -964(depth)X -1169(exceeds)X -1451(the)X -1576(depth)X -1781(of)X -1875(the)X -2000(direc-)X -432 3406(tory.)N -630(The)X -784(following)X -1123(code)X -1303(fragment)X -1621(helps)X -1818(to)X -1908(illustrate)X -432 3494(the)N -554(extendible)X -912(hashing)X -1185(algorithm)X -1520([FAG79])X -1838(for)X -1955(access-)X -432 3582(ing)N -554(individual)X -898(buckets)X -1163(and)X -1299(maintaining)X -1701(the)X -1819(directory.)X -0 f -8 s -432 3881(hash)N -622(=)X -698 -0.4038(calchash\(key\);)AX -432 3969(mask)N -622(=)X -698 -0.4018(maskvec[depth];)AX -432 4145(bucket)N -698(=)X -774 -0.4038(directory[hash)AX -1344(&)X -1420(mask];)X -432 4321(/*)N -546(Key)X -698 -0.4219(Insertion)AX -1078(*/)X -432 4409(if)N -546 -0.4038(\(store\(bucket,)AX -1116(key,)X -1306(data\))X -1534(==)X -1648(FAIL\))X -1876({)X -720 4497(newbl)N -948(=)X -1024 -0.4167(getpage\(\);)AX -720 4585 -0.4000(bucket->depth++;)AN -720 4673 -0.4091(newbl->depth)AN -1214(=)X -1290 -0.4038(bucket->depth;)AX -720 4761(if)N -834 -0.4038(\(bucket->depth)AX -1404(>)X -1480(depth\))X -1746({)X -1008 4849(/*)N -1122(double)X -1388 -0.4219(directory)AX -1768(*/)X -1008 4937(depth++;)N -1 f -16 s -432 5033 MXY -864 0 Dl -2 f -8 s -472 5088(5)N -1 f -9 s -534 5113(This)N -692(decision)X -962(to)X -1048(split)X -1202(the)X -1319(directory)X -1608(is)X -1685(based)X -1878(on)X -1979(a)X -2040(com-)X -432 5193(parison)N -666(of)X -748(the)X -858(depth)X -1040(of)X -1121(the)X -1230(page)X -1387(being)X -1568(split)X -1713(and)X -1838(the)X -1947(depth)X -2128(of)X -432 5273(the)N -543(trie.)X -698(In)X -781(Figure)X -992(2,)X -1069(the)X -1180(depths)X -1390(of)X -1472(both)X -1622(L00)X -1760(and)X -1886(L01)X -2024(are)X -2134(2,)X -432 5353(whereas)N -689(the)X -798(depth)X -979(of)X -1060(L1)X -1161(is)X -1230(1.)X -1323(Therefore,)X -1646(if)X -1710(L1)X -1810(were)X -1970(to)X -2046(split,)X -432 5433(the)N -543(directory)X -826(would)X -1029(not)X -1144(need)X -1303(to)X -1382(split.)X -1565(In)X -1648(reality,)X -1872(a)X -1926(bucket)X -2140(is)X -432 5513(allocated)N -727(for)X -846(the)X -969(directory)X -1264(at)X -1351(the)X -1474(time)X -1637(of)X -1732(\256le)X -1858(creation)X -2124(so)X -432 5593(although)N -707(the)X -818(directory)X -1100(splits)X -1274(logically,)X -1566(physical)X -1828(splits)X -2002(do)X -2096(not)X -432 5673(occur)N -610(until)X -760(the)X -866(\256le)X -976(becomes)X -1246(quite)X -1408(large.)X -0 f -8 s -2994 538 -0.4219(directory)AN -3374(=)X -3450 -0.3971(double\(directory\);)AX -2706 626(})N -2706 714 -0.3958(splitbucket\(bucket,)AN -3466(newbl\))X -2706 802(...)N -2418 890(})N -2 f -10 s -3169 1255(hsearch)N -1 f -2590 1387(Since)N -2 f -2807(hsearch)X -1 f -3100(does)X -3286(not)X -3427(have)X -3617(to)X -3717(translate)X -4027(hash)X -2418 1475(values)N -2659(into)X -2819(disk)X -2988(addresses,)X -3352(it)X -3432(can)X -3579(use)X -3721(much)X -3934(simpler)X -2418 1563(algorithms)N -2808(than)X -2994(those)X -3211(de\256ned)X -3495(above.)X -3775(System)X -4058(V's)X -2 f -2418 1651(hsearch)N -1 f -2708(constructs)X -3069(a)X -3141(\256xed-size)X -3489(hash)X -3671(table)X -3862(\(speci\256ed)X -2418 1739(by)N -2519(the)X -2637(user)X -2791(at)X -2869(table)X -3045(creation\).)X -3391(By)X -3504(default,)X -3767(a)X -3823(multiplica-)X -2418 1827(tive)N -2570(hash)X -2748(function)X -3046(based)X -3260(on)X -3371(that)X -3522(described)X -3861(in)X -3954(Knuth,)X -2418 1915(Volume)N -2710(3,)X -2804(section)X -3065(6.4)X -3199([KNU68])X -3541(is)X -3628(used)X -3809(to)X -3905(obtain)X -4138(a)X -2418 2003(primary)N -2694(bucket)X -2930(address.)X -3233(If)X -3309(this)X -3446(bucket)X -3681(is)X -3755(full,)X -3907(a)X -3964(secon-)X -2418 2091(dary)N -2593(multiplicative)X -3069(hash)X -3248(value)X -3454(is)X -3538(computed)X -3885(to)X -3978(de\256ne)X -2418 2179(the)N -2542(probe)X -2751(interval.)X -3062(The)X -3213(probe)X -3422(interval)X -3693(is)X -3772(added)X -3989(to)X -4076(the)X -2418 2267(original)N -2712(bucket)X -2971(address)X -3257(\(modulo)X -3573(the)X -3716(table)X -3916(size\))X -4112(to)X -2418 2355(obtain)N -2658(a)X -2734(new)X -2908(bucket)X -3162(address.)X -3483(This)X -3665(process)X -3946(repeats)X -2418 2443(until)N -2588(an)X -2688(empty)X -2911(bucket)X -3148(is)X -3224(found.)X -3474(If)X -3551(no)X -3654(bucket)X -3891(is)X -3967(found,)X -2418 2531(an)N -2514(insertion)X -2814(fails)X -2972(with)X -3134(a)X -3190(``table)X -3420(full'')X -3605(condition.)X -2590 2645(The)N -2768(basic)X -2986(algorithm)X -3350(may)X -3541(be)X -3670(modi\256ed)X -4006(by)X -4138(a)X -2418 2733(number)N -2705(of)X -2813(compile)X -3112(time)X -3295(options)X -3571(available)X -3902(to)X -4005(those)X -2418 2821(users)N -2604(with)X -2767(AT&T)X -3006(source)X -3237(code.)X -3450(First,)X -3637(the)X -3756(package)X -4040(pro-)X -2418 2909(vides)N -2638(two)X -2809(options)X -3094(for)X -3238(hash)X -3435(functions.)X -3803(Users)X -4036(may)X -2418 2997(specify)N -2690(their)X -2877(own)X -3055(hash)X -3242(function)X -3549(by)X -3669(compiling)X -4032(with)X -2418 3085(``USCR'')N -2757(de\256ned)X -3016(and)X -3155(declaring)X -3477(and)X -3616(de\256ning)X -3901(the)X -4022(vari-)X -2418 3173(able)N -2 f -2578(hcompar)X -1 f -2863(,)X -2909(a)X -2971(function)X -3263(taking)X -3488(two)X -3633(string)X -3840(arguments)X -2418 3261(and)N -2560(returning)X -2880(an)X -2982(integer.)X -3271(Users)X -3480(may)X -3643(also)X -3797(request)X -4054(that)X -2418 3349(hash)N -2587(values)X -2814(be)X -2912(computed)X -3250(simply)X -3489(by)X -3590(taking)X -3811(the)X -3930(modulo)X -2418 3437(of)N -2521(key)X -2673(\(using)X -2909(division)X -3201(rather)X -3424(than)X -3597(multiplication)X -4080(for)X -2418 3525(hash)N -2589(value)X -2787(calculation\).)X -3230(If)X -3308(this)X -3447(technique)X -3783(is)X -3859(used,)X -4049(col-)X -2418 3613(lisions)N -2651(are)X -2775(resolved)X -3072(by)X -3176(scanning)X -3485(sequentially)X -3896(from)X -4076(the)X -2418 3701(selected)N -2702(bucket)X -2941(\(linear)X -3176(probing\).)X -3517(This)X -3684(option)X -3913(is)X -3991(avail-)X -2418 3789(able)N -2572(by)X -2672(de\256ning)X -2954(the)X -3072(variable)X -3351(``DIV'')X -3622(at)X -3700(compile)X -3978(time.)X -2590 3903(A)N -2720(second)X -3015(option,)X -3311(based)X -3565(on)X -3716(an)X -3863(algorithm)X -2418 3991(discovered)N -2787(by)X -2888(Richard)X -3163(P.)X -3248(Brent,)X -3466(rearranges)X -3822(the)X -3940(table)X -4116(at)X -2418 4079(the)N -2549(time)X -2724(of)X -2824(insertion)X -3137(in)X -3232(order)X -3434(to)X -3528(speed)X -3743(up)X -3855(retrievals.)X -2418 4167(The)N -2571(basic)X -2764(idea)X -2926(is)X -3007(to)X -3097(shorten)X -3361(long)X -3531(probe)X -3741(sequences)X -4094(by)X -2418 4255(lengthening)N -2833(short)X -3030(probe)X -3249(sequences.)X -3651(Once)X -3857(the)X -3991(probe)X -2418 4343(chain)N -2613(has)X -2741(exceeded)X -3062(some)X -3252(threshold)X -3571(\(Brent)X -3796(suggests)X -4087(2\),)X -2418 4431(we)N -2541(attempt)X -2809(to)X -2899(shuf\257e)X -3145(any)X -3289(colliding)X -3601(keys)X -3776(\(keys)X -3978(which)X -2418 4519(appeared)N -2734(in)X -2821(the)X -2944(probe)X -3152(sequence)X -3471(of)X -3562(the)X -3684(new)X -3842(key\).)X -4049(The)X -2418 4607(details)N -2652(of)X -2744(this)X -2884(key)X -3025(shuf\257ing)X -3333(can)X -3469(be)X -3569(found)X -3780(in)X -3866([KNU68])X -2418 4695(and)N -2576([BRE73].)X -2946(This)X -3129(algorithm)X -3481(may)X -3660(be)X -3777(obtained)X -4094(by)X -2418 4783(de\256ning)N -2700(the)X -2818(variable)X -3097(``BRENT'')X -3487(at)X -3565(compile)X -3843(time.)X -2590 4897(A)N -2698(third)X -2899(set)X -3038(of)X -3154(options,)X -3458(obtained)X -3783(by)X -3912(de\256ning)X -2418 4985(``CHAINED'',)N -2943(use)X -3086(linked)X -3321(lists)X -3484(to)X -3581(resolve)X -3848(collisions.)X -2418 5073(Either)N -2647(of)X -2747(the)X -2878(primary)X -3164(hash)X -3343(function)X -3642(described)X -3982(above)X -2418 5161(may)N -2584(be)X -2688(used,)X -2882(but)X -3011(all)X -3118(collisions)X -3451(are)X -3577(resolved)X -3876(by)X -3983(build-)X -2418 5249(ing)N -2554(a)X -2623(linked)X -2856(list)X -2986(of)X -3086(entries)X -3333(from)X -3522(the)X -3653(primary)X -3940(bucket.)X -2418 5337(By)N -2542(default,)X -2816(new)X -2981(entries)X -3226(will)X -3381(be)X -3488(added)X -3711(to)X -3804(a)X -3871(bucket)X -4116(at)X -2418 5425(the)N -2541(beginning)X -2886(of)X -2978(the)X -3101(bucket)X -3339(chain.)X -3577(However,)X -3916(compile)X -2418 5513(options)N -2706(``SORTUP'')X -3173(or)X -3293(``SORTDOWN'')X -3908(may)X -4098(be)X -2418 5601(speci\256ed)N -2723(to)X -2805(order)X -2995(the)X -3113(hash)X -3280(chains)X -3505(within)X -3729(each)X -3897(bucket.)X -3 f -432 5960(4)N -2970(USENIX)X -9 f -3292(-)X -3 f -3356(Winter)X -3621('91)X -9 f -3748(-)X -3 f -3812(Dallas,)X -4065(TX)X - -5 p -%%Page: 5 5 -0(Courier)xf 0 f -10 s 10 xH 0 xS 0 f -3 f -720 258(Seltzer)N -977(&)X -1064(Yigit)X -3278(A)X -3356(New)X -3528(Hashing)X -3831(Package)X -4136(for)X -4259(UNIX)X -2 f -1444 538(dynahash)N -1 f -892 670(The)N -2 f -1054(dynahash)X -1 f -1398(library,)X -1669(written)X -1932(by)X -2048(Esmond)X -2346(Pitt,)X -720 758(implements)N -1183(Larson's)X -1554(linear)X -1827(hashing)X -2165(algorithm)X -720 846([LAR88])N -1097(with)X -1302(an)X -2 f -1440(hsearch)X -1 f -1756(compatible)X -2174(interface.)X -720 934(Intuitively,)N -1099(a)X -1161(hash)X -1334(table)X -1516(begins)X -1751(as)X -1844(a)X -1905(single)X -2121(bucket)X -2360(and)X -720 1022(grows)N -941(in)X -1028(generations,)X -1443(where)X -1665(a)X -1725(generation)X -2088(corresponds)X -720 1110(to)N -815(a)X -884(doubling)X -1201(in)X -1296(the)X -1427(size)X -1585(of)X -1685(the)X -1815(hash)X -1994(table.)X -2222(The)X -2379(0)X -2 f -7 s -1078(th)Y -10 s -1 f -720 1198(generation)N -1085(occurs)X -1321(as)X -1414(the)X -1538(table)X -1719(grows)X -1940(from)X -2121(one)X -2262(bucket)X -720 1286(to)N -814(two.)X -1006(In)X -1105(the)X -1235(next)X -1405(generation)X -1776(the)X -1906(table)X -2093(grows)X -2320(from)X -720 1374(two)N -862(to)X -946(four.)X -1122(During)X -1371(each)X -1541(generation,)X -1921(every)X -2121(bucket)X -2356(that)X -720 1462(existed)N -967(at)X -1045(the)X -1163(beginning)X -1503(of)X -1590(the)X -1708(generation)X -2067(is)X -2140(split.)X -892 1576(The)N -1041(table)X -1221(starts)X -1414(as)X -1505(a)X -1565(single)X -1780(bucket)X -2018(\(numbered)X -2389(0\),)X -720 1664(the)N -839(current)X -1088(split)X -1245(bucket)X -1479(is)X -1552(set)X -1661(to)X -1743(bucket)X -1977(0,)X -2057(and)X -2193(the)X -2311(max-)X -720 1752(imum)N -933(split)X -1097(point)X -1288(is)X -1368(set)X -1483(to)X -1571(twice)X -1771(the)X -1895(current)X -2149(split)X -2312(point)X -720 1840(\(0\).)N -863(When)X -1084(it)X -1157(is)X -1239(time)X -1410(for)X -1532(a)X -1596(bucket)X -1838(to)X -1928(split,)X -2113(the)X -2239(keys)X -2414(in)X -720 1928(the)N -872(current)X -1154(split)X -1345(bucket)X -1612(are)X -1764(divided)X -2057(between)X -2378(the)X -720 2016(current)N -981(split)X -1151(bucket)X -1397(and)X -1545(a)X -1613(new)X -1779(bucket)X -2025(whose)X -2262(bucket)X -720 2104(number)N -1000(is)X -1088(equal)X -1297(to)X -1394(1)X -1469(+)X -1549(current)X -1812(split)X -1984(bucket)X -2232(+)X -2311(max-)X -720 2192(imum)N -927(split)X -1085(point.)X -1310(We)X -1442(can)X -1574(determine)X -1915(which)X -2131(keys)X -2298(move)X -720 2280(to)N -807(the)X -929(new)X -1087(bucket)X -1325(by)X -1429(examining)X -1791(the)X -2 f -1913(n)X -7 s -1962 2248(th)N -10 s -1 f -2043 2280(bit)N -2151(of)X -2242(a)X -2302(key's)X -720 2368(hash)N -899(value)X -1105(where)X -1334(n)X -1406(is)X -1491(the)X -1620(generation)X -1990(number.)X -2306(After)X -720 2456(the)N -846(bucket)X -1088(at)X -1174(the)X -1300(maximum)X -1651(split)X -1815(point)X -2006(has)X -2140(been)X -2319(split,)X -720 2544(the)N -839(generation)X -1198(number)X -1463(is)X -1536(incremented,)X -1973(the)X -2091(current)X -2339(split)X -720 2632(point)N -908(is)X -985(set)X -1098(back)X -1274(to)X -1360(zero,)X -1543(and)X -1683(the)X -1805(maximum)X -2152(split)X -2312(point)X -720 2720(is)N -815(set)X -946(to)X -1050(the)X -1190(number)X -1477(of)X -1586(the)X -1725(last)X -1877(bucket)X -2132(in)X -2235(the)X -2374(\256le)X -720 2808(\(which)N -971(is)X -1052(equal)X -1253(to)X -1342(twice)X -1543(the)X -1668(old)X -1797(maximum)X -2148(split)X -2312(point)X -720 2896(plus)N -873(1\).)X -892 3010(To)N -1031(facilitate)X -1361(locating)X -1668(keys,)X -1884(we)X -2027(maintain)X -2356(two)X -720 3098(masks.)N -989(The)X -1143(low)X -1291(mask)X -1488(is)X -1569(equal)X -1771(to)X -1861(the)X -1987(maximum)X -2339(split)X -720 3186(bucket)N -967(and)X -1116(the)X -1247(high)X -1422(mask)X -1624(is)X -1710(equal)X -1917(to)X -2011(the)X -2141(next)X -2311(max-)X -720 3274(imum)N -931(split)X -1093(bucket.)X -1372(To)X -1486(locate)X -1703(a)X -1764(speci\256c)X -2033(key,)X -2193(we)X -2311(com-)X -720 3362(pute)N -881(a)X -940(32-bit)X -1154(hash)X -1324(value)X -1520(using)X -1715(a)X -1773(bit-randomizing)X -2311(algo-)X -720 3450(rithm)N -932(such)X -1118(as)X -1224(the)X -1361(one)X -1516(described)X -1862(in)X -1962([LAR88].)X -2334(This)X -720 3538(hash)N -893(value)X -1093(is)X -1172(then)X -1336(masked)X -1607(with)X -1775(the)X -1898(high)X -2065(mask.)X -2299(If)X -2378(the)X -720 3626(resulting)N -1026(number)X -1297(is)X -1376(greater)X -1626(than)X -1790(the)X -1913(maximum)X -2262(bucket)X -720 3714(in)N -823(the)X -962(table)X -1159(\(current)X -1455(split)X -1633(bucket)X -1888(+)X -1974(maximum)X -2339(split)X -720 3802(point\),)N -962(the)X -1091(hash)X -1269(value)X -1474(is)X -1558(masked)X -1834(with)X -2007(the)X -2136(low)X -2287(mask.)X -720 3890(In)N -825(either)X -1046(case,)X -1242(the)X -1377(result)X -1592(of)X -1696(the)X -1831(mask)X -2037(is)X -2127(the)X -2262(bucket)X -720 3978(number)N -989(for)X -1107(the)X -1229(given)X -1431(key.)X -1611(The)X -1759(algorithm)X -2093(below)X -2312(illus-)X -720 4066(trates)N -914(this)X -1049(process.)X -0 f -8 s -720 4365(h)N -796(=)X -872 -0.4038(calchash\(key\);)AX -720 4453(bucket)N -986(=)X -1062(h)X -1138(&)X -1214 -0.4167(high_mask;)AX -720 4541(if)N -834(\()X -910(bucket)X -1176(>)X -1252 -0.4167(max_bucket)AX -1670(\))X -1008 4629(bucket)N -1274(=)X -1350(h)X -1426(&)X -1502 -0.4219(low_mask;)AX -720 4717 -0.4018(return\(bucket\);)AN -1 f -10 s -892 5042(In)N -1013(order)X -1237(to)X -1353(decide)X -1617(when)X -1845(to)X -1961(split)X -2152(a)X -2242(bucket,)X -2 f -720 5130(dynahash)N -1 f -1050(uses)X -2 f -1210(controlled)X -1561(splitting)X -1 f -1822(.)X -1884(A)X -1964(hash)X -2133(table)X -2311(has)X -2440(a)X -720 5218(\256ll)N -837(factor)X -1054(which)X -1279(is)X -1361(expressed)X -1707(in)X -1798(terms)X -2004(of)X -2099(the)X -2225(average)X -720 5306(number)N -990(of)X -1082(keys)X -1253(in)X -1339(each)X -1511(bucket.)X -1789(Each)X -1974(time)X -2140(the)X -2262(table's)X -720 5394(total)N -885(number)X -1153(of)X -1243(keys)X -1413(divided)X -1676(by)X -1778(its)X -1875(number)X -2142(of)X -2231(buckets)X -720 5482(exceeds)N -995(this)X -1130(\256ll)X -1238(factor,)X -1466(a)X -1522(bucket)X -1756(is)X -1829(split.)X -2878 538(Since)N -3079(the)X -2 f -3200(hsearch)X -1 f -3477(create)X -3693(interface)X -3998(\()X -2 f -4025(hcreate)X -1 f -4266(\))X -4315(calls)X -2706 626(for)N -2842(an)X -2960(estimate)X -3269(of)X -3378(the)X -3518(\256nal)X -3702(size)X -3869(of)X -3978(the)X -4118(hash)X -4306(table)X -2706 714(\()N -2 f -2733(nelem)X -1 f -2925(\),)X -2 f -3007(dynahash)X -1 f -3349(uses)X -3522(this)X -3672(information)X -4085(to)X -4182(initialize)X -2706 802(the)N -2848(table.)X -3088(The)X -3257(initial)X -3486(number)X -3774(of)X -3884(buckets)X -4172(is)X -4268(set)X -4400(to)X -2 f -2706 890(nelem)N -1 f -2926(rounded)X -3217(to)X -3306(the)X -3431(next)X -3596(higher)X -3828(power)X -4056(of)X -4150(two.)X -4337(The)X -2706 978(current)N -2958(split)X -3118(point)X -3305(is)X -3381(set)X -3493(to)X -3578(0)X -3641(and)X -3780(the)X -3901(maximum)X -4248(bucket)X -2706 1066(and)N -2842(maximum)X -3186(split)X -3343(point)X -3527(are)X -3646(set)X -3755(to)X -3837(this)X -3972(rounded)X -4255(value.)X -3 f -3148 1220(The)N -3301(New)X -3473(Implementation)X -1 f -2878 1352(Our)N -3042(implementation)X -3583(is)X -3675(also)X -3842(based)X -4063(on)X -4181(Larson's)X -2706 1440(linear)N -2939(hashing)X -3238([LAR88])X -3582(algorithm)X -3943(as)X -4060(well)X -4248(as)X -4364(the)X -2 f -2706 1528(dynahash)N -1 f -3047(implementation.)X -3623(The)X -2 f -3782(dbm)X -1 f -3954(family)X -4197(of)X -4297(algo-)X -2706 1616(rithms)N -2942(decide)X -3184(dynamically)X -3612(which)X -3840(bucket)X -4085(to)X -4178(split)X -4346(and)X -2706 1704(when)N -2914(to)X -3010(split)X -3180(it)X -3257(\(when)X -3491(it)X -3568(over\257ows\))X -3944(while)X -2 f -4155(dynahash)X -1 f -2706 1792(splits)N -2933(in)X -3054(a)X -3149(prede\256ned)X -3547(order)X -3776(\(linearly\))X -4134(and)X -4309(at)X -4426(a)X -2706 1880(prede\256ned)N -3116(time)X -3328(\(when)X -3599(the)X -3767(table)X -3993(\256ll)X -4151(factor)X -4409(is)X -2706 1968(exceeded\).)N -3121(We)X -3280(use)X -3434(a)X -3517(hybrid)X -3773(of)X -3887(these)X -4099(techniques.)X -2706 2056(Splits)N -2913(occur)X -3118(in)X -3206(the)X -3330(prede\256ned)X -3695(order)X -3891(of)X -3984(linear)X -4193(hashing,)X -2706 2144(but)N -2845(the)X -2980(time)X -3159(at)X -3253(which)X -3485(pages)X -3704(are)X -3839(split)X -4012(is)X -4101(determined)X -2706 2232(both)N -2869(by)X -2970(page)X -3143(over\257ows)X -3480(\()X -2 f -3507(uncontrolled)X -3937(splitting)X -1 f -4198(\))X -4246(and)X -4382(by)X -2706 2320(exceeding)N -3052(the)X -3170(\256ll)X -3278(factor)X -3486(\()X -2 f -3513(controlled)X -3862(splitting)X -1 f -4123(\))X -2878 2434(A)N -2962(hash)X -3135(table)X -3317(is)X -3395(parameterized)X -3876(by)X -3981(both)X -4148(its)X -4248(bucket)X -2706 2522(size)N -2904(\()X -2 f -2931(bsize)X -1 f -(\))S -3191(and)X -3380(\256ll)X -3541(factor)X -3801(\()X -2 f -3828(ffactor)X -1 f -4041(\).)X -4180(Whereas)X -2 f -2706 2610(dynahash's)N -1 f -3095(buckets)X -3364(can)X -3500(be)X -3599(represented)X -3993(as)X -4083(a)X -4142(linked)X -4365(list)X -2706 2698(of)N -2798(elements)X -3108(in)X -3195(memory,)X -3507(our)X -3639(package)X -3928(needs)X -4136(to)X -4222(support)X -2706 2786(disk)N -2874(access,)X -3135(and)X -3286(must)X -3476(represent)X -3806(buckets)X -4086(in)X -4183(terms)X -4395(of)X -2706 2874(pages.)N -2955(The)X -2 f -3106(bsize)X -1 f -3291(is)X -3369(the)X -3492(size)X -3642(\(in)X -3756(bytes\))X -3977(of)X -4069(these)X -4259(pages.)X -2706 2962(As)N -2833(in)X -2933(linear)X -3154(hashing,)X -3461(the)X -3597(number)X -3879(of)X -3983(buckets)X -4265(in)X -4364(the)X -2706 3050(table)N -2906(is)X -3003(equal)X -3221(to)X -3327(the)X -3469(number)X -3758(of)X -3869(keys)X -4060(in)X -4165(the)X -4306(table)X -2706 3138(divided)N -2988(by)X -2 f -3110(ffactor)X -1 f -3323(.)X -2 f -8 s -3113(6)Y -1 f -10 s -3417 3138(The)N -3584(controlled)X -3950(splitting)X -4252(occurs)X -2706 3226(each)N -2878(time)X -3044(the)X -3166(number)X -3435(of)X -3526(keys)X -3697(in)X -3783(the)X -3905(table)X -4085(exceeds)X -4364(the)X -2706 3314(\256ll)N -2814(factor)X -3022(multiplied)X -3370(by)X -3470(the)X -3588(number)X -3853(of)X -3940(buckets.)X -2878 3428(Inserting)N -3187(keys)X -3358(and)X -3498(splitting)X -3783(buckets)X -4051(is)X -4127(performed)X -2706 3516(precisely)N -3018(as)X -3107(described)X -3437(previously)X -3796(for)X -2 f -3911(dynahash)X -1 f -4218(.)X -4279(How-)X -2706 3604(ever,)N -2897(since)X -3094(buckets)X -3371(are)X -3502(now)X -3671(comprised)X -4036(of)X -4134(pages,)X -4368(we)X -2706 3692(must)N -2883(be)X -2981(prepared)X -3284(to)X -3367(handle)X -3602(cases)X -3793(where)X -4011(the)X -4130(size)X -4276(of)X -4364(the)X -2706 3780(keys)N -2873(and)X -3009(data)X -3163(in)X -3245(a)X -3301(bucket)X -3535(exceed)X -3779(the)X -3897(bucket)X -4131(size.)X -3 f -3318 3934(Over\257ow)N -3654(Pages)X -1 f -2878 4066(There)N -3095(are)X -3223(two)X -3372(cases)X -3571(where)X -3797(a)X -3862(key)X -4007(may)X -4174(not)X -4305(\256t)X -4400(in)X -2706 4154(its)N -2802(designated)X -3166(bucket.)X -3441(In)X -3529(the)X -3647(\256rst)X -3791(case,)X -3970(the)X -4088(total)X -4250(size)X -4395(of)X -2706 4242(the)N -2833(key)X -2978(and)X -3123(data)X -3286(may)X -3453(exceed)X -3706(the)X -3833(bucket)X -4076(size.)X -4269(In)X -4364(the)X -2706 4330(second,)N -3008(addition)X -3328(of)X -3453(a)X -3547(new)X -3739(key)X -3913(could)X -4149(cause)X -4386(an)X -2706 4418(over\257ow,)N -3068(but)X -3227(the)X -3382(bucket)X -3652(in)X -3770(question)X -4097(is)X -4206(not)X -4364(yet)X -2706 4506(scheduled)N -3049(to)X -3133(be)X -3230(split.)X -3428(In)X -3516(existing)X -3790(implementations,)X -4364(the)X -2706 4594(second)N -2953(case)X -3115(never)X -3317(arises)X -3523(\(since)X -3738(buckets)X -4006(are)X -4128(split)X -4288(when)X -2706 4682(they)N -2871(over\257ow\))X -3210(and)X -3352(the)X -3476(\256rst)X -3626(case)X -3791(is)X -3870(not)X -3998(handled)X -4278(at)X -4362(all.)X -2706 4770(Although)N -3036(large)X -3225(key/data)X -3525(pair)X -3678(handling)X -3986(is)X -4066(dif\256cult)X -4346(and)X -2706 4858(expensive,)N -3083(it)X -3163(is)X -3252(essential.)X -3604(In)X -3706(a)X -3777(linear)X -3995(hashed)X -4253(imple-)X -2706 4946(mentation,)N -3087(over\257ow)X -3413(pages)X -3636(are)X -3775(required)X -4083(for)X -4217(buckets)X -2706 5034(which)N -2935(over\257ow)X -3253(before)X -3492(they)X -3662(are)X -3793(split,)X -3982(so)X -4085(we)X -4211(can)X -4355(use)X -2706 5122(the)N -2833(same)X -3027(mechanism)X -3421(for)X -3544(large)X -3734(key/data)X -4035(pairs)X -4220(that)X -4368(we)X -2706 5210(use)N -2837(for)X -2955(over\257ow)X -3264(pages.)X -3511(Logically,)X -3862(we)X -3980(chain)X -4177(over\257ow)X -16 s -2706 5353 MXY -864 0 Dl -2 f -8 s -2746 5408(6)N -1 f -9 s -2801 5433(This)N -2952(is)X -3023(not)X -3138(strictly)X -3361(true.)X -3532(The)X -3667(\256le)X -3782(does)X -3937(not)X -4052(contract)X -4306(when)X -2706 5513(keys)N -2861(are)X -2972(deleted,)X -3221(so)X -3308(the)X -3419(number)X -3662(of)X -3744(buckets)X -3986(is)X -4056(actually)X -4306(equal)X -2706 5593(to)N -2782(the)X -2890(maximum)X -3202(number)X -3441(of)X -3520(keys)X -3671(ever)X -3814(present)X -4041(in)X -4116(the)X -4223(table)X -4382(di-)X -2706 5673(vided)N -2884(by)X -2974(the)X -3080(\256ll)X -3178(factor.)X -3 f -10 s -720 5960(USENIX)N -9 f -1042(-)X -3 f -1106(Winter)X -1371('91)X -9 f -1498(-)X -3 f -1562(Dallas,)X -1815(TX)X -4424(5)X - -6 p -%%Page: 6 6 -0(Courier)xf 0 f -10 s 10 xH 0 xS 0 f -3 f -432 258(A)N -510(New)X -682(Hashing)X -985(Package)X -1290(for)X -1413(UNIX)X -3663(Seltzer)X -3920(&)X -4007(Yigit)X -1 f -432 538(pages)N -639(to)X -725(the)X -847(buckets)X -1116(\(also)X -1296(called)X -1512(primary)X -1789(pages\).)X -2062(In)X -2152(a)X -432 626(memory)N -730(based)X -943(representation,)X -1448(over\257ow)X -1763(pages)X -1976(do)X -2086(not)X -432 714(pose)N -628(any)X -792(special)X -1063(problems)X -1409(because)X -1712(we)X -1854(can)X -2014(chain)X -432 802(over\257ow)N -776(pages)X -1017(to)X -1137(primary)X -1449(pages)X -1690(using)X -1921(memory)X -432 890(pointers.)N -776(However,)X -1137(mapping)X -1463(these)X -1674(over\257ow)X -2005(pages)X -432 978(into)N -584(a)X -648(disk)X -809(\256le)X -939(is)X -1019(more)X -1211(of)X -1305(a)X -1368(challenge,)X -1723(since)X -1915(we)X -2036(need)X -432 1066(to)N -547(be)X -675(able)X -861(to)X -975(address)X -1268(both)X -1462(bucket)X -1728(pages,)X -1983(whose)X -432 1154(numbers)N -729(are)X -849(growing)X -1137(linearly,)X -1422(and)X -1558(some)X -1747(indeterminate)X -432 1242(number)N -715(of)X -820(over\257ow)X -1143(pages)X -1364(without)X -1646(reorganizing)X -2090(the)X -432 1330(\256le.)N -604 1444(One)N -789(simple)X -1053(solution)X -1361(would)X -1612(be)X -1739(to)X -1852(allocate)X -2152(a)X -432 1532(separate)N -737(\256le)X -880(for)X -1015(over\257ow)X -1341(pages.)X -1604(The)X -1769(disadvantage)X -432 1620(with)N -605(such)X -783(a)X -850(technique)X -1193(is)X -1276(that)X -1426(it)X -1500(requires)X -1789(an)X -1895(extra)X -2086(\256le)X -432 1708(descriptor,)N -794(an)X -891(extra)X -1073(system)X -1316(call)X -1453(on)X -1554(open)X -1731(and)X -1867(close,)X -2072(and)X -432 1796(logically)N -739(associating)X -1122(two)X -1269(independent)X -1687(\256les.)X -1886(For)X -2023(these)X -432 1884(reasons,)N -728(we)X -857(wanted)X -1123(to)X -1219(map)X -1391(both)X -1567(primary)X -1855(pages)X -2072(and)X -432 1972(over\257ow)N -737(pages)X -940(into)X -1084(the)X -1202(same)X -1387(\256le)X -1509(space.)X -604 2086(The)N -799(buddy-in-waiting)X -1425(algorithm)X -1806(provides)X -2152(a)X -432 2174(mechanism)N -851(to)X -966(support)X -1259(multiple)X -1578(pages)X -1814(per)X -1970(logical)X -432 2262(bucket)N -685(while)X -902(retaining)X -1226(the)X -1362(simple)X -1613(split)X -1788(sequence)X -2121(of)X -432 2350(linear)N -681(hashing.)X -1015(Over\257ow)X -1383(pages)X -1631(are)X -1795(preallocated)X -432 2438(between)N -781(generations)X -1232(of)X -1379(primary)X -1713(pages.)X -1996(These)X -432 2526(over\257ow)N -759(pages)X -984(are)X -1125(used)X -1314(by)X -1436(any)X -1594(bucket)X -1850(containing)X -432 2614(more)N -646(keys)X -842(than)X -1029(\256t)X -1144(on)X -1273(the)X -1420(primary)X -1723(page)X -1924(and)X -2089(are)X -432 2702(reclaimed,)N -808(if)X -896(possible,)X -1217(when)X -1430(the)X -1567(bucket)X -1819(later)X -2000(splits.)X -432 2790(Figure)N -687(3)X -773(depicts)X -1045(the)X -1188(layout)X -1433(of)X -1545(primary)X -1844(pages)X -2072(and)X -432 2878(over\257ow)N -752(pages)X -970(within)X -1209(the)X -1342(same)X -1542(\256le.)X -1699(Over\257ow)X -2036(page)X -432 2966(use)N -586(information)X -1011(is)X -1111(recorded)X -1440(in)X -1548(bitmaps)X -1847(which)X -2089(are)X -432 3054(themselves)N -819(stored)X -1046(on)X -1157(over\257ow)X -1472(pages.)X -1725(The)X -1880(addresses)X -432 3142(of)N -520(the)X -639(bitmap)X -882(pages)X -1086(and)X -1223(the)X -1342(number)X -1608(of)X -1695(pages)X -1898(allocated)X -432 3230(at)N -515(each)X -688(split)X -850(point)X -1039(are)X -1163(stored)X -1384(in)X -1470(the)X -1592(\256le)X -1718(header.)X -1997(Using)X -432 3318(this)N -577(information,)X -1005(both)X -1177(over\257ow)X -1492(addresses)X -1829(and)X -1974(bucket)X -432 3406(addresses)N -764(can)X -900(be)X -999(mapped)X -1276(to)X -1361(disk)X -1517(addresses)X -1848(by)X -1951(the)X -2072(fol-)X -432 3494(lowing)N -674(calculation:)X -0 f -8 s -432 3793(int)N -736(bucket;)X -1192(/*)X -1306(bucket)X -1572(address)X -1876(*/)X -432 3881(u_short)N -736(oaddr;)X -1192(/*)X -1306(OVERFLOW)X -1648(address)X -1952(*/)X -432 3969(int)N -736 -0.4125(nhdr_pages;)AX -1192(/*)X -1306(npages)X -1572(in)X -1686 -112.4062(\256le)AX -1838(header)X -2104(*/)X -432 4057(int)N -736 -0.4125(spares[32];)AX -1192(/*)X -1306(npages)X -1572(at)X -1686(each)X -1876(split)X -2104(*/)X -432 4145(int)N -736(log2\(\);)X -1198(/*)X -1312(ceil\(log)X -1654(base)X -1844(2\))X -1958(*/)X -432 4321(#DEFINE)N -736 -0.3929(BUCKET_TO_PAGE\(bucket\))AX -1610(\\)X -584 4409(bucket)N -850(+)X -926 -0.4167(nhdr_pages)AX -1344(+)X -1420(\\)X -584 4497 -0.3894(\(bucket?spares[logs2\(bucket)AN -1648(+)X -1724(1\)-1]:0\))X -432 4673(#DEFINE)N -736 -0.3947(OADDR_TO_PAGE\(oaddr\))AX -1534(\\)X -584 4761 -0.3984(BUCKET_TO_PAGE\(\(1)AN -1268(<<)X -1382 -0.4091(\(oaddr>>11\)\))AX -1876(-)X -1952(1\))X -2066(+)X -2142(\\)X -584 4849(oaddr)N -812(&)X -888(0x7ff;)X -1 f -10 s -604 5262(An)N -728(over\257ow)X -1039(page)X -1217(is)X -1295(addressed)X -1637(by)X -1742(its)X -1842(split)X -2004(point,)X -432 5350(identifying)N -858(the)X -1031(generations)X -1476(between)X -1819(which)X -2090(the)X -432 5438(over\257ow)N -740(page)X -915(is)X -991(allocated,)X -1324(and)X -1463(its)X -1561(page)X -1736(number,)X -2023(iden-)X -432 5526(tifying)N -665(the)X -783(particular)X -1111(page)X -1283(within)X -1507(the)X -1625(split)X -1782(point.)X -1986(In)X -2073(this)X -432 5614(implementation,)N -983(offsets)X -1225(within)X -1457(pages)X -1668(are)X -1795(16)X -1903(bits)X -2046(long)X -432 5702(\(limiting)N -732(the)X -851(maximum)X -1196(page)X -1368(size)X -1513(to)X -1595(32K\),)X -1800(so)X -1891(we)X -2005(select)X -2418 538(an)N -2535(over\257ow)X -2860(page)X -3052(addressing)X -3435(algorithm)X -3786(that)X -3946(can)X -4098(be)X -2418 626(expressed)N -2760(in)X -2847(16)X -2952(bits)X -3091(and)X -3231(which)X -3451(allows)X -3684(quick)X -3886(retrieval.)X -2418 714(The)N -2568(top)X -2695(\256ve)X -2840(bits)X -2980(indicate)X -3258(the)X -3380(split)X -3541(point)X -3729(and)X -3869(the)X -3991(lower)X -2418 802(eleven)N -2650(indicate)X -2926(the)X -3046(page)X -3220(number)X -3487(within)X -3713(the)X -3832(split)X -3990(point.)X -2418 890(Since)N -2633(\256ve)X -2789(bits)X -2940(are)X -3075(reserved)X -3384(for)X -3514(the)X -3648(split)X -3821(point,)X -4041(\256les)X -2418 978(may)N -2578(split)X -2737(32)X -2839(times)X -3034(yielding)X -3318(a)X -3376(maximum)X -3721(\256le)X -3844(size)X -3990(of)X -4078(2)X -7 s -946(32)Y -10 s -2418 1066(buckets)N -2698(and)X -2849(32)X -2 f -(*)S -1 f -2982(2)X -7 s -1034(11)Y -10 s -3113 1066(over\257ow)N -3433(pages.)X -3691(The)X -3850(maximum)X -2418 1154(page)N -2597(size)X -2749(is)X -2829(2)X -7 s -1122(15)Y -10 s -1154(,)Y -2971(yielding)X -3259(a)X -3321(maximum)X -3671(\256le)X -3799(size)X -3950(greater)X -2418 1242(than)N -2601(131,000)X -2906(GB)X -3061(\(on)X -3212(\256le)X -3358(systems)X -3655(supporting)X -4041(\256les)X -2418 1330(larger)N -2626(than)X -2784(4GB\).)X -10 f -2418 1418 -0.0930(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)AN -1 Dt -4014 2275 MXY -0 133 Dl -3881 2275 MXY -0 133 Dl -3748 2275 MXY -0 133 Dl -3083 2275 MXY -0 133 Dl -5 s -1 f -3523 2475(2/3)N -3390(2/2)X -3257(2/1)X -2859(1/2)X -2726(1/1)X -5 Dt -3814 1743 MXY -0 133 Dl -3282 1743 MXY -0 133 Dl -3017 1743 MXY -0 133 Dl -2884 1743 MXY -0 133 Dl -1 Dt -3681 1743 MXY -0 133 Dl -133 0 Dl -0 -133 Dl --133 0 Dl -3548 MX -0 133 Dl -133 0 Dl -0 -133 Dl --133 0 Dl -3415 MX -0 133 Dl -133 0 Dl -0 -133 Dl --133 0 Dl -3282 MX -0 133 Dl -133 0 Dl -0 -133 Dl --133 0 Dl -3150 MX -0 133 Dl -132 0 Dl -0 -133 Dl --132 0 Dl -3017 MX -0 133 Dl -133 0 Dl -0 -133 Dl --133 0 Dl -2884 MX -0 133 Dl -133 0 Dl -0 -133 Dl --133 0 Dl -3 f -8 s -3017 2601(Over\257ow)N -3285(Addresses)X -3515 2833(Over\257ow)N -3783(Pages)X -2850(Buckets)X -1 Di -3349 2740 MXY - 3349 2740 lineto - 3482 2740 lineto - 3482 2873 lineto - 3349 2873 lineto - 3349 2740 lineto -closepath 3 3349 2740 3482 2873 Dp -2684 MX -0 133 Dl -133 0 Dl -0 -133 Dl --133 0 Dl -5 Dt -4146 2275 MXY -0 133 Dl -3216 2275 MXY -0 133 Dl -2684 2275 MXY -0 133 Dl -2551 2275 MXY -0 133 Dl -1 f -3798 1963(3)N -3266 1980(2)N -3001(1)X -2868(0)X -1 Dt -2751 1743 MXY -0 133 Dl -133 0 Dl -0 -133 Dl --133 0 Dl -3548 2275 MXY --15 -22 Dl -2 16 Dl --13 11 Dl -26 -5 Dl --282 -117 Dl -3432 2275 MXY --10 -25 Dl --2 16 Dl --15 8 Dl -27 1 Dl --166 -117 Dl -3282 2275 MXY -12 -25 Dl --14 10 Dl --15 -6 Dl -17 21 Dl --16 -117 Dl -2884 2275 MXY -26 7 Dl --12 -12 Dl -3 -16 Dl --17 21 Dl -382 -117 Dl -2751 2275 MXY -25 9 Dl --11 -12 Dl -5 -17 Dl --19 20 Dl -515 -117 Dl -3 f -3070 2152(Over\257ow)N -3338(Pages)X -3482 2275 MXY - 3482 2275 lineto - 3615 2275 lineto - 3615 2408 lineto - 3482 2408 lineto - 3482 2275 lineto -closepath 3 3482 2275 3615 2408 Dp -3349 MX - 3349 2275 lineto - 3482 2275 lineto - 3482 2408 lineto - 3349 2408 lineto - 3349 2275 lineto -closepath 3 3349 2275 3482 2408 Dp -3216 MX - 3216 2275 lineto - 3349 2275 lineto - 3349 2408 lineto - 3216 2408 lineto - 3216 2275 lineto -closepath 3 3216 2275 3349 2408 Dp -2817 MX - 2817 2275 lineto - 2950 2275 lineto - 2950 2408 lineto - 2817 2408 lineto - 2817 2275 lineto -closepath 3 2817 2275 2950 2408 Dp -2684 MX - 2684 2275 lineto - 2817 2275 lineto - 2817 2408 lineto - 2684 2408 lineto - 2684 2275 lineto -closepath 3 2684 2275 2817 2408 Dp -3615 MX -0 133 Dl -531 0 Dl -0 -133 Dl --531 0 Dl -2950 MX -0 133 Dl -266 0 Dl -0 -133 Dl --266 0 Dl -2551 MX -0 133 Dl -133 0 Dl -0 -133 Dl --133 0 Dl -3798 1726 MXY --21 -18 Dl -6 16 Dl --10 13 Dl -25 -11 Dl --599 -99 Dl -3266 1726 MXY --1 -27 Dl --7 15 Dl --17 1 Dl -25 11 Dl --67 -99 Dl -3033 1726 MXY -27 1 Dl --14 -8 Dl --1 -17 Dl --12 24 Dl -166 -99 Dl -2900 1726 MXY -27 7 Dl --13 -11 Dl -3 -17 Dl --17 21 Dl -299 -99 Dl -3058 1621(Split)N -3203(Points)X -2418 2275 MXY -0 133 Dl -133 0 Dl -0 -133 Dl --133 0 Dl -3 Dt --1 Ds -3137(Figure)Y -2619(3:)X -1 f -2691(Split)X -2832(points)X -3008(occur)X -3168(between)X -3399(generations)X -3712(and)X -3823(are)X -3919(numbered)X -2418 3225(from)N -2560(0.)X -2642(In)X -2713(this)X -2824(\256gure)X -2991(there)X -3136(are)X -3231(two)X -3345(over\257ow)X -3590(pages)X -3753(allocated)X -4000(at)X -4063(split)X -2418 3313(point)N -2566(1)X -2614(and)X -2722(three)X -2865(allocated)X -3111(at)X -3173(split)X -3300(point)X -3448(2.)X -10 s -10 f -2418 3489 -0.0930(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)AN -3 f -2949 3731(Buffer)N -3192(Management)X -1 f -2590 3863(The)N -2744(hash)X -2920(table)X -3105(is)X -3187(stored)X -3412(in)X -3502(memory)X -3797(as)X -3892(a)X -3956(logical)X -2418 3951(array)N -2633(of)X -2749(bucket)X -3012(pointers.)X -3359(Physically,)X -3761(the)X -3907(array)X -4121(is)X -2418 4039(arranged)N -2728(in)X -2818(segments)X -3144(of)X -3239(256)X -3387(pointers.)X -3713(Initially,)X -4013(there)X -2418 4127(is)N -2530(space)X -2767(to)X -2887(allocate)X -3195(256)X -3373(segments.)X -3769(Reallocation)X -2418 4215(occurs)N -2651(when)X -2847(the)X -2967(number)X -3234(of)X -3323(buckets)X -3590(exceeds)X -3867(32K)X -4027(\(256)X -2418 4303(*)N -2508(256\).)X -2745(Primary)X -3053(pages)X -3286(may)X -3473(be)X -3598(accessed)X -3929(directly)X -2418 4391(through)N -2711(the)X -2853(array)X -3062(by)X -3185(bucket)X -3442(number)X -3730(and)X -3889(over\257ow)X -2418 4479(pages)N -2628(are)X -2754 0.4028(referenced)AX -3122(logically)X -3429(by)X -3536(their)X -3710(over\257ow)X -4022(page)X -2418 4567(address.)N -2726(For)X -2864(small)X -3063(hash)X -3236(tables,)X -3469(it)X -3539(is)X -3618(desirable)X -3934(to)X -4022(keep)X -2418 4655(all)N -2525(pages)X -2735(in)X -2823(main)X -3009(memory)X -3302(while)X -3506(on)X -3612(larger)X -3826(tables,)X -4059(this)X -2418 4743(is)N -2523(probably)X -2860(impossible.)X -3298(To)X -3438(satisfy)X -3698(both)X -3891(of)X -4009(these)X -2418 4831(requirements,)N -2900(the)X -3041(package)X -3348(includes)X -3658(buffer)X -3897(manage-)X -2418 4919(ment)N -2598(with)X -2760(LRU)X -2940(\(least)X -3134(recently)X -3413(used\))X -3607(replacement.)X -2590 5033(By)N -2730(default,)X -3020(the)X -3165(package)X -3475(allocates)X -3802(up)X -3928(to)X -4036(64K)X -2418 5121(bytes)N -2616(of)X -2712(buffered)X -3014(pages.)X -3246(All)X -3377(pages)X -3589(in)X -3680(the)X -3807(buffer)X -4032(pool)X -2418 5209(are)N -2542(linked)X -2766(in)X -2852(LRU)X -3036(order)X -3230(to)X -3316(facilitate)X -3621(fast)X -3761(replacement.)X -2418 5297(Whereas)N -2724(ef\256cient)X -3011(access)X -3241(to)X -3327(primary)X -3605(pages)X -3812(is)X -3889(provided)X -2418 5385(by)N -2521(the)X -2642(bucket)X -2879(array,)X -3087(ef\256cient)X -3372(access)X -3600(to)X -3684(over\257ow)X -3991(pages)X -2418 5473(is)N -2501(provided)X -2816(by)X -2926(linking)X -3182(over\257ow)X -3497(page)X -3679(buffers)X -3936(to)X -4027(their)X -2418 5561(predecessor)N -2827(page)X -3008(\(either)X -3247(the)X -3374(primary)X -3657(page)X -3838(or)X -3933(another)X -2418 5649(over\257ow)N -2742(page\).)X -3000(This)X -3181(means)X -3425(that)X -3584(an)X -3699(over\257ow)X -4022(page)X -3 f -432 5960(6)N -2970(USENIX)X -9 f -3292(-)X -3 f -3356(Winter)X -3621('91)X -9 f -3748(-)X -3 f -3812(Dallas,)X -4065(TX)X - -7 p -%%Page: 7 7 -0(Courier)xf 0 f -10 s 10 xH 0 xS 0 f -3 f -720 258(Seltzer)N -977(&)X -1064(Yigit)X -3278(A)X -3356(New)X -3528(Hashing)X -3831(Package)X -4136(for)X -4259(UNIX)X -1 f -720 538(cannot)N -955(be)X -1052(present)X -1305(in)X -1388(the)X -1507(buffer)X -1724(pool)X -1886(if)X -1955(its)X -2050(primary)X -2324(page)X -720 626(is)N -804(not)X -937(present.)X -1240(This)X -1413(does)X -1591(not)X -1724(impact)X -1972(performance)X -2409(or)X -720 714(functionality,)N -1209(because)X -1524(an)X -1660(over\257ow)X -2005(page)X -2217(will)X -2400(be)X -720 802(accessed)N -1048(only)X -1236(after)X -1430(its)X -1550(predecessor)X -1975(page)X -2172(has)X -2324(been)X -720 890(accessed.)N -1068(Figure)X -1303(4)X -1369(depicts)X -1622(the)X -1746(data)X -1905(structures)X -2242(used)X -2414(to)X -720 978(manage)N -990(the)X -1108(buffer)X -1325(pool.)X -892 1092(The)N -1040(in-memory)X -1419(bucket)X -1656(array)X -1845(contains)X -2134(pointers)X -2414(to)X -720 1180(buffer)N -975(header)X -1248(structures)X -1617(which)X -1870(represent)X -2222(primary)X -720 1268(pages.)N -968(Buffer)X -1203(headers)X -1474(contain)X -1735(modi\256ed)X -2043(bits,)X -2202(the)X -2324(page)X -720 1356(address)N -995(of)X -1096(the)X -1228(buffer,)X -1479(a)X -1548(pointer)X -1808(to)X -1903(the)X -2034(actual)X -2259(buffer,)X -720 1444(and)N -875(a)X -950(pointer)X -1216(to)X -1317(the)X -1454(buffer)X -1690(header)X -1944(for)X -2077(an)X -2191(over\257ow)X -720 1532(page)N -901(if)X -979(it)X -1052(exists,)X -1283(in)X -1374(addition)X -1665(to)X -1756(the)X -1883(LRU)X -2072(links.)X -2296(If)X -2378(the)X -720 1620(buffer)N -950(corresponding)X -1442(to)X -1537(a)X -1606(particular)X -1947(bucket)X -2194(is)X -2280(not)X -2414(in)X -720 1708(memory,)N -1048(its)X -1164(pointer)X -1432(is)X -1526(NULL.)X -1801(In)X -1909(effect,)X -2154(pages)X -2377(are)X -720 1796(linked)N -950(in)X -1042(three)X -1233(ways.)X -1468(Using)X -1689(the)X -1817(buffer)X -2043(headers,)X -2338(they)X -720 1884(are)N -851(linked)X -1083(physically)X -1444(through)X -1725(the)X -1854(LRU)X -2045(links)X -2231(and)X -2378(the)X -720 1972(over\257ow)N -1036(links.)X -1241(Using)X -1462(the)X -1590(pages)X -1803(themselves,)X -2209(they)X -2377(are)X -720 2060(linked)N -943(logically)X -1246(through)X -1518(the)X -1639(over\257ow)X -1946(addresses)X -2276(on)X -2378(the)X -720 2148(page.)N -948(Since)X -1162(over\257ow)X -1482(pages)X -1700(are)X -1834(accessed)X -2151(only)X -2328(after)X -720 2236(their)N -904(predecessor)X -1321(pages,)X -1560(they)X -1734(are)X -1869(removed)X -2186(from)X -2378(the)X -720 2324(buffer)N -937(pool)X -1099(when)X -1293(their)X -1460(primary)X -1734(is)X -1807(removed.)X -10 f -720 2412 -0.0930(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)AN -1 Dt -2309 3177 MXY -24 15 Dl --8 -15 Dl -8 -15 Dl --24 15 Dl -52 0 Dl -789 3160 MXY --35 0 Dl -0 -156 Dl -1607 0 Dl -0 173 Dl -789 3091 MXY --24 -15 Dl -9 15 Dl --9 15 Dl -24 -15 Dl --69 0 Dl -2309 3125 MXY -104 0 Dl -0 -155 Dl --1693 0 Dl -0 121 Dl -927 3160 MXY -24 15 Dl --9 -15 Dl -9 -15 Dl --24 15 Dl -553 0 Dl -1618 3177 MXY -8 27 Dl -4 -17 Dl -16 -6 Dl --28 -4 Dl -138 121 Dl -1895 3315 MXY -28 3 Dl --15 -9 Dl -1 -18 Dl --14 24 Dl -276 -138 Dl -3108 MY --28 -3 Dl -15 10 Dl --1 17 Dl -14 -24 Dl --276 138 Dl -1756 3229 MXY --8 -27 Dl --3 17 Dl --16 6 Dl -27 4 Dl --138 -121 Dl -1480 MX --24 -15 Dl -9 15 Dl --9 15 Dl -24 -15 Dl --553 0 Dl -3 f -5 s -1083 3073(LRU)N -1178(chain)X -4 Ds -1402 3851 MXY - 1402 3851 lineto - 1471 3851 lineto - 1471 3920 lineto - 1402 3920 lineto - 1402 3851 lineto -closepath 19 1402 3851 1471 3920 Dp -1445 3747(Over\257ow)N -1613(Address)X -1549 3609 MXY -0 69 Dl -1756 MX --23 -15 Dl -8 15 Dl --8 15 Dl -23 -15 Dl --207 0 Dl --1 Ds -3 Dt -1756 3419 MXY --6 -28 Dl --4 17 Dl --17 5 Dl -27 6 Dl --138 -138 Dl -2240 3471 MXY -15 -24 Dl --15 9 Dl --15 -9 Dl -15 24 Dl -0 -138 Dl -1826 3609 MXY -15 -24 Dl --15 9 Dl --16 -9 Dl -16 24 Dl -0 -138 Dl -1549 MX -15 -24 Dl --15 9 Dl --15 -9 Dl -15 24 Dl -0 -138 Dl -858 3471 MXY -15 -24 Dl --15 9 Dl --15 -9 Dl -15 24 Dl -0 -138 Dl -2240 3056 MXY -15 -24 Dl --15 9 Dl --15 -9 Dl -15 24 Dl -0 -138 Dl -1549 3056 MXY -15 -24 Dl --15 9 Dl --15 -9 Dl -15 24 Dl -0 -138 Dl -858 3056 MXY -15 -24 Dl --15 9 Dl --15 -9 Dl -15 24 Dl -0 -138 Dl -1 Dt -2171 3471 MXY - 2171 3471 lineto - 2448 3471 lineto - 2448 3609 lineto - 2171 3609 lineto - 2171 3471 lineto -closepath 19 2171 3471 2448 3609 Dp -1756 3609 MXY - 1756 3609 lineto - 2033 3609 lineto - 2033 3747 lineto - 1756 3747 lineto - 1756 3609 lineto -closepath 3 1756 3609 2033 3747 Dp -1480 3471 MXY - 1480 3471 lineto - 1756 3471 lineto - 1756 3609 lineto - 1480 3609 lineto - 1480 3471 lineto -closepath 19 1480 3471 1756 3609 Dp -789 MX - 789 3471 lineto - 1065 3471 lineto - 1065 3609 lineto - 789 3609 lineto - 789 3471 lineto -closepath 19 789 3471 1065 3609 Dp -962 3903(Buffer)N -1083(Header)X -849 3851 MXY - 849 3851 lineto - 918 3851 lineto - 918 3920 lineto - 849 3920 lineto - 849 3851 lineto -closepath 14 849 3851 918 3920 Dp -1756 3194 MXY - 1756 3194 lineto - 1895 3194 lineto - 1895 3471 lineto - 1756 3471 lineto - 1756 3194 lineto -closepath 14 1756 3194 1895 3471 Dp -2171 3056 MXY - 2171 3056 lineto - 2309 3056 lineto - 2309 3333 lineto - 2171 3333 lineto - 2171 3056 lineto -closepath 14 2171 3056 2309 3333 Dp -1480 MX - 1480 3056 lineto - 1618 3056 lineto - 1618 3333 lineto - 1480 3333 lineto - 1480 3056 lineto -closepath 14 1480 3056 1618 3333 Dp -789 MX - 789 3056 lineto - 927 3056 lineto - 927 3333 lineto - 789 3333 lineto - 789 3056 lineto -closepath 14 789 3056 927 3333 Dp -2780 MY -0 138 Dl -138 0 Dl -0 -138 Dl --138 0 Dl -927 MX -0 138 Dl -138 0 Dl -0 -138 Dl --138 0 Dl -1065 MX -0 138 Dl -138 0 Dl -0 -138 Dl --138 0 Dl -1203 MX -0 138 Dl -139 0 Dl -0 -138 Dl --139 0 Dl -1342 MX -0 138 Dl -138 0 Dl -0 -138 Dl --138 0 Dl -1480 MX -0 138 Dl -138 0 Dl -0 -138 Dl --138 0 Dl -1618 MX -0 138 Dl -138 0 Dl -0 -138 Dl --138 0 Dl -1756 MX -0 138 Dl -139 0 Dl -0 -138 Dl --139 0 Dl -1895 MX -0 138 Dl -138 0 Dl -0 -138 Dl --138 0 Dl -2033 MX -0 138 Dl -138 0 Dl -0 -138 Dl --138 0 Dl -2171 MX -0 138 Dl -138 0 Dl -0 -138 Dl --138 0 Dl -2309 MX -0 138 Dl -139 0 Dl -0 -138 Dl --139 0 Dl -13 s -1048 2720(In)N -1173(Memory)X -1580(Bucket)X -1918(Array)X -867 3584(B0)N -1558(B5)X -2223(B10)X -1788 3722(O1/1)N -5 s -1515 3903(Primay)N -1651(Buffer)X -4 Ds -1990 3851 MXY - 1990 3851 lineto - 2059 3851 lineto - 2059 3920 lineto - 1990 3920 lineto - 1990 3851 lineto -closepath 3 1990 3851 2059 3920 Dp -2102 3903(Over\257ow)N -2270(Buffer)X -3 Dt --1 Ds -8 s -720 4184(Figure)N -922(4:)X -1 f -996(Three)X -1164(primary)X -1386(pages)X -1551(\(B0,)X -1683(B5,)X -1794(B10\))X -1942(are)X -2039(accessed)X -2281(directly)X -720 4272(from)N -862(the)X -958(bucket)X -1146(array.)X -1326(The)X -1443(one)X -1553(over\257ow)X -1798(page)X -1935(\(O1/1\))X -2122(is)X -2182(linked)X -2359(phy-)X -720 4360(sically)N -915(from)X -1067(its)X -1155(primary)X -1384(page's)X -1577(buffer)X -1759(header)X -1955(as)X -2035(well)X -2172(as)X -2252(logically)X -720 4448(from)N -860(its)X -937(predecessor)X -1253(page)X -1389(buffer)X -1560(\(B5\).)X -10 s -10 f -720 4624 -0.0930(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)AN -3 f -1191 4954(Table)N -1406(Parameterization)X -1 f -892 5086(When)N -1107(a)X -1166(hash)X -1336(table)X -1515(is)X -1590(created,)X -1865(the)X -1985(bucket)X -2221(size,)X -2388(\256ll)X -720 5174(factor,)N -953(initial)X -1164(number)X -1434(of)X -1526(elements,)X -1856(number)X -2125(of)X -2216(bytes)X -2409(of)X -720 5262(main)N -919(memory)X -1225(used)X -1411(for)X -1543(caching,)X -1851(and)X -2005(a)X -2079(user-de\256ned)X -720 5350(hash)N -892(function)X -1184(may)X -1347(be)X -1448(speci\256ed.)X -1797(The)X -1946(bucket)X -2184(size)X -2333(\(and)X -720 5438(page)N -906(size)X -1064(for)X -1191(over\257ow)X -1509(pages\))X -1752(defaults)X -2039(to)X -2134(256)X -2287(bytes.)X -720 5526(For)N -858(tables)X -1072(with)X -1241(large)X -1429(data)X -1590(items,)X -1810(it)X -1881(may)X -2046(be)X -2149(preferable)X -720 5614(to)N -803(increase)X -1088(the)X -1207(page)X -1380(size,)X -1545(and,)X -1701(conversely,)X -2089(applications)X -720 5702(storing)N -1002(small)X -1235(items)X -1467(exclusively)X -1891(in)X -2012(memory)X -2338(may)X -2706 538(bene\256t)N -2966(from)X -3164(a)X -3242(smaller)X -3520(bucket)X -3776(size.)X -3983(A)X -4082(bucket)X -4337(size)X -2706 626(smaller)N -2962(than)X -3120(64)X -3220(bytes)X -3409(is)X -3482(not)X -3604(recommended.)X -2878 740(The)N -3031(\256ll)X -3147(factor)X -3363(indicates)X -3676(a)X -3740(desired)X -4000(density)X -4258(within)X -2706 828(the)N -2833(hash)X -3009(table.)X -3234(It)X -3312(is)X -3394(an)X -3499(approximation)X -3995(of)X -4091(the)X -4217(number)X -2706 916(of)N -2815(keys)X -3004(allowed)X -3300(to)X -3404(accumulate)X -3811(in)X -3914(any)X -4071(one)X -4228(bucket,)X -2706 1004(determining)N -3119(when)X -3319(the)X -3442(hash)X -3614(table)X -3795(grows.)X -4056(Its)X -4161(default)X -4409(is)X -2706 1092(eight.)N -2953(If)X -3054(the)X -3199(user)X -3380(knows)X -3636(the)X -3781(average)X -4079(size)X -4251(of)X -4364(the)X -2706 1180(key/data)N -3008(pairs)X -3194(being)X -3402(stored)X -3627(in)X -3718(the)X -3845(table,)X -4050(near)X -4218(optimal)X -2706 1268(bucket)N -2943(sizes)X -3122(and)X -3261(\256ll)X -3372(factors)X -3614(may)X -3775(be)X -3874(selected)X -4155(by)X -4257(apply-)X -2706 1356(ing)N -2828(the)X -2946(equation:)X -0 f -8 s -2706 1655(\(1\))N -2994 -0.3938(\(\(average_pair_length)AX -3830(+)X -3906(4\))X -4020(*)X -3032 1743(ffactor\))N -3374(>=)X -3488(bsize)X -1 f -10 s -2706 2042(For)N -2859(highly)X -3104(time)X -3287(critical)X -3551(applications,)X -3999(experimenting)X -2706 2130(with)N -2919(different)X -3266(bucket)X -3550(sizes)X -3776(and)X -3962(\256ll)X -4120(factors)X -4409(is)X -2706 2218(encouraged.)N -2878 2332(Figures)N -3144(5a,b,)X -3326(and)X -3468(c)X -3530(illustrate)X -3836(the)X -3960(effects)X -4200(of)X -4292(vary-)X -2706 2420(ing)N -2841(page)X -3026(sizes)X -3215(and)X -3363(\256ll)X -3483(factors)X -3734(for)X -3860(the)X -3990(same)X -4187(data)X -4353(set.)X -2706 2508(The)N -2864(data)X -3031(set)X -3152(consisted)X -3482(of)X -3581(24474)X -3813(keys)X -3992(taken)X -4198(from)X -4386(an)X -2706 2596(online)N -2931(dictionary.)X -3301(The)X -3451(data)X -3609(value)X -3807(for)X -3925(each)X -4097(key)X -4237(was)X -4386(an)X -2706 2684(ASCII)N -2938(string)X -3143(for)X -3260(an)X -3359(integer)X -3605(from)X -3784(1)X -3847(to)X -3931(24474)X -4153(inclusive.)X -2706 2772(The)N -2867(test)X -3013(run)X -3155(consisted)X -3488(of)X -3590(creating)X -3884(a)X -3955(new)X -4124(hash)X -4306(table)X -2706 2860(\(where)N -2966(the)X -3100(ultimate)X -3398(size)X -3559(of)X -3662(the)X -3796(table)X -3987(was)X -4147(known)X -4400(in)X -2706 2948(advance\),)N -3054(entering)X -3354(each)X -3539(key/data)X -3848(pair)X -4010(into)X -4171(the)X -4306(table)X -2706 3036(and)N -2849(then)X -3014(retrieving)X -3353(each)X -3528(key/data)X -3827(pair)X -3979(from)X -4162(the)X -4286(table.)X -2706 3124(Each)N -2898(of)X -2996(the)X -3125(graphs)X -3369(shows)X -3599(the)X -3727(timings)X -3996(resulting)X -4306(from)X -2706 3212(varying)N -2973(the)X -3093(pagesize)X -3392(from)X -3570(128)X -3712(bytes)X -3903(to)X -3986(1M)X -4118(and)X -4255(the)X -4374(\256ll)X -2706 3300(factor)N -2929(from)X -3120(1)X -3195(to)X -3292(128.)X -3486(For)X -3631(each)X -3813(run,)X -3974(the)X -4106(buffer)X -4337(size)X -2706 3388(was)N -2874(set)X -3006(at)X -3106(1M.)X -3299(The)X -3466(tests)X -3650(were)X -3849(all)X -3971(run)X -4120(on)X -4242(an)X -4360(HP)X -2706 3476(9000/370)N -3077(\(33.3)X -3312(Mhz)X -3527(MC68030\),)X -3966(with)X -4176(16M)X -4395(of)X -2706 3564(memory,)N -3042(64K)X -3228(physically)X -3605(addressed)X -3970(cache,)X -4222(and)X -4386(an)X -2706 3652(HP7959S)N -3055(disk)X -3231(drive,)X -3459(running)X -3751(4.3BSD-Reno)X -4244(single-)X -2706 3740(user.)N -2878 3854(Both)N -3066(system)X -3321(time)X -3496(\(Figure)X -3764(5a\))X -3899(and)X -4047(elapsed)X -4320(time)X -2706 3942(\(Figure)N -2966(5b\))X -3097(show)X -3290(that)X -3434(for)X -3552(all)X -3655(bucket)X -3892(sizes,)X -4091(the)X -4212(greatest)X -2706 4030(performance)N -3137(gains)X -3329(are)X -3451(made)X -3648(by)X -3751(increasing)X -4104(the)X -4225(\256ll)X -4336(fac-)X -2706 4118(tor)N -2822(until)X -2995(equation)X -3298(1)X -3365(is)X -3445(satis\256ed.)X -3774(The)X -3925(user)X -4085(time)X -4253(shown)X -2706 4206(in)N -2791(Figure)X -3023(5c)X -3122(gives)X -3314(a)X -3373(more)X -3561(detailed)X -3838(picture)X -4083(of)X -4172(how)X -4332(per-)X -2706 4294(formance)N -3054(varies.)X -3330(The)X -3499(smaller)X -3778(bucket)X -4035(sizes)X -4234(require)X -2706 4382(fewer)N -2921(keys)X -3099(per)X -3233(page)X -3416(to)X -3509(satisfy)X -3749(equation)X -4056(1)X -4127(and)X -4274(there-)X -2706 4470(fore)N -2860(incur)X -3049(fewer)X -3257(collisions.)X -3607(However,)X -3946(when)X -4144(the)X -4265(buffer)X -2706 4558(pool)N -2884(size)X -3045(is)X -3134(\256xed,)X -3349(smaller)X -3620(pages)X -3838(imply)X -4059(more)X -4259(pages.)X -2706 4646(An)N -2830(increased)X -3160(number)X -3430(of)X -3522(pages)X -3730(means)X -3960(more)X -2 f -4150(malloc\(3\))X -1 f -2706 4734(calls)N -2879(and)X -3021(more)X -3212(overhead)X -3533(in)X -3621(the)X -3745(hash)X -3918(package's)X -4265(buffer)X -2706 4822(manager)N -3003(to)X -3085(manage)X -3355(the)X -3473(additional)X -3813(pages.)X -2878 4936(The)N -3028(tradeoff)X -3308(works)X -3529(out)X -3655(most)X -3834(favorably)X -4166(when)X -4364(the)X -2706 5024(page)N -2886(size)X -3039(is)X -3120(256)X -3268(and)X -3412(the)X -3538(\256ll)X -3654(factor)X -3870(is)X -3950(8.)X -4057(Similar)X -4319(con-)X -2706 5112(clusions)N -3009(were)X -3207(obtained)X -3524(if)X -3614(the)X -3753(test)X -3905(was)X -4071(run)X -4218(without)X -2706 5200(knowing)N -3007(the)X -3126(\256nal)X -3289(table)X -3466(size)X -3612(in)X -3695(advance.)X -4020(If)X -4095(the)X -4214(\256le)X -4337(was)X -2706 5288(closed)N -2942(and)X -3088(written)X -3345(to)X -3437(disk,)X -3620(the)X -3748(conclusions)X -4156(were)X -4343(still)X -2706 5376(the)N -2832(same.)X -3065(However,)X -3408(rereading)X -3740(the)X -3865(\256le)X -3994(from)X -4177(disk)X -4337(was)X -2706 5464(slightly)N -2983(faster)X -3199(if)X -3285(a)X -3358(larger)X -3583(bucket)X -3834(size)X -3996(and)X -4149(\256ll)X -4274(factor)X -2706 5552(were)N -2898(used)X -3079(\(1K)X -3238(bucket)X -3486(size)X -3645(and)X -3795(32)X -3909(\256ll)X -4031(factor\).)X -4320(This)X -2706 5640(follows)N -2987(intuitively)X -3356(from)X -3553(the)X -3691(improved)X -4038(ef\256ciency)X -4395(of)X -3 f -720 5960(USENIX)N -9 f -1042(-)X -3 f -1106(Winter)X -1371('91)X -9 f -1498(-)X -3 f -1562(Dallas,)X -1815(TX)X -4424(7)X - -8 p -%%Page: 8 8 -0(Courier)xf 0 f -10 s 10 xH 0 xS 0 f -3 f -432 258(A)N -510(New)X -682(Hashing)X -985(Package)X -1290(for)X -1413(UNIX)X -3663(Seltzer)X -3920(&)X -4007(Yigit)X -1 f -432 538(performing)N -830(1K)X -965(reads)X -1172(from)X -1365(the)X -1500(disk)X -1670(rather)X -1894(than)X -2068(256)X -432 626(byte)N -609(reads.)X -857(In)X -962(general,)X -1257(performance)X -1702(for)X -1834(disk)X -2005(based)X -432 714(tables)N -639(is)X -712(best)X -861(when)X -1055(the)X -1173(page)X -1345(size)X -1490(is)X -1563(approximately)X -2046(1K.)X -10 f -432 802 -0.0930(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)AN -619 2380 MXY --12 24 Dl -24 0 Dl --12 -24 Dl -629 2437 MXY --12 24 Dl -24 0 Dl --12 -24 Dl -648 2504 MXY --12 25 Dl -24 0 Dl --12 -25 Dl -686 2515 MXY --12 24 Dl -24 0 Dl --12 -24 Dl -762 2516 MXY --12 24 Dl -25 0 Dl --13 -24 Dl -916 2515 MXY --13 24 Dl -25 0 Dl --12 -24 Dl -1222 2516 MXY --12 24 Dl -24 0 Dl --12 -24 Dl -1834 2515 MXY --12 24 Dl -24 0 Dl --12 -24 Dl -1 Dt -619 2392 MXY -10 57 Dl -19 67 Dl -38 11 Dl -76 1 Dl -154 -1 Dl -306 1 Dl -612 -1 Dl -8 s -1 f -1628 2522(128)N -3 Dt -607 2245 MXY -24 Dc -617 2375 MXY -23 Dc -635 2442 MXY -24 Dc -674 2525 MXY -23 Dc -750 2529 MXY -24 Dc -904 2527 MXY -23 Dc -1210 MX -23 Dc -1822 2528 MXY -23 Dc -20 Ds -1 Dt -619 2245 MXY -10 130 Dl -19 67 Dl -38 83 Dl -76 4 Dl -154 -2 Dl -306 0 Dl -612 1 Dl -678 2482(256)N --1 Ds -3 Dt -619 2127 MXY -0 24 Dl -0 -12 Dl -12 0 Dl --24 0 Dl -629 2191 MXY -0 25 Dl -0 -12 Dl -12 0 Dl --24 0 Dl -648 2334 MXY -0 24 Dl -0 -12 Dl -12 0 Dl --24 0 Dl -686 2409 MXY -0 25 Dl -0 -13 Dl -12 0 Dl --24 0 Dl -762 2516 MXY -0 25 Dl -0 -12 Dl -13 0 Dl --25 0 Dl -916 2516 MXY -0 24 Dl -0 -12 Dl -12 0 Dl --25 0 Dl -1222 2515 MXY -0 24 Dl -0 -12 Dl -12 0 Dl --24 0 Dl -1834 2515 MXY -0 24 Dl -0 -12 Dl -12 0 Dl --24 0 Dl -5 Dt -619 2139 MXY -10 65 Dl -19 142 Dl -38 75 Dl -76 108 Dl -154 -1 Dl -306 -1 Dl -612 0 Dl -694 2401(512)N -3 Dt -631 2064 MXY --24 24 Dl -12 -12 Dl --12 -12 Dl -24 24 Dl -641 2077 MXY --24 25 Dl -12 -12 Dl --12 -13 Dl -24 25 Dl -660 2132 MXY --24 24 Dl -12 -12 Dl --12 -12 Dl -24 24 Dl -698 2292 MXY --24 24 Dl -12 -12 Dl --12 -12 Dl -24 24 Dl -775 2382 MXY --25 24 Dl -12 -12 Dl --12 -12 Dl -25 24 Dl -928 2516 MXY --25 24 Dl -13 -12 Dl --13 -12 Dl -25 24 Dl -1234 2516 MXY --24 25 Dl -12 -12 Dl --12 -13 Dl -24 25 Dl -1846 2516 MXY --24 24 Dl -12 -12 Dl --12 -12 Dl -24 24 Dl -16 Ds -1 Dt -619 2076 MXY -10 14 Dl -19 54 Dl -38 160 Dl -76 90 Dl -154 134 Dl -306 1 Dl -612 -1 Dl -694 2257(1024)N --1 Ds -3 Dt -619 1877 MXY -12 -24 Dl --24 0 Dl -12 24 Dl -629 1855 MXY -12 -24 Dl --24 0 Dl -12 24 Dl -648 1838 MXY -12 -24 Dl --24 0 Dl -12 24 Dl -686 1860 MXY -12 -25 Dl --24 0 Dl -12 25 Dl -762 1923 MXY -13 -24 Dl --25 0 Dl -12 24 Dl -916 2087 MXY -12 -24 Dl --25 0 Dl -13 24 Dl -1222 2256 MXY -12 -24 Dl --24 0 Dl -12 24 Dl -1834 2541 MXY -12 -25 Dl --24 0 Dl -12 25 Dl -619 1865 MXY -10 -22 Dl -19 -17 Dl -38 21 Dl -76 64 Dl -154 164 Dl -306 169 Dl -612 285 Dl -1645 2427(4096)N -619 1243 MXY -0 24 Dl -0 -12 Dl -12 0 Dl --24 0 Dl -629 1196 MXY -0 24 Dl -0 -12 Dl -12 0 Dl --24 0 Dl -648 1146 MXY -0 24 Dl -0 -12 Dl -12 0 Dl --24 0 Dl -686 1174 MXY -0 25 Dl -0 -13 Dl -12 0 Dl --24 0 Dl -762 1249 MXY -0 24 Dl -0 -12 Dl -13 0 Dl --25 0 Dl -916 1371 MXY -0 24 Dl -0 -12 Dl -12 0 Dl --25 0 Dl -1222 1680 MXY -0 24 Dl -0 -12 Dl -12 0 Dl --24 0 Dl -1834 1999 MXY -0 24 Dl -0 -12 Dl -12 0 Dl --24 0 Dl -619 1255 MXY -10 -47 Dl -19 -50 Dl -38 28 Dl -76 75 Dl -154 122 Dl -306 309 Dl -612 319 Dl -1741 1934(8192)N -5 Dt -609 2531 MXY -1225 0 Dl -609 MX -0 -1553 Dl -2531 MY -0 16 Dl -4 Ds -1 Dt -2531 MY -0 -1553 Dl -593 2625(0)N --1 Ds -5 Dt -916 2531 MXY -0 16 Dl -4 Ds -1 Dt -2531 MY -0 -1553 Dl -884 2625(32)N --1 Ds -5 Dt -1222 2531 MXY -0 16 Dl -4 Ds -1 Dt -2531 MY -0 -1553 Dl -1190 2625(64)N --1 Ds -5 Dt -1528 2531 MXY -0 16 Dl -4 Ds -1 Dt -2531 MY -0 -1553 Dl -1496 2625(96)N --1 Ds -5 Dt -1834 2531 MXY -0 16 Dl -4 Ds -1 Dt -2531 MY -0 -1553 Dl -1786 2625(128)N --1 Ds -5 Dt -609 2531 MXY --16 0 Dl -4 Ds -1 Dt -609 MX -1225 0 Dl -545 2558(0)N --1 Ds -5 Dt -609 2013 MXY --16 0 Dl -4 Ds -1 Dt -609 MX -1225 0 Dl -481 2040(100)N --1 Ds -5 Dt -609 1496 MXY --16 0 Dl -4 Ds -1 Dt -609 MX -1225 0 Dl -481 1523(200)N --1 Ds -5 Dt -609 978 MXY --16 0 Dl -4 Ds -1 Dt -609 MX -1225 0 Dl -481 1005(300)N -1088 2724(Fill)N -1194(Factor)X -422 1611(S)N -426 1667(e)N -426 1724(c)N -424 1780(o)N -424 1837(n)N -424 1893(d)N -428 1949(s)N -3 Dt --1 Ds -3 f -432 2882(Figure)N -636(5a:)X -1 f -744(System)X -956(Time)X -1113(for)X -1209(dictionary)X -1490(data)X -1618(set)X -1711(with)X -1847(1M)X -1958(of)X -2033(buffer)X -432 2970(space)N -594(and)X -707(varying)X -923(bucket)X -1114(sizes)X -1259(and)X -1372(\256ll)X -1465(factors.)X -1675(Each)X -1823(line)X -1940(is)X -2004(labeled)X -432 3058(with)N -562(its)X -639(bucket)X -825(size.)X -10 s -10 f -432 3234 -0.0930(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)AN -8 s -1 f -428 4381(s)N -424 4325(d)N -424 4269(n)N -424 4212(o)N -426 4156(c)N -426 4099(e)N -422 4043(S)N -1116 5156(Fill)N -1222(Factor)X -506 3437(3200)N -4 Ds -1 Dt -666 3410 MXY -1168 0 Dl --1 Ds -5 Dt -666 MX --16 0 Dl -506 3825(2400)N -4 Ds -1 Dt -666 3799 MXY -1168 0 Dl --1 Ds -5 Dt -666 MX --16 0 Dl -506 4214(1600)N -4 Ds -1 Dt -666 4186 MXY -1168 0 Dl --1 Ds -5 Dt -666 MX --16 0 Dl -538 4602(800)N -4 Ds -1 Dt -666 4575 MXY -1168 0 Dl --1 Ds -5 Dt -666 MX --16 0 Dl -602 4990(0)N -4 Ds -1 Dt -666 4963 MXY -1168 0 Dl --1 Ds -5 Dt -666 MX --16 0 Dl -1786 5057(128)N -4 Ds -1 Dt -1834 4963 MXY -0 -1553 Dl --1 Ds -5 Dt -4963 MY -0 16 Dl -1510 5057(96)N -4 Ds -1 Dt -1542 4963 MXY -0 -1553 Dl --1 Ds -5 Dt -4963 MY -0 16 Dl -1218 5057(64)N -4 Ds -1 Dt -1250 4963 MXY -0 -1553 Dl --1 Ds -5 Dt -4963 MY -0 16 Dl -926 5057(32)N -4 Ds -1 Dt -958 4963 MXY -0 -1553 Dl --1 Ds -5 Dt -4963 MY -0 16 Dl -650 5057(0)N -4 Ds -1 Dt -666 4963 MXY -0 -1553 Dl --1 Ds -5 Dt -4963 MY -0 16 Dl -4963 MY -0 -1553 Dl -4963 MY -1168 0 Dl -1741 4752(8192)N -3 Dt -675 3732 MXY -9 -172 Dl -18 -118 Dl -37 128 Dl -73 -121 Dl -146 623 Dl -292 497 Dl -584 245 Dl -4802 MY -0 24 Dl -0 -12 Dl -12 0 Dl --24 0 Dl -1250 4557 MXY -0 25 Dl -0 -13 Dl -12 0 Dl --24 0 Dl -958 4060 MXY -0 24 Dl -0 -12 Dl -12 0 Dl --24 0 Dl -812 3437 MXY -0 24 Dl -0 -12 Dl -12 0 Dl --24 0 Dl -739 3558 MXY -0 24 Dl -0 -12 Dl -12 0 Dl --24 0 Dl -702 3430 MXY -0 25 Dl -0 -13 Dl -13 0 Dl --25 0 Dl -684 3548 MXY -0 24 Dl -0 -12 Dl -12 0 Dl --24 0 Dl -675 3720 MXY -0 24 Dl -0 -12 Dl -12 0 Dl --24 0 Dl -1637 4912(4096)N -675 4307 MXY -9 -58 Dl -18 30 Dl -37 89 Dl -73 144 Dl -146 235 Dl -292 122 Dl -584 89 Dl -4970 MY -12 -24 Dl --24 0 Dl -12 24 Dl -1250 4881 MXY -12 -24 Dl --24 0 Dl -12 24 Dl -958 4759 MXY -12 -24 Dl --24 0 Dl -12 24 Dl -812 4524 MXY -12 -24 Dl --24 0 Dl -12 24 Dl -739 4380 MXY -12 -24 Dl --24 0 Dl -12 24 Dl -702 4291 MXY -13 -24 Dl --25 0 Dl -12 24 Dl -684 4261 MXY -12 -24 Dl --24 0 Dl -12 24 Dl -675 4319 MXY -12 -24 Dl --24 0 Dl -12 24 Dl -734 4662(1024)N -16 Ds -1 Dt -675 4352 MXY -9 60 Dl -18 134 Dl -37 266 Dl -73 117 Dl -146 30 Dl -292 0 Dl -584 -1 Dl --1 Ds -3 Dt -1846 4946 MXY --24 24 Dl -12 -12 Dl --12 -12 Dl -24 24 Dl -1262 4946 MXY --24 25 Dl -12 -12 Dl --12 -13 Dl -24 25 Dl -970 4947 MXY --24 24 Dl -12 -12 Dl --12 -12 Dl -24 24 Dl -824 4917 MXY --24 24 Dl -12 -12 Dl --12 -12 Dl -24 24 Dl -751 4800 MXY --24 24 Dl -12 -12 Dl --12 -12 Dl -24 24 Dl -715 4534 MXY --25 25 Dl -12 -13 Dl --12 -12 Dl -25 25 Dl -696 4400 MXY --24 24 Dl -12 -12 Dl --12 -12 Dl -24 24 Dl -687 4339 MXY --24 25 Dl -12 -12 Dl --12 -13 Dl -24 25 Dl -718 4792(512)N -5 Dt -675 4422 MXY -9 137 Dl -18 278 Dl -37 105 Dl -73 18 Dl -146 -1 Dl -292 0 Dl -584 -1 Dl -3 Dt -4946 MY -0 24 Dl -0 -12 Dl -12 0 Dl --24 0 Dl -1250 4946 MXY -0 25 Dl -0 -12 Dl -12 0 Dl --24 0 Dl -958 4947 MXY -0 24 Dl -0 -12 Dl -12 0 Dl --24 0 Dl -812 4948 MXY -0 24 Dl -0 -12 Dl -12 0 Dl --24 0 Dl -739 4930 MXY -0 24 Dl -0 -12 Dl -12 0 Dl --24 0 Dl -702 4824 MXY -0 25 Dl -0 -12 Dl -13 0 Dl --25 0 Dl -684 4547 MXY -0 24 Dl -0 -12 Dl -12 0 Dl --24 0 Dl -675 4410 MXY -0 25 Dl -0 -13 Dl -12 0 Dl --24 0 Dl -750 4921(256)N -20 Ds -1 Dt -675 4597 MXY -9 246 Dl -18 106 Dl -37 10 Dl -73 0 Dl -146 0 Dl -292 0 Dl -584 -1 Dl --1 Ds -3 Dt -1822 MX -23 Dc -1238 4959 MXY -23 Dc -946 MX -23 Dc -800 MX -23 Dc -727 MX -23 Dc -691 4949 MXY -23 Dc -672 4843 MXY -24 Dc -663 4597 MXY -24 Dc -1395 4961(128)N -1 Dt -675 4855 MXY -9 93 Dl -18 10 Dl -37 1 Dl -73 0 Dl -146 -1 Dl -292 0 Dl -584 0 Dl -3 Dt -4946 MY --12 24 Dl -24 0 Dl --12 -24 Dl -1250 MX --12 24 Dl -24 0 Dl --12 -24 Dl -958 MX --12 24 Dl -24 0 Dl --12 -24 Dl -812 MX --12 25 Dl -24 0 Dl --12 -25 Dl -739 4947 MXY --12 24 Dl -24 0 Dl --12 -24 Dl -702 4946 MXY --12 24 Dl -25 0 Dl --13 -24 Dl -684 4936 MXY --12 24 Dl -24 0 Dl --12 -24 Dl -675 4843 MXY --12 24 Dl -24 0 Dl --12 -24 Dl -3 Dt --1 Ds -3 f -432 5314(Figure)N -634(5b:)X -1 f -744(Elapsed)X -967(Time)X -1123(for)X -1218(dictionary)X -1498(data)X -1625(set)X -1717(with)X -1851(1M)X -1960(of)X -2033(buffer)X -432 5402(space)N -593(and)X -705(varying)X -920(bucket)X -1110(sizes)X -1254(and)X -1366(\256ll)X -1457(factors.)X -1681(Each)X -1827(line)X -1942(is)X -2004(labeled)X -432 5490(with)N -562(its)X -639(bucket)X -825(size.)X -10 s -2590 538(If)N -2677(an)X -2785(approximation)X -3284(of)X -3383(the)X -3513(number)X -3790(of)X -3889(elements)X -2418 626(ultimately)N -2773(to)X -2866(be)X -2973(stored)X -3200(in)X -3293(the)X -3422(hash)X -3599(table)X -3785(is)X -3868(known)X -4116(at)X -2418 714(the)N -2564(time)X -2754(of)X -2869(creation,)X -3196(the)X -3342(hash)X -3536(package)X -3847(takes)X -4059(this)X -2418 802(number)N -2688(as)X -2779(a)X -2839(parameter)X -3185(and)X -3325(uses)X -3487(it)X -3555(to)X -3641(hash)X -3812(entries)X -4050(into)X -2418 890(the)N -2541(full)X -2677(sized)X -2867(table)X -3048(rather)X -3261(than)X -3424(growing)X -3716(the)X -3838(table)X -4018(from)X -2418 978(a)N -2477(single)X -2691(bucket.)X -2968(If)X -3044(this)X -3181(number)X -3448(is)X -3523(not)X -3647(known,)X -3907(the)X -4027(hash)X -2418 1066(table)N -2632(starts)X -2859(with)X -3059(a)X -3153(single)X -3402(bucket)X -3674(and)X -3848(gracefully)X -2418 1154(expands)N -2707(as)X -2800(elements)X -3111(are)X -3236(added,)X -3474(although)X -3780(a)X -3842(slight)X -4044(per-)X -2418 1242(formance)N -2747(degradation)X -3151(may)X -3313(be)X -3413(noticed.)X -3713(Figure)X -3946(6)X -4010(illus-)X -2418 1330(trates)N -2625(the)X -2756(difference)X -3116(in)X -3211(performance)X -3651(between)X -3952(storing)X -2418 1418(keys)N -2588(in)X -2673(a)X -2732(\256le)X -2857(when)X -3054(the)X -3174(ultimate)X -3458(size)X -3605(is)X -3680(known)X -3920(\(the)X -4067(left)X -2418 1506(bars)N -2581(in)X -2672(each)X -2849(set\),)X -3014(compared)X -3360(to)X -3450(building)X -3744(the)X -3870(\256le)X -4000(when)X -2418 1594(the)N -2550(ultimate)X -2846(size)X -3005(is)X -3091(unknown)X -3422(\(the)X -3580(right)X -3764(bars)X -3931(in)X -4026(each)X -2418 1682(set\).)N -2609(Once)X -2814(the)X -2947(\256ll)X -3069(factor)X -3291(is)X -3378(suf\256ciently)X -3772(high)X -3948(for)X -4076(the)X -2418 1770(page)N -2596(size)X -2747(\(8\),)X -2887(growing)X -3180(the)X -3304(table)X -3486(dynamically)X -3908(does)X -4081(lit-)X -2418 1858(tle)N -2518(to)X -2600(degrade)X -2875(performance.)X -10 f -2418 1946 -0.0930(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)AN -9 s -1 f -2413 3238(s)N -2409 3173(d)N -2409 3108(n)N -2409 3043(o)N -2411 2979(c)N -2411 2914(e)N -2407 2849(S)N -3143 4129(Fill)N -3261(Factor)X -2448 2152(15)N -4 Ds -1 Dt -2557 2122 MXY -1473 0 Dl --1 Ds -5 Dt -2557 MX --19 0 Dl -2448 2747(10)N -4 Ds -1 Dt -2557 2717 MXY -1473 0 Dl --1 Ds -5 Dt -2557 MX --19 0 Dl -2484 3343(5)N -4 Ds -1 Dt -2557 3313 MXY -1473 0 Dl --1 Ds -5 Dt -2557 MX --19 0 Dl -2484 3938(0)N -4 Ds -1 Dt -2557 3908 MXY -1473 0 Dl --1 Ds -5 Dt -2557 MX --19 0 Dl -3976 4015(128)N -4 Ds -1 Dt -4030 3908 MXY -0 -1786 Dl --1 Ds -5 Dt -3908 MY -0 19 Dl -3626 4015(96)N -4 Ds -1 Dt -3662 3908 MXY -0 -1786 Dl --1 Ds -5 Dt -3908 MY -0 19 Dl -3258 4015(64)N -4 Ds -1 Dt -3294 3908 MXY -0 -1786 Dl --1 Ds -5 Dt -3908 MY -0 19 Dl -2889 4015(32)N -4 Ds -1 Dt -2925 3908 MXY -0 -1786 Dl --1 Ds -5 Dt -3908 MY -0 19 Dl -2539 4015(0)N -4 Ds -1 Dt -2557 3908 MXY -0 -1786 Dl --1 Ds -5 Dt -3908 MY -0 19 Dl -3908 MY -0 -1786 Dl -3908 MY -1473 0 Dl -4053 2378(8192)N -3 Dt -2569 2277 MXY -11 0 Dl -23 48 Dl -46 -167 Dl -92 35 Dl -184 12 Dl -369 143 Dl -736 0 Dl -2334 MY -0 28 Dl -0 -14 Dl -14 0 Dl --28 0 Dl -3294 2334 MXY -0 28 Dl -0 -14 Dl -13 0 Dl --27 0 Dl -2925 2192 MXY -0 27 Dl -0 -14 Dl -14 0 Dl --28 0 Dl -2741 2180 MXY -0 27 Dl -0 -14 Dl -14 0 Dl --28 0 Dl -2649 2144 MXY -0 28 Dl -0 -14 Dl -14 0 Dl --28 0 Dl -2603 2311 MXY -0 27 Dl -0 -13 Dl -14 0 Dl --28 0 Dl -2580 2263 MXY -0 28 Dl -0 -14 Dl -14 0 Dl --28 0 Dl -2569 2263 MXY -0 28 Dl -0 -14 Dl -13 0 Dl --27 0 Dl -4053 2591(4096)N -2569 2348 MXY -11 -11 Dl -23 -96 Dl -46 71 Dl -92 72 Dl -184 226 Dl -369 48 Dl -736 -60 Dl -2612 MY -14 -28 Dl --28 0 Dl -14 28 Dl -3294 2672 MXY -13 -28 Dl --27 0 Dl -14 28 Dl -2925 2624 MXY -14 -28 Dl --28 0 Dl -14 28 Dl -2741 2398 MXY -14 -28 Dl --28 0 Dl -14 28 Dl -2649 2326 MXY -14 -27 Dl --28 0 Dl -14 27 Dl -2603 2255 MXY -14 -28 Dl --28 0 Dl -14 28 Dl -2580 2350 MXY -14 -27 Dl --28 0 Dl -14 27 Dl -2569 2362 MXY -13 -28 Dl --27 0 Dl -14 28 Dl -4053 2681(1024)N -16 Ds -1 Dt -2569 2300 MXY -11 48 Dl -23 96 Dl -46 95 Dl -92 274 Dl -184 202 Dl -369 -155 Dl -736 -190 Dl --1 Ds -3 Dt -4044 2656 MXY --28 28 Dl -14 -14 Dl --14 -14 Dl -28 28 Dl -3307 2846 MXY --27 28 Dl -14 -14 Dl --14 -14 Dl -27 28 Dl -2939 3001 MXY --28 28 Dl -14 -14 Dl --14 -14 Dl -28 28 Dl -2755 2799 MXY --28 28 Dl -14 -14 Dl --14 -14 Dl -28 28 Dl -2663 2525 MXY --28 28 Dl -14 -14 Dl --14 -14 Dl -28 28 Dl -2617 2430 MXY --28 28 Dl -14 -14 Dl --14 -14 Dl -28 28 Dl -2594 2334 MXY --28 28 Dl -14 -14 Dl --14 -14 Dl -28 28 Dl -2582 2287 MXY --27 27 Dl -14 -14 Dl --14 -13 Dl -27 27 Dl -4053 2851(512)N -5 Dt -2569 2372 MXY -11 -24 Dl -23 405 Dl -46 83 Dl -92 227 Dl -184 -72 Dl -369 -119 Dl -736 -107 Dl -3 Dt -2751 MY -0 28 Dl -0 -14 Dl -14 0 Dl --28 0 Dl -3294 2858 MXY -0 28 Dl -0 -14 Dl -13 0 Dl --27 0 Dl -2925 2977 MXY -0 28 Dl -0 -14 Dl -14 0 Dl --28 0 Dl -2741 3049 MXY -0 27 Dl -0 -13 Dl -14 0 Dl --28 0 Dl -2649 2823 MXY -0 27 Dl -0 -14 Dl -14 0 Dl --28 0 Dl -2603 2739 MXY -0 28 Dl -0 -14 Dl -14 0 Dl --28 0 Dl -2580 2334 MXY -0 28 Dl -0 -14 Dl -14 0 Dl --28 0 Dl -2569 2358 MXY -0 28 Dl -0 -14 Dl -13 0 Dl --27 0 Dl -4053 2795(256)N -20 Ds -1 Dt -2569 2456 MXY -11 285 Dl -23 95 Dl -46 251 Dl -92 -60 Dl -184 -84 Dl -369 -107 Dl -736 -71 Dl --1 Ds -3 Dt -4016 MX -27 Dc -3280 2836 MXY -27 Dc -2912 2943 MXY -27 Dc -2728 3027 MXY -27 Dc -2635 3087 MXY -28 Dc -2589 2836 MXY -28 Dc -2566 2741 MXY -27 Dc -2554 2456 MXY -28 Dc -4053 2741(128)N -1 Dt -2569 2729 MXY -11 203 Dl -23 131 Dl -46 -60 Dl -92 -119 Dl -184 -60 Dl -369 -83 Dl -736 -12 Dl -3 Dt -2716 MY --14 27 Dl -28 0 Dl --14 -27 Dl -3294 2727 MXY --14 28 Dl -27 0 Dl --13 -28 Dl -2925 2811 MXY --14 27 Dl -28 0 Dl --14 -27 Dl -2741 2870 MXY --14 28 Dl -28 0 Dl --14 -28 Dl -2649 2989 MXY --14 28 Dl -28 0 Dl --14 -28 Dl -2603 3049 MXY --14 27 Dl -28 0 Dl --14 -27 Dl -2580 2918 MXY --14 28 Dl -28 0 Dl --14 -28 Dl -2569 2716 MXY --14 27 Dl -27 0 Dl --13 -27 Dl -3 Dt --1 Ds -3 f -8 s -2418 4286(Figure)N -2628(5c:)X -1 f -2738(User)X -2887(Time)X -3051(for)X -3154(dictionary)X -3442(data)X -3577(set)X -3677(with)X -3820(1M)X -3938(of)X -4019(buffer)X -2418 4374(space)N -2579(and)X -2691(varying)X -2906(bucket)X -3096(sizes)X -3240(and)X -3352(\256ll)X -3443(factors.)X -3667(Each)X -3813(line)X -3928(is)X -3990(labeled)X -2418 4462(with)N -2548(its)X -2625(bucket)X -2811(size.)X -10 s -10 f -2418 4638 -0.0930(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)AN -1 f -2590 4840(Since)N -2796(no)X -2904(known)X -3150(hash)X -3325(function)X -3620(performs)X -3938(equally)X -2418 4928(well)N -2589(on)X -2702(all)X -2815(possible)X -3110(data,)X -3297(the)X -3428(user)X -3595(may)X -3766(\256nd)X -3923(that)X -4076(the)X -2418 5016(built-in)N -2678(hash)X -2849(function)X -3140(does)X -3311(poorly)X -3544(on)X -3648(a)X -3708(particular)X -4040(data)X -2418 5104(set.)N -2548(In)X -2636(this)X -2771(case,)X -2950(a)X -3006(hash)X -3173(function,)X -3480(taking)X -3700(two)X -3840(arguments)X -2418 5192(\(a)N -2507(pointer)X -2760(to)X -2848(a)X -2910(byte)X -3074(string)X -3282(and)X -3424(a)X -3486(length\))X -3739(and)X -3880(returning)X -2418 5280(an)N -2517(unsigned)X -2829(long)X -2993(to)X -3077(be)X -3175(used)X -3344(as)X -3433(the)X -3553(hash)X -3722(value,)X -3938(may)X -4098(be)X -2418 5368(speci\256ed)N -2731(at)X -2817(hash)X -2992(table)X -3176(creation)X -3463(time.)X -3673(When)X -3893(an)X -3996(exist-)X -2418 5456(ing)N -2570(hash)X -2767(table)X -2973(is)X -3076(opened)X -3358(and)X -3524(a)X -3609(hash)X -3805(function)X -4121(is)X -2418 5544(speci\256ed,)N -2752(the)X -2879(hash)X -3054(package)X -3346(will)X -3498(try)X -3615(to)X -3705(determine)X -4054(that)X -2418 5632(the)N -2546(hash)X -2723(function)X -3020(supplied)X -3321(is)X -3404(the)X -3532(one)X -3678(with)X -3850(which)X -4076(the)X -2418 5720(table)N -2630(was)X -2811(created.)X -3139(There)X -3382(are)X -3536(a)X -3627(variety)X -3905(of)X -4027(hash)X -3 f -432 5960(8)N -2970(USENIX)X -9 f -3292(-)X -3 f -3356(Winter)X -3621('91)X -9 f -3748(-)X -3 f -3812(Dallas,)X -4065(TX)X - -9 p -%%Page: 9 9 -0(Courier)xf 0 f -10 s 10 xH 0 xS 0 f -3 f -720 258(Seltzer)N -977(&)X -1064(Yigit)X -3278(A)X -3356(New)X -3528(Hashing)X -3831(Package)X -4136(for)X -4259(UNIX)X -1 f -720 538(functions)N -1065(provided)X -1397(with)X -1586(the)X -1731(package.)X -2082(The)X -2253(default)X -720 626(function)N -1014(for)X -1135(the)X -1260(package)X -1551(is)X -1631(the)X -1755(one)X -1897(which)X -2119(offered)X -2378(the)X -720 714(best)N -875(performance)X -1308(in)X -1396(terms)X -1600(of)X -1693(cycles)X -1920(executed)X -2232(per)X -2360(call)X -720 802(\(it)N -827(did)X -965(not)X -1103(produce)X -1398(the)X -1531(fewest)X -1776(collisions)X -2117(although)X -2432(it)X -720 890(was)N -866(within)X -1091(a)X -1148(small)X -1341(percentage)X -1710(of)X -1797(the)X -1915(function)X -2202(that)X -2342(pro-)X -720 978(duced)N -947(the)X -1080(fewest)X -1324(collisions\).)X -1731(Again,)X -1981(in)X -2077(time)X -2253(critical)X -720 1066(applications,)N -1152(users)X -1342(are)X -1466(encouraged)X -1862(to)X -1949(experiment)X -2334(with)X -720 1154(a)N -783(variety)X -1032(of)X -1125(hash)X -1298(functions)X -1622(to)X -1710(achieve)X -1982(optimal)X -2252(perfor-)X -720 1242(mance.)N -10 f -720 1330 -0.0930(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)AN -3 f -7 s -1038 2925(Full)N -1149(size)X -1251(table)X -1384(\(left\))X -1547 2718(Fill)N -1643(Factor)X -2268 2662(64)N -1964(32)X -1674(16)X -1384(8)X -1093(4)X -4 Ds -1 Dt -900 2280 MXY -1548 0 Dl -900 1879 MXY -1548 0 Dl -900 1506 MXY -1548 0 Dl -1563 2902 MXY -111 0 Dl --1 Ds -900 MX -110 0 Dl -1425 2828(System)N -983(User)X -1895 2778 MXY - 1895 2778 lineto - 1950 2778 lineto - 1950 2833 lineto - 1895 2833 lineto - 1895 2778 lineto -closepath 21 1895 2778 1950 2833 Dp -1342 MX - 1342 2778 lineto - 1397 2778 lineto - 1397 2833 lineto - 1342 2833 lineto - 1342 2778 lineto -closepath 14 1342 2778 1397 2833 Dp -900 MX - 900 2778 lineto - 955 2778 lineto - 955 2833 lineto - 900 2833 lineto - 900 2778 lineto -closepath 3 900 2778 955 2833 Dp -5 Dt -2283 2211 MXY -96 0 Dl -1992 MX -97 0 Dl -1702 MX -97 0 Dl -1411 2252 MXY -97 0 Dl -4 Ds -1 Dt -2283 2211 MXY - 2283 2211 lineto - 2379 2211 lineto - 2379 2252 lineto - 2283 2252 lineto - 2283 2211 lineto -closepath 14 2283 2211 2379 2252 Dp -1992 MX - 1992 2211 lineto - 2089 2211 lineto - 2089 2252 lineto - 1992 2252 lineto - 1992 2211 lineto -closepath 14 1992 2211 2089 2252 Dp -1702 MX - 1702 2211 lineto - 1799 2211 lineto - 1799 2252 lineto - 1702 2252 lineto - 1702 2211 lineto -closepath 14 1702 2211 1799 2252 Dp -1411 2252 MXY - 1411 2252 lineto - 1508 2252 lineto - 1508 2294 lineto - 1411 2294 lineto - 1411 2252 lineto -closepath 14 1411 2252 1508 2294 Dp -2283 MX - 2283 2252 lineto - 2379 2252 lineto - 2379 2612 lineto - 2283 2612 lineto - 2283 2252 lineto -closepath 3 2283 2252 2379 2612 Dp -1992 MX - 1992 2252 lineto - 2089 2252 lineto - 2089 2612 lineto - 1992 2612 lineto - 1992 2252 lineto -closepath 3 1992 2252 2089 2612 Dp -1702 MX - 1702 2252 lineto - 1799 2252 lineto - 1799 2612 lineto - 1702 2612 lineto - 1702 2252 lineto -closepath 3 1702 2252 1799 2612 Dp -1411 2294 MXY - 1411 2294 lineto - 1508 2294 lineto - 1508 2612 lineto - 1411 2612 lineto - 1411 2294 lineto -closepath 3 1411 2294 1508 2612 Dp --1 Ds -2158 2238 MXY - 2158 2238 lineto - 2255 2238 lineto - 2255 2252 lineto - 2158 2252 lineto - 2158 2238 lineto -closepath 21 2158 2238 2255 2252 Dp -1868 MX - 1868 2238 lineto - 1965 2238 lineto - 1965 2280 lineto - 1868 2280 lineto - 1868 2238 lineto -closepath 21 1868 2238 1965 2280 Dp -1577 MX - 1577 2238 lineto - 1674 2238 lineto - 1674 2308 lineto - 1577 2308 lineto - 1577 2238 lineto -closepath 21 1577 2238 1674 2308 Dp -1287 2308 MXY - 1287 2308 lineto - 1287 2280 lineto - 1384 2280 lineto - 1384 2308 lineto - 1287 2308 lineto -closepath 21 1287 2280 1384 2308 Dp -2158 2280 MXY - 2158 2280 lineto - 2158 2252 lineto - 2255 2252 lineto - 2255 2280 lineto - 2158 2280 lineto -closepath 14 2158 2252 2255 2280 Dp -1868 2308 MXY - 1868 2308 lineto - 1868 2280 lineto - 1965 2280 lineto - 1965 2308 lineto - 1868 2308 lineto -closepath 14 1868 2280 1965 2308 Dp -1577 2335 MXY - 1577 2335 lineto - 1577 2308 lineto - 1674 2308 lineto - 1674 2335 lineto - 1577 2335 lineto -closepath 14 1577 2308 1674 2335 Dp -1287 2363 MXY - 1287 2363 lineto - 1287 2308 lineto - 1384 2308 lineto - 1384 2363 lineto - 1287 2363 lineto -closepath 14 1287 2308 1384 2363 Dp -2158 2280 MXY - 2158 2280 lineto - 2255 2280 lineto - 2255 2612 lineto - 2158 2612 lineto - 2158 2280 lineto -closepath 3 2158 2280 2255 2612 Dp -1868 2308 MXY - 1868 2308 lineto - 1965 2308 lineto - 1965 2612 lineto - 1868 2612 lineto - 1868 2308 lineto -closepath 3 1868 2308 1965 2612 Dp -1577 2335 MXY - 1577 2335 lineto - 1674 2335 lineto - 1674 2612 lineto - 1577 2612 lineto - 1577 2335 lineto -closepath 3 1577 2335 1674 2612 Dp -1287 2363 MXY - 1287 2363 lineto - 1384 2363 lineto - 1384 2612 lineto - 1287 2612 lineto - 1287 2363 lineto -closepath 3 1287 2363 1384 2612 Dp -4 Ds -1121 2066 MXY - 1121 2066 lineto - 1218 2066 lineto - 1224 2080 lineto - 1127 2080 lineto - 1121 2066 lineto -closepath 21 1121 2066 1224 2080 Dp -2080 MY - 1121 2080 lineto - 1218 2080 lineto - 1218 2273 lineto - 1121 2273 lineto - 1121 2080 lineto -closepath 14 1121 2080 1218 2273 Dp -2273 MY - 1121 2273 lineto - 1218 2273 lineto - 1218 2612 lineto - 1121 2612 lineto - 1121 2273 lineto -closepath 3 1121 2273 1218 2612 Dp --1 Ds -997 1589 MXY - 997 1589 lineto - 1093 1589 lineto - 1093 1644 lineto - 997 1644 lineto - 997 1589 lineto -closepath 21 997 1589 1093 1644 Dp -1644 MY - 997 1644 lineto - 1093 1644 lineto - 1093 2280 lineto - 997 2280 lineto - 997 1644 lineto -closepath 14 997 1644 1093 2280 Dp -2280 MY - 997 2280 lineto - 1093 2280 lineto - 1093 2612 lineto - 997 2612 lineto - 997 2280 lineto -closepath 3 997 2280 1093 2612 Dp -10 s -719 2093(s)N -712 2037(d)N -712 1982(n)N -714 1927(o)N -716 1872(c)N -716 1816(e)N -712 1761(S)N -804 2286(10)N -804 1899(20)N -804 1540(30)N -3 Dt -900 1506 MXY -0 1106 Dl -1548 0 Dl -7 s -1978 2828(Elapsed)N -1701 2925(Dynamically)N -2018(grown)X -2184(table)X -2317(\(right\))X -3 Dt --1 Ds -8 s -720 3180(Figure)N -934(6:)X -1 f -1020(The)X -1152(total)X -1299(regions)X -1520(indicate)X -1755(the)X -1865(difference)X -2154(between)X -2398(the)X -720 3268(elapsed)N -931(time)X -1065(and)X -1177(the)X -1275(sum)X -1402(of)X -1475(the)X -1573(system)X -1771(and)X -1883(user)X -2008(time.)X -2173(The)X -2291(left)X -2395(bar)X -720 3356(of)N -798(each)X -939(set)X -1035(depicts)X -1241(the)X -1344(timing)X -1537(of)X -1615(the)X -1718(test)X -1831(run)X -1940(when)X -2102(the)X -2204(number)X -2423(of)X -720 3444(entries)N -910(is)X -973(known)X -1167(in)X -1237(advance.)X -1496(The)X -1614(right)X -1754(bars)X -1879(depict)X -2054(the)X -2151(timing)X -2338(when)X -720 3532(the)N -814(\256le)X -912(is)X -971(grown)X -1150(from)X -1290(a)X -1334(single)X -1503(bucket.)X -10 s -10 f -720 3708 -0.0930(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)AN -1 f -892 3910(Since)N -1131(this)X -1307(hashing)X -1617(package)X -1942(provides)X -2279(buffer)X -720 3998(management,)N -1188(the)X -1323(amount)X -1600(of)X -1704(space)X -1920(allocated)X -2247(for)X -2378(the)X -720 4086(buffer)N -948(pool)X -1121(may)X -1290(be)X -1397(speci\256ed)X -1713(by)X -1824(the)X -1953(user.)X -2157(Using)X -2378(the)X -720 4174(same)N -910(data)X -1069(set)X -1183(and)X -1324(test)X -1459(procedure)X -1805(as)X -1896(used)X -2067(to)X -2153(derive)X -2378(the)X -720 4262(graphs)N -962(in)X -1052(Figures)X -1320(5a-c,)X -1507(Figure)X -1744(7)X -1812(shows)X -2039(the)X -2164(impact)X -2409(of)X -720 4350(varying)N -997(the)X -1126(size)X -1282(of)X -1380(the)X -1509(buffer)X -1737(pool.)X -1950(The)X -2106(bucket)X -2351(size)X -720 4438(was)N -873(set)X -989(to)X -1078(256)X -1225(bytes)X -1421(and)X -1564(the)X -1689(\256ll)X -1804(factor)X -2019(was)X -2171(set)X -2287(to)X -2376(16.)X -720 4526(The)N -869(buffer)X -1090(pool)X -1256(size)X -1404(was)X -1552(varied)X -1776(from)X -1955(0)X -2018(\(the)X -2166(minimum)X -720 4614(number)N -986(of)X -1074(pages)X -1277(required)X -1565(to)X -1647(be)X -1743(buffered\))X -2063(to)X -2145(1M.)X -2316(With)X -720 4702(1M)N -854(of)X -944(buffer)X -1164(space,)X -1386(the)X -1507(package)X -1794(performed)X -2151(no)X -2253(I/O)X -2382(for)X -720 4790(this)N -871(data)X -1040(set.)X -1204(As)X -1328(Figure)X -1572(7)X -1647(illustrates,)X -2013(increasing)X -2378(the)X -720 4878(buffer)N -944(pool)X -1113(size)X -1265(can)X -1404(have)X -1583(a)X -1646(dramatic)X -1954(affect)X -2165(on)X -2271(result-)X -720 4966(ing)N -842(performance.)X -2 f -8 s -1269 4941(7)N -1 f -16 s -720 5353 MXY -864 0 Dl -2 f -8 s -760 5408(7)N -1 f -9 s -826 5433(Some)N -1024(allocators)X -1338(are)X -1460(extremely)X -1782(inef\256cient)X -2107(at)X -2192(allocating)X -720 5513(memory.)N -1029(If)X -1110(you)X -1251(\256nd)X -1396(that)X -1536(applications)X -1916(are)X -2036(running)X -2292(out)X -2416(of)X -720 5593(memory)N -1005(before)X -1234(you)X -1386(think)X -1578(they)X -1746(should,)X -2000(try)X -2124(varying)X -2388(the)X -720 5673(pagesize)N -986(to)X -1060(get)X -1166(better)X -1348(utilization)X -1658(from)X -1816(the)X -1922(memory)X -2180(allocator.)X -10 s -2830 1975 MXY -0 -28 Dl -28 0 Dl -0 28 Dl --28 0 Dl -2853 2004 MXY -0 -27 Dl -28 0 Dl -0 27 Dl --28 0 Dl -2876 2016 MXY -0 -27 Dl -27 0 Dl -0 27 Dl --27 0 Dl -2922 1998 MXY -0 -27 Dl -27 0 Dl -0 27 Dl --27 0 Dl -2967 2025 MXY -0 -28 Dl -28 0 Dl -0 28 Dl --28 0 Dl -3013 2031 MXY -0 -28 Dl -28 0 Dl -0 28 Dl --28 0 Dl -3059 MX -0 -28 Dl -27 0 Dl -0 28 Dl --27 0 Dl -3196 2052 MXY -0 -28 Dl -27 0 Dl -0 28 Dl --27 0 Dl -3561 2102 MXY -0 -28 Dl -28 0 Dl -0 28 Dl --28 0 Dl -4292 2105 MXY -0 -28 Dl -27 0 Dl -0 28 Dl --27 0 Dl -4 Ds -1 Dt -2844 1961 MXY -23 30 Dl -23 12 Dl -45 -18 Dl -46 26 Dl -46 6 Dl -45 0 Dl -137 21 Dl -366 50 Dl -730 3 Dl -9 s -4227 2158(User)N --1 Ds -3 Dt -2830 1211 MXY -27 Dc -2853 1261 MXY -27 Dc -2876 1267 MXY -27 Dc -2921 1341 MXY -27 Dc -2967 1385 MXY -27 Dc -3013 1450 MXY -27 Dc -3059 1497 MXY -27 Dc -3196 1686 MXY -27 Dc -3561 2109 MXY -27 Dc -4292 2295 MXY -27 Dc -20 Ds -1 Dt -2844 1211 MXY -23 50 Dl -23 6 Dl -45 74 Dl -46 44 Dl -46 65 Dl -45 47 Dl -137 189 Dl -366 423 Dl -730 186 Dl -4181 2270(System)N --1 Ds -3 Dt -2844 583 MXY -0 28 Dl -0 -14 Dl -14 0 Dl --28 0 Dl -2867 672 MXY -0 27 Dl -0 -14 Dl -14 0 Dl --28 0 Dl -2890 701 MXY -0 28 Dl -0 -14 Dl -13 0 Dl --27 0 Dl -2935 819 MXY -0 28 Dl -0 -14 Dl -14 0 Dl --27 0 Dl -2981 849 MXY -0 28 Dl -0 -14 Dl -14 0 Dl --28 0 Dl -3027 908 MXY -0 27 Dl -0 -13 Dl -14 0 Dl --28 0 Dl -3072 1026 MXY -0 27 Dl -0 -13 Dl -14 0 Dl --27 0 Dl -3209 1292 MXY -0 27 Dl -0 -14 Dl -14 0 Dl --27 0 Dl -3575 1823 MXY -0 28 Dl -0 -14 Dl -14 0 Dl --28 0 Dl -4305 2059 MXY -0 28 Dl -0 -14 Dl -14 0 Dl --27 0 Dl -5 Dt -2844 597 MXY -23 88 Dl -23 30 Dl -45 118 Dl -46 30 Dl -46 59 Dl -45 118 Dl -137 265 Dl -366 532 Dl -730 236 Dl -4328 2103(Total)N -2844 2310 MXY -1461 0 Dl -2844 MX -0 -1772 Dl -2310 MY -0 18 Dl -4 Ds -1 Dt -2310 MY -0 -1772 Dl -2826 2416(0)N --1 Ds -5 Dt -3209 2310 MXY -0 18 Dl -4 Ds -1 Dt -2310 MY -0 -1772 Dl -3155 2416(256)N --1 Ds -5 Dt -3575 2310 MXY -0 18 Dl -4 Ds -1 Dt -2310 MY -0 -1772 Dl -3521 2416(512)N --1 Ds -5 Dt -3940 2310 MXY -0 18 Dl -4 Ds -1 Dt -2310 MY -0 -1772 Dl -3886 2416(768)N --1 Ds -5 Dt -4305 2310 MXY -0 18 Dl -4 Ds -1 Dt -2310 MY -0 -1772 Dl -4233 2416(1024)N --1 Ds -5 Dt -2844 2310 MXY --18 0 Dl -4 Ds -1 Dt -2844 MX -1461 0 Dl -2771 2340(0)N --1 Ds -5 Dt -2844 2014 MXY --18 0 Dl -2844 1719 MXY --18 0 Dl -4 Ds -1 Dt -2844 MX -1461 0 Dl -2735 1749(20)N --1 Ds -5 Dt -2844 1423 MXY --18 0 Dl -2844 1128 MXY --18 0 Dl -4 Ds -1 Dt -2844 MX -1461 0 Dl -2735 1158(40)N --1 Ds -5 Dt -2844 833 MXY --18 0 Dl -2844 538 MXY --18 0 Dl -4 Ds -1 Dt -2844 MX -1461 0 Dl -2735 568(60)N -3239 2529(Buffer)N -3445(Pool)X -3595(Size)X -3737(\(in)X -3835(K\))X -2695 1259(S)N -2699 1324(e)N -2699 1388(c)N -2697 1452(o)N -2697 1517(n)N -2697 1581(d)N -2701 1645(s)N -3 Dt --1 Ds -3 f -8 s -2706 2773(Figure)N -2908(7:)X -1 f -2982(User)X -3123(time)X -3258(is)X -3322(virtually)X -3560(insensitive)X -3854(to)X -3924(the)X -4022(amount)X -4234(of)X -4307(buffer)X -2706 2861(pool)N -2852(available,)X -3130(however,)X -3396(both)X -3541(system)X -3750(time)X -3895(and)X -4018(elapsed)X -4240(time)X -4385(are)X -2706 2949(inversely)N -2960(proportional)X -3296(to)X -3366(the)X -3464(size)X -3583(of)X -3656(the)X -3753(buffer)X -3927(pool.)X -4092(Even)X -4242(for)X -4335(large)X -2706 3037(data)N -2831(sets)X -2946(where)X -3120(one)X -3230(expects)X -3439(few)X -3552(collisions,)X -3832(specifying)X -4116(a)X -4162(large)X -4307(buffer)X -2706 3125(pool)N -2836(dramatically)X -3171(improves)X -3425(performance.)X -10 s -10 f -2706 3301 -0.0930(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)AN -3 f -3175 3543(Enhanced)N -3536(Functionality)X -1 f -2878 3675(This)N -3046(hashing)X -3320(package)X -3609(provides)X -3910(a)X -3971(set)X -4085(of)X -4177(compati-)X -2706 3763(bility)N -2895(routines)X -3174(to)X -3257(implement)X -3620(the)X -2 f -3739(ndbm)X -1 f -3937(interface.)X -4279(How-)X -2706 3851(ever,)N -2893(when)X -3095(the)X -3220(native)X -3443(interface)X -3752(is)X -3832(used,)X -4026(the)X -4151(following)X -2706 3939(additional)N -3046(functionality)X -3475(is)X -3548(provided:)X -10 f -2798 4071(g)N -1 f -2946(Inserts)X -3197(never)X -3413(fail)X -3556(because)X -3847(too)X -3985(many)X -4199(keys)X -2946 4159(hash)N -3113(to)X -3195(the)X -3313(same)X -3498(value.)X -10 f -2798 4247(g)N -1 f -2946(Inserts)X -3187(never)X -3393(fail)X -3527(because)X -3808(key)X -3950(and/or)X -4181(asso-)X -2946 4335(ciated)N -3158(data)X -3312(is)X -3385(too)X -3507(large)X -10 f -2798 4423(g)N -1 f -2946(Hash)X -3131(functions)X -3449(may)X -3607(be)X -3703(user-speci\256ed.)X -10 f -2798 4511(g)N -1 f -2946(Multiple)X -3268(pages)X -3498(may)X -3683(be)X -3806(cached)X -4077(in)X -4186(main)X -2946 4599(memory.)N -2706 4731(It)N -2801(also)X -2976(provides)X -3298(a)X -3380(set)X -3514(of)X -3626(compatibility)X -4097(routines)X -4400(to)X -2706 4819(implement)N -3087(the)X -2 f -3224(hsearch)X -1 f -3516(interface.)X -3876(Again,)X -4130(the)X -4266(native)X -2706 4907(interface)N -3008(offers)X -3216(enhanced)X -3540(functionality:)X -10 f -2798 5039(g)N -1 f -2946(Files)X -3121(may)X -3279(grow)X -3464(beyond)X -2 f -3720(nelem)X -1 f -3932(elements.)X -10 f -2798 5127(g)N -1 f -2946(Multiple)X -3247(hash)X -3420(tables)X -3632(may)X -3795(be)X -3896(accessed)X -4203(con-)X -2946 5215(currently.)N -10 f -2798 5303(g)N -1 f -2946(Hash)X -3134(tables)X -3344(may)X -3505(be)X -3604(stored)X -3823(and)X -3962(accessed)X -4266(on)X -2946 5391(disk.)N -10 f -2798 5479(g)N -1 f -2946(Hash)X -3155(functions)X -3497(may)X -3679(be)X -3799(user-speci\256ed)X -4288(at)X -2946 5567(runtime.)N -3 f -720 5960(USENIX)N -9 f -1042(-)X -3 f -1106(Winter)X -1371('91)X -9 f -1498(-)X -3 f -1562(Dallas,)X -1815(TX)X -4424(9)X - -10 p -%%Page: 10 10 -0(Courier)xf 0 f -10 s 10 xH 0 xS 0 f -3 f -432 258(A)N -510(New)X -682(Hashing)X -985(Package)X -1290(for)X -1413(UNIX)X -3663(Seltzer)X -3920(&)X -4007(Yigit)X -459 538(Relative)N -760(Performance)X -1227(of)X -1314(the)X -1441(New)X -1613(Implementation)X -1 f -604 670(The)N -761(performance)X -1200(testing)X -1445(of)X -1544(the)X -1674(new)X -1840(package)X -2135(is)X -432 758(divided)N -711(into)X -874(two)X -1033(test)X -1183(suites.)X -1424(The)X -1588(\256rst)X -1751(suite)X -1941(of)X -2046(tests)X -432 846(requires)N -727(that)X -882(the)X -1015(tables)X -1237(be)X -1348(read)X -1522(from)X -1713(and)X -1864(written)X -2126(to)X -432 934(disk.)N -640(In)X -742(these)X -942(tests,)X -1139(the)X -1272(basis)X -1467(for)X -1595(comparison)X -2003(is)X -2090(the)X -432 1022(4.3BSD-Reno)N -908(version)X -1169(of)X -2 f -1260(ndbm)X -1 f -1438(.)X -1502(Based)X -1722(on)X -1826(the)X -1948(designs)X -432 1110(of)N -2 f -521(sdbm)X -1 f -712(and)X -2 f -850(gdbm)X -1 f -1028(,)X -1070(they)X -1230(are)X -1351(expected)X -1659(to)X -1743(perform)X -2024(simi-)X -432 1198(larly)N -605(to)X -2 f -693(ndbm)X -1 f -871(,)X -917(and)X -1059(we)X -1179(do)X -1285(not)X -1413(show)X -1608(their)X -1781(performance)X -432 1286(numbers.)N -800(The)X -977(second)X -1252(suite)X -1454(contains)X -1772(the)X -1921(memory)X -432 1374(resident)N -712(test)X -849(which)X -1071(does)X -1243(not)X -1370(require)X -1623(that)X -1768(the)X -1891(\256les)X -2049(ever)X -432 1462(be)N -533(written)X -784(to)X -870(disk,)X -1047(only)X -1213(that)X -1357(hash)X -1528(tables)X -1739(may)X -1901(be)X -2001(mani-)X -432 1550(pulated)N -692(in)X -778(main)X -961(memory.)X -1291(In)X -1381(this)X -1519(test,)X -1673(we)X -1790(compare)X -2090(the)X -432 1638(performance)N -859(to)X -941(that)X -1081(of)X -1168(the)X -2 f -1286(hsearch)X -1 f -1560(routines.)X -604 1752(For)N -760(both)X -947(suites,)X -1194(two)X -1358(different)X -1679(databases)X -2031(were)X -432 1840(used.)N -656(The)X -818(\256rst)X -979(is)X -1069(the)X -1204(dictionary)X -1566(database)X -1880(described)X -432 1928(previously.)N -836(The)X -987(second)X -1236(was)X -1386(constructed)X -1781(from)X -1962(a)X -2023(pass-)X -432 2016(word)N -647(\256le)X -799(with)X -990(approximately)X -1502(300)X -1671(accounts.)X -2041(Two)X -432 2104(records)N -700(were)X -887(constructed)X -1287(for)X -1411(each)X -1589(account.)X -1909(The)X -2064(\256rst)X -432 2192(used)N -604(the)X -727(logname)X -1028(as)X -1120(the)X -1243(key)X -1384(and)X -1525(the)X -1648(remainder)X -1999(of)X -2090(the)X -432 2280(password)N -768(entry)X -965(for)X -1091(the)X -1221(data.)X -1427(The)X -1584(second)X -1839(was)X -1996(keyed)X -432 2368(by)N -541(uid)X -672(and)X -817(contained)X -1157(the)X -1283(entire)X -1494(password)X -1825(entry)X -2018(as)X -2113(its)X -432 2456(data)N -589(\256eld.)X -794(The)X -942(tests)X -1107(were)X -1287(all)X -1389(run)X -1518(on)X -1620(the)X -1740(HP)X -1864(9000)X -2046(with)X -432 2544(the)N -574(same)X -783(con\256guration)X -1254(previously)X -1636(described.)X -2027(Each)X -432 2632(test)N -576(was)X -734(run)X -874(\256ve)X -1027(times)X -1232(and)X -1380(the)X -1510(timing)X -1750(results)X -1991(of)X -2090(the)X -432 2720(runs)N -602(were)X -791(averaged.)X -1154(The)X -1311(variance)X -1616(across)X -1849(the)X -1979(5)X -2050(runs)X -432 2808(was)N -591(approximately)X -1088(1%)X -1229(of)X -1330(the)X -1462(average)X -1746(yielding)X -2041(95%)X -432 2896(con\256dence)N -800(intervals)X -1096(of)X -1183(approximately)X -1666(2%.)X -3 f -1021 3050(Disk)N -1196(Based)X -1420(Tests)X -1 f -604 3182(In)N -693(these)X -880(tests,)X -1064(we)X -1180(use)X -1308(a)X -1365(bucket)X -1600(size)X -1746(of)X -1834(1024)X -2015(and)X -2152(a)X -432 3270(\256ll)N -540(factor)X -748(of)X -835(32.)X -3 f -432 3384(create)N -663(test)X -1 f -547 3498(The)N -703(keys)X -881(are)X -1011(entered)X -1279(into)X -1433(the)X -1561(hash)X -1738(table,)X -1944(and)X -2090(the)X -547 3586(\256le)N -669(is)X -742(\257ushed)X -993(to)X -1075(disk.)X -3 f -432 3700(read)N -608(test)X -1 f -547 3814(A)N -640(lookup)X -897(is)X -984(performed)X -1353(for)X -1481(each)X -1663(key)X -1813(in)X -1909(the)X -2041(hash)X -547 3902(table.)N -3 f -432 4016(verify)N -653(test)X -1 f -547 4130(A)N -640(lookup)X -897(is)X -984(performed)X -1353(for)X -1481(each)X -1663(key)X -1813(in)X -1909(the)X -2041(hash)X -547 4218(table,)N -759(and)X -911(the)X -1045(data)X -1215(returned)X -1519(is)X -1608(compared)X -1961(against)X -547 4306(that)N -687(originally)X -1018(stored)X -1234(in)X -1316(the)X -1434(hash)X -1601(table.)X -3 f -432 4420(sequential)N -798(retrieve)X -1 f -547 4534(All)N -674(keys)X -846(are)X -970(retrieved)X -1281(in)X -1367(sequential)X -1716(order)X -1910(from)X -2090(the)X -547 4622(hash)N -724(table.)X -950(The)X -2 f -1105(ndbm)X -1 f -1313(interface)X -1625(allows)X -1863(sequential)X -547 4710(retrieval)N -848(of)X -948(the)X -1079(keys)X -1259(from)X -1448(the)X -1578(database,)X -1907(but)X -2041(does)X -547 4798(not)N -701(return)X -945(the)X -1094(data)X -1279(associated)X -1660(with)X -1853(each)X -2052(key.)X -547 4886(Therefore,)N -929(we)X -1067(compare)X -1388(the)X -1530(performance)X -1980(of)X -2090(the)X -547 4974(new)N -703(package)X -989(to)X -1073(two)X -1215(different)X -1514(runs)X -1674(of)X -2 f -1763(ndbm)X -1 f -1941(.)X -2002(In)X -2090(the)X -547 5062(\256rst)N -697(case,)X -2 f -882(ndbm)X -1 f -1086(returns)X -1335(only)X -1503(the)X -1627(keys)X -1800(while)X -2003(in)X -2090(the)X -547 5150(second,)N -2 f -823(ndbm)X -1 f -1034(returns)X -1290(both)X -1465(the)X -1596(keys)X -1776(and)X -1924(the)X -2054(data)X -547 5238(\(requiring)N -894(a)X -956(second)X -1204(call)X -1345(to)X -1432(the)X -1555(library\).)X -1861(There)X -2074(is)X -2152(a)X -547 5326(single)N -764(run)X -897(for)X -1017(the)X -1141(new)X -1300(library)X -1539(since)X -1729(it)X -1798(returns)X -2046(both)X -547 5414(the)N -665(key)X -801(and)X -937(the)X -1055(data.)X -3 f -3014 538(In-Memory)N -3431(Test)X -1 f -2590 670(This)N -2757(test)X -2892(uses)X -3054(a)X -3114(bucket)X -3352(size)X -3501(of)X -3592(256)X -3736(and)X -3876(a)X -3936(\256ll)X -4048(fac-)X -2418 758(tor)N -2527(of)X -2614(8.)X -3 f -2418 872(create/read)N -2827(test)X -1 f -2533 986(In)N -2627(this)X -2769(test,)X -2927(a)X -2989(hash)X -3162(table)X -3344(is)X -3423(created)X -3682(by)X -3788(inserting)X -4094(all)X -2533 1074(the)N -2660(key/data)X -2961(pairs.)X -3186(Then)X -3380(a)X -3445(keyed)X -3666(retrieval)X -3963(is)X -4044(per-)X -2533 1162(formed)N -2801(for)X -2931(each)X -3115(pair,)X -3295(and)X -3446(the)X -3579(hash)X -3761(table)X -3952(is)X -4040(des-)X -2533 1250(troyed.)N -3 f -2938 1404(Performance)N -3405(Results)X -1 f -2590 1536(Figures)N -2866(8a)X -2978(and)X -3130(8b)X -3246(show)X -3451(the)X -3585(user)X -3755(time,)X -3952(system)X -2418 1624(time,)N -2608(and)X -2752(elapsed)X -3021(time)X -3191(for)X -3312(each)X -3487(test)X -3625(for)X -3746(both)X -3915(the)X -4040(new)X -2418 1712(implementation)N -2951(and)X -3098(the)X -3227(old)X -3360(implementation)X -3893(\()X -2 f -3920(hsearch)X -1 f -2418 1800(or)N -2 f -2528(ndbm)X -1 f -2706(,)X -2769(whichever)X -3147(is)X -3243(appropriate\))X -3678(as)X -3787(well)X -3967(as)X -4076(the)X -2418 1888(improvement.)N -2929(The)X -3098(improvement)X -3569(is)X -3666(expressed)X -4027(as)X -4138(a)X -2418 1976(percentage)N -2787(of)X -2874(the)X -2992(old)X -3114(running)X -3383(time:)X -0 f -8 s -2418 2275(%)N -2494(=)X -2570(100)X -2722(*)X -2798 -0.4219(\(old_time)AX -3178(-)X -3254 -0.4219(new_time\))AX -3634(/)X -3710(old_time)X -1 f -10 s -2590 2600(In)N -2700(nearly)X -2944(all)X -3067(cases,)X -3299(the)X -3439(new)X -3615(routines)X -3915(perform)X -2418 2688(better)N -2628(than)X -2793(the)X -2918(old)X -3047(routines)X -3332(\(both)X -2 f -3527(hsearch)X -1 f -3807(and)X -2 f -3949(ndbm)X -1 f -4127(\).)X -2418 2776(Although)N -2755(the)X -3 f -2888(create)X -1 f -3134(tests)X -3311(exhibit)X -3567(superior)X -3864(user)X -4032(time)X -2418 2864(performance,)N -2869(the)X -2991(test)X -3126(time)X -3292(is)X -3369(dominated)X -3731(by)X -3834(the)X -3955(cost)X -4107(of)X -2418 2952(writing)N -2677(the)X -2803(actual)X -3023(\256le)X -3153(to)X -3243(disk.)X -3444(For)X -3583(the)X -3709(large)X -3897(database)X -2418 3040(\(the)N -2564(dictionary\),)X -2957(this)X -3093(completely)X -3470(overwhelmed)X -3927(the)X -4045(sys-)X -2418 3128(tem)N -2570(time.)X -2783(However,)X -3129(for)X -3254(the)X -3383(small)X -3587(data)X -3752(base,)X -3946(we)X -4071(see)X -2418 3216(that)N -2569(differences)X -2958(in)X -3051(both)X -3224(user)X -3389(and)X -3536(system)X -3788(time)X -3960(contri-)X -2418 3304(bute)N -2576(to)X -2658(the)X -2776(superior)X -3059(performance)X -3486(of)X -3573(the)X -3691(new)X -3845(package.)X -2590 3418(The)N -3 f -2764(read)X -1 f -2920(,)X -3 f -2989(verify)X -1 f -3190(,)X -3259(and)X -3 f -3424(sequential)X -1 f -3818(results)X -4075(are)X -2418 3506(deceptive)N -2758(for)X -2883(the)X -3012(small)X -3216(database)X -3524(since)X -3720(the)X -3849(entire)X -4063(test)X -2418 3594(ran)N -2551(in)X -2643(under)X -2856(a)X -2922(second.)X -3215(However,)X -3560(on)X -3669(the)X -3796(larger)X -4013(data-)X -2418 3682(base)N -2590(the)X -3 f -2716(read)X -1 f -2900(and)X -3 f -3044(verify)X -1 f -3273(tests)X -3443(bene\256t)X -3689(from)X -3873(the)X -3999(cach-)X -2418 3770(ing)N -2546(of)X -2639(buckets)X -2910(in)X -2998(the)X -3122(new)X -3282(package)X -3571(to)X -3658(improve)X -3950(perfor-)X -2418 3858(mance)N -2666(by)X -2784(over)X -2965(80%.)X -3169(Since)X -3384(the)X -3519(\256rst)X -3 f -3680(sequential)X -1 f -4063(test)X -2418 3946(does)N -2598(not)X -2733(require)X -2 f -2994(ndbm)X -1 f -3205(to)X -3299(return)X -3523(the)X -3653(data)X -3819(values,)X -4076(the)X -2418 4034(user)N -2573(time)X -2735(is)X -2808(lower)X -3011(than)X -3169(for)X -3283(the)X -3401(new)X -3555(package.)X -3879(However)X -2418 4122(when)N -2613(we)X -2728(require)X -2977(both)X -3139(packages)X -3454(to)X -3536(return)X -3748(data,)X -3922(the)X -4040(new)X -2418 4210(package)N -2702(excels)X -2923(in)X -3005(all)X -3105(three)X -3286(timings.)X -2590 4324(The)N -2773(small)X -3003(database)X -3337(runs)X -3532(so)X -3660(quickly)X -3957(in)X -4076(the)X -2418 4412(memory-resident)N -3000(case)X -3173(that)X -3326(the)X -3457(results)X -3699(are)X -3831(uninterest-)X -2418 4500(ing.)N -2589(However,)X -2933(for)X -3056(the)X -3183(larger)X -3400(database)X -3706(the)X -3833(new)X -3995(pack-)X -2418 4588(age)N -2567(pays)X -2751(a)X -2824(small)X -3033(penalty)X -3305(in)X -3403(system)X -3661(time)X -3839(because)X -4130(it)X -2418 4676(limits)N -2636(its)X -2748(main)X -2944(memory)X -3247(utilization)X -3607(and)X -3759(swaps)X -3991(pages)X -2418 4764(out)N -2550(to)X -2642(temporary)X -3002(storage)X -3264(in)X -3356(the)X -3484(\256le)X -3616(system)X -3868(while)X -4076(the)X -2 f -2418 4852(hsearch)N -1 f -2698(package)X -2988(requires)X -3273(that)X -3419(the)X -3543(application)X -3924(allocate)X -2418 4940(enough)N -2692(space)X -2909(for)X -3041(all)X -3159(key/data)X -3468(pair.)X -3670(However,)X -4022(even)X -2418 5028(with)N -2600(the)X -2738(system)X -3000(time)X -3182(penalty,)X -3477(the)X -3614(resulting)X -3933(elapsed)X -2418 5116(time)N -2580(improves)X -2898(by)X -2998(over)X -3161(50%.)X -3 f -432 5960(10)N -2970(USENIX)X -9 f -3292(-)X -3 f -3356(Winter)X -3621('91)X -9 f -3748(-)X -3 f -3812(Dallas,)X -4065(TX)X - -11 p -%%Page: 11 11 -0(Courier)xf 0 f -10 s 10 xH 0 xS 0 f -3 f -720 258(Seltzer)N -977(&)X -1064(Yigit)X -3278(A)X -3356(New)X -3528(Hashing)X -3831(Package)X -4136(for)X -4259(UNIX)X -1 f -10 f -908 454(i)N -927(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -2 f -1379 546(hash)N -1652(ndbm)X -1950(%change)X -1 f -10 f -908 550(i)N -927(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -948 642(CREATE)N -10 f -908 646(i)N -927(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -1125 738(user)N -1424(6.4)X -1671(12.2)X -2073(48)X -1157 826(sys)N -1384(32.5)X -1671(34.7)X -2113(6)X -3 f -1006 914(elapsed)N -10 f -1310 922(c)N -890(c)Y -810(c)Y -730(c)Y -3 f -1384 914(90.4)N -10 f -1581 922(c)N -890(c)Y -810(c)Y -730(c)Y -3 f -1671 914(99.6)N -10 f -1883 922(c)N -890(c)Y -810(c)Y -730(c)Y -3 f -2113 914(9)N -1 f -10 f -908 910(i)N -927(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -908 926(i)N -927(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -948 1010(READ)N -10 f -908 1014(i)N -927(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -1125 1106(user)N -1424(3.4)X -1711(6.1)X -2073(44)X -1157 1194(sys)N -1424(1.2)X -1671(15.3)X -2073(92)X -3 f -1006 1282(elapsed)N -10 f -1310 1290(c)N -1258(c)Y -1178(c)Y -1098(c)Y -3 f -1424 1282(4.0)N -10 f -1581 1290(c)N -1258(c)Y -1178(c)Y -1098(c)Y -3 f -1671 1282(21.2)N -10 f -1883 1290(c)N -1258(c)Y -1178(c)Y -1098(c)Y -3 f -2073 1282(81)N -1 f -10 f -908 1278(i)N -927(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -908 1294(i)N -927(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -948 1378(VERIFY)N -10 f -908 1382(i)N -927(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -1125 1474(user)N -1424(3.5)X -1711(6.3)X -2073(44)X -1157 1562(sys)N -1424(1.2)X -1671(15.3)X -2073(92)X -3 f -1006 1650(elapsed)N -10 f -1310 1658(c)N -1626(c)Y -1546(c)Y -1466(c)Y -3 f -1424 1650(4.0)N -10 f -1581 1658(c)N -1626(c)Y -1546(c)Y -1466(c)Y -3 f -1671 1650(21.2)N -10 f -1883 1658(c)N -1626(c)Y -1546(c)Y -1466(c)Y -3 f -2073 1650(81)N -1 f -10 f -908 1646(i)N -927(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -908 1662(i)N -927(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -948 1746(SEQUENTIAL)N -10 f -908 1750(i)N -927(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -1125 1842(user)N -1424(2.7)X -1711(1.9)X -2046(-42)X -1157 1930(sys)N -1424(0.7)X -1711(3.9)X -2073(82)X -3 f -1006 2018(elapsed)N -10 f -1310 2026(c)N -1994(c)Y -1914(c)Y -1834(c)Y -3 f -1424 2018(3.0)N -10 f -1581 2026(c)N -1994(c)Y -1914(c)Y -1834(c)Y -3 f -1711 2018(5.0)N -10 f -1883 2026(c)N -1994(c)Y -1914(c)Y -1834(c)Y -3 f -2073 2018(40)N -1 f -10 f -908 2014(i)N -927(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -908 2030(i)N -927(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -948 2114(SEQUENTIAL)N -1467(\(with)X -1656(data)X -1810(retrieval\))X -10 f -908 2118(i)N -927(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -1125 2210(user)N -1424(2.7)X -1711(8.2)X -2073(67)X -1157 2298(sys)N -1424(0.7)X -1711(4.3)X -2073(84)X -3 f -1006 2386(elapsed)N -1424(3.0)X -1671(12.0)X -2073(75)X -1 f -10 f -908 2390(i)N -927(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -899 2394(c)N -2378(c)Y -2298(c)Y -2218(c)Y -2138(c)Y -2058(c)Y -1978(c)Y -1898(c)Y -1818(c)Y -1738(c)Y -1658(c)Y -1578(c)Y -1498(c)Y -1418(c)Y -1338(c)Y -1258(c)Y -1178(c)Y -1098(c)Y -1018(c)Y -938(c)Y -858(c)Y -778(c)Y -698(c)Y -618(c)Y -538(c)Y -1310 2394(c)N -2362(c)Y -2282(c)Y -2202(c)Y -1581 2394(c)N -2362(c)Y -2282(c)Y -2202(c)Y -1883 2394(c)N -2362(c)Y -2282(c)Y -2202(c)Y -2278 2394(c)N -2378(c)Y -2298(c)Y -2218(c)Y -2138(c)Y -2058(c)Y -1978(c)Y -1898(c)Y -1818(c)Y -1738(c)Y -1658(c)Y -1578(c)Y -1498(c)Y -1418(c)Y -1338(c)Y -1258(c)Y -1178(c)Y -1098(c)Y -1018(c)Y -938(c)Y -858(c)Y -778(c)Y -698(c)Y -618(c)Y -538(c)Y -905 2574(i)N -930(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -2 f -1318 2666(hash)N -1585(hsearch)X -1953(%change)X -1 f -10 f -905 2670(i)N -930(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -945 2762(CREATE/READ)N -10 f -905 2766(i)N -930(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -1064 2858(user)N -1343(6.6)X -1642(17.2)X -2096(62)X -1096 2946(sys)N -1343(1.1)X -1682(0.3)X -2029(-266)X -3 f -945 3034(elapsed)N -1343(7.8)X -1642(17.0)X -2096(54)X -1 f -10 f -905 3038(i)N -930(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -896 3050(c)N -2978(c)Y -2898(c)Y -2818(c)Y -2738(c)Y -2658(c)Y -1249 3034(c)N -3010(c)Y -2930(c)Y -2850(c)Y -1520 3034(c)N -3010(c)Y -2930(c)Y -2850(c)Y -1886 3034(c)N -3010(c)Y -2930(c)Y -2850(c)Y -2281 3050(c)N -2978(c)Y -2898(c)Y -2818(c)Y -2738(c)Y -2658(c)Y -3 f -720 3174(Figure)N -967(8a:)X -1 f -1094(Timing)X -1349(results)X -1578(for)X -1692(the)X -1810(dictionary)X -2155(database.)X -10 f -720 3262 -0.0930(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)AN -3 f -1407 3504(Conclusion)N -1 f -892 3636(This)N -1063(paper)X -1271(has)X -1407(presented)X -1744(the)X -1871(design,)X -2129(implemen-)X -720 3724(tation)N -928(and)X -1070(performance)X -1503(of)X -1596(a)X -1658(new)X -1818(hashing)X -2093(package)X -2382(for)X -720 3812(UNIX.)N -993(The)X -1150(new)X -1316(package)X -1612(provides)X -1919(a)X -1986(superset)X -2280(of)X -2378(the)X -720 3900(functionality)N -1159(of)X -1255(existing)X -1537(hashing)X -1815(packages)X -2139(and)X -2284(incor-)X -720 3988(porates)N -975(additional)X -1318(features)X -1596(such)X -1766(as)X -1855(large)X -2038(key)X -2176(handling,)X -720 4076(user)N -876(de\256ned)X -1134(hash)X -1302(functions,)X -1641(multiple)X -1928(hash)X -2096(tables,)X -2324(vari-)X -720 4164(able)N -894(sized)X -1099(pages,)X -1342(and)X -1498(linear)X -1721(hashing.)X -2050(In)X -2156(nearly)X -2396(all)X -720 4252(cases,)N -954(the)X -1096(new)X -1274(package)X -1582(provides)X -1902(improved)X -2252(perfor-)X -720 4340(mance)N -974(on)X -1098(the)X -1240(order)X -1454(of)X -1565(50-80%)X -1863(for)X -2001(the)X -2142(workloads)X -720 4428(shown.)N -990(Applications)X -1420(such)X -1588(as)X -1676(the)X -1794(loader,)X -2035(compiler,)X -2360(and)X -720 4516(mail,)N -921(which)X -1156(currently)X -1485(implement)X -1866(their)X -2051(own)X -2227(hashing)X -720 4604(routines,)N -1032(should)X -1279(be)X -1389(modi\256ed)X -1706(to)X -1801(use)X -1941(the)X -2072(generic)X -2342(rou-)X -720 4692(tines.)N -892 4806(This)N -1087(hashing)X -1389(package)X -1705(is)X -1810(one)X -1978(access)X -2236(method)X -720 4894(which)N -953(is)X -1043(part)X -1205(of)X -1309(a)X -1382(generic)X -1656(database)X -1970(access)X -2212(package)X -720 4982(being)N -955(developed)X -1342(at)X -1457(the)X -1612(University)X -2007(of)X -2131(California,)X -720 5070(Berkeley.)N -1089(It)X -1177(will)X -1340(include)X -1614(a)X -1688(btree)X -1887(access)X -2131(method)X -2409(as)X -720 5158(well)N -916(as)X -1041(\256xed)X -1259(and)X -1433(variable)X -1750(length)X -2007(record)X -2270(access)X -720 5246(methods)N -1024(in)X -1119(addition)X -1414(to)X -1509(the)X -1640(hashed)X -1896(support)X -2168(presented)X -720 5334(here.)N -948(All)X -1099(of)X -1215(the)X -1361(access)X -1615(methods)X -1934(are)X -2081(based)X -2312(on)X -2440(a)X -720 5422(key/data)N -1037(pair)X -1207(interface)X -1533(and)X -1693(appear)X -1952(identical)X -2272(to)X -2378(the)X -720 5510(application)N -1121(layer,)X -1347(allowing)X -1671(application)X -2071(implementa-)X -720 5598(tions)N -906(to)X -999(be)X -1106(largely)X -1360(independent)X -1783(of)X -1881(the)X -2010(database)X -2318(type.)X -720 5686(The)N -873(package)X -1165(is)X -1246(expected)X -1560(to)X -1650(be)X -1754(an)X -1858(integral)X -2131(part)X -2284(of)X -2378(the)X -2706 538(4.4BSD)N -3006(system,)X -3293(with)X -3479(various)X -3759(standard)X -4075(applications)X -2706 626(such)N -2879(as)X -2972(more\(1\),)X -3277(sort\(1\))X -3517(and)X -3659(vi\(1\))X -3841(based)X -4050(on)X -4156(it.)X -4266(While)X -2706 714(the)N -2833(current)X -3089(design)X -3326(does)X -3501(not)X -3631(support)X -3899(multi-user)X -4256(access)X -2706 802(or)N -2804(transactions,)X -3238(they)X -3407(could)X -3616(be)X -3723(incorporated)X -4159(relatively)X -2706 890(easily.)N -10 f -2894 938(i)N -2913(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -2 f -3365 1030(hash)N -3638(ndbm)X -3936(%change)X -1 f -10 f -2894 1034(i)N -2913(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -2934 1126(CREATE)N -10 f -2894 1130(i)N -2913(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -3111 1222(user)N -3390(0.2)X -3677(0.4)X -4079(50)X -3143 1310(sys)N -3390(0.1)X -3677(1.0)X -4079(90)X -3 f -2992 1398(elapsed)N -10 f -3296 1406(c)N -1374(c)Y -1294(c)Y -1214(c)Y -3 f -3390 1398(0)N -10 f -3567 1406(c)N -1374(c)Y -1294(c)Y -1214(c)Y -3 f -3677 1398(3.2)N -10 f -3869 1406(c)N -1374(c)Y -1294(c)Y -1214(c)Y -3 f -4039 1398(100)N -1 f -10 f -2894 1394(i)N -2913(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -2894 1410(i)N -2913(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -2934 1494(READ)N -10 f -2894 1498(i)N -2913(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -3111 1590(user)N -3390(0.1)X -3677(0.1)X -4119(0)X -3143 1678(sys)N -3390(0.1)X -3677(0.4)X -4079(75)X -3 f -2992 1766(elapsed)N -10 f -3296 1774(c)N -1742(c)Y -1662(c)Y -1582(c)Y -3 f -3390 1766(0.0)N -10 f -3567 1774(c)N -1742(c)Y -1662(c)Y -1582(c)Y -3 f -3677 1766(0.0)N -10 f -3869 1774(c)N -1742(c)Y -1662(c)Y -1582(c)Y -3 f -4119 1766(0)N -1 f -10 f -2894 1762(i)N -2913(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -2894 1778(i)N -2913(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -2934 1862(VERIFY)N -10 f -2894 1866(i)N -2913(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -3111 1958(user)N -3390(0.1)X -3677(0.2)X -4079(50)X -3143 2046(sys)N -3390(0.1)X -3677(0.3)X -4079(67)X -3 f -2992 2134(elapsed)N -10 f -3296 2142(c)N -2110(c)Y -2030(c)Y -1950(c)Y -3 f -3390 2134(0.0)N -10 f -3567 2142(c)N -2110(c)Y -2030(c)Y -1950(c)Y -3 f -3677 2134(0.0)N -10 f -3869 2142(c)N -2110(c)Y -2030(c)Y -1950(c)Y -3 f -4119 2134(0)N -1 f -10 f -2894 2130(i)N -2913(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -2894 2146(i)N -2913(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -2934 2230(SEQUENTIAL)N -10 f -2894 2234(i)N -2913(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -3111 2326(user)N -3390(0.1)X -3677(0.0)X -4012(-100)X -3143 2414(sys)N -3390(0.1)X -3677(0.1)X -4119(0)X -3 f -2992 2502(elapsed)N -10 f -3296 2510(c)N -2478(c)Y -2398(c)Y -2318(c)Y -3 f -3390 2502(0.0)N -10 f -3567 2510(c)N -2478(c)Y -2398(c)Y -2318(c)Y -3 f -3677 2502(0.0)N -10 f -3869 2510(c)N -2478(c)Y -2398(c)Y -2318(c)Y -3 f -4119 2502(0)N -1 f -10 f -2894 2498(i)N -2913(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -2894 2514(i)N -2913(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -2934 2598(SEQUENTIAL)N -3453(\(with)X -3642(data)X -3796(retrieval\))X -10 f -2894 2602(i)N -2913(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -3111 2694(user)N -3390(0.1)X -3677(0.1)X -4119(0)X -3143 2782(sys)N -3390(0.1)X -3677(0.1)X -4119(0)X -3 f -2992 2870(elapsed)N -3390(0.0)X -3677(0.0)X -4119(0)X -1 f -10 f -2894 2874(i)N -2913(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -2885 2878(c)N -2862(c)Y -2782(c)Y -2702(c)Y -2622(c)Y -2542(c)Y -2462(c)Y -2382(c)Y -2302(c)Y -2222(c)Y -2142(c)Y -2062(c)Y -1982(c)Y -1902(c)Y -1822(c)Y -1742(c)Y -1662(c)Y -1582(c)Y -1502(c)Y -1422(c)Y -1342(c)Y -1262(c)Y -1182(c)Y -1102(c)Y -1022(c)Y -3296 2878(c)N -2846(c)Y -2766(c)Y -2686(c)Y -3567 2878(c)N -2846(c)Y -2766(c)Y -2686(c)Y -3869 2878(c)N -2846(c)Y -2766(c)Y -2686(c)Y -4264 2878(c)N -2862(c)Y -2782(c)Y -2702(c)Y -2622(c)Y -2542(c)Y -2462(c)Y -2382(c)Y -2302(c)Y -2222(c)Y -2142(c)Y -2062(c)Y -1982(c)Y -1902(c)Y -1822(c)Y -1742(c)Y -1662(c)Y -1582(c)Y -1502(c)Y -1422(c)Y -1342(c)Y -1262(c)Y -1182(c)Y -1102(c)Y -1022(c)Y -2891 3058(i)N -2916(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -2 f -3304 3150(hash)N -3571(hsearch)X -3939(%change)X -1 f -10 f -2891 3154(i)N -2916(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -2931 3246(CREATE/READ)N -10 f -2891 3250(i)N -2916(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -3050 3342(user)N -3329(0.3)X -3648(0.4)X -4048(25)X -3082 3430(sys)N -3329(0.0)X -3648(0.0)X -4088(0)X -3 f -2931 3518(elapsed)N -3329(0.0)X -3648(0.0)X -4088(0)X -1 f -10 f -2891 3522(i)N -2916(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -2882 3534(c)N -3462(c)Y -3382(c)Y -3302(c)Y -3222(c)Y -3142(c)Y -3235 3518(c)N -3494(c)Y -3414(c)Y -3334(c)Y -3506 3518(c)N -3494(c)Y -3414(c)Y -3334(c)Y -3872 3518(c)N -3494(c)Y -3414(c)Y -3334(c)Y -4267 3534(c)N -3462(c)Y -3382(c)Y -3302(c)Y -3222(c)Y -3142(c)Y -3 f -2706 3658(Figure)N -2953(8b:)X -1 f -3084(Timing)X -3339(results)X -3568(for)X -3682(the)X -3800(password)X -4123(database.)X -10 f -2706 3746 -0.0930(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)AN -3 f -3396 3988(References)N -1 f -2706 4120([ATT79])N -3058(AT&T,)X -3358(DBM\(3X\),)X -2 f -3773(Unix)X -3990(Programmer's)X -2878 4208(Manual,)N -3194(Seventh)X -3491(Edition,)X -3793(Volume)X -4085(1)X -1 f -(,)S -4192(January,)X -2878 4296(1979.)N -2706 4472([ATT85])N -3027(AT&T,)X -3296(HSEARCH\(BA_LIB\),)X -2 f -4053(Unix)X -4239(System)X -2878 4560(User's)N -3112(Manual,)X -3401(System)X -3644(V.3)X -1 f -3753(,)X -3793(pp.)X -3913(506-508,)X -4220(1985.)X -2706 4736([BRE73])N -3025(Brent,)X -3253(Richard)X -3537(P.,)X -3651(``Reducing)X -4041(the)X -4168(Retrieval)X -2878 4824(Time)N -3071(of)X -3162(Scatter)X -3409(Storage)X -3678(Techniques'',)X -2 f -4146(Commun-)X -2878 4912(ications)N -3175(of)X -3281(the)X -3422(ACM)X -1 f -3591(,)X -3654(Volume)X -3955(16,)X -4098(No.)X -4259(2,)X -4362(pp.)X -2878 5000(105-109,)N -3185(February,)X -3515(1973.)X -2706 5176([BSD86])N -3055(NDBM\(3\),)X -2 f -3469(4.3BSD)X -3775(Unix)X -3990(Programmer's)X -2878 5264(Manual)N -3155(Reference)X -3505(Guide)X -1 f -3701(,)X -3749(University)X -4114(of)X -4208(Califor-)X -2878 5352(nia,)N -3016(Berkeley,)X -3346(1986.)X -2706 5528([ENB88])N -3025(Enbody,)X -3319(R.)X -3417(J.,)X -3533(Du,)X -3676(H.)X -3779(C.,)X -3897(``Dynamic)X -4270(Hash-)X -2878 5616(ing)N -3034(Schemes'',)X -2 f -3427(ACM)X -3630(Computing)X -4019(Surveys)X -1 f -4269(,)X -4322(Vol.)X -2878 5704(20,)N -2998(No.)X -3136(2,)X -3216(pp.)X -3336(85-113,)X -3603(June)X -3770(1988.)X -3 f -720 5960(USENIX)N -9 f -1042(-)X -3 f -1106(Winter)X -1371('91)X -9 f -1498(-)X -3 f -1562(Dallas,)X -1815(TX)X -4384(11)X - -12 p -%%Page: 12 12 -0(Courier)xf 0 f -10 s 10 xH 0 xS 0 f -3 f -432 258(A)N -510(New)X -682(Hashing)X -985(Package)X -1290(for)X -1413(UNIX)X -3663(Seltzer)X -3920(&)X -4007(Yigit)X -1 f -432 538([FAG79])N -776(Ronald)X -1057(Fagin,)X -1308(Jurg)X -1495(Nievergelt,)X -1903(Nicholas)X -604 626(Pippenger,)N -1003(H.)X -1135(Raymond)X -1500(Strong,)X -1787(``Extendible)X -604 714(Hashing)N -901(--)X -985(A)X -1073(Fast)X -1236(Access)X -1493(Method)X -1771(for)X -1894(Dynamic)X -604 802(Files'',)N -2 f -855(ACM)X -1046(Transactions)X -1485(on)X -1586(Database)X -1914(Systems)X -1 f -2168(,)X -604 890(Volume)N -882(4,)X -962(No.)X -1100(3.,)X -1200(September)X -1563(1979,)X -1763(pp)X -1863(315-34)X -432 1066([KNU68],)N -802(Knuth,)X -1064(D.E.,)X -2 f -1273(The)X -1434(Art)X -1577(of)X -1680(Computer)X -2041(Pro-)X -604 1154(gramming)N -971(Vol.)X -1140(3:)X -1245(Sorting)X -1518(and)X -1676(Searching)X -1 f -2001(,)X -2058(sec-)X -604 1242(tions)N -779(6.3-6.4,)X -1046(pp)X -1146(481-550.)X -432 1418([LAR78])N -747(Larson,)X -1011(Per-Ake,)X -1319(``Dynamic)X -1687(Hashing'',)X -2 f -2048(BIT)X -1 f -(,)S -604 1506(Vol.)N -764(18,)X -884(1978,)X -1084(pp.)X -1204(184-201.)X -432 1682([LAR88])N -752(Larson,)X -1021(Per-Ake,)X -1335(``Dynamic)X -1709(Hash)X -1900(Tables'',)X -2 f -604 1770(Communications)N -1183(of)X -1281(the)X -1415(ACM)X -1 f -1584(,)X -1640(Volume)X -1934(31,)X -2070(No.)X -604 1858(4.,)N -704(April)X -893(1988,)X -1093(pp)X -1193(446-457.)X -432 2034([LIT80])N -731(Witold,)X -1013(Litwin,)X -1286(``Linear)X -1590(Hashing:)X -1939(A)X -2036(New)X -604 2122(Tool)N -786(for)X -911(File)X -1065(and)X -1211(Table)X -1424(Addressing'',)X -2 f -1893(Proceed-)X -604 2210(ings)N -761(of)X -847(the)X -969(6th)X -1095(International)X -1540(Conference)X -1933(on)X -2036(Very)X -604 2298(Large)N -815(Databases)X -1 f -1153(,)X -1193(1980.)X -432 2474([NEL90])N -743(Nelson,)X -1011(Philip)X -1222(A.,)X -2 f -1341(Gdbm)X -1558(1.4)X -1679(source)X -1913(distribu-)X -604 2562(tion)N -748(and)X -888(README)X -1 f -1209(,)X -1249(August)X -1500(1990.)X -432 2738([THOM90])N -840(Ken)X -1011(Thompson,)X -1410(private)X -1670(communication,)X -604 2826(Nov.)N -782(1990.)X -432 3002([TOR87])N -790(Torek,)X -1066(C.,)X -1222(``Re:)X -1470(dbm.a)X -1751(and)X -1950(ndbm.a)X -604 3090(archives'',)N -2 f -966(USENET)X -1279(newsgroup)X -1650(comp.unix)X -1 f -2002(1987.)X -432 3266([TOR88])N -760(Torek,)X -1006(C.,)X -1133(``Re:)X -1351(questions)X -1686(regarding)X -2027(data-)X -604 3354(bases)N -826(created)X -1106(with)X -1295(dbm)X -1484(and)X -1647(ndbm)X -1876(routines'')X -2 f -604 3442(USENET)N -937(newsgroup)X -1328(comp.unix.questions)X -1 f -1982(,)X -2041(June)X -604 3530(1988.)N -432 3706([WAL84])N -773(Wales,)X -1018(R.,)X -1135(``Discussion)X -1564(of)X -1655("dbm")X -1887(data)X -2045(base)X -604 3794(system'',)N -2 f -973(USENET)X -1339(newsgroup)X -1762(unix.wizards)X -1 f -2168(,)X -604 3882(January,)N -894(1984.)X -432 4058([YIG89])N -751(Ozan)X -963(S.)X -1069(Yigit,)X -1294(``How)X -1545(to)X -1648(Roll)X -1826(Your)X -2032(Own)X -604 4146(Dbm/Ndbm'',)N -2 f -1087(unpublished)X -1504(manuscript)X -1 f -(,)S -1910(Toronto,)X -604 4234(July,)N -777(1989)X -3 f -432 5960(12)N -2970(USENIX)X -9 f -3292(-)X -3 f -3356(Winter)X -3621('91)X -9 f -3748(-)X -3 f -3812(Dallas,)X -4065(TX)X - -13 p -%%Page: 13 13 -0(Courier)xf 0 f -10 s 10 xH 0 xS 0 f -3 f -720 258(Seltzer)N -977(&)X -1064(Yigit)X -3278(A)X -3356(New)X -3528(Hashing)X -3831(Package)X -4136(for)X -4259(UNIX)X -1 f -720 538(Margo)N -960(I.)X -1033(Seltzer)X -1282(is)X -1361(a)X -1423(Ph.D.)X -1631(student)X -1887(in)X -1974(the)X -2097(Department)X -720 626(of)N -823(Electrical)X -1167(Engineering)X -1595(and)X -1747(Computer)X -2102(Sciences)X -2418(at)X -720 714(the)N -850(University)X -1220(of)X -1318(California,)X -1694(Berkeley.)X -2055(Her)X -2207(research)X -720 802(interests)N -1017(include)X -1283(\256le)X -1415(systems,)X -1718(databases,)X -2076(and)X -2221(transac-)X -720 890(tion)N -896(processing)X -1291(systems.)X -1636(She)X -1807(spent)X -2027(several)X -2306(years)X -720 978(working)N -1026(at)X -1123(startup)X -1380(companies)X -1762(designing)X -2112(and)X -2267(imple-)X -720 1066(menting)N -1048(\256le)X -1216(systems)X -1535(and)X -1716(transaction)X -2133(processing)X -720 1154(software)N -1026(and)X -1170(designing)X -1509(microprocessors.)X -2103(Ms.)X -2253(Seltzer)X -720 1242(received)N -1057(her)X -1223(AB)X -1397(in)X -1522(Applied)X -1843(Mathematics)X -2320(from)X -720 1330 0.1953(Harvard/Radcliffe)AN -1325(College)X -1594(in)X -1676(1983.)X -720 1444(In)N -810(her)X -936(spare)X -1129(time,)X -1313(Margo)X -1549(can)X -1683(usually)X -1936(be)X -2034(found)X -2243(prepar-)X -720 1532(ing)N -868(massive)X -1171(quantities)X -1527(of)X -1639(food)X -1831(for)X -1970(hungry)X -2242(hoards,)X -720 1620(studying)N -1022(Japanese,)X -1355(or)X -1449(playing)X -1716(soccer)X -1948(with)X -2116(an)X -2218(exciting)X -720 1708(Bay)N -912(Area)X -1132(Women's)X -1507(Soccer)X -1788(team,)X -2026(the)X -2186(Berkeley)X -720 1796(Bruisers.)N -720 1910(Ozan)N -915(\()X -3 f -942(Oz)X -1 f -1040(\))X -1092(Yigit)X -1281(is)X -1358(currently)X -1672(a)X -1732(software)X -2033(engineer)X -2334(with)X -720 1998(the)N -886(Communications)X -1499(Research)X -1861(and)X -2044(Development)X -720 2086(group,)N -948(Computing)X -1328(Services,)X -1641(York)X -1826(University.)X -2224(His)X -2355(for-)X -720 2174(mative)N -967(years)X -1166(were)X -1352(also)X -1510(spent)X -1708(at)X -1795(York,)X -2009(where)X -2234(he)X -2338(held)X -720 2262(system)N -985(programmer)X -1425(and)X -1583(administrator)X -2052(positions)X -2382(for)X -720 2350(various)N -995(mixtures)X -1314(of)X -1420(of)X -1526(UNIX)X -1765(systems)X -2056(starting)X -2334(with)X -720 2438(Berkeley)N -1031(4.1)X -1151(in)X -1233(1982,)X -1433(while)X -1631(at)X -1709(the)X -1827(same)X -2012(time)X -2174(obtaining)X -720 2526(a)N -776(degree)X -1011(in)X -1093(Computer)X -1433(Science.)X -720 2640(In)N -813(his)X -931(copious)X -1205(free)X -1356(time,)X -1543(Oz)X -1662(enjoys)X -1896(working)X -2188(on)X -2293(what-)X -720 2728(ever)N -890(software)X -1197(looks)X -1400(interesting,)X -1788(which)X -2014(often)X -2209(includes)X -720 2816(language)N -1044(interpreters,)X -1464(preprocessors,)X -1960(and)X -2110(lately,)X -2342(pro-)X -720 2904(gram)N -905(generators)X -1260(and)X -1396(expert)X -1617(systems.)X -720 3018(Oz)N -836(has)X -964(authored)X -1266(several)X -1515(public-domain)X -2003(software)X -2301(tools,)X -720 3106(including)N -1069(an)X -1191(nroff-like)X -1545(text)X -1711(formatter)X -2 f -2056(proff)X -1 f -2257(that)X -2423(is)X -720 3194(apparently)N -1083(still)X -1226(used)X -1397(in)X -1483(some)X -1676(basement)X -2002(PCs.)X -2173(His)X -2307(latest)X -720 3282(obsessions)N -1143(include)X -1460(the)X -1639(incredible)X -2040(programming)X -720 3370(language)N -1030(Scheme,)X -1324(and)X -1460(Chinese)X -1738(Brush)X -1949(painting.)X -3 f -720 5960(USENIX)N -9 f -1042(-)X -3 f -1106(Winter)X -1371('91)X -9 f -1498(-)X -3 f -1562(Dallas,)X -1815(TX)X -4384(13)X - -14 p -%%Page: 14 14 -0(Courier)xf 0 f -10 s 10 xH 0 xS 0 f -3 f -432 5960(14)N -2970(USENIX)X -9 f -3292(-)X -3 f -3356(Winter)X -3621('91)X -9 f -3748(-)X -3 f -3812(Dallas,)X -4065(TX)X - -14 p -%%Trailer -xt - -xs diff --git a/lib/libc/db/docs/libtp.usenix.ps b/lib/libc/db/docs/libtp.usenix.ps deleted file mode 100644 index b7e441a..0000000 --- a/lib/libc/db/docs/libtp.usenix.ps +++ /dev/null @@ -1,12340 +0,0 @@ -%!PS-Adobe-1.0 -%%Creator: utopia:margo (& Seltzer,608-13E,8072,) -%%Title: stdin (ditroff) -%%CreationDate: Thu Dec 12 15:32:11 1991 -%%EndComments -% @(#)psdit.pro 1.3 4/15/88 -% lib/psdit.pro -- prolog for psdit (ditroff) files -% Copyright (c) 1984, 1985 Adobe Systems Incorporated. All Rights Reserved. -% last edit: shore Sat Nov 23 20:28:03 1985 -% RCSID: $FreeBSD$ - -% Changed by Edward Wang (edward@ucbarpa.berkeley.edu) to handle graphics, -% 17 Feb, 87. - -/$DITroff 140 dict def $DITroff begin -/fontnum 1 def /fontsize 10 def /fontheight 10 def /fontslant 0 def -/xi{0 72 11 mul translate 72 resolution div dup neg scale 0 0 moveto - /fontnum 1 def /fontsize 10 def /fontheight 10 def /fontslant 0 def F - /pagesave save def}def -/PB{save /psv exch def currentpoint translate - resolution 72 div dup neg scale 0 0 moveto}def -/PE{psv restore}def -/arctoobig 90 def /arctoosmall .05 def -/m1 matrix def /m2 matrix def /m3 matrix def /oldmat matrix def -/tan{dup sin exch cos div}def -/point{resolution 72 div mul}def -/dround {transform round exch round exch itransform}def -/xT{/devname exch def}def -/xr{/mh exch def /my exch def /resolution exch def}def -/xp{}def -/xs{docsave restore end}def -/xt{}def -/xf{/fontname exch def /slotno exch def fontnames slotno get fontname eq not - {fonts slotno fontname findfont put fontnames slotno fontname put}if}def -/xH{/fontheight exch def F}def -/xS{/fontslant exch def F}def -/s{/fontsize exch def /fontheight fontsize def F}def -/f{/fontnum exch def F}def -/F{fontheight 0 le{/fontheight fontsize def}if - fonts fontnum get fontsize point 0 0 fontheight point neg 0 0 m1 astore - fontslant 0 ne{1 0 fontslant tan 1 0 0 m2 astore m3 concatmatrix}if - makefont setfont .04 fontsize point mul 0 dround pop setlinewidth}def -/X{exch currentpoint exch pop moveto show}def -/N{3 1 roll moveto show}def -/Y{exch currentpoint pop exch moveto show}def -/S{show}def -/ditpush{}def/ditpop{}def -/AX{3 -1 roll currentpoint exch pop moveto 0 exch ashow}def -/AN{4 2 roll moveto 0 exch ashow}def -/AY{3 -1 roll currentpoint pop exch moveto 0 exch ashow}def -/AS{0 exch ashow}def -/MX{currentpoint exch pop moveto}def -/MY{currentpoint pop exch moveto}def -/MXY{moveto}def -/cb{pop}def % action on unknown char -- nothing for now -/n{}def/w{}def -/p{pop showpage pagesave restore /pagesave save def}def -/Dt{/Dlinewidth exch def}def 1 Dt -/Ds{/Ddash exch def}def -1 Ds -/Di{/Dstipple exch def}def 1 Di -/Dsetlinewidth{2 Dlinewidth mul setlinewidth}def -/Dsetdash{Ddash 4 eq{[8 12]}{Ddash 16 eq{[32 36]} - {Ddash 20 eq{[32 12 8 12]}{[]}ifelse}ifelse}ifelse 0 setdash}def -/Dstroke{gsave Dsetlinewidth Dsetdash 1 setlinecap stroke grestore - currentpoint newpath moveto}def -/Dl{rlineto Dstroke}def -/arcellipse{/diamv exch def /diamh exch def oldmat currentmatrix pop - currentpoint translate 1 diamv diamh div scale /rad diamh 2 div def - currentpoint exch rad add exch rad -180 180 arc oldmat setmatrix}def -/Dc{dup arcellipse Dstroke}def -/De{arcellipse Dstroke}def -/Da{/endv exch def /endh exch def /centerv exch def /centerh exch def - /cradius centerv centerv mul centerh centerh mul add sqrt def - /eradius endv endv mul endh endh mul add sqrt def - /endang endv endh atan def - /startang centerv neg centerh neg atan def - /sweep startang endang sub dup 0 lt{360 add}if def - sweep arctoobig gt - {/midang startang sweep 2 div sub def /midrad cradius eradius add 2 div def - /midh midang cos midrad mul def /midv midang sin midrad mul def - midh neg midv neg endh endv centerh centerv midh midv Da - Da} - {sweep arctoosmall ge - {/controldelt 1 sweep 2 div cos sub 3 sweep 2 div sin mul div 4 mul def - centerv neg controldelt mul centerh controldelt mul - endv neg controldelt mul centerh add endh add - endh controldelt mul centerv add endv add - centerh endh add centerv endv add rcurveto Dstroke} - {centerh endh add centerv endv add rlineto Dstroke} - ifelse} - ifelse}def -/Dpatterns[ -[%cf[widthbits] -[8<0000000000000010>] -[8<0411040040114000>] -[8<0204081020408001>] -[8<0000103810000000>] -[8<6699996666999966>] -[8<0000800100001008>] -[8<81c36666c3810000>] -[8<0f0e0c0800000000>] -[8<0000000000000010>] -[8<0411040040114000>] -[8<0204081020408001>] -[8<0000001038100000>] -[8<6699996666999966>] -[8<0000800100001008>] -[8<81c36666c3810000>] -[8<0f0e0c0800000000>] -[8<0042660000246600>] -[8<0000990000990000>] -[8<0804020180402010>] -[8<2418814242811824>] -[8<6699996666999966>] -[8<8000000008000000>] -[8<00001c3e363e1c00>] -[8<0000000000000000>] -[32<00000040000000c00000004000000040000000e0000000000000000000000000>] -[32<00000000000060000000900000002000000040000000f0000000000000000000>] -[32<000000000000000000e0000000100000006000000010000000e0000000000000>] -[32<00000000000000002000000060000000a0000000f00000002000000000000000>] -[32<0000000e0000000000000000000000000000000f000000080000000e00000001>] -[32<0000090000000600000000000000000000000000000007000000080000000e00>] -[32<00010000000200000004000000040000000000000000000000000000000f0000>] -[32<0900000006000000090000000600000000000000000000000000000006000000>]] -[%ug -[8<0000020000000000>] -[8<0000020000002000>] -[8<0004020000002000>] -[8<0004020000402000>] -[8<0004060000402000>] -[8<0004060000406000>] -[8<0006060000406000>] -[8<0006060000606000>] -[8<00060e0000606000>] -[8<00060e000060e000>] -[8<00070e000060e000>] -[8<00070e000070e000>] -[8<00070e020070e000>] -[8<00070e020070e020>] -[8<04070e020070e020>] -[8<04070e024070e020>] -[8<04070e064070e020>] -[8<04070e064070e060>] -[8<06070e064070e060>] -[8<06070e066070e060>] -[8<06070f066070e060>] -[8<06070f066070f060>] -[8<060f0f066070f060>] -[8<060f0f0660f0f060>] -[8<060f0f0760f0f060>] -[8<060f0f0760f0f070>] -[8<0e0f0f0760f0f070>] -[8<0e0f0f07e0f0f070>] -[8<0e0f0f0fe0f0f070>] -[8<0e0f0f0fe0f0f0f0>] -[8<0f0f0f0fe0f0f0f0>] -[8<0f0f0f0ff0f0f0f0>] -[8<1f0f0f0ff0f0f0f0>] -[8<1f0f0f0ff1f0f0f0>] -[8<1f0f0f8ff1f0f0f0>] -[8<1f0f0f8ff1f0f0f8>] -[8<9f0f0f8ff1f0f0f8>] -[8<9f0f0f8ff9f0f0f8>] -[8<9f0f0f9ff9f0f0f8>] -[8<9f0f0f9ff9f0f0f9>] -[8<9f8f0f9ff9f0f0f9>] -[8<9f8f0f9ff9f8f0f9>] -[8<9f8f1f9ff9f8f0f9>] -[8<9f8f1f9ff9f8f1f9>] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8]] -[%mg -[8<8000000000000000>] -[8<0822080080228000>] -[8<0204081020408001>] -[8<40e0400000000000>] -[8<66999966>] -[8<8001000010080000>] -[8<81c36666c3810000>] -[8] -[16<07c00f801f003e007c00f800f001e003c007800f001f003e007c00f801f003e0>] -[16<1f000f8007c003e001f000f8007c003e001f800fc007e003f001f8007c003e00>] -[8] -[16<0040008001000200040008001000200040008000000100020004000800100020>] -[16<0040002000100008000400020001800040002000100008000400020001000080>] -[16<1fc03fe07df0f8f8f07de03fc01f800fc01fe03ff07df8f87df03fe01fc00f80>] -[8<80>] -[8<8040201000000000>] -[8<84cc000048cc0000>] -[8<9900009900000000>] -[8<08040201804020100800020180002010>] -[8<2418814242811824>] -[8<66999966>] -[8<8000000008000000>] -[8<70f8d8f870000000>] -[8<0814224180402010>] -[8] -[8<018245aa45820100>] -[8<221c224180808041>] -[8<88000000>] -[8<0855800080550800>] -[8<2844004482440044>] -[8<0810204080412214>] -[8<00>]]]def -/Dfill{ - transform /maxy exch def /maxx exch def - transform /miny exch def /minx exch def - minx maxx gt{/minx maxx /maxx minx def def}if - miny maxy gt{/miny maxy /maxy miny def def}if - Dpatterns Dstipple 1 sub get exch 1 sub get - aload pop /stip exch def /stipw exch def /stiph 128 def - /imatrix[stipw 0 0 stiph 0 0]def - /tmatrix[stipw 0 0 stiph 0 0]def - /minx minx cvi stiph idiv stiph mul def - /miny miny cvi stipw idiv stipw mul def - gsave eoclip 0 setgray - miny stiph maxy{ - tmatrix exch 5 exch put - minx stipw maxx{ - tmatrix exch 4 exch put tmatrix setmatrix - stipw stiph true imatrix {stip} imagemask - }for - }for - grestore -}def -/Dp{Dfill Dstroke}def -/DP{Dfill currentpoint newpath moveto}def -end - -/ditstart{$DITroff begin - /nfonts 60 def % NFONTS makedev/ditroff dependent! - /fonts[nfonts{0}repeat]def - /fontnames[nfonts{()}repeat]def -/docsave save def -}def - -% character outcalls -/oc{ - /pswid exch def /cc exch def /name exch def - /ditwid pswid fontsize mul resolution mul 72000 div def - /ditsiz fontsize resolution mul 72 div def - ocprocs name known{ocprocs name get exec}{name cb}ifelse -}def -/fractm [.65 0 0 .6 0 0] def -/fraction{ - /fden exch def /fnum exch def gsave /cf currentfont def - cf fractm makefont setfont 0 .3 dm 2 copy neg rmoveto - fnum show rmoveto currentfont cf setfont(\244)show setfont fden show - grestore ditwid 0 rmoveto -}def -/oce{grestore ditwid 0 rmoveto}def -/dm{ditsiz mul}def -/ocprocs 50 dict def ocprocs begin -(14){(1)(4)fraction}def -(12){(1)(2)fraction}def -(34){(3)(4)fraction}def -(13){(1)(3)fraction}def -(23){(2)(3)fraction}def -(18){(1)(8)fraction}def -(38){(3)(8)fraction}def -(58){(5)(8)fraction}def -(78){(7)(8)fraction}def -(sr){gsave 0 .06 dm rmoveto(\326)show oce}def -(is){gsave 0 .15 dm rmoveto(\362)show oce}def -(->){gsave 0 .02 dm rmoveto(\256)show oce}def -(<-){gsave 0 .02 dm rmoveto(\254)show oce}def -(==){gsave 0 .05 dm rmoveto(\272)show oce}def -(uc){gsave currentpoint 400 .009 dm mul add translate - 8 -8 scale ucseal oce}def -end - -% an attempt at a PostScript FONT to implement ditroff special chars -% this will enable us to -% cache the little buggers -% generate faster, more compact PS out of psdit -% confuse everyone (including myself)! -50 dict dup begin -/FontType 3 def -/FontName /DIThacks def -/FontMatrix [.001 0 0 .001 0 0] def -/FontBBox [-260 -260 900 900] def% a lie but ... -/Encoding 256 array def -0 1 255{Encoding exch /.notdef put}for -Encoding - dup 8#040/space put %space - dup 8#110/rc put %right ceil - dup 8#111/lt put %left top curl - dup 8#112/bv put %bold vert - dup 8#113/lk put %left mid curl - dup 8#114/lb put %left bot curl - dup 8#115/rt put %right top curl - dup 8#116/rk put %right mid curl - dup 8#117/rb put %right bot curl - dup 8#120/rf put %right floor - dup 8#121/lf put %left floor - dup 8#122/lc put %left ceil - dup 8#140/sq put %square - dup 8#141/bx put %box - dup 8#142/ci put %circle - dup 8#143/br put %box rule - dup 8#144/rn put %root extender - dup 8#145/vr put %vertical rule - dup 8#146/ob put %outline bullet - dup 8#147/bu put %bullet - dup 8#150/ru put %rule - dup 8#151/ul put %underline - pop -/DITfd 100 dict def -/BuildChar{0 begin - /cc exch def /fd exch def - /charname fd /Encoding get cc get def - /charwid fd /Metrics get charname get def - /charproc fd /CharProcs get charname get def - charwid 0 fd /FontBBox get aload pop setcachedevice - 2 setlinejoin 40 setlinewidth - newpath 0 0 moveto gsave charproc grestore - end}def -/BuildChar load 0 DITfd put -/CharProcs 50 dict def -CharProcs begin -/space{}def -/.notdef{}def -/ru{500 0 rls}def -/rn{0 840 moveto 500 0 rls}def -/vr{0 800 moveto 0 -770 rls}def -/bv{0 800 moveto 0 -1000 rls}def -/br{0 840 moveto 0 -1000 rls}def -/ul{0 -140 moveto 500 0 rls}def -/ob{200 250 rmoveto currentpoint newpath 200 0 360 arc closepath stroke}def -/bu{200 250 rmoveto currentpoint newpath 200 0 360 arc closepath fill}def -/sq{80 0 rmoveto currentpoint dround newpath moveto - 640 0 rlineto 0 640 rlineto -640 0 rlineto closepath stroke}def -/bx{80 0 rmoveto currentpoint dround newpath moveto - 640 0 rlineto 0 640 rlineto -640 0 rlineto closepath fill}def -/ci{500 360 rmoveto currentpoint newpath 333 0 360 arc - 50 setlinewidth stroke}def - -/lt{0 -200 moveto 0 550 rlineto currx 800 2cx s4 add exch s4 a4p stroke}def -/lb{0 800 moveto 0 -550 rlineto currx -200 2cx s4 add exch s4 a4p stroke}def -/rt{0 -200 moveto 0 550 rlineto currx 800 2cx s4 sub exch s4 a4p stroke}def -/rb{0 800 moveto 0 -500 rlineto currx -200 2cx s4 sub exch s4 a4p stroke}def -/lk{0 800 moveto 0 300 -300 300 s4 arcto pop pop 1000 sub - 0 300 4 2 roll s4 a4p 0 -200 lineto stroke}def -/rk{0 800 moveto 0 300 s2 300 s4 arcto pop pop 1000 sub - 0 300 4 2 roll s4 a4p 0 -200 lineto stroke}def -/lf{0 800 moveto 0 -1000 rlineto s4 0 rls}def -/rf{0 800 moveto 0 -1000 rlineto s4 neg 0 rls}def -/lc{0 -200 moveto 0 1000 rlineto s4 0 rls}def -/rc{0 -200 moveto 0 1000 rlineto s4 neg 0 rls}def -end - -/Metrics 50 dict def Metrics begin -/.notdef 0 def -/space 500 def -/ru 500 def -/br 0 def -/lt 416 def -/lb 416 def -/rt 416 def -/rb 416 def -/lk 416 def -/rk 416 def -/rc 416 def -/lc 416 def -/rf 416 def -/lf 416 def -/bv 416 def -/ob 350 def -/bu 350 def -/ci 750 def -/bx 750 def -/sq 750 def -/rn 500 def -/ul 500 def -/vr 0 def -end - -DITfd begin -/s2 500 def /s4 250 def /s3 333 def -/a4p{arcto pop pop pop pop}def -/2cx{2 copy exch}def -/rls{rlineto stroke}def -/currx{currentpoint pop}def -/dround{transform round exch round exch itransform} def -end -end -/DIThacks exch definefont pop -ditstart -(psc)xT -576 1 1 xr -1(Times-Roman)xf 1 f -2(Times-Italic)xf 2 f -3(Times-Bold)xf 3 f -4(Times-BoldItalic)xf 4 f -5(Helvetica)xf 5 f -6(Helvetica-Bold)xf 6 f -7(Courier)xf 7 f -8(Courier-Bold)xf 8 f -9(Symbol)xf 9 f -10(DIThacks)xf 10 f -10 s -1 f -xi -%%EndProlog - -%%Page: 1 1 -10 s 10 xH 0 xS 1 f -3 f -14 s -1205 1206(LIBTP:)N -1633(Portable,)X -2100(M)X -2206(odular)X -2551(Transactions)X -3202(for)X -3374(UNIX)X -1 f -11 s -3661 1162(1)N -2 f -12 s -2182 1398(Margo)N -2467(Seltzer)X -2171 1494(Michael)N -2511(Olson)X -1800 1590(University)N -2225(of)X -2324(California,)X -2773(Berkeley)X -3 f -2277 1878(Abstract)N -1 f -10 s -755 2001(Transactions)N -1198(provide)X -1475(a)X -1543(useful)X -1771(programming)X -2239(paradigm)X -2574(for)X -2700(maintaining)X -3114(logical)X -3364(consistency,)X -3790(arbitrating)X -4156(con-)X -555 2091(current)N -808(access,)X -1059(and)X -1200(managing)X -1540(recovery.)X -1886(In)X -1977(traditional)X -2330(UNIX)X -2555(systems,)X -2852(the)X -2974(only)X -3140(easy)X -3307(way)X -3465(of)X -3556(using)X -3753(transactions)X -4160(is)X -4237(to)X -555 2181(purchase)N -876(a)X -947(database)X -1258(system.)X -1554(Such)X -1748(systems)X -2035(are)X -2168(often)X -2367(slow,)X -2572(costly,)X -2817(and)X -2967(may)X -3139(not)X -3275(provide)X -3554(the)X -3686(exact)X -3890(functionality)X -555 2271(desired.)N -848(This)X -1011(paper)X -1210(presents)X -1493(the)X -1611(design,)X -1860(implementation,)X -2402(and)X -2538(performance)X -2965(of)X -3052(LIBTP,)X -3314(a)X -3370(simple,)X -3623(non-proprietary)X -4147(tran-)X -555 2361(saction)N -809(library)X -1050(using)X -1249(the)X -1373(4.4BSD)X -1654(database)X -1957(access)X -2189(routines)X -2473(\()X -3 f -2500(db)X -1 f -2588(\(3\)\).)X -2775(On)X -2899(a)X -2961(conventional)X -3401(transaction)X -3779(processing)X -4148(style)X -555 2451(benchmark,)N -959(its)X -1061(performance)X -1495(is)X -1575(approximately)X -2065(85%)X -2239(that)X -2386(of)X -2480(the)X -2604(database)X -2907(access)X -3139(routines)X -3423(without)X -3693(transaction)X -4071(protec-)X -555 2541(tion,)N -725(200%)X -938(that)X -1084(of)X -1177(using)X -3 f -1376(fsync)X -1 f -1554(\(2\))X -1674(to)X -1761(commit)X -2030(modi\256cations)X -2490(to)X -2577(disk,)X -2755(and)X -2896(125%)X -3108(that)X -3253(of)X -3345(a)X -3406(commercial)X -3810(relational)X -4138(data-)X -555 2631(base)N -718(system.)X -3 f -555 2817(1.)N -655(Introduction)X -1 f -755 2940(Transactions)N -1186(are)X -1306(used)X -1474(in)X -1557(database)X -1855(systems)X -2129(to)X -2212(enable)X -2443(concurrent)X -2807(users)X -2992(to)X -3074(apply)X -3272(multi-operation)X -3790(updates)X -4055(without)X -555 3030(violating)N -863(the)X -985(integrity)X -1280(of)X -1371(the)X -1493(database.)X -1814(They)X -2003(provide)X -2271(the)X -2392(properties)X -2736(of)X -2826(atomicity,)X -3171(consistency,)X -3588(isolation,)X -3906(and)X -4045(durabil-)X -555 3120(ity.)N -701(By)X -816(atomicity,)X -1160(we)X -1276(mean)X -1472(that)X -1614(the)X -1734(set)X -1845(of)X -1934(updates)X -2200(comprising)X -2581(a)X -2638(transaction)X -3011(must)X -3187(be)X -3284(applied)X -3541(as)X -3629(a)X -3686(single)X -3898(unit;)X -4085(that)X -4226(is,)X -555 3210(they)N -714(must)X -890(either)X -1094(all)X -1195(be)X -1292(applied)X -1549(to)X -1632(the)X -1751(database)X -2049(or)X -2137(all)X -2238(be)X -2335(absent.)X -2601(Consistency)X -3013(requires)X -3293(that)X -3434(a)X -3491(transaction)X -3864(take)X -4019(the)X -4138(data-)X -555 3300(base)N -725(from)X -908(one)X -1051(logically)X -1358(consistent)X -1704(state)X -1877(to)X -1965(another.)X -2272(The)X -2423(property)X -2721(of)X -2814(isolation)X -3115(requires)X -3400(that)X -3546(concurrent)X -3916(transactions)X -555 3390(yield)N -750(results)X -994(which)X -1225(are)X -1358(indistinguishable)X -1938(from)X -2128(the)X -2260(results)X -2503(which)X -2733(would)X -2967(be)X -3077(obtained)X -3387(by)X -3501(running)X -3784(the)X -3916(transactions)X -555 3480(sequentially.)N -1002(Finally,)X -1268(durability)X -1599(requires)X -1878(that)X -2018(once)X -2190(transactions)X -2593(have)X -2765(been)X -2937(committed,)X -3319(their)X -3486(results)X -3715(must)X -3890(be)X -3986(preserved)X -555 3570(across)N -776(system)X -1018(failures)X -1279([TPCB90].)X -755 3693(Although)N -1080(these)X -1268(properties)X -1612(are)X -1734(most)X -1912(frequently)X -2265(discussed)X -2595(in)X -2680(the)X -2801(context)X -3060(of)X -3150(databases,)X -3501(they)X -3661(are)X -3782(useful)X -4000(program-)X -555 3783(ming)N -750(paradigms)X -1114(for)X -1238(more)X -1433(general)X -1700(purpose)X -1984(applications.)X -2441(There)X -2659(are)X -2788(several)X -3046(different)X -3353(situations)X -3689(where)X -3916(transactions)X -555 3873(can)N -687(be)X -783(used)X -950(to)X -1032(replace)X -1285(current)X -1533(ad-hoc)X -1772(mechanisms.)X -755 3996(One)N -910(situation)X -1206(is)X -1280(when)X -1475(multiple)X -1762(\256les)X -1916(or)X -2004(parts)X -2181(of)X -2269(\256les)X -2422(need)X -2594(to)X -2676(be)X -2772(updated)X -3046(in)X -3128(an)X -3224(atomic)X -3462(fashion.)X -3758(For)X -3889(example,)X -4201(the)X -555 4086(traditional)N -907(UNIX)X -1131(\256le)X -1256(system)X -1501(uses)X -1661(ordering)X -1955(constraints)X -2324(to)X -2408(achieve)X -2676(recoverability)X -3144(in)X -3228(the)X -3348(face)X -3505(of)X -3594(crashes.)X -3893(When)X -4107(a)X -4165(new)X -555 4176(\256le)N -678(is)X -752(created,)X -1026(its)X -1122(inode)X -1321(is)X -1395(written)X -1642(to)X -1724(disk)X -1877(before)X -2103(the)X -2221(new)X -2375(\256le)X -2497(is)X -2570(added)X -2782(to)X -2864(the)X -2982(directory)X -3292(structure.)X -3633(This)X -3795(guarantees)X -4159(that,)X -555 4266(if)N -627(the)X -748(system)X -993(crashes)X -1253(between)X -1544(the)X -1665(two)X -1808(I/O's,)X -2016(the)X -2137(directory)X -2450(does)X -2620(not)X -2744(contain)X -3002(a)X -3060 0.4531(reference)AX -3383(to)X -3467(an)X -3565(invalid)X -3809(inode.)X -4049(In)X -4138(actu-)X -555 4356(ality,)N -741(the)X -863(desired)X -1119(effect)X -1326(is)X -1402(that)X -1545(these)X -1733(two)X -1876(updates)X -2144(have)X -2319(the)X -2440(transactional)X -2873(property)X -3168(of)X -3258(atomicity)X -3583(\(either)X -3816(both)X -3981(writes)X -4200(are)X -555 4446(visible)N -790(or)X -879(neither)X -1124(is\).)X -1266(Rather)X -1501(than)X -1660(building)X -1947(special)X -2191(purpose)X -2466(recovery)X -2769(mechanisms)X -3186(into)X -3331(the)X -3450(\256le)X -3573(system)X -3816(or)X -3904(related)X -4144(tools)X -555 4536(\()N -2 f -582(e.g.)X -3 f -726(fsck)X -1 f -864(\(8\)\),)X -1033(one)X -1177(could)X -1383(use)X -1518(general)X -1783(purpose)X -2064(transaction)X -2443(recovery)X -2752(protocols)X -3077(after)X -3252(system)X -3501(failure.)X -3778(Any)X -3943(application)X -555 4626(that)N -705(needs)X -918(to)X -1010(keep)X -1192(multiple,)X -1508(related)X -1757(\256les)X -1920(\(or)X -2044(directories\))X -2440(consistent)X -2790(should)X -3032(do)X -3141(so)X -3241(using)X -3443(transactions.)X -3895(Source)X -4147(code)X -555 4716(control)N -805(systems,)X -1101(such)X -1271(as)X -1361(RCS)X -1534(and)X -1673(SCCS,)X -1910(should)X -2146(use)X -2276(transaction)X -2651(semantics)X -2990(to)X -3075(allow)X -3276(the)X -3397(``checking)X -3764(in'')X -3903(of)X -3992(groups)X -4232(of)X -555 4806(related)N -801(\256les.)X -1001(In)X -1095(this)X -1237(way,)X -1418(if)X -1493(the)X -1617 0.2841(``check-in'')AX -2028(fails,)X -2212(the)X -2336(transaction)X -2714(may)X -2878(be)X -2980(aborted,)X -3267(backing)X -3547(out)X -3675(the)X -3799(partial)X -4030(``check-)X -555 4896(in'')N -691(leaving)X -947(the)X -1065(source)X -1295(repository)X -1640(in)X -1722(a)X -1778(consistent)X -2118(state.)X -755 5019(A)N -842(second)X -1094(situation)X -1398(where)X -1624(transactions)X -2036(can)X -2177(be)X -2282(used)X -2458(to)X -2549(replace)X -2811(current)X -3068(ad-hoc)X -3316(mechanisms)X -3741(is)X -3822(in)X -3912(applications)X -555 5109(where)N -776(concurrent)X -1144(updates)X -1413(to)X -1499(a)X -1559(shared)X -1793(\256le)X -1919(are)X -2042(desired,)X -2318(but)X -2444(there)X -2629(is)X -2706(logical)X -2948(consistency)X -3345(of)X -3435(the)X -3556(data)X -3713(which)X -3932(needs)X -4138(to)X -4223(be)X -555 5199(preserved.)N -928(For)X -1059(example,)X -1371(when)X -1565(the)X -1683(password)X -2006(\256le)X -2128(is)X -2201(updated,)X -2495(\256le)X -2617(locking)X -2877(is)X -2950(used)X -3117(to)X -3199(disallow)X -3490(concurrent)X -3854(access.)X -4120(Tran-)X -555 5289(saction)N -804(semantics)X -1142(on)X -1244(the)X -1364(password)X -1689(\256les)X -1844(would)X -2066(allow)X -2266(concurrent)X -2632(updates,)X -2919(while)X -3119(preserving)X -3479(the)X -3598(logical)X -3837(consistency)X -4232(of)X -555 5379(the)N -681(password)X -1012(database.)X -1357(Similarly,)X -1702(UNIX)X -1930(utilities)X -2196(which)X -2419(rewrite)X -2674(\256les)X -2834(face)X -2996(a)X -3059(potential)X -3366(race)X -3528(condition)X -3857(between)X -4152(their)X -555 5469(rewriting)N -871(a)X -929(\256le)X -1053(and)X -1191(another)X -1453(process)X -1715(reading)X -1977(the)X -2096(\256le.)X -2259(For)X -2391(example,)X -2704(the)X -2823(compiler)X -3129(\(more)X -3342(precisely,)X -3673(the)X -3792(assembler\))X -4161(may)X -8 s -10 f -555 5541(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)N -5 s -1 f -727 5619(1)N -8 s -763 5644(To)N -850(appear)X -1035(in)X -1101(the)X -2 f -1195(Proceedings)X -1530(of)X -1596(the)X -1690(1992)X -1834(Winter)X -2024(Usenix)X -1 f -2201(,)X -2233(San)X -2345(Francisco,)X -2625(CA,)X -2746(January)X -2960(1992.)X - -2 p -%%Page: 2 2 -8 s 8 xH 0 xS 1 f -10 s -3 f -1 f -555 630(have)N -737(to)X -829(rewrite)X -1087(a)X -1152(\256le)X -1283(to)X -1374(which)X -1599(it)X -1672(has)X -1808(write)X -2002(permission)X -2382(in)X -2473(a)X -2538(directory)X -2857(to)X -2948(which)X -3173(it)X -3246(does)X -3422(not)X -3553(have)X -3734(write)X -3928(permission.)X -555 720(While)N -779(the)X -904(``.o'')X -1099(\256le)X -1228(is)X -1308(being)X -1513(written,)X -1787(another)X -2055(utility)X -2272(such)X -2446(as)X -3 f -2540(nm)X -1 f -2651(\(1\))X -2772(or)X -3 f -2866(ar)X -1 f -2942(\(1\))X -3063(may)X -3228(read)X -3394(the)X -3519(\256le)X -3648(and)X -3791(produce)X -4077(invalid)X -555 810(results)N -790(since)X -981(the)X -1105(\256le)X -1233(has)X -1366(not)X -1494(been)X -1672(completely)X -2054(written.)X -2347(Currently,)X -2700(some)X -2895(utilities)X -3160(use)X -3293(special)X -3542(purpose)X -3821(code)X -3998(to)X -4085(handle)X -555 900(such)N -722(cases)X -912(while)X -1110(others)X -1326(ignore)X -1551(the)X -1669(problem)X -1956(and)X -2092(force)X -2278(users)X -2463(to)X -2545(live)X -2685(with)X -2847(the)X -2965(consequences.)X -755 1023(In)N -845(this)X -983(paper,)X -1205(we)X -1322(present)X -1577(a)X -1635(simple)X -1870(library)X -2106(which)X -2324(provides)X -2622(transaction)X -2996(semantics)X -3334(\(atomicity,)X -3705(consistency,)X -4121(isola-)X -555 1113(tion,)N -720(and)X -857(durability\).)X -1236(The)X -1382(4.4BSD)X -1658(database)X -1956(access)X -2182(methods)X -2473(have)X -2645(been)X -2817(modi\256ed)X -3121(to)X -3203(use)X -3330(this)X -3465(library,)X -3719(optionally)X -4063(provid-)X -555 1203(ing)N -682(shared)X -917(buffer)X -1139(management)X -1574(between)X -1867(applications,)X -2298(locking,)X -2582(and)X -2722(transaction)X -3098(semantics.)X -3478(Any)X -3640(UNIX)X -3865(program)X -4161(may)X -555 1293(transaction)N -930(protect)X -1176(its)X -1274(data)X -1430(by)X -1532(requesting)X -1888(transaction)X -2262(protection)X -2609(with)X -2773(the)X -3 f -2893(db)X -1 f -2981(\(3\))X -3097(library)X -3333(or)X -3422(by)X -3524(adding)X -3764(appropriate)X -4152(calls)X -555 1383(to)N -646(the)X -773(transaction)X -1154(manager,)X -1480(buffer)X -1706(manager,)X -2032(lock)X -2199(manager,)X -2525(and)X -2670(log)X -2801(manager.)X -3147(The)X -3301(library)X -3543(routines)X -3829(may)X -3995(be)X -4099(linked)X -555 1473(into)N -708(the)X -834(host)X -995(application)X -1379(and)X -1523(called)X -1743(by)X -1851(subroutine)X -2217(interface,)X -2547(or)X -2642(they)X -2808(may)X -2974(reside)X -3194(in)X -3284(a)X -3348(separate)X -3640(server)X -3865(process.)X -4174(The)X -555 1563(server)N -772(architecture)X -1172(provides)X -1468(for)X -1582(network)X -1865(access)X -2091(and)X -2227(better)X -2430(protection)X -2775(mechanisms.)X -3 f -555 1749(2.)N -655(Related)X -938(Work)X -1 f -755 1872(There)N -1000(has)X -1164(been)X -1373(much)X -1608(discussion)X -1998(in)X -2117(recent)X -2371(years)X -2597(about)X -2831(new)X -3021(transaction)X -3429(models)X -3716(and)X -3888(architectures)X -555 1962 0.1172([SPEC88][NODI90][CHEN91][MOHA91].)AN -2009(Much)X -2220(of)X -2310(this)X -2448(work)X -2636(focuses)X -2900(on)X -3003(new)X -3160(ways)X -3348(to)X -3433(model)X -3656(transactions)X -4062(and)X -4201(the)X -555 2052(interactions)N -953(between)X -1245(them,)X -1449(while)X -1651(the)X -1772(work)X -1960(presented)X -2291(here)X -2453(focuses)X -2717(on)X -2820(the)X -2941(implementation)X -3466(and)X -3605(performance)X -4035(of)X -4125(tradi-)X -555 2142(tional)N -757(transaction)X -1129(techniques)X -1492(\(write-ahead)X -1919(logging)X -2183(and)X -2319(two-phase)X -2669(locking\))X -2956(on)X -3056(a)X -3112(standard)X -3404(operating)X -3727(system)X -3969(\(UNIX\).)X -755 2265(Such)N -947(traditional)X -1308(operating)X -1643(systems)X -1928(are)X -2059(often)X -2256(criticized)X -2587(for)X -2713(their)X -2892(inability)X -3190(to)X -3283(perform)X -3573(transaction)X -3956(processing)X -555 2355(adequately.)N -971([STON81])X -1342(cites)X -1517(three)X -1706(main)X -1894(areas)X -2088(of)X -2183(inadequate)X -2559(support:)X -2849(buffer)X -3074(management,)X -3532(the)X -3658(\256le)X -3788(system,)X -4058(and)X -4201(the)X -555 2445(process)N -823(structure.)X -1191(These)X -1410(arguments)X -1771(are)X -1897(summarized)X -2316(in)X -2405(table)X -2587(one.)X -2769(Fortunately,)X -3184(much)X -3388(has)X -3521(changed)X -3815(since)X -4006(1981.)X -4232(In)X -555 2535(the)N -683(area)X -848(of)X -945(buffer)X -1172(management,)X -1632(most)X -1817(UNIX)X -2048(systems)X -2331(provide)X -2606(the)X -2734(ability)X -2968(to)X -3060(memory)X -3357(map)X -3525(\256les,)X -3708(thus)X -3870(obviating)X -4201(the)X -555 2625(need)N -734(for)X -855(a)X -918(copy)X -1101(between)X -1396(kernel)X -1624(and)X -1766(user)X -1926(space.)X -2171(If)X -2251(a)X -2313(database)X -2616(system)X -2864(is)X -2943(going)X -3151(to)X -3239(use)X -3372(the)X -3496(\256le)X -3624(system)X -3872(buffer)X -4095(cache,)X -555 2715(then)N -719(a)X -781(system)X -1029(call)X -1171(is)X -1250(required.)X -1584(However,)X -1924(if)X -1998(buffering)X -2322(is)X -2400(provided)X -2710(at)X -2793(user)X -2952(level)X -3133(using)X -3331(shared)X -3566(memory,)X -3878(as)X -3970(in)X -4057(LIBTP,)X -555 2805(buffer)N -776(management)X -1210(is)X -1287(only)X -1452(as)X -1542(slow)X -1716(as)X -1806(access)X -2035(to)X -2120(shared)X -2353(memory)X -2643(and)X -2782(any)X -2921(replacement)X -3337(algorithm)X -3671(may)X -3832(be)X -3931(used.)X -4121(Since)X -555 2895(multiple)N -849(processes)X -1185(can)X -1325(access)X -1559(the)X -1685(shared)X -1923(data,)X -2105(prefetching)X -2499(may)X -2665(be)X -2769(accomplished)X -3238(by)X -3346(separate)X -3638(processes)X -3973(or)X -4067(threads)X -555 2985(whose)N -782(sole)X -932(purpose)X -1207(is)X -1281(to)X -1364(prefetch)X -1649(pages)X -1853(and)X -1990(wait)X -2149(on)X -2250(them.)X -2471(There)X -2680(is)X -2754(still)X -2894(no)X -2995(way)X -3150(to)X -3233(enforce)X -3496(write)X -3682(ordering)X -3975(other)X -4161(than)X -555 3075(keeping)N -829(pages)X -1032(in)X -1114(user)X -1268(memory)X -1555(and)X -1691(using)X -1884(the)X -3 f -2002(fsync)X -1 f -2180(\(3\))X -2294(system)X -2536(call)X -2672(to)X -2754(perform)X -3033(synchronous)X -3458(writes.)X -755 3198(In)N -845(the)X -966(area)X -1124(of)X -1214(\256le)X -1339(systems,)X -1635(the)X -1756(fast)X -1895(\256le)X -2020(system)X -2265(\(FFS\))X -2474([MCKU84])X -2871(allows)X -3103(allocation)X -3442(in)X -3527(units)X -3704(up)X -3806(to)X -3890(64KBytes)X -4232(as)X -555 3288(opposed)N -846(to)X -932(the)X -1054(4KByte)X -1327(and)X -1466(8KByte)X -1738(\256gures)X -1979(quoted)X -2220(in)X -2305([STON81].)X -2711(The)X -2859(measurements)X -3341(in)X -3426(this)X -3564(paper)X -3766(were)X -3946(taken)X -4143(from)X -555 3378(an)N -655(8KByte)X -928(FFS,)X -1104(but)X -1230(as)X -1320(LIBTP)X -1565(runs)X -1726(exclusively)X -2114(in)X -2199(user)X -2356(space,)X -2578(there)X -2762(is)X -2838(nothing)X -3105(to)X -3190(prevent)X -3454(it)X -3521(from)X -3700(being)X -3901(run)X -4031(on)X -4134(other)X -555 3468(UNIX)N -776(compatible)X -1152(\256le)X -1274(systems)X -1547(\(e.g.)X -1710(log-structured)X -2180([ROSE91],)X -2558(extent-based,)X -3004(or)X -3091(multi-block)X -3484([SELT91]\).)X -755 3591(Finally,)N -1029(with)X -1199(regard)X -1433(to)X -1523(the)X -1648(process)X -1916(structure,)X -2244(neither)X -2494(context)X -2757(switch)X -2993(time)X -3162(nor)X -3296(scheduling)X -3670(around)X -3920(semaphores)X -555 3681(seems)N -785(to)X -881(affect)X -1099(the)X -1231(system)X -1487(performance.)X -1968(However,)X -2317(the)X -2449(implementation)X -2984(of)X -3084(semaphores)X -3496(can)X -3641(impact)X -3892(performance)X -555 3771(tremendously.)N -1051(This)X -1213(is)X -1286(discussed)X -1613(in)X -1695(more)X -1880(detail)X -2078(in)X -2160(section)X -2407(4.3.)X -755 3894(The)N -908(Tuxedo)X -1181(system)X -1431(from)X -1615(AT&T)X -1861(is)X -1941(a)X -2004(transaction)X -2383(manager)X -2687(which)X -2910(coordinates)X -3307(distributed)X -3676(transaction)X -4055(commit)X -555 3984(from)N -738(a)X -801(variety)X -1051(of)X -1145(different)X -1449(local)X -1632(transaction)X -2011(managers.)X -2386(At)X -2493(this)X -2634(time,)X -2822(LIBTP)X -3070(does)X -3243(not)X -3371(have)X -3549(its)X -3650(own)X -3814(mechanism)X -4205(for)X -555 4074(distributed)N -942(commit)X -1231(processing,)X -1639(but)X -1786(could)X -2009(be)X -2130(used)X -2322(as)X -2434(a)X -2515(local)X -2716(transaction)X -3113(agent)X -3331(by)X -3455(systems)X -3752(such)X -3943(as)X -4054(Tuxedo)X -555 4164([ANDR89].)N -10 f -863 4393(i)N -870(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -903 4483(Buffer)N -1133(Management)X -10 f -1672(g)X -1 f -1720(Data)X -1892(must)X -2067(be)X -2163(copied)X -2397(between)X -2685(kernel)X -2906(space)X -3105(and)X -3241(user)X -3395(space.)X -10 f -1672 4573(g)N -1 f -1720(Buffer)X -1950(pool)X -2112(access)X -2338(is)X -2411(too)X -2533(slow.)X -10 f -1672 4663(g)N -1 f -1720(There)X -1928(is)X -2001(no)X -2101(way)X -2255(to)X -2337(request)X -2589(prefetch.)X -10 f -1672 4753(g)N -1 f -1720(Replacement)X -2159(is)X -2232(usually)X -2483(LRU)X -2663(which)X -2879(may)X -3037(be)X -3133(suboptimal)X -3508(for)X -3622(databases.)X -10 f -1672 4843(g)N -1 f -1720(There)X -1928(is)X -2001(no)X -2101(way)X -2255(to)X -2337(guarantee)X -2670(write)X -2855(ordering.)X -10 f -863 4853(i)N -870(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -903 4943(File)N -1047(System)X -10 f -1672(g)X -1 f -1720(Allocation)X -2078(is)X -2151(done)X -2327(in)X -2409(small)X -2602(blocks)X -2831(\(usually)X -3109(4K)X -3227(or)X -3314(8K\).)X -10 f -1672 5033(g)N -1 f -1720(Logical)X -1985(organization)X -2406(of)X -2493(\256les)X -2646(is)X -2719(redundantly)X -3122(expressed.)X -10 f -863 5043(i)N -870(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -903 5133(Process)N -1168(Structure)X -10 f -1672(g)X -1 f -1720(Context)X -1993(switching)X -2324(and)X -2460(message)X -2752(passing)X -3012(are)X -3131(too)X -3253(slow.)X -10 f -1672 5223(g)N -1 f -1720(A)X -1798(process)X -2059(may)X -2217(be)X -2313(descheduled)X -2730(while)X -2928(holding)X -3192(a)X -3248(semaphore.)X -10 f -863 5233(i)N -870(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -863(c)X -5193(c)Y -5113(c)Y -5033(c)Y -4953(c)Y -4873(c)Y -4793(c)Y -4713(c)Y -4633(c)Y -4553(c)Y -4473(c)Y -3990 5233(c)N -5193(c)Y -5113(c)Y -5033(c)Y -4953(c)Y -4873(c)Y -4793(c)Y -4713(c)Y -4633(c)Y -4553(c)Y -4473(c)Y -3 f -1156 5446(Table)N -1371(One:)X -1560(Shortcomings)X -2051(of)X -2138(UNIX)X -2363(transaction)X -2770(support)X -3056(cited)X -3241(in)X -3327([STON81].)X - -3 p -%%Page: 3 3 -10 s 10 xH 0 xS 3 f -1 f -755 630(The)N -901(transaction)X -1274(architecture)X -1675(presented)X -2004(in)X -2087([YOUN91])X -2474(is)X -2548(very)X -2712(similar)X -2955(to)X -3038(that)X -3179(implemented)X -3618(in)X -3701(the)X -3820(LIBTP.)X -4103(While)X -555 720([YOUN91])N -947(presents)X -1236(a)X -1298(model)X -1524(for)X -1644(providing)X -1981(transaction)X -2359(services,)X -2663(this)X -2803(paper)X -3007(focuses)X -3273(on)X -3378(the)X -3501(implementation)X -4028(and)X -4169(per-)X -555 810(formance)N -881(of)X -970(a)X -1028(particular)X -1358(system.)X -1642(In)X -1731(addition,)X -2034(we)X -2149(provide)X -2415(detailed)X -2690(comparisons)X -3116(with)X -3279(alternative)X -3639(solutions:)X -3970(traditional)X -555 900(UNIX)N -776(services)X -1055(and)X -1191(commercial)X -1590(database)X -1887(management)X -2317(systems.)X -3 f -555 1086(3.)N -655(Architecture)X -1 f -755 1209(The)N -906(library)X -1146(is)X -1224(designed)X -1534(to)X -1621(provide)X -1891(well)X -2054(de\256ned)X -2315(interfaces)X -2653(to)X -2740(the)X -2863(services)X -3147(required)X -3440(for)X -3559(transaction)X -3936(processing.)X -555 1299(These)N -777(services)X -1066(are)X -1195(recovery,)X -1527(concurrency)X -1955(control,)X -2232(and)X -2378(the)X -2506(management)X -2946(of)X -3043(shared)X -3283(data.)X -3487(First)X -3663(we)X -3787(will)X -3941(discuss)X -4201(the)X -555 1389(design)N -795(tradeoffs)X -1112(in)X -1205(the)X -1334(selection)X -1650(of)X -1748(recovery,)X -2081(concurrency)X -2510(control,)X -2787(and)X -2933(buffer)X -3160(management)X -3600(implementations,)X -4183(and)X -555 1479(then)N -713(we)X -827(will)X -971(present)X -1223(the)X -1341(overall)X -1584(library)X -1818(architecture)X -2218(and)X -2354(module)X -2614(descriptions.)X -3 f -555 1665(3.1.)N -715(Design)X -966(Tradeoffs)X -1 f -3 f -555 1851(3.1.1.)N -775(Crash)X -1004(Recovery)X -1 f -755 1974(The)N -909(recovery)X -1220(protocol)X -1516(is)X -1598(responsible)X -1992(for)X -2115(providing)X -2455(the)X -2582(transaction)X -2963(semantics)X -3308(discussed)X -3644(earlier.)X -3919(There)X -4136(are)X -4263(a)X -555 2064(wide)N -739(range)X -946(of)X -1041(recovery)X -1351(protocols)X -1677(available)X -1995([HAER83],)X -2395(but)X -2525(we)X -2647(can)X -2786(crudely)X -3054(divide)X -3281(them)X -3468(into)X -3619(two)X -3766(main)X -3953(categories.)X -555 2154(The)N -706(\256rst)X -856(category)X -1159(records)X -1422(all)X -1528(modi\256cations)X -1989(to)X -2077(the)X -2201(database)X -2504(in)X -2592(a)X -2653(separate)X -2942(\256le,)X -3089(and)X -3230(uses)X -3393(this)X -3533(\256le)X -3660(\(log\))X -3841(to)X -3928(back)X -4105(out)X -4232(or)X -555 2244(reapply)N -825(these)X -1019(modi\256cations)X -1483(if)X -1561(a)X -1626(transaction)X -2007(aborts)X -2232(or)X -2328(the)X -2455(system)X -2706(crashes.)X -3012(We)X -3153(call)X -3298(this)X -3442(set)X -3560(the)X -3 f -3687(logging)X -3963(protocols)X -1 f -4279(.)X -555 2334(The)N -703(second)X -949(category)X -1249(avoids)X -1481(the)X -1602(use)X -1732(of)X -1822(a)X -1881(log)X -2006(by)X -2109(carefully)X -2418(controlling)X -2792(when)X -2989(data)X -3146(are)X -3268(written)X -3518(to)X -3603(disk.)X -3799(We)X -3934(call)X -4073(this)X -4210(set)X -555 2424(the)N -3 f -673(non-logging)X -1096(protocols)X -1 f -1412(.)X -755 2547(Non-logging)N -1185(protocols)X -1504(hold)X -1666(dirty)X -1837(buffers)X -2085(in)X -2167(main)X -2347(memory)X -2634(or)X -2721(temporary)X -3071(\256les)X -3224(until)X -3390(commit)X -3654(and)X -3790(then)X -3948(force)X -4134(these)X -555 2637(pages)N -769(to)X -862(disk)X -1026(at)X -1115(transaction)X -1498(commit.)X -1813(While)X -2040(we)X -2165(can)X -2308(use)X -2446(temporary)X -2807(\256les)X -2971(to)X -3064(hold)X -3237(dirty)X -3418(pages)X -3631(that)X -3781(may)X -3949(need)X -4131(to)X -4223(be)X -555 2727(evicted)N -810(from)X -988(memory)X -1277(during)X -1508(a)X -1566(long-running)X -2006(transaction,)X -2400(the)X -2520(only)X -2684(user-level)X -3023(mechanism)X -3410(to)X -3494(force)X -3682(pages)X -3887(to)X -3971(disk)X -4126(is)X -4201(the)X -3 f -555 2817(fsync)N -1 f -733(\(2\))X -850(system)X -1095(call.)X -1274(Unfortunately,)X -3 f -1767(fsync)X -1 f -1945(\(2\))X -2062(is)X -2138(an)X -2237(expensive)X -2581(system)X -2826(call)X -2965(in)X -3050(that)X -3193(it)X -3260(forces)X -3480(all)X -3583(pages)X -3789(of)X -3879(a)X -3938(\256le)X -4062(to)X -4146(disk,)X -555 2907(and)N -691(transactions)X -1094(that)X -1234(manage)X -1504(more)X -1689(than)X -1847(one)X -1983(\256le)X -2105(must)X -2280(issue)X -2460(one)X -2596(call)X -2732(per)X -2855(\256le.)X -755 3030(In)N -853(addition,)X -3 f -1166(fsync)X -1 f -1344(\(2\))X -1469(provides)X -1776(no)X -1887(way)X -2051(to)X -2143(control)X -2400(the)X -2528(order)X -2728(in)X -2820(which)X -3046(dirty)X -3227(pages)X -3440(are)X -3569(written)X -3826(to)X -3918(disk.)X -4121(Since)X -555 3120(non-logging)N -976(protocols)X -1304(must)X -1489(sometimes)X -1861(order)X -2061(writes)X -2287(carefully)X -2603([SULL92],)X -2987(they)X -3155(are)X -3284(dif\256cult)X -3567(to)X -3659(implement)X -4030(on)X -4139(Unix)X -555 3210(systems.)N -868(As)X -977(a)X -1033(result,)X -1251(we)X -1365(have)X -1537(chosen)X -1780(to)X -1862(implement)X -2224(a)X -2280(logging)X -2544(protocol.)X -755 3333(Logging)N -1050(protocols)X -1372(may)X -1534(be)X -1634(categorized)X -2029(based)X -2236(on)X -2340(how)X -2502(information)X -2904(is)X -2981(logged)X -3223(\(physically)X -3602(or)X -3692(logically\))X -4022(and)X -4161(how)X -555 3423(much)N -767(is)X -854(logged)X -1106(\(before)X -1373(images,)X -1654(after)X -1836(images)X -2097(or)X -2198(both\).)X -2441(In)X -3 f -2542(physical)X -2855(logging)X -1 f -3103(,)X -3157(images)X -3417(of)X -3517(complete)X -3844(physical)X -4144(units)X -555 3513(\(pages)N -786(or)X -874(buffers\))X -1150(are)X -1270(recorded,)X -1593(while)X -1792(in)X -3 f -1875(logical)X -2118(logging)X -1 f -2387(a)X -2444(description)X -2820(of)X -2907(the)X -3025(operation)X -3348(is)X -3421(recorded.)X -3763(Therefore,)X -4121(while)X -555 3603(we)N -675(may)X -839(record)X -1071(entire)X -1280(pages)X -1489(in)X -1577(a)X -1639(physical)X -1932(log,)X -2080(we)X -2200(need)X -2378(only)X -2546(record)X -2777(the)X -2900(records)X -3162(being)X -3365(modi\256ed)X -3674(in)X -3761(a)X -3822(logical)X -4065(log.)X -4232(In)X -555 3693(fact,)N -718(physical)X -1006(logging)X -1271(can)X -1404(be)X -1501(thought)X -1766(of)X -1854(as)X -1942(a)X -1999(special)X -2243(case)X -2403(of)X -2491(logical)X -2730(logging,)X -3015(since)X -3201(the)X -3320 0.3125(``records'')AX -3686(that)X -3827(we)X -3942(log)X -4065(in)X -4148(logi-)X -555 3783(cal)N -673(logging)X -941(might)X -1151(be)X -1251(physical)X -1542(pages.)X -1789(Since)X -1991(logical)X -2233(logging)X -2501(is)X -2578(both)X -2743(more)X -2931(space-ef\256cient)X -3423(and)X -3562(more)X -3750(general,)X -4030(we)X -4147(have)X -555 3873(chosen)N -798(it)X -862(for)X -976(our)X -1103(logging)X -1367(protocol.)X -755 3996(In)N -3 f -843(before-image)X -1315(logging)X -1 f -1563(,)X -1604(we)X -1719(log)X -1842(a)X -1899(copy)X -2076(of)X -2164(the)X -2283(data)X -2438(before)X -2665(the)X -2784(update,)X -3039(while)X -3238(in)X -3 f -3321(after-image)X -3739(logging)X -1 f -3987(,)X -4027(we)X -4141(log)X -4263(a)X -555 4086(copy)N -740(of)X -836(the)X -963(data)X -1126(after)X -1303(the)X -1429(update.)X -1711(If)X -1793(we)X -1915(log)X -2045(only)X -2215(before-images,)X -2723(then)X -2889(there)X -3078(is)X -3159(suf\256cient)X -3485(information)X -3891(in)X -3981(the)X -4107(log)X -4237(to)X -555 4176(allow)N -761(us)X -860(to)X -3 f -950(undo)X -1 f -1150(the)X -1276(transaction)X -1656(\(go)X -1791(back)X -1971(to)X -2061(the)X -2187(state)X -2361(represented)X -2759(by)X -2866(the)X -2991(before-image\).)X -3514(However,)X -3876(if)X -3952(the)X -4077(system)X -555 4266(crashes)N -814(and)X -952(a)X -1010(committed)X -1374(transaction's)X -1806(changes)X -2087(have)X -2261(not)X -2385(reached)X -2658(the)X -2778(disk,)X -2953(we)X -3068(have)X -3241(no)X -3342(means)X -3568(to)X -3 f -3651(redo)X -1 f -3828(the)X -3947(transaction)X -555 4356(\(reapply)N -849(the)X -973(updates\).)X -1311(Therefore,)X -1675(logging)X -1945(only)X -2113(before-images)X -2599(necessitates)X -3004(forcing)X -3262(dirty)X -3439(pages)X -3648(at)X -3732(commit)X -4002(time.)X -4210(As)X -555 4446(mentioned)N -913(above,)X -1145(forcing)X -1397(pages)X -1600(at)X -1678(commit)X -1942(is)X -2015(considered)X -2383(too)X -2505(costly.)X -755 4569(If)N -834(we)X -953(log)X -1080(only)X -1247(after-images,)X -1694(then)X -1857(there)X -2043(is)X -2121(suf\256cient)X -2444(information)X -2847(in)X -2934(the)X -3057(log)X -3184(to)X -3271(allow)X -3474(us)X -3570(to)X -3657(redo)X -3825(the)X -3947(transaction)X -555 4659(\(go)N -687(forward)X -967(to)X -1054(the)X -1177(state)X -1348(represented)X -1743(by)X -1847(the)X -1969(after-image\),)X -2411(but)X -2537(we)X -2655(do)X -2759(not)X -2885(have)X -3061(the)X -3183(information)X -3585(required)X -3877(to)X -3963(undo)X -4147(tran-)X -555 4749(sactions)N -845(which)X -1073(aborted)X -1346(after)X -1526(dirty)X -1709(pages)X -1924(were)X -2113(written)X -2372(to)X -2466(disk.)X -2670(Therefore,)X -3039(logging)X -3314(only)X -3487(after-images)X -3920(necessitates)X -555 4839(holding)N -819(all)X -919(dirty)X -1090(buffers)X -1338(in)X -1420(main)X -1600(memory)X -1887(until)X -2053(commit)X -2317(or)X -2404(writing)X -2655(them)X -2835(to)X -2917(a)X -2973(temporary)X -3323(\256le.)X -755 4962(Since)N -956(neither)X -1202(constraint)X -1541(\(forcing)X -1823(pages)X -2029(on)X -2132(commit)X -2399(or)X -2489(buffering)X -2811(pages)X -3016(until)X -3184(commit\))X -3477(was)X -3624(feasible,)X -3916(we)X -4032(chose)X -4237(to)X -555 5052(log)N -683(both)X -851(before)X -1083(and)X -1225(after)X -1399(images.)X -1672(The)X -1823(only)X -1991(remaining)X -2342(consideration)X -2800(is)X -2879(when)X -3079(changes)X -3363(get)X -3486(written)X -3738(to)X -3825(disk.)X -4023(Changes)X -555 5142(affect)N -764(both)X -931(data)X -1090(pages)X -1298(and)X -1438(the)X -1560(log.)X -1726(If)X -1804(the)X -1926(changed)X -2218(data)X -2376(page)X -2552(is)X -2629(written)X -2880(before)X -3110(the)X -3232(log)X -3358(page,)X -3554(and)X -3694(the)X -3816(system)X -4062(crashes)X -555 5232(before)N -787(the)X -911(log)X -1039(page)X -1217(is)X -1296(written,)X -1569(the)X -1693(log)X -1820(will)X -1969(contain)X -2230(insuf\256cient)X -2615(information)X -3018(to)X -3105(undo)X -3290(the)X -3413(change.)X -3706(This)X -3873(violates)X -4147(tran-)X -555 5322(saction)N -803(semantics,)X -1160(since)X -1346(some)X -1536(changed)X -1825(data)X -1980(pages)X -2184(may)X -2343(not)X -2466(have)X -2638(been)X -2810(written,)X -3077(and)X -3213(the)X -3331(database)X -3628(cannot)X -3862(be)X -3958(restored)X -4237(to)X -555 5412(its)N -650(pre-transaction)X -1152(state.)X -755 5535(The)N -914(log)X -1050(record)X -1290(describing)X -1658(an)X -1768(update)X -2016(must)X -2205(be)X -2315(written)X -2576(to)X -2672(stable)X -2893(storage)X -3159(before)X -3398(the)X -3529(modi\256ed)X -3846(page.)X -4071(This)X -4246(is)X -3 f -555 5625(write-ahead)N -992(logging)X -1 f -1240(.)X -1307(If)X -1388(log)X -1517(records)X -1781(are)X -1907(safely)X -2126(written)X -2380(to)X -2469(disk,)X -2649(data)X -2810(pages)X -3020(may)X -3185(be)X -3288(written)X -3542(at)X -3627(any)X -3770(time)X -3939(afterwards.)X -555 5715(This)N -721(means)X -950(that)X -1094(the)X -1216(only)X -1382(\256le)X -1508(that)X -1652(ever)X -1815(needs)X -2022(to)X -2108(be)X -2208(forced)X -2438(to)X -2524(disk)X -2681(is)X -2758(the)X -2880(log.)X -3046(Since)X -3248(the)X -3370(log)X -3495(is)X -3571(append-only,)X -4015(modi\256ed)X - -4 p -%%Page: 4 4 -10 s 10 xH 0 xS 1 f -3 f -1 f -555 630(pages)N -760(always)X -1005(appear)X -1242(at)X -1322(the)X -1442(end)X -1580(and)X -1718(may)X -1878(be)X -1976(written)X -2224(to)X -2307(disk)X -2461(ef\256ciently)X -2807(in)X -2890(any)X -3027(\256le)X -3150(system)X -3393(that)X -3534(favors)X -3756(sequential)X -4102(order-)X -555 720(ing)N -677(\()X -2 f -704(e.g.)X -1 f -820(,)X -860(FFS,)X -1032(log-structured)X -1502(\256le)X -1624(system,)X -1886(or)X -1973(an)X -2069(extent-based)X -2495(system\).)X -3 f -555 906(3.1.2.)N -775(Concurrency)X -1245(Control)X -1 f -755 1029(The)N -918(concurrency)X -1354(control)X -1619(protocol)X -1923(is)X -2013(responsible)X -2415(for)X -2546(maintaining)X -2965(consistency)X -3376(in)X -3475(the)X -3610(presence)X -3929(of)X -4033(multiple)X -555 1119(accesses.)N -897(There)X -1114(are)X -1242(several)X -1499(alternative)X -1867(solutions)X -2183(such)X -2358(as)X -2453(locking,)X -2741(optimistic)X -3088(concurrency)X -3514(control)X -3769([KUNG81],)X -4183(and)X -555 1209(timestamp)N -912(ordering)X -1208([BERN80].)X -1619(Since)X -1821(optimistic)X -2164(methods)X -2459(and)X -2599(timestamp)X -2956(ordering)X -3252(are)X -3374(generally)X -3696(more)X -3884(complex)X -4183(and)X -555 1299(restrict)N -804(concurrency)X -1228(without)X -1498(eliminating)X -1888(starvation)X -2230(or)X -2323(deadlocks,)X -2690(we)X -2810(chose)X -3018(two-phase)X -3373(locking)X -3638(\(2PL\).)X -3890(Strict)X -4088(2PL)X -4246(is)X -555 1389(suboptimal)N -935(for)X -1054(certain)X -1297(data)X -1455(structures)X -1791(such)X -1962(as)X -2053(B-trees)X -2309(because)X -2588(it)X -2656(can)X -2792(limit)X -2966(concurrency,)X -3408(so)X -3503(we)X -3621(use)X -3752(a)X -3812(special)X -4059(locking)X -555 1479(protocol)N -842(based)X -1045(on)X -1145(one)X -1281(described)X -1609(in)X -1691([LEHM81].)X -755 1602(The)N -901(B-tree)X -1123(locking)X -1384(protocol)X -1672(we)X -1787(implemented)X -2226(releases)X -2502(locks)X -2691(at)X -2769(internal)X -3034(nodes)X -3241(in)X -3323(the)X -3441(tree)X -3582(as)X -3669(it)X -3733(descends.)X -4083(A)X -4161(lock)X -555 1692(on)N -658(an)X -757(internal)X -1025(page)X -1200(is)X -1276(always)X -1522(released)X -1808(before)X -2036(a)X -2094(lock)X -2254(on)X -2356(its)X -2453(child)X -2635(is)X -2710(obtained)X -3008(\(that)X -3177(is,)X -3272(locks)X -3463(are)X -3584(not)X -3 f -3708(coupled)X -1 f -3996([BAY77])X -555 1782(during)N -786(descent\).)X -1116(When)X -1330(a)X -1388(leaf)X -1531(\(or)X -1647(internal\))X -1941(page)X -2115(is)X -2190(split,)X -2369(a)X -2427(write)X -2614(lock)X -2774(is)X -2849(acquired)X -3148(on)X -3250(the)X -3370(parent)X -3593(before)X -3821(the)X -3941(lock)X -4100(on)X -4201(the)X -555 1872(just-split)N -855(page)X -1028(is)X -1102(released)X -1387(\(locks)X -1604(are)X -3 f -1724(coupled)X -1 f -2011(during)X -2241(ascent\).)X -2530(Write)X -2734(locks)X -2924(on)X -3025(internal)X -3291(pages)X -3495(are)X -3615(released)X -3899(immediately)X -555 1962(after)N -723(the)X -841(page)X -1013(is)X -1086(updated,)X -1380(but)X -1502(locks)X -1691(on)X -1791(leaf)X -1932(pages)X -2135(are)X -2254(held)X -2412(until)X -2578(the)X -2696(end)X -2832(of)X -2919(the)X -3037(transaction.)X -755 2085(Since)N -964(locks)X -1164(are)X -1294(released)X -1589(during)X -1828(descent,)X -2119(the)X -2247(structure)X -2558(of)X -2655(the)X -2783(tree)X -2934(may)X -3102(change)X -3360(above)X -3582(a)X -3648(node)X -3834(being)X -4042(used)X -4219(by)X -555 2175(some)N -752(process.)X -1061(If)X -1143(that)X -1291(process)X -1560(must)X -1743(later)X -1914(ascend)X -2161(the)X -2287(tree)X -2435(because)X -2717(of)X -2811(a)X -2874(page)X -3053(split,)X -3237(any)X -3380(such)X -3554(change)X -3809(must)X -3991(not)X -4120(cause)X -555 2265(confusion.)N -938(We)X -1077(use)X -1211(the)X -1336(technique)X -1675(described)X -2010(in)X -2099([LEHM81])X -2487(which)X -2710(exploits)X -2989(the)X -3113(ordering)X -3411(of)X -3504(data)X -3664(on)X -3770(a)X -3832(B-tree)X -4059(page)X -4237(to)X -555 2355(guarantee)N -888(that)X -1028(no)X -1128(process)X -1389(ever)X -1548(gets)X -1697(lost)X -1832(as)X -1919(a)X -1975(result)X -2173(of)X -2260(internal)X -2525(page)X -2697(updates)X -2962(made)X -3156(by)X -3256(other)X -3441(processes.)X -755 2478(If)N -836(a)X -899(transaction)X -1278(that)X -1425(updates)X -1697(a)X -1760(B-tree)X -1988(aborts,)X -2231(the)X -2356(user-visible)X -2757(changes)X -3043(to)X -3131(the)X -3255(tree)X -3402(must)X -3583(be)X -3685(rolled)X -3898(back.)X -4116(How-)X -555 2568(ever,)N -735(changes)X -1015(to)X -1097(the)X -1215(internal)X -1480(nodes)X -1687(of)X -1774(the)X -1892(tree)X -2033(need)X -2205(not)X -2327(be)X -2423(rolled)X -2630(back,)X -2822(since)X -3007(these)X -3192(pages)X -3395(contain)X -3651(no)X -3751(user-visible)X -4145(data.)X -555 2658(When)N -771(rolling)X -1008(back)X -1184(a)X -1244(transaction,)X -1640(we)X -1758(roll)X -1893(back)X -2069(all)X -2173(leaf)X -2318(page)X -2494(updates,)X -2783(but)X -2909(no)X -3013(internal)X -3281(insertions)X -3615(or)X -3705(page)X -3880(splits.)X -4111(In)X -4201(the)X -555 2748(worst)N -759(case,)X -944(this)X -1085(will)X -1235(leave)X -1431(a)X -1493(leaf)X -1640(page)X -1818(less)X -1964(than)X -2128(half)X -2279(full.)X -2456(This)X -2624(may)X -2788(cause)X -2993(poor)X -3166(space)X -3371(utilization,)X -3741(but)X -3869(does)X -4042(not)X -4170(lose)X -555 2838(user)N -709(data.)X -755 2961(Holding)N -1038(locks)X -1228(on)X -1329(leaf)X -1471(pages)X -1675(until)X -1842(transaction)X -2215(commit)X -2480(guarantees)X -2845(that)X -2986(no)X -3087(other)X -3273(process)X -3535(can)X -3668(insert)X -3866(or)X -3953(delete)X -4165(data)X -555 3051(that)N -711(has)X -854(been)X -1042(touched)X -1332(by)X -1448(this)X -1598(process.)X -1914(Rolling)X -2188(back)X -2375(insertions)X -2721(and)X -2872(deletions)X -3196(on)X -3311(leaf)X -3467(pages)X -3685(guarantees)X -4064(that)X -4219(no)X -555 3141(aborted)N -819(updates)X -1087(are)X -1209(ever)X -1371(visible)X -1607(to)X -1692(other)X -1880(transactions.)X -2326(Leaving)X -2612(page)X -2787(splits)X -2978(intact)X -3179(permits)X -3442(us)X -3536(to)X -3621(release)X -3867(internal)X -4134(write)X -555 3231(locks)N -744(early.)X -965(Thus)X -1145(transaction)X -1517(semantics)X -1853(are)X -1972(preserved,)X -2325(and)X -2461(locks)X -2650(are)X -2769(held)X -2927(for)X -3041(shorter)X -3284(periods.)X -755 3354(The)N -901(extra)X -1083(complexity)X -1464(introduced)X -1828(by)X -1929(this)X -2065(locking)X -2326(protocol)X -2614(appears)X -2881(substantial,)X -3264(but)X -3387(it)X -3452(is)X -3525(important)X -3856(for)X -3970(multi-user)X -555 3444(execution.)N -950(The)X -1118(bene\256ts)X -1410(of)X -1520(non-two-phase)X -2040(locking)X -2323(on)X -2446(B-trees)X -2721(are)X -2863(well)X -3044(established)X -3443(in)X -3548(the)X -3689(database)X -4009(literature)X -555 3534([BAY77],)N -899([LEHM81].)X -1320(If)X -1394(a)X -1450(process)X -1711(held)X -1869(locks)X -2058(until)X -2224(it)X -2288(committed,)X -2670(then)X -2828(a)X -2884(long-running)X -3322(update)X -3556(could)X -3754(lock)X -3912(out)X -4034(all)X -4134(other)X -555 3624(transactions)N -967(by)X -1076(preventing)X -1448(any)X -1593(other)X -1787(process)X -2057(from)X -2241(locking)X -2509(the)X -2635(root)X -2792(page)X -2972(of)X -3067(the)X -3193(tree.)X -3382(The)X -3535(B-tree)X -3764(locking)X -4032(protocol)X -555 3714(described)N -884(above)X -1096(guarantees)X -1460(that)X -1600(locks)X -1789(on)X -1889(internal)X -2154(pages)X -2357(are)X -2476(held)X -2634(for)X -2748(extremely)X -3089(short)X -3269(periods,)X -3545(thereby)X -3806(increasing)X -4156(con-)X -555 3804(currency.)N -3 f -555 3990(3.1.3.)N -775(Management)X -1245(of)X -1332(Shared)X -1596(Data)X -1 f -755 4113(Database)N -1075(systems)X -1353(permit)X -1587(many)X -1790(users)X -1980(to)X -2067(examine)X -2364(and)X -2505(update)X -2744(the)X -2866(same)X -3055(data)X -3213(concurrently.)X -3683(In)X -3774(order)X -3968(to)X -4054(provide)X -555 4203(this)N -702(concurrent)X -1078(access)X -1316(and)X -1464(enforce)X -1738(the)X -1868(write-ahead)X -2280(logging)X -2556(protocol)X -2855(described)X -3195(in)X -3289(section)X -3548(3.1.1,)X -3759(we)X -3884(use)X -4022(a)X -4089(shared)X -555 4293(memory)N -848(buffer)X -1071(manager.)X -1414(Not)X -1559(only)X -1726(does)X -1898(this)X -2038(provide)X -2308(the)X -2431(guarantees)X -2800(we)X -2919(require,)X -3192(but)X -3319(a)X -3380(user-level)X -3722(buffer)X -3944(manager)X -4246(is)X -555 4383(frequently)N -916(faster)X -1126(than)X -1295(using)X -1498(the)X -1626(\256le)X -1758(system)X -2010(buffer)X -2237(cache.)X -2491(Reads)X -2717(or)X -2814(writes)X -3040(involving)X -3376(the)X -3504(\256le)X -3636(system)X -3888(buffer)X -4115(cache)X -555 4473(often)N -746(require)X -1000(copying)X -1284(data)X -1444(between)X -1738(user)X -1898(and)X -2040(kernel)X -2266(space)X -2470(while)X -2673(a)X -2734(user-level)X -3076(buffer)X -3298(manager)X -3600(can)X -3737(return)X -3954(pointers)X -4237(to)X -555 4563(data)N -709(pages)X -912(directly.)X -1217(Additionally,)X -1661(if)X -1730(more)X -1915(than)X -2073(one)X -2209(process)X -2470(uses)X -2628(the)X -2746(same)X -2931(page,)X -3123(then)X -3281(fewer)X -3485(copies)X -3710(may)X -3868(be)X -3964(required.)X -3 f -555 4749(3.2.)N -715(Module)X -997(Architecture)X -1 f -755 4872(The)N -913(preceding)X -1262(sections)X -1552(described)X -1892(modules)X -2195(for)X -2321(managing)X -2669(the)X -2799(transaction)X -3183(log,)X -3337(locks,)X -3558(and)X -3706(a)X -3774(cache)X -3990(of)X -4089(shared)X -555 4962(buffers.)N -847(In)X -938(addition,)X -1244(we)X -1362(need)X -1538(to)X -1624(provide)X -1893(functionality)X -2326(for)X -2444(transaction)X -2 f -2819(begin)X -1 f -2997(,)X -2 f -3040(commit)X -1 f -3276(,)X -3319(and)X -2 f -3458(abort)X -1 f -3654(processing,)X -4040(necessi-)X -555 5052(tating)N -769(a)X -837(transaction)X -1221(manager.)X -1570(In)X -1669(order)X -1871(to)X -1965(arbitrate)X -2265(concurrent)X -2641(access)X -2879(to)X -2973(locks)X -3173(and)X -3320(buffers,)X -3599(we)X -3724(include)X -3991(a)X -4058(process)X -555 5142(management)N -995(module)X -1264(which)X -1489(manages)X -1799(a)X -1864(collection)X -2209(of)X -2305(semaphores)X -2713(used)X -2889(to)X -2980(block)X -3187(and)X -3332(release)X -3585(processes.)X -3962(Finally,)X -4237(in)X -555 5232(order)N -752(to)X -841(provide)X -1113(a)X -1176(simple,)X -1436(standard)X -1735(interface)X -2044(we)X -2165(have)X -2344(modi\256ed)X -2655(the)X -2780(database)X -3084(access)X -3317(routines)X -3602(\()X -3 f -3629(db)X -1 f -3717(\(3\)\).)X -3904(For)X -4041(the)X -4165(pur-)X -555 5322(poses)N -758(of)X -850(this)X -990(paper)X -1194(we)X -1313(call)X -1453(the)X -1575(modi\256ed)X -1883(package)X -2171(the)X -3 f -2293(Record)X -2567(Manager)X -1 f -2879(.)X -2943(Figure)X -3176(one)X -3316(shows)X -3540(the)X -3662(main)X -3846(interfaces)X -4183(and)X -555 5412(architecture)N -955(of)X -1042(LIBTP.)X - -5 p -%%Page: 5 5 -10 s 10 xH 0 xS 1 f -3 f -1 f -11 s -1851 1520(log_commit)N -2764 2077(buf_unpin)N -2764 1987(buf_get)N -3633 1408(buf_unpin)N -3633 1319(buf_pin)N -3633 1230(buf_get)N -3 f -17 s -1163 960(Txn)N -1430(M)X -1559(anager)X -2582(Record)X -3040(M)X -3169(anager)X -1 Dt -2363 726 MXY -0 355 Dl -1426 0 Dl -0 -355 Dl --1426 0 Dl -3255 1616 MXY -0 535 Dl -534 0 Dl -0 -535 Dl --534 0 Dl -2185 MX -0 535 Dl -535 0 Dl -0 -535 Dl --535 0 Dl -1116 MX -0 535 Dl -534 0 Dl -0 -535 Dl --534 0 Dl -726 MY -0 355 Dl -891 0 Dl -0 -355 Dl --891 0 Dl -1 f -11 s -2207 1297(lock)N -2564 1386(log)N -865(unlock_all)X -1851 1609(log_unroll)N -1650 2508 MXY -0 178 Dl -1605 0 Dl -0 -178 Dl --1605 0 Dl -1294 1616 MXY -19 -30 Dl --19 11 Dl --20 -11 Dl -20 30 Dl -0 -535 Dl -2319 2508 MXY --22 -30 Dl -4 23 Dl --18 14 Dl -36 -7 Dl --936 -357 Dl -3277 2455(sleep_on)N -1405 1616 MXY -36 4 Dl --18 -13 Dl -1 -22 Dl --19 31 Dl -1070 -535 Dl -2631 2508 MXY -36 6 Dl --18 -14 Dl -3 -22 Dl --21 30 Dl -891 -357 Dl -1426 2455(sleep_on)N -3255 1884 MXY --31 -20 Dl -11 20 Dl --11 19 Dl -31 -19 Dl --535 0 Dl -1554 2366(wake)N -3277(wake)X -2185 1884 MXY --31 -20 Dl -12 20 Dl --12 19 Dl -31 -19 Dl --356 0 Dl -0 -803 Dl -3 f -17 s -1236 1851(Lock)N -1118 2030(M)N -1247(anager)X -2339 1851(Log)N -2187 2030(M)N -2316(anager)X -3333 1851(Buffer)N -3257 2030(M)N -3386(anager)X -3522 1616 MXY -20 -30 Dl --20 11 Dl --20 -11 Dl -20 30 Dl -0 -535 Dl -1950 2654(Process)N -2424(M)X -2553(anager)X -2542 1616 MXY -19 -30 Dl --19 11 Dl --20 -11 Dl -20 30 Dl -0 -535 Dl -1 f -11 s -2207 1364(unlock)N -2452 2508 MXY -20 -31 Dl --20 11 Dl --19 -11 Dl -19 31 Dl -0 -357 Dl -2497 2322(sleep_on)N -2497 2233(wake)N -3 Dt --1 Ds -3 f -10 s -1790 2830(Figure)N -2037(1:)X -2144(Library)X -2435(module)X -2708(interfaces.)X -1 f -10 f -555 3010(h)N -579(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)X -3 f -555 3286(3.2.1.)N -775(The)X -928(Log)X -1081(Manager)X -1 f -755 3409(The)N -3 f -907(Log)X -1067(Manager)X -1 f -1406(enforces)X -1706(the)X -1831(write-ahead)X -2238(logging)X -2509(protocol.)X -2843(Its)X -2949(primitive)X -3268(operations)X -3628(are)X -2 f -3753(log)X -1 f -3855(,)X -2 f -3901(log_commit)X -1 f -4279(,)X -2 f -555 3499(log_read)N -1 f -844(,)X -2 f -889(log_roll)X -1 f -1171(and)X -2 f -1312(log_unroll)X -1 f -1649(.)X -1714(The)X -2 f -1864(log)X -1 f -1991(call)X -2132(performs)X -2447(a)X -2508(buffered)X -2806(write)X -2996(of)X -3088(the)X -3211(speci\256ed)X -3520(log)X -3646(record)X -3876(and)X -4016(returns)X -4263(a)X -555 3589(unique)N -809(log)X -947(sequence)X -1278(number)X -1559(\(LSN\).)X -1840(This)X -2017(LSN)X -2203(may)X -2376(then)X -2549(be)X -2660(used)X -2842(to)X -2939(retrieve)X -3220(a)X -3291(record)X -3532(from)X -3723(the)X -3856(log)X -3993(using)X -4201(the)X -2 f -555 3679(log_read)N -1 f -865(call.)X -1042(The)X -2 f -1188(log)X -1 f -1311(interface)X -1614(knows)X -1844(very)X -2008(little)X -2175(about)X -2374(the)X -2493(internal)X -2759(format)X -2993(of)X -3080(the)X -3198(log)X -3320(records)X -3577(it)X -3641(receives.)X -3965(Rather,)X -4219(all)X -555 3769(log)N -681(records)X -942(are)X -1065 0.4028(referenced)AX -1430(by)X -1534(a)X -1594(header)X -1833(structure,)X -2158(a)X -2218(log)X -2344(record)X -2574(type,)X -2756(and)X -2896(a)X -2956(character)X -3276(buffer)X -3497(containing)X -3859(the)X -3981(data)X -4138(to)X -4223(be)X -555 3859(logged.)N -834(The)X -980(log)X -1103(record)X -1330(type)X -1489(is)X -1563(used)X -1731(to)X -1814(call)X -1951(the)X -2070(appropriate)X -2457(redo)X -2621(and)X -2758(undo)X -2939(routines)X -3217(during)X -2 f -3446(abort)X -1 f -3639(and)X -2 f -3775(commit)X -1 f -4031(process-)X -555 3949(ing.)N -721(While)X -941(we)X -1059(have)X -1235(used)X -1406(the)X -3 f -1528(Log)X -1684(Manager)X -1 f -2019(to)X -2104(provide)X -2372(before)X -2601(and)X -2740(after)X -2911(image)X -3130(logging,)X -3417(it)X -3484(may)X -3645(also)X -3797(be)X -3896(used)X -4066(for)X -4183(any)X -555 4039(of)N -642(the)X -760(logging)X -1024(algorithms)X -1386(discussed.)X -755 4162(The)N -2 f -905(log_commit)X -1 f -1308(operation)X -1636(behaves)X -1920(exactly)X -2177(like)X -2322(the)X -2 f -2445(log)X -1 f -2572(operation)X -2900(but)X -3026(guarantees)X -3394(that)X -3538(the)X -3660(log)X -3786(has)X -3917(been)X -4093(forced)X -555 4252(to)N -643(disk)X -802(before)X -1034(returning.)X -1394(A)X -1478(discussion)X -1837(of)X -1930(our)X -2063(commit)X -2333(strategy)X -2613(appears)X -2884(in)X -2971(the)X -3094(implementation)X -3621(section)X -3873(\(section)X -4152(4.2\).)X -2 f -555 4342(Log_unroll)N -1 f -935(reads)X -1126(log)X -1249(records)X -1507(from)X -1684(the)X -1803(log,)X -1946(following)X -2278(backward)X -2611(transaction)X -2983(pointers)X -3261(and)X -3397(calling)X -3635(the)X -3753(appropriate)X -4139(undo)X -555 4432(routines)N -839(to)X -927(implement)X -1295(transaction)X -1673(abort.)X -1904(In)X -1997(a)X -2059(similar)X -2307(manner,)X -2 f -2594(log_roll)X -1 f -2877(reads)X -3073(log)X -3201(records)X -3464(sequentially)X -3877(forward,)X -4178(cal-)X -555 4522(ling)N -699(the)X -817(appropriate)X -1203(redo)X -1366(routines)X -1644(to)X -1726(recover)X -1988(committed)X -2350(transactions)X -2753(after)X -2921(a)X -2977(system)X -3219(crash.)X -3 f -555 4708(3.2.2.)N -775(The)X -928(Buffer)X -1171(Manager)X -1 f -755 4831(The)N -3 f -912(Buffer)X -1167(Manager)X -1 f -1511(uses)X -1681(a)X -1749(pool)X -1923(of)X -2022(shared)X -2264(memory)X -2563(to)X -2657(provide)X -2934(a)X -3002(least-recently-used)X -3641(\(LRU\))X -3886(block)X -4095(cache.)X -555 4921(Although)N -886(the)X -1013(current)X -1270(library)X -1513(provides)X -1818(an)X -1923(LRU)X -2112(cache,)X -2345(it)X -2418(would)X -2647(be)X -2752(simple)X -2994(to)X -3085(add)X -3229(alternate)X -3534(replacement)X -3955(policies)X -4232(as)X -555 5011(suggested)N -903(by)X -1015([CHOU85])X -1408(or)X -1507(to)X -1601(provide)X -1878(multiple)X -2176(buffer)X -2405(pools)X -2610(with)X -2784(different)X -3092(policies.)X -3412(Transactions)X -3853(request)X -4116(pages)X -555 5101(from)N -736(the)X -859(buffer)X -1081(manager)X -1383(and)X -1524(keep)X -1701(them)X -3 f -1886(pinned)X -1 f -2145(to)X -2232(ensure)X -2466(that)X -2610(they)X -2772(are)X -2895(not)X -3021(written)X -3272(to)X -3358(disk)X -3515(while)X -3717(they)X -3879(are)X -4002(in)X -4088(a)X -4148(logi-)X -555 5191(cally)N -732(inconsistent)X -1135(state.)X -1343(When)X -1556(page)X -1729(replacement)X -2143(is)X -2217(necessary,)X -2571(the)X -3 f -2689(Buffer)X -2932(Manager)X -1 f -3264(\256nds)X -3439(an)X -3535(unpinned)X -3853(page)X -4025(and)X -4161(then)X -555 5281(checks)N -794(with)X -956(the)X -3 f -1074(Log)X -1227(Manager)X -1 f -1559(to)X -1641(ensure)X -1871(that)X -2011(the)X -2129(write-ahead)X -2529(protocol)X -2816(is)X -2889(enforced.)X -3 f -555 5467(3.2.3.)N -775(The)X -928(Lock)X -1121(Manager)X -1 f -755 5590(The)N -3 f -901(Lock)X -1095(Manager)X -1 f -1428(supports)X -1720(general)X -1978(purpose)X -2253(locking)X -2514(\(single)X -2753(writer,)X -2986(multiple)X -3273(readers\))X -3553(which)X -3769(is)X -3842(currently)X -4152(used)X -555 5680(to)N -638(provide)X -904(two-phase)X -1254(locking)X -1514(and)X -1650(high)X -1812(concurrency)X -2230(B-tree)X -2451(locking.)X -2751(However,)X -3086(the)X -3204(general)X -3461(purpose)X -3735(nature)X -3956(of)X -4043(the)X -4161(lock)X - -6 p -%%Page: 6 6 -10 s 10 xH 0 xS 1 f -3 f -1 f -555 630(manager)N -857(provides)X -1158(the)X -1281(ability)X -1510(to)X -1597(support)X -1862(a)X -1923(variety)X -2171(of)X -2263(locking)X -2528(protocols.)X -2890(Currently,)X -3241(all)X -3345(locks)X -3538(are)X -3661(issued)X -3885(at)X -3967(the)X -4089(granu-)X -555 720(larity)N -747(of)X -837(a)X -896(page)X -1071(\(the)X -1219(size)X -1367(of)X -1457(a)X -1516(buffer)X -1736(in)X -1821(the)X -1942(buffer)X -2161(pool\))X -2352(which)X -2570(is)X -2645(identi\256ed)X -2969(by)X -3071(two)X -3213(4-byte)X -3440(integers)X -3716(\(a)X -3801(\256le)X -3925(id)X -4009(and)X -4147(page)X -555 810(number\).)N -898(This)X -1071(provides)X -1378(the)X -1507(necessary)X -1851(information)X -2259(to)X -2351(extend)X -2595(the)X -3 f -2723(Lock)X -2926(Manager)X -1 f -3268(to)X -3360(perform)X -3649(hierarchical)X -4059(locking)X -555 900([GRAY76].)N -982(The)X -1133(current)X -1387(implementation)X -1915(does)X -2088(not)X -2216(support)X -2482(locks)X -2677(at)X -2760(other)X -2950(granularities)X -3376(and)X -3517(does)X -3689(not)X -3816(promote)X -4108(locks;)X -555 990(these)N -740(are)X -859(obvious)X -1132(future)X -1344(additions)X -1657(to)X -1739(the)X -1857(system.)X -755 1113(If)N -831(an)X -929(incoming)X -1253(lock)X -1413(request)X -1667(cannot)X -1903(be)X -2001(granted,)X -2284(the)X -2404(requesting)X -2760(process)X -3023(is)X -3098(queued)X -3352(for)X -3467(the)X -3586(lock)X -3745(and)X -3882(descheduled.)X -555 1203(When)N -769(a)X -827(lock)X -987(is)X -1062(released,)X -1368(the)X -1488(wait)X -1647(queue)X -1860(is)X -1934(traversed)X -2250(and)X -2387(any)X -2524(newly)X -2741(compatible)X -3118(locks)X -3308(are)X -3428(granted.)X -3730(Locks)X -3947(are)X -4067(located)X -555 1293(via)N -680(a)X -743(\256le)X -872(and)X -1015(page)X -1194(hash)X -1368(table)X -1551(and)X -1694(are)X -1820(chained)X -2097(both)X -2266(by)X -2373(object)X -2595(and)X -2737(by)X -2843(transaction,)X -3241(facilitating)X -3614(rapid)X -3805(traversal)X -4108(of)X -4201(the)X -555 1383(lock)N -713(table)X -889(during)X -1118(transaction)X -1490(commit)X -1754(and)X -1890(abort.)X -755 1506(The)N -907(primary)X -1188(interfaces)X -1528(to)X -1617(the)X -1742(lock)X -1907(manager)X -2211(are)X -2 f -2337(lock)X -1 f -2471(,)X -2 f -2518(unlock)X -1 f -2732(,)X -2779(and)X -2 f -2922(lock_unlock_all)X -1 f -3434(.)X -2 f -3500(Lock)X -1 f -3682(obtains)X -3939(a)X -4001(new)X -4161(lock)X -555 1596(for)N -680(a)X -747(speci\256c)X -1023(object.)X -1290(There)X -1509(are)X -1638(also)X -1797(two)X -1947(variants)X -2231(of)X -2328(the)X -2 f -2456(lock)X -1 f -2620(request,)X -2 f -2902(lock_upgrade)X -1 f -3373(and)X -2 f -3519(lock_downgrade)X -1 f -4053(,)X -4103(which)X -555 1686(allow)N -755(the)X -875(caller)X -1076(to)X -1160(atomically)X -1519(trade)X -1701(a)X -1758(lock)X -1917(of)X -2005(one)X -2142(type)X -2301(for)X -2416(a)X -2473(lock)X -2632(of)X -2720(another.)X -2 f -3022(Unlock)X -1 f -3275(releases)X -3551(a)X -3608(speci\256c)X -3874(mode)X -4073(of)X -4161(lock)X -555 1776(on)N -655(a)X -711(speci\256c)X -976(object.)X -2 f -1232(Lock_unlock_all)X -1 f -1786(releases)X -2061(all)X -2161(the)X -2279(locks)X -2468(associated)X -2818(with)X -2980(a)X -3036(speci\256c)X -3301(transaction.)X -3 f -555 1962(3.2.4.)N -775(The)X -928(Process)X -1207(Manager)X -1 f -755 2085(The)N -3 f -900(Process)X -1179(Manager)X -1 f -1511(acts)X -1656(as)X -1743(a)X -1799(user-level)X -2136(scheduler)X -2464(to)X -2546(make)X -2740(processes)X -3068(wait)X -3226(on)X -3326(unavailable)X -3716(locks)X -3905(and)X -4041(pending)X -555 2175(buffer)N -778(cache)X -988(I/O.)X -1161(For)X -1297(each)X -1470(process,)X -1756(a)X -1817(semaphore)X -2190(is)X -2268(maintained)X -2649(upon)X -2834(which)X -3055(that)X -3200(process)X -3466(waits)X -3660(when)X -3859(it)X -3928(needs)X -4136(to)X -4223(be)X -555 2265(descheduled.)N -1014(When)X -1228(a)X -1286(process)X -1549(needs)X -1754(to)X -1838(be)X -1936(run,)X -2084(its)X -2180(semaphore)X -2549(is)X -2623(cleared,)X -2897(and)X -3034(the)X -3153(operating)X -3477(system)X -3720(reschedules)X -4116(it.)X -4201(No)X -555 2355(sophisticated)N -1002(scheduling)X -1378(algorithm)X -1718(is)X -1799(applied;)X -2085(if)X -2162(the)X -2288(lock)X -2454(for)X -2576(which)X -2800(a)X -2864(process)X -3133(was)X -3286(waiting)X -3554(becomes)X -3863(available,)X -4201(the)X -555 2445(process)N -824(is)X -905(made)X -1107(runnable.)X -1456(It)X -1533(would)X -1761(have)X -1941(been)X -2121(possible)X -2411(to)X -2501(change)X -2757(the)X -2883(kernel's)X -3170(process)X -3439(scheduler)X -3775(to)X -3865(interact)X -4134(more)X -555 2535(ef\256ciently)N -900(with)X -1062(the)X -1180(lock)X -1338(manager,)X -1655(but)X -1777(doing)X -1979(so)X -2070(would)X -2290(have)X -2462(compromised)X -2918(our)X -3045(commitment)X -3469(to)X -3551(a)X -3607(user-level)X -3944(package.)X -3 f -555 2721(3.2.5.)N -775(The)X -928(Transaction)X -1361(Manager)X -1 f -755 2844(The)N -3 f -901(Transaction)X -1335(Manager)X -1 f -1668(provides)X -1965(the)X -2084(standard)X -2377(interface)X -2680(of)X -2 f -2768(txn_begin)X -1 f -3084(,)X -2 f -3125(txn_commit)X -1 f -3499(,)X -3540(and)X -2 f -3676(txn_abort)X -1 f -3987(.)X -4047(It)X -4116(keeps)X -555 2934(track)N -742(of)X -835(all)X -941(active)X -1159(transactions,)X -1588(assigns)X -1845(unique)X -2089(transaction)X -2467(identi\256ers,)X -2833(and)X -2974(directs)X -3213(the)X -3336(abort)X -3526(and)X -3667(commit)X -3936(processing.)X -555 3024(When)N -772(a)X -2 f -833(txn_begin)X -1 f -1174(is)X -1252(issued,)X -1497(the)X -3 f -1620(Transaction)X -2058(Manager)X -1 f -2395(assigns)X -2651(the)X -2773(next)X -2935(available)X -3249(transaction)X -3625(identi\256er,)X -3958(allocates)X -4263(a)X -555 3114(per-process)N -948(transaction)X -1322(structure)X -1625(in)X -1709(shared)X -1941(memory,)X -2249(increments)X -2622(the)X -2741(count)X -2940(of)X -3028(active)X -3241(transactions,)X -3665(and)X -3802(returns)X -4046(the)X -4165(new)X -555 3204(transaction)N -937(identi\256er)X -1256(to)X -1348(the)X -1476(calling)X -1724(process.)X -2034(The)X -2188(in-memory)X -2573(transaction)X -2954(structure)X -3264(contains)X -3560(a)X -3625(pointer)X -3881(into)X -4034(the)X -4161(lock)X -555 3294(table)N -734(for)X -851(locks)X -1043(held)X -1204(by)X -1307(this)X -1445(transaction,)X -1840(the)X -1961(last)X -2095(log)X -2220(sequence)X -2538(number,)X -2826(a)X -2885(transaction)X -3260(state)X -3430(\()X -2 f -3457(idle)X -1 f -(,)S -2 f -3620(running)X -1 f -3873(,)X -2 f -3915(aborting)X -1 f -4190(,)X -4232(or)X -2 f -555 3384(committing\))N -1 f -942(,)X -982(an)X -1078(error)X -1255(code,)X -1447(and)X -1583(a)X -1639(semaphore)X -2007(identi\256er.)X -755 3507(At)N -859(commit,)X -1147(the)X -3 f -1269(Transaction)X -1706(Manager)X -1 f -2042(calls)X -2 f -2213(log_commit)X -1 f -2615(to)X -2700(record)X -2929(the)X -3050(end)X -3189(of)X -3279(transaction)X -3654(and)X -3793(to)X -3878(\257ush)X -4056(the)X -4177(log.)X -555 3597(Then)N -743(it)X -810(directs)X -1047(the)X -3 f -1168(Lock)X -1364(Manager)X -1 f -1699(to)X -1784(release)X -2031(all)X -2134(locks)X -2325(associated)X -2677(with)X -2841(the)X -2961(given)X -3161(transaction.)X -3575(If)X -3651(a)X -3709(transaction)X -4083(aborts,)X -555 3687(the)N -3 f -680(Transaction)X -1120(Manager)X -1 f -1459(calls)X -1633(on)X -2 f -1739(log_unroll)X -1 f -2102(to)X -2190(read)X -2355(the)X -2479(transaction's)X -2915(log)X -3043(records)X -3306(and)X -3448(undo)X -3634(any)X -3776(modi\256cations)X -4237(to)X -555 3777(the)N -673(database.)X -1010(As)X -1119(in)X -1201(the)X -1319(commit)X -1583(case,)X -1762(it)X -1826(then)X -1984(calls)X -2 f -2151(lock_unlock_all)X -1 f -2683(to)X -2765(release)X -3009(the)X -3127(transaction's)X -3557(locks.)X -3 f -555 3963(3.2.6.)N -775(The)X -928(Record)X -1198(Manager)X -1 f -755 4086(The)N -3 f -919(Record)X -1208(Manager)X -1 f -1559(supports)X -1869(the)X -2006(abstraction)X -2397(of)X -2503(reading)X -2783(and)X -2938(writing)X -3208(records)X -3484(to)X -3585(a)X -3660(database.)X -3996(We)X -4147(have)X -555 4176(modi\256ed)N -861(the)X -981(the)X -1101(database)X -1399(access)X -1626(routines)X -3 f -1905(db)X -1 f -1993(\(3\))X -2108([BSD91])X -2418(to)X -2501(call)X -2638(the)X -2757(log,)X -2900(lock,)X -3079(and)X -3216(buffer)X -3434(managers.)X -3803(In)X -3891(order)X -4082(to)X -4165(pro-)X -555 4266(vide)N -718(functionality)X -1152(to)X -1239(perform)X -1523(undo)X -1708(and)X -1849(redo,)X -2037(the)X -3 f -2160(Record)X -2434(Manager)X -1 f -2770(de\256nes)X -3021(a)X -3081(collection)X -3421(of)X -3512(log)X -3638(record)X -3868(types)X -4061(and)X -4201(the)X -555 4356(associated)N -920(undo)X -1115(and)X -1266(redo)X -1444(routines.)X -1777(The)X -3 f -1937(Log)X -2105(Manager)X -1 f -2452(performs)X -2777(a)X -2848(table)X -3039(lookup)X -3296(on)X -3411(the)X -3543(record)X -3783(type)X -3955(to)X -4051(call)X -4201(the)X -555 4446(appropriate)N -951(routines.)X -1299(For)X -1440(example,)X -1762(the)X -1890(B-tree)X -2121(access)X -2356(method)X -2625(requires)X -2913(two)X -3062(log)X -3193(record)X -3428(types:)X -3648(insert)X -3855(and)X -4000(delete.)X -4241(A)X -555 4536(replace)N -808(operation)X -1131(is)X -1204(implemented)X -1642(as)X -1729(a)X -1785(delete)X -1997(followed)X -2302(by)X -2402(an)X -2498(insert)X -2696(and)X -2832(is)X -2905(logged)X -3143(accordingly.)X -3 f -555 4722(3.3.)N -715(Application)X -1134(Architectures)X -1 f -755 4845(The)N -907(structure)X -1215(of)X -1309(LIBTP)X -1558(allows)X -1794(application)X -2177(designers)X -2507(to)X -2596(trade)X -2784(off)X -2905(performance)X -3339(and)X -3481(protection.)X -3872(Since)X -4076(a)X -4138(large)X -555 4935(portion)N -810(of)X -901(LIBTP's)X -1205(functionality)X -1638(is)X -1715(provided)X -2024(by)X -2128(managing)X -2468(structures)X -2804(in)X -2889(shared)X -3122(memory,)X -3432(its)X -3530(structures)X -3865(are)X -3987(subject)X -4237(to)X -555 5025(corruption)N -926(by)X -1043(applications)X -1467(when)X -1678(the)X -1813(library)X -2064(is)X -2154(linked)X -2391(directly)X -2673(with)X -2852(the)X -2987(application.)X -3420(For)X -3568(this)X -3720(reason,)X -3987(LIBTP)X -4246(is)X -555 5115(designed)N -864(to)X -950(allow)X -1152(compilation)X -1558(into)X -1706(a)X -1766(separate)X -2053(server)X -2273(process)X -2537(which)X -2756(may)X -2917(be)X -3016(accessed)X -3321(via)X -3442(a)X -3501(socket)X -3729(interface.)X -4094(In)X -4184(this)X -555 5205(way)N -712(LIBTP's)X -1015(data)X -1172(structures)X -1507(are)X -1629(protected)X -1951(from)X -2130(application)X -2509(code,)X -2704(but)X -2829(communication)X -3349(overhead)X -3666(is)X -3741(increased.)X -4107(When)X -555 5295(applications)N -975(are)X -1107(trusted,)X -1377(LIBTP)X -1631(may)X -1801(be)X -1909(compiled)X -2239(directly)X -2516(into)X -2672(the)X -2802(application)X -3190(providing)X -3533(improved)X -3872(performance.)X -555 5385(Figures)N -815(two)X -955(and)X -1091(three)X -1272(show)X -1461(the)X -1579(two)X -1719(alternate)X -2016(application)X -2392(architectures.)X -755 5508(There)N -964(are)X -1084(potentially)X -1447(two)X -1588(modes)X -1818(in)X -1901(which)X -2118(one)X -2255(might)X -2462(use)X -2590(LIBTP)X -2833(in)X -2916(a)X -2972(server)X -3189(based)X -3392(architecture.)X -3832(In)X -3919(the)X -4037(\256rst,)X -4201(the)X -555 5598(server)N -778(would)X -1004(provide)X -1275(the)X -1399(capability)X -1741(to)X -1829(respond)X -2109(to)X -2197(requests)X -2486(to)X -2574(each)X -2747(of)X -2839(the)X -2962(low)X -3107(level)X -3288(modules)X -3584(\(lock,)X -3794(log,)X -3941(buffer,)X -4183(and)X -555 5688(transaction)N -944(managers\).)X -1356(Unfortunately,)X -1863(the)X -1998(performance)X -2442(of)X -2546(such)X -2730(a)X -2803(system)X -3062(is)X -3152(likely)X -3371(to)X -3470(be)X -3583(blindingly)X -3947(slow)X -4134(since)X - -7 p -%%Page: 7 7 -10 s 10 xH 0 xS 1 f -3 f -1 f -1 Dt -1864 1125 MXY -15 -26 Dl --15 10 Dl --14 -10 Dl -14 26 Dl -0 -266 Dl -1315 1125 MXY -15 -26 Dl --15 10 Dl --14 -10 Dl -14 26 Dl -0 -266 Dl -3 Dt -1133 1125 MXY -0 798 Dl -931 0 Dl -0 -798 Dl --931 0 Dl -1 Dt -1266 1257 MXY -0 133 Dl -665 0 Dl -0 -133 Dl --665 0 Dl -3 f -8 s -1513 1351(driver)N -1502 1617(LIBTP)N -1266 1390 MXY -0 400 Dl -665 0 Dl -0 -400 Dl --665 0 Dl -3 Dt -1133 726 MXY -0 133 Dl -931 0 Dl -0 -133 Dl --931 0 Dl -1 f -1029 1098(txn_abort)N -964 1015(txn_commit)N -1018 932(txn_begin)N -1910 1015(db_ops)N -3 f -1308 820(Application)N -1645(Program)X -1398 1218(Server)N -1594(Process)X -1 f -1390 986(socket)N -1569(interface)X -1 Dt -1848 967 MXY --23 -14 Dl -8 14 Dl --8 15 Dl -23 -15 Dl --50 0 Dl -1324 MX -23 15 Dl --9 -15 Dl -9 -14 Dl --23 14 Dl -50 0 Dl -3 Dt -2862 859 MXY -0 1064 Dl -932 0 Dl -0 -1064 Dl --932 0 Dl -1 Dt -3178 1390 MXY -24 -12 Dl --17 0 Dl --8 -15 Dl -1 27 Dl -150 -265 Dl -3494 1390 MXY -0 -27 Dl --8 15 Dl --16 1 Dl -24 11 Dl --166 -265 Dl -3 f -3232 1617(LIBTP)N -2995 1390 MXY -0 400 Dl -666 0 Dl -0 -400 Dl --666 0 Dl -992 MY -0 133 Dl -666 0 Dl -0 -133 Dl --666 0 Dl -3168 1086(Application)N -1 f -2939 1201(txn_begin)N -2885 1284(txn_commit)N -2950 1368(txn_abort)N -3465 1284(db_ops)N -3 f -3155 766(Single)N -3339(Process)X -3 Dt --1 Ds -811 2100(Figure)N -1023(2:)X -1107(Server)X -1318(Architecture.)X -1 f -1727(In)X -1811(this)X -1934(con\256guration,)X -811 2190(the)N -916(library)X -1113(is)X -1183(loaded)X -1380(into)X -1507(a)X -1562(server)X -1744(process)X -1962(which)X -2145(is)X -2214(ac-)X -811 2280(cessed)N -993(via)X -1087(a)X -1131(socket)X -1310(interface.)X -3 f -2563 2100(Figure)N -2803(3:)X -2914(Single)X -3140(Process)X -3403(Architecture.)X -1 f -3839(In)X -3950(this)X -2563 2190(con\256guration,)N -2948(the)X -3053(library)X -3250(routines)X -3483(are)X -3587(loaded)X -3784(as)X -3864(part)X -3990(of)X -2563 2280(the)N -2657(application)X -2957(and)X -3065(accessed)X -3303(via)X -3397(a)X -3441(subroutine)X -3727(interface.)X -10 s -10 f -555 2403(h)N -579(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)X -1 f -555 2679(modifying)N -909(a)X -966(piece)X -1157(of)X -1245(data)X -1400(would)X -1621(require)X -1870(three)X -2051(or)X -2138(possibly)X -2424(four)X -2578(separate)X -2862(communications:)X -3433(one)X -3569(to)X -3651(lock)X -3809(the)X -3927(data,)X -4101(one)X -4237(to)X -555 2769(obtain)N -781(the)X -905(data,)X -1085(one)X -1227(to)X -1315(log)X -1443(the)X -1567(modi\256cation,)X -2017(and)X -2159(possibly)X -2451(one)X -2593(to)X -2681(transmit)X -2969(the)X -3093(modi\256ed)X -3403(data.)X -3583(Figure)X -3817(four)X -3976(shows)X -4201(the)X -555 2859(relative)N -826(performance)X -1263(for)X -1387(retrieving)X -1728(a)X -1793(single)X -2013(record)X -2248(using)X -2450(the)X -2577(record)X -2812(level)X -2997(call)X -3142(versus)X -3376(using)X -3578(the)X -3705(lower)X -3917(level)X -4102(buffer)X -555 2949(management)N -987(and)X -1125(locking)X -1387(calls.)X -1616(The)X -1763(2:1)X -1887(ratio)X -2056(observed)X -2367(in)X -2450(the)X -2569(single)X -2781(process)X -3043(case)X -3203(re\257ects)X -3456(the)X -3575(additional)X -3916(overhead)X -4232(of)X -555 3039(parsing)N -819(eight)X -1006(commands)X -1380(rather)X -1595(than)X -1760(one)X -1903(while)X -2108(the)X -2233(3:1)X -2362(ratio)X -2536(observed)X -2853(in)X -2942(the)X -3067(client/server)X -3491(architecture)X -3898(re\257ects)X -4157(both)X -555 3129(the)N -679(parsing)X -941(and)X -1083(the)X -1207(communication)X -1731(overheard.)X -2118(Although)X -2445(there)X -2631(may)X -2794(be)X -2895(applications)X -3307(which)X -3528(could)X -3731(tolerate)X -3997(such)X -4169(per-)X -555 3219(formance,)N -904(it)X -973(seems)X -1194(far)X -1309(more)X -1499(feasible)X -1774(to)X -1861(support)X -2126(a)X -2187(higher)X -2417(level)X -2597(interface,)X -2923(such)X -3094(as)X -3185(that)X -3329(provided)X -3638(by)X -3742(a)X -3802(query)X -4009(language)X -555 3309(\()N -2 f -582(e.g.)X -1 f -718(SQL)X -889([SQL86]\).)X -755 3432(Although)N -1081(LIBTP)X -1327(does)X -1498(not)X -1624(have)X -1800(an)X -1900(SQL)X -2075(parser,)X -2316(we)X -2433(have)X -2608(built)X -2777(a)X -2836(server)X -3056(application)X -3435(using)X -3631(the)X -3752(toolkit)X -3983(command)X -555 3522(language)N -882(\(TCL\))X -1124([OUST90].)X -1544(The)X -1706(server)X -1940(supports)X -2248(a)X -2321(command)X -2674(line)X -2831(interface)X -3150(similar)X -3409(to)X -3508(the)X -3643(subroutine)X -4017(interface)X -555 3612(de\256ned)N -811(in)X -3 f -893(db)X -1 f -981(\(3\).)X -1135(Since)X -1333(it)X -1397(is)X -1470(based)X -1673(on)X -1773(TCL,)X -1964(it)X -2028(provides)X -2324(control)X -2571(structures)X -2903(as)X -2990(well.)X -3 f -555 3798(4.)N -655(Implementation)X -1 f -3 f -555 3984(4.1.)N -715(Locking)X -1014(and)X -1162(Deadlock)X -1502(Detection)X -1 f -755 4107(LIBTP)N -1007(uses)X -1175(two-phase)X -1535(locking)X -1805(for)X -1929(user)X -2093(data.)X -2297(Strictly)X -2562(speaking,)X -2897(the)X -3024(two)X -3173(phases)X -3416(in)X -3507(two-phase)X -3866(locking)X -4135(are)X -4263(a)X -3 f -555 4197(grow)N -1 f -756(phase,)X -986(during)X -1221(which)X -1443(locks)X -1638(are)X -1763(acquired,)X -2086(and)X -2228(a)X -3 f -2290(shrink)X -1 f -2537(phase,)X -2766(during)X -3001(which)X -3223(locks)X -3418(are)X -3543(released.)X -3873(No)X -3997(lock)X -4161(may)X -555 4287(ever)N -720(be)X -822(acquired)X -1124(during)X -1358(the)X -1481(shrink)X -1706(phase.)X -1954(The)X -2104(grow)X -2294(phase)X -2502(lasts)X -2669(until)X -2840(the)X -2963(\256rst)X -3112(release,)X -3381(which)X -3602(marks)X -3823(the)X -3946(start)X -4109(of)X -4201(the)X -555 4377(shrink)N -780(phase.)X -1028(In)X -1120(practice,)X -1420(the)X -1543(grow)X -1733(phase)X -1941(lasts)X -2108(for)X -2227(the)X -2350(duration)X -2642(of)X -2734(a)X -2795(transaction)X -3172(in)X -3259(LIBTP)X -3506(and)X -3647(in)X -3734(commercial)X -4138(data-)X -555 4467(base)N -721(systems.)X -1037(The)X -1184(shrink)X -1406(phase)X -1611(takes)X -1798(place)X -1990(during)X -2221(transaction)X -2595(commit)X -2861(or)X -2950(abort.)X -3177(This)X -3341(means)X -3568(that)X -3710(locks)X -3901(are)X -4022(acquired)X -555 4557(on)N -655(demand)X -929(during)X -1158(the)X -1276(lifetime)X -1545(of)X -1632(a)X -1688(transaction,)X -2080(and)X -2216(held)X -2374(until)X -2540(commit)X -2804(time,)X -2986(at)X -3064(which)X -3280(point)X -3464(all)X -3564(locks)X -3753(are)X -3872(released.)X -755 4680(If)N -832(multiple)X -1121(transactions)X -1527(are)X -1649(active)X -1864(concurrently,)X -2313(deadlocks)X -2657(can)X -2792(occur)X -2994(and)X -3133(must)X -3311(be)X -3410(detected)X -3701(and)X -3840(resolved.)X -4174(The)X -555 4770(lock)N -715(table)X -893(can)X -1027(be)X -1125(thought)X -1391(of)X -1480(as)X -1569(a)X -1627(representation)X -2104(of)X -2193(a)X -2251(directed)X -2532(graph.)X -2777(The)X -2924(nodes)X -3133(in)X -3216(the)X -3335(graph)X -3539(are)X -3659(transactions.)X -4103(Edges)X -555 4860(represent)N -878(the)X -3 f -1004(waits-for)X -1 f -1340(relation)X -1613(between)X -1909(transactions;)X -2342(if)X -2419(transaction)X -2 f -2799(A)X -1 f -2876(is)X -2957(waiting)X -3225(for)X -3347(a)X -3411(lock)X -3577(held)X -3743(by)X -3851(transaction)X -2 f -4230(B)X -1 f -4279(,)X -555 4950(then)N -716(a)X -775(directed)X -1057(edge)X -1232(exists)X -1437(from)X -2 f -1616(A)X -1 f -1687(to)X -2 f -1771(B)X -1 f -1842(in)X -1926(the)X -2046(graph.)X -2291(A)X -2371(deadlock)X -2683(exists)X -2887(if)X -2958(a)X -3016(cycle)X -3208(appears)X -3476(in)X -3560(the)X -3680(graph.)X -3925(By)X -4040(conven-)X -555 5040(tion,)N -719(no)X -819(transaction)X -1191(ever)X -1350(waits)X -1539(for)X -1653(a)X -1709(lock)X -1867(it)X -1931(already)X -2188(holds,)X -2401(so)X -2492(re\257exive)X -2793(edges)X -2996(are)X -3115(impossible.)X -755 5163(A)N -836(distinguished)X -1285(process)X -1549(monitors)X -1856(the)X -1977(lock)X -2138(table,)X -2337(searching)X -2668(for)X -2785(cycles.)X -3048(The)X -3195(frequency)X -3539(with)X -3703(which)X -3921(this)X -4058(process)X -555 5253(runs)N -716(is)X -792(user-settable;)X -1243(for)X -1360(the)X -1481(multi-user)X -1833(tests)X -1998(discussed)X -2328(in)X -2413(section)X -2663(5.1.2,)X -2866(it)X -2933(has)X -3063(been)X -3238(set)X -3350(to)X -3435(wake)X -3628(up)X -3731(every)X -3932(second,)X -4197(but)X -555 5343(more)N -742(sophisticated)X -1182(schedules)X -1516(are)X -1636(certainly)X -1938(possible.)X -2261(When)X -2474(a)X -2531(cycle)X -2722(is)X -2796(detected,)X -3105(one)X -3242(of)X -3330(the)X -3449(transactions)X -3853(in)X -3936(the)X -4055(cycle)X -4246(is)X -555 5433(nominated)N -917(and)X -1057(aborted.)X -1362(When)X -1578(the)X -1700(transaction)X -2076(aborts,)X -2315(it)X -2382(rolls)X -2547(back)X -2722(its)X -2820(changes)X -3102(and)X -3241(releases)X -3519(its)X -3617(locks,)X -3829(thereby)X -4093(break-)X -555 5523(ing)N -677(the)X -795(cycle)X -985(in)X -1067(the)X -1185(graph.)X - -8 p -%%Page: 8 8 -10 s 10 xH 0 xS 1 f -3 f -1 f -4 Ds -1 Dt -1866 865 MXY -1338 0 Dl -1866 1031 MXY -1338 0 Dl -1866 1199 MXY -1338 0 Dl -1866 1366 MXY -1338 0 Dl -1866 1533 MXY -1338 0 Dl -1866 1701 MXY -1338 0 Dl --1 Ds -5 Dt -1866 1868 MXY -1338 0 Dl -1 Dt -1 Di -2981 MX - 2981 1868 lineto - 2981 1575 lineto - 3092 1575 lineto - 3092 1868 lineto - 2981 1868 lineto -closepath 21 2981 1575 3092 1868 Dp -2646 MX - 2646 1868 lineto - 2646 949 lineto - 2758 949 lineto - 2758 1868 lineto - 2646 1868 lineto -closepath 14 2646 949 2758 1868 Dp -2312 MX - 2312 1868 lineto - 2312 1701 lineto - 2423 1701 lineto - 2423 1868 lineto - 2312 1868 lineto -closepath 3 2312 1701 2423 1868 Dp -1977 MX - 1977 1868 lineto - 1977 1512 lineto - 2089 1512 lineto - 2089 1868 lineto - 1977 1868 lineto -closepath 19 1977 1512 2089 1868 Dp -3 f -2640 2047(Client/Server)N -1957(Single)X -2185(Process)X -7 s -2957 1957(record)N -2570(component)X -2289(record)X -1890(components)X -1733 1724(.1)N -1733 1556(.2)N -1733 1389(.3)N -1733 1222(.4)N -1733 1055(.5)N -1733 889(.6)N -1590 726(Elapsed)N -1794(Time)X -1613 782(\(in)N -1693(seconds\))X -3 Dt --1 Ds -8 s -555 2255(Figure)N -756(4:)X -829(Comparison)X -1187(of)X -1260(High)X -1416(and)X -1540(Low)X -1681(Level)X -1850(Interfaces.)X -1 f -2174(Elapsed)X -2395(time)X -2528(in)X -2597(seconds)X -2818(to)X -2887(perform)X -3111(a)X -3158(single)X -3330(record)X -3511(retrieval)X -3742(from)X -3885(a)X -3932(command)X -4203(line)X -555 2345(\(rather)N -751(than)X -888(a)X -943(procedural)X -1241(interface\))X -1510(is)X -1579(shown)X -1772(on)X -1862(the)X -1966(y)X -2024(axis.)X -2185(The)X -2310(``component'')X -2704(numbers)X -2950(re\257ect)X -3135(the)X -3239(timings)X -3458(when)X -3622(the)X -3726(record)X -3914(is)X -3983(retrieved)X -4235(by)X -555 2435(separate)N -785(calls)X -924(to)X -996(the)X -1096(lock)X -1228(manager)X -1469(and)X -1583(buffer)X -1760(manager)X -2001(while)X -2165(the)X -2264(``record'')X -2531(timings)X -2745(were)X -2889(obtained)X -3130(by)X -3215(using)X -3375(a)X -3424(single)X -3598(call)X -3711(to)X -3782(the)X -3881(record)X -4064(manager.)X -555 2525(The)N -674(2:1)X -776(ratio)X -913(observed)X -1163(for)X -1257(the)X -1355(single)X -1528(process)X -1739(case)X -1868(is)X -1930(a)X -1977(re\257ection)X -2237(of)X -2309(the)X -2406(parsing)X -2613(overhead)X -2865(for)X -2958(executing)X -3225(eight)X -3372(separate)X -3599(commands)X -3895(rather)X -4062(than)X -4191(one.)X -555 2615(The)N -673(additional)X -948(factor)X -1115(of)X -1187(one)X -1298(re\257ected)X -1536(in)X -1605(the)X -1702(3:1)X -1803(ratio)X -1939(for)X -2031(the)X -2127(client/server)X -2460(architecture)X -2794(is)X -2855(due)X -2965(to)X -3033(the)X -3129(communication)X -3545(overhead.)X -3828(The)X -3945(true)X -4062(ratios)X -4222(are)X -555 2705(actually)N -775(worse)X -945(since)X -1094(the)X -1190(component)X -1492(timings)X -1703(do)X -1785(not)X -1884(re\257ect)X -2060(the)X -2155(search)X -2334(times)X -2490(within)X -2671(each)X -2804(page)X -2941(or)X -3011(the)X -3106(time)X -3237(required)X -3466(to)X -3533(transmit)X -3760(the)X -3855(page)X -3992(between)X -4221(the)X -555 2795(two)N -667(processes.)X -10 s -10 f -555 2885(h)N -579(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)X -3 f -555 3161(4.2.)N -715(Group)X -961(Commit)X -1 f -755 3284(Since)N -959(the)X -1083(log)X -1211(must)X -1392(be)X -1494(\257ushed)X -1751(to)X -1839(disk)X -1997(at)X -2080(commit)X -2349(time,)X -2536(disk)X -2694(bandwidth)X -3057(fundamentally)X -3545(limits)X -3751(the)X -3874(rate)X -4020(at)X -4103(which)X -555 3374(transactions)N -959(complete.)X -1314(Since)X -1513(most)X -1688(transactions)X -2091(write)X -2276(only)X -2438(a)X -2494(few)X -2635(small)X -2828(records)X -3085(to)X -3167(the)X -3285(log,)X -3427(the)X -3545(last)X -3676(page)X -3848(of)X -3935(the)X -4053(log)X -4175(will)X -555 3464(be)N -658(\257ushed)X -916(once)X -1095(by)X -1202(every)X -1408(transaction)X -1787(which)X -2010(writes)X -2233(to)X -2322(it.)X -2433(In)X -2527(the)X -2652(naive)X -2853(implementation,)X -3402(these)X -3593(\257ushes)X -3841(would)X -4067(happen)X -555 3554(serially.)N -755 3677(LIBTP)N -1008(uses)X -3 f -1177(group)X -1412(commit)X -1 f -1702([DEWI84])X -2077(in)X -2170(order)X -2371(to)X -2464(amortize)X -2775(the)X -2903(cost)X -3062(of)X -3159(one)X -3305(synchronous)X -3740(disk)X -3903(write)X -4098(across)X -555 3767(multiple)N -851(transactions.)X -1304(Group)X -1539(commit)X -1812(provides)X -2117(a)X -2182(way)X -2345(for)X -2468(a)X -2533(group)X -2749(of)X -2845(transactions)X -3257(to)X -3348(commit)X -3621(simultaneously.)X -4174(The)X -555 3857(\256rst)N -709(several)X -967(transactions)X -1380(to)X -1472(commit)X -1745(write)X -1939(their)X -2115(changes)X -2403(to)X -2494(the)X -2621(in-memory)X -3006(log)X -3137(page,)X -3338(then)X -3505(sleep)X -3699(on)X -3808(a)X -3873(distinguished)X -555 3947(semaphore.)N -966(Later,)X -1179(a)X -1238(committing)X -1629(transaction)X -2004(\257ushes)X -2249(the)X -2370(page)X -2545(to)X -2630(disk,)X -2805(and)X -2943(wakes)X -3166(up)X -3268(all)X -3370(its)X -3467(sleeping)X -3756(peers.)X -3988(The)X -4135(point)X -555 4037(at)N -635(which)X -853(changes)X -1134(are)X -1255(actually)X -1531(written)X -1780(is)X -1855(determined)X -2238(by)X -2340(three)X -2523(thresholds.)X -2914(The)X -3061(\256rst)X -3207(is)X -3281(the)X -2 f -3400(group)X -3612(threshold)X -1 f -3935(and)X -4072(de\256nes)X -555 4127(the)N -674(minimum)X -1005(number)X -1271(of)X -1359(transactions)X -1763(which)X -1979(must)X -2154(be)X -2250(active)X -2462(in)X -2544(the)X -2662(system)X -2904(before)X -3130(transactions)X -3533(are)X -3652(forced)X -3878(to)X -3960(participate)X -555 4217(in)N -646(a)X -711(group)X -927(commit.)X -1240(The)X -1394(second)X -1646(is)X -1728(the)X -2 f -1855(wait)X -2021(threshold)X -1 f -2352(which)X -2577(is)X -2658(expressed)X -3003(as)X -3098(the)X -3224(percentage)X -3601(of)X -3696(active)X -3916(transactions)X -555 4307(waiting)N -826(to)X -919(be)X -1026(committed.)X -1439(The)X -1595(last)X -1737(is)X -1821(the)X -2 f -1950(logdelay)X -2257(threshold)X -1 f -2590(which)X -2816(indicates)X -3131(how)X -3299(much)X -3507(un\257ushed)X -3848(log)X -3980(should)X -4223(be)X -555 4397(allowed)N -829(to)X -911(accumulate)X -1297(before)X -1523(a)X -1579(waiting)X -1839(transaction's)X -2289(commit)X -2553(record)X -2779(is)X -2852(\257ushed.)X -755 4520(Group)N -981(commit)X -1246(can)X -1379(substantially)X -1803(improve)X -2090(performance)X -2517(for)X -2631(high-concurrency)X -3218(environments.)X -3714(If)X -3788(only)X -3950(a)X -4006(few)X -4147(tran-)X -555 4610(sactions)N -836(are)X -957(running,)X -1248(it)X -1314(is)X -1389(unlikely)X -1673(to)X -1757(improve)X -2046(things)X -2263(at)X -2343(all.)X -2485(The)X -2632(crossover)X -2962(point)X -3148(is)X -3223(the)X -3343(point)X -3529(at)X -3609(which)X -3827(the)X -3947(transaction)X -555 4700(commit)N -823(rate)X -968(is)X -1045(limited)X -1295(by)X -1399(the)X -1521(bandwidth)X -1883(of)X -1974(the)X -2096(device)X -2330(on)X -2434(which)X -2654(the)X -2776(log)X -2902(resides.)X -3189(If)X -3267(processes)X -3599(are)X -3722(trying)X -3937(to)X -4023(\257ush)X -4201(the)X -555 4790(log)N -677(faster)X -876(than)X -1034(the)X -1152(log)X -1274(disk)X -1427(can)X -1559(accept)X -1785(data,)X -1959(then)X -2117(group)X -2324(commit)X -2588(will)X -2732(increase)X -3016(the)X -3134(commit)X -3398(rate.)X -3 f -555 4976(4.3.)N -715(Kernel)X -971(Intervention)X -1418(for)X -1541(Synchronization)X -1 f -755 5099(Since)N -954(LIBTP)X -1197(uses)X -1356(data)X -1511(in)X -1594(shared)X -1825(memory)X -2113(\()X -2 f -2140(e.g.)X -1 f -2277(the)X -2395(lock)X -2553(table)X -2729(and)X -2865(buffer)X -3082(pool\))X -3271(it)X -3335(must)X -3510(be)X -3606(possible)X -3888(for)X -4002(a)X -4058(process)X -555 5189(to)N -640(acquire)X -900(exclusive)X -1226(access)X -1454(to)X -1538(shared)X -1770(data)X -1926(in)X -2010(order)X -2202(to)X -2286(prevent)X -2549(corruption.)X -2945(In)X -3034(addition,)X -3338(the)X -3458(process)X -3721(manager)X -4020(must)X -4197(put)X -555 5279(processes)N -886(to)X -971(sleep)X -1159(when)X -1356(the)X -1477(lock)X -1638(or)X -1728(buffer)X -1948(they)X -2109(request)X -2364(is)X -2440(in)X -2525(use)X -2655(by)X -2758(some)X -2950(other)X -3138(process.)X -3441(In)X -3530(the)X -3650(LIBTP)X -3894(implementa-)X -555 5385(tion)N -705(under)X -914(Ultrix)X -1131(4.0)X -7 s -5353(2)Y -10 s -5385(,)Y -1305(we)X -1424(use)X -1556(System)X -1816(V)X -1899(semaphores)X -2303(to)X -2390(provide)X -2660(this)X -2800(synchronization.)X -3377(Semaphores)X -3794(implemented)X -4237(in)X -555 5475(this)N -701(fashion)X -968(turn)X -1128(out)X -1261(to)X -1354(be)X -1461(an)X -1568(expensive)X -1920(choice)X -2161(for)X -2285(synchronization,)X -2847(because)X -3132(each)X -3310(access)X -3546(traps)X -3732(to)X -3824(the)X -3952(kernel)X -4183(and)X -8 s -10 f -555 5547(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)N -5 s -1 f -727 5625(2)N -8 s -763 5650(Ultrix)N -932(and)X -1040(DEC)X -1184(are)X -1277(trademarks)X -1576(of)X -1645(Digital)X -1839(Equipment)X -2136(Corporation.)X - -9 p -%%Page: 9 9 -8 s 8 xH 0 xS 1 f -10 s -3 f -1 f -555 630(executes)N -852(atomically)X -1210(there.)X -755 753(On)N -878(architectures)X -1314(that)X -1459(support)X -1724(atomic)X -1967(test-and-set,)X -2382(a)X -2443(much)X -2646(better)X -2854(choice)X -3089(would)X -3314(be)X -3415(to)X -3502(attempt)X -3767(to)X -3854(obtain)X -4079(a)X -4139(spin-)X -555 843(lock)N -714(with)X -877(a)X -934(test-and-set,)X -1345(and)X -1482(issue)X -1663(a)X -1720(system)X -1963(call)X -2100(only)X -2263(if)X -2333(the)X -2452(spinlock)X -2744(is)X -2818(unavailable.)X -3249(Since)X -3447(virtually)X -3738(all)X -3838(semaphores)X -4237(in)X -555 933(LIBTP)N -801(are)X -924(uncontested)X -1330(and)X -1469(are)X -1591(held)X -1752(for)X -1869(very)X -2035(short)X -2218(periods)X -2477(of)X -2567(time,)X -2752(this)X -2890(would)X -3113(improve)X -3403(performance.)X -3873(For)X -4007(example,)X -555 1023(processes)N -885(must)X -1062(acquire)X -1321(exclusive)X -1646(access)X -1874(to)X -1958(buffer)X -2177(pool)X -2341(metadata)X -2653(in)X -2737(order)X -2929(to)X -3013(\256nd)X -3159(and)X -3297(pin)X -3421(a)X -3479(buffer)X -3698(in)X -3781(shared)X -4012(memory.)X -555 1113(This)N -721(semaphore)X -1093(is)X -1170(requested)X -1502(most)X -1681(frequently)X -2034(in)X -2119(LIBTP.)X -2404(However,)X -2742(once)X -2917(it)X -2984(is)X -3060(acquired,)X -3380(only)X -3545(a)X -3604(few)X -3748(instructions)X -4144(must)X -555 1203(be)N -656(executed)X -966(before)X -1196(it)X -1264(is)X -1341(released.)X -1669(On)X -1791(one)X -1931(architecture)X -2335(for)X -2453(which)X -2673(we)X -2791(were)X -2972(able)X -3130(to)X -3216(gather)X -3441(detailed)X -3719(pro\256ling)X -4018(informa-)X -555 1293(tion,)N -729(the)X -857(cost)X -1015(of)X -1111(the)X -1238(semaphore)X -1615(calls)X -1791(accounted)X -2146(for)X -2269(25%)X -2445(of)X -2541(the)X -2668(total)X -2839(time)X -3010(spent)X -3208(updating)X -3517(the)X -3644(metadata.)X -4003(This)X -4174(was)X -555 1383(fairly)N -749(consistent)X -1089(across)X -1310(most)X -1485(of)X -1572(the)X -1690(critical)X -1933(sections.)X -755 1506(In)N -848(an)X -950(attempt)X -1216(to)X -1304(quantify)X -1597(the)X -1720(overhead)X -2040(of)X -2132(kernel)X -2358(synchronization,)X -2915(we)X -3034(ran)X -3162(tests)X -3329(on)X -3434(a)X -3495(version)X -3756(of)X -3848(4.3BSD-Reno)X -555 1596(which)N -786(had)X -937(been)X -1123(modi\256ed)X -1441(to)X -1537(support)X -1811(binary)X -2050(semaphore)X -2432(facilities)X -2742(similar)X -2998(to)X -3094(those)X -3297(described)X -3639(in)X -3735([POSIX91].)X -4174(The)X -555 1686(hardware)N -880(platform)X -1181(consisted)X -1504(of)X -1595(an)X -1695(HP300)X -1941(\(33MHz)X -2237(MC68030\))X -2612(workstation)X -3014(with)X -3180(16MBytes)X -3537(of)X -3628(main)X -3812(memory,)X -4123(and)X -4263(a)X -555 1776(600MByte)N -920(HP7959)X -1205(SCSI)X -1396(disk)X -1552(\(17)X -1682(ms)X -1798(average)X -2072(seek)X -2237(time\).)X -2468(We)X -2602(ran)X -2727(three)X -2910(sets)X -3052(of)X -3141(comparisons)X -3568(which)X -3786(are)X -3907(summarized)X -555 1866(in)N -645(\256gure)X -860(\256ve.)X -1028(In)X -1123(each)X -1299(comparison)X -1701(we)X -1823(ran)X -1954(two)X -2102(tests,)X -2292(one)X -2436(using)X -2637(hardware)X -2965(spinlocks)X -3295(and)X -3438(the)X -3563(other)X -3755(using)X -3955(kernel)X -4183(call)X -555 1956(synchronization.)N -1135(Since)X -1341(the)X -1467(test)X -1606(was)X -1758(run)X -1892(single-user,)X -2291(none)X -2474(of)X -2568(the)X -2693(the)X -2818(locks)X -3014(were)X -3198(contested.)X -3568(In)X -3662(the)X -3787(\256rst)X -3938(two)X -4085(sets)X -4232(of)X -555 2046(tests,)N -743(we)X -863(ran)X -992(the)X -1116(full)X -1253(transaction)X -1631(processing)X -2000(benchmark)X -2383(described)X -2717(in)X -2805(section)X -3058(5.1.)X -3223(In)X -3315(one)X -3456(case)X -3620(we)X -3739(ran)X -3867(with)X -4034(both)X -4201(the)X -555 2136(database)N -854(and)X -992(log)X -1116(on)X -1218(the)X -1338(same)X -1525(disk)X -1680(\(1)X -1769(Disk\))X -1969(and)X -2107(in)X -2191(the)X -2311(second,)X -2576(we)X -2692(ran)X -2817(with)X -2981(the)X -3101(database)X -3400(and)X -3538(log)X -3661(on)X -3762(separate)X -4047(disks)X -4232(\(2)X -555 2226(Disk\).)N -800(In)X -894(the)X -1019(last)X -1157(test,)X -1315(we)X -1436(wanted)X -1695(to)X -1784(create)X -2004(a)X -2067(CPU)X -2249(bound)X -2476(environment,)X -2928(so)X -3026(we)X -3146(used)X -3319(a)X -3381(database)X -3684(small)X -3883(enough)X -4145(to)X -4233(\256t)X -555 2316(completely)N -941(in)X -1033(the)X -1161(cache)X -1375(and)X -1521(issued)X -1751(read-only)X -2089(transactions.)X -2541(The)X -2695(results)X -2933(in)X -3024(\256gure)X -3240(\256ve)X -3389(express)X -3659(the)X -3786(kernel)X -4016(call)X -4161(syn-)X -555 2406(chronization)N -980(performance)X -1411(as)X -1502(a)X -1562(percentage)X -1935(of)X -2026(the)X -2148(spinlock)X -2443(performance.)X -2914(For)X -3049(example,)X -3365(in)X -3451(the)X -3573(1)X -3637(disk)X -3794(case,)X -3977(the)X -4098(kernel)X -555 2496(call)N -697(implementation)X -1225(achieved)X -1537(4.4)X -1662(TPS)X -1824(\(transactions)X -2259(per)X -2387(second\))X -2662(while)X -2865(the)X -2988(semaphore)X -3361(implementation)X -3888(achieved)X -4199(4.6)X -555 2586(TPS,)N -735(and)X -874(the)X -995(relative)X -1259(performance)X -1689(of)X -1779(the)X -1900(kernel)X -2123(synchronization)X -2657(is)X -2732(96%)X -2901(that)X -3043(of)X -3132(the)X -3252(spinlock)X -3545(\(100)X -3714(*)X -3776(4.4)X -3898(/)X -3942(4.6\).)X -4111(There)X -555 2676(are)N -674(two)X -814(striking)X -1078(observations)X -1503(from)X -1679(these)X -1864(results:)X -10 f -635 2799(g)N -1 f -755(even)X -927(when)X -1121(the)X -1239(system)X -1481(is)X -1554(disk)X -1707(bound,)X -1947(the)X -2065(CPU)X -2240(cost)X -2389(of)X -2476(synchronization)X -3008(is)X -3081(noticeable,)X -3451(and)X -10 f -635 2922(g)N -1 f -755(when)X -949(we)X -1063(are)X -1182(CPU)X -1357(bound,)X -1597(the)X -1715(difference)X -2062(is)X -2135(dramatic)X -2436(\(67%\).)X -3 f -555 3108(4.4.)N -715(Transaction)X -1148(Protected)X -1499(Access)X -1747(Methods)X -1 f -755 3231(The)N -903(B-tree)X -1127(and)X -1266(\256xed)X -1449(length)X -1671(recno)X -1872(\(record)X -2127(number\))X -2421(access)X -2649(methods)X -2942(have)X -3116(been)X -3290(modi\256ed)X -3596(to)X -3680(provide)X -3947(transaction)X -555 3321(protection.)N -941(Whereas)X -1244(the)X -1363(previously)X -1722(published)X -2054(interface)X -2357(to)X -2440(the)X -2559(access)X -2786(routines)X -3065(had)X -3202(separate)X -3487(open)X -3664(calls)X -3832(for)X -3946(each)X -4114(of)X -4201(the)X -10 f -555 3507(h)N -579(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)X -1 Dt -2978 5036 MXY - 2978 5036 lineto - 2978 4662 lineto - 3093 4662 lineto - 3093 5036 lineto - 2978 5036 lineto -closepath 21 2978 4662 3093 5036 Dp -2518 MX - 2518 5036 lineto - 2518 3960 lineto - 2633 3960 lineto - 2633 5036 lineto - 2518 5036 lineto -closepath 3 2518 3960 2633 5036 Dp -2059 MX - 2059 5036 lineto - 2059 3946 lineto - 2174 3946 lineto - 2174 5036 lineto - 2059 5036 lineto -closepath 1 2059 3946 2174 5036 Dp -3 f -7 s -2912 5141(Read-only)N -1426 3767(of)N -1487(Spinlock)X -1710(Throughput)X -1480 3710(Throughput)N -1786(as)X -1850(a)X -1892(%)X -11 s -1670 4843(20)N -1670 4614(40)N -1670 4384(60)N -1670 4155(80)N -1648 3925(100)N -7 s -2041 5141(1)N -2083(Disk)X -2490(2)X -2532(Disks)X -5 Dt -1829 5036 MXY -1494 0 Dl -4 Ds -1 Dt -1829 4806 MXY -1494 0 Dl -1829 4577 MXY -1494 0 Dl -1829 4347 MXY -1494 0 Dl -1829 4118 MXY -1494 0 Dl -1829 3888 MXY -1494 0 Dl -3 Dt --1 Ds -8 s -555 5360(Figure)N -753(5:)X -823(Kernel)X -1028(Overhead)X -1315(for)X -1413(System)X -1625(Call)X -1756(Synchronization.)X -1 f -2254(The)X -2370(performance)X -2708(of)X -2778(the)X -2873(kernel)X -3049(call)X -3158(synchronization)X -3583(is)X -3643(expressed)X -3911(as)X -3980(a)X -4024(percentage)X -555 5450(of)N -625(the)X -720(spinlock)X -954(synchronization)X -1379(performance.)X -1749(In)X -1819(disk)X -1943(bound)X -2120(cases)X -2271(\(1)X -2341(Disk)X -2479(and)X -2588(2)X -2637(Disks\),)X -2837(we)X -2928(see)X -3026(that)X -3139(4-6%)X -3294(of)X -3364(the)X -3459(performance)X -3797(is)X -3857(lost)X -3966(due)X -4074(to)X -4140(kernel)X -555 5540(calls)N -688(while)X -846(in)X -912(the)X -1006(CPU)X -1147(bound)X -1323(case,)X -1464(we)X -1554(have)X -1690(lost)X -1799(67%)X -1932(of)X -2001(the)X -2095(performance)X -2432(due)X -2540(to)X -2606(kernel)X -2781(calls.)X - -10 p -%%Page: 10 10 -8 s 8 xH 0 xS 1 f -10 s -3 f -1 f -555 630(access)N -781(methods,)X -1092(we)X -1206(now)X -1364(have)X -1536(an)X -1632(integrated)X -1973(open)X -2149(call)X -2285(with)X -2447(the)X -2565(following)X -2896(calling)X -3134(conventions:)X -7 f -715 753(DB)N -859(*dbopen)X -1243(\(const)X -1579(char)X -1819(*file,)X -2155(int)X -2347(flags,)X -2683(int)X -2875(mode,)X -3163(DBTYPE)X -3499(type,)X -1291 843(int)N -1483(dbflags,)X -1915(const)X -2203(void)X -2443(*openinfo\))X -1 f -555 966(where)N -2 f -774(\256le)X -1 f -894(is)X -969(the)X -1089(name)X -1285(of)X -1374(the)X -1494(\256le)X -1618(being)X -1818(opened,)X -2 f -2092(\257ags)X -1 f -2265(and)X -2 f -2402(mode)X -1 f -2597(are)X -2717(the)X -2836(standard)X -3129(arguments)X -3484(to)X -3 f -3567(open)X -1 f -3731(\(2\),)X -2 f -3866(type)X -1 f -4021(is)X -4095(one)X -4232(of)X -555 1056(the)N -680(access)X -913(method)X -1180(types,)X -2 f -1396(db\257ags)X -1 f -1654(indicates)X -1966(the)X -2091(mode)X -2296(of)X -2390(the)X -2515(buffer)X -2739(pool)X -2907(and)X -3049(transaction)X -3427(protection,)X -3798(and)X -2 f -3940(openinfo)X -1 f -4246(is)X -555 1146(the)N -681(access)X -915(method)X -1183(speci\256c)X -1456(information.)X -1902(Currently,)X -2257(the)X -2383(possible)X -2673(values)X -2906(for)X -2 f -3028(db\257ags)X -1 f -3287(are)X -3414(DB_SHARED)X -3912(and)X -4055(DB_TP)X -555 1236(indicating)N -895(that)X -1035(buffers)X -1283(should)X -1516(be)X -1612(kept)X -1770(in)X -1852(a)X -1908(shared)X -2138(buffer)X -2355(pool)X -2517(and)X -2653(that)X -2793(the)X -2911(\256le)X -3033(should)X -3266(be)X -3362(transaction)X -3734(protected.)X -755 1359(The)N -900(modi\256cations)X -1355(required)X -1643(to)X -1725(add)X -1861(transaction)X -2233(protection)X -2578(to)X -2660(an)X -2756(access)X -2982(method)X -3242(are)X -3361(quite)X -3541(simple)X -3774(and)X -3910(localized.)X -715 1482(1.)N -795(Replace)X -1074(\256le)X -2 f -1196(open)X -1 f -1372(with)X -2 f -1534(buf_open)X -1 f -1832(.)X -715 1572(2.)N -795(Replace)X -1074(\256le)X -2 f -1196(read)X -1 f -1363(and)X -2 f -1499(write)X -1 f -1683(calls)X -1850(with)X -2012(buffer)X -2229(manager)X -2526(calls)X -2693(\()X -2 f -2720(buf_get)X -1 f -(,)S -2 f -3000(buf_unpin)X -1 f -3324(\).)X -715 1662(3.)N -795(Precede)X -1070(buffer)X -1287(manager)X -1584(calls)X -1751(with)X -1913(an)X -2009(appropriate)X -2395(\(read)X -2581(or)X -2668(write\))X -2880(lock)X -3038(call.)X -715 1752(4.)N -795(Before)X -1034(updates,)X -1319(issue)X -1499(a)X -1555(logging)X -1819(operation.)X -715 1842(5.)N -795(After)X -985(data)X -1139(have)X -1311(been)X -1483(accessed,)X -1805(release)X -2049(the)X -2167(buffer)X -2384(manager)X -2681(pin.)X -715 1932(6.)N -795(Provide)X -1064(undo/redo)X -1409(code)X -1581(for)X -1695(each)X -1863(type)X -2021(of)X -2108(log)X -2230(record)X -2456(de\256ned.)X -555 2071(The)N -702(following)X -1035(code)X -1209(fragments)X -1552(show)X -1743(how)X -1903(to)X -1987(transaction)X -2361(protect)X -2606(several)X -2856(updates)X -3123(to)X -3206(a)X -3263(B-tree.)X -7 s -3484 2039(3)N -10 s -3533 2071(In)N -3621(the)X -3740(unprotected)X -4140(case,)X -555 2161(an)N -652(open)X -829(call)X -966(is)X -1040(followed)X -1346(by)X -1447(a)X -1504(read)X -1664(call)X -1801(to)X -1884(obtain)X -2105(the)X -2224(meta-data)X -2562(for)X -2677(the)X -2796(B-tree.)X -3058(Instead,)X -3331(we)X -3446(issue)X -3627(an)X -3724(open)X -3901(to)X -3984(the)X -4102(buffer)X -555 2251(manager)N -852(to)X -934(obtain)X -1154(a)X -1210(\256le)X -1332(id)X -1414(and)X -1550(a)X -1606(buffer)X -1823(request)X -2075(to)X -2157(obtain)X -2377(the)X -2495(meta-data)X -2832(as)X -2919(shown)X -3148(below.)X -7 f -715 2374(char)N -955(*path;)X -715 2464(int)N -907(fid,)X -1147(flags,)X -1483(len,)X -1723(mode;)X -715 2644(/*)N -859(Obtain)X -1195(a)X -1291(file)X -1531(id)X -1675(with)X -1915(which)X -2203(to)X -2347(access)X -2683(the)X -2875(buffer)X -3211(pool)X -3451(*/)X -715 2734(fid)N -907(=)X -1003(buf_open\(path,)X -1723(flags,)X -2059(mode\);)X -715 2914(/*)N -859(Read)X -1099(the)X -1291(meta)X -1531(data)X -1771(\(page)X -2059(0\))X -2203(for)X -2395(the)X -2587(B-tree)X -2923(*/)X -715 3004(if)N -859(\(tp_lock\(fid,)X -1531(0,)X -1675(READ_LOCK\)\))X -1003 3094(return)N -1339(error;)X -715 3184(meta_data_ptr)N -1387(=)X -1483(buf_get\(fid,)X -2107(0,)X -2251(BF_PIN,)X -2635(&len\);)X -1 f -555 3307(The)N -714(BF_PIN)X -1014(argument)X -1350(to)X -2 f -1445(buf_get)X -1 f -1718(indicates)X -2036(that)X -2189(we)X -2316(wish)X -2500(to)X -2595(leave)X -2798(this)X -2946(page)X -3131(pinned)X -3382(in)X -3477(memory)X -3777(so)X -3881(that)X -4034(it)X -4111(is)X -4197(not)X -555 3397(swapped)N -862(out)X -990(while)X -1194(we)X -1314(are)X -1439(accessing)X -1772(it.)X -1881(The)X -2031(last)X -2167(argument)X -2495(to)X -2 f -2582(buf_get)X -1 f -2847(returns)X -3095(the)X -3218(number)X -3488(of)X -3580(bytes)X -3774(on)X -3879(the)X -4002(page)X -4179(that)X -555 3487(were)N -732(valid)X -912(so)X -1003(that)X -1143(the)X -1261(access)X -1487(method)X -1747(may)X -1905(initialize)X -2205(the)X -2323(page)X -2495(if)X -2564(necessary.)X -755 3610(Next,)N -955(consider)X -1251(inserting)X -1555(a)X -1615(record)X -1845(on)X -1949(a)X -2009(particular)X -2341(page)X -2517(of)X -2608(a)X -2668(B-tree.)X -2932(In)X -3022(the)X -3143(unprotected)X -3545(case,)X -3727(we)X -3844(read)X -4006(the)X -4127(page,)X -555 3700(call)N -2 f -693(_bt_insertat)X -1 f -1079(,)X -1121(and)X -1258(write)X -1444(the)X -1563(page.)X -1776(Instead,)X -2049(we)X -2164(lock)X -2323(the)X -2442(page,)X -2635(request)X -2888(the)X -3007(buffer,)X -3245(log)X -3368(the)X -3487(change,)X -3756(modify)X -4008(the)X -4127(page,)X -555 3790(and)N -691(release)X -935(the)X -1053(buffer.)X -7 f -715 3913(int)N -907(fid,)X -1147(len,)X -1387(pageno;)X -1867(/*)X -2011(Identifies)X -2539(the)X -2731(buffer)X -3067(*/)X -715 4003(int)N -907(index;)X -1867(/*)X -2011(Location)X -2443(at)X -2587(which)X -2875(to)X -3019(insert)X -3355(the)X -3547(new)X -3739(pair)X -3979(*/)X -715 4093(DBT)N -907(*keyp,)X -1243(*datap;)X -1867(/*)X -2011(Key/Data)X -2443(pair)X -2683(to)X -2827(be)X -2971(inserted)X -3403(*/)X -715 4183(DATUM)N -1003(*d;)X -1867(/*)X -2011(Key/data)X -2443(structure)X -2923(to)X -3067(insert)X -3403(*/)X -715 4363(/*)N -859(Lock)X -1099(and)X -1291(request)X -1675(the)X -1867(buffer)X -2203(*/)X -715 4453(if)N -859(\(tp_lock\(fid,)X -1531(pageno,)X -1915(WRITE_LOCK\)\))X -1003 4543(return)N -1339(error;)X -715 4633(buffer_ptr)N -1243(=)X -1339(buf_get\(fid,)X -1963(pageno,)X -2347(BF_PIN,)X -2731(&len\);)X -715 4813(/*)N -859(Log)X -1051(and)X -1243(perform)X -1627(the)X -1819(update)X -2155(*/)X -715 4903(log_insdel\(BTREE_INSERT,)N -1915(fid,)X -2155(pageno,)X -2539(keyp,)X -2827(datap\);)X -715 4993(_bt_insertat\(buffer_ptr,)N -1915(d,)X -2059(index\);)X -715 5083(buf_unpin\(buffer_ptr\);)N -1 f -555 5206(Succinctly,)N -942(the)X -1068(algorithm)X -1407(for)X -1529(turning)X -1788(unprotected)X -2195(code)X -2375(into)X -2527(protected)X -2854(code)X -3034(is)X -3115(to)X -3205(replace)X -3466(read)X -3633(operations)X -3995(with)X -2 f -4165(lock)X -1 f -555 5296(and)N -2 f -691(buf_get)X -1 f -951(operations)X -1305(and)X -1441(write)X -1626(operations)X -1980(with)X -2 f -2142(log)X -1 f -2264(and)X -2 f -2400(buf_unpin)X -1 f -2744(operations.)X -8 s -10 f -555 5458(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)N -5 s -1 f -727 5536(3)N -8 s -766 5561(The)N -884(following)X -1152(code)X -1291(fragments)X -1565(are)X -1661(examples,)X -1937(but)X -2038(do)X -2120(not)X -2220(de\256ne)X -2394(the)X -2490(\256nal)X -2622(interface.)X -2894(The)X -3011(\256nal)X -3143(interface)X -3383(will)X -3501(be)X -3579(determined)X -3884(after)X -4018(LIBTP)X -4214(has)X -555 5633(been)N -691(fully)X -828(integrated)X -1099(with)X -1229(the)X -1323(most)X -1464(recent)X -3 f -1635(db)X -1 f -1707(\(3\))X -1797(release)X -1989(from)X -2129(the)X -2223(Computer)X -2495(Systems)X -2725(Research)X -2974(Group)X -3153(at)X -3215(University)X -3501(of)X -3570(California,)X -3861(Berkeley.)X - -11 p -%%Page: 11 11 -8 s 8 xH 0 xS 1 f -10 s -3 f -555 630(5.)N -655(Performance)X -1 f -755 753(In)N -845(this)X -983(section,)X -1253(we)X -1370(present)X -1625(the)X -1746(results)X -1978(of)X -2067(two)X -2209(very)X -2374(different)X -2673(benchmarks.)X -3103(The)X -3250(\256rst)X -3396(is)X -3471(an)X -3569(online)X -3791(transaction)X -4165(pro-)X -555 843(cessing)N -824(benchmark,)X -1234(similar)X -1489(to)X -1584(the)X -1715(standard)X -2020(TPCB,)X -2272(but)X -2407(has)X -2547(been)X -2732(adapted)X -3015(to)X -3110(run)X -3250(in)X -3345(a)X -3414(desktop)X -3696(environment.)X -4174(The)X -555 933(second)N -798(emulates)X -1103(a)X -1159(computer-aided)X -1683(design)X -1912(environment)X -2337(and)X -2473(provides)X -2769(more)X -2954(complex)X -3250(query)X -3453(processing.)X -3 f -555 1119(5.1.)N -715(Transaction)X -1148(Processing)X -1533(Benchmark)X -1 f -755 1242(For)N -887(this)X -1023(section,)X -1291(all)X -1392(performance)X -1820(numbers)X -2117(shown)X -2346(except)X -2576(for)X -2690(the)X -2808(commercial)X -3207(database)X -3504(system)X -3746(were)X -3923(obtained)X -4219(on)X -555 1332(a)N -614(DECstation)X -1009(5000/200)X -1333(with)X -1497(32MBytes)X -1852(of)X -1941(memory)X -2230(running)X -2501(Ultrix)X -2714(V4.0,)X -2914(accessing)X -3244(a)X -3302(DEC)X -3484(RZ57)X -3688(1GByte)X -3959(disk)X -4114(drive.)X -555 1422(The)N -720(commercial)X -1139(relational)X -1482(database)X -1799(system)X -2061(tests)X -2242(were)X -2438(run)X -2584(on)X -2703(a)X -2778(comparable)X -3192(machine,)X -3523(a)X -3598(Sparcstation)X -4033(1+)X -4157(with)X -555 1512(32MBytes)N -915(memory)X -1209(and)X -1352(a)X -1415(1GByte)X -1691(external)X -1976(disk)X -2135(drive.)X -2366(The)X -2517(database,)X -2840(binaries)X -3120(and)X -3262(log)X -3390(resided)X -3648(on)X -3754(the)X -3878(same)X -4069(device.)X -555 1602(Reported)N -869(times)X -1062(are)X -1181(the)X -1299(means)X -1524(of)X -1611(\256ve)X -1751(tests)X -1913(and)X -2049(have)X -2221(standard)X -2513(deviations)X -2862(within)X -3086(two)X -3226(percent)X -3483(of)X -3570(the)X -3688(mean.)X -755 1725(The)N -905(test)X -1041(database)X -1343(was)X -1493(con\256gured)X -1861(according)X -2203(to)X -2290(the)X -2413(TPCB)X -2637(scaling)X -2889(rules)X -3070(for)X -3189(a)X -3250(10)X -3355(transaction)X -3732(per)X -3860(second)X -4108(\(TPS\))X -555 1815(system)N -817(with)X -999(1,000,000)X -1359(account)X -1649(records,)X -1946(100)X -2106(teller)X -2311(records,)X -2607(and)X -2762(10)X -2881(branch)X -3139(records.)X -3455(Where)X -3709(TPS)X -3885(numbers)X -4200(are)X -555 1905(reported,)N -865(we)X -981(are)X -1102(running)X -1373(a)X -1431(modi\256ed)X -1737(version)X -1995(of)X -2084(the)X -2203(industry)X -2486(standard)X -2779(transaction)X -3152(processing)X -3516(benchmark,)X -3914(TPCB.)X -4174(The)X -555 1995(TPCB)N -780(benchmark)X -1163(simulates)X -1491(a)X -1553(withdrawal)X -1940(performed)X -2301(by)X -2407(a)X -2469(hypothetical)X -2891(teller)X -3082(at)X -3166(a)X -3228(hypothetical)X -3650(bank.)X -3872(The)X -4022(database)X -555 2085(consists)N -831(of)X -921(relations)X -1220(\(\256les\))X -1430(for)X -1547(accounts,)X -1871(branches,)X -2200(tellers,)X -2439(and)X -2578(history.)X -2863(For)X -2997(each)X -3168(transaction,)X -3563(the)X -3684(account,)X -3976(teller,)X -4183(and)X -555 2175(branch)N -795(balances)X -1093(must)X -1269(be)X -1366(updated)X -1641(to)X -1724(re\257ect)X -1946(the)X -2065(withdrawal)X -2447(and)X -2584(a)X -2640(history)X -2882(record)X -3108(is)X -3181(written)X -3428(which)X -3644(contains)X -3931(the)X -4049(account)X -555 2265(id,)N -657(branch)X -896(id,)X -998(teller)X -1183(id,)X -1285(and)X -1421(the)X -1539(amount)X -1799(of)X -1886(the)X -2004(withdrawal)X -2385([TPCB90].)X -755 2388(Our)N -914(implementation)X -1450(of)X -1551(the)X -1683(benchmark)X -2074(differs)X -2317(from)X -2506(the)X -2637(speci\256cation)X -3075(in)X -3170(several)X -3431(aspects.)X -3736(The)X -3894(speci\256cation)X -555 2478(requires)N -840(that)X -985(the)X -1108(database)X -1410(keep)X -1587(redundant)X -1933(logs)X -2091(on)X -2196(different)X -2498(devices,)X -2784(but)X -2911(we)X -3030(use)X -3162(a)X -3223(single)X -3439(log.)X -3606(Furthermore,)X -4052(all)X -4157(tests)X -555 2568(were)N -734(run)X -863(on)X -965(a)X -1023(single,)X -1256(centralized)X -1631(system)X -1875(so)X -1968(there)X -2151(is)X -2226(no)X -2328(notion)X -2553(of)X -2641(remote)X -2885(accesses.)X -3219(Finally,)X -3486(we)X -3601(calculated)X -3948(throughput)X -555 2658(by)N -662(dividing)X -955(the)X -1080(total)X -1249(elapsed)X -1517(time)X -1686(by)X -1793(the)X -1918(number)X -2190(of)X -2284(transactions)X -2694(processed)X -3038(rather)X -3253(than)X -3418(by)X -3525(computing)X -3894(the)X -4018(response)X -555 2748(time)N -717(for)X -831(each)X -999(transaction.)X -755 2871(The)N -912(performance)X -1351(comparisons)X -1788(focus)X -1993(on)X -2104(traditional)X -2464(Unix)X -2655(techniques)X -3029(\(unprotected,)X -3486(using)X -3 f -3690(\257ock)X -1 f -3854(\(2\))X -3979(and)X -4126(using)X -3 f -555 2961(fsync)N -1 f -733(\(2\)\))X -884(and)X -1030(a)X -1096(commercial)X -1504(relational)X -1836(database)X -2142(system.)X -2433(Well-behaved)X -2913(applications)X -3329(using)X -3 f -3531(\257ock)X -1 f -3695(\(2\))X -3818(are)X -3946(guaranteed)X -555 3051(that)N -704(concurrent)X -1077(processes')X -1441(updates)X -1715(do)X -1824(not)X -1955(interact)X -2225(with)X -2396(one)X -2541(another,)X -2831(but)X -2962(no)X -3070(guarantees)X -3442(about)X -3648(atomicity)X -3978(are)X -4105(made.)X -555 3141(That)N -731(is,)X -833(if)X -911(the)X -1038(system)X -1289(crashes)X -1555(in)X -1646(mid-transaction,)X -2198(only)X -2369(parts)X -2554(of)X -2649(that)X -2797(transaction)X -3177(will)X -3329(be)X -3433(re\257ected)X -3738(in)X -3828(the)X -3954 0.3125(after-crash)AX -555 3231(state)N -725(of)X -815(the)X -936(database.)X -1276(The)X -1424(use)X -1554(of)X -3 f -1643(fsync)X -1 f -1821(\(2\))X -1937(at)X -2017(transaction)X -2391(commit)X -2657(time)X -2821(provides)X -3119(guarantees)X -3485(of)X -3574(durability)X -3907(after)X -4077(system)X -555 3321(failure.)N -825(However,)X -1160(there)X -1341(is)X -1414(no)X -1514(mechanism)X -1899(to)X -1981(perform)X -2260(transaction)X -2632(abort.)X -3 f -555 3507(5.1.1.)N -775(Single-User)X -1191(Tests)X -1 f -755 3630(These)N -978(tests)X -1151(compare)X -1459(LIBTP)X -1712(in)X -1804(a)X -1870(variety)X -2123(of)X -2220(con\256gurations)X -2708(to)X -2800(traditional)X -3159(UNIX)X -3390(solutions)X -3708(and)X -3854(a)X -3920(commercial)X -555 3720(relational)N -884(database)X -1187(system)X -1435(\(RDBMS\).)X -1814(To)X -1929(demonstrate)X -2347(the)X -2471(server)X -2694(architecture)X -3100(we)X -3220(built)X -3392(a)X -3454(front)X -3636(end)X -3777(test)X -3913(process)X -4179(that)X -555 3810(uses)N -732(TCL)X -922([OUST90])X -1304(to)X -1405(parse)X -1614(database)X -1930(access)X -2175(commands)X -2561(and)X -2716(call)X -2870(the)X -3006(database)X -3321(access)X -3565(routines.)X -3901(In)X -4006(one)X -4160(case)X -555 3900(\(SERVER\),)N -956(frontend)X -1249(and)X -1386(backend)X -1675(processes)X -2004(were)X -2181(created)X -2434(which)X -2650(communicated)X -3142(via)X -3260(an)X -3356(IP)X -3447(socket.)X -3712(In)X -3799(the)X -3917(second)X -4160(case)X -555 3990(\(TCL\),)N -802(a)X -860(single)X -1073(process)X -1336(read)X -1497(queries)X -1751(from)X -1929(standard)X -2223(input,)X -2429(parsed)X -2660(them,)X -2861(and)X -2998(called)X -3211(the)X -3330(database)X -3628(access)X -3855(routines.)X -4174(The)X -555 4080(performance)N -987(difference)X -1338(between)X -1630(the)X -1752(TCL)X -1927(and)X -2067(SERVER)X -2397(tests)X -2563(quanti\256es)X -2898(the)X -3020(communication)X -3542(overhead)X -3861(of)X -3952(the)X -4074(socket.)X -555 4170(The)N -732(RDBMS)X -1063(implementation)X -1617(used)X -1816(embedded)X -2198(SQL)X -2401(in)X -2515(C)X -2620(with)X -2814(stored)X -3062(database)X -3391(procedures.)X -3835(Therefore,)X -4224(its)X -555 4260(con\256guration)N -1003(is)X -1076(a)X -1132(hybrid)X -1361(of)X -1448(the)X -1566(single)X -1777(process)X -2038(architecture)X -2438(and)X -2574(the)X -2692(server)X -2909(architecture.)X -3349(The)X -3494(graph)X -3697(in)X -3779(\256gure)X -3986(six)X -4099(shows)X -555 4350(a)N -611(comparison)X -1005(of)X -1092(the)X -1210(following)X -1541(six)X -1654(con\256gurations:)X -1126 4506(LIBTP)N -1552(Uses)X -1728(the)X -1846(LIBTP)X -2088(library)X -2322(in)X -2404(a)X -2460(single)X -2671(application.)X -1126 4596(TCL)N -1552(Uses)X -1728(the)X -1846(LIBTP)X -2088(library)X -2322(in)X -2404(a)X -2460(single)X -2671(application,)X -3067(requires)X -3346(query)X -3549(parsing.)X -1126 4686(SERVER)N -1552(Uses)X -1728(the)X -1846(LIBTP)X -2088(library)X -2322(in)X -2404(a)X -2460(server)X -2677(con\256guration,)X -3144(requires)X -3423(query)X -3626(parsing.)X -1126 4776(NOTP)N -1552(Uses)X -1728(no)X -1828(locking,)X -2108(logging,)X -2392(or)X -2479(concurrency)X -2897(control.)X -1126 4866(FLOCK)N -1552(Uses)X -3 f -1728(\257ock)X -1 f -1892(\(2\))X -2006(for)X -2120(concurrency)X -2538(control)X -2785(and)X -2921(nothing)X -3185(for)X -3299(durability.)X -1126 4956(FSYNC)N -1552(Uses)X -3 f -1728(fsync)X -1 f -1906(\(2\))X -2020(for)X -2134(durability)X -2465(and)X -2601(nothing)X -2865(for)X -2979(concurrency)X -3397(control.)X -1126 5046(RDBMS)N -1552(Uses)X -1728(a)X -1784(commercial)X -2183(relational)X -2506(database)X -2803(system.)X -755 5235(The)N -902(results)X -1133(show)X -1324(that)X -1466(LIBTP,)X -1730(both)X -1894(in)X -1978(the)X -2098(procedural)X -2464(and)X -2602(parsed)X -2834(environments,)X -3312(is)X -3387(competitive)X -3787(with)X -3951(a)X -4009(commer-)X -555 5325(cial)N -692(system)X -935(\(comparing)X -1326(LIBTP,)X -1589(TCL,)X -1781(and)X -1917(RDBMS\).)X -2263(Compared)X -2617(to)X -2699(existing)X -2972(UNIX)X -3193(solutions,)X -3521(LIBTP)X -3763(is)X -3836(approximately)X -555 5415(15%)N -738(slower)X -988(than)X -1162(using)X -3 f -1371(\257ock)X -1 f -1535(\(2\))X -1665(or)X -1768(no)X -1884(protection)X -2245(but)X -2383(over)X -2562(80%)X -2745(better)X -2964(than)X -3137(using)X -3 f -3345(fsync)X -1 f -3523(\(2\))X -3652(\(comparing)X -4057(LIBTP,)X -555 5505(FLOCK,)N -857(NOTP,)X -1106(and)X -1242(FSYNC\).)X - -12 p -%%Page: 12 12 -10 s 10 xH 0 xS 1 f -3 f -8 s -3500 2184(RDBMS)N -1 Dt -3553 2085 MXY - 3553 2085 lineto - 3676 2085 lineto - 3676 1351 lineto - 3553 1351 lineto - 3553 2085 lineto -closepath 16 3553 1351 3676 2085 Dp -2018 2184(SERVER)N -1720 1168 MXY -0 917 Dl -122 0 Dl -0 -917 Dl --122 0 Dl -1715 2184(TCL)N -2087 1534 MXY - 2087 1534 lineto - 2209 1534 lineto - 2209 2085 lineto - 2087 2085 lineto - 2087 1534 lineto -closepath 12 2087 1534 2209 2085 Dp -3187 MX - 3187 1534 lineto - 3309 1534 lineto - 3309 2085 lineto - 3187 2085 lineto - 3187 1534 lineto -closepath 19 3187 1534 3309 2085 Dp -3142 2184(FSYNC)N -2425(NOTP)X -2453 955 MXY - 2453 955 lineto - 2576 955 lineto - 2576 2085 lineto - 2453 2085 lineto - 2453 955 lineto -closepath 21 2453 955 2576 2085 Dp -2820 1000 MXY - 2820 1000 lineto - 2942 1000 lineto - 2942 2085 lineto - 2820 2085 lineto - 2820 1000 lineto -closepath 14 2820 1000 2942 2085 Dp -5 Dt -1231 2085 MXY -2567 0 Dl -4 Ds -1 Dt -1231 1840 MXY -2567 0 Dl -1231 1596 MXY -2567 0 Dl -1231 1351 MXY -2567 0 Dl -1231 1108 MXY -2567 0 Dl -1231 863 MXY -2567 0 Dl -11 s -1087 1877(2)N -1087 1633(4)N -1087 1388(6)N -1087 1145(8)N -1065 900(10)N -1028 763(TPS)N --1 Ds -1353 2085 MXY - 1353 2085 lineto - 1353 1151 lineto - 1476 1151 lineto - 1476 2085 lineto - 1353 2085 lineto -closepath 3 1353 1151 1476 2085 Dp -8 s -1318 2184(LIBTP)N -2767(FLOCK)X -3 Dt --1 Ds -10 s -1597 2399(Figure)N -1844(6:)X -1931(Single-User)X -2347(Performance)X -2814(Comparison.)X -1 f -10 f -555 2579(h)N -579(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)X -3 f -555 2855(5.1.2.)N -775(Multi-User)X -1174(Tests)X -1 f -755 2978(While)N -975(the)X -1097(single-user)X -1473(tests)X -1639(form)X -1819(a)X -1878(basis)X -2061(for)X -2178(comparing)X -2544(LIBTP)X -2789(to)X -2874(other)X -3062(systems,)X -3358(our)X -3488(goal)X -3649(in)X -3734(multi-user)X -4086(testing)X -555 3068(was)N -714(to)X -810(analyze)X -1089(its)X -1197(scalability.)X -1579(To)X -1701(this)X -1849(end,)X -2018(we)X -2145(have)X -2330(run)X -2470(the)X -2601(benchmark)X -2991(in)X -3086(three)X -3280(modes,)X -3542(the)X -3673(normal)X -3933(disk)X -4099(bound)X -555 3158(con\256guration)N -1010(\(\256gure)X -1252(seven\),)X -1510(a)X -1573(CPU)X -1755(bound)X -1982(con\256guration)X -2436(\(\256gure)X -2677(eight,)X -2884(READ-ONLY\),)X -3426(and)X -3569(lock)X -3734(contention)X -4099(bound)X -555 3248(\(\256gure)N -796(eight,)X -1003(NO_FSYNC\).)X -1510(Since)X -1715(the)X -1840(normal)X -2094(con\256guration)X -2548(is)X -2628(completely)X -3011(disk)X -3171(bound)X -3398(\(each)X -3600(transaction)X -3978(requires)X -4263(a)X -555 3354(random)N -823(read,)X -1005(a)X -1064(random)X -1332(write,)X -1540(and)X -1679(a)X -1738(sequential)X -2086(write)X -7 s -2251 3322(4)N -10 s -3354(\))Y -2329(we)X -2446(expect)X -2679(to)X -2764(see)X -2890(little)X -3059(performance)X -3489(improvement)X -3939(as)X -4028(the)X -4148(mul-)X -555 3444(tiprogramming)N -1064(level)X -1249(increases.)X -1613(In)X -1709(fact,)X -1879(\256gure)X -2095(seven)X -2307(reveals)X -2564(that)X -2713(we)X -2836(are)X -2964(able)X -3127(to)X -3218(overlap)X -3487(CPU)X -3670(and)X -3814(disk)X -3975(utilization)X -555 3534(slightly)N -825(producing)X -1181(approximately)X -1674(a)X -1740(10%)X -1917(performance)X -2354(improvement)X -2811(with)X -2983(two)X -3133(processes.)X -3511(After)X -3711(that)X -3861(point,)X -4075(perfor-)X -555 3624(mance)N -785(drops)X -983(off,)X -1117(and)X -1253(at)X -1331(a)X -1387(multi-programming)X -2038(level)X -2214(of)X -2301(4,)X -2381(we)X -2495(are)X -2614(performing)X -2995(worse)X -3207(than)X -3365(in)X -3447(the)X -3565(single)X -3776(process)X -4037(case.)X -755 3747(Similar)N -1021(behavior)X -1333(was)X -1489(reported)X -1787(on)X -1897(the)X -2025(commercial)X -2434(relational)X -2767(database)X -3074(system)X -3326(using)X -3529(the)X -3657(same)X -3852(con\256guration.)X -555 3837(The)N -707(important)X -1045(conclusion)X -1419(to)X -1508(draw)X -1696(from)X -1879(this)X -2021(is)X -2101(that)X -2248(you)X -2395(cannot)X -2636(attain)X -2841(good)X -3028(multi-user)X -3384(scaling)X -3638(on)X -3745(a)X -3808(badly)X -4013(balanced)X -555 3927(system.)N -839(If)X -915(multi-user)X -1266(performance)X -1695(on)X -1797(applications)X -2205(of)X -2293(this)X -2429(sort)X -2570(is)X -2644(important,)X -2996(one)X -3133(must)X -3309(have)X -3482(a)X -3539(separate)X -3824(logging)X -4089(device)X -555 4017(and)N -697(horizontally)X -1110(partition)X -1407(the)X -1531(database)X -1834(to)X -1921(allow)X -2124(a)X -2185(suf\256ciently)X -2570(high)X -2737(degree)X -2977(of)X -3069(multiprogramming)X -3698(that)X -3843(group)X -4055(commit)X -555 4107(can)N -687(amortize)X -988(the)X -1106(cost)X -1255(of)X -1342(log)X -1464(\257ushing.)X -755 4230(By)N -871(using)X -1067(a)X -1126(very)X -1292(small)X -1488(database)X -1788(\(one)X -1954(that)X -2097(can)X -2232(be)X -2331(entirely)X -2599(cached)X -2846(in)X -2930(main)X -3112(memory\))X -3428(and)X -3566(read-only)X -3896(transactions,)X -555 4320(we)N -670(generated)X -1004(a)X -1061(CPU)X -1236(bound)X -1456(environment.)X -1921(By)X -2034(using)X -2227(the)X -2345(same)X -2530(small)X -2723(database,)X -3040(the)X -3158(complete)X -3472(TPCB)X -3691(transaction,)X -4083(and)X -4219(no)X -3 f -555 4410(fsync)N -1 f -733(\(2\))X -862(on)X -977(the)X -1110(log)X -1247(at)X -1340(commit,)X -1639(we)X -1768(created)X -2036(a)X -2107(lock)X -2280(contention)X -2652(bound)X -2886(environment.)X -3365(The)X -3524(small)X -3731(database)X -4042(used)X -4223(an)X -555 4500(account)N -828(\256le)X -953(containing)X -1314(only)X -1479(1000)X -1662(records)X -1922(rather)X -2133(than)X -2294(the)X -2415(full)X -2549(1,000,000)X -2891(records)X -3150(and)X -3288(ran)X -3413(enough)X -3671(transactions)X -4076(to)X -4160(read)X -555 4590(the)N -677(entire)X -883(database)X -1183(into)X -1330(the)X -1451(buffer)X -1671(pool)X -1836(\(2000\))X -2073(before)X -2302(beginning)X -2645(measurements.)X -3147(The)X -3295(read-only)X -3626(transaction)X -4001(consisted)X -555 4680(of)N -646(three)X -831(database)X -1132(reads)X -1326(\(from)X -1533(the)X -1655(1000)X -1839(record)X -2069(account)X -2343(\256le,)X -2489(the)X -2611(100)X -2754(record)X -2983(teller)X -3171(\256le,)X -3316(and)X -3455(the)X -3576(10)X -3679(record)X -3908(branch)X -4150(\256le\).)X -555 4770(Since)N -759(no)X -865(data)X -1025(were)X -1208(modi\256ed)X -1518(and)X -1660(no)X -1766(history)X -2014(records)X -2277(were)X -2460(written,)X -2733(no)X -2839(log)X -2966(records)X -3228(were)X -3410(written.)X -3702(For)X -3838(the)X -3961(contention)X -555 4860(bound)N -780(con\256guration,)X -1252(we)X -1371(used)X -1543(the)X -1666(normal)X -1918(TPCB)X -2142(transaction)X -2519(\(against)X -2798(the)X -2920(small)X -3117(database\))X -3445(and)X -3585(disabled)X -3876(the)X -3998(log)X -4124(\257ush.)X -555 4950(Figure)N -784(eight)X -964(shows)X -1184(both)X -1346(of)X -1433(these)X -1618(results.)X -755 5073(The)N -902(read-only)X -1231(test)X -1363(indicates)X -1669(that)X -1810(we)X -1925(barely)X -2147(scale)X -2329(at)X -2408(all)X -2509(in)X -2592(the)X -2711(CPU)X -2887(bound)X -3108(case.)X -3308(The)X -3454(explanation)X -3849(for)X -3964(that)X -4105(is)X -4179(that)X -555 5163(even)N -735(with)X -905(a)X -969(single)X -1188(process,)X -1477(we)X -1599(are)X -1726(able)X -1888(to)X -1978(drive)X -2171(the)X -2297(CPU)X -2480(utilization)X -2832(to)X -2922(96%.)X -3137(As)X -3254(a)X -3317(result,)X -3542(that)X -3689(gives)X -3885(us)X -3983(very)X -4153(little)X -555 5253(room)N -753(for)X -876(improvement,)X -1352(and)X -1497(it)X -1570(takes)X -1764(a)X -1829(multiprogramming)X -2462(level)X -2647(of)X -2743(four)X -2906(to)X -2997(approach)X -3321(100%)X -3537(CPU)X -3721(saturation.)X -4106(In)X -4201(the)X -555 5343(case)N -718(where)X -939(we)X -1057(do)X -1161(perform)X -1444(writes,)X -1684(we)X -1802(are)X -1925(interested)X -2261(in)X -2347(detecting)X -2665(when)X -2863(lock)X -3025(contention)X -3387(becomes)X -3691(a)X -3750(dominant)X -4075(perfor-)X -555 5433(mance)N -787(factor.)X -1037(Contention)X -1414(will)X -1560(cause)X -1761(two)X -1903(phenomena;)X -2317(we)X -2433(will)X -2579(see)X -2704(transactions)X -3109(queueing)X -3425(behind)X -3665(frequently)X -4017(accessed)X -555 5523(data,)N -731(and)X -869(we)X -985(will)X -1131(see)X -1256(transaction)X -1629(abort)X -1815(rates)X -1988(increasing)X -2339(due)X -2476(to)X -2559(deadlock.)X -2910(Given)X -3127(that)X -3268(the)X -3387(branch)X -3627(\256le)X -3750(contains)X -4038(only)X -4201(ten)X -8 s -10 f -555 5595(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)N -5 s -1 f -727 5673(4)N -8 s -763 5698(Although)N -1021(the)X -1115(log)X -1213(is)X -1272(written)X -1469(sequentially,)X -1810(we)X -1900(do)X -1980(not)X -2078(get)X -2172(the)X -2266(bene\256t)X -2456(of)X -2525(sequentiality)X -2868(since)X -3015(the)X -3109(log)X -3207(and)X -3315(database)X -3550(reside)X -3718(on)X -3798(the)X -3892(same)X -4039(disk.)X - -13 p -%%Page: 13 13 -8 s 8 xH 0 xS 1 f -10 s -3 f -1 f -3187 2051 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -3286 2028 MXY -0 17 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -3384 1926 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -3483 1910 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -3581 1910 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -3680 1832 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -3778 1909 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -3877 1883 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -3975 1679 MXY -0 17 Dl -0 -8 Dl -9 0 Dl --18 0 Dl -4074 1487 MXY -0 17 Dl -0 -8 Dl -9 0 Dl --18 0 Dl -5 Dt -3187 2060 MXY -99 -24 Dl -98 -101 Dl -99 -16 Dl -98 0 Dl -99 -78 Dl -98 77 Dl -99 -26 Dl -98 -204 Dl -99 -192 Dl -3 f -6 s -4088 1516(SMALL)N -3 Dt -3187 2051 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -3286 2051 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -3384 2041 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -3483 1990 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -3581 1843 MXY -0 17 Dl -0 -8 Dl -9 0 Dl --18 0 Dl -3680 1578 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -3778 1496 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -3877 1430 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -3975 1269 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -4074 1070 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -1 Dt -3187 2060 MXY -99 0 Dl -98 -10 Dl -99 -51 Dl -98 -147 Dl -99 -265 Dl -98 -82 Dl -99 -66 Dl -98 -161 Dl -99 -199 Dl -4088 1099(LARGE)N -5 Dt -3089 2060 MXY -985 0 Dl -3089 MX -0 -1174 Dl -4 Ds -1 Dt -3581 2060 MXY -0 -1174 Dl -4074 2060 MXY -0 -1174 Dl -3089 1825 MXY -985 0 Dl -9 s -2993 1855(25)N -3089 1591 MXY -985 0 Dl -2993 1621(50)N -3089 1356 MXY -985 0 Dl -2993 1386(75)N -3089 1121 MXY -985 0 Dl -2957 1151(100)N -3089 886 MXY -985 0 Dl -2957 916(125)N -3281 2199(Multiprogramming)N -3071 2152(0)N -3569(5)X -4038(10)X -2859 787(Aborts)N -3089(per)X -3211(500)X -2901 847(transactions)N --1 Ds -3 Dt -2037 1342 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -2125 1358 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -2213 1341 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -2301 1191 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -2388 1124 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --17 0 Dl -2476 1157 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -2564 1157 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -2652 1161 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -2740 1153 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -2828 1150 MXY -0 18 Dl -0 -9 Dl -8 0 Dl --17 0 Dl -5 Dt -2037 1351 MXY -88 16 Dl -88 -17 Dl -88 -150 Dl -87 -67 Dl -88 33 Dl -88 0 Dl -88 4 Dl -88 -8 Dl -88 -3 Dl -6 s -2685 1234(READ-ONLY)N -3 Dt -2037 1464 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -2125 1640 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -2213 1854 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -2301 1872 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -2388 1871 MXY -0 17 Dl -0 -9 Dl -9 0 Dl --17 0 Dl -2476 1933 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -2564 1914 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -2652 1903 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -2740 1980 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -2828 2004 MXY -0 18 Dl -0 -9 Dl -8 0 Dl --17 0 Dl -1 Dt -2037 1473 MXY -88 176 Dl -88 214 Dl -88 18 Dl -87 -2 Dl -88 63 Dl -88 -19 Dl -88 -11 Dl -88 77 Dl -88 24 Dl -2759 1997(NO-FSYNC)N -5 Dt -1949 2060 MXY -879 0 Dl -1949 MX -0 -1174 Dl -4 Ds -1 Dt -2388 2060 MXY -0 -1174 Dl -2828 2060 MXY -0 -1174 Dl -1949 1825 MXY -879 0 Dl -9 s -1842 1855(40)N -1949 1591 MXY -879 0 Dl -1842 1621(80)N -1949 1356 MXY -879 0 Dl -1806 1386(120)N -1949 1121 MXY -879 0 Dl -1806 1151(160)N -1949 886 MXY -879 0 Dl -1806 916(200)N -2088 2199(Multiprogramming)N -1844 863(in)N -1922(TPS)X -1761 792(Throughput)N -1931 2121(0)N -2370 2133(5)N -2792(10)X -6 s -1679 1833(LIBTP)N --1 Ds -3 Dt -837 1019 MXY -0 17 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -929 878 MXY -0 17 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -1021 939 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -1113 1043 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -1205 1314 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -1297 1567 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -1389 1665 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -1481 1699 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -1573 1828 MXY -0 18 Dl -0 -9 Dl -9 0 Dl --18 0 Dl -1665 1804 MXY -0 18 Dl -0 -9 Dl -8 0 Dl --17 0 Dl -5 Dt -837 1027 MXY -92 -141 Dl -92 62 Dl -92 104 Dl -92 271 Dl -92 253 Dl -92 98 Dl -92 34 Dl -92 129 Dl -92 -24 Dl -745 2060 MXY -920 0 Dl -745 MX -0 -1174 Dl -4 Ds -1 Dt -1205 2060 MXY -0 -1174 Dl -1665 2060 MXY -0 -1174 Dl -745 1766 MXY -920 0 Dl -9 s -673 1796(3)N -745 1473 MXY -920 0 Dl -673 1503(5)N -745 1180 MXY -920 0 Dl -673 1210(8)N -745 886 MXY -920 0 Dl -637 916(10)N -905 2199(Multiprogramming)N -622 851(in)N -700(TPS)X -575 792(Throughput)N -733 2152(0)N -1196(5)X -1629(10)X -3 Dt --1 Ds -8 s -655 2441(Figure)N -872(7:)X -960(Multi-user)X -1286(Performance.)X -1 f -655 2531(Since)N -825(the)X -931(con\256guration)X -1300(is)X -1371(completely)X -655 2621(disk)N -790(bound,)X -994(we)X -1096(see)X -1204(only)X -1345(a)X -1400(small)X -1566(im-)X -655 2711(provement)N -964(by)X -1064(adding)X -1274(a)X -1337(second)X -1549(pro-)X -655 2801(cess.)N -849(Adding)X -1081(any)X -1213(more)X -1383(concurrent)X -655 2891(processes)N -935(causes)X -1137(performance)X -1493(degra-)X -655 2981(dation.)N -3 f -1927 2441(Figure)N -2149(8:)X -2243(Multi-user)X -2574(Performance)X -1927 2531(on)N -2021(a)X -2079(small)X -2251(database.)X -1 f -2551(With)X -2704(one)X -2821(pro-)X -1927 2621(cess,)N -2075(we)X -2174(are)X -2276(driving)X -2486(the)X -2589(CPU)X -2739(at)X -2810(96%)X -1927 2711(utilization)N -2215(leaving)X -2430(little)X -2575(room)X -2737(for)X -2838(im-)X -1927 2801(provement)N -2238(as)X -2328(the)X -2443(multiprogramming)X -1927 2891(level)N -2091(increases.)X -2396(In)X -2489(the)X -2607(NO-FSYNC)X -1927 2981(case,)N -2076(lock)X -2209(contention)X -2502(degrades)X -2751(perfor-)X -1927 3071(mance)N -2117(as)X -2194(soon)X -2339(as)X -2416(a)X -2468(second)X -2669(process)X -2884(is)X -1927 3161(added.)N -3 f -3199 2441(Figure)N -3405(9:)X -3482(Abort)X -3669(rates)X -3827(on)X -3919(the)X -4028(TPCB)X -3199 2531(Benchmark.)N -1 f -3589(The)X -3726(abort)X -3895(rate)X -4028(climbs)X -3199 2621(more)N -3366(quickly)X -3594(for)X -3704(the)X -3818(large)X -3980(database)X -3199 2711(test)N -3324(since)X -3491(processes)X -3771(are)X -3884(descheduled)X -3199 2801(more)N -3409(frequently,)X -3766(allowing)X -4068(more)X -3199 2891(processes)N -3459(to)X -3525(vie)X -3619(for)X -3709(the)X -3803(same)X -3950(locks.)X -10 s -10 f -555 3284(h)N -579(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)X -1 f -555 3560(records,)N -835(we)X -952(expect)X -1185(contention)X -1546(to)X -1631(become)X -1904(a)X -1963(factor)X -2174(quickly)X -2437(and)X -2576(the)X -2697(NO-FSYNC)X -3120(line)X -3263(in)X -3348(\256gure)X -3557(eight)X -3739(demonstrates)X -4184(this)X -555 3650(dramatically.)N -1022(Each)X -1209(additional)X -1555(process)X -1822(causes)X -2058(both)X -2226(more)X -2417(waiting)X -2682(and)X -2823(more)X -3013(deadlocking.)X -3470(Figure)X -3704(nine)X -3867(shows)X -4092(that)X -4237(in)X -555 3740(the)N -681(small)X -882(database)X -1187(case)X -1353(\(SMALL\),)X -1725(waiting)X -1992(is)X -2072(the)X -2197(dominant)X -2526(cause)X -2732(of)X -2826(declining)X -3151(performance)X -3585(\(the)X -3737(number)X -4009(of)X -4103(aborts)X -555 3830(increases)N -878(less)X -1026(steeply)X -1281(than)X -1447(the)X -1573(performance)X -2008(drops)X -2214(off)X -2336(in)X -2426(\256gure)X -2641(eight\),)X -2876(while)X -3082(in)X -3172(the)X -3298(large)X -3487(database)X -3792(case)X -3958(\(LARGE\),)X -555 3920(deadlocking)N -967(contributes)X -1343(more)X -1528(to)X -1610(the)X -1728(declining)X -2046(performance.)X -755 4043(Deadlocks)N -1116(are)X -1237(more)X -1424(likely)X -1628(to)X -1712(occur)X -1913(in)X -1997(the)X -2116(LARGE)X -2404(test)X -2536(than)X -2695(in)X -2778(the)X -2897(SMALL)X -3189(test)X -3321(because)X -3597(there)X -3779(are)X -3899(more)X -4085(oppor-)X -555 4133(tunities)N -814(to)X -900(wait.)X -1082(In)X -1173(the)X -1295(SMALL)X -1590(case,)X -1773(processes)X -2105(never)X -2307(do)X -2410(I/O)X -2540(and)X -2679(are)X -2801(less)X -2944(likely)X -3149(to)X -3234(be)X -3333(descheduled)X -3753(during)X -3985(a)X -4044(transac-)X -555 4223(tion.)N -740(In)X -828(the)X -947(LARGE)X -1235(case,)X -1415(processes)X -1744(will)X -1889(frequently)X -2240(be)X -2337(descheduled)X -2755(since)X -2941(they)X -3100(have)X -3273(to)X -3356(perform)X -3636(I/O.)X -3804(This)X -3967(provides)X -4263(a)X -555 4313(window)N -837(where)X -1058(a)X -1118(second)X -1365(process)X -1630(can)X -1766(request)X -2022(locks)X -2215(on)X -2318(already)X -2578(locked)X -2815(pages,)X -3041(thus)X -3197(increasing)X -3550(the)X -3671(likelihood)X -4018(of)X -4108(build-)X -555 4403(ing)N -677(up)X -777(long)X -939(chains)X -1164(of)X -1251(waiting)X -1511(processes.)X -1879(Eventually,)X -2266(this)X -2401(leads)X -2586(to)X -2668(deadlock.)X -3 f -555 4589(5.2.)N -715(The)X -868(OO1)X -1052(Benchmark)X -1 f -755 4712(The)N -903(TPCB)X -1125(benchmark)X -1505(described)X -1836(in)X -1921(the)X -2042(previous)X -2341(section)X -2591(measures)X -2913(performance)X -3343(under)X -3549(a)X -3608(conventional)X -4044(transac-)X -555 4802(tion)N -706(processing)X -1076(workload.)X -1446(Other)X -1656(application)X -2039(domains,)X -2357(such)X -2531(as)X -2625(computer-aided)X -3156(design,)X -3412(have)X -3591(substantially)X -4022(different)X -555 4892(access)N -786(patterns.)X -1105(In)X -1197(order)X -1392(to)X -1479(measure)X -1772(the)X -1895(performance)X -2327(of)X -2418(LIBTP)X -2664(under)X -2871(workloads)X -3229(of)X -3320(this)X -3459(type,)X -3641(we)X -3759(implemented)X -4201(the)X -555 4982(OO1)N -731(benchmark)X -1108(described)X -1436(in)X -1518([CATT91].)X -755 5105(The)N -908(database)X -1213(models)X -1472(a)X -1535(set)X -1651(of)X -1745(electronics)X -2120(components)X -2534(with)X -2703(connections)X -3113(among)X -3358(them.)X -3585(One)X -3746(table)X -3929(stores)X -4143(parts)X -555 5195(and)N -696(another)X -962(stores)X -1174(connections.)X -1622(There)X -1835(are)X -1959(three)X -2145(connections)X -2552(originating)X -2927(at)X -3009(any)X -3149(given)X -3351(part.)X -3540(Ninety)X -3782(percent)X -4043(of)X -4134(these)X -555 5285(connections)N -960(are)X -1081(to)X -1165(nearby)X -1406(parts)X -1584(\(those)X -1802(with)X -1966(nearby)X -2 f -2207(ids)X -1 f -2300(\))X -2348(to)X -2431(model)X -2652(the)X -2771(spatial)X -3001(locality)X -3262(often)X -3448(exhibited)X -3767(in)X -3850(CAD)X -4040(applica-)X -555 5375(tions.)N -779(Ten)X -933(percent)X -1198(of)X -1293(the)X -1419(connections)X -1830(are)X -1957(randomly)X -2292(distributed)X -2662(among)X -2908(all)X -3016(other)X -3209(parts)X -3393(in)X -3483(the)X -3609(database.)X -3954(Every)X -4174(part)X -555 5465(appears)N -829(exactly)X -1089(three)X -1278(times)X -1479(in)X -1569(the)X -2 f -1695(from)X -1 f -1874(\256eld)X -2043(of)X -2137(a)X -2200(connection)X -2579(record,)X -2832(and)X -2975(zero)X -3141(or)X -3235(more)X -3427(times)X -3627(in)X -3716(the)X -2 f -3841(to)X -1 f -3930(\256eld.)X -4139(Parts)X -555 5555(have)N -2 f -727(x)X -1 f -783(and)X -2 f -919(y)X -1 f -975(locations)X -1284(set)X -1393(randomly)X -1720(in)X -1802(an)X -1898(appropriate)X -2284(range.)X - -14 p -%%Page: 14 14 -10 s 10 xH 0 xS 1 f -3 f -1 f -755 630(The)N -900(intent)X -1102(of)X -1189(OO1)X -1365(is)X -1438(to)X -1520(measure)X -1808(the)X -1926(overall)X -2169(cost)X -2318(of)X -2405(a)X -2461(query)X -2664(mix)X -2808(characteristic)X -3257(of)X -3344(engineering)X -3743(database)X -4040(applica-)X -555 720(tions.)N -770(There)X -978(are)X -1097(three)X -1278(tests:)X -10 f -635 843(g)N -2 f -755(Lookup)X -1 f -1022(generates)X -1353(1,000)X -1560(random)X -1832(part)X -2 f -1984(ids)X -1 f -2077(,)X -2124(fetches)X -2378(the)X -2502(corresponding)X -2987(parts)X -3169(from)X -3351(the)X -3475(database,)X -3798(and)X -3940(calls)X -4113(a)X -4175(null)X -755 933(procedure)N -1097(in)X -1179(the)X -1297(host)X -1450(programming)X -1906(language)X -2216(with)X -2378(the)X -2496(parts')X -2 f -2699(x)X -1 f -2755(and)X -2 f -2891(y)X -1 f -2947(positions.)X -10 f -635 1056(g)N -2 f -755(Traverse)X -1 f -1067(retrieves)X -1371(a)X -1434(random)X -1706(part)X -1858(from)X -2041(the)X -2166(database)X -2470(and)X -2613(follows)X -2880(connections)X -3290(from)X -3473(it)X -3544(to)X -3632(other)X -3823(parts.)X -4045(Each)X -4232(of)X -755 1146(those)N -947(parts)X -1126(is)X -1202(retrieved,)X -1531(and)X -1670(all)X -1773(connections)X -2179(from)X -2358(it)X -2424(followed.)X -2771(This)X -2935(procedure)X -3279(is)X -3354(repeated)X -3649(depth-\256rst)X -4000(for)X -4116(seven)X -755 1236(hops)N -930(from)X -1110(the)X -1232(original)X -1505(part,)X -1674(for)X -1792(a)X -1852(total)X -2018(of)X -2109(3280)X -2293(parts.)X -2513(Backward)X -2862(traversal)X -3162(also)X -3314(exists,)X -3539(and)X -3678(follows)X -3941(all)X -4044(connec-)X -755 1326(tions)N -930(into)X -1074(a)X -1130(given)X -1328(part)X -1473(to)X -1555(their)X -1722(origin.)X -10 f -635 1449(g)N -2 f -755(Insert)X -1 f -962(adds)X -1129(100)X -1269(new)X -1423(parts)X -1599(and)X -1735(their)X -1902(connections.)X -755 1572(The)N -913(benchmark)X -1303(is)X -1389(single-user,)X -1794(but)X -1929(multi-user)X -2291(access)X -2530(controls)X -2821(\(locking)X -3120(and)X -3268(transaction)X -3652(protection\))X -4036(must)X -4223(be)X -555 1662(enforced.)N -898(It)X -968(is)X -1042(designed)X -1348(to)X -1431(be)X -1528(run)X -1656(on)X -1757(a)X -1814(database)X -2112(with)X -2275(20,000)X -2516(parts,)X -2713(and)X -2850(on)X -2951(one)X -3087(with)X -3249(200,000)X -3529(parts.)X -3745(Because)X -4033(we)X -4147(have)X -555 1752(insuf\256cient)N -935(disk)X -1088(space)X -1287(for)X -1401(the)X -1519(larger)X -1727(database,)X -2044(we)X -2158(report)X -2370(results)X -2599(only)X -2761(for)X -2875(the)X -2993(20,000)X -3233(part)X -3378(database.)X -3 f -555 1938(5.2.1.)N -775(Implementation)X -1 f -755 2061(The)N -920(LIBTP)X -1182(implementation)X -1724(of)X -1831(OO1)X -2027(uses)X -2205(the)X -2342(TCL)X -2532([OUST90])X -2914(interface)X -3235(described)X -3582(earlier.)X -3867(The)X -4031(backend)X -555 2151(accepts)N -813(commands)X -1181(over)X -1345(an)X -1442(IP)X -1534(socket)X -1760(and)X -1897(performs)X -2208(the)X -2327(requested)X -2656(database)X -2954(actions.)X -3242(The)X -3387(frontend)X -3679(opens)X -3886(and)X -4022(executes)X -555 2241(a)N -618(TCL)X -796(script.)X -1041(This)X -1210(script)X -1415(contains)X -1709(database)X -2013(accesses)X -2313(interleaved)X -2697(with)X -2866(ordinary)X -3165(program)X -3463(control)X -3716(statements.)X -4120(Data-)X -555 2331(base)N -718(commands)X -1085(are)X -1204(submitted)X -1539(to)X -1621(the)X -1739(backend)X -2027(and)X -2163(results)X -2392(are)X -2511(bound)X -2731(to)X -2813(program)X -3105(variables.)X -755 2454(The)N -903(parts)X -1082(table)X -1261(was)X -1409(stored)X -1628(as)X -1718(a)X -1776(B-tree)X -1999(indexed)X -2275(by)X -2 f -2377(id)X -1 f -2439(.)X -2501(The)X -2648(connection)X -3022(table)X -3200(was)X -3347(stored)X -3565(as)X -3654(a)X -3712(set)X -3823(of)X -3912(\256xed-length)X -555 2544(records)N -824(using)X -1029(the)X -1159(4.4BSD)X -1446(recno)X -1657(access)X -1895(method.)X -2207(In)X -2306(addition,)X -2620(two)X -2771(B-tree)X -3003(indices)X -3261(were)X -3449(maintained)X -3836(on)X -3947(connection)X -555 2634(table)N -732(entries.)X -1007(One)X -1162(index)X -1360(mapped)X -1634(the)X -2 f -1752(from)X -1 f -1923(\256eld)X -2085(to)X -2167(a)X -2223(connection)X -2595(record)X -2821(number,)X -3106(and)X -3242(the)X -3360(other)X -3545(mapped)X -3819(the)X -2 f -3937(to)X -1 f -4019(\256eld)X -4181(to)X -4263(a)X -555 2724(connection)N -932(record)X -1163(number.)X -1473(These)X -1690(indices)X -1941(support)X -2205(fast)X -2345(lookups)X -2622(on)X -2726(connections)X -3133(in)X -3219(both)X -3385(directions.)X -3765(For)X -3900(the)X -4022(traversal)X -555 2814(tests,)N -743(the)X -867(frontend)X -1165(does)X -1338(an)X -1439(index)X -1642(lookup)X -1889(to)X -1976(discover)X -2273(the)X -2396(connected)X -2747(part's)X -2 f -2955(id)X -1 f -3017(,)X -3062(and)X -3203(then)X -3366(does)X -3538(another)X -3804(lookup)X -4051(to)X -4138(fetch)X -555 2904(the)N -673(part)X -818(itself.)X -3 f -555 3090(5.2.2.)N -775(Performance)X -1242(Measurements)X -1766(for)X -1889(OO1)X -1 f -755 3213(We)N -888(compare)X -1186(LIBTP's)X -1487(OO1)X -1664(performance)X -2092(to)X -2174(that)X -2314(reported)X -2602(in)X -2684([CATT91].)X -3087(Those)X -3303(results)X -3532(were)X -3709(collected)X -4019(on)X -4119(a)X -4175(Sun)X -555 3303(3/280)N -759(\(25)X -888(MHz)X -1075(MC68020\))X -1448(with)X -1612(16)X -1714(MBytes)X -1989(of)X -2078(memory)X -2367(and)X -2505(two)X -2647(Hitachi)X -2904(892MByte)X -3267(disks)X -3452(\(15)X -3580(ms)X -3694(average)X -3966(seek)X -4130(time\))X -555 3393(behind)N -793(an)X -889(SMD-4)X -1149(controller.)X -1521(Frontends)X -1861(ran)X -1984(on)X -2084(an)X -2180(8MByte)X -2462(Sun)X -2606(3/260.)X -755 3516(In)N -844(order)X -1036(to)X -1120(measure)X -1410(performance)X -1839(on)X -1941(a)X -1999(machine)X -2293(of)X -2382(roughly)X -2653(equivalent)X -3009(processor)X -3339(power,)X -3582(we)X -3698(ran)X -3822(one)X -3959(set)X -4069(of)X -4157(tests)X -555 3606(on)N -666(a)X -733(standalone)X -1107(MC68030-based)X -1671(HP300)X -1923(\(33MHz)X -2225(MC68030\).)X -2646(The)X -2801(database)X -3108(was)X -3263(stored)X -3489(on)X -3599(a)X -3665(300MByte)X -4037(HP7959)X -555 3696(SCSI)N -744(disk)X -898(\(17)X -1026(ms)X -1139(average)X -1410(seek)X -1573(time\).)X -1802(Since)X -2000(this)X -2135(machine)X -2427(is)X -2500(not)X -2622(connected)X -2968(to)X -3050(a)X -3106(network,)X -3409(we)X -3523(ran)X -3646(local)X -3822(tests)X -3984(where)X -4201(the)X -555 3786(frontend)N -855(and)X -999(backend)X -1295(run)X -1430(on)X -1538(the)X -1664(same)X -1856(machine.)X -2195(We)X -2334(compare)X -2638(these)X -2830(measurements)X -3316(with)X -3485(Cattell's)X -3783(local)X -3966(Sun)X -4117(3/280)X -555 3876(numbers.)N -755 3999(Because)N -1051(the)X -1177(benchmark)X -1562(requires)X -1849(remote)X -2100(access,)X -2354(we)X -2476(ran)X -2607(another)X -2876(set)X -2993(of)X -3088(tests)X -3258(on)X -3365(a)X -3428(DECstation)X -3828(5000/200)X -4157(with)X -555 4089(32M)N -732(of)X -825(memory)X -1118(running)X -1393(Ultrix)X -1610(V4.0)X -1794(and)X -1936(a)X -1998(DEC)X -2184(1GByte)X -2459(RZ57)X -2666(SCSI)X -2859(disk.)X -3057(We)X -3194(compare)X -3496(the)X -3619(local)X -3800(performance)X -4232(of)X -555 4179(OO1)N -734(on)X -837(the)X -958(DECstation)X -1354(to)X -1439(its)X -1536(remote)X -1781(performance.)X -2250(For)X -2383(the)X -2503(remote)X -2748(case,)X -2929(we)X -3045(ran)X -3170(the)X -3290(frontend)X -3584(on)X -3686(a)X -3744(DECstation)X -4139(3100)X -555 4269(with)N -717(16)X -817(MBytes)X -1090(of)X -1177(main)X -1357(memory.)X -755 4392(The)N -900(databases)X -1228(tested)X -1435(in)X -1517([CATT91])X -1880(are)X -10 f -635 4515(g)N -1 f -755(INDEX,)X -1045(a)X -1101(highly-optimized)X -1672(access)X -1898(method)X -2158(package)X -2442(developed)X -2792(at)X -2870(Sun)X -3014(Microsystems.)X -10 f -635 4638(g)N -1 f -755(OODBMS,)X -1137(a)X -1193(beta)X -1347(release)X -1591(of)X -1678(a)X -1734(commercial)X -2133(object-oriented)X -2639(database)X -2936(management)X -3366(system.)X -10 f -635 4761(g)N -1 f -755(RDBMS,)X -1076(a)X -1133(UNIX-based)X -1565(commercial)X -1965(relational)X -2289(data)X -2444(manager)X -2742(at)X -2821(production)X -3189(release.)X -3474(The)X -3620(OO1)X -3797(implementation)X -755 4851(used)N -922(embedded)X -1272(SQL)X -1443(in)X -1525(C.)X -1638(Stored)X -1867(procedures)X -2240(were)X -2417(de\256ned)X -2673(to)X -2755(reduce)X -2990(client-server)X -3412(traf\256c.)X -755 4974(Table)N -974(two)X -1130(shows)X -1366(the)X -1500(measurements)X -1995(from)X -2187([CATT91])X -2566(and)X -2718(LIBTP)X -2976(for)X -3106(a)X -3178(local)X -3370(test)X -3517(on)X -3632(the)X -3765(MC680x0-based)X -555 5064(hardware.)N -915(All)X -1037(caches)X -1272(are)X -1391(cleared)X -1644(before)X -1870(each)X -2038(test.)X -2209(All)X -2331(times)X -2524(are)X -2643(in)X -2725(seconds.)X -755 5187(Table)N -960(two)X -1102(shows)X -1324(that)X -1466(LIBTP)X -1710(outperforms)X -2123(the)X -2242(commercial)X -2642(relational)X -2966(system,)X -3229(but)X -3352(is)X -3426(slower)X -3661(than)X -3820(OODBMS)X -4183(and)X -555 5277(INDEX.)N -872(Since)X -1077(the)X -1202(caches)X -1444(were)X -1628(cleared)X -1888(at)X -1973(the)X -2098(start)X -2263(of)X -2356(each)X -2530(test,)X -2687(disk)X -2846(throughput)X -3223(is)X -3302(critical)X -3551(in)X -3639(this)X -3780(test.)X -3957(The)X -4108(single)X -555 5367(SCSI)N -749(HP)X -877(drive)X -1068(used)X -1241(by)X -1347(LIBTP)X -1595(is)X -1674(approximately)X -2163(13%)X -2336(slower)X -2576(than)X -2739(the)X -2862(disks)X -3051(used)X -3223(in)X -3310([CATT91])X -3678(which)X -3899(accounts)X -4205(for)X -555 5457(part)N -700(of)X -787(the)X -905(difference.)X -755 5580(OODBMS)N -1118(and)X -1255(INDEX)X -1525(outperform)X -1906(LIBTP)X -2148(most)X -2323(dramatically)X -2744(on)X -2844(traversal.)X -3181(This)X -3343(is)X -3416(because)X -3691(we)X -3805(use)X -3932(index)X -4130(look-)X -555 5670(ups)N -689(to)X -774(\256nd)X -921(connections,)X -1347(whereas)X -1634(the)X -1755(other)X -1942(two)X -2084(systems)X -2359(use)X -2488(a)X -2546(link)X -2692(access)X -2920(method.)X -3222(The)X -3369(index)X -3569(requires)X -3850(us)X -3943(to)X -4027(examine)X - -15 p -%%Page: 15 15 -10 s 10 xH 0 xS 1 f -3 f -1 f -10 f -555 679(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)N -2 f -606 769(Measure)N -1 f -1019(INDEX)X -1389(OODBMS)X -1851(RDBMS)X -2250(LIBTP)X -10 f -555 771(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)N -555 787(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)N -1 f -595 869(Lookup)N -1114(5.4)X -1490(12.9)X -1950(27)X -2291(27.2)X -595 959(Traversal)N -1074(13)X -1530(9.8)X -1950(90)X -2291(47.3)X -595 1049(Insert)N -1114(7.4)X -1530(1.5)X -1950(22)X -2331(9.7)X -10 f -555 1059(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)N -555(c)X -999(c)Y -919(c)Y -839(c)Y -759(c)Y -959 1059(c)N -999(c)Y -919(c)Y -839(c)Y -759(c)Y -1329 1059(c)N -999(c)Y -919(c)Y -839(c)Y -759(c)Y -1791 1059(c)N -999(c)Y -919(c)Y -839(c)Y -759(c)Y -2190 1059(c)N -999(c)Y -919(c)Y -839(c)Y -759(c)Y -2512 1059(c)N -999(c)Y -919(c)Y -839(c)Y -759(c)Y -2618 679(i)N -2629(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -2 f -2829 769(Measure)N -3401(Cache)X -3726(Local)X -4028(Remote)X -1 f -10 f -2618 771(i)N -2629(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -2618 787(i)N -2629(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -2658 869(Lookup)N -3401(cold)X -3747(15.7)X -4078(20.6)X -3401 959(warm)N -3787(7.8)X -4078(12.4)X -10 f -2618 969(i)N -2629(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -2658 1059(Forward)N -2950(traversal)X -3401(cold)X -3747(28.4)X -4078(52.6)X -3401 1149(warm)N -3747(23.5)X -4078(47.4)X -10 f -2618 1159(i)N -2629(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -2658 1249(Backward)N -3004(traversal)X -3401(cold)X -3747(24.2)X -4078(47.4)X -3401 1339(warm)N -3747(24.3)X -4078(47.6)X -10 f -2618 1349(i)N -2629(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -1 f -2658 1439(Insert)N -3401(cold)X -3787(7.5)X -4078(10.3)X -3401 1529(warm)N -3787(6.7)X -4078(10.9)X -10 f -2618 1539(i)N -2629(iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii)X -2618(c)X -1479(c)Y -1399(c)Y -1319(c)Y -1239(c)Y -1159(c)Y -1079(c)Y -999(c)Y -919(c)Y -839(c)Y -759(c)Y -3341 1539(c)N -1479(c)Y -1399(c)Y -1319(c)Y -1239(c)Y -1159(c)Y -1079(c)Y -999(c)Y -919(c)Y -839(c)Y -759(c)Y -3666 1539(c)N -1479(c)Y -1399(c)Y -1319(c)Y -1239(c)Y -1159(c)Y -1079(c)Y -999(c)Y -919(c)Y -839(c)Y -759(c)Y -3968 1539(c)N -1479(c)Y -1399(c)Y -1319(c)Y -1239(c)Y -1159(c)Y -1079(c)Y -999(c)Y -919(c)Y -839(c)Y -759(c)Y -4309 1539(c)N -1479(c)Y -1399(c)Y -1319(c)Y -1239(c)Y -1159(c)Y -1079(c)Y -999(c)Y -919(c)Y -839(c)Y -759(c)Y -3 f -587 1785(Table)N -823(2:)X -931(Local)X -1163(MC680x0)X -1538(Performance)X -2026(of)X -2133(Several)X -587 1875(Systems)N -883(on)X -987(OO1.)X -2667 1785(Table)N -2909(3:)X -3023(Local)X -3260(vs.)X -3397(Remote)X -3707(Performance)X -4200(of)X -2667 1875(LIBTP)N -2926(on)X -3030(OO1.)X -1 f -10 f -555 1998(h)N -579(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)X -1 f -555 2274(two)N -696(disk)X -850(pages,)X -1074(but)X -1197(the)X -1316(links)X -1492(require)X -1741(only)X -1904(one,)X -2061(regardless)X -2408(of)X -2496(database)X -2794(size.)X -2980(Cattell)X -3214(reports)X -3458(that)X -3599(lookups)X -3873(using)X -4067(B-trees)X -555 2364(instead)N -808(of)X -901(links)X -1082(makes)X -1313(traversal)X -1616(take)X -1776(twice)X -1976(as)X -2069(long)X -2237(in)X -2325(INDEX.)X -2641(Adding)X -2907(a)X -2969(link)X -3119(access)X -3351(method)X -3617(to)X -3 f -3704(db)X -1 f -3792(\(3\))X -3911(or)X -4003(using)X -4201(the)X -555 2454(existing)N -828(hash)X -995(method)X -1255(would)X -1475(apparently)X -1834(be)X -1930(a)X -1986(good)X -2166(idea.)X -755 2577(Both)N -936(OODBMS)X -1304(and)X -1446(INDEX)X -1722(issue)X -1908 0.1944(coarser-granularity)AX -2545(locks)X -2739(than)X -2902(LIBTP.)X -3189(This)X -3356(limits)X -3562(concurrency)X -3985(for)X -4104(multi-)X -555 2667(user)N -711(applications,)X -1140(but)X -1264(helps)X -1455(single-user)X -1829(applications.)X -2278(In)X -2367(addition,)X -2671(the)X -2791(fact)X -2934(that)X -3076(LIBTP)X -3319(releases)X -3595(B-tree)X -3817(locks)X -4007(early)X -4189(is)X -4263(a)X -555 2757(drawback)N -896(in)X -986(OO1.)X -1210(Since)X -1416(there)X -1605(is)X -1686(no)X -1793(concurrency)X -2218(in)X -2307(the)X -2432(benchmark,)X -2836(high-concurrency)X -3430(strategies)X -3760(only)X -3929(show)X -4125(up)X -4232(as)X -555 2847(increased)N -882(locking)X -1145(overhead.)X -1503(Finally,)X -1772(the)X -1892(architecture)X -2294(of)X -2383(the)X -2503(LIBTP)X -2747(implementation)X -3271(was)X -3418(substantially)X -3844(different)X -4143(from)X -555 2937(that)N -702(of)X -796(either)X -1006(OODBMS)X -1375(or)X -1469(INDEX.)X -1786(Both)X -1968(of)X -2062(those)X -2258(systems)X -2538(do)X -2645(the)X -2770(searches)X -3070(in)X -3159(the)X -3284(user's)X -3503(address)X -3771(space,)X -3997(and)X -4139(issue)X -555 3027(requests)N -844(for)X -964(pages)X -1173(to)X -1260(the)X -1383(server)X -1605(process.)X -1911(Pages)X -2123(are)X -2247(cached)X -2496(in)X -2583(the)X -2706(client,)X -2929(and)X -3070(many)X -3273(queries)X -3530(can)X -3667(be)X -3768(satis\256ed)X -4055(without)X -555 3117(contacting)N -910(the)X -1029(server)X -1247(at)X -1326(all.)X -1467(LIBTP)X -1710(submits)X -1979(all)X -2080(the)X -2199(queries)X -2452(to)X -2535(the)X -2653(server)X -2870(process,)X -3151(and)X -3287(receives)X -3571(database)X -3868(records)X -4125(back;)X -555 3207(it)N -619(does)X -786(no)X -886(client)X -1084(caching.)X -755 3330(The)N -911(RDBMS)X -1221(architecture)X -1632(is)X -1716(much)X -1925(closer)X -2148(to)X -2241(that)X -2392(of)X -2490(LIBTP.)X -2783(A)X -2872(server)X -3100(process)X -3372(receives)X -3667(queries)X -3930(and)X -4076(returns)X -555 3420(results)N -786(to)X -870(a)X -928(client.)X -1168(The)X -1315(timing)X -1545(results)X -1776(in)X -1860(table)X -2038(two)X -2180(clearly)X -2421(show)X -2612(that)X -2754(the)X -2874(conventional)X -3309(database)X -3607(client/server)X -4025(model)X -4246(is)X -555 3510(expensive.)N -941(LIBTP)X -1188(outperforms)X -1605(the)X -1728(RDBMS)X -2032(on)X -2136(traversal)X -2437(and)X -2577(insertion.)X -2921(We)X -3057(speculate)X -3380(that)X -3524(this)X -3663(is)X -3740(due)X -3880(in)X -3966(part)X -4115(to)X -4201(the)X -555 3600(overhead)N -870(of)X -957(query)X -1160(parsing,)X -1436(optimization,)X -1880(and)X -2016(repeated)X -2309(interpretation)X -2761(of)X -2848(the)X -2966(plan)X -3124(tree)X -3265(in)X -3347(the)X -3465(RDBMS')X -3791(query)X -3994(executor.)X -755 3723(Table)N -962(three)X -1147(shows)X -1371(the)X -1492(differences)X -1873(between)X -2164(local)X -2343(and)X -2482(remote)X -2728(execution)X -3063(of)X -3153(LIBTP's)X -3456(OO1)X -3635(implementation)X -4160(on)X -4263(a)X -555 3813(DECstation.)N -989(We)X -1122(measured)X -1451(performance)X -1879(with)X -2042(a)X -2099(populated)X -2436(\(warm\))X -2694(cache)X -2899(and)X -3036(an)X -3133(empty)X -3354(\(cold\))X -3567(cache.)X -3812(Reported)X -4126(times)X -555 3903(are)N -681(the)X -806(means)X -1037(of)X -1130(twenty)X -1374(tests,)X -1562(and)X -1704(are)X -1829(in)X -1917(seconds.)X -2237(Standard)X -2548(deviations)X -2903(were)X -3086(within)X -3316(seven)X -3525(percent)X -3788(of)X -3881(the)X -4005(mean)X -4205(for)X -555 3993(remote,)N -818(and)X -954(two)X -1094(percent)X -1351(of)X -1438(the)X -1556(mean)X -1750(for)X -1864(local.)X -755 4116(The)N -914(20ms)X -1121(overhead)X -1450(of)X -1551(TCP/IP)X -1824(on)X -1938(an)X -2048(Ethernet)X -2354(entirely)X -2633(accounts)X -2948(for)X -3076(the)X -3207(difference)X -3567(in)X -3662(speed.)X -3918(The)X -4076(remote)X -555 4206(traversal)N -857(times)X -1055(are)X -1179(nearly)X -1405(double)X -1648(the)X -1771(local)X -1952(times)X -2150(because)X -2430(we)X -2549(do)X -2653(index)X -2855(lookups)X -3132(and)X -3272(part)X -3421(fetches)X -3673(in)X -3759(separate)X -4047(queries.)X -555 4296(It)N -629(would)X -854(make)X -1053(sense)X -1252(to)X -1339(do)X -1444(indexed)X -1723(searches)X -2021(on)X -2126(the)X -2248(server,)X -2489(but)X -2615(we)X -2733(were)X -2914(unwilling)X -3244(to)X -3330(hard-code)X -3676(knowledge)X -4052(of)X -4143(OO1)X -555 4386(indices)N -803(into)X -948(our)X -1075(LIBTP)X -1317(TCL)X -1488(server.)X -1745(Cold)X -1920(and)X -2056(warm)X -2259(insertion)X -2559(times)X -2752(are)X -2871(identical)X -3167(since)X -3352(insertions)X -3683(do)X -3783(not)X -3905(bene\256t)X -4143(from)X -555 4476(caching.)N -755 4599(One)N -915(interesting)X -1279(difference)X -1632(shown)X -1867(by)X -1973(table)X -2155(three)X -2342(is)X -2421(the)X -2545(cost)X -2700(of)X -2793(forward)X -3074(versus)X -3305(backward)X -3644(traversal.)X -3987(When)X -4205(we)X -555 4689(built)N -725(the)X -847(database,)X -1168(we)X -1285(inserted)X -1562(parts)X -1741(in)X -1826(part)X -2 f -1974(id)X -1 f -2059(order.)X -2292(We)X -2427(built)X -2596(the)X -2717(indices)X -2967(at)X -3048(the)X -3169(same)X -3357(time.)X -3562(Therefore,)X -3923(the)X -4044(forward)X -555 4779(index)N -757(had)X -897(keys)X -1068(inserted)X -1346(in)X -1432(order,)X -1646(while)X -1848(the)X -1970(backward)X -2307(index)X -2509(had)X -2649(keys)X -2820(inserted)X -3098(more)X -3286(randomly.)X -3656(In-order)X -3943(insertion)X -4246(is)X -555 4885(pessimal)N -858(for)X -975(B-tree)X -1199(indices,)X -1469(so)X -1563(the)X -1684(forward)X -1962(index)X -2163(is)X -2239(much)X -2440(larger)X -2651(than)X -2812(the)X -2933(backward)X -3269(one)X -7 s -3385 4853(5)N -10 s -4885(.)Y -3476(This)X -3640(larger)X -3850(size)X -3997(shows)X -4219(up)X -555 4975(as)N -642(extra)X -823(disk)X -976(reads)X -1166(in)X -1248(the)X -1366(cold)X -1524(benchmark.)X -3 f -555 5161(6.)N -655(Conclusions)X -1 f -755 5284(LIBTP)N -1006(provides)X -1311(the)X -1438(basic)X -1632(building)X -1927(blocks)X -2165(to)X -2256(support)X -2525(transaction)X -2906(protection.)X -3300(In)X -3396(comparison)X -3799(with)X -3970(traditional)X -555 5374(Unix)N -746(libraries)X -1040(and)X -1187(commercial)X -1597(systems,)X -1900(it)X -1974(offers)X -2192(a)X -2258(variety)X -2511(of)X -2608(tradeoffs.)X -2964(Using)X -3185(complete)X -3509(transaction)X -3891(protection)X -4246(is)X -555 5464(more)N -747(complicated)X -1166(than)X -1331(simply)X -1575(adding)X -3 f -1820(fsync)X -1 f -1998(\(2\))X -2119(and)X -3 f -2262(\257ock)X -1 f -2426(\(2\))X -2547(calls)X -2721(to)X -2810(code,)X -3008(but)X -3136(it)X -3206(is)X -3285(faster)X -3490(in)X -3578(some)X -3773(cases)X -3969(and)X -4111(offers)X -8 s -10 f -555 5536(hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)N -5 s -1 f -727 5614(5)N -8 s -763 5639(The)N -878(next)X -1004(release)X -1196(of)X -1265(the)X -1359(4.4BSD)X -1580(access)X -1758(method)X -1966(will)X -2082(automatically)X -2446(detect)X -2614(and)X -2722(compensate)X -3039(for)X -3129(in-order)X -3350(insertion,)X -3606(eliminating)X -3914(this)X -4023(problem.)X - -16 p -%%Page: 16 16 -8 s 8 xH 0 xS 1 f -10 s -3 f -1 f -555 630(stricter)N -801(guarantees)X -1168(\(atomicity,)X -1540(consistency,)X -1957(isolation,)X -2275(and)X -2414(durability\).)X -2815(If)X -2892(the)X -3013(data)X -3170(to)X -3255(be)X -3354(protected)X -3676(are)X -3798(already)X -4058(format-)X -555 720(ted)N -675(\()X -2 f -702(i.e.)X -1 f -821(use)X -949(one)X -1086(of)X -1174(the)X -1293(database)X -1591(access)X -1818(methods\),)X -2157(then)X -2316(adding)X -2555(transaction)X -2928(protection)X -3274(requires)X -3554(no)X -3655(additional)X -3996(complex-)X -555 810(ity,)N -679(but)X -801(incurs)X -1017(a)X -1073(performance)X -1500(penalty)X -1756(of)X -1843(approximately)X -2326(15%.)X -755 933(In)N -844(comparison)X -1240(with)X -1404(commercial)X -1805(database)X -2104(systems,)X -2399(the)X -2519(tradeoffs)X -2827(are)X -2948(more)X -3135(complex.)X -3473(LIBTP)X -3717(does)X -3886(not)X -4009(currently)X -555 1023(support)N -825(a)X -891(standard)X -1193(query)X -1406(language.)X -1766(The)X -1921(TCL-based)X -2312(server)X -2539(process)X -2810(allows)X -3049(a)X -3115(certain)X -3364(ease)X -3533(of)X -3630(use)X -3767(which)X -3993(would)X -4223(be)X -555 1113(enhanced)N -882(with)X -1047(a)X -1106(more)X -1294(user-friendly)X -1732(interface)X -2037(\()X -2 f -2064(e.g.)X -1 f -2203(a)X -2261(windows)X -2572(based)X -2777(query-by-form)X -3272(application\),)X -3697(for)X -3813(which)X -4031(we)X -4147(have)X -555 1203(a)N -620(working)X -916(prototype.)X -1292(When)X -1513(accesses)X -1815(do)X -1924(not)X -2055(require)X -2312(sophisticated)X -2758(query)X -2969(processing,)X -3360(the)X -3486(TCL)X -3665(interface)X -3975(is)X -4056(an)X -4160(ade-)X -555 1293(quate)N -756(solution.)X -1080(What)X -1281(LIBTP)X -1529(fails)X -1693(to)X -1781(provide)X -2052(in)X -2140(functionality,)X -2595(it)X -2665(makes)X -2896(up)X -3002(for)X -3122(in)X -3210(performance)X -3643(and)X -3785(\257exibility.)X -4161(Any)X -555 1383(application)N -931(may)X -1089(make)X -1283(use)X -1410(of)X -1497(its)X -1592(record)X -1818(interface)X -2120(or)X -2207(the)X -2325(more)X -2510(primitive)X -2823(log,)X -2965(lock,)X -3143(and)X -3279(buffer)X -3496(calls.)X -755 1506(Future)N -987(work)X -1175(will)X -1322(focus)X -1519(on)X -1621(overcoming)X -2026(some)X -2217(of)X -2306(the)X -2426(areas)X -2614(in)X -2698(which)X -2916(LIBTP)X -3160(is)X -3235(currently)X -3547(de\256cient)X -3845(and)X -3983(extending)X -555 1596(its)N -652(transaction)X -1026(model.)X -1288(The)X -1435(addition)X -1719(of)X -1808(an)X -1905(SQL)X -2077(parser)X -2295(and)X -2432(forms)X -2640(front)X -2817(end)X -2954(will)X -3099(improve)X -3387(the)X -3506(system's)X -3807(ease)X -3967(of)X -4055(use)X -4183(and)X -555 1686(make)N -750(it)X -815(more)X -1001(competitive)X -1400(with)X -1563(commercial)X -1963(systems.)X -2277(In)X -2365(the)X -2484(long)X -2647(term,)X -2835(we)X -2950(would)X -3170(like)X -3310(to)X -3392(add)X -3528(generalized)X -3919(hierarchical)X -555 1776(locking,)N -836(nested)X -1062(transactions,)X -1486(parallel)X -1748(transactions,)X -2171(passing)X -2431(of)X -2518(transactions)X -2921(between)X -3209(processes,)X -3557(and)X -3693(distributed)X -4055(commit)X -555 1866(handling.)N -900(In)X -992(the)X -1115(short)X -1300(term,)X -1492(the)X -1614(next)X -1776(step)X -1929(is)X -2006(to)X -2092(integrate)X -2397(LIBTP)X -2643(with)X -2809(the)X -2931(most)X -3110(recent)X -3331(release)X -3579(of)X -3670(the)X -3792(database)X -4093(access)X -555 1956(routines)N -833(and)X -969(make)X -1163(it)X -1227(freely)X -1435(available)X -1745(via)X -1863(anonymous)X -2252(ftp.)X -3 f -555 2142(7.)N -655(Acknowledgements)X -1 f -755 2265(We)N -888(would)X -1109(like)X -1250(to)X -1332(thank)X -1530(John)X -1701(Wilkes)X -1948(and)X -2084(Carl)X -2242(Staelin)X -2484(of)X -2571(Hewlett-Packard)X -3131(Laboratories)X -3557(and)X -3693(Jon)X -3824(Krueger.)X -4148(John)X -555 2355(and)N -694(Carl)X -855(provided)X -1162(us)X -1255(with)X -1419(an)X -1517(extra)X -1700(disk)X -1855(for)X -1971(the)X -2091(HP)X -2215(testbed)X -2464(less)X -2606(than)X -2766(24)X -2868(hours)X -3068(after)X -3238(we)X -3354(requested)X -3684(it.)X -3770(Jon)X -3903(spent)X -4094(count-)X -555 2445(less)N -699(hours)X -901(helping)X -1164(us)X -1258(understand)X -1633(the)X -1754(intricacies)X -2107(of)X -2197(commercial)X -2599(database)X -2899(products)X -3198(and)X -3337(their)X -3507(behavior)X -3811(under)X -4017(a)X -4076(variety)X -555 2535(of)N -642(system)X -884(con\256gurations.)X -3 f -555 2721(8.)N -655(References)X -1 f -555 2901([ANDR89])N -942(Andrade,)X -1265(J.,)X -1361(Carges,)X -1629(M.,)X -1765(Kovach,)X -2060(K.,)X -2183(``Building)X -2541(an)X -2642(On-Line)X -2939(Transaction)X -3343(Processing)X -3715(System)X -3975(On)X -4098(UNIX)X -727 2991(System)N -982(V'',)X -2 f -1134(CommUNIXations)X -1 f -1725(,)X -1765 0.2188(November/December)AX -2477(1989.)X -555 3171([BAY77])N -878(Bayer,)X -1110(R.,)X -1223(Schkolnick,)X -1623(M.,)X -1754(``Concurrency)X -2243(of)X -2330(Operations)X -2702(on)X -2802(B-Trees'',)X -2 f -3155(Acta)X -3322(Informatica)X -1 f -3700(,)X -3740(1977.)X -555 3351([BERN80])N -936(Bernstein,)X -1297(P.,)X -1415(Goodman,)X -1785(N.,)X -1917(``Timestamp)X -2365(Based)X -2595(Algorithms)X -2992(for)X -3119(Concurrency)X -3567(Control)X -3844(in)X -3939(Distributed)X -727 3441(Database)N -1042(Systems'',)X -2 f -1402(Proceedings)X -1823(6th)X -1945(International)X -2387(Conference)X -2777(on)X -2877(Very)X -3049(Large)X -3260(Data)X -3440(Bases)X -1 f -3627(,)X -3667(October)X -3946(1980.)X -555 3621([BSD91])N -864(DB\(3\),)X -2 f -1109(4.4BSD)X -1376(Unix)X -1552(Programmer's)X -2044(Manual)X -2313(Reference)X -2655(Guide)X -1 f -2851(,)X -2891(University)X -3249(of)X -3336(California,)X -3701(Berkeley,)X -4031(1991.)X -555 3801([CATT91])N -923(Cattell,)X -1181(R.G.G.,)X -1455(``An)X -1632(Engineering)X -2049(Database)X -2369(Benchmark'',)X -2 f -2838(The)X -2983(Benchmark)X -3373(Handbook)X -3731(for)X -3848(Database)X -4179(and)X -727 3891(Transaction)N -1133(Processing)X -1509(Systems)X -1 f -1763(,)X -1803(J.)X -1874(Gray,)X -2075(editor,)X -2302(Morgan)X -2576(Kaufman)X -2895(1991.)X -555 4071([CHEN91])N -929(Cheng,)X -1180(E.,)X -1291(Chang,)X -1542(E.,)X -1653(Klein,)X -1872(J.,)X -1964(Lee,)X -2126(D.,)X -2245(Lu,)X -2375(E.,)X -2485(Lutgardo,)X -2820(A.,)X -2939(Obermarck,)X -3342(R.,)X -3456(``An)X -3629(Open)X -3824(and)X -3961(Extensible)X -727 4161(Event-Based)N -1157(Transaction)X -1556(Manager'',)X -2 f -1936(Proceedings)X -2357(1991)X -2537(Summer)X -2820(Usenix)X -1 f -3043(,)X -3083(Nashville,)X -3430(TN,)X -3577(June)X -3744(1991.)X -555 4341([CHOU85])N -943(Chou,)X -1163(H.,)X -1288(DeWitt,)X -1570(D.,)X -1694(``An)X -1872(Evaluation)X -2245(of)X -2338(Buffer)X -2574(Management)X -3019(Strategies)X -3361(for)X -3481(Relational)X -3836(Database)X -4157(Sys-)X -727 4431(tems'',)N -2 f -972(Proceedings)X -1393(of)X -1475(the)X -1593(11th)X -1755(International)X -2197(Conference)X -2587(on)X -2687(Very)X -2859(Large)X -3070(Databases)X -1 f -3408(,)X -3448(1985.)X -555 4611([DEWI84])N -925(DeWitt,)X -1207(D.,)X -1331(Katz,)X -1529(R.,)X -1648(Olken,)X -1890(F.,)X -2000(Shapiro,)X -2295(L.,)X -2410(Stonebraker,)X -2843(M.,)X -2979(Wood,)X -3220(D.,)X -3343(``Implementation)X -3929(Techniques)X -727 4701(for)N -841(Main)X -1030(Memory)X -1326(Database)X -1641(Systems'',)X -2 f -2001(Proceedings)X -2422(of)X -2504(SIGMOD)X -1 f -2812(,)X -2852(pp.)X -2972(1-8,)X -3119(June)X -3286(1984.)X -555 4881([GRAY76])N -944(Gray,)X -1153(J.,)X -1252(Lorie,)X -1474(R.,)X -1595(Putzolu,)X -1887(F.,)X -1999(and)X -2143(Traiger,)X -2428(I.,)X -2522(``Granularity)X -2973(of)X -3067(locks)X -3263(and)X -3406(degrees)X -3679(of)X -3773(consistency)X -4174(in)X -4263(a)X -727 4971(large)N -909(shared)X -1140(data)X -1295(base'',)X -2 f -1533(Modeling)X -1861(in)X -1944(Data)X -2125(Base)X -2301(Management)X -2740(Systems)X -1 f -2994(,)X -3034(Elsevier)X -3317(North)X -3524(Holland,)X -3822(New)X -3994(York,)X -4199(pp.)X -727 5061(365-394.)N -555 5241([HAER83])N -931(Haerder,)X -1235(T.)X -1348(Reuter,)X -1606(A.)X -1728(``Principles)X -2126(of)X -2217(Transaction-Oriented)X -2928(Database)X -3246(Recovery'',)X -2 f -3651(Computing)X -4029(Surveys)X -1 f -4279(,)X -727 5331(15\(4\);)N -943(237-318,)X -1250(1983.)X -555 5511([KUNG81])N -943(Kung,)X -1162(H.)X -1261(T.,)X -1371(Richardson,)X -1777(J.,)X -1869(``On)X -2042(Optimistic)X -2400(Methods)X -2701(for)X -2816(Concurrency)X -3252(Control'',)X -2 f -3591(ACM)X -3781(Transactions)X -4219(on)X -727 5601(Database)N -1054(Systems)X -1 f -1328(6\(2\);)X -1504(213-226,)X -1811(1981.)X - -17 p -%%Page: 17 17 -10 s 10 xH 0 xS 1 f -3 f -1 f -555 630([LEHM81])N -939(Lehman,)X -1245(P.,)X -1352(Yao,)X -1529(S.,)X -1636(``Ef\256cient)X -1989(Locking)X -2279(for)X -2396(Concurrent)X -2780(Operations)X -3155(on)X -3258(B-trees'',)X -2 f -3587(ACM)X -3779(Transactions)X -4219(on)X -727 720(Database)N -1054(Systems)X -1 f -1308(,)X -1348(6\(4\),)X -1522(December)X -1873(1981.)X -555 900([MOHA91])N -964(Mohan,)X -1241(C.,)X -1364(Pirahesh,)X -1690(H.,)X -1818(``ARIES-RRH:)X -2366(Restricted)X -2721(Repeating)X -3076(of)X -3173(History)X -3442(in)X -3533(the)X -3660(ARIES)X -3920(Transaction)X -727 990(Recovery)N -1055(Method'',)X -2 f -1398(Proceedings)X -1819(7th)X -1941(International)X -2383(Conference)X -2773(on)X -2873(Data)X -3053(Engineering)X -1 f -3449(,)X -3489(Kobe,)X -3703(Japan,)X -3926(April)X -4115(1991.)X -555 1170([NODI90])N -914(Nodine,)X -1194(M.,)X -1328(Zdonik,)X -1602(S.,)X -1709(``Cooperative)X -2178(Transaction)X -2580(Hierarchies:)X -2996(A)X -3077(Transaction)X -3479(Model)X -3711(to)X -3796(Support)X -4072(Design)X -727 1260(Applications'',)N -2 f -1242(Proceedings)X -1675(16th)X -1849(International)X -2303(Conference)X -2704(on)X -2815(Very)X -2998(Large)X -3220(Data)X -3411(Bases)X -1 f -3598(,)X -3649(Brisbane,)X -3985(Australia,)X -727 1350(August)N -978(1990.)X -555 1530([OUST90])N -923(Ousterhout,)X -1324(J.,)X -1420(``Tcl:)X -1648(An)X -1771(Embeddable)X -2197(Command)X -2555(Language'',)X -2 f -2971(Proceedings)X -3396(1990)X -3580(Winter)X -3822(Usenix)X -1 f -4045(,)X -4089(Wash-)X -727 1620(ington,)N -971(D.C.,)X -1162(January)X -1432(1990.)X -555 1800([POSIX91])N -955(``Unapproved)X -1441(Draft)X -1645(for)X -1773(Realtime)X -2096(Extension)X -2450(for)X -2578(Portable)X -2879(Operating)X -3234(Systems'',)X -3608(Draft)X -3812(11,)X -3946(October)X -4239(7,)X -727 1890(1991,)N -927(IEEE)X -1121(Computer)X -1461(Society.)X -555 2070([ROSE91])N -925(Rosenblum,)X -1341(M.,)X -1484(Ousterhout,)X -1892(J.,)X -1995(``The)X -2206(Design)X -2464(and)X -2611(Implementation)X -3149(of)X -3247(a)X -3314(Log-Structured)X -3835(File)X -3990(System'',)X -2 f -727 2160(Proceedings)N -1148(of)X -1230(the)X -1348(13th)X -1510(Symposium)X -1895(on)X -1995(Operating)X -2344(Systems)X -2618(Principles)X -1 f -2947(,)X -2987(1991.)X -555 2340([SELT91])N -904(Seltzer,)X -1171(M.,)X -1306(Stonebraker,)X -1738(M.,)X -1873(``Read)X -2116(Optimized)X -2478(File)X -2626(Systems:)X -2938(A)X -3020(Performance)X -3454(Evaluation'',)X -2 f -3898(Proceedings)X -727 2430(7th)N -849(Annual)X -1100(International)X -1542(Conference)X -1932(on)X -2032(Data)X -2212(Engineering)X -1 f -2608(,)X -2648(Kobe,)X -2862(Japan,)X -3085(April)X -3274(1991.)X -555 2610([SPEC88])N -907(Spector,)X -1200(Rausch,)X -1484(Bruell,)X -1732(``Camelot:)X -2107(A)X -2192(Flexible,)X -2501(Distributed)X -2888(Transaction)X -3294(Processing)X -3668(System'',)X -2 f -4004(Proceed-)X -727 2700(ings)N -880(of)X -962(Spring)X -1195(COMPCON)X -1606(1988)X -1 f -(,)S -1806(February)X -2116(1988.)X -555 2880([SQL86])N -862(American)X -1201(National)X -1499(Standards)X -1836(Institute,)X -2139(``Database)X -2509(Language)X -2847(SQL'',)X -3093(ANSI)X -3301(X3.135-1986)X -3747(\(ISO)X -3924(9075\),)X -4152(May)X -727 2970(1986.)N -555 3150([STON81])N -919(Stonebraker,)X -1348(M.,)X -1480(``Operating)X -1876(System)X -2132(Support)X -2406(for)X -2520(Database)X -2835(Management'',)X -2 f -3348(Communications)X -3910(of)X -3992(the)X -4110(ACM)X -1 f -4279(,)X -727 3240(1981.)N -555 3420([SULL92])N -925(Sullivan,)X -1247(M.,)X -1394(Olson,)X -1641(M.,)X -1788(``An)X -1976(Index)X -2195(Implementation)X -2737(Supporting)X -3127(Fast)X -3295(Recovery)X -3638(for)X -3767(the)X -3900(POSTGRES)X -727 3510(Storage)N -1014(System'',)X -1365(to)X -1469(appear)X -1726(in)X -2 f -1830(Proceedings)X -2272(8th)X -2415(Annual)X -2687(International)X -3150(Conference)X -3561(on)X -3682(Data)X -3883(Engineering)X -1 f -4279(,)X -727 3600(Tempe,)N -990(Arizona,)X -1289(February)X -1599(1992.)X -555 3780([TPCB90])N -914(Transaction)X -1319(Processing)X -1692(Performance)X -2129(Council,)X -2428(``TPC)X -2653(Benchmark)X -3048(B'',)X -3200(Standard)X -3510(Speci\256cation,)X -3973(Waterside)X -727 3870(Associates,)N -1110(Fremont,)X -1421(CA.,)X -1592(1990.)X -555 4050([YOUN91])N -947(Young,)X -1211(M.)X -1328(W.,)X -1470(Thompson,)X -1858(D.)X -1962(S.,)X -2072(Jaffe,)X -2274(E.,)X -2388(``A)X -2525(Modular)X -2826(Architecture)X -3253(for)X -3372(Distributed)X -3757(Transaction)X -4161(Pro-)X -727 4140(cessing'',)N -2 f -1057(Proceedings)X -1478(1991)X -1658(Winter)X -1896(Usenix)X -1 f -2119(,)X -2159(Dallas,)X -2404(TX,)X -2551(January)X -2821(1991.)X -3 f -755 4263(Margo)N -1008(I.)X -1080(Seltzer)X -1 f -1338(is)X -1411(a)X -1467(Ph.D.)X -1669(student)X -1920(in)X -2002(the)X -2120(Department)X -2519(of)X -2606(Electrical)X -2934(Engineering)X -3346(and)X -3482(Computer)X -3822(Sciences)X -4123(at)X -4201(the)X -555 4353(University)N -919(of)X -1012(California,)X -1383(Berkeley.)X -1739(Her)X -1886(research)X -2181(interests)X -2474(include)X -2735(\256le)X -2862(systems,)X -3160(databases,)X -3513(and)X -3654(transaction)X -4031(process-)X -555 4443(ing)N -686(systems.)X -1008(She)X -1157(spent)X -1355(several)X -1612(years)X -1811(working)X -2107(at)X -2194(startup)X -2441(companies)X -2813(designing)X -3153(and)X -3298(implementing)X -3771(\256le)X -3902(systems)X -4183(and)X -555 4533(transaction)N -929(processing)X -1294(software)X -1592(and)X -1729(designing)X -2061(microprocessors.)X -2648(Ms.)X -2791(Seltzer)X -3035(received)X -3329(her)X -3453(AB)X -3585(in)X -3668(Applied)X -3947(Mathemat-)X -555 4623(ics)N -664(from)X -840 0.1953(Harvard/Radcliffe)AX -1445(College)X -1714(in)X -1796(1983.)X -755 4746(In)N -845(her)X -971(spare)X -1163(time,)X -1347(Margo)X -1583(can)X -1717(usually)X -1970(be)X -2068(found)X -2277(preparing)X -2607(massive)X -2887(quantities)X -3220(of)X -3309(food)X -3478(for)X -3594(hungry)X -3843(hordes,)X -4099(study-)X -555 4836(ing)N -677(Japanese,)X -1003(or)X -1090(playing)X -1350(soccer)X -1576(with)X -1738(an)X -1834(exciting)X -2112(Bay)X -2261(Area)X -2438(Women's)X -2770(Soccer)X -3009(team,)X -3205(the)X -3323(Berkeley)X -3633(Bruisers.)X -3 f -755 5049(Michael)N -1056(A.)X -1159(Olson)X -1 f -1383(is)X -1461(a)X -1522(Master's)X -1828(student)X -2084(in)X -2170(the)X -2292(Department)X -2695(of)X -2786(Electrical)X -3118(Engineering)X -3534(and)X -3674(Computer)X -4018(Sciences)X -555 5139(at)N -645(the)X -774(University)X -1143(of)X -1241(California,)X -1617(Berkeley.)X -1978(His)X -2120(primary)X -2405(interests)X -2703(are)X -2833(database)X -3141(systems)X -3425(and)X -3572(mass)X -3763(storage)X -4026(systems.)X -555 5229(Mike)N -759(spent)X -963(two)X -1118(years)X -1323(working)X -1625(for)X -1754(a)X -1825(commercial)X -2239(database)X -2551(system)X -2808(vendor)X -3066(before)X -3307(joining)X -3567(the)X -3699(Postgres)X -4004(Research)X -555 5319(Group)N -780(at)X -858(Berkeley)X -1168(in)X -1250(1988.)X -1470(He)X -1584(received)X -1877(his)X -1990(B.A.)X -2161(in)X -2243(Computer)X -2583(Science)X -2853(from)X -3029(Berkeley)X -3339(in)X -3421(May)X -3588(1991.)X -755 5442(Mike)N -945(only)X -1108(recently)X -1388(transferred)X -1758(into)X -1903(Sin)X -2030(City,)X -2208(but)X -2330(is)X -2403(rapidly)X -2650(adopting)X -2950(local)X -3126(customs)X -3408(and)X -3544(coloration.)X -3929(In)X -4016(his)X -4129(spare)X -555 5532(time,)N -742(he)X -843(organizes)X -1176(informal)X -1477(Friday)X -1711(afternoon)X -2043(study)X -2240(groups)X -2482(to)X -2568(discuss)X -2823(recent)X -3044(technical)X -3358(and)X -3498(economic)X -3834(developments.)X -555 5622(Among)N -815(his)X -928(hobbies)X -1197(are)X -1316(Charles)X -1581(Dickens,)X -1884(Red)X -2033(Rock,)X -2242(and)X -2378(speaking)X -2683(Dutch)X -2899(to)X -2981(anyone)X -3233(who)X -3391(will)X -3535(permit)X -3764(it.)X - -17 p -%%Trailer -xt - -xs - diff --git a/lib/libc/db/hash/Makefile.inc b/lib/libc/db/hash/Makefile.inc deleted file mode 100644 index 38b523d..0000000 --- a/lib/libc/db/hash/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 -# $FreeBSD$ - -.PATH: ${.CURDIR}/../libc/db/hash - -SRCS+= hash.c hash_bigkey.c hash_buf.c hash_func.c hash_log2.c \ - hash_page.c hsearch.c ndbm.c diff --git a/lib/libc/db/hash/README b/lib/libc/db/hash/README deleted file mode 100644 index f29ccf7..0000000 --- a/lib/libc/db/hash/README +++ /dev/null @@ -1,72 +0,0 @@ -# @(#)README 8.1 (Berkeley) 6/4/93 - -This package implements a superset of the hsearch and dbm/ndbm libraries. - -Test Programs: - All test programs which need key/data pairs expect them entered - with key and data on separate lines - - tcreat3.c - Takes - bucketsize (bsize), - fill factor (ffactor), and - initial number of elements (nelem). - Creates a hash table named hashtest containing the - keys/data pairs entered from standard in. - thash4.c - Takes - bucketsize (bsize), - fill factor (ffactor), - initial number of elements (nelem) - bytes of cache (ncached), and - file from which to read data (fname) - Creates a table from the key/data pairs on standard in and - then does a read of each key/data in fname - tdel.c - Takes - bucketsize (bsize), and - fill factor (ffactor). - file from which to read data (fname) - Reads each key/data pair from fname and deletes the - key from the hash table hashtest - tseq.c - Reads the key/data pairs in the file hashtest and writes them - to standard out. - tread2.c - Takes - butes of cache (ncached). - Reads key/data pairs from standard in and looks them up - in the file hashtest. - tverify.c - Reads key/data pairs from standard in, looks them up - in the file hashtest, and verifies that the data is - correct. - -NOTES: - -The file search.h is provided for using the hsearch compatible interface -on BSD systems. On System V derived systems, search.h should appear in -/usr/include. - -The man page ../man/db.3 explains the interface to the hashing system. -The file hash.ps is a postscript copy of a paper explaining -the history, implementation, and performance of the hash package. - -"bugs" or idiosyncracies - -If you have a lot of overflows, it is possible to run out of overflow -pages. Currently, this will cause a message to be printed on stderr. -Eventually, this will be indicated by a return error code. - -If you are using the ndbm interface and exit without flushing or closing the -file, you may lose updates since the package buffers all writes. Also, -the db interface only creates a single database file. To avoid overwriting -the user's original file, the suffix ".db" is appended to the file name -passed to dbm_open. Additionally, if your code "knows" about the historic -.dir and .pag files, it will break. - -There is a fundamental difference between this package and the old hsearch. -Hsearch requires the user to maintain the keys and data in the application's -allocated memory while hash takes care of all storage management. The down -side is that the byte strings passed in the ENTRY structure must be null -terminated (both the keys and the data). diff --git a/lib/libc/db/hash/extern.h b/lib/libc/db/hash/extern.h deleted file mode 100644 index 3167e6d..0000000 --- a/lib/libc/db/hash/extern.h +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * Copyright (c) 1991, 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. - * - * @(#)extern.h 8.4 (Berkeley) 6/16/94 - */ - -BUFHEAD *__add_ovflpage __P((HTAB *, BUFHEAD *)); -int __addel __P((HTAB *, BUFHEAD *, const DBT *, const DBT *)); -int __big_delete __P((HTAB *, BUFHEAD *)); -int __big_insert __P((HTAB *, BUFHEAD *, const DBT *, const DBT *)); -int __big_keydata __P((HTAB *, BUFHEAD *, DBT *, DBT *, int)); -int __big_return __P((HTAB *, BUFHEAD *, int, DBT *, int)); -int __big_split __P((HTAB *, BUFHEAD *, BUFHEAD *, BUFHEAD *, - int, u_int32_t, SPLIT_RETURN *)); -int __buf_free __P((HTAB *, int, int)); -void __buf_init __P((HTAB *, int)); -u_int32_t __call_hash __P((HTAB *, char *, int)); -int __delpair __P((HTAB *, BUFHEAD *, int)); -int __expand_table __P((HTAB *)); -int __find_bigpair __P((HTAB *, BUFHEAD *, int, char *, int)); -u_int16_t __find_last_page __P((HTAB *, BUFHEAD **)); -void __free_ovflpage __P((HTAB *, BUFHEAD *)); -BUFHEAD *__get_buf __P((HTAB *, u_int32_t, BUFHEAD *, int)); -int __get_page __P((HTAB *, char *, u_int32_t, int, int, int)); -int __ibitmap __P((HTAB *, int, int, int)); -u_int32_t __log2 __P((u_int32_t)); -int __put_page __P((HTAB *, char *, u_int32_t, int, int)); -void __reclaim_buf __P((HTAB *, BUFHEAD *)); -int __split_page __P((HTAB *, u_int32_t, u_int32_t)); - -/* Default hash routine. */ -extern u_int32_t (*__default_hash) __P((const void *, size_t)); - -#ifdef HASH_STATISTICS -extern int hash_accesses, hash_collisions, hash_expansions, hash_overflows; -#endif diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c deleted file mode 100644 index dcef5df..0000000 --- a/lib/libc/db/hash/hash.c +++ /dev/null @@ -1,1003 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hash.c 8.9 (Berkeley) 6/16/94"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#ifdef DEBUG -#include -#endif - -#include -#include "hash.h" -#include "page.h" -#include "extern.h" - -static int alloc_segs __P((HTAB *, int)); -static int flush_meta __P((HTAB *)); -static int hash_access __P((HTAB *, ACTION, DBT *, DBT *)); -static int hash_close __P((DB *)); -static int hash_delete __P((const DB *, const DBT *, u_int32_t)); -static int hash_fd __P((const DB *)); -static int hash_get __P((const DB *, const DBT *, DBT *, u_int32_t)); -static int hash_put __P((const DB *, DBT *, const DBT *, u_int32_t)); -static void *hash_realloc __P((SEGMENT **, int, int)); -static int hash_seq __P((const DB *, DBT *, DBT *, u_int32_t)); -static int hash_sync __P((const DB *, u_int32_t)); -static int hdestroy __P((HTAB *)); -static HTAB *init_hash __P((HTAB *, const char *, HASHINFO *)); -static int init_htab __P((HTAB *, int)); -#if BYTE_ORDER == LITTLE_ENDIAN -static void swap_header __P((HTAB *)); -static void swap_header_copy __P((HASHHDR *, HASHHDR *)); -#endif - -/* Fast arithmetic, relying on powers of 2, */ -#define MOD(x, y) ((x) & ((y) - 1)) - -#define RETURN_ERROR(ERR, LOC) { save_errno = ERR; goto LOC; } - -/* Return values */ -#define SUCCESS (0) -#define ERROR (-1) -#define ABNORMAL (1) - -#ifdef HASH_STATISTICS -int hash_accesses, hash_collisions, hash_expansions, hash_overflows; -#endif - -/************************** INTERFACE ROUTINES ***************************/ -/* OPEN/CLOSE */ - -extern DB * -__hash_open(file, flags, mode, info, dflags) - const char *file; - int flags, mode, dflags; - const HASHINFO *info; /* Special directives for create */ -{ - HTAB *hashp; - struct stat statbuf; - DB *dbp; - int bpages, hdrsize, new_table, nsegs, save_errno; - - if ((flags & O_ACCMODE) == O_WRONLY) { - errno = EINVAL; - return (NULL); - } - - if (!(hashp = (HTAB *)calloc(1, sizeof(HTAB)))) - return (NULL); - hashp->fp = -1; - - /* - * Even if user wants write only, we need to be able to read - * the actual file, so we need to open it read/write. But, the - * field in the hashp structure needs to be accurate so that - * we can check accesses. - */ - hashp->flags = flags; - - new_table = 0; - if (!file || (flags & O_TRUNC) || - (stat(file, &statbuf) && (errno == ENOENT))) { - if (errno == ENOENT) - errno = 0; /* Just in case someone looks at errno */ - new_table = 1; - } - if (file) { - if ((hashp->fp = _open(file, flags, mode)) == -1) - RETURN_ERROR(errno, error0); - - /* if the .db file is empty, and we had permission to create - a new .db file, then reinitialize the database */ - if ((flags & O_CREAT) && - fstat(hashp->fp, &statbuf) == 0 && statbuf.st_size == 0) - new_table = 1; - - (void)_fcntl(hashp->fp, F_SETFD, 1); - } - if (new_table) { - if (!(hashp = init_hash(hashp, file, (HASHINFO *)info))) - RETURN_ERROR(errno, error1); - } else { - /* Table already exists */ - if (info && info->hash) - hashp->hash = info->hash; - else - hashp->hash = __default_hash; - - hdrsize = _read(hashp->fp, &hashp->hdr, sizeof(HASHHDR)); -#if BYTE_ORDER == LITTLE_ENDIAN - swap_header(hashp); -#endif - if (hdrsize == -1) - RETURN_ERROR(errno, error1); - if (hdrsize != sizeof(HASHHDR)) - RETURN_ERROR(EFTYPE, error1); - /* Verify file type, versions and hash function */ - if (hashp->MAGIC != HASHMAGIC) - RETURN_ERROR(EFTYPE, error1); -#define OLDHASHVERSION 1 - if (hashp->VERSION != HASHVERSION && - hashp->VERSION != OLDHASHVERSION) - RETURN_ERROR(EFTYPE, error1); - if (hashp->hash(CHARKEY, sizeof(CHARKEY)) != hashp->H_CHARKEY) - RETURN_ERROR(EFTYPE, error1); - /* - * Figure out how many segments we need. Max_Bucket is the - * maximum bucket number, so the number of buckets is - * max_bucket + 1. - */ - nsegs = (hashp->MAX_BUCKET + 1 + hashp->SGSIZE - 1) / - hashp->SGSIZE; - hashp->nsegs = 0; - if (alloc_segs(hashp, nsegs)) - /* - * If alloc_segs fails, table will have been destroyed - * and errno will have been set. - */ - return (NULL); - /* Read in bitmaps */ - bpages = (hashp->SPARES[hashp->OVFL_POINT] + - (hashp->BSIZE << BYTE_SHIFT) - 1) >> - (hashp->BSHIFT + BYTE_SHIFT); - - hashp->nmaps = bpages; - (void)memset(&hashp->mapp[0], 0, bpages * sizeof(u_int32_t *)); - } - - /* Initialize Buffer Manager */ - if (info && info->cachesize) - __buf_init(hashp, info->cachesize); - else - __buf_init(hashp, DEF_BUFSIZE); - - hashp->new_file = new_table; - hashp->save_file = file && (hashp->flags & O_RDWR); - hashp->cbucket = -1; - if (!(dbp = (DB *)malloc(sizeof(DB)))) { - save_errno = errno; - hdestroy(hashp); - errno = save_errno; - return (NULL); - } - dbp->internal = hashp; - dbp->close = hash_close; - dbp->del = hash_delete; - dbp->fd = hash_fd; - dbp->get = hash_get; - dbp->put = hash_put; - dbp->seq = hash_seq; - dbp->sync = hash_sync; - dbp->type = DB_HASH; - -#ifdef DEBUG - (void)fprintf(stderr, -"%s\n%s%x\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%x\n%s%x\n%s%d\n%s%d\n", - "init_htab:", - "TABLE POINTER ", hashp, - "BUCKET SIZE ", hashp->BSIZE, - "BUCKET SHIFT ", hashp->BSHIFT, - "DIRECTORY SIZE ", hashp->DSIZE, - "SEGMENT SIZE ", hashp->SGSIZE, - "SEGMENT SHIFT ", hashp->SSHIFT, - "FILL FACTOR ", hashp->FFACTOR, - "MAX BUCKET ", hashp->MAX_BUCKET, - "OVFL POINT ", hashp->OVFL_POINT, - "LAST FREED ", hashp->LAST_FREED, - "HIGH MASK ", hashp->HIGH_MASK, - "LOW MASK ", hashp->LOW_MASK, - "NSEGS ", hashp->nsegs, - "NKEYS ", hashp->NKEYS); -#endif -#ifdef HASH_STATISTICS - hash_overflows = hash_accesses = hash_collisions = hash_expansions = 0; -#endif - return (dbp); - -error1: - if (hashp != NULL) - (void)_close(hashp->fp); - -error0: - free(hashp); - errno = save_errno; - return (NULL); -} - -static int -hash_close(dbp) - DB *dbp; -{ - HTAB *hashp; - int retval; - - if (!dbp) - return (ERROR); - - hashp = (HTAB *)dbp->internal; - retval = hdestroy(hashp); - free(dbp); - return (retval); -} - -static int -hash_fd(dbp) - const DB *dbp; -{ - HTAB *hashp; - - if (!dbp) - return (ERROR); - - hashp = (HTAB *)dbp->internal; - if (hashp->fp == -1) { - errno = ENOENT; - return (-1); - } - return (hashp->fp); -} - -/************************** LOCAL CREATION ROUTINES **********************/ -static HTAB * -init_hash(hashp, file, info) - HTAB *hashp; - const char *file; - HASHINFO *info; -{ - struct stat statbuf; - int nelem; - - nelem = 1; - hashp->NKEYS = 0; - hashp->LORDER = BYTE_ORDER; - hashp->BSIZE = DEF_BUCKET_SIZE; - hashp->BSHIFT = DEF_BUCKET_SHIFT; - hashp->SGSIZE = DEF_SEGSIZE; - hashp->SSHIFT = DEF_SEGSIZE_SHIFT; - hashp->DSIZE = DEF_DIRSIZE; - hashp->FFACTOR = DEF_FFACTOR; - hashp->hash = __default_hash; - memset(hashp->SPARES, 0, sizeof(hashp->SPARES)); - memset(hashp->BITMAPS, 0, sizeof (hashp->BITMAPS)); - - /* Fix bucket size to be optimal for file system */ - if (file != NULL) { - if (stat(file, &statbuf)) - return (NULL); - hashp->BSIZE = statbuf.st_blksize; - hashp->BSHIFT = __log2(hashp->BSIZE); - } - - if (info) { - if (info->bsize) { - /* Round pagesize up to power of 2 */ - hashp->BSHIFT = __log2(info->bsize); - hashp->BSIZE = 1 << hashp->BSHIFT; - if (hashp->BSIZE > MAX_BSIZE) { - errno = EINVAL; - return (NULL); - } - } - if (info->ffactor) - hashp->FFACTOR = info->ffactor; - if (info->hash) - hashp->hash = info->hash; - if (info->nelem) - nelem = info->nelem; - if (info->lorder) { - if (info->lorder != BIG_ENDIAN && - info->lorder != LITTLE_ENDIAN) { - errno = EINVAL; - return (NULL); - } - hashp->LORDER = info->lorder; - } - } - /* init_htab should destroy the table and set errno if it fails */ - if (init_htab(hashp, nelem)) - return (NULL); - else - return (hashp); -} -/* - * This calls alloc_segs which may run out of memory. Alloc_segs will destroy - * the table and set errno, so we just pass the error information along. - * - * Returns 0 on No Error - */ -static int -init_htab(hashp, nelem) - HTAB *hashp; - int nelem; -{ - register int nbuckets, nsegs; - int l2; - - /* - * Divide number of elements by the fill factor and determine a - * desired number of buckets. Allocate space for the next greater - * power of two number of buckets. - */ - nelem = (nelem - 1) / hashp->FFACTOR + 1; - - l2 = __log2(MAX(nelem, 2)); - nbuckets = 1 << l2; - - hashp->SPARES[l2] = l2 + 1; - hashp->SPARES[l2 + 1] = l2 + 1; - hashp->OVFL_POINT = l2; - hashp->LAST_FREED = 2; - - /* First bitmap page is at: splitpoint l2 page offset 1 */ - if (__ibitmap(hashp, OADDR_OF(l2, 1), l2 + 1, 0)) - return (-1); - - hashp->MAX_BUCKET = hashp->LOW_MASK = nbuckets - 1; - hashp->HIGH_MASK = (nbuckets << 1) - 1; - hashp->HDRPAGES = ((MAX(sizeof(HASHHDR), MINHDRSIZE) - 1) >> - hashp->BSHIFT) + 1; - - nsegs = (nbuckets - 1) / hashp->SGSIZE + 1; - nsegs = 1 << __log2(nsegs); - - if (nsegs > hashp->DSIZE) - hashp->DSIZE = nsegs; - return (alloc_segs(hashp, nsegs)); -} - -/********************** DESTROY/CLOSE ROUTINES ************************/ - -/* - * Flushes any changes to the file if necessary and destroys the hashp - * structure, freeing all allocated space. - */ -static int -hdestroy(hashp) - HTAB *hashp; -{ - int i, save_errno; - - save_errno = 0; - -#ifdef HASH_STATISTICS - (void)fprintf(stderr, "hdestroy: accesses %ld collisions %ld\n", - hash_accesses, hash_collisions); - (void)fprintf(stderr, "hdestroy: expansions %ld\n", - hash_expansions); - (void)fprintf(stderr, "hdestroy: overflows %ld\n", - hash_overflows); - (void)fprintf(stderr, "keys %ld maxp %d segmentcount %d\n", - hashp->NKEYS, hashp->MAX_BUCKET, hashp->nsegs); - - for (i = 0; i < NCACHED; i++) - (void)fprintf(stderr, - "spares[%d] = %d\n", i, hashp->SPARES[i]); -#endif - /* - * Call on buffer manager to free buffers, and if required, - * write them to disk. - */ - if (__buf_free(hashp, 1, hashp->save_file)) - save_errno = errno; - if (hashp->dir) { - free(*hashp->dir); /* Free initial segments */ - /* Free extra segments */ - while (hashp->exsegs--) - free(hashp->dir[--hashp->nsegs]); - free(hashp->dir); - } - if (flush_meta(hashp) && !save_errno) - save_errno = errno; - /* Free Bigmaps */ - for (i = 0; i < hashp->nmaps; i++) - if (hashp->mapp[i]) - free(hashp->mapp[i]); - - if (hashp->fp != -1) - (void)_close(hashp->fp); - - free(hashp); - - if (save_errno) { - errno = save_errno; - return (ERROR); - } - return (SUCCESS); -} -/* - * Write modified pages to disk - * - * Returns: - * 0 == OK - * -1 ERROR - */ -static int -hash_sync(dbp, flags) - const DB *dbp; - u_int32_t flags; -{ - HTAB *hashp; - - if (flags != 0) { - errno = EINVAL; - return (ERROR); - } - - if (!dbp) - return (ERROR); - - hashp = (HTAB *)dbp->internal; - if (!hashp->save_file) - return (0); - if (__buf_free(hashp, 0, 1) || flush_meta(hashp)) - return (ERROR); - hashp->new_file = 0; - return (0); -} - -/* - * Returns: - * 0 == OK - * -1 indicates that errno should be set - */ -static int -flush_meta(hashp) - HTAB *hashp; -{ - HASHHDR *whdrp; -#if BYTE_ORDER == LITTLE_ENDIAN - HASHHDR whdr; -#endif - int fp, i, wsize; - - if (!hashp->save_file) - return (0); - hashp->MAGIC = HASHMAGIC; - hashp->VERSION = HASHVERSION; - hashp->H_CHARKEY = hashp->hash(CHARKEY, sizeof(CHARKEY)); - - fp = hashp->fp; - whdrp = &hashp->hdr; -#if BYTE_ORDER == LITTLE_ENDIAN - whdrp = &whdr; - swap_header_copy(&hashp->hdr, whdrp); -#endif - if ((lseek(fp, (off_t)0, SEEK_SET) == -1) || - ((wsize = _write(fp, whdrp, sizeof(HASHHDR))) == -1)) - return (-1); - else - if (wsize != sizeof(HASHHDR)) { - errno = EFTYPE; - hashp->error = errno; - return (-1); - } - for (i = 0; i < NCACHED; i++) - if (hashp->mapp[i]) - if (__put_page(hashp, (char *)hashp->mapp[i], - hashp->BITMAPS[i], 0, 1)) - return (-1); - return (0); -} - -/*******************************SEARCH ROUTINES *****************************/ -/* - * All the access routines return - * - * Returns: - * 0 on SUCCESS - * 1 to indicate an external ERROR (i.e. key not found, etc) - * -1 to indicate an internal ERROR (i.e. out of memory, etc) - */ -static int -hash_get(dbp, key, data, flag) - const DB *dbp; - const DBT *key; - DBT *data; - u_int32_t flag; -{ - HTAB *hashp; - - hashp = (HTAB *)dbp->internal; - if (flag) { - hashp->error = errno = EINVAL; - return (ERROR); - } - return (hash_access(hashp, HASH_GET, (DBT *)key, data)); -} - -static int -hash_put(dbp, key, data, flag) - const DB *dbp; - DBT *key; - const DBT *data; - u_int32_t flag; -{ - HTAB *hashp; - - hashp = (HTAB *)dbp->internal; - if (flag && flag != R_NOOVERWRITE) { - hashp->error = errno = EINVAL; - return (ERROR); - } - if ((hashp->flags & O_ACCMODE) == O_RDONLY) { - hashp->error = errno = EPERM; - return (ERROR); - } - return (hash_access(hashp, flag == R_NOOVERWRITE ? - HASH_PUTNEW : HASH_PUT, (DBT *)key, (DBT *)data)); -} - -static int -hash_delete(dbp, key, flag) - const DB *dbp; - const DBT *key; - u_int32_t flag; /* Ignored */ -{ - HTAB *hashp; - - hashp = (HTAB *)dbp->internal; - if (flag && flag != R_CURSOR) { - hashp->error = errno = EINVAL; - return (ERROR); - } - if ((hashp->flags & O_ACCMODE) == O_RDONLY) { - hashp->error = errno = EPERM; - return (ERROR); - } - return (hash_access(hashp, HASH_DELETE, (DBT *)key, NULL)); -} - -/* - * Assume that hashp has been set in wrapper routine. - */ -static int -hash_access(hashp, action, key, val) - HTAB *hashp; - ACTION action; - DBT *key, *val; -{ - register BUFHEAD *rbufp; - BUFHEAD *bufp, *save_bufp; - register u_int16_t *bp; - register int n, ndx, off, size; - register char *kp; - u_int16_t pageno; - -#ifdef HASH_STATISTICS - hash_accesses++; -#endif - - off = hashp->BSIZE; - size = key->size; - kp = (char *)key->data; - rbufp = __get_buf(hashp, __call_hash(hashp, kp, size), NULL, 0); - if (!rbufp) - return (ERROR); - save_bufp = rbufp; - - /* Pin the bucket chain */ - rbufp->flags |= BUF_PIN; - for (bp = (u_int16_t *)rbufp->page, n = *bp++, ndx = 1; ndx < n;) - if (bp[1] >= REAL_KEY) { - /* Real key/data pair */ - if (size == off - *bp && - memcmp(kp, rbufp->page + *bp, size) == 0) - goto found; - off = bp[1]; -#ifdef HASH_STATISTICS - hash_collisions++; -#endif - bp += 2; - ndx += 2; - } else if (bp[1] == OVFLPAGE) { - rbufp = __get_buf(hashp, *bp, rbufp, 0); - if (!rbufp) { - save_bufp->flags &= ~BUF_PIN; - return (ERROR); - } - /* FOR LOOP INIT */ - bp = (u_int16_t *)rbufp->page; - n = *bp++; - ndx = 1; - off = hashp->BSIZE; - } else if (bp[1] < REAL_KEY) { - if ((ndx = - __find_bigpair(hashp, rbufp, ndx, kp, size)) > 0) - goto found; - if (ndx == -2) { - bufp = rbufp; - if (!(pageno = - __find_last_page(hashp, &bufp))) { - ndx = 0; - rbufp = bufp; - break; /* FOR */ - } - rbufp = __get_buf(hashp, pageno, bufp, 0); - if (!rbufp) { - save_bufp->flags &= ~BUF_PIN; - return (ERROR); - } - /* FOR LOOP INIT */ - bp = (u_int16_t *)rbufp->page; - n = *bp++; - ndx = 1; - off = hashp->BSIZE; - } else { - save_bufp->flags &= ~BUF_PIN; - return (ERROR); - } - } - - /* Not found */ - switch (action) { - case HASH_PUT: - case HASH_PUTNEW: - if (__addel(hashp, rbufp, key, val)) { - save_bufp->flags &= ~BUF_PIN; - return (ERROR); - } else { - save_bufp->flags &= ~BUF_PIN; - return (SUCCESS); - } - case HASH_GET: - case HASH_DELETE: - default: - save_bufp->flags &= ~BUF_PIN; - return (ABNORMAL); - } - -found: - switch (action) { - case HASH_PUTNEW: - save_bufp->flags &= ~BUF_PIN; - return (ABNORMAL); - case HASH_GET: - bp = (u_int16_t *)rbufp->page; - if (bp[ndx + 1] < REAL_KEY) { - if (__big_return(hashp, rbufp, ndx, val, 0)) - return (ERROR); - } else { - val->data = (u_char *)rbufp->page + (int)bp[ndx + 1]; - val->size = bp[ndx] - bp[ndx + 1]; - } - break; - case HASH_PUT: - if ((__delpair(hashp, rbufp, ndx)) || - (__addel(hashp, rbufp, key, val))) { - save_bufp->flags &= ~BUF_PIN; - return (ERROR); - } - break; - case HASH_DELETE: - if (__delpair(hashp, rbufp, ndx)) - return (ERROR); - break; - default: - abort(); - } - save_bufp->flags &= ~BUF_PIN; - return (SUCCESS); -} - -static int -hash_seq(dbp, key, data, flag) - const DB *dbp; - DBT *key, *data; - u_int32_t flag; -{ - register u_int32_t bucket; - register BUFHEAD *bufp; - HTAB *hashp; - u_int16_t *bp, ndx; - - hashp = (HTAB *)dbp->internal; - if (flag && flag != R_FIRST && flag != R_NEXT) { - hashp->error = errno = EINVAL; - return (ERROR); - } -#ifdef HASH_STATISTICS - hash_accesses++; -#endif - if ((hashp->cbucket < 0) || (flag == R_FIRST)) { - hashp->cbucket = 0; - hashp->cndx = 1; - hashp->cpage = NULL; - } - - for (bp = NULL; !bp || !bp[0]; ) { - if (!(bufp = hashp->cpage)) { - for (bucket = hashp->cbucket; - bucket <= hashp->MAX_BUCKET; - bucket++, hashp->cndx = 1) { - bufp = __get_buf(hashp, bucket, NULL, 0); - if (!bufp) - return (ERROR); - hashp->cpage = bufp; - bp = (u_int16_t *)bufp->page; - if (bp[0]) - break; - } - hashp->cbucket = bucket; - if (hashp->cbucket > hashp->MAX_BUCKET) { - hashp->cbucket = -1; - return (ABNORMAL); - } - } else - bp = (u_int16_t *)hashp->cpage->page; - -#ifdef DEBUG - assert(bp); - assert(bufp); -#endif - while (bp[hashp->cndx + 1] == OVFLPAGE) { - bufp = hashp->cpage = - __get_buf(hashp, bp[hashp->cndx], bufp, 0); - if (!bufp) - return (ERROR); - bp = (u_int16_t *)(bufp->page); - hashp->cndx = 1; - } - if (!bp[0]) { - hashp->cpage = NULL; - ++hashp->cbucket; - } - } - ndx = hashp->cndx; - if (bp[ndx + 1] < REAL_KEY) { - if (__big_keydata(hashp, bufp, key, data, 1)) - return (ERROR); - } else { - key->data = (u_char *)hashp->cpage->page + bp[ndx]; - key->size = (ndx > 1 ? bp[ndx - 1] : hashp->BSIZE) - bp[ndx]; - data->data = (u_char *)hashp->cpage->page + bp[ndx + 1]; - data->size = bp[ndx] - bp[ndx + 1]; - ndx += 2; - if (ndx > bp[0]) { - hashp->cpage = NULL; - hashp->cbucket++; - hashp->cndx = 1; - } else - hashp->cndx = ndx; - } - return (SUCCESS); -} - -/********************************* UTILITIES ************************/ - -/* - * Returns: - * 0 ==> OK - * -1 ==> Error - */ -extern int -__expand_table(hashp) - HTAB *hashp; -{ - u_int32_t old_bucket, new_bucket; - int dirsize, new_segnum, spare_ndx; - -#ifdef HASH_STATISTICS - hash_expansions++; -#endif - new_bucket = ++hashp->MAX_BUCKET; - old_bucket = (hashp->MAX_BUCKET & hashp->LOW_MASK); - - new_segnum = new_bucket >> hashp->SSHIFT; - - /* Check if we need a new segment */ - if (new_segnum >= hashp->nsegs) { - /* Check if we need to expand directory */ - if (new_segnum >= hashp->DSIZE) { - /* Reallocate directory */ - dirsize = hashp->DSIZE * sizeof(SEGMENT *); - if (!hash_realloc(&hashp->dir, dirsize, dirsize << 1)) - return (-1); - hashp->DSIZE = dirsize << 1; - } - if ((hashp->dir[new_segnum] = - (SEGMENT)calloc(hashp->SGSIZE, sizeof(SEGMENT))) == NULL) - return (-1); - hashp->exsegs++; - hashp->nsegs++; - } - /* - * If the split point is increasing (MAX_BUCKET's log base 2 - * * increases), we need to copy the current contents of the spare - * split bucket to the next bucket. - */ - spare_ndx = __log2(hashp->MAX_BUCKET + 1); - if (spare_ndx > hashp->OVFL_POINT) { - hashp->SPARES[spare_ndx] = hashp->SPARES[hashp->OVFL_POINT]; - hashp->OVFL_POINT = spare_ndx; - } - - if (new_bucket > hashp->HIGH_MASK) { - /* Starting a new doubling */ - hashp->LOW_MASK = hashp->HIGH_MASK; - hashp->HIGH_MASK = new_bucket | hashp->LOW_MASK; - } - /* Relocate records to the new bucket */ - return (__split_page(hashp, old_bucket, new_bucket)); -} - -/* - * If realloc guarantees that the pointer is not destroyed if the realloc - * fails, then this routine can go away. - */ -static void * -hash_realloc(p_ptr, oldsize, newsize) - SEGMENT **p_ptr; - int oldsize, newsize; -{ - register void *p; - - if ( (p = malloc(newsize)) ) { - memmove(p, *p_ptr, oldsize); - memset((char *)p + oldsize, 0, newsize - oldsize); - free(*p_ptr); - *p_ptr = p; - } - return (p); -} - -extern u_int32_t -__call_hash(hashp, k, len) - HTAB *hashp; - char *k; - int len; -{ - int n, bucket; - - n = hashp->hash(k, len); - bucket = n & hashp->HIGH_MASK; - if (bucket > hashp->MAX_BUCKET) - bucket = bucket & hashp->LOW_MASK; - return (bucket); -} - -/* - * Allocate segment table. On error, destroy the table and set errno. - * - * Returns 0 on success - */ -static int -alloc_segs(hashp, nsegs) - HTAB *hashp; - int nsegs; -{ - register int i; - register SEGMENT store; - - int save_errno; - - if ((hashp->dir = - (SEGMENT *)calloc(hashp->DSIZE, sizeof(SEGMENT *))) == NULL) { - save_errno = errno; - (void)hdestroy(hashp); - errno = save_errno; - return (-1); - } - /* Allocate segments */ - if ((store = - (SEGMENT)calloc(nsegs << hashp->SSHIFT, sizeof(SEGMENT))) == NULL) { - save_errno = errno; - (void)hdestroy(hashp); - errno = save_errno; - return (-1); - } - for (i = 0; i < nsegs; i++, hashp->nsegs++) - hashp->dir[i] = &store[i << hashp->SSHIFT]; - return (0); -} - -#if BYTE_ORDER == LITTLE_ENDIAN -/* - * Hashp->hdr needs to be byteswapped. - */ -static void -swap_header_copy(srcp, destp) - HASHHDR *srcp, *destp; -{ - int i; - - P_32_COPY(srcp->magic, destp->magic); - P_32_COPY(srcp->version, destp->version); - P_32_COPY(srcp->lorder, destp->lorder); - P_32_COPY(srcp->bsize, destp->bsize); - P_32_COPY(srcp->bshift, destp->bshift); - P_32_COPY(srcp->dsize, destp->dsize); - P_32_COPY(srcp->ssize, destp->ssize); - P_32_COPY(srcp->sshift, destp->sshift); - P_32_COPY(srcp->ovfl_point, destp->ovfl_point); - P_32_COPY(srcp->last_freed, destp->last_freed); - P_32_COPY(srcp->max_bucket, destp->max_bucket); - P_32_COPY(srcp->high_mask, destp->high_mask); - P_32_COPY(srcp->low_mask, destp->low_mask); - P_32_COPY(srcp->ffactor, destp->ffactor); - P_32_COPY(srcp->nkeys, destp->nkeys); - P_32_COPY(srcp->hdrpages, destp->hdrpages); - P_32_COPY(srcp->h_charkey, destp->h_charkey); - for (i = 0; i < NCACHED; i++) { - P_32_COPY(srcp->spares[i], destp->spares[i]); - P_16_COPY(srcp->bitmaps[i], destp->bitmaps[i]); - } -} - -static void -swap_header(hashp) - HTAB *hashp; -{ - HASHHDR *hdrp; - int i; - - hdrp = &hashp->hdr; - - M_32_SWAP(hdrp->magic); - M_32_SWAP(hdrp->version); - M_32_SWAP(hdrp->lorder); - M_32_SWAP(hdrp->bsize); - M_32_SWAP(hdrp->bshift); - M_32_SWAP(hdrp->dsize); - M_32_SWAP(hdrp->ssize); - M_32_SWAP(hdrp->sshift); - M_32_SWAP(hdrp->ovfl_point); - M_32_SWAP(hdrp->last_freed); - M_32_SWAP(hdrp->max_bucket); - M_32_SWAP(hdrp->high_mask); - M_32_SWAP(hdrp->low_mask); - M_32_SWAP(hdrp->ffactor); - M_32_SWAP(hdrp->nkeys); - M_32_SWAP(hdrp->hdrpages); - M_32_SWAP(hdrp->h_charkey); - for (i = 0; i < NCACHED; i++) { - M_32_SWAP(hdrp->spares[i]); - M_16_SWAP(hdrp->bitmaps[i]); - } -} -#endif diff --git a/lib/libc/db/hash/hash.h b/lib/libc/db/hash/hash.h deleted file mode 100644 index 504a9b6..0000000 --- a/lib/libc/db/hash/hash.h +++ /dev/null @@ -1,293 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)hash.h 8.3 (Berkeley) 5/31/94 - */ - -/* Operations */ -typedef enum { - HASH_GET, HASH_PUT, HASH_PUTNEW, HASH_DELETE, HASH_FIRST, HASH_NEXT -} ACTION; - -/* Buffer Management structures */ -typedef struct _bufhead BUFHEAD; - -struct _bufhead { - BUFHEAD *prev; /* LRU links */ - BUFHEAD *next; /* LRU links */ - BUFHEAD *ovfl; /* Overflow page buffer header */ - u_int32_t addr; /* Address of this page */ - char *page; /* Actual page data */ - char flags; -#define BUF_MOD 0x0001 -#define BUF_DISK 0x0002 -#define BUF_BUCKET 0x0004 -#define BUF_PIN 0x0008 -}; - -#define IS_BUCKET(X) ((X) & BUF_BUCKET) - -typedef BUFHEAD **SEGMENT; - -/* Hash Table Information */ -typedef struct hashhdr { /* Disk resident portion */ - int magic; /* Magic NO for hash tables */ - int version; /* Version ID */ - u_int32_t lorder; /* Byte Order */ - int bsize; /* Bucket/Page Size */ - int bshift; /* Bucket shift */ - int dsize; /* Directory Size */ - int ssize; /* Segment Size */ - int sshift; /* Segment shift */ - int ovfl_point; /* Where overflow pages are being - * allocated */ - int last_freed; /* Last overflow page freed */ - int max_bucket; /* ID of Maximum bucket in use */ - int high_mask; /* Mask to modulo into entire table */ - int low_mask; /* Mask to modulo into lower half of - * table */ - int ffactor; /* Fill factor */ - int nkeys; /* Number of keys in hash table */ - int hdrpages; /* Size of table header */ - int h_charkey; /* value of hash(CHARKEY) */ -#define NCACHED 32 /* number of bit maps and spare - * points */ - int spares[NCACHED];/* spare pages for overflow */ - u_int16_t bitmaps[NCACHED]; /* address of overflow page - * bitmaps */ -} HASHHDR; - -typedef struct htab { /* Memory resident data structure */ - HASHHDR hdr; /* Header */ - int nsegs; /* Number of allocated segments */ - int exsegs; /* Number of extra allocated - * segments */ - u_int32_t /* Hash function */ - (*hash)__P((const void *, size_t)); - int flags; /* Flag values */ - int fp; /* File pointer */ - char *tmp_buf; /* Temporary Buffer for BIG data */ - char *tmp_key; /* Temporary Buffer for BIG keys */ - BUFHEAD *cpage; /* Current page */ - int cbucket; /* Current bucket */ - int cndx; /* Index of next item on cpage */ - int error; /* Error Number -- for DBM - * compatability */ - int new_file; /* Indicates if fd is backing store - * or no */ - int save_file; /* Indicates whether we need to flush - * file at - * exit */ - u_int32_t *mapp[NCACHED]; /* Pointers to page maps */ - int nmaps; /* Initial number of bitmaps */ - int nbufs; /* Number of buffers left to - * allocate */ - BUFHEAD bufhead; /* Header of buffer lru list */ - SEGMENT *dir; /* Hash Bucket directory */ -} HTAB; - -/* - * Constants - */ -#define MAX_BSIZE 65536 /* 2^16 */ -#define MIN_BUFFERS 6 -#define MINHDRSIZE 512 -#define DEF_BUFSIZE 65536 /* 64 K */ -#define DEF_BUCKET_SIZE 4096 -#define DEF_BUCKET_SHIFT 12 /* log2(BUCKET) */ -#define DEF_SEGSIZE 256 -#define DEF_SEGSIZE_SHIFT 8 /* log2(SEGSIZE) */ -#define DEF_DIRSIZE 256 -#define DEF_FFACTOR 65536 -#define MIN_FFACTOR 4 -#define SPLTMAX 8 -#define CHARKEY "%$sniglet^&" -#define NUMKEY 1038583 -#define BYTE_SHIFT 3 -#define INT_TO_BYTE 2 -#define INT_BYTE_SHIFT 5 -#define ALL_SET ((u_int32_t)0xFFFFFFFF) -#define ALL_CLEAR 0 - -#define PTROF(X) ((BUFHEAD *)((ptrdiff_t)(X)&~0x3)) -#define ISMOD(X) ((u_int32_t)(ptrdiff_t)(X)&0x1) -#define DOMOD(X) ((X) = (char *)((ptrdiff_t)(X)|0x1)) -#define ISDISK(X) ((u_int32_t)(ptrdiff_t)(X)&0x2) -#define DODISK(X) ((X) = (char *)((ptrdiff_t)(X)|0x2)) - -#define BITS_PER_MAP 32 - -/* Given the address of the beginning of a big map, clear/set the nth bit */ -#define CLRBIT(A, N) ((A)[(N)/BITS_PER_MAP] &= ~(1<<((N)%BITS_PER_MAP))) -#define SETBIT(A, N) ((A)[(N)/BITS_PER_MAP] |= (1<<((N)%BITS_PER_MAP))) -#define ISSET(A, N) ((A)[(N)/BITS_PER_MAP] & (1<<((N)%BITS_PER_MAP))) - -/* Overflow management */ -/* - * Overflow page numbers are allocated per split point. At each doubling of - * the table, we can allocate extra pages. So, an overflow page number has - * the top 5 bits indicate which split point and the lower 11 bits indicate - * which page at that split point is indicated (pages within split points are - * numberered starting with 1). - */ - -#define SPLITSHIFT 11 -#define SPLITMASK 0x7FF -#define SPLITNUM(N) (((u_int32_t)(N)) >> SPLITSHIFT) -#define OPAGENUM(N) ((N) & SPLITMASK) -#define OADDR_OF(S,O) ((u_int32_t)((u_int32_t)(S) << SPLITSHIFT) + (O)) - -#define BUCKET_TO_PAGE(B) \ - (B) + hashp->HDRPAGES + ((B) ? hashp->SPARES[__log2((B)+1)-1] : 0) -#define OADDR_TO_PAGE(B) \ - BUCKET_TO_PAGE ( (1 << SPLITNUM((B))) -1 ) + OPAGENUM((B)); - -/* - * page.h contains a detailed description of the page format. - * - * Normally, keys and data are accessed from offset tables in the top of - * each page which point to the beginning of the key and data. There are - * four flag values which may be stored in these offset tables which indicate - * the following: - * - * - * OVFLPAGE Rather than a key data pair, this pair contains - * the address of an overflow page. The format of - * the pair is: - * OVERFLOW_PAGE_NUMBER OVFLPAGE - * - * PARTIAL_KEY This must be the first key/data pair on a page - * and implies that page contains only a partial key. - * That is, the key is too big to fit on a single page - * so it starts on this page and continues on the next. - * The format of the page is: - * KEY_OFF PARTIAL_KEY OVFL_PAGENO OVFLPAGE - * - * KEY_OFF -- offset of the beginning of the key - * PARTIAL_KEY -- 1 - * OVFL_PAGENO - page number of the next overflow page - * OVFLPAGE -- 0 - * - * FULL_KEY This must be the first key/data pair on the page. It - * is used in two cases. - * - * Case 1: - * There is a complete key on the page but no data - * (because it wouldn't fit). The next page contains - * the data. - * - * Page format it: - * KEY_OFF FULL_KEY OVFL_PAGENO OVFL_PAGE - * - * KEY_OFF -- offset of the beginning of the key - * FULL_KEY -- 2 - * OVFL_PAGENO - page number of the next overflow page - * OVFLPAGE -- 0 - * - * Case 2: - * This page contains no key, but part of a large - * data field, which is continued on the next page. - * - * Page format it: - * DATA_OFF FULL_KEY OVFL_PAGENO OVFL_PAGE - * - * KEY_OFF -- offset of the beginning of the data on - * this page - * FULL_KEY -- 2 - * OVFL_PAGENO - page number of the next overflow page - * OVFLPAGE -- 0 - * - * FULL_KEY_DATA - * This must be the first key/data pair on the page. - * There are two cases: - * - * Case 1: - * This page contains a key and the beginning of the - * data field, but the data field is continued on the - * next page. - * - * Page format is: - * KEY_OFF FULL_KEY_DATA OVFL_PAGENO DATA_OFF - * - * KEY_OFF -- offset of the beginning of the key - * FULL_KEY_DATA -- 3 - * OVFL_PAGENO - page number of the next overflow page - * DATA_OFF -- offset of the beginning of the data - * - * Case 2: - * This page contains the last page of a big data pair. - * There is no key, only the tail end of the data - * on this page. - * - * Page format is: - * DATA_OFF FULL_KEY_DATA - * - * DATA_OFF -- offset of the beginning of the data on - * this page - * FULL_KEY_DATA -- 3 - * OVFL_PAGENO - page number of the next overflow page - * OVFLPAGE -- 0 - * - * OVFL_PAGENO and OVFLPAGE are optional (they are - * not present if there is no next page). - */ - -#define OVFLPAGE 0 -#define PARTIAL_KEY 1 -#define FULL_KEY 2 -#define FULL_KEY_DATA 3 -#define REAL_KEY 4 - -/* Short hands for accessing structure */ -#define BSIZE hdr.bsize -#define BSHIFT hdr.bshift -#define DSIZE hdr.dsize -#define SGSIZE hdr.ssize -#define SSHIFT hdr.sshift -#define LORDER hdr.lorder -#define OVFL_POINT hdr.ovfl_point -#define LAST_FREED hdr.last_freed -#define MAX_BUCKET hdr.max_bucket -#define FFACTOR hdr.ffactor -#define HIGH_MASK hdr.high_mask -#define LOW_MASK hdr.low_mask -#define NKEYS hdr.nkeys -#define HDRPAGES hdr.hdrpages -#define SPARES hdr.spares -#define BITMAPS hdr.bitmaps -#define VERSION hdr.version -#define MAGIC hdr.magic -#define NEXT_FREE hdr.next_free -#define H_CHARKEY hdr.h_charkey diff --git a/lib/libc/db/hash/hash_bigkey.c b/lib/libc/db/hash/hash_bigkey.c deleted file mode 100644 index 0cee07e..0000000 --- a/lib/libc/db/hash/hash_bigkey.c +++ /dev/null @@ -1,667 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)hash_bigkey.c 8.3 (Berkeley) 5/31/94"; -#endif /* LIBC_SCCS and not lint */ - -/* - * PACKAGE: hash - * DESCRIPTION: - * Big key/data handling for the hashing package. - * - * ROUTINES: - * External - * __big_keydata - * __big_split - * __big_insert - * __big_return - * __big_delete - * __find_last_page - * Internal - * collect_key - * collect_data - */ - -#include - -#include -#include -#include -#include - -#ifdef DEBUG -#include -#endif - -#include -#include "hash.h" -#include "page.h" -#include "extern.h" - -static int collect_key __P((HTAB *, BUFHEAD *, int, DBT *, int)); -static int collect_data __P((HTAB *, BUFHEAD *, int, int)); - -/* - * Big_insert - * - * You need to do an insert and the key/data pair is too big - * - * Returns: - * 0 ==> OK - *-1 ==> ERROR - */ -extern int -__big_insert(hashp, bufp, key, val) - HTAB *hashp; - BUFHEAD *bufp; - const DBT *key, *val; -{ - register u_int16_t *p; - int key_size, n, val_size; - u_int16_t space, move_bytes, off; - char *cp, *key_data, *val_data; - - cp = bufp->page; /* Character pointer of p. */ - p = (u_int16_t *)cp; - - key_data = (char *)key->data; - key_size = key->size; - val_data = (char *)val->data; - val_size = val->size; - - /* First move the Key */ - for (space = FREESPACE(p) - BIGOVERHEAD; key_size; - space = FREESPACE(p) - BIGOVERHEAD) { - move_bytes = MIN(space, key_size); - off = OFFSET(p) - move_bytes; - memmove(cp + off, key_data, move_bytes); - key_size -= move_bytes; - key_data += move_bytes; - n = p[0]; - p[++n] = off; - p[0] = ++n; - FREESPACE(p) = off - PAGE_META(n); - OFFSET(p) = off; - p[n] = PARTIAL_KEY; - bufp = __add_ovflpage(hashp, bufp); - if (!bufp) - return (-1); - n = p[0]; - if (!key_size) - if (FREESPACE(p)) { - move_bytes = MIN(FREESPACE(p), val_size); - off = OFFSET(p) - move_bytes; - p[n] = off; - memmove(cp + off, val_data, move_bytes); - val_data += move_bytes; - val_size -= move_bytes; - p[n - 2] = FULL_KEY_DATA; - FREESPACE(p) = FREESPACE(p) - move_bytes; - OFFSET(p) = off; - } else - p[n - 2] = FULL_KEY; - p = (u_int16_t *)bufp->page; - cp = bufp->page; - bufp->flags |= BUF_MOD; - } - - /* Now move the data */ - for (space = FREESPACE(p) - BIGOVERHEAD; val_size; - space = FREESPACE(p) - BIGOVERHEAD) { - move_bytes = MIN(space, val_size); - /* - * Here's the hack to make sure that if the data ends on the - * same page as the key ends, FREESPACE is at least one. - */ - if (space == val_size && val_size == val->size) - move_bytes--; - off = OFFSET(p) - move_bytes; - memmove(cp + off, val_data, move_bytes); - val_size -= move_bytes; - val_data += move_bytes; - n = p[0]; - p[++n] = off; - p[0] = ++n; - FREESPACE(p) = off - PAGE_META(n); - OFFSET(p) = off; - if (val_size) { - p[n] = FULL_KEY; - bufp = __add_ovflpage(hashp, bufp); - if (!bufp) - return (-1); - cp = bufp->page; - p = (u_int16_t *)cp; - } else - p[n] = FULL_KEY_DATA; - bufp->flags |= BUF_MOD; - } - return (0); -} - -/* - * Called when bufp's page contains a partial key (index should be 1) - * - * All pages in the big key/data pair except bufp are freed. We cannot - * free bufp because the page pointing to it is lost and we can't get rid - * of its pointer. - * - * Returns: - * 0 => OK - *-1 => ERROR - */ -extern int -__big_delete(hashp, bufp) - HTAB *hashp; - BUFHEAD *bufp; -{ - register BUFHEAD *last_bfp, *rbufp; - u_int16_t *bp, pageno; - int key_done, n; - - rbufp = bufp; - last_bfp = NULL; - bp = (u_int16_t *)bufp->page; - pageno = 0; - key_done = 0; - - while (!key_done || (bp[2] != FULL_KEY_DATA)) { - if (bp[2] == FULL_KEY || bp[2] == FULL_KEY_DATA) - key_done = 1; - - /* - * If there is freespace left on a FULL_KEY_DATA page, then - * the data is short and fits entirely on this page, and this - * is the last page. - */ - if (bp[2] == FULL_KEY_DATA && FREESPACE(bp)) - break; - pageno = bp[bp[0] - 1]; - rbufp->flags |= BUF_MOD; - rbufp = __get_buf(hashp, pageno, rbufp, 0); - if (last_bfp) - __free_ovflpage(hashp, last_bfp); - last_bfp = rbufp; - if (!rbufp) - return (-1); /* Error. */ - bp = (u_int16_t *)rbufp->page; - } - - /* - * If we get here then rbufp points to the last page of the big - * key/data pair. Bufp points to the first one -- it should now be - * empty pointing to the next page after this pair. Can't free it - * because we don't have the page pointing to it. - */ - - /* This is information from the last page of the pair. */ - n = bp[0]; - pageno = bp[n - 1]; - - /* Now, bp is the first page of the pair. */ - bp = (u_int16_t *)bufp->page; - if (n > 2) { - /* There is an overflow page. */ - bp[1] = pageno; - bp[2] = OVFLPAGE; - bufp->ovfl = rbufp->ovfl; - } else - /* This is the last page. */ - bufp->ovfl = NULL; - n -= 2; - bp[0] = n; - FREESPACE(bp) = hashp->BSIZE - PAGE_META(n); - OFFSET(bp) = hashp->BSIZE - 1; - - bufp->flags |= BUF_MOD; - if (rbufp) - __free_ovflpage(hashp, rbufp); - if (last_bfp != rbufp) - __free_ovflpage(hashp, last_bfp); - - hashp->NKEYS--; - return (0); -} -/* - * Returns: - * 0 = key not found - * -1 = get next overflow page - * -2 means key not found and this is big key/data - * -3 error - */ -extern int -__find_bigpair(hashp, bufp, ndx, key, size) - HTAB *hashp; - BUFHEAD *bufp; - int ndx; - char *key; - int size; -{ - register u_int16_t *bp; - register char *p; - int ksize; - u_int16_t bytes; - char *kkey; - - bp = (u_int16_t *)bufp->page; - p = bufp->page; - ksize = size; - kkey = key; - - for (bytes = hashp->BSIZE - bp[ndx]; - bytes <= size && bp[ndx + 1] == PARTIAL_KEY; - bytes = hashp->BSIZE - bp[ndx]) { - if (memcmp(p + bp[ndx], kkey, bytes)) - return (-2); - kkey += bytes; - ksize -= bytes; - bufp = __get_buf(hashp, bp[ndx + 2], bufp, 0); - if (!bufp) - return (-3); - p = bufp->page; - bp = (u_int16_t *)p; - ndx = 1; - } - - if (bytes != ksize || memcmp(p + bp[ndx], kkey, bytes)) { -#ifdef HASH_STATISTICS - ++hash_collisions; -#endif - return (-2); - } else - return (ndx); -} - -/* - * Given the buffer pointer of the first overflow page of a big pair, - * find the end of the big pair - * - * This will set bpp to the buffer header of the last page of the big pair. - * It will return the pageno of the overflow page following the last page - * of the pair; 0 if there isn't any (i.e. big pair is the last key in the - * bucket) - */ -extern u_int16_t -__find_last_page(hashp, bpp) - HTAB *hashp; - BUFHEAD **bpp; -{ - BUFHEAD *bufp; - u_int16_t *bp, pageno; - int n; - - bufp = *bpp; - bp = (u_int16_t *)bufp->page; - for (;;) { - n = bp[0]; - - /* - * This is the last page if: the tag is FULL_KEY_DATA and - * either only 2 entries OVFLPAGE marker is explicit there - * is freespace on the page. - */ - if (bp[2] == FULL_KEY_DATA && - ((n == 2) || (bp[n] == OVFLPAGE) || (FREESPACE(bp)))) - break; - - pageno = bp[n - 1]; - bufp = __get_buf(hashp, pageno, bufp, 0); - if (!bufp) - return (0); /* Need to indicate an error! */ - bp = (u_int16_t *)bufp->page; - } - - *bpp = bufp; - if (bp[0] > 2) - return (bp[3]); - else - return (0); -} - -/* - * Return the data for the key/data pair that begins on this page at this - * index (index should always be 1). - */ -extern int -__big_return(hashp, bufp, ndx, val, set_current) - HTAB *hashp; - BUFHEAD *bufp; - int ndx; - DBT *val; - int set_current; -{ - BUFHEAD *save_p; - u_int16_t *bp, len, off, save_addr; - char *tp; - - bp = (u_int16_t *)bufp->page; - while (bp[ndx + 1] == PARTIAL_KEY) { - bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); - if (!bufp) - return (-1); - bp = (u_int16_t *)bufp->page; - ndx = 1; - } - - if (bp[ndx + 1] == FULL_KEY) { - bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); - if (!bufp) - return (-1); - bp = (u_int16_t *)bufp->page; - save_p = bufp; - save_addr = save_p->addr; - off = bp[1]; - len = 0; - } else - if (!FREESPACE(bp)) { - /* - * This is a hack. We can't distinguish between - * FULL_KEY_DATA that contains complete data or - * incomplete data, so we require that if the data - * is complete, there is at least 1 byte of free - * space left. - */ - off = bp[bp[0]]; - len = bp[1] - off; - save_p = bufp; - save_addr = bufp->addr; - bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); - if (!bufp) - return (-1); - bp = (u_int16_t *)bufp->page; - } else { - /* The data is all on one page. */ - tp = (char *)bp; - off = bp[bp[0]]; - val->data = (u_char *)tp + off; - val->size = bp[1] - off; - if (set_current) { - if (bp[0] == 2) { /* No more buckets in - * chain */ - hashp->cpage = NULL; - hashp->cbucket++; - hashp->cndx = 1; - } else { - hashp->cpage = __get_buf(hashp, - bp[bp[0] - 1], bufp, 0); - if (!hashp->cpage) - return (-1); - hashp->cndx = 1; - if (!((u_int16_t *) - hashp->cpage->page)[0]) { - hashp->cbucket++; - hashp->cpage = NULL; - } - } - } - return (0); - } - - val->size = collect_data(hashp, bufp, (int)len, set_current); - if (val->size == -1) - return (-1); - if (save_p->addr != save_addr) { - /* We are pretty short on buffers. */ - errno = EINVAL; /* OUT OF BUFFERS */ - return (-1); - } - memmove(hashp->tmp_buf, (save_p->page) + off, len); - val->data = (u_char *)hashp->tmp_buf; - return (0); -} -/* - * Count how big the total datasize is by recursing through the pages. Then - * allocate a buffer and copy the data as you recurse up. - */ -static int -collect_data(hashp, bufp, len, set) - HTAB *hashp; - BUFHEAD *bufp; - int len, set; -{ - register u_int16_t *bp; - register char *p; - BUFHEAD *xbp; - u_int16_t save_addr; - int mylen, totlen; - - p = bufp->page; - bp = (u_int16_t *)p; - mylen = hashp->BSIZE - bp[1]; - save_addr = bufp->addr; - - if (bp[2] == FULL_KEY_DATA) { /* End of Data */ - totlen = len + mylen; - if (hashp->tmp_buf) - free(hashp->tmp_buf); - if ((hashp->tmp_buf = (char *)malloc(totlen)) == NULL) - return (-1); - if (set) { - hashp->cndx = 1; - if (bp[0] == 2) { /* No more buckets in chain */ - hashp->cpage = NULL; - hashp->cbucket++; - } else { - hashp->cpage = - __get_buf(hashp, bp[bp[0] - 1], bufp, 0); - if (!hashp->cpage) - return (-1); - else if (!((u_int16_t *)hashp->cpage->page)[0]) { - hashp->cbucket++; - hashp->cpage = NULL; - } - } - } - } else { - xbp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); - if (!xbp || ((totlen = - collect_data(hashp, xbp, len + mylen, set)) < 1)) - return (-1); - } - if (bufp->addr != save_addr) { - errno = EINVAL; /* Out of buffers. */ - return (-1); - } - memmove(&hashp->tmp_buf[len], (bufp->page) + bp[1], mylen); - return (totlen); -} - -/* - * Fill in the key and data for this big pair. - */ -extern int -__big_keydata(hashp, bufp, key, val, set) - HTAB *hashp; - BUFHEAD *bufp; - DBT *key, *val; - int set; -{ - key->size = collect_key(hashp, bufp, 0, val, set); - if (key->size == -1) - return (-1); - key->data = (u_char *)hashp->tmp_key; - return (0); -} - -/* - * Count how big the total key size is by recursing through the pages. Then - * collect the data, allocate a buffer and copy the key as you recurse up. - */ -static int -collect_key(hashp, bufp, len, val, set) - HTAB *hashp; - BUFHEAD *bufp; - int len; - DBT *val; - int set; -{ - BUFHEAD *xbp; - char *p; - int mylen, totlen; - u_int16_t *bp, save_addr; - - p = bufp->page; - bp = (u_int16_t *)p; - mylen = hashp->BSIZE - bp[1]; - - save_addr = bufp->addr; - totlen = len + mylen; - if (bp[2] == FULL_KEY || bp[2] == FULL_KEY_DATA) { /* End of Key. */ - if (hashp->tmp_key != NULL) - free(hashp->tmp_key); - if ((hashp->tmp_key = (char *)malloc(totlen)) == NULL) - return (-1); - if (__big_return(hashp, bufp, 1, val, set)) - return (-1); - } else { - xbp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); - if (!xbp || ((totlen = - collect_key(hashp, xbp, totlen, val, set)) < 1)) - return (-1); - } - if (bufp->addr != save_addr) { - errno = EINVAL; /* MIS -- OUT OF BUFFERS */ - return (-1); - } - memmove(&hashp->tmp_key[len], (bufp->page) + bp[1], mylen); - return (totlen); -} - -/* - * Returns: - * 0 => OK - * -1 => error - */ -extern int -__big_split(hashp, op, np, big_keyp, addr, obucket, ret) - HTAB *hashp; - BUFHEAD *op; /* Pointer to where to put keys that go in old bucket */ - BUFHEAD *np; /* Pointer to new bucket page */ - /* Pointer to first page containing the big key/data */ - BUFHEAD *big_keyp; - int addr; /* Address of big_keyp */ - u_int32_t obucket;/* Old Bucket */ - SPLIT_RETURN *ret; -{ - register BUFHEAD *tmpp; - register u_int16_t *tp; - BUFHEAD *bp; - DBT key, val; - u_int32_t change; - u_int16_t free_space, n, off; - - bp = big_keyp; - - /* Now figure out where the big key/data goes */ - if (__big_keydata(hashp, big_keyp, &key, &val, 0)) - return (-1); - change = (__call_hash(hashp, key.data, key.size) != obucket); - - if ( (ret->next_addr = __find_last_page(hashp, &big_keyp)) ) { - if (!(ret->nextp = - __get_buf(hashp, ret->next_addr, big_keyp, 0))) - return (-1);; - } else - ret->nextp = NULL; - - /* Now make one of np/op point to the big key/data pair */ -#ifdef DEBUG - assert(np->ovfl == NULL); -#endif - if (change) - tmpp = np; - else - tmpp = op; - - tmpp->flags |= BUF_MOD; -#ifdef DEBUG1 - (void)fprintf(stderr, - "BIG_SPLIT: %d->ovfl was %d is now %d\n", tmpp->addr, - (tmpp->ovfl ? tmpp->ovfl->addr : 0), (bp ? bp->addr : 0)); -#endif - tmpp->ovfl = bp; /* one of op/np point to big_keyp */ - tp = (u_int16_t *)tmpp->page; -#ifdef DEBUG - assert(FREESPACE(tp) >= OVFLSIZE); -#endif - n = tp[0]; - off = OFFSET(tp); - free_space = FREESPACE(tp); - tp[++n] = (u_int16_t)addr; - tp[++n] = OVFLPAGE; - tp[0] = n; - OFFSET(tp) = off; - FREESPACE(tp) = free_space - OVFLSIZE; - - /* - * Finally, set the new and old return values. BIG_KEYP contains a - * pointer to the last page of the big key_data pair. Make sure that - * big_keyp has no following page (2 elements) or create an empty - * following page. - */ - - ret->newp = np; - ret->oldp = op; - - tp = (u_int16_t *)big_keyp->page; - big_keyp->flags |= BUF_MOD; - if (tp[0] > 2) { - /* - * There may be either one or two offsets on this page. If - * there is one, then the overflow page is linked on normally - * and tp[4] is OVFLPAGE. If there are two, tp[4] contains - * the second offset and needs to get stuffed in after the - * next overflow page is added. - */ - n = tp[4]; - free_space = FREESPACE(tp); - off = OFFSET(tp); - tp[0] -= 2; - FREESPACE(tp) = free_space + OVFLSIZE; - OFFSET(tp) = off; - tmpp = __add_ovflpage(hashp, big_keyp); - if (!tmpp) - return (-1); - tp[4] = n; - } else - tmpp = big_keyp; - - if (change) - ret->newp = tmpp; - else - ret->oldp = tmpp; - return (0); -} diff --git a/lib/libc/db/hash/hash_buf.c b/lib/libc/db/hash/hash_buf.c deleted file mode 100644 index 92e1f93..0000000 --- a/lib/libc/db/hash/hash_buf.c +++ /dev/null @@ -1,355 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)hash_buf.c 8.5 (Berkeley) 7/15/94"; -#endif /* LIBC_SCCS and not lint */ - -/* - * PACKAGE: hash - * - * DESCRIPTION: - * Contains buffer management - * - * ROUTINES: - * External - * __buf_init - * __get_buf - * __buf_free - * __reclaim_buf - * Internal - * newbuf - */ - -#include - -#include -#include -#include -#include - -#ifdef DEBUG -#include -#endif - -#include -#include "hash.h" -#include "page.h" -#include "extern.h" - -static BUFHEAD *newbuf __P((HTAB *, u_int32_t, BUFHEAD *)); - -/* Unlink B from its place in the lru */ -#define BUF_REMOVE(B) { \ - (B)->prev->next = (B)->next; \ - (B)->next->prev = (B)->prev; \ -} - -/* Insert B after P */ -#define BUF_INSERT(B, P) { \ - (B)->next = (P)->next; \ - (B)->prev = (P); \ - (P)->next = (B); \ - (B)->next->prev = (B); \ -} - -#define MRU hashp->bufhead.next -#define LRU hashp->bufhead.prev - -#define MRU_INSERT(B) BUF_INSERT((B), &hashp->bufhead) -#define LRU_INSERT(B) BUF_INSERT((B), LRU) - -/* - * We are looking for a buffer with address "addr". If prev_bp is NULL, then - * address is a bucket index. If prev_bp is not NULL, then it points to the - * page previous to an overflow page that we are trying to find. - * - * CAVEAT: The buffer header accessed via prev_bp's ovfl field may no longer - * be valid. Therefore, you must always verify that its address matches the - * address you are seeking. - */ -extern BUFHEAD * -__get_buf(hashp, addr, prev_bp, newpage) - HTAB *hashp; - u_int32_t addr; - BUFHEAD *prev_bp; - int newpage; /* If prev_bp set, indicates a new overflow page. */ -{ - register BUFHEAD *bp; - register u_int32_t is_disk_mask; - register int is_disk, segment_ndx; - SEGMENT segp; - - is_disk = 0; - is_disk_mask = 0; - if (prev_bp) { - bp = prev_bp->ovfl; - if (!bp || (bp->addr != addr)) - bp = NULL; - if (!newpage) - is_disk = BUF_DISK; - } else { - /* Grab buffer out of directory */ - segment_ndx = addr & (hashp->SGSIZE - 1); - - /* valid segment ensured by __call_hash() */ - segp = hashp->dir[addr >> hashp->SSHIFT]; -#ifdef DEBUG - assert(segp != NULL); -#endif - bp = PTROF(segp[segment_ndx]); - is_disk_mask = ISDISK(segp[segment_ndx]); - is_disk = is_disk_mask || !hashp->new_file; - } - - if (!bp) { - bp = newbuf(hashp, addr, prev_bp); - if (!bp || - __get_page(hashp, bp->page, addr, !prev_bp, is_disk, 0)) - return (NULL); - if (!prev_bp) - segp[segment_ndx] = - (BUFHEAD *)((ptrdiff_t)bp | is_disk_mask); - } else { - BUF_REMOVE(bp); - MRU_INSERT(bp); - } - return (bp); -} - -/* - * We need a buffer for this page. Either allocate one, or evict a resident - * one (if we have as many buffers as we're allowed) and put this one in. - * - * If newbuf finds an error (returning NULL), it also sets errno. - */ -static BUFHEAD * -newbuf(hashp, addr, prev_bp) - HTAB *hashp; - u_int32_t addr; - BUFHEAD *prev_bp; -{ - register BUFHEAD *bp; /* The buffer we're going to use */ - register BUFHEAD *xbp; /* Temp pointer */ - register BUFHEAD *next_xbp; - SEGMENT segp; - int segment_ndx; - u_int16_t oaddr, *shortp; - - oaddr = 0; - bp = LRU; - /* - * If LRU buffer is pinned, the buffer pool is too small. We need to - * allocate more buffers. - */ - if (hashp->nbufs || (bp->flags & BUF_PIN)) { - /* Allocate a new one */ - if ((bp = (BUFHEAD *)malloc(sizeof(BUFHEAD))) == NULL) - return (NULL); -#ifdef PURIFY - memset(bp, 0xff, sizeof(BUFHEAD)); -#endif - if ((bp->page = (char *)malloc(hashp->BSIZE)) == NULL) { - free(bp); - return (NULL); - } -#ifdef PURIFY - memset(bp->page, 0xff, hashp->BSIZE); -#endif - if (hashp->nbufs) - hashp->nbufs--; - } else { - /* Kick someone out */ - BUF_REMOVE(bp); - /* - * If this is an overflow page with addr 0, it's already been - * flushed back in an overflow chain and initialized. - */ - if ((bp->addr != 0) || (bp->flags & BUF_BUCKET)) { - /* - * Set oaddr before __put_page so that you get it - * before bytes are swapped. - */ - shortp = (u_int16_t *)bp->page; - if (shortp[0]) - oaddr = shortp[shortp[0] - 1]; - if ((bp->flags & BUF_MOD) && __put_page(hashp, bp->page, - bp->addr, (int)IS_BUCKET(bp->flags), 0)) - return (NULL); - /* - * Update the pointer to this page (i.e. invalidate it). - * - * If this is a new file (i.e. we created it at open - * time), make sure that we mark pages which have been - * written to disk so we retrieve them from disk later, - * rather than allocating new pages. - */ - if (IS_BUCKET(bp->flags)) { - segment_ndx = bp->addr & (hashp->SGSIZE - 1); - segp = hashp->dir[bp->addr >> hashp->SSHIFT]; -#ifdef DEBUG - assert(segp != NULL); -#endif - - if (hashp->new_file && - ((bp->flags & BUF_MOD) || - ISDISK(segp[segment_ndx]))) - segp[segment_ndx] = (BUFHEAD *)BUF_DISK; - else - segp[segment_ndx] = NULL; - } - /* - * Since overflow pages can only be access by means of - * their bucket, free overflow pages associated with - * this bucket. - */ - for (xbp = bp; xbp->ovfl;) { - next_xbp = xbp->ovfl; - xbp->ovfl = 0; - xbp = next_xbp; - - /* Check that ovfl pointer is up date. */ - if (IS_BUCKET(xbp->flags) || - (oaddr != xbp->addr)) - break; - - shortp = (u_int16_t *)xbp->page; - if (shortp[0]) - /* set before __put_page */ - oaddr = shortp[shortp[0] - 1]; - if ((xbp->flags & BUF_MOD) && __put_page(hashp, - xbp->page, xbp->addr, 0, 0)) - return (NULL); - xbp->addr = 0; - xbp->flags = 0; - BUF_REMOVE(xbp); - LRU_INSERT(xbp); - } - } - } - - /* Now assign this buffer */ - bp->addr = addr; -#ifdef DEBUG1 - (void)fprintf(stderr, "NEWBUF1: %d->ovfl was %d is now %d\n", - bp->addr, (bp->ovfl ? bp->ovfl->addr : 0), 0); -#endif - bp->ovfl = NULL; - if (prev_bp) { - /* - * If prev_bp is set, this is an overflow page, hook it in to - * the buffer overflow links. - */ -#ifdef DEBUG1 - (void)fprintf(stderr, "NEWBUF2: %d->ovfl was %d is now %d\n", - prev_bp->addr, (prev_bp->ovfl ? bp->ovfl->addr : 0), - (bp ? bp->addr : 0)); -#endif - prev_bp->ovfl = bp; - bp->flags = 0; - } else - bp->flags = BUF_BUCKET; - MRU_INSERT(bp); - return (bp); -} - -extern void -__buf_init(hashp, nbytes) - HTAB *hashp; - int nbytes; -{ - BUFHEAD *bfp; - int npages; - - bfp = &(hashp->bufhead); - npages = (nbytes + hashp->BSIZE - 1) >> hashp->BSHIFT; - npages = MAX(npages, MIN_BUFFERS); - - hashp->nbufs = npages; - bfp->next = bfp; - bfp->prev = bfp; - /* - * This space is calloc'd so these are already null. - * - * bfp->ovfl = NULL; - * bfp->flags = 0; - * bfp->page = NULL; - * bfp->addr = 0; - */ -} - -extern int -__buf_free(hashp, do_free, to_disk) - HTAB *hashp; - int do_free, to_disk; -{ - BUFHEAD *bp; - - /* Need to make sure that buffer manager has been initialized */ - if (!LRU) - return (0); - for (bp = LRU; bp != &hashp->bufhead;) { - /* Check that the buffer is valid */ - if (bp->addr || IS_BUCKET(bp->flags)) { - if (to_disk && (bp->flags & BUF_MOD) && - __put_page(hashp, bp->page, - bp->addr, IS_BUCKET(bp->flags), 0)) - return (-1); - } - /* Check if we are freeing stuff */ - if (do_free) { - if (bp->page) - free(bp->page); - BUF_REMOVE(bp); - free(bp); - bp = LRU; - } else - bp = bp->prev; - } - return (0); -} - -extern void -__reclaim_buf(hashp, bp) - HTAB *hashp; - BUFHEAD *bp; -{ - bp->ovfl = 0; - bp->addr = 0; - bp->flags = 0; - BUF_REMOVE(bp); - LRU_INSERT(bp); -} diff --git a/lib/libc/db/hash/hash_func.c b/lib/libc/db/hash/hash_func.c deleted file mode 100644 index a5ec434..0000000 --- a/lib/libc/db/hash/hash_func.c +++ /dev/null @@ -1,212 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)hash_func.c 8.2 (Berkeley) 2/21/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include "hash.h" -#include "page.h" -#include "extern.h" - -static u_int32_t hash1 __P((const void *, size_t)); -static u_int32_t hash2 __P((const void *, size_t)); -static u_int32_t hash3 __P((const void *, size_t)); -static u_int32_t hash4 __P((const void *, size_t)); - -/* Global default hash function */ -u_int32_t (*__default_hash) __P((const void *, size_t)) = hash4; - -/* - * HASH FUNCTIONS - * - * Assume that we've already split the bucket to which this key hashes, - * calculate that bucket, and check that in fact we did already split it. - * - * This came from ejb's hsearch. - */ - -#define PRIME1 37 -#define PRIME2 1048583 - -static u_int32_t -hash1(keyarg, len) - const void *keyarg; - register size_t len; -{ - register const u_char *key; - register u_int32_t h; - - /* Convert string to integer */ - for (key = keyarg, h = 0; len--;) - h = h * PRIME1 ^ (*key++ - ' '); - h %= PRIME2; - return (h); -} - -/* - * Phong's linear congruential hash - */ -#define dcharhash(h, c) ((h) = 0x63c63cd9*(h) + 0x9c39c33d + (c)) - -static u_int32_t -hash2(keyarg, len) - const void *keyarg; - size_t len; -{ - register const u_char *e, *key; - register u_int32_t h; - register u_char c; - - key = keyarg; - e = key + len; - for (h = 0; key != e;) { - c = *key++; - if (!c && key > e) - break; - dcharhash(h, c); - } - return (h); -} - -/* - * This is INCREDIBLY ugly, but fast. We break the string up into 8 byte - * units. On the first time through the loop we get the "leftover bytes" - * (strlen % 8). On every other iteration, we perform 8 HASHC's so we handle - * all 8 bytes. Essentially, this saves us 7 cmp & branch instructions. If - * this routine is heavily used enough, it's worth the ugly coding. - * - * OZ's original sdbm hash - */ -static u_int32_t -hash3(keyarg, len) - const void *keyarg; - register size_t len; -{ - register const u_char *key; - register size_t loop; - register u_int32_t h; - -#define HASHC h = *key++ + 65599 * h - - h = 0; - key = keyarg; - if (len > 0) { - loop = (len + 8 - 1) >> 3; - - switch (len & (8 - 1)) { - case 0: - do { - HASHC; - /* FALLTHROUGH */ - case 7: - HASHC; - /* FALLTHROUGH */ - case 6: - HASHC; - /* FALLTHROUGH */ - case 5: - HASHC; - /* FALLTHROUGH */ - case 4: - HASHC; - /* FALLTHROUGH */ - case 3: - HASHC; - /* FALLTHROUGH */ - case 2: - HASHC; - /* FALLTHROUGH */ - case 1: - HASHC; - } while (--loop); - } - } - return (h); -} - -/* Hash function from Chris Torek. */ -static u_int32_t -hash4(keyarg, len) - const void *keyarg; - register size_t len; -{ - register const u_char *key; - register size_t loop; - register u_int32_t h; - -#define HASH4a h = (h << 5) - h + *key++; -#define HASH4b h = (h << 5) + h + *key++; -#define HASH4 HASH4b - - h = 0; - key = keyarg; - if (len > 0) { - loop = (len + 8 - 1) >> 3; - - switch (len & (8 - 1)) { - case 0: - do { - HASH4; - /* FALLTHROUGH */ - case 7: - HASH4; - /* FALLTHROUGH */ - case 6: - HASH4; - /* FALLTHROUGH */ - case 5: - HASH4; - /* FALLTHROUGH */ - case 4: - HASH4; - /* FALLTHROUGH */ - case 3: - HASH4; - /* FALLTHROUGH */ - case 2: - HASH4; - /* FALLTHROUGH */ - case 1: - HASH4; - } while (--loop); - } - } - return (h); -} diff --git a/lib/libc/db/hash/hash_log2.c b/lib/libc/db/hash/hash_log2.c deleted file mode 100644 index c8c56bf..0000000 --- a/lib/libc/db/hash/hash_log2.c +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)hash_log2.c 8.2 (Berkeley) 5/31/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include - -u_int32_t -__log2(num) - u_int32_t num; -{ - register u_int32_t i, limit; - - limit = 1; - for (i = 0; limit < num; limit = limit << 1, i++); - return (i); -} diff --git a/lib/libc/db/hash/hash_page.c b/lib/libc/db/hash/hash_page.c deleted file mode 100644 index 30445e4..0000000 --- a/lib/libc/db/hash/hash_page.c +++ /dev/null @@ -1,946 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hash_page.c 8.7 (Berkeley) 8/16/94"; -#endif /* LIBC_SCCS and not lint */ - -/* - * PACKAGE: hashing - * - * DESCRIPTION: - * Page manipulation for hashing package. - * - * ROUTINES: - * - * External - * __get_page - * __add_ovflpage - * Internal - * overflow_page - * open_temp - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#ifdef DEBUG -#include -#endif - -#include -#include "hash.h" -#include "page.h" -#include "extern.h" - -static u_int32_t *fetch_bitmap __P((HTAB *, int)); -static u_int32_t first_free __P((u_int32_t)); -static int open_temp __P((HTAB *)); -static u_int16_t overflow_page __P((HTAB *)); -static void putpair __P((char *, const DBT *, const DBT *)); -static void squeeze_key __P((u_int16_t *, const DBT *, const DBT *)); -static int ugly_split - __P((HTAB *, u_int32_t, BUFHEAD *, BUFHEAD *, int, int)); - -#define PAGE_INIT(P) { \ - ((u_int16_t *)(P))[0] = 0; \ - ((u_int16_t *)(P))[1] = hashp->BSIZE - 3 * sizeof(u_int16_t); \ - ((u_int16_t *)(P))[2] = hashp->BSIZE; \ -} - -/* - * This is called AFTER we have verified that there is room on the page for - * the pair (PAIRFITS has returned true) so we go right ahead and start moving - * stuff on. - */ -static void -putpair(p, key, val) - char *p; - const DBT *key, *val; -{ - register u_int16_t *bp, n, off; - - bp = (u_int16_t *)p; - - /* Enter the key first. */ - n = bp[0]; - - off = OFFSET(bp) - key->size; - memmove(p + off, key->data, key->size); - bp[++n] = off; - - /* Now the data. */ - off -= val->size; - memmove(p + off, val->data, val->size); - bp[++n] = off; - - /* Adjust page info. */ - bp[0] = n; - bp[n + 1] = off - ((n + 3) * sizeof(u_int16_t)); - bp[n + 2] = off; -} - -/* - * Returns: - * 0 OK - * -1 error - */ -extern int -__delpair(hashp, bufp, ndx) - HTAB *hashp; - BUFHEAD *bufp; - register int ndx; -{ - register u_int16_t *bp, newoff; - register int n; - u_int16_t pairlen; - - bp = (u_int16_t *)bufp->page; - n = bp[0]; - - if (bp[ndx + 1] < REAL_KEY) - return (__big_delete(hashp, bufp)); - if (ndx != 1) - newoff = bp[ndx - 1]; - else - newoff = hashp->BSIZE; - pairlen = newoff - bp[ndx + 1]; - - if (ndx != (n - 1)) { - /* Hard Case -- need to shuffle keys */ - register int i; - register char *src = bufp->page + (int)OFFSET(bp); - register char *dst = src + (int)pairlen; - memmove(dst, src, bp[ndx + 1] - OFFSET(bp)); - - /* Now adjust the pointers */ - for (i = ndx + 2; i <= n; i += 2) { - if (bp[i + 1] == OVFLPAGE) { - bp[i - 2] = bp[i]; - bp[i - 1] = bp[i + 1]; - } else { - bp[i - 2] = bp[i] + pairlen; - bp[i - 1] = bp[i + 1] + pairlen; - } - } - } - /* Finally adjust the page data */ - bp[n] = OFFSET(bp) + pairlen; - bp[n - 1] = bp[n + 1] + pairlen + 2 * sizeof(u_int16_t); - bp[0] = n - 2; - hashp->NKEYS--; - - bufp->flags |= BUF_MOD; - return (0); -} -/* - * Returns: - * 0 ==> OK - * -1 ==> Error - */ -extern int -__split_page(hashp, obucket, nbucket) - HTAB *hashp; - u_int32_t obucket, nbucket; -{ - register BUFHEAD *new_bufp, *old_bufp; - register u_int16_t *ino; - register char *np; - DBT key, val; - int n, ndx, retval; - u_int16_t copyto, diff, off, moved; - char *op; - - copyto = (u_int16_t)hashp->BSIZE; - off = (u_int16_t)hashp->BSIZE; - old_bufp = __get_buf(hashp, obucket, NULL, 0); - if (old_bufp == NULL) - return (-1); - new_bufp = __get_buf(hashp, nbucket, NULL, 0); - if (new_bufp == NULL) - return (-1); - - old_bufp->flags |= (BUF_MOD | BUF_PIN); - new_bufp->flags |= (BUF_MOD | BUF_PIN); - - ino = (u_int16_t *)(op = old_bufp->page); - np = new_bufp->page; - - moved = 0; - - for (n = 1, ndx = 1; n < ino[0]; n += 2) { - if (ino[n + 1] < REAL_KEY) { - retval = ugly_split(hashp, obucket, old_bufp, new_bufp, - (int)copyto, (int)moved); - old_bufp->flags &= ~BUF_PIN; - new_bufp->flags &= ~BUF_PIN; - return (retval); - - } - key.data = (u_char *)op + ino[n]; - key.size = off - ino[n]; - - if (__call_hash(hashp, key.data, key.size) == obucket) { - /* Don't switch page */ - diff = copyto - off; - if (diff) { - copyto = ino[n + 1] + diff; - memmove(op + copyto, op + ino[n + 1], - off - ino[n + 1]); - ino[ndx] = copyto + ino[n] - ino[n + 1]; - ino[ndx + 1] = copyto; - } else - copyto = ino[n + 1]; - ndx += 2; - } else { - /* Switch page */ - val.data = (u_char *)op + ino[n + 1]; - val.size = ino[n] - ino[n + 1]; - putpair(np, &key, &val); - moved += 2; - } - - off = ino[n + 1]; - } - - /* Now clean up the page */ - ino[0] -= moved; - FREESPACE(ino) = copyto - sizeof(u_int16_t) * (ino[0] + 3); - OFFSET(ino) = copyto; - -#ifdef DEBUG3 - (void)fprintf(stderr, "split %d/%d\n", - ((u_int16_t *)np)[0] / 2, - ((u_int16_t *)op)[0] / 2); -#endif - /* unpin both pages */ - old_bufp->flags &= ~BUF_PIN; - new_bufp->flags &= ~BUF_PIN; - return (0); -} - -/* - * Called when we encounter an overflow or big key/data page during split - * handling. This is special cased since we have to begin checking whether - * the key/data pairs fit on their respective pages and because we may need - * overflow pages for both the old and new pages. - * - * The first page might be a page with regular key/data pairs in which case - * we have a regular overflow condition and just need to go on to the next - * page or it might be a big key/data pair in which case we need to fix the - * big key/data pair. - * - * Returns: - * 0 ==> success - * -1 ==> failure - */ -static int -ugly_split(hashp, obucket, old_bufp, new_bufp, copyto, moved) - HTAB *hashp; - u_int32_t obucket; /* Same as __split_page. */ - BUFHEAD *old_bufp, *new_bufp; - int copyto; /* First byte on page which contains key/data values. */ - int moved; /* Number of pairs moved to new page. */ -{ - register BUFHEAD *bufp; /* Buffer header for ino */ - register u_int16_t *ino; /* Page keys come off of */ - register u_int16_t *np; /* New page */ - register u_int16_t *op; /* Page keys go on to if they aren't moving */ - - BUFHEAD *last_bfp; /* Last buf header OVFL needing to be freed */ - DBT key, val; - SPLIT_RETURN ret; - u_int16_t n, off, ov_addr, scopyto; - char *cino; /* Character value of ino */ - - bufp = old_bufp; - ino = (u_int16_t *)old_bufp->page; - np = (u_int16_t *)new_bufp->page; - op = (u_int16_t *)old_bufp->page; - last_bfp = NULL; - scopyto = (u_int16_t)copyto; /* ANSI */ - - n = ino[0] - 1; - while (n < ino[0]) { - if (ino[2] < REAL_KEY && ino[2] != OVFLPAGE) { - if (__big_split(hashp, old_bufp, - new_bufp, bufp, bufp->addr, obucket, &ret)) - return (-1); - old_bufp = ret.oldp; - if (!old_bufp) - return (-1); - op = (u_int16_t *)old_bufp->page; - new_bufp = ret.newp; - if (!new_bufp) - return (-1); - np = (u_int16_t *)new_bufp->page; - bufp = ret.nextp; - if (!bufp) - return (0); - cino = (char *)bufp->page; - ino = (u_int16_t *)cino; - last_bfp = ret.nextp; - } else if (ino[n + 1] == OVFLPAGE) { - ov_addr = ino[n]; - /* - * Fix up the old page -- the extra 2 are the fields - * which contained the overflow information. - */ - ino[0] -= (moved + 2); - FREESPACE(ino) = - scopyto - sizeof(u_int16_t) * (ino[0] + 3); - OFFSET(ino) = scopyto; - - bufp = __get_buf(hashp, ov_addr, bufp, 0); - if (!bufp) - return (-1); - - ino = (u_int16_t *)bufp->page; - n = 1; - scopyto = hashp->BSIZE; - moved = 0; - - if (last_bfp) - __free_ovflpage(hashp, last_bfp); - last_bfp = bufp; - } - /* Move regular sized pairs of there are any */ - off = hashp->BSIZE; - for (n = 1; (n < ino[0]) && (ino[n + 1] >= REAL_KEY); n += 2) { - cino = (char *)ino; - key.data = (u_char *)cino + ino[n]; - key.size = off - ino[n]; - val.data = (u_char *)cino + ino[n + 1]; - val.size = ino[n] - ino[n + 1]; - off = ino[n + 1]; - - if (__call_hash(hashp, key.data, key.size) == obucket) { - /* Keep on old page */ - if (PAIRFITS(op, (&key), (&val))) - putpair((char *)op, &key, &val); - else { - old_bufp = - __add_ovflpage(hashp, old_bufp); - if (!old_bufp) - return (-1); - op = (u_int16_t *)old_bufp->page; - putpair((char *)op, &key, &val); - } - old_bufp->flags |= BUF_MOD; - } else { - /* Move to new page */ - if (PAIRFITS(np, (&key), (&val))) - putpair((char *)np, &key, &val); - else { - new_bufp = - __add_ovflpage(hashp, new_bufp); - if (!new_bufp) - return (-1); - np = (u_int16_t *)new_bufp->page; - putpair((char *)np, &key, &val); - } - new_bufp->flags |= BUF_MOD; - } - } - } - if (last_bfp) - __free_ovflpage(hashp, last_bfp); - return (0); -} - -/* - * Add the given pair to the page - * - * Returns: - * 0 ==> OK - * 1 ==> failure - */ -extern int -__addel(hashp, bufp, key, val) - HTAB *hashp; - BUFHEAD *bufp; - const DBT *key, *val; -{ - register u_int16_t *bp, *sop; - int do_expand; - - bp = (u_int16_t *)bufp->page; - do_expand = 0; - while (bp[0] && (bp[2] < REAL_KEY || bp[bp[0]] < REAL_KEY)) - /* Exception case */ - if (bp[2] == FULL_KEY_DATA && bp[0] == 2) - /* This is the last page of a big key/data pair - and we need to add another page */ - break; - else if (bp[2] < REAL_KEY && bp[bp[0]] != OVFLPAGE) { - bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); - if (!bufp) - return (-1); - bp = (u_int16_t *)bufp->page; - } else - /* Try to squeeze key on this page */ - if (FREESPACE(bp) > PAIRSIZE(key, val)) { - squeeze_key(bp, key, val); - return (0); - } else { - bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); - if (!bufp) - return (-1); - bp = (u_int16_t *)bufp->page; - } - - if (PAIRFITS(bp, key, val)) - putpair(bufp->page, key, val); - else { - do_expand = 1; - bufp = __add_ovflpage(hashp, bufp); - if (!bufp) - return (-1); - sop = (u_int16_t *)bufp->page; - - if (PAIRFITS(sop, key, val)) - putpair((char *)sop, key, val); - else - if (__big_insert(hashp, bufp, key, val)) - return (-1); - } - bufp->flags |= BUF_MOD; - /* - * If the average number of keys per bucket exceeds the fill factor, - * expand the table. - */ - hashp->NKEYS++; - if (do_expand || - (hashp->NKEYS / (hashp->MAX_BUCKET + 1) > hashp->FFACTOR)) - return (__expand_table(hashp)); - return (0); -} - -/* - * - * Returns: - * pointer on success - * NULL on error - */ -extern BUFHEAD * -__add_ovflpage(hashp, bufp) - HTAB *hashp; - BUFHEAD *bufp; -{ - register u_int16_t *sp; - u_int16_t ndx, ovfl_num; -#ifdef DEBUG1 - int tmp1, tmp2; -#endif - sp = (u_int16_t *)bufp->page; - - /* Check if we are dynamically determining the fill factor */ - if (hashp->FFACTOR == DEF_FFACTOR) { - hashp->FFACTOR = sp[0] >> 1; - if (hashp->FFACTOR < MIN_FFACTOR) - hashp->FFACTOR = MIN_FFACTOR; - } - bufp->flags |= BUF_MOD; - ovfl_num = overflow_page(hashp); -#ifdef DEBUG1 - tmp1 = bufp->addr; - tmp2 = bufp->ovfl ? bufp->ovfl->addr : 0; -#endif - if (!ovfl_num || !(bufp->ovfl = __get_buf(hashp, ovfl_num, bufp, 1))) - return (NULL); - bufp->ovfl->flags |= BUF_MOD; -#ifdef DEBUG1 - (void)fprintf(stderr, "ADDOVFLPAGE: %d->ovfl was %d is now %d\n", - tmp1, tmp2, bufp->ovfl->addr); -#endif - ndx = sp[0]; - /* - * Since a pair is allocated on a page only if there's room to add - * an overflow page, we know that the OVFL information will fit on - * the page. - */ - sp[ndx + 4] = OFFSET(sp); - sp[ndx + 3] = FREESPACE(sp) - OVFLSIZE; - sp[ndx + 1] = ovfl_num; - sp[ndx + 2] = OVFLPAGE; - sp[0] = ndx + 2; -#ifdef HASH_STATISTICS - hash_overflows++; -#endif - return (bufp->ovfl); -} - -/* - * Returns: - * 0 indicates SUCCESS - * -1 indicates FAILURE - */ -extern int -__get_page(hashp, p, bucket, is_bucket, is_disk, is_bitmap) - HTAB *hashp; - char *p; - u_int32_t bucket; - int is_bucket, is_disk, is_bitmap; -{ - register int fd, page, size; - int rsize; - u_int16_t *bp; - - fd = hashp->fp; - size = hashp->BSIZE; - - if ((fd == -1) || !is_disk) { - PAGE_INIT(p); - return (0); - } - if (is_bucket) - page = BUCKET_TO_PAGE(bucket); - else - page = OADDR_TO_PAGE(bucket); - if ((lseek(fd, (off_t)page << hashp->BSHIFT, SEEK_SET) == -1) || - ((rsize = _read(fd, p, size)) == -1)) - return (-1); - bp = (u_int16_t *)p; - if (!rsize) - bp[0] = 0; /* We hit the EOF, so initialize a new page */ - else - if (rsize != size) { - errno = EFTYPE; - return (-1); - } - if (!is_bitmap && !bp[0]) { - PAGE_INIT(p); - } else - if (hashp->LORDER != BYTE_ORDER) { - register int i, max; - - if (is_bitmap) { - max = hashp->BSIZE >> 2; /* divide by 4 */ - for (i = 0; i < max; i++) - M_32_SWAP(((int *)p)[i]); - } else { - M_16_SWAP(bp[0]); - max = bp[0] + 2; - for (i = 1; i <= max; i++) - M_16_SWAP(bp[i]); - } - } - return (0); -} - -/* - * Write page p to disk - * - * Returns: - * 0 ==> OK - * -1 ==>failure - */ -extern int -__put_page(hashp, p, bucket, is_bucket, is_bitmap) - HTAB *hashp; - char *p; - u_int32_t bucket; - int is_bucket, is_bitmap; -{ - register int fd, page, size; - int wsize; - - size = hashp->BSIZE; - if ((hashp->fp == -1) && open_temp(hashp)) - return (-1); - fd = hashp->fp; - - if (hashp->LORDER != BYTE_ORDER) { - register int i; - register int max; - - if (is_bitmap) { - max = hashp->BSIZE >> 2; /* divide by 4 */ - for (i = 0; i < max; i++) - M_32_SWAP(((int *)p)[i]); - } else { - max = ((u_int16_t *)p)[0] + 2; - for (i = 0; i <= max; i++) - M_16_SWAP(((u_int16_t *)p)[i]); - } - } - if (is_bucket) - page = BUCKET_TO_PAGE(bucket); - else - page = OADDR_TO_PAGE(bucket); - if ((lseek(fd, (off_t)page << hashp->BSHIFT, SEEK_SET) == -1) || - ((wsize = _write(fd, p, size)) == -1)) - /* Errno is set */ - return (-1); - if (wsize != size) { - errno = EFTYPE; - return (-1); - } - return (0); -} - -#define BYTE_MASK ((1 << INT_BYTE_SHIFT) -1) -/* - * Initialize a new bitmap page. Bitmap pages are left in memory - * once they are read in. - */ -extern int -__ibitmap(hashp, pnum, nbits, ndx) - HTAB *hashp; - int pnum, nbits, ndx; -{ - u_int32_t *ip; - int clearbytes, clearints; - - if ((ip = (u_int32_t *)malloc(hashp->BSIZE)) == NULL) - return (1); - hashp->nmaps++; - clearints = ((nbits - 1) >> INT_BYTE_SHIFT) + 1; - clearbytes = clearints << INT_TO_BYTE; - (void)memset((char *)ip, 0, clearbytes); - (void)memset(((char *)ip) + clearbytes, 0xFF, - hashp->BSIZE - clearbytes); - ip[clearints - 1] = ALL_SET << (nbits & BYTE_MASK); - SETBIT(ip, 0); - hashp->BITMAPS[ndx] = (u_int16_t)pnum; - hashp->mapp[ndx] = ip; - return (0); -} - -static u_int32_t -first_free(map) - u_int32_t map; -{ - register u_int32_t i, mask; - - mask = 0x1; - for (i = 0; i < BITS_PER_MAP; i++) { - if (!(mask & map)) - return (i); - mask = mask << 1; - } - return (i); -} - -static u_int16_t -overflow_page(hashp) - HTAB *hashp; -{ - register u_int32_t *freep; - register int max_free, offset, splitnum; - u_int16_t addr; - int bit, first_page, free_bit, free_page, i, in_use_bits, j; -#ifdef DEBUG2 - int tmp1, tmp2; -#endif - splitnum = hashp->OVFL_POINT; - max_free = hashp->SPARES[splitnum]; - - free_page = (max_free - 1) >> (hashp->BSHIFT + BYTE_SHIFT); - free_bit = (max_free - 1) & ((hashp->BSIZE << BYTE_SHIFT) - 1); - - /* Look through all the free maps to find the first free block */ - first_page = hashp->LAST_FREED >>(hashp->BSHIFT + BYTE_SHIFT); - for ( i = first_page; i <= free_page; i++ ) { - if (!(freep = (u_int32_t *)hashp->mapp[i]) && - !(freep = fetch_bitmap(hashp, i))) - return (0); - if (i == free_page) - in_use_bits = free_bit; - else - in_use_bits = (hashp->BSIZE << BYTE_SHIFT) - 1; - - if (i == first_page) { - bit = hashp->LAST_FREED & - ((hashp->BSIZE << BYTE_SHIFT) - 1); - j = bit / BITS_PER_MAP; - bit = bit & ~(BITS_PER_MAP - 1); - } else { - bit = 0; - j = 0; - } - for (; bit <= in_use_bits; j++, bit += BITS_PER_MAP) - if (freep[j] != ALL_SET) - goto found; - } - - /* No Free Page Found */ - hashp->LAST_FREED = hashp->SPARES[splitnum]; - hashp->SPARES[splitnum]++; - offset = hashp->SPARES[splitnum] - - (splitnum ? hashp->SPARES[splitnum - 1] : 0); - -#define OVMSG "HASH: Out of overflow pages. Increase page size\n" - if (offset > SPLITMASK) { - if (++splitnum >= NCACHED) { - (void)_write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1); - return (0); - } - hashp->OVFL_POINT = splitnum; - hashp->SPARES[splitnum] = hashp->SPARES[splitnum-1]; - hashp->SPARES[splitnum-1]--; - offset = 1; - } - - /* Check if we need to allocate a new bitmap page */ - if (free_bit == (hashp->BSIZE << BYTE_SHIFT) - 1) { - free_page++; - if (free_page >= NCACHED) { - (void)_write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1); - return (0); - } - /* - * This is tricky. The 1 indicates that you want the new page - * allocated with 1 clear bit. Actually, you are going to - * allocate 2 pages from this map. The first is going to be - * the map page, the second is the overflow page we were - * looking for. The init_bitmap routine automatically, sets - * the first bit of itself to indicate that the bitmap itself - * is in use. We would explicitly set the second bit, but - * don't have to if we tell init_bitmap not to leave it clear - * in the first place. - */ - if (__ibitmap(hashp, - (int)OADDR_OF(splitnum, offset), 1, free_page)) - return (0); - hashp->SPARES[splitnum]++; -#ifdef DEBUG2 - free_bit = 2; -#endif - offset++; - if (offset > SPLITMASK) { - if (++splitnum >= NCACHED) { - (void)_write(STDERR_FILENO, OVMSG, - sizeof(OVMSG) - 1); - return (0); - } - hashp->OVFL_POINT = splitnum; - hashp->SPARES[splitnum] = hashp->SPARES[splitnum-1]; - hashp->SPARES[splitnum-1]--; - offset = 0; - } - } else { - /* - * Free_bit addresses the last used bit. Bump it to address - * the first available bit. - */ - free_bit++; - SETBIT(freep, free_bit); - } - - /* Calculate address of the new overflow page */ - addr = OADDR_OF(splitnum, offset); -#ifdef DEBUG2 - (void)fprintf(stderr, "OVERFLOW_PAGE: ADDR: %d BIT: %d PAGE %d\n", - addr, free_bit, free_page); -#endif - return (addr); - -found: - bit = bit + first_free(freep[j]); - SETBIT(freep, bit); -#ifdef DEBUG2 - tmp1 = bit; - tmp2 = i; -#endif - /* - * Bits are addressed starting with 0, but overflow pages are addressed - * beginning at 1. Bit is a bit addressnumber, so we need to increment - * it to convert it to a page number. - */ - bit = 1 + bit + (i * (hashp->BSIZE << BYTE_SHIFT)); - if (bit >= hashp->LAST_FREED) - hashp->LAST_FREED = bit - 1; - - /* Calculate the split number for this page */ - for (i = 0; (i < splitnum) && (bit > hashp->SPARES[i]); i++); - offset = (i ? bit - hashp->SPARES[i - 1] : bit); - if (offset >= SPLITMASK) - return (0); /* Out of overflow pages */ - addr = OADDR_OF(i, offset); -#ifdef DEBUG2 - (void)fprintf(stderr, "OVERFLOW_PAGE: ADDR: %d BIT: %d PAGE %d\n", - addr, tmp1, tmp2); -#endif - - /* Allocate and return the overflow page */ - return (addr); -} - -/* - * Mark this overflow page as free. - */ -extern void -__free_ovflpage(hashp, obufp) - HTAB *hashp; - BUFHEAD *obufp; -{ - register u_int16_t addr; - u_int32_t *freep; - int bit_address, free_page, free_bit; - u_int16_t ndx; - - addr = obufp->addr; -#ifdef DEBUG1 - (void)fprintf(stderr, "Freeing %d\n", addr); -#endif - ndx = (((u_int16_t)addr) >> SPLITSHIFT); - bit_address = - (ndx ? hashp->SPARES[ndx - 1] : 0) + (addr & SPLITMASK) - 1; - if (bit_address < hashp->LAST_FREED) - hashp->LAST_FREED = bit_address; - free_page = (bit_address >> (hashp->BSHIFT + BYTE_SHIFT)); - free_bit = bit_address & ((hashp->BSIZE << BYTE_SHIFT) - 1); - - if (!(freep = hashp->mapp[free_page])) - freep = fetch_bitmap(hashp, free_page); -#ifdef DEBUG - /* - * This had better never happen. It means we tried to read a bitmap - * that has already had overflow pages allocated off it, and we - * failed to read it from the file. - */ - if (!freep) - assert(0); -#endif - CLRBIT(freep, free_bit); -#ifdef DEBUG2 - (void)fprintf(stderr, "FREE_OVFLPAGE: ADDR: %d BIT: %d PAGE %d\n", - obufp->addr, free_bit, free_page); -#endif - __reclaim_buf(hashp, obufp); -} - -/* - * Returns: - * 0 success - * -1 failure - */ -static int -open_temp(hashp) - HTAB *hashp; -{ - sigset_t set, oset; - static char namestr[] = "_hashXXXXXX"; - - /* Block signals; make sure file goes away at process exit. */ - (void)sigfillset(&set); - (void)sigprocmask(SIG_BLOCK, &set, &oset); - if ((hashp->fp = mkstemp(namestr)) != -1) { - (void)unlink(namestr); - (void)_fcntl(hashp->fp, F_SETFD, 1); - } - (void)sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL); - return (hashp->fp != -1 ? 0 : -1); -} - -/* - * We have to know that the key will fit, but the last entry on the page is - * an overflow pair, so we need to shift things. - */ -static void -squeeze_key(sp, key, val) - u_int16_t *sp; - const DBT *key, *val; -{ - register char *p; - u_int16_t free_space, n, off, pageno; - - p = (char *)sp; - n = sp[0]; - free_space = FREESPACE(sp); - off = OFFSET(sp); - - pageno = sp[n - 1]; - off -= key->size; - sp[n - 1] = off; - memmove(p + off, key->data, key->size); - off -= val->size; - sp[n] = off; - memmove(p + off, val->data, val->size); - sp[0] = n + 2; - sp[n + 1] = pageno; - sp[n + 2] = OVFLPAGE; - FREESPACE(sp) = free_space - PAIRSIZE(key, val); - OFFSET(sp) = off; -} - -static u_int32_t * -fetch_bitmap(hashp, ndx) - HTAB *hashp; - int ndx; -{ - if (ndx >= hashp->nmaps) - return (NULL); - if ((hashp->mapp[ndx] = (u_int32_t *)malloc(hashp->BSIZE)) == NULL) - return (NULL); - if (__get_page(hashp, - (char *)hashp->mapp[ndx], hashp->BITMAPS[ndx], 0, 1, 1)) { - free(hashp->mapp[ndx]); - return (NULL); - } - return (hashp->mapp[ndx]); -} - -#ifdef DEBUG4 -int -print_chain(addr) - int addr; -{ - BUFHEAD *bufp; - short *bp, oaddr; - - (void)fprintf(stderr, "%d ", addr); - bufp = __get_buf(hashp, addr, NULL, 0); - bp = (short *)bufp->page; - while (bp[0] && ((bp[bp[0]] == OVFLPAGE) || - ((bp[0] > 2) && bp[2] < REAL_KEY))) { - oaddr = bp[bp[0] - 1]; - (void)fprintf(stderr, "%d ", (int)oaddr); - bufp = __get_buf(hashp, (int)oaddr, bufp, 0); - bp = (short *)bufp->page; - } - (void)fprintf(stderr, "\n"); -} -#endif diff --git a/lib/libc/db/hash/hsearch.c b/lib/libc/db/hash/hsearch.c deleted file mode 100644 index 6185330..0000000 --- a/lib/libc/db/hash/hsearch.c +++ /dev/null @@ -1,107 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)hsearch.c 8.4 (Berkeley) 7/21/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include - -#include -#include "search.h" - -static DB *dbp = NULL; -static ENTRY retval; - -extern int -hcreate(nel) - u_int nel; -{ - HASHINFO info; - - info.nelem = nel; - info.bsize = 256; - info.ffactor = 8; - info.cachesize = 0; - info.hash = NULL; - info.lorder = 0; - dbp = (DB *)__hash_open(NULL, O_CREAT | O_RDWR, 0600, &info, 0); - return (dbp != NULL); -} - -extern ENTRY * -hsearch(item, action) - ENTRY item; - ACTION action; -{ - DBT key, val; - int status; - - if (!dbp) - return (NULL); - key.data = (u_char *)item.key; - key.size = strlen(item.key) + 1; - - if (action == ENTER) { - val.data = (u_char *)item.data; - val.size = strlen(item.data) + 1; - status = (dbp->put)(dbp, &key, &val, R_NOOVERWRITE); - if (status) - return (NULL); - } else { - /* FIND */ - status = (dbp->get)(dbp, &key, &val, 0); - if (status) - return (NULL); - else - item.data = (char *)val.data; - } - retval.key = item.key; - retval.data = item.data; - return (&retval); -} - -extern void -hdestroy() -{ - if (dbp) { - (void)(dbp->close)(dbp); - dbp = NULL; - } -} diff --git a/lib/libc/db/hash/ndbm.c b/lib/libc/db/hash/ndbm.c deleted file mode 100644 index 2e8165d..0000000 --- a/lib/libc/db/hash/ndbm.c +++ /dev/null @@ -1,229 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)ndbm.c 8.4 (Berkeley) 7/21/94"; -#endif /* LIBC_SCCS and not lint */ - -/* - * This package provides a dbm compatible interface to the new hashing - * package described in db(3). - */ - -#include - -#include -#include -#include - -#include -#include "hash.h" - -/* - * Returns: - * *DBM on success - * NULL on failure - */ -extern DBM * -dbm_open(file, flags, mode) - const char *file; - int flags, mode; -{ - HASHINFO info; - char path[MAXPATHLEN]; - - info.bsize = 4096; - info.ffactor = 40; - info.nelem = 1; - info.cachesize = 0; - info.hash = NULL; - info.lorder = 0; - - if( strlen(file) >= sizeof(path) - strlen(DBM_SUFFIX)) { - errno = ENAMETOOLONG; - return(NULL); - } - (void)strcpy(path, file); - (void)strcat(path, DBM_SUFFIX); - return ((DBM *)__hash_open(path, flags, mode, &info, 0)); -} - -extern void -dbm_close(db) - DBM *db; -{ - (void)(db->close)(db); -} - -/* - * Returns: - * DATUM on success - * NULL on failure - */ -extern datum -dbm_fetch(db, key) - DBM *db; - datum key; -{ - datum retdata; - int status; - DBT dbtkey, dbtretdata; - - dbtkey.data = key.dptr; - dbtkey.size = key.dsize; - status = (db->get)(db, &dbtkey, &dbtretdata, 0); - if (status) { - dbtretdata.data = NULL; - dbtretdata.size = 0; - } - retdata.dptr = dbtretdata.data; - retdata.dsize = dbtretdata.size; - return (retdata); -} - -/* - * Returns: - * DATUM on success - * NULL on failure - */ -extern datum -dbm_firstkey(db) - DBM *db; -{ - int status; - datum retkey; - DBT dbtretkey, dbtretdata; - - status = (db->seq)(db, &dbtretkey, &dbtretdata, R_FIRST); - if (status) - dbtretkey.data = NULL; - retkey.dptr = dbtretkey.data; - retkey.dsize = dbtretkey.size; - return (retkey); -} - -/* - * Returns: - * DATUM on success - * NULL on failure - */ -extern datum -dbm_nextkey(db) - DBM *db; -{ - int status; - datum retkey; - DBT dbtretkey, dbtretdata; - - status = (db->seq)(db, &dbtretkey, &dbtretdata, R_NEXT); - if (status) - dbtretkey.data = NULL; - retkey.dptr = dbtretkey.data; - retkey.dsize = dbtretkey.size; - return (retkey); -} - -/* - * Returns: - * 0 on success - * <0 failure - */ -extern int -dbm_delete(db, key) - DBM *db; - datum key; -{ - int status; - DBT dbtkey; - - dbtkey.data = key.dptr; - dbtkey.size = key.dsize; - status = (db->del)(db, &dbtkey, 0); - if (status) - return (-1); - else - return (0); -} - -/* - * Returns: - * 0 on success - * <0 failure - * 1 if DBM_INSERT and entry exists - */ -extern int -dbm_store(db, key, data, flags) - DBM *db; - datum key, data; - int flags; -{ - DBT dbtkey, dbtdata; - - dbtkey.data = key.dptr; - dbtkey.size = key.dsize; - dbtdata.data = data.dptr; - dbtdata.size = data.dsize; - return ((db->put)(db, &dbtkey, &dbtdata, - (flags == DBM_INSERT) ? R_NOOVERWRITE : 0)); -} - -extern int -dbm_error(db) - DBM *db; -{ - HTAB *hp; - - hp = (HTAB *)db->internal; - return (hp->error); -} - -extern int -dbm_clearerr(db) - DBM *db; -{ - HTAB *hp; - - hp = (HTAB *)db->internal; - hp->error = 0; - return (0); -} - -extern int -dbm_dirfno(db) - DBM *db; -{ - return(((HTAB *)db->internal)->fp); -} diff --git a/lib/libc/db/hash/page.h b/lib/libc/db/hash/page.h deleted file mode 100644 index 0fc0d5a..0000000 --- a/lib/libc/db/hash/page.h +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)page.h 8.2 (Berkeley) 5/31/94 - */ - -/* - * Definitions for hashing page file format. - */ - -/* - * routines dealing with a data page - * - * page format: - * +------------------------------+ - * p | n | keyoff | datoff | keyoff | - * +------------+--------+--------+ - * | datoff | free | ptr | --> | - * +--------+---------------------+ - * | F R E E A R E A | - * +--------------+---------------+ - * | <---- - - - | data | - * +--------+-----+----+----------+ - * | key | data | key | - * +--------+----------+----------+ - * - * Pointer to the free space is always: p[p[0] + 2] - * Amount of free space on the page is: p[p[0] + 1] - */ - -/* - * How many bytes required for this pair? - * 2 shorts in the table at the top of the page + room for the - * key and room for the data - * - * We prohibit entering a pair on a page unless there is also room to append - * an overflow page. The reason for this it that you can get in a situation - * where a single key/data pair fits on a page, but you can't append an - * overflow page and later you'd have to split the key/data and handle like - * a big pair. - * You might as well do this up front. - */ - -#define PAIRSIZE(K,D) (2*sizeof(u_int16_t) + (K)->size + (D)->size) -#define BIGOVERHEAD (4*sizeof(u_int16_t)) -#define KEYSIZE(K) (4*sizeof(u_int16_t) + (K)->size); -#define OVFLSIZE (2*sizeof(u_int16_t)) -#define FREESPACE(P) ((P)[(P)[0]+1]) -#define OFFSET(P) ((P)[(P)[0]+2]) -#define PAIRFITS(P,K,D) \ - (((P)[2] >= REAL_KEY) && \ - (PAIRSIZE((K),(D)) + OVFLSIZE) <= FREESPACE((P))) -#define PAGE_META(N) (((N)+3) * sizeof(u_int16_t)) - -typedef struct { - BUFHEAD *newp; - BUFHEAD *oldp; - BUFHEAD *nextp; - u_int16_t next_addr; -} SPLIT_RETURN; diff --git a/lib/libc/db/hash/search.h b/lib/libc/db/hash/search.h deleted file mode 100644 index 4d3b914..0000000 --- a/lib/libc/db/hash/search.h +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)search.h 8.1 (Berkeley) 6/4/93 - */ - -/* Backward compatibility to hsearch interface. */ -typedef struct entry { - char *key; - char *data; -} ENTRY; - -typedef enum { - FIND, ENTER -} ACTION; - -int hcreate __P((unsigned int)); -void hdestroy __P((void)); -ENTRY *hsearch __P((ENTRY, ACTION)); diff --git a/lib/libc/db/man/Makefile.inc b/lib/libc/db/man/Makefile.inc deleted file mode 100644 index 1498413..0000000 --- a/lib/libc/db/man/Makefile.inc +++ /dev/null @@ -1,10 +0,0 @@ -# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 -# $FreeBSD$ - -.PATH: ${.CURDIR}/../libc/db/man - -.if ${LIB} == "c" -MAN3+= btree.3 dbopen.3 hash.3 mpool.3 recno.3 - -MLINKS+= dbopen.3 db.3 -.endif diff --git a/lib/libc/db/man/btree.3 b/lib/libc/db/man/btree.3 deleted file mode 100644 index 9ce6d66..0000000 --- a/lib/libc/db/man/btree.3 +++ /dev/null @@ -1,234 +0,0 @@ -.\" Copyright (c) 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. -.\" -.\" @(#)btree.3 8.4 (Berkeley) 8/18/94 -.\" $FreeBSD$ -.\" -.TH BTREE 3 "August 18, 1994" -.\".UC 7 -.SH NAME -btree \- btree database access method -.SH SYNOPSIS -.nf -.ft B -#include -#include -.ft R -.fi -.SH DESCRIPTION -The routine -.IR dbopen -is the library interface to database files. -One of the supported file formats is btree files. -The general description of the database access methods is in -.IR dbopen (3), -this manual page describes only the btree specific information. -.PP -The btree data structure is a sorted, balanced tree structure storing -associated key/data pairs. -.PP -The btree access method specific data structure provided to -.I dbopen -is defined in the include file as follows: -.PP -typedef struct { -.RS -u_long flags; -.br -u_int cachesize; -.br -int maxkeypage; -.br -int minkeypage; -.br -u_int psize; -.br -int (*compare)(const DBT *key1, const DBT *key2); -.br -size_t (*prefix)(const DBT *key1, const DBT *key2); -.br -int lorder; -.RE -} BTREEINFO; -.PP -The elements of this structure are as follows: -.TP -flags -The flag value is specified by -.IR or 'ing -any of the following values: -.RS -.TP -R_DUP -Permit duplicate keys in the tree, i.e. permit insertion if the key to be -inserted already exists in the tree. -The default behavior, as described in -.IR dbopen (3), -is to overwrite a matching key when inserting a new key or to fail if -the R_NOOVERWRITE flag is specified. -The R_DUP flag is overridden by the R_NOOVERWRITE flag, and if the -R_NOOVERWRITE flag is specified, attempts to insert duplicate keys into -the tree will fail. -.IP -If the database contains duplicate keys, the order of retrieval of -key/data pairs is undefined if the -.I get -routine is used, however, -.I seq -routine calls with the R_CURSOR flag set will always return the logical -``first'' of any group of duplicate keys. -.RE -.TP -cachesize -A suggested maximum size (in bytes) of the memory cache. -This value is -.B only -advisory, and the access method will allocate more memory rather than fail. -Since every search examines the root page of the tree, caching the most -recently used pages substantially improves access time. -In addition, physical writes are delayed as long as possible, so a moderate -cache can reduce the number of I/O operations significantly. -Obviously, using a cache increases (but only increases) the likelihood of -corruption or lost data if the system crashes while a tree is being modified. -If -.I cachesize -is 0 (no size is specified) a default cache is used. -.TP -maxkeypage -The maximum number of keys which will be stored on any single page. -Not currently implemented. -.\" The maximum number of keys which will be stored on any single page. -.\" Because of the way the btree data structure works, -.\" .I maxkeypage -.\" must always be greater than or equal to 2. -.\" If -.\" .I maxkeypage -.\" is 0 (no maximum number of keys is specified) the page fill factor is -.\" made as large as possible (which is almost invariably what is wanted). -.TP -minkeypage -The minimum number of keys which will be stored on any single page. -This value is used to determine which keys will be stored on overflow -pages, i.e. if a key or data item is longer than the pagesize divided -by the minkeypage value, it will be stored on overflow pages instead -of in the page itself. -If -.I minkeypage -is 0 (no minimum number of keys is specified) a value of 2 is used. -.TP -psize -Page size is the size (in bytes) of the pages used for nodes in the tree. -The minimum page size is 512 bytes and the maximum page size is 64K. -If -.I psize -is 0 (no page size is specified) a page size is chosen based on the -underlying file system I/O block size. -.TP -compare -Compare is the key comparison function. -It must return an integer less than, equal to, or greater than zero if the -first key argument is considered to be respectively less than, equal to, -or greater than the second key argument. -The same comparison function must be used on a given tree every time it -is opened. -If -.I compare -is NULL (no comparison function is specified), the keys are compared -lexically, with shorter keys considered less than longer keys. -.TP -prefix -Prefix is the prefix comparison function. -If specified, this routine must return the number of bytes of the second key -argument which are necessary to determine that it is greater than the first -key argument. -If the keys are equal, the key length should be returned. -Note, the usefulness of this routine is very data dependent, but, in some -data sets can produce significantly reduced tree sizes and search times. -If -.I prefix -is NULL (no prefix function is specified), -.B and -no comparison function is specified, a default lexical comparison routine -is used. -If -.I prefix -is NULL and a comparison routine is specified, no prefix comparison is -done. -.TP -lorder -The byte order for integers in the stored database metadata. -The number should represent the order as an integer; for example, -big endian order would be the number 4,321. -If -.I lorder -is 0 (no order is specified) the current host order is used. -.PP -If the file already exists (and the O_TRUNC flag is not specified), the -values specified for the parameters flags, lorder and psize are ignored -in favor of the values used when the tree was created. -.PP -Forward sequential scans of a tree are from the least key to the greatest. -.PP -Space freed up by deleting key/data pairs from the tree is never reclaimed, -although it is normally made available for reuse. -This means that the btree storage structure is grow-only. -The only solutions are to avoid excessive deletions, or to create a fresh -tree periodically from a scan of an existing one. -.PP -Searches, insertions, and deletions in a btree will all complete in -O lg base N where base is the average fill factor. -Often, inserting ordered data into btrees results in a low fill factor. -This implementation has been modified to make ordered insertion the best -case, resulting in a much better than normal page fill factor. -.SH ERRORS -The -.I btree -access method routines may fail and set -.I errno -for any of the errors specified for the library routine -.IR dbopen (3). -.SH "SEE ALSO" -.IR dbopen (3), -.IR hash (3), -.IR mpool (3), -.IR recno (3) -.sp -.IR "The Ubiquitous B-tree" , -Douglas Comer, ACM Comput. Surv. 11, 2 (June 1979), 121-138. -.sp -.IR "Prefix B-trees" , -Bayer and Unterauer, ACM Transactions on Database Systems, Vol. 2, 1 -(March 1977), 11-26. -.sp -.IR "The Art of Computer Programming Vol. 3: Sorting and Searching" , -D.E. Knuth, 1968, pp 471-480. -.SH BUGS -Only big and little endian byte order is supported. diff --git a/lib/libc/db/man/dbopen.3 b/lib/libc/db/man/dbopen.3 deleted file mode 100644 index defc687..0000000 --- a/lib/libc/db/man/dbopen.3 +++ /dev/null @@ -1,477 +0,0 @@ -.\" Copyright (c) 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. -.\" -.\" @(#)dbopen.3 8.5 (Berkeley) 1/2/94 -.\" $FreeBSD$ -.\" -.TH DBOPEN 3 "January 2, 1994" -.UC 7 -.SH NAME -dbopen \- database access methods -.SH SYNOPSIS -.nf -.ft B -#include -#include -#include - -DB * -dbopen(const char *file, int flags, int mode, DBTYPE type, -.ti +5 -const void *openinfo); -.ft R -.fi -.SH DESCRIPTION -.IR Dbopen -is the library interface to database files. -The supported file formats are btree, hashed and UNIX file oriented. -The btree format is a representation of a sorted, balanced tree structure. -The hashed format is an extensible, dynamic hashing scheme. -The flat-file format is a byte stream file with fixed or variable length -records. -The formats and file format specific information are described in detail -in their respective manual pages -.IR btree (3), -.IR hash (3) -and -.IR recno (3). -.PP -Dbopen opens -.I file -for reading and/or writing. -Files never intended to be preserved on disk may be created by setting -the file parameter to NULL. -.PP -The -.I flags -and -.I mode arguments -are as specified to the -.IR open (2) -routine, however, only the O_CREAT, O_EXCL, O_EXLOCK, O_NONBLOCK, -O_RDONLY, O_RDWR, O_SHLOCK and O_TRUNC flags are meaningful. -(Note, opening a database file O_WRONLY is not possible.) -.\"Three additional options may be specified by -.\".IR or 'ing -.\"them into the -.\".I flags -.\"argument. -.\".TP -.\"DB_LOCK -.\"Do the necessary locking in the database to support concurrent access. -.\"If concurrent access isn't needed or the database is read-only this -.\"flag should not be set, as it tends to have an associated performance -.\"penalty. -.\".TP -.\"DB_SHMEM -.\"Place the underlying memory pool used by the database in shared -.\"memory. -.\"Necessary for concurrent access. -.\".TP -.\"DB_TXN -.\"Support transactions in the database. -.\"The DB_LOCK and DB_SHMEM flags must be set as well. -.PP -The -.I type -argument is of type DBTYPE (as defined in the include file) and -may be set to DB_BTREE, DB_HASH or DB_RECNO. -.PP -The -.I openinfo -argument is a pointer to an access method specific structure described -in the access method's manual page. -If -.I openinfo -is NULL, each access method will use defaults appropriate for the system -and the access method. -.PP -.I Dbopen -returns a pointer to a DB structure on success and NULL on error. -The DB structure is defined in the include file, and contains at -least the following fields: -.sp -.nf -typedef struct { -.RS -DBTYPE type; -int (*close)(const DB *db); -int (*del)(const DB *db, const DBT *key, u_int flags); -int (*fd)(const DB *db); -int (*get)(const DB *db, DBT *key, DBT *data, u_int flags); -int (*put)(const DB *db, DBT *key, const DBT *data, -.ti +5 -u_int flags); -int (*sync)(const DB *db, u_int flags); -int (*seq)(const DB *db, DBT *key, DBT *data, u_int flags); -.RE -} DB; -.fi -.PP -These elements describe a database type and a set of functions performing -various actions. -These functions take a pointer to a structure as returned by -.IR dbopen , -and sometimes one or more pointers to key/data structures and a flag value. -.TP -type -The type of the underlying access method (and file format). -.TP -close -A pointer to a routine to flush any cached information to disk, free any -allocated resources, and close the underlying file(s). -Since key/data pairs may be cached in memory, failing to sync the file -with a -.I close -or -.I sync -function may result in inconsistent or lost information. -.I Close -routines return -1 on error (setting -.IR errno ) -and 0 on success. -.TP -del -A pointer to a routine to remove key/data pairs from the database. -.IP -The parameter -.I flag -may be set to the following value: -.RS -.TP -R_CURSOR -Delete the record referenced by the cursor. -The cursor must have previously been initialized. -.RE -.IP -.I Delete -routines return -1 on error (setting -.IR errno ), -0 on success, and 1 if the specified -.I key -was not in the file. -.TP -fd -A pointer to a routine which returns a file descriptor representative -of the underlying database. -A file descriptor referencing the same file will be returned to all -processes which call -.I dbopen -with the same -.I file -name. -This file descriptor may be safely used as an argument to the -.IR fcntl (2) -and -.IR flock (2) -locking functions. -The file descriptor is not necessarily associated with any of the -underlying files used by the access method. -No file descriptor is available for in memory databases. -.I Fd -routines return -1 on error (setting -.IR errno ), -and the file descriptor on success. -.TP -get -A pointer to a routine which is the interface for keyed retrieval from -the database. -The address and length of the data associated with the specified -.I key -are returned in the structure referenced by -.IR data . -.I Get -routines return -1 on error (setting -.IR errno ), -0 on success, and 1 if the -.I key -was not in the file. -.TP -put -A pointer to a routine to store key/data pairs in the database. -.IP -The parameter -.I flag -may be set to one of the following values: -.RS -.TP -R_CURSOR -Replace the key/data pair referenced by the cursor. -The cursor must have previously been initialized. -.TP -R_IAFTER -Append the data immediately after the data referenced by -.IR key , -creating a new key/data pair. -The record number of the appended key/data pair is returned in the -.I key -structure. -(Applicable only to the DB_RECNO access method.) -.TP -R_IBEFORE -Insert the data immediately before the data referenced by -.IR key , -creating a new key/data pair. -The record number of the inserted key/data pair is returned in the -.I key -structure. -(Applicable only to the DB_RECNO access method.) -.TP -R_NOOVERWRITE -Enter the new key/data pair only if the key does not previously exist. -.TP -R_SETCURSOR -Store the key/data pair, setting or initializing the position of the -cursor to reference it. -(Applicable only to the DB_BTREE and DB_RECNO access methods.) -.RE -.IP -R_SETCURSOR is available only for the DB_BTREE and DB_RECNO access -methods because it implies that the keys have an inherent order -which does not change. -.IP -R_IAFTER and R_IBEFORE are available only for the DB_RECNO -access method because they each imply that the access method is able to -create new keys. -This is only true if the keys are ordered and independent, record numbers -for example. -.IP -The default behavior of the -.I put -routines is to enter the new key/data pair, replacing any previously -existing key. -.IP -.I Put -routines return -1 on error (setting -.IR errno ), -0 on success, and 1 if the R_NOOVERWRITE -.I flag -was set and the key already exists in the file. -.TP -seq -A pointer to a routine which is the interface for sequential -retrieval from the database. -The address and length of the key are returned in the structure -referenced by -.IR key , -and the address and length of the data are returned in the -structure referenced -by -.IR data . -.IP -Sequential key/data pair retrieval may begin at any time, and the -position of the ``cursor'' is not affected by calls to the -.IR del , -.IR get , -.IR put , -or -.I sync -routines. -Modifications to the database during a sequential scan will be reflected -in the scan, i.e. records inserted behind the cursor will not be returned -while records inserted in front of the cursor will be returned. -.IP -The flag value -.B must -be set to one of the following values: -.RS -.TP -R_CURSOR -The data associated with the specified key is returned. -This differs from the -.I get -routines in that it sets or initializes the cursor to the location of -the key as well. -(Note, for the DB_BTREE access method, the returned key is not necessarily an -exact match for the specified key. -The returned key is the smallest key greater than or equal to the specified -key, permitting partial key matches and range searches.) -.TP -R_FIRST -The first key/data pair of the database is returned, and the cursor -is set or initialized to reference it. -.TP -R_LAST -The last key/data pair of the database is returned, and the cursor -is set or initialized to reference it. -(Applicable only to the DB_BTREE and DB_RECNO access methods.) -.TP -R_NEXT -Retrieve the key/data pair immediately after the cursor. -If the cursor is not yet set, this is the same as the R_FIRST flag. -.TP -R_PREV -Retrieve the key/data pair immediately before the cursor. -If the cursor is not yet set, this is the same as the R_LAST flag. -(Applicable only to the DB_BTREE and DB_RECNO access methods.) -.RE -.IP -R_LAST and R_PREV are available only for the DB_BTREE and DB_RECNO -access methods because they each imply that the keys have an inherent -order which does not change. -.IP -.I Seq -routines return -1 on error (setting -.IR errno ), -0 on success and 1 if there are no key/data pairs less than or greater -than the specified or current key. -If the DB_RECNO access method is being used, and if the database file -is a character special file and no complete key/data pairs are currently -available, the -.I seq -routines return 2. -.TP -sync -A pointer to a routine to flush any cached information to disk. -If the database is in memory only, the -.I sync -routine has no effect and will always succeed. -.IP -The flag value may be set to the following value: -.RS -.TP -R_RECNOSYNC -If the DB_RECNO access method is being used, this flag causes -the sync routine to apply to the btree file which underlies the -recno file, not the recno file itself. -(See the -.I bfname -field of the -.IR recno (3) -manual page for more information.) -.RE -.IP -.I Sync -routines return -1 on error (setting -.IR errno ) -and 0 on success. -.SH "KEY/DATA PAIRS" -Access to all file types is based on key/data pairs. -Both keys and data are represented by the following data structure: -.PP -typedef struct { -.RS -void *data; -.br -size_t size; -.RE -} DBT; -.PP -The elements of the DBT structure are defined as follows: -.TP -data -A pointer to a byte string. -.TP -size -The length of the byte string. -.PP -Key and data byte strings may reference strings of essentially unlimited -length although any two of them must fit into available memory at the same -time. -It should be noted that the access methods provide no guarantees about -byte string alignment. -.SH ERRORS -The -.I dbopen -routine may fail and set -.I errno -for any of the errors specified for the library routines -.IR open (2) -and -.IR malloc (3) -or the following: -.TP -[EFTYPE] -A file is incorrectly formatted. -.TP -[EINVAL] -A parameter has been specified (hash function, pad byte etc.) that is -incompatible with the current file specification or which is not -meaningful for the function (for example, use of the cursor without -prior initialization) or there is a mismatch between the version -number of file and the software. -.PP -The -.I close -routines may fail and set -.I errno -for any of the errors specified for the library routines -.IR close (2), -.IR read (2), -.IR write (2), -.IR free (3), -or -.IR fsync (2). -.PP -The -.IR del , -.IR get , -.I put -and -.I seq -routines may fail and set -.I errno -for any of the errors specified for the library routines -.IR read (2), -.IR write (2), -.IR free (3) -or -.IR malloc (3). -.PP -The -.I fd -routines will fail and set -.I errno -to ENOENT for in memory databases. -.PP -The -.I sync -routines may fail and set -.I errno -for any of the errors specified for the library routine -.IR fsync (2). -.SH "SEE ALSO" -.IR btree (3), -.IR hash (3), -.IR mpool (3), -.IR recno (3) -.sp -.IR "LIBTP: Portable, Modular Transactions for UNIX" , -Margo Seltzer, Michael Olson, USENIX proceedings, Winter 1992. -.SH BUGS -The typedef DBT is a mnemonic for ``data base thang'', and was used -because noone could think of a reasonable name that wasn't already used. -.PP -The file descriptor interface is a kluge and will be deleted in a -future version of the interface. -.PP -None of the access methods provide any form of concurrent access, -locking, or transactions. diff --git a/lib/libc/db/man/hash.3 b/lib/libc/db/man/hash.3 deleted file mode 100644 index 54e02ca..0000000 --- a/lib/libc/db/man/hash.3 +++ /dev/null @@ -1,160 +0,0 @@ -.\" Copyright (c) 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. -.\" -.\" @(#)hash.3 8.6 (Berkeley) 8/18/94 -.\" $FreeBSD$ -.\" -.TH HASH 3 "August 18, 1994" -.UC 7 -.SH NAME -hash \- hash database access method -.SH SYNOPSIS -.nf -.ft B -#include -#include -.ft R -.fi -.SH DESCRIPTION -The routine -.IR dbopen -is the library interface to database files. -One of the supported file formats is hash files. -The general description of the database access methods is in -.IR dbopen (3), -this manual page describes only the hash specific information. -.PP -The hash data structure is an extensible, dynamic hashing scheme. -.PP -The access method specific data structure provided to -.I dbopen -is defined in the include file as follows: -.sp -typedef struct { -.RS -u_int bsize; -.br -u_int ffactor; -.br -u_int nelem; -.br -u_int cachesize; -.br -u_int32_t (*hash)(const void *, size_t); -.br -int lorder; -.RE -} HASHINFO; -.PP -The elements of this structure are as follows: -.TP -bsize -.I Bsize -defines the hash table bucket size, and is, by default, 256 bytes. -It may be preferable to increase the page size for disk-resident tables -and tables with large data items. -.TP -ffactor -.I Ffactor -indicates a desired density within the hash table. -It is an approximation of the number of keys allowed to accumulate in any -one bucket, determining when the hash table grows or shrinks. -The default value is 8. -.TP -nelem -.I Nelem -is an estimate of the final size of the hash table. -If not set or set too low, hash tables will expand gracefully as keys -are entered, although a slight performance degradation may be noticed. -The default value is 1. -.TP -cachesize -A suggested maximum size, in bytes, of the memory cache. -This value is -.B only -advisory, and the access method will allocate more memory rather -than fail. -.TP -hash -.I Hash -is a user defined hash function. -Since no hash function performs equally well on all possible data, the -user may find that the built-in hash function does poorly on a particular -data set. -User specified hash functions must take two arguments (a pointer to a byte -string and a length) and return a 32-bit quantity to be used as the hash -value. -.TP -lorder -The byte order for integers in the stored database metadata. -The number should represent the order as an integer; for example, -big endian order would be the number 4,321. -If -.I lorder -is 0 (no order is specified) the current host order is used. -If the file already exists, the specified value is ignored and the -value specified when the tree was created is used. -.PP -If the file already exists (and the O_TRUNC flag is not specified), the -values specified for the parameters bsize, ffactor, lorder and nelem are -ignored and the values specified when the tree was created are used. -.PP -If a hash function is specified, -.I hash_open -will attempt to determine if the hash function specified is the same as -the one with which the database was created, and will fail if it is not. -.PP -Backward compatible interfaces to the older -.I dbm -and -.I ndbm -routines are provided, however these interfaces are not compatible with -previous file formats. -.SH ERRORS -The -.I hash -access method routines may fail and set -.I errno -for any of the errors specified for the library routine -.IR dbopen (3). -.SH "SEE ALSO" -.IR btree (3), -.IR dbopen (3), -.IR mpool (3), -.IR recno (3) -.sp -.IR "Dynamic Hash Tables" , -Per-Ake Larson, Communications of the ACM, April 1988. -.sp -.IR "A New Hash Package for UNIX" , -Margo Seltzer, USENIX Proceedings, Winter 1991. -.SH BUGS -Only big and little endian byte order is supported. diff --git a/lib/libc/db/man/mpool.3 b/lib/libc/db/man/mpool.3 deleted file mode 100644 index 5174df6..0000000 --- a/lib/libc/db/man/mpool.3 +++ /dev/null @@ -1,220 +0,0 @@ -.\" Copyright (c) 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. -.\" -.\" @(#)mpool.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.TH MPOOL 3 "June 4, 1993" -.UC 7 -.SH NAME -mpool \- shared memory buffer pool -.SH SYNOPSIS -.nf -.ft B -#include -#include - -MPOOL * -mpool_open (DBT *key, int fd, pgno_t pagesize, pgno_t maxcache); - -void -mpool_filter (MPOOL *mp, void (*pgin)(void *, pgno_t, void *), -.ti +5 -void (*pgout)(void *, pgno_t, void *), void *pgcookie); - -void * -mpool_new (MPOOL *mp, pgno_t *pgnoaddr); - -void * -mpool_get (MPOOL *mp, pgno_t pgno, u_int flags); - -int -mpool_put (MPOOL *mp, void *pgaddr, u_int flags); - -int -mpool_sync (MPOOL *mp); - -int -mpool_close (MPOOL *mp); -.ft R -.fi -.SH DESCRIPTION -.IR Mpool -is the library interface intended to provide page oriented buffer management -of files. -The buffers may be shared between processes. -.PP -The function -.I mpool_open -initializes a memory pool. -The -.I key -argument is the byte string used to negotiate between multiple -processes wishing to share buffers. -If the file buffers are mapped in shared memory, all processes using -the same key will share the buffers. -If -.I key -is NULL, the buffers are mapped into private memory. -The -.I fd -argument is a file descriptor for the underlying file, which must be seekable. -If -.I key -is non-NULL and matches a file already being mapped, the -.I fd -argument is ignored. -.PP -The -.I pagesize -argument is the size, in bytes, of the pages into which the file is broken up. -The -.I maxcache -argument is the maximum number of pages from the underlying file to cache -at any one time. -This value is not relative to the number of processes which share a file's -buffers, but will be the largest value specified by any of the processes -sharing the file. -.PP -The -.I mpool_filter -function is intended to make transparent input and output processing of the -pages possible. -If the -.I pgin -function is specified, it is called each time a buffer is read into the memory -pool from the backing file. -If the -.I pgout -function is specified, it is called each time a buffer is written into the -backing file. -Both functions are called with the -.I pgcookie -pointer, the page number and a pointer to the page to being read or written. -.PP -The function -.I mpool_new -takes an MPOOL pointer and an address as arguments. -If a new page can be allocated, a pointer to the page is returned and -the page number is stored into the -.I pgnoaddr -address. -Otherwise, NULL is returned and errno is set. -.PP -The function -.I mpool_get -takes a MPOOL pointer and a page number as arguments. -If the page exists, a pointer to the page is returned. -Otherwise, NULL is returned and errno is set. -The flags parameter is not currently used. -.PP -The function -.I mpool_put -unpins the page referenced by -.IR pgaddr . -.I Pgaddr -must be an address previously returned by -.I mpool_get -or -.IR mpool_new . -The flag value is specified by -.IR or 'ing -any of the following values: -.TP -MPOOL_DIRTY -The page has been modified and needs to be written to the backing file. -.PP -.I Mpool_put -returns 0 on success and -1 if an error occurs. -.PP -The function -.I mpool_sync -writes all modified pages associated with the MPOOL pointer to the -backing file. -.I Mpool_sync -returns 0 on success and -1 if an error occurs. -.PP -The -.I mpool_close -function free's up any allocated memory associated with the memory pool -cookie. -Modified pages are -.B not -written to the backing file. -.I Mpool_close -returns 0 on success and -1 if an error occurs. -.SH ERRORS -The -.I mpool_open -function may fail and set -.I errno -for any of the errors specified for the library routine -.IR malloc (3). -.PP -The -.I mpool_get -function may fail and set -.I errno -for the following: -.TP 15 -[EINVAL] -The requested record doesn't exist. -.PP -The -.I mpool_new -and -.I mpool_get -functions may fail and set -.I errno -for any of the errors specified for the library routines -.IR read (2) , -.IR write (2) , -and -.IR malloc (3). -.PP -The -.I mpool_sync -function may fail and set -.I errno -for any of the errors specified for the library routine -.IR write (2). -.PP -The -.I mpool_close -function may fail and set -.I errno -for any of the errors specified for the library routine -.IR free (3). -.SH "SEE ALSO" -.IR dbopen (3), -.IR btree (3), -.IR hash (3), -.IR recno (3) diff --git a/lib/libc/db/man/recno.3 b/lib/libc/db/man/recno.3 deleted file mode 100644 index 84b7e25..0000000 --- a/lib/libc/db/man/recno.3 +++ /dev/null @@ -1,217 +0,0 @@ -.\" Copyright (c) 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. -.\" -.\" @(#)recno.3 8.5 (Berkeley) 8/18/94 -.\" $FreeBSD$ -.\" -.TH RECNO 3 "August 18, 1994" -.UC 7 -.SH NAME -recno \- record number database access method -.SH SYNOPSIS -.nf -.ft B -#include -#include -.ft R -.fi -.SH DESCRIPTION -The routine -.IR dbopen -is the library interface to database files. -One of the supported file formats is record number files. -The general description of the database access methods is in -.IR dbopen (3), -this manual page describes only the recno specific information. -.PP -The record number data structure is either variable or fixed-length -records stored in a flat-file format, accessed by the logical record -number. -The existence of record number five implies the existence of records -one through four, and the deletion of record number one causes -record number five to be renumbered to record number four, as well -as the cursor, if positioned after record number one, to shift down -one record. -.PP -The recno access method specific data structure provided to -.I dbopen -is defined in the include file as follows: -.PP -typedef struct { -.RS -u_long flags; -.br -u_int cachesize; -.br -u_int psize; -.br -int lorder; -.br -size_t reclen; -.br -u_char bval; -.br -char *bfname; -.RE -} RECNOINFO; -.PP -The elements of this structure are defined as follows: -.TP -flags -The flag value is specified by -.IR or 'ing -any of the following values: -.RS -.TP -R_FIXEDLEN -The records are fixed-length, not byte delimited. -The structure element -.I reclen -specifies the length of the record, and the structure element -.I bval -is used as the pad character. -Any records, inserted into the database, that are less than -.I reclen -bytes long are automatically padded. -.TP -R_NOKEY -In the interface specified by -.IR dbopen , -the sequential record retrieval fills in both the caller's key and -data structures. -If the R_NOKEY flag is specified, the -.I cursor -routines are not required to fill in the key structure. -This permits applications to retrieve records at the end of files without -reading all of the intervening records. -.TP -R_SNAPSHOT -This flag requires that a snapshot of the file be taken when -.I dbopen -is called, instead of permitting any unmodified records to be read from -the original file. -.RE -.TP -cachesize -A suggested maximum size, in bytes, of the memory cache. -This value is -.B only -advisory, and the access method will allocate more memory rather than fail. -If -.I cachesize -is 0 (no size is specified) a default cache is used. -.TP -psize -The recno access method stores the in-memory copies of its records -in a btree. -This value is the size (in bytes) of the pages used for nodes in that tree. -If -.I psize -is 0 (no page size is specified) a page size is chosen based on the -underlying file system I/O block size. -See -.IR btree (3) -for more information. -.TP -lorder -The byte order for integers in the stored database metadata. -The number should represent the order as an integer; for example, -big endian order would be the number 4,321. -If -.I lorder -is 0 (no order is specified) the current host order is used. -.TP -reclen -The length of a fixed-length record. -.TP -bval -The delimiting byte to be used to mark the end of a record for -variable-length records, and the pad character for fixed-length -records. -If no value is specified, newlines (``\en'') are used to mark the end -of variable-length records and fixed-length records are padded with -spaces. -.TP -bfname -The recno access method stores the in-memory copies of its records -in a btree. -If bfname is non-NULL, it specifies the name of the btree file, -as if specified as the file name for a dbopen of a btree file. -.PP -The data part of the key/data pair used by the recno access method -is the same as other access methods. -The key is different. -The -.I data -field of the key should be a pointer to a memory location of type -.IR recno_t , -as defined in the include file. -This type is normally the largest unsigned integral type available to -the implementation. -The -.I size -field of the key should be the size of that type. -.PP -Because there can be no meta-data associated with the underlying -recno access method files, any changes made to the default values -(e.g. fixed record length or byte separator value) must be explicitly -specified each time the file is opened. -.PP -In the interface specified by -.IR dbopen , -using the -.I put -interface to create a new record will cause the creation of multiple, -empty records if the record number is more than one greater than the -largest record currently in the database. -.SH ERRORS -The -.I recno -access method routines may fail and set -.I errno -for any of the errors specified for the library routine -.IR dbopen (3) -or the following: -.TP -[EINVAL] -An attempt was made to add a record to a fixed-length database that -was too large to fit. -.SH "SEE ALSO" -.IR btree (3), -.IR dbopen (3), -.IR hash (3), -.IR mpool (3) -.sp -.IR "Document Processing in a Relational Database System" , -Michael Stonebraker, Heidi Stettner, Joseph Kalash, Antonin Guttman, -Nadene Lynn, Memorandum No. UCB/ERL M82/32, May 1982. -.SH BUGS -Only big and little endian byte order is supported. diff --git a/lib/libc/db/mpool/Makefile.inc b/lib/libc/db/mpool/Makefile.inc deleted file mode 100644 index 461e62a..0000000 --- a/lib/libc/db/mpool/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 -# $FreeBSD$ - -.PATH: ${.CURDIR}/../libc/db/mpool - -SRCS+= mpool.c diff --git a/lib/libc/db/mpool/README b/lib/libc/db/mpool/README deleted file mode 100644 index 0f01fbc..0000000 --- a/lib/libc/db/mpool/README +++ /dev/null @@ -1,7 +0,0 @@ -# @(#)README 8.1 (Berkeley) 6/4/93 - -These are the current memory pool routines. -They aren't ready for prime time, yet, and -the interface is expected to change. - ---keith diff --git a/lib/libc/db/mpool/mpool.c b/lib/libc/db/mpool/mpool.c deleted file mode 100644 index 29377d3..0000000 --- a/lib/libc/db/mpool/mpool.c +++ /dev/null @@ -1,465 +0,0 @@ -/*- - * Copyright (c) 1990, 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)mpool.c 8.5 (Berkeley) 7/26/94"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#define __MPOOLINTERFACE_PRIVATE -#include - -static BKT *mpool_bkt __P((MPOOL *)); -static BKT *mpool_look __P((MPOOL *, pgno_t)); -static int mpool_write __P((MPOOL *, BKT *)); - -/* - * mpool_open -- - * Initialize a memory pool. - */ -MPOOL * -mpool_open(key, fd, pagesize, maxcache) - void *key; - int fd; - pgno_t pagesize, maxcache; -{ - struct stat sb; - MPOOL *mp; - int entry; - - /* - * Get information about the file. - * - * XXX - * We don't currently handle pipes, although we should. - */ - if (fstat(fd, &sb)) - return (NULL); - if (!S_ISREG(sb.st_mode)) { - errno = ESPIPE; - return (NULL); - } - - /* Allocate and initialize the MPOOL cookie. */ - if ((mp = (MPOOL *)calloc(1, sizeof(MPOOL))) == NULL) - return (NULL); - CIRCLEQ_INIT(&mp->lqh); - for (entry = 0; entry < HASHSIZE; ++entry) - CIRCLEQ_INIT(&mp->hqh[entry]); - mp->maxcache = maxcache; - mp->npages = sb.st_size / pagesize; - mp->pagesize = pagesize; - mp->fd = fd; - return (mp); -} - -/* - * mpool_filter -- - * Initialize input/output filters. - */ -void -mpool_filter(mp, pgin, pgout, pgcookie) - MPOOL *mp; - void (*pgin) __P((void *, pgno_t, void *)); - void (*pgout) __P((void *, pgno_t, void *)); - void *pgcookie; -{ - mp->pgin = pgin; - mp->pgout = pgout; - mp->pgcookie = pgcookie; -} - -/* - * mpool_new -- - * Get a new page of memory. - */ -void * -mpool_new(mp, pgnoaddr) - MPOOL *mp; - pgno_t *pgnoaddr; -{ - struct _hqh *head; - BKT *bp; - - if (mp->npages == MAX_PAGE_NUMBER) { - (void)fprintf(stderr, "mpool_new: page allocation overflow.\n"); - abort(); - } -#ifdef STATISTICS - ++mp->pagenew; -#endif - /* - * Get a BKT from the cache. Assign a new page number, attach - * it to the head of the hash chain, the tail of the lru chain, - * and return. - */ - if ((bp = mpool_bkt(mp)) == NULL) - return (NULL); - *pgnoaddr = bp->pgno = mp->npages++; - bp->flags = MPOOL_PINNED; - - head = &mp->hqh[HASHKEY(bp->pgno)]; - CIRCLEQ_INSERT_HEAD(head, bp, hq); - CIRCLEQ_INSERT_TAIL(&mp->lqh, bp, q); - return (bp->page); -} - -/* - * mpool_get - * Get a page. - */ -void * -mpool_get(mp, pgno, flags) - MPOOL *mp; - pgno_t pgno; - u_int flags; /* XXX not used? */ -{ - struct _hqh *head; - BKT *bp; - off_t off; - int nr; - - /* Check for attempt to retrieve a non-existent page. */ - if (pgno >= mp->npages) { - errno = EINVAL; - return (NULL); - } - -#ifdef STATISTICS - ++mp->pageget; -#endif - - /* Check for a page that is cached. */ - if ((bp = mpool_look(mp, pgno)) != NULL) { -#ifdef DEBUG - if (bp->flags & MPOOL_PINNED) { - (void)fprintf(stderr, - "mpool_get: page %d already pinned\n", bp->pgno); - abort(); - } -#endif - /* - * Move the page to the head of the hash chain and the tail - * of the lru chain. - */ - head = &mp->hqh[HASHKEY(bp->pgno)]; - CIRCLEQ_REMOVE(head, bp, hq); - CIRCLEQ_INSERT_HEAD(head, bp, hq); - CIRCLEQ_REMOVE(&mp->lqh, bp, q); - CIRCLEQ_INSERT_TAIL(&mp->lqh, bp, q); - - /* Return a pinned page. */ - bp->flags |= MPOOL_PINNED; - return (bp->page); - } - - /* Get a page from the cache. */ - if ((bp = mpool_bkt(mp)) == NULL) - return (NULL); - - /* Read in the contents. */ -#ifdef STATISTICS - ++mp->pageread; -#endif - off = mp->pagesize * pgno; - if (lseek(mp->fd, off, SEEK_SET) != off) - return (NULL); - if ((nr = _read(mp->fd, bp->page, mp->pagesize)) != mp->pagesize) { - if (nr >= 0) - errno = EFTYPE; - return (NULL); - } - - /* Set the page number, pin the page. */ - bp->pgno = pgno; - bp->flags = MPOOL_PINNED; - - /* - * Add the page to the head of the hash chain and the tail - * of the lru chain. - */ - head = &mp->hqh[HASHKEY(bp->pgno)]; - CIRCLEQ_INSERT_HEAD(head, bp, hq); - CIRCLEQ_INSERT_TAIL(&mp->lqh, bp, q); - - /* Run through the user's filter. */ - if (mp->pgin != NULL) - (mp->pgin)(mp->pgcookie, bp->pgno, bp->page); - - return (bp->page); -} - -/* - * mpool_put - * Return a page. - */ -int -mpool_put(mp, page, flags) - MPOOL *mp; - void *page; - u_int flags; -{ - BKT *bp; - -#ifdef STATISTICS - ++mp->pageput; -#endif - bp = (BKT *)((char *)page - sizeof(BKT)); -#ifdef DEBUG - if (!(bp->flags & MPOOL_PINNED)) { - (void)fprintf(stderr, - "mpool_put: page %d not pinned\n", bp->pgno); - abort(); - } -#endif - bp->flags &= ~MPOOL_PINNED; - bp->flags |= flags & MPOOL_DIRTY; - return (RET_SUCCESS); -} - -/* - * mpool_close - * Close the buffer pool. - */ -int -mpool_close(mp) - MPOOL *mp; -{ - BKT *bp; - - /* Free up any space allocated to the lru pages. */ - while ((bp = mp->lqh.cqh_first) != (void *)&mp->lqh) { - CIRCLEQ_REMOVE(&mp->lqh, mp->lqh.cqh_first, q); - free(bp); - } - - /* Free the MPOOL cookie. */ - free(mp); - return (RET_SUCCESS); -} - -/* - * mpool_sync - * Sync the pool to disk. - */ -int -mpool_sync(mp) - MPOOL *mp; -{ - BKT *bp; - - /* Walk the lru chain, flushing any dirty pages to disk. */ - for (bp = mp->lqh.cqh_first; - bp != (void *)&mp->lqh; bp = bp->q.cqe_next) - if (bp->flags & MPOOL_DIRTY && - mpool_write(mp, bp) == RET_ERROR) - return (RET_ERROR); - - /* Sync the file descriptor. */ - return (_fsync(mp->fd) ? RET_ERROR : RET_SUCCESS); -} - -/* - * mpool_bkt - * Get a page from the cache (or create one). - */ -static BKT * -mpool_bkt(mp) - MPOOL *mp; -{ - struct _hqh *head; - BKT *bp; - - /* If under the max cached, always create a new page. */ - if (mp->curcache < mp->maxcache) - goto new; - - /* - * If the cache is max'd out, walk the lru list for a buffer we - * can flush. If we find one, write it (if necessary) and take it - * off any lists. If we don't find anything we grow the cache anyway. - * The cache never shrinks. - */ - for (bp = mp->lqh.cqh_first; - bp != (void *)&mp->lqh; bp = bp->q.cqe_next) - if (!(bp->flags & MPOOL_PINNED)) { - /* Flush if dirty. */ - if (bp->flags & MPOOL_DIRTY && - mpool_write(mp, bp) == RET_ERROR) - return (NULL); -#ifdef STATISTICS - ++mp->pageflush; -#endif - /* Remove from the hash and lru queues. */ - head = &mp->hqh[HASHKEY(bp->pgno)]; - CIRCLEQ_REMOVE(head, bp, hq); - CIRCLEQ_REMOVE(&mp->lqh, bp, q); -#ifdef DEBUG - { void *spage; - spage = bp->page; - memset(bp, 0xff, sizeof(BKT) + mp->pagesize); - bp->page = spage; - } -#endif - return (bp); - } - -new: if ((bp = (BKT *)malloc(sizeof(BKT) + mp->pagesize)) == NULL) - return (NULL); -#ifdef STATISTICS - ++mp->pagealloc; -#endif -#if defined(DEBUG) || defined(PURIFY) - memset(bp, 0xff, sizeof(BKT) + mp->pagesize); -#endif - bp->page = (char *)bp + sizeof(BKT); - ++mp->curcache; - return (bp); -} - -/* - * mpool_write - * Write a page to disk. - */ -static int -mpool_write(mp, bp) - MPOOL *mp; - BKT *bp; -{ - off_t off; - -#ifdef STATISTICS - ++mp->pagewrite; -#endif - - /* Run through the user's filter. */ - if (mp->pgout) - (mp->pgout)(mp->pgcookie, bp->pgno, bp->page); - - off = mp->pagesize * bp->pgno; - if (lseek(mp->fd, off, SEEK_SET) != off) - return (RET_ERROR); - if (_write(mp->fd, bp->page, mp->pagesize) != mp->pagesize) - return (RET_ERROR); - - bp->flags &= ~MPOOL_DIRTY; - return (RET_SUCCESS); -} - -/* - * mpool_look - * Lookup a page in the cache. - */ -static BKT * -mpool_look(mp, pgno) - MPOOL *mp; - pgno_t pgno; -{ - struct _hqh *head; - BKT *bp; - - head = &mp->hqh[HASHKEY(pgno)]; - for (bp = head->cqh_first; bp != (void *)head; bp = bp->hq.cqe_next) - if (bp->pgno == pgno) { -#ifdef STATISTICS - ++mp->cachehit; -#endif - return (bp); - } -#ifdef STATISTICS - ++mp->cachemiss; -#endif - return (NULL); -} - -#ifdef STATISTICS -/* - * mpool_stat - * Print out cache statistics. - */ -void -mpool_stat(mp) - MPOOL *mp; -{ - BKT *bp; - int cnt; - char *sep; - - (void)fprintf(stderr, "%lu pages in the file\n", mp->npages); - (void)fprintf(stderr, - "page size %lu, cacheing %lu pages of %lu page max cache\n", - mp->pagesize, mp->curcache, mp->maxcache); - (void)fprintf(stderr, "%lu page puts, %lu page gets, %lu page new\n", - mp->pageput, mp->pageget, mp->pagenew); - (void)fprintf(stderr, "%lu page allocs, %lu page flushes\n", - mp->pagealloc, mp->pageflush); - if (mp->cachehit + mp->cachemiss) - (void)fprintf(stderr, - "%.0f%% cache hit rate (%lu hits, %lu misses)\n", - ((double)mp->cachehit / (mp->cachehit + mp->cachemiss)) - * 100, mp->cachehit, mp->cachemiss); - (void)fprintf(stderr, "%lu page reads, %lu page writes\n", - mp->pageread, mp->pagewrite); - - sep = ""; - cnt = 0; - for (bp = mp->lqh.cqh_first; - bp != (void *)&mp->lqh; bp = bp->q.cqe_next) { - (void)fprintf(stderr, "%s%d", sep, bp->pgno); - if (bp->flags & MPOOL_DIRTY) - (void)fprintf(stderr, "d"); - if (bp->flags & MPOOL_PINNED) - (void)fprintf(stderr, "P"); - if (++cnt == 10) { - sep = "\n"; - cnt = 0; - } else - sep = ", "; - - } - (void)fprintf(stderr, "\n"); -} -#endif diff --git a/lib/libc/db/mpool/mpool.libtp b/lib/libc/db/mpool/mpool.libtp deleted file mode 100644 index bcd827d..0000000 --- a/lib/libc/db/mpool/mpool.libtp +++ /dev/null @@ -1,746 +0,0 @@ -/****************************************************************************** - -VERSION $FreeBSD$ -PACKAGE: User Level Shared Memory Manager - -DESCRIPTION: - This package provides a buffer pool interface implemented as - a collection of file pages mapped into shared memory. - - Based on Mark's buffer manager - -ROUTINES: - External - buf_alloc - buf_flags - buf_get - buf_init - buf_last - buf_open - buf_pin - buf_sync - buf_unpin - Internal - bf_assign_buf - bf_fid_to_fd - bf_newbuf - bf_put_page - - -******************************************************************************/ -#include -#include -#include -#include -#include -#include -#include "list.h" -#include "user.h" -#include "txn_sys.h" -#include "buf.h" -#include "semkeys.h" -#include "error.h" - -/* - we need to translate between some type of file id that the user - process passes and a file descriptor. For now, it's a nop. -*/ -#define GET_MASTER get_sem ( buf_spinlock ) -#define RELEASE_MASTER release_sem ( buf_spinlock ) - -#define LRUID *buf_lru -#define LRUP (bufhdr_table+*buf_lru) -#define MRU bufhdr_table[*buf_lru].lru.prev - -/* Global indicator that you have started reusing buffers */ -int do_statistics = 0; -/* - Process Statics (pointers into shared memory) -*/ -static BUF_T *buf_table = 0; -static BUFHDR_T *bufhdr_table; -static int *buf_hash_table; -static int *buf_lru; /* LRU is the free list */ -static int buf_spinlock; -static FINFO_T *buf_fids; -static int *buf_sp; /* Pointer to string free space */ -static char *buf_strings; - -/* Process Local FID->FD table */ -static int fds[NUM_FILE_ENTRIES]; - -/* Static routines */ -static BUFHDR_T *bf_assign_buf(); -static int bf_fid_to_fd(); -static BUFHDR_T *bf_newbuf(); -static int bf_put_page(); - -/* - Return 0 on success - 1 on failure -*/ -extern int -buf_init ( ) -{ - ADDR_T buf_region; - BUFHDR_T *bhp; - int i; - int ref_count; - int *spinlockp; - - /* - Initialize Process local structures - */ - for ( i = 0; i < NUM_FILE_ENTRIES; i++ ) { - fds[i] = -1; - } - - buf_region = attach_region ( BUF_REGION_NAME, BUF_REGION_NUM, - BUF_REGION_SIZE, &ref_count ); - if ( !buf_region ) { - return (1); - } - error_log3 ( "Buf Region: ADDR: %d ID: %d SIZE: %d\n", buf_region, - BUF_REGION_NUM, BUF_REGION_SIZE ); - - buf_table = (BUF_T *)buf_region; - bufhdr_table = (BUFHDR_T *)(buf_table + NUM_BUFS); - buf_hash_table = (int *)(bufhdr_table + NUM_BUFS); - buf_lru = buf_hash_table + NUMTABLE_ENTRIES; - spinlockp = buf_lru + 1; - buf_fids = (FINFO_T *)(spinlockp+1); - buf_sp = (int *)(buf_fids + NUM_FILE_ENTRIES); - buf_strings = (char *)(buf_sp + 1); - - /* Create locking spinlock (gets creating holding the lock) */ - buf_spinlock = create_sem ( BUF_SPIN_NAME, BUF_SPIN_NUM, ref_count <= 1 ); - if ( buf_spinlock < 0 ) { - return(1); - } - if ( ref_count <= 1 ) { - *spinlockp = buf_spinlock; - - /* Now initialize the buffer manager */ - - /* 1. Free list */ - *buf_lru = 0; - - /* 2. Buffer headers */ - for ( i = 0, bhp = bufhdr_table; i < NUM_BUFS; bhp++, i++ ) { - bhp->lru.next = i+1; - bhp->lru.prev = i-1; - bhp->flags = 0; /* All Flags off */ - bhp->refcount = 0; - bhp->wait_proc = -1; /* No sleepers */ - LISTPE_INIT ( hash, bhp, i ); /* Hash chains */ - } - bufhdr_table[0].lru.prev = NUM_BUFS-1; - bufhdr_table[NUM_BUFS-1].lru.next = 0; - - /* 3. Hash Table */ - for ( i = 0; i < NUMTABLE_ENTRIES; i++ ) { - buf_hash_table[i] = NUM_BUFS; - } - - /* 4. File ID Table */ - for ( i = 0; i < NUM_FILE_ENTRIES; i++ ) { - buf_fids[i].offset = -1; - buf_fids[i].npages = -1; - buf_fids[i].refcount = 0; - } - - /* 5. Free String Pointer */ - *buf_sp = (FILE_NAME_LEN*NUM_FILE_ENTRIES); - if (RELEASE_MASTER) { - return(1); - } - error_log0 ( "Initialized buffer region\n" ); - } - return (0); -} - -extern void -buf_exit() -{ - int ref; - int i; - - /* Flush Buffer Pool on Exit */ - for ( i = 0; i < NUM_FILE_ENTRIES; i++ ) { - if ( fds[i] != -1 ) { - close ( fds[i] ); - } - } - if ( buf_table ) { - detach_region ( buf_table, BUF_REGION_NUM, BUF_REGION_SIZE, &ref ); - } - return; -} - -/* - We need an empty buffer. Find the LRU unpinned NON-Dirty page. -*/ -static BUFHDR_T * -bf_newbuf() -{ - int fd; - int lruid; - int nbytes; - int ndx; - BUFHDR_T *bhp; - - lruid = LRUID; - for ( bhp = LRUP; - bhp->flags & (BUF_PINNED|BUF_IO_IN_PROGRESS); - bhp = LISTP_NEXTP (bufhdr_table, lru, bhp ) ) { - - if ( bhp->lru.next == lruid ) { - /* OUT OF BUFFERS */ - error_log1 ( "All buffers are pinned. %s\n", - "Unable to grant buffer request" ); - return(NULL); - } - } - /* BHP can be used */ - if ( bhp->flags & BUF_DIRTY ) { - do_statistics = 1; - /* - MIS Check for log flushed appropriately - */ - fd = bf_fid_to_fd(bhp->id.file_id); - if ( fd == -1 ) { - error_log1 ("Invalid fid %d\n", bhp->id.file_id); - return(NULL); - } - if ( bf_put_page(fd, bhp) < 0 ) { - return(NULL); - } - } - /* Update Hash Pointers */ - ndx = BUF_HASH ( bhp->id.file_id, bhp->id.obj_id ); - LISTP_REMOVE(bufhdr_table, hash, bhp); - if ( buf_hash_table[ndx] == (bhp-bufhdr_table) ) { - if ( bhp->hash.next != (bhp-bufhdr_table) ) { - buf_hash_table[ndx] = bhp->hash.next; - } else { - buf_hash_table[ndx] = NUM_BUFS; - } - } - INIT_BUF(bhp); - - return(bhp); -} -/* - buf_alloc - - Add a page to a file and return a buffer for it. - -*/ -ADDR_T -buf_alloc ( fid, new_pageno ) -int fid; -int *new_pageno; -{ - BUFHDR_T *bhp; - int fd; - int len; - int ndx; - OBJ_T fobj; - - if (GET_MASTER) { - return(NULL); - } - if ( buf_fids[fid].npages == -1 ) { - /* initialize npages field */ - fd = bf_fid_to_fd ( fid ); - } - assert (fid < NUM_FILE_ENTRIES); - - *new_pageno = buf_fids[fid].npages; - if ( *new_pageno == -1 ) { - RELEASE_MASTER; - return ( NULL ); - } - buf_fids[fid].npages++; - ndx = BUF_HASH ( fid, *new_pageno ); - fobj.file_id = fid; - fobj.obj_id = *new_pageno; - bhp = bf_assign_buf ( ndx, &fobj, BF_PIN|BF_DIRTY|BF_EMPTY, &len ); - if ( RELEASE_MASTER ) { - /* Memory leak */ - return(NULL); - } - if ( bhp ) { - return ((ADDR_T)(buf_table+(bhp-bufhdr_table))); - } else { - return ( NULL ); - } -} - - -/* - Buffer Flags - BF_DIRTY Mark page as dirty - BF_EMPTY Don't initialize page, just get buffer - BF_PIN Retrieve with pin - -MIS -Might want to add a flag that sets an LSN for this buffer is the -DIRTY flag is set - -Eventually, you may want a flag that indicates the I/O and lock -request should be shipped off together, but not for now. -*/ -extern ADDR_T -buf_get ( file_id, page_id, flags, len ) -int file_id; -int page_id; -u_long flags; -int *len; /* Number of bytes read into buffer */ -{ - BUFHDR_T *bhp; - int bufid; - int fd; - int ndx; - int next_bufid; - int stat; - OBJ_T fobj; - - ndx = BUF_HASH ( file_id, page_id ); - fobj.file_id = (long) file_id; - fobj.obj_id = (long) page_id; - if ( GET_MASTER ) { - return(NULL); - } - /* - This could be a for loop, but we lose speed - by making all the cases general purpose so we - optimize for the no-collision case. - */ - bufid = buf_hash_table[ndx]; - if ( bufid < NUM_BUFS ) { - for ( bhp = bufhdr_table+bufid; - !OBJ_EQ (bhp->id, fobj) || !(bhp->flags & BUF_VALID); - bhp = LISTP_NEXTP ( bufhdr_table, hash, bhp ) ) { - - if ( bhp->hash.next == bufid ) { - goto not_found; - } - } -/* found */ - if ( flags & BF_PIN ) { - bhp->flags |= BUF_PINNED; - bhp->refcount++; -#ifdef PIN_DEBUG - fprintf(stderr, "buf_get: %X PINNED (%d)\n", - buf_table + (bhp-bufhdr_table), bhp->refcount); -#endif - } - if ( flags & BF_DIRTY ) { - bhp->flags |= BUF_DIRTY; - } - - while ( bhp->flags & BUF_IO_IN_PROGRESS ) { - /* MIS -- eventually err check here */ -#ifdef DEBUG - printf("About to sleep on %d (me: %d\n)\n", bhp->wait_proc, - my_txnp - txn_table); -#endif -#ifdef WAIT_STATS - buf_waits++; -#endif - stat = proc_sleep_on ( &(bhp->wait_proc), buf_spinlock ); - if ( stat ) { - /* Memory leak */ - return(NULL); - } - if (!( bhp->flags & BUF_IO_IN_PROGRESS) && - (!OBJ_EQ (bhp->id, fobj) || !(bhp->flags & BUF_VALID))) { - if (RELEASE_MASTER) - return(NULL); - return(buf_get ( file_id, page_id, flags, len )); - } - } - MAKE_MRU( bhp ); - *len = BUFSIZE; - } else { -not_found: - /* If you get here, the page isn't in the hash table */ - bhp = bf_assign_buf ( ndx, &fobj, flags, len ); - } - /* Common code between found and not found */ - - if ( bhp && bhp->flags & BUF_NEWPAGE ) { - *len = 0; - } - if (RELEASE_MASTER){ - /* Memory leak */ - return(NULL); - } - if ( bhp ) { - return ((ADDR_T)(buf_table+(bhp-bufhdr_table))); - } else { - return ( NULL ); - } -} - -/* - MIS - do I want to add file links to buffer pool? -*/ -extern int -buf_sync ( fid, close ) -int fid; -int close; /* should we dec refcount and possibly - invalidate all the buffers */ -{ - int i; - int fd; - int invalidate; - BUFHDR_T *bhp; - - if ( (fd = bf_fid_to_fd ( fid )) < 0 ) { - return(1); - } - if (GET_MASTER) { - return(1); - } - invalidate = (buf_fids[fid].refcount == 1 && close); - if ( invalidate ) - for ( bhp = bufhdr_table, i = 0; i < NUM_BUFS; bhp++, i++ ) { - if (bhp->id.file_id == fid) { - if ((bhp->flags & BF_DIRTY) && (bf_put_page( fd, bhp ) < 0)) { - return(1); - } - bhp->id.file_id = -1; - } - } - if (invalidate || close) - buf_fids[fid].refcount--; - - if (RELEASE_MASTER) { - return(1); - } - return(0); - - -} - -extern int -buf_flags ( addr, set_flags, unset_flags ) -ADDR_T addr; -u_long set_flags; -u_long unset_flags; -{ - int bufid; - BUFHDR_T *bhp; - -#ifdef PIN_DEBUG - fprintf(stderr, "buf_flags: %X setting %s%s%s%s%s releasing %s%s%s%s%s\n", - addr, - set_flags&BUF_DIRTY ? "DIRTY " : "", - set_flags&BUF_VALID ? "VALID " : "", - set_flags&BUF_PINNED ? "PINNED " : "", - set_flags&BUF_IO_ERROR ? "IO_ERROR " : "", - set_flags&BUF_IO_IN_PROGRESS ? "IO_IN_PROG " : "", - set_flags&BUF_NEWPAGE ? "NEWPAGE " : "", - unset_flags&BUF_DIRTY ? "DIRTY " : "", - unset_flags&BUF_VALID ? "VALID " : "", - unset_flags&BUF_PINNED ? "PINNED " : "", - unset_flags&BUF_IO_ERROR ? "IO_ERROR " : "", - unset_flags&BUF_IO_IN_PROGRESS ? "IO_IN_PROG " : "", - unset_flags&BUF_NEWPAGE ? "NEWPAGE " : "" ); -#endif - if (!ADDR_OK(addr)) { - error_log1 ( "buf_pin: Invalid Buffer Address %x\n", addr ); - return(1); - } - bufid = ((BUF_T *)addr) - buf_table; - assert ( bufid < NUM_BUFS); - bhp = &bufhdr_table[bufid]; - if (GET_MASTER) { - return(1); - } - bhp->flags |= set_flags; - if ( set_flags & BUF_PINNED ) { - bhp->refcount++; - } - if ( set_flags & BUF_DIRTY ) { - unset_flags |= BUF_NEWPAGE; - } - - if ( unset_flags & BUF_PINNED ) { - bhp->refcount--; - if ( bhp->refcount ) { - /* Turn off pin bit so it doesn't get unset */ - unset_flags &= ~BUF_PINNED; - } - } - bhp->flags &= ~unset_flags; - MAKE_MRU(bhp); - if (RELEASE_MASTER) { - return(1); - } - return(0); -} - -/* - Take a string name and produce an fid. - - returns -1 on error - - MIS -- this is a potential problem -- you keep actual names - here -- what if people run from different directories? -*/ -extern int -buf_name_lookup ( fname ) -char *fname; -{ - int i; - int fid; - int ndx; - - fid = -1; - if (GET_MASTER) { - return(-1); - } - for ( i = 0; i < NUM_FILE_ENTRIES; i++ ) { - if ( buf_fids[i].offset == -1 ) { - fid = i; - } else { - if (!strcmp (fname, buf_strings+buf_fids[i].offset)) { - if (RELEASE_MASTER) { - return(-1); - } - buf_fids[i].refcount++; - return(i); - } - } - } - if ( fid == -1 ) { - error_log0 ( "No more file ID's\n" ); - } else { - ndx = *buf_sp - strlen(fname) - 1; - if ( ndx < 0 ) { - error_log0 ( "Out of string space\n" ); - fid = -1; - } else { - *buf_sp = ndx; - strcpy ( buf_strings+ndx, fname ); - buf_fids[fid].offset = ndx; - } - buf_fids[fid].refcount = 1; - } - if (RELEASE_MASTER) { - return(-1); - } - return(fid); -} - -static int -bf_fid_to_fd ( fid ) -int fid; -{ - struct stat sbuf; - - assert ( (fid < NUM_FILE_ENTRIES) && (buf_fids[fid].offset != -1) ); - if ( fds[fid] != -1 ) { - return(fds[fid]); - - } - fds[fid] = open ( buf_strings+buf_fids[fid].offset, O_RDWR|O_CREAT, - 0666 ); - if ( fds[fid] < 0 ) { - error_log3 ( "Error Opening File %s FID: %d FD: %d. Errno = %d\n", - buf_strings+buf_fids[fid].offset, fid, fds[fid], - errno ); - return(-1); - } - error_log3 ( "Opening File %s FID: %d FD: %d\n", - buf_strings+buf_fids[fid].offset, fid, fds[fid] ); - if ( buf_fids[fid].npages == -1 ) { - /* Initialize the npages field */ - if ( fstat ( fds[fid], &sbuf ) ) { - error_log3 ( "Error Fstating %s FID: %d. Errno = %d\n", - buf_strings+buf_fids[fid].offset, fid, errno ); - } else { - buf_fids[fid].npages = ( sbuf.st_size / BUFSIZE ); - } - } - - return ( fds[fid] ); -} - -static int -bf_put_page ( fd, bhp ) -int fd; -BUFHDR_T *bhp; -{ - int nbytes; - - assert ( (bhp-bufhdr_table) < NUM_BUFS ); - if ( lseek ( fd, bhp->id.obj_id << BUFSHIFT, L_SET ) < 0 ) { - return(-1); - } - bhp->flags |= BUF_IO_IN_PROGRESS; - if (RELEASE_MASTER) { - return(-1); - } - nbytes = write(fd, buf_table[bhp-bufhdr_table], BUFSIZE); - if (GET_MASTER) { - return(-2); - } - if ( nbytes < 0 ) { - error_log1 ("Write failed with error code %d\n", errno); - return(-1); - } else if ( nbytes != BUFSIZE ) { - error_log1 ("Short write: %d bytes of %d\n", nbytes, BUFSIZE ); - } - bhp->flags &= ~(BUF_DIRTY|BUF_IO_IN_PROGRESS); - return (0); -} - -static BUFHDR_T * -bf_assign_buf ( ndx, obj, flags, len ) -int ndx; -OBJ_T *obj; -u_long flags; -int *len; /* Number of bytes read */ -{ - BUFHDR_T *bhp; - int fd; - - assert ( obj->file_id < NUM_FILE_ENTRIES ); - bhp = bf_newbuf(); - if ( !bhp ) { - return(NULL); - } - OBJ_ASSIGN ( (*obj), bhp->id ); - if ( buf_hash_table[ndx] >= NUM_BUFS ) { - buf_hash_table[ndx] = bhp-bufhdr_table; - } else { - LISTPE_INSERT ( bufhdr_table, hash, bhp, buf_hash_table[ndx] ); - } - - bhp->flags |= BUF_VALID; - if ( flags & BF_PIN ) { - bhp->flags |= BUF_PINNED; - bhp->refcount++; -#ifdef PIN_DEBUG - fprintf(stderr, "bf_assign_buf: %X PINNED (%d)\n", - buf_table + (bhp-bufhdr_table), bhp->refcount); -#endif - } - fd = bf_fid_to_fd(obj->file_id); - if ( fd == -1 ) { - error_log1 ("Invalid fid %d\n", obj->file_id); - bhp->flags |= ~BUF_IO_ERROR; - return(NULL); - } - if ( obj->obj_id >= buf_fids[obj->file_id].npages) { - buf_fids[obj->file_id].npages = obj->obj_id+1; - *len = 0; - } else if ( flags & BF_EMPTY ) { - *len = 0; - } else { - bhp->flags |= BUF_IO_IN_PROGRESS; - if (RELEASE_MASTER) { - return(NULL); - } - if ( lseek ( fd, obj->obj_id << BUFSHIFT, L_SET ) < -1 ) { - error_log2 ("Unable to perform seek on file: %d to page %d", - obj->file_id, obj->obj_id ); - bhp->flags &= ~BUF_IO_IN_PROGRESS; - bhp->flags |= ~BUF_IO_ERROR; - return(NULL); - } - *len = read(fd, buf_table[bhp-bufhdr_table], BUFSIZE); - if ( *len < 0 ) { - error_log2 ("Unable to perform read on file: %d to page %d", - obj->file_id, obj->obj_id ); - bhp->flags &= ~BUF_IO_IN_PROGRESS; - bhp->flags |= ~BUF_IO_ERROR; - return(NULL); - } - if (GET_MASTER) { - return(NULL); - } - bhp->flags &= ~BUF_IO_IN_PROGRESS; - if ( bhp->wait_proc != -1 ) { - /* wake up waiter and anyone waiting on it */ -#ifdef DEBUG - printf("Waking transaction %d due to completed I/O\n", - bhp->wait_proc); -#endif - proc_wake_id ( bhp->wait_proc ); - bhp->wait_proc = -1; - } - MAKE_MRU(bhp); - } - - if ( flags & BF_DIRTY ) { - bhp->flags |= BUF_DIRTY; - } else if ( *len < BUFSIZE ) { - bhp->flags |= BUF_NEWPAGE; - } - return ( bhp ); -} - -int -buf_last ( fid ) -int fid; -{ - int val; - - if (GET_MASTER) { - return(-1); - } - assert ( fid < NUM_FILE_ENTRIES ); - if ( buf_fids[fid].npages == -1 ) { - /* initialize npages field */ - (void) bf_fid_to_fd ( fid ); - } - val = buf_fids[fid].npages; - if ( val ) { - val--; /* Convert to page number */ - } - if (RELEASE_MASTER) { - return(-1); - } - return(val); -} - -#ifdef DEBUG -extern void -buf_dump ( id, all ) -int id; -int all; -{ - int i; - BUFHDR_T *bhp; - - printf ( "LRU + %d\n", *buf_lru ); - if ( all ) { - printf("ID\tFID\tPID\tLNEXT\tLPREV\tHNEXT\tHPREV\tSLEEP\tFLAG\tREFS\n"); - for ( bhp = bufhdr_table, i = 0; i < NUM_BUFS; bhp++, i++ ) { - printf ( "%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%x\t%d\n", i, - bhp->id.file_id, bhp->id.obj_id, - bhp->lru.next, bhp->lru.prev, - bhp->hash.next, bhp->hash.prev, - bhp->wait_proc, bhp->flags, bhp->refcount ); - } - } else { - if ( id >= NUM_BUFS ) { - printf ( "Buffer ID (%d) too high\n", id ); - return; - } - bhp = bufhdr_table+id; - printf ( "%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%x\t%d\n", i, - bhp->id.file_id, bhp->id.obj_id, - bhp->lru.next, bhp->lru.prev, - bhp->hash.next, bhp->hash.prev, - bhp->wait_proc, bhp->flags, bhp->refcount ); - } - return; -} -#endif - diff --git a/lib/libc/db/recno/Makefile.inc b/lib/libc/db/recno/Makefile.inc deleted file mode 100644 index 295332e..0000000 --- a/lib/libc/db/recno/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 -# $FreeBSD$ - -.PATH: ${.CURDIR}/../libc/db/recno - -SRCS+= rec_close.c rec_delete.c rec_get.c rec_open.c rec_put.c rec_search.c \ - rec_seq.c rec_utils.c diff --git a/lib/libc/db/recno/extern.h b/lib/libc/db/recno/extern.h deleted file mode 100644 index feed434..0000000 --- a/lib/libc/db/recno/extern.h +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)extern.h 8.3 (Berkeley) 6/4/94 - */ - -#include "../btree/extern.h" - -int __rec_close __P((DB *)); -int __rec_delete __P((const DB *, const DBT *, u_int)); -int __rec_dleaf __P((BTREE *, PAGE *, u_int32_t)); -int __rec_fd __P((const DB *)); -int __rec_fmap __P((BTREE *, recno_t)); -int __rec_fout __P((BTREE *)); -int __rec_fpipe __P((BTREE *, recno_t)); -int __rec_get __P((const DB *, const DBT *, DBT *, u_int)); -int __rec_iput __P((BTREE *, recno_t, const DBT *, u_int)); -int __rec_put __P((const DB *dbp, DBT *, const DBT *, u_int)); -int __rec_ret __P((BTREE *, EPG *, recno_t, DBT *, DBT *)); -EPG *__rec_search __P((BTREE *, recno_t, enum SRCHOP)); -int __rec_seq __P((const DB *, DBT *, DBT *, u_int)); -int __rec_sync __P((const DB *, u_int)); -int __rec_vmap __P((BTREE *, recno_t)); -int __rec_vout __P((BTREE *)); -int __rec_vpipe __P((BTREE *, recno_t)); diff --git a/lib/libc/db/recno/rec_close.c b/lib/libc/db/recno/rec_close.c deleted file mode 100644 index 25d01de..0000000 --- a/lib/libc/db/recno/rec_close.c +++ /dev/null @@ -1,185 +0,0 @@ -/*- - * Copyright (c) 1990, 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rec_close.c 8.6 (Berkeley) 8/18/94"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include "recno.h" - -/* - * __REC_CLOSE -- Close a recno tree. - * - * Parameters: - * dbp: pointer to access method - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__rec_close(dbp) - DB *dbp; -{ - BTREE *t; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - if (__rec_sync(dbp, 0) == RET_ERROR) - return (RET_ERROR); - - /* Committed to closing. */ - status = RET_SUCCESS; - if (F_ISSET(t, R_MEMMAPPED) && munmap(t->bt_smap, t->bt_msize)) - status = RET_ERROR; - - if (!F_ISSET(t, R_INMEM)) - if (F_ISSET(t, R_CLOSEFP)) { - if (fclose(t->bt_rfp)) - status = RET_ERROR; - } else - if (_close(t->bt_rfd)) - status = RET_ERROR; - - if (__bt_close(dbp) == RET_ERROR) - status = RET_ERROR; - - return (status); -} - -/* - * __REC_SYNC -- sync the recno tree to disk. - * - * Parameters: - * dbp: pointer to access method - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -int -__rec_sync(dbp, flags) - const DB *dbp; - u_int flags; -{ - struct iovec iov[2]; - BTREE *t; - DBT data, key; - off_t off; - recno_t scursor, trec; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - if (flags == R_RECNOSYNC) - return (__bt_sync(dbp, 0)); - - if (F_ISSET(t, R_RDONLY | R_INMEM) || !F_ISSET(t, R_MODIFIED)) - return (RET_SUCCESS); - - /* Read any remaining records into the tree. */ - if (!F_ISSET(t, R_EOF) && t->bt_irec(t, MAX_REC_NUMBER) == RET_ERROR) - return (RET_ERROR); - - /* Rewind the file descriptor. */ - if (lseek(t->bt_rfd, (off_t)0, SEEK_SET) != 0) - return (RET_ERROR); - - /* Save the cursor. */ - scursor = t->bt_cursor.rcursor; - - key.size = sizeof(recno_t); - key.data = &trec; - - if (F_ISSET(t, R_FIXLEN)) { - /* - * We assume that fixed length records are all fixed length. - * Any that aren't are either EINVAL'd or corrected by the - * record put code. - */ - status = (dbp->seq)(dbp, &key, &data, R_FIRST); - while (status == RET_SUCCESS) { - if (_write(t->bt_rfd, data.data, data.size) != - data.size) - return (RET_ERROR); - status = (dbp->seq)(dbp, &key, &data, R_NEXT); - } - } else { - iov[1].iov_base = (char *)&t->bt_bval; - iov[1].iov_len = 1; - - status = (dbp->seq)(dbp, &key, &data, R_FIRST); - while (status == RET_SUCCESS) { - iov[0].iov_base = data.data; - iov[0].iov_len = data.size; - if (writev(t->bt_rfd, iov, 2) != data.size + 1) - return (RET_ERROR); - status = (dbp->seq)(dbp, &key, &data, R_NEXT); - } - } - - /* Restore the cursor. */ - t->bt_cursor.rcursor = scursor; - - if (status == RET_ERROR) - return (RET_ERROR); - if ((off = lseek(t->bt_rfd, (off_t)0, SEEK_CUR)) == -1) - return (RET_ERROR); - if (ftruncate(t->bt_rfd, off)) - return (RET_ERROR); - F_CLR(t, R_MODIFIED); - return (RET_SUCCESS); -} diff --git a/lib/libc/db/recno/rec_delete.c b/lib/libc/db/recno/rec_delete.c deleted file mode 100644 index a16593d..0000000 --- a/lib/libc/db/recno/rec_delete.c +++ /dev/null @@ -1,197 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)rec_delete.c 8.7 (Berkeley) 7/14/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "recno.h" - -static int rec_rdelete __P((BTREE *, recno_t)); - -/* - * __REC_DELETE -- Delete the item(s) referenced by a key. - * - * Parameters: - * dbp: pointer to access method - * key: key to delete - * flags: R_CURSOR if deleting what the cursor references - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. - */ -int -__rec_delete(dbp, key, flags) - const DB *dbp; - const DBT *key; - u_int flags; -{ - BTREE *t; - recno_t nrec; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - switch(flags) { - case 0: - if ((nrec = *(recno_t *)key->data) == 0) - goto einval; - if (nrec > t->bt_nrecs) - return (RET_SPECIAL); - --nrec; - status = rec_rdelete(t, nrec); - break; - case R_CURSOR: - if (!F_ISSET(&t->bt_cursor, CURS_INIT)) - goto einval; - if (t->bt_nrecs == 0) - return (RET_SPECIAL); - status = rec_rdelete(t, t->bt_cursor.rcursor - 1); - if (status == RET_SUCCESS) - --t->bt_cursor.rcursor; - break; - default: -einval: errno = EINVAL; - return (RET_ERROR); - } - - if (status == RET_SUCCESS) - F_SET(t, B_MODIFIED | R_MODIFIED); - return (status); -} - -/* - * REC_RDELETE -- Delete the data matching the specified key. - * - * Parameters: - * tree: tree - * nrec: record to delete - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. - */ -static int -rec_rdelete(t, nrec) - BTREE *t; - recno_t nrec; -{ - EPG *e; - PAGE *h; - int status; - - /* Find the record; __rec_search pins the page. */ - if ((e = __rec_search(t, nrec, SDELETE)) == NULL) - return (RET_ERROR); - - /* Delete the record. */ - h = e->page; - status = __rec_dleaf(t, h, e->index); - if (status != RET_SUCCESS) { - mpool_put(t->bt_mp, h, 0); - return (status); - } - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - return (RET_SUCCESS); -} - -/* - * __REC_DLEAF -- Delete a single record from a recno leaf page. - * - * Parameters: - * t: tree - * index: index on current page to delete - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -int -__rec_dleaf(t, h, index) - BTREE *t; - PAGE *h; - u_int32_t index; -{ - RLEAF *rl; - indx_t *ip, cnt, offset; - u_int32_t nbytes; - char *from; - void *to; - - /* - * Delete a record from a recno leaf page. Internal records are never - * deleted from internal pages, regardless of the records that caused - * them to be added being deleted. Pages made empty by deletion are - * not reclaimed. They are, however, made available for reuse. - * - * Pack the remaining entries at the end of the page, shift the indices - * down, overwriting the deleted record and its index. If the record - * uses overflow pages, make them available for reuse. - */ - to = rl = GETRLEAF(h, index); - if (rl->flags & P_BIGDATA && __ovfl_delete(t, rl->bytes) == RET_ERROR) - return (RET_ERROR); - nbytes = NRLEAF(rl); - - /* - * Compress the key/data pairs. Compress and adjust the [BR]LEAF - * offsets. Reset the headers. - */ - from = (char *)h + h->upper; - memmove(from + nbytes, from, (char *)to - from); - h->upper += nbytes; - - offset = h->linp[index]; - for (cnt = &h->linp[index] - (ip = &h->linp[0]); cnt--; ++ip) - if (ip[0] < offset) - ip[0] += nbytes; - for (cnt = &h->linp[NEXTINDEX(h)] - ip; --cnt; ++ip) - ip[0] = ip[1] < offset ? ip[1] + nbytes : ip[1]; - h->lower -= sizeof(indx_t); - --t->bt_nrecs; - return (RET_SUCCESS); -} diff --git a/lib/libc/db/recno/rec_get.c b/lib/libc/db/recno/rec_get.c deleted file mode 100644 index 0a8b880..0000000 --- a/lib/libc/db/recno/rec_get.c +++ /dev/null @@ -1,311 +0,0 @@ -/*- - * Copyright (c) 1990, 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rec_get.c 8.9 (Berkeley) 8/18/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include "recno.h" - -/* - * __REC_GET -- Get a record from the btree. - * - * Parameters: - * dbp: pointer to access method - * key: key to find - * data: data to return - * flag: currently unused - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. - */ -int -__rec_get(dbp, key, data, flags) - const DB *dbp; - const DBT *key; - DBT *data; - u_int flags; -{ - BTREE *t; - EPG *e; - recno_t nrec; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* Get currently doesn't take any flags, and keys of 0 are illegal. */ - if (flags || (nrec = *(recno_t *)key->data) == 0) { - errno = EINVAL; - return (RET_ERROR); - } - - /* - * If we haven't seen this record yet, try to find it in the - * original file. - */ - if (nrec > t->bt_nrecs) { - if (F_ISSET(t, R_EOF | R_INMEM)) - return (RET_SPECIAL); - if ((status = t->bt_irec(t, nrec)) != RET_SUCCESS) - return (status); - } - - --nrec; - if ((e = __rec_search(t, nrec, SEARCH)) == NULL) - return (RET_ERROR); - - status = __rec_ret(t, e, 0, NULL, data); - if (F_ISSET(t, B_DB_LOCK)) - mpool_put(t->bt_mp, e->page, 0); - else - t->bt_pinned = e->page; - return (status); -} - -/* - * __REC_FPIPE -- Get fixed length records from a pipe. - * - * Parameters: - * t: tree - * cnt: records to read - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__rec_fpipe(t, top) - BTREE *t; - recno_t top; -{ - DBT data; - recno_t nrec; - size_t len; - int ch; - u_char *p; - - if (t->bt_rdata.size < t->bt_reclen) { - t->bt_rdata.data = t->bt_rdata.data == NULL ? - malloc(t->bt_reclen) : - reallocf(t->bt_rdata.data, t->bt_reclen); - if (t->bt_rdata.data == NULL) - return (RET_ERROR); - t->bt_rdata.size = t->bt_reclen; - } - data.data = t->bt_rdata.data; - data.size = t->bt_reclen; - - for (nrec = t->bt_nrecs; nrec < top;) { - len = t->bt_reclen; - for (p = t->bt_rdata.data;; *p++ = ch) - if ((ch = getc(t->bt_rfp)) == EOF || !--len) { - if (ch != EOF) - *p = ch; - if (len != 0) - memset(p, t->bt_bval, len); - if (__rec_iput(t, - nrec, &data, 0) != RET_SUCCESS) - return (RET_ERROR); - ++nrec; - break; - } - if (ch == EOF) - break; - } - if (nrec < top) { - F_SET(t, R_EOF); - return (RET_SPECIAL); - } - return (RET_SUCCESS); -} - -/* - * __REC_VPIPE -- Get variable length records from a pipe. - * - * Parameters: - * t: tree - * cnt: records to read - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__rec_vpipe(t, top) - BTREE *t; - recno_t top; -{ - DBT data; - recno_t nrec; - indx_t len; - size_t sz; - int bval, ch; - u_char *p; - - bval = t->bt_bval; - for (nrec = t->bt_nrecs; nrec < top; ++nrec) { - for (p = t->bt_rdata.data, - sz = t->bt_rdata.size;; *p++ = ch, --sz) { - if ((ch = getc(t->bt_rfp)) == EOF || ch == bval) { - data.data = t->bt_rdata.data; - data.size = p - (u_char *)t->bt_rdata.data; - if (ch == EOF && data.size == 0) - break; - if (__rec_iput(t, nrec, &data, 0) - != RET_SUCCESS) - return (RET_ERROR); - break; - } - if (sz == 0) { - len = p - (u_char *)t->bt_rdata.data; - t->bt_rdata.size += (sz = 256); - t->bt_rdata.data = t->bt_rdata.data == NULL ? - malloc(t->bt_rdata.size) : - reallocf(t->bt_rdata.data, t->bt_rdata.size); - if (t->bt_rdata.data == NULL) - return (RET_ERROR); - p = (u_char *)t->bt_rdata.data + len; - } - } - if (ch == EOF) - break; - } - if (nrec < top) { - F_SET(t, R_EOF); - return (RET_SPECIAL); - } - return (RET_SUCCESS); -} - -/* - * __REC_FMAP -- Get fixed length records from a file. - * - * Parameters: - * t: tree - * cnt: records to read - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__rec_fmap(t, top) - BTREE *t; - recno_t top; -{ - DBT data; - recno_t nrec; - u_char *sp, *ep, *p; - size_t len; - - if (t->bt_rdata.size < t->bt_reclen) { - t->bt_rdata.data = t->bt_rdata.data == NULL ? - malloc(t->bt_reclen) : - reallocf(t->bt_rdata.data, t->bt_reclen); - if (t->bt_rdata.data == NULL) - return (RET_ERROR); - t->bt_rdata.size = t->bt_reclen; - } - data.data = t->bt_rdata.data; - data.size = t->bt_reclen; - - sp = (u_char *)t->bt_cmap; - ep = (u_char *)t->bt_emap; - for (nrec = t->bt_nrecs; nrec < top; ++nrec) { - if (sp >= ep) { - F_SET(t, R_EOF); - return (RET_SPECIAL); - } - len = t->bt_reclen; - for (p = t->bt_rdata.data; - sp < ep && len > 0; *p++ = *sp++, --len); - if (len != 0) - memset(p, t->bt_bval, len); - if (__rec_iput(t, nrec, &data, 0) != RET_SUCCESS) - return (RET_ERROR); - } - t->bt_cmap = (caddr_t)sp; - return (RET_SUCCESS); -} - -/* - * __REC_VMAP -- Get variable length records from a file. - * - * Parameters: - * t: tree - * cnt: records to read - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__rec_vmap(t, top) - BTREE *t; - recno_t top; -{ - DBT data; - u_char *sp, *ep; - recno_t nrec; - int bval; - - sp = (u_char *)t->bt_cmap; - ep = (u_char *)t->bt_emap; - bval = t->bt_bval; - - for (nrec = t->bt_nrecs; nrec < top; ++nrec) { - if (sp >= ep) { - F_SET(t, R_EOF); - return (RET_SPECIAL); - } - for (data.data = sp; sp < ep && *sp != bval; ++sp); - data.size = sp - (u_char *)data.data; - if (__rec_iput(t, nrec, &data, 0) != RET_SUCCESS) - return (RET_ERROR); - ++sp; - } - t->bt_cmap = (caddr_t)sp; - return (RET_SUCCESS); -} diff --git a/lib/libc/db/recno/rec_open.c b/lib/libc/db/recno/rec_open.c deleted file mode 100644 index eaeacc5..0000000 --- a/lib/libc/db/recno/rec_open.c +++ /dev/null @@ -1,243 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rec_open.c 8.10 (Berkeley) 9/1/94"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include "recno.h" - -DB * -__rec_open(fname, flags, mode, openinfo, dflags) - const char *fname; - int flags, mode, dflags; - const RECNOINFO *openinfo; -{ - BTREE *t; - BTREEINFO btopeninfo; - DB *dbp; - PAGE *h; - struct stat sb; - int rfd, sverrno; - - /* Open the user's file -- if this fails, we're done. */ - if (fname != NULL && (rfd = _open(fname, flags, mode)) < 0) - return (NULL); - - /* Create a btree in memory (backed by disk). */ - dbp = NULL; - if (openinfo) { - if (openinfo->flags & ~(R_FIXEDLEN | R_NOKEY | R_SNAPSHOT)) - goto einval; - btopeninfo.flags = 0; - btopeninfo.cachesize = openinfo->cachesize; - btopeninfo.maxkeypage = 0; - btopeninfo.minkeypage = 0; - btopeninfo.psize = openinfo->psize; - btopeninfo.compare = NULL; - btopeninfo.prefix = NULL; - btopeninfo.lorder = openinfo->lorder; - dbp = __bt_open(openinfo->bfname, - O_RDWR, S_IRUSR | S_IWUSR, &btopeninfo, dflags); - } else - dbp = __bt_open(NULL, O_RDWR, S_IRUSR | S_IWUSR, NULL, dflags); - if (dbp == NULL) - goto err; - - /* - * Some fields in the tree structure are recno specific. Fill them - * in and make the btree structure look like a recno structure. We - * don't change the bt_ovflsize value, it's close enough and slightly - * bigger. - */ - t = dbp->internal; - if (openinfo) { - if (openinfo->flags & R_FIXEDLEN) { - F_SET(t, R_FIXLEN); - t->bt_reclen = openinfo->reclen; - if (t->bt_reclen == 0) - goto einval; - } - t->bt_bval = openinfo->bval; - } else - t->bt_bval = '\n'; - - F_SET(t, R_RECNO); - if (fname == NULL) - F_SET(t, R_EOF | R_INMEM); - else - t->bt_rfd = rfd; - - if (fname != NULL) { - /* - * In 4.4BSD, stat(2) returns true for ISSOCK on pipes. - * Unfortunately, that's not portable, so we use lseek - * and check the errno values. - */ - errno = 0; - if (lseek(rfd, (off_t)0, SEEK_CUR) == -1 && errno == ESPIPE) { - switch (flags & O_ACCMODE) { - case O_RDONLY: - F_SET(t, R_RDONLY); - break; - default: - goto einval; - } -slow: if ((t->bt_rfp = fdopen(rfd, "r")) == NULL) - goto err; - F_SET(t, R_CLOSEFP); - t->bt_irec = - F_ISSET(t, R_FIXLEN) ? __rec_fpipe : __rec_vpipe; - } else { - switch (flags & O_ACCMODE) { - case O_RDONLY: - F_SET(t, R_RDONLY); - break; - case O_RDWR: - break; - default: - goto einval; - } - - if (fstat(rfd, &sb)) - goto err; - /* - * Kluge -- we'd like to test to see if the file is too - * big to mmap. Since, we don't know what size or type - * off_t's or size_t's are, what the largest unsigned - * integral type is, or what random insanity the local - * C compiler will perpetrate, doing the comparison in - * a portable way is flatly impossible. Hope that mmap - * fails if the file is too large. - */ - if (sb.st_size == 0) - F_SET(t, R_EOF); - else { -#ifdef MMAP_NOT_AVAILABLE - /* - * XXX - * Mmap doesn't work correctly on many current - * systems. In particular, it can fail subtly, - * with cache coherency problems. Don't use it - * for now. - */ - t->bt_msize = sb.st_size; - if ((t->bt_smap = mmap(NULL, t->bt_msize, - PROT_READ, MAP_PRIVATE, rfd, - (off_t)0)) == MAP_FAILED) - goto slow; - t->bt_cmap = t->bt_smap; - t->bt_emap = t->bt_smap + sb.st_size; - t->bt_irec = F_ISSET(t, R_FIXLEN) ? - __rec_fmap : __rec_vmap; - F_SET(t, R_MEMMAPPED); -#else - goto slow; -#endif - } - } - } - - /* Use the recno routines. */ - dbp->close = __rec_close; - dbp->del = __rec_delete; - dbp->fd = __rec_fd; - dbp->get = __rec_get; - dbp->put = __rec_put; - dbp->seq = __rec_seq; - dbp->sync = __rec_sync; - - /* If the root page was created, reset the flags. */ - if ((h = mpool_get(t->bt_mp, P_ROOT, 0)) == NULL) - goto err; - if ((h->flags & P_TYPE) == P_BLEAF) { - F_CLR(h, P_TYPE); - F_SET(h, P_RLEAF); - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - } else - mpool_put(t->bt_mp, h, 0); - - if (openinfo && openinfo->flags & R_SNAPSHOT && - !F_ISSET(t, R_EOF | R_INMEM) && - t->bt_irec(t, MAX_REC_NUMBER) == RET_ERROR) - goto err; - return (dbp); - -einval: errno = EINVAL; -err: sverrno = errno; - if (dbp != NULL) - (void)__bt_close(dbp); - if (fname != NULL) - (void)_close(rfd); - errno = sverrno; - return (NULL); -} - -int -__rec_fd(dbp) - const DB *dbp; -{ - BTREE *t; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* In-memory database can't have a file descriptor. */ - if (F_ISSET(t, R_INMEM)) { - errno = ENOENT; - return (-1); - } - return (t->bt_rfd); -} diff --git a/lib/libc/db/recno/rec_put.c b/lib/libc/db/recno/rec_put.c deleted file mode 100644 index 0a5bddf..0000000 --- a/lib/libc/db/recno/rec_put.c +++ /dev/null @@ -1,279 +0,0 @@ -/*- - * Copyright (c) 1990, 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rec_put.c 8.7 (Berkeley) 8/18/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include - -#include -#include "recno.h" - -/* - * __REC_PUT -- Add a recno item to the tree. - * - * Parameters: - * dbp: pointer to access method - * key: key - * data: data - * flag: R_CURSOR, R_IAFTER, R_IBEFORE, R_NOOVERWRITE - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key is - * already in the tree and R_NOOVERWRITE specified. - */ -int -__rec_put(dbp, key, data, flags) - const DB *dbp; - DBT *key; - const DBT *data; - u_int flags; -{ - BTREE *t; - DBT fdata, tdata; - recno_t nrec; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* - * If using fixed-length records, and the record is long, return - * EINVAL. If it's short, pad it out. Use the record data return - * memory, it's only short-term. - */ - if (F_ISSET(t, R_FIXLEN) && data->size != t->bt_reclen) { - if (data->size > t->bt_reclen) - goto einval; - - if (t->bt_rdata.size < t->bt_reclen) { - t->bt_rdata.data = - reallocf(t->bt_rdata.data, t->bt_reclen); - if (t->bt_rdata.data == NULL) - return (RET_ERROR); - t->bt_rdata.size = t->bt_reclen; - } - memmove(t->bt_rdata.data, data->data, data->size); - memset((char *)t->bt_rdata.data + data->size, - t->bt_bval, t->bt_reclen - data->size); - fdata.data = t->bt_rdata.data; - fdata.size = t->bt_reclen; - } else { - fdata.data = data->data; - fdata.size = data->size; - } - - switch (flags) { - case R_CURSOR: - if (!F_ISSET(&t->bt_cursor, CURS_INIT)) - goto einval; - nrec = t->bt_cursor.rcursor; - break; - case R_SETCURSOR: - if ((nrec = *(recno_t *)key->data) == 0) - goto einval; - break; - case R_IAFTER: - if ((nrec = *(recno_t *)key->data) == 0) { - nrec = 1; - flags = R_IBEFORE; - } - break; - case 0: - case R_IBEFORE: - if ((nrec = *(recno_t *)key->data) == 0) - goto einval; - break; - case R_NOOVERWRITE: - if ((nrec = *(recno_t *)key->data) == 0) - goto einval; - if (nrec <= t->bt_nrecs) - return (RET_SPECIAL); - break; - default: -einval: errno = EINVAL; - return (RET_ERROR); - } - - /* - * Make sure that records up to and including the put record are - * already in the database. If skipping records, create empty ones. - */ - if (nrec > t->bt_nrecs) { - if (!F_ISSET(t, R_EOF | R_INMEM) && - t->bt_irec(t, nrec) == RET_ERROR) - return (RET_ERROR); - if (nrec > t->bt_nrecs + 1) { - if (F_ISSET(t, R_FIXLEN)) { - if ((tdata.data = - (void *)malloc(t->bt_reclen)) == NULL) - return (RET_ERROR); - tdata.size = t->bt_reclen; - memset(tdata.data, t->bt_bval, tdata.size); - } else { - tdata.data = NULL; - tdata.size = 0; - } - while (nrec > t->bt_nrecs + 1) - if (__rec_iput(t, - t->bt_nrecs, &tdata, 0) != RET_SUCCESS) - return (RET_ERROR); - if (F_ISSET(t, R_FIXLEN)) - free(tdata.data); - } - } - - if ((status = __rec_iput(t, nrec - 1, &fdata, flags)) != RET_SUCCESS) - return (status); - - if (flags == R_SETCURSOR) - t->bt_cursor.rcursor = nrec; - - F_SET(t, R_MODIFIED); - return (__rec_ret(t, NULL, nrec, key, NULL)); -} - -/* - * __REC_IPUT -- Add a recno item to the tree. - * - * Parameters: - * t: tree - * nrec: record number - * data: data - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__rec_iput(t, nrec, data, flags) - BTREE *t; - recno_t nrec; - const DBT *data; - u_int flags; -{ - DBT tdata; - EPG *e; - PAGE *h; - indx_t index, nxtindex; - pgno_t pg; - u_int32_t nbytes; - int dflags, status; - char *dest, db[NOVFLSIZE]; - - /* - * If the data won't fit on a page, store it on indirect pages. - * - * XXX - * If the insert fails later on, these pages aren't recovered. - */ - if (data->size > t->bt_ovflsize) { - if (__ovfl_put(t, data, &pg) == RET_ERROR) - return (RET_ERROR); - tdata.data = db; - tdata.size = NOVFLSIZE; - *(pgno_t *)db = pg; - *(u_int32_t *)(db + sizeof(pgno_t)) = data->size; - dflags = P_BIGDATA; - data = &tdata; - } else - dflags = 0; - - /* __rec_search pins the returned page. */ - if ((e = __rec_search(t, nrec, - nrec > t->bt_nrecs || flags == R_IAFTER || flags == R_IBEFORE ? - SINSERT : SEARCH)) == NULL) - return (RET_ERROR); - - h = e->page; - index = e->index; - - /* - * Add the specified key/data pair to the tree. The R_IAFTER and - * R_IBEFORE flags insert the key after/before the specified key. - * - * Pages are split as required. - */ - switch (flags) { - case R_IAFTER: - ++index; - break; - case R_IBEFORE: - break; - default: - if (nrec < t->bt_nrecs && - __rec_dleaf(t, h, index) == RET_ERROR) { - mpool_put(t->bt_mp, h, 0); - return (RET_ERROR); - } - break; - } - - /* - * If not enough room, split the page. The split code will insert - * the key and data and unpin the current page. If inserting into - * the offset array, shift the pointers up. - */ - nbytes = NRLEAFDBT(data->size); - if (h->upper - h->lower < nbytes + sizeof(indx_t)) { - status = __bt_split(t, h, NULL, data, dflags, nbytes, index); - if (status == RET_SUCCESS) - ++t->bt_nrecs; - return (status); - } - - if (index < (nxtindex = NEXTINDEX(h))) - memmove(h->linp + index + 1, h->linp + index, - (nxtindex - index) * sizeof(indx_t)); - h->lower += sizeof(indx_t); - - h->linp[index] = h->upper -= nbytes; - dest = (char *)h + h->upper; - WR_RLEAF(dest, data, dflags); - - ++t->bt_nrecs; - F_SET(t, B_MODIFIED); - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - - return (RET_SUCCESS); -} diff --git a/lib/libc/db/recno/rec_search.c b/lib/libc/db/recno/rec_search.c deleted file mode 100644 index acc109e..0000000 --- a/lib/libc/db/recno/rec_search.c +++ /dev/null @@ -1,126 +0,0 @@ -/*- - * Copyright (c) 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rec_search.c 8.4 (Berkeley) 7/14/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include - -#include -#include "recno.h" - -/* - * __REC_SEARCH -- Search a btree for a key. - * - * Parameters: - * t: tree to search - * recno: key to find - * op: search operation - * - * Returns: - * EPG for matching record, if any, or the EPG for the location of the - * key, if it were inserted into the tree. - * - * Returns: - * The EPG for matching record, if any, or the EPG for the location - * of the key, if it were inserted into the tree, is entered into - * the bt_cur field of the tree. A pointer to the field is returned. - */ -EPG * -__rec_search(t, recno, op) - BTREE *t; - recno_t recno; - enum SRCHOP op; -{ - register indx_t index; - register PAGE *h; - EPGNO *parent; - RINTERNAL *r; - pgno_t pg; - indx_t top; - recno_t total; - int sverrno; - - BT_CLR(t); - for (pg = P_ROOT, total = 0;;) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - goto err; - if (h->flags & P_RLEAF) { - t->bt_cur.page = h; - t->bt_cur.index = recno - total; - return (&t->bt_cur); - } - for (index = 0, top = NEXTINDEX(h);;) { - r = GETRINTERNAL(h, index); - if (++index == top || total + r->nrecs > recno) - break; - total += r->nrecs; - } - - BT_PUSH(t, pg, index - 1); - - pg = r->pgno; - switch (op) { - case SDELETE: - --GETRINTERNAL(h, (index - 1))->nrecs; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - break; - case SINSERT: - ++GETRINTERNAL(h, (index - 1))->nrecs; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - break; - case SEARCH: - mpool_put(t->bt_mp, h, 0); - break; - } - - } - /* Try and recover the tree. */ -err: sverrno = errno; - if (op != SEARCH) - while ((parent = BT_POP(t)) != NULL) { - if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) - break; - if (op == SINSERT) - --GETRINTERNAL(h, parent->index)->nrecs; - else - ++GETRINTERNAL(h, parent->index)->nrecs; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - } - errno = sverrno; - return (NULL); -} diff --git a/lib/libc/db/recno/rec_seq.c b/lib/libc/db/recno/rec_seq.c deleted file mode 100644 index f80992c..0000000 --- a/lib/libc/db/recno/rec_seq.c +++ /dev/null @@ -1,131 +0,0 @@ -/*- - * Copyright (c) 1991, 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. - */ - -#ifndef lint -static char sccsid[] = "@(#)rec_seq.c 8.3 (Berkeley) 7/14/94"; -#endif /* not lint */ - -#include - -#include -#include -#include -#include - -#include -#include "recno.h" - -/* - * __REC_SEQ -- Recno sequential scan interface. - * - * Parameters: - * dbp: pointer to access method - * key: key for positioning and return value - * data: data return value - * flags: R_CURSOR, R_FIRST, R_LAST, R_NEXT, R_PREV. - * - * Returns: - * RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key. - */ -int -__rec_seq(dbp, key, data, flags) - const DB *dbp; - DBT *key, *data; - u_int flags; -{ - BTREE *t; - EPG *e; - recno_t nrec; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - switch(flags) { - case R_CURSOR: - if ((nrec = *(recno_t *)key->data) == 0) - goto einval; - break; - case R_NEXT: - if (F_ISSET(&t->bt_cursor, CURS_INIT)) { - nrec = t->bt_cursor.rcursor + 1; - break; - } - /* FALLTHROUGH */ - case R_FIRST: - nrec = 1; - break; - case R_PREV: - if (F_ISSET(&t->bt_cursor, CURS_INIT)) { - if ((nrec = t->bt_cursor.rcursor - 1) == 0) - return (RET_SPECIAL); - break; - } - /* FALLTHROUGH */ - case R_LAST: - if (!F_ISSET(t, R_EOF | R_INMEM) && - t->bt_irec(t, MAX_REC_NUMBER) == RET_ERROR) - return (RET_ERROR); - nrec = t->bt_nrecs; - break; - default: -einval: errno = EINVAL; - return (RET_ERROR); - } - - if (t->bt_nrecs == 0 || nrec > t->bt_nrecs) { - if (!F_ISSET(t, R_EOF | R_INMEM) && - (status = t->bt_irec(t, nrec)) != RET_SUCCESS) - return (status); - if (t->bt_nrecs == 0 || nrec > t->bt_nrecs) - return (RET_SPECIAL); - } - - if ((e = __rec_search(t, nrec - 1, SEARCH)) == NULL) - return (RET_ERROR); - - F_SET(&t->bt_cursor, CURS_INIT); - t->bt_cursor.rcursor = nrec; - - status = __rec_ret(t, e, nrec, key, data); - if (F_ISSET(t, B_DB_LOCK)) - mpool_put(t->bt_mp, e->page, 0); - else - t->bt_pinned = e->page; - return (status); -} diff --git a/lib/libc/db/recno/rec_utils.c b/lib/libc/db/recno/rec_utils.c deleted file mode 100644 index baea3fa..0000000 --- a/lib/libc/db/recno/rec_utils.c +++ /dev/null @@ -1,122 +0,0 @@ -/*- - * Copyright (c) 1990, 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rec_utils.c 8.6 (Berkeley) 7/16/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "recno.h" - -/* - * __rec_ret -- - * Build return data. - * - * Parameters: - * t: tree - * e: key/data pair to be returned - * nrec: record number - * key: user's key structure - * data: user's data structure - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -int -__rec_ret(t, e, nrec, key, data) - BTREE *t; - EPG *e; - recno_t nrec; - DBT *key, *data; -{ - RLEAF *rl; - void *p; - - if (key == NULL) - goto dataonly; - - /* We have to copy the key, it's not on the page. */ - if (sizeof(recno_t) > t->bt_rkey.size) { - p = (void *)(t->bt_rkey.data == NULL ? - malloc(sizeof(recno_t)) : - realloc(t->bt_rkey.data, sizeof(recno_t))); - if (p == NULL) - return (RET_ERROR); - t->bt_rkey.data = p; - t->bt_rkey.size = sizeof(recno_t); - } - memmove(t->bt_rkey.data, &nrec, sizeof(recno_t)); - key->size = sizeof(recno_t); - key->data = t->bt_rkey.data; - -dataonly: - if (data == NULL) - return (RET_SUCCESS); - - /* - * We must copy big keys/data to make them contigous. Otherwise, - * leave the page pinned and don't copy unless the user specified - * concurrent access. - */ - rl = GETRLEAF(e->page, e->index); - if (rl->flags & P_BIGDATA) { - if (__ovfl_get(t, rl->bytes, - &data->size, &t->bt_rdata.data, &t->bt_rdata.size)) - return (RET_ERROR); - data->data = t->bt_rdata.data; - } else if (F_ISSET(t, B_DB_LOCK)) { - /* Use +1 in case the first record retrieved is 0 length. */ - if (rl->dsize + 1 > t->bt_rdata.size) { - p = (void *)(t->bt_rdata.data == NULL ? - malloc(rl->dsize + 1) : - realloc(t->bt_rdata.data, rl->dsize + 1)); - if (p == NULL) - return (RET_ERROR); - t->bt_rdata.data = p; - t->bt_rdata.size = rl->dsize + 1; - } - memmove(t->bt_rdata.data, rl->bytes, rl->dsize); - data->size = rl->dsize; - data->data = t->bt_rdata.data; - } else { - data->size = rl->dsize; - data->data = rl->bytes; - } - return (RET_SUCCESS); -} diff --git a/lib/libc/db/recno/recno.h b/lib/libc/db/recno/recno.h deleted file mode 100644 index bec772c..0000000 --- a/lib/libc/db/recno/recno.h +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)recno.h 8.1 (Berkeley) 6/4/93 - */ - -enum SRCHOP { SDELETE, SINSERT, SEARCH}; /* Rec_search operation. */ - -#include "../btree/btree.h" -#include "extern.h" diff --git a/lib/libc/db/test/Makefile b/lib/libc/db/test/Makefile deleted file mode 100644 index 7ea5302..0000000 --- a/lib/libc/db/test/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -# @(#)Makefile 8.15 (Berkeley) 7/28/94 - -PROG= dbtest -OBJS= dbtest.o strerror.o - -# Uncomment the STAT line get hash and btree statistical use info. This -# also forces ld to load the btree debug functions for use by gdb, which -# is useful. The db library has to be compiled with -DSTATISTICS as well. -INC= -I${PORTDIR}/include -I${PORTDIR} -OORG= -g -#STAT= -DSTATISTICS -CFLAGS= -D__DBINTERFACE_PRIVATE -DDEBUG ${STAT} ${OORG} ${INC} - -dbtest: ${OBJS} ${PORTDIR}/libdb.a - ${CC} -o ${.TARGET} ${OBJS} ${PORTDIR}/libdb.a - -strerror.o: ${PORTDIR}/clib/strerror.c - ${CC} -c ${PORTDIR}/clib/strerror.c - -clean: - rm -f dbtest.core gmon.out ${OBJS} ${PROG} t1 t2 t3 - -${OBJS}: Makefile diff --git a/lib/libc/db/test/README b/lib/libc/db/test/README deleted file mode 100644 index 0c0cd13..0000000 --- a/lib/libc/db/test/README +++ /dev/null @@ -1,74 +0,0 @@ -# @(#)README 8.8 (Berkeley) 7/31/94 - -To build this portably, try something like: - - make PORTDIR="../PORT/MACH" - -where MACH is the machine, i.e. "sunos.4.1.1". - -To run the tests, enter "sh run.test". If your system dictionary isn't -in /usr/share/dict/words, edit run.test to reflect the correct place. - -Fairly large files (the command files) are built in this directory during -the test runs, and even larger files (the database files) are created in -"/var/tmp". If the latter directory doesn't exist, set the environmental -variable TMPDIR to a directory where the files can be built. - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -The script file consists of lines with an initial character which is -the command for that line, or an initial character indicating a key -or data entry for a previous command. - -Legal command characters are as follows: - -c: compare a record - + must be followed by [kK][dD]; the data value in the database - associated with the specified key is compared to the specified - data value. -e: echo a string - + writes out the rest of the line into the output file; if the - last character is not a carriage-return, a newline is appended. -f: set the flags for the next command - + no value zero's the flags -g: do a get command - + must be followed by [kK] - + writes out the retrieved data DBT. -o [r]: dump [reverse] - + dump the database out, if 'r' is set, in reverse order. -p: do a put command - + must be followed by [kK][dD] -r: do a del command - + must be followed by [kK] unless R_CURSOR flag set. -S: sync the database -s: do a seq command - + must be followed by [kK] if R_CURSOR flag set. - + writes out the retrieved data DBT. - -Legal key/data characters are as follows: - -D [file]: data file - + set the current data value to the contents of the file -d [data]: - + set the current key value to the contents of the line. -K [file]: key file - + set the current key value to the contents of the file -k [data]: - + set the current key value to the contents of the line. - -Blank lines, lines with leading white space, and lines with leading -hash marks (#) are ignored. - -Options to dbtest are as follows: - - -d: Set the DB_LOCK flag. - -f: Use the file argument as the database file. - -i: Use the rest of the argument to set elements in the info - structure. If the type is btree, then "-i cachesize=10240" - will set BTREEINFO.cachesize to 10240. - -o: The rest of the argument is the output file instead of - using stdout. - -s: Don't delete the database file before opening it, i.e. - use the database file from a previous run. - -Dbtest requires two arguments, the type of access "hash", "recno" -or "btree", and the script name or "-" to indicate stdin. diff --git a/lib/libc/db/test/btree.tests/main.c b/lib/libc/db/test/btree.tests/main.c deleted file mode 100644 index 39c1da0..0000000 --- a/lib/libc/db/test/btree.tests/main.c +++ /dev/null @@ -1,765 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)main.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "btree.h" - -typedef struct cmd_table { - char *cmd; - int nargs; - int rconv; - void (*func) __P((DB *, char **)); - char *usage, *descrip; -} cmd_table; - -int stopstop; -DB *globaldb; - -void append __P((DB *, char **)); -void bstat __P((DB *, char **)); -void cursor __P((DB *, char **)); -void delcur __P((DB *, char **)); -void delete __P((DB *, char **)); -void dump __P((DB *, char **)); -void first __P((DB *, char **)); -void get __P((DB *, char **)); -void help __P((DB *, char **)); -void iafter __P((DB *, char **)); -void ibefore __P((DB *, char **)); -void icursor __P((DB *, char **)); -void insert __P((DB *, char **)); -void keydata __P((DBT *, DBT *)); -void last __P((DB *, char **)); -void list __P((DB *, char **)); -void load __P((DB *, char **)); -void mstat __P((DB *, char **)); -void next __P((DB *, char **)); -int parse __P((char *, char **, int)); -void previous __P((DB *, char **)); -void show __P((DB *, char **)); -void usage __P((void)); -void user __P((DB *)); - -cmd_table commands[] = { - "?", 0, 0, help, "help", NULL, - "a", 2, 1, append, "append key def", "append key with data def", - "b", 0, 0, bstat, "bstat", "stat btree", - "c", 1, 1, cursor, "cursor word", "move cursor to word", - "delc", 0, 0, delcur, "delcur", "delete key the cursor references", - "dele", 1, 1, delete, "delete word", "delete word", - "d", 0, 0, dump, "dump", "dump database", - "f", 0, 0, first, "first", "move cursor to first record", - "g", 1, 1, get, "get key", "locate key", - "h", 0, 0, help, "help", "print command summary", - "ia", 2, 1, iafter, "iafter key data", "insert data after key", - "ib", 2, 1, ibefore, "ibefore key data", "insert data before key", - "ic", 2, 1, icursor, "icursor key data", "replace cursor", - "in", 2, 1, insert, "insert key def", "insert key with data def", - "la", 0, 0, last, "last", "move cursor to last record", - "li", 1, 1, list, "list file", "list to a file", - "loa", 1, 0, load, "load file", NULL, - "loc", 1, 1, get, "get key", NULL, - "m", 0, 0, mstat, "mstat", "stat memory pool", - "n", 0, 0, next, "next", "move cursor forward one record", - "p", 0, 0, previous, "previous", "move cursor back one record", - "q", 0, 0, NULL, "quit", "quit", - "sh", 1, 0, show, "show page", "dump a page", - { NULL }, -}; - -int recno; /* use record numbers */ -char *dict = "words"; /* default dictionary */ -char *progname; - -int -main(argc, argv) - int argc; - char **argv; -{ - int c; - DB *db; - BTREEINFO b; - - progname = *argv; - - b.flags = 0; - b.cachesize = 0; - b.maxkeypage = 0; - b.minkeypage = 0; - b.psize = 0; - b.compare = NULL; - b.prefix = NULL; - b.lorder = 0; - - while ((c = getopt(argc, argv, "bc:di:lp:ru")) != EOF) { - switch (c) { - case 'b': - b.lorder = BIG_ENDIAN; - break; - case 'c': - b.cachesize = atoi(optarg); - break; - case 'd': - b.flags |= R_DUP; - break; - case 'i': - dict = optarg; - break; - case 'l': - b.lorder = LITTLE_ENDIAN; - break; - case 'p': - b.psize = atoi(optarg); - break; - case 'r': - recno = 1; - break; - case 'u': - b.flags = 0; - break; - default: - usage(); - } - } - argc -= optind; - argv += optind; - - if (recno) - db = dbopen(*argv == NULL ? NULL : *argv, O_RDWR, - 0, DB_RECNO, NULL); - else - db = dbopen(*argv == NULL ? NULL : *argv, O_CREAT|O_RDWR, - 0600, DB_BTREE, &b); - - if (db == NULL) { - (void)fprintf(stderr, "dbopen: %s\n", strerror(errno)); - exit(1); - } - globaldb = db; - user(db); - exit(0); - /* NOTREACHED */ -} - -void -user(db) - DB *db; -{ - FILE *ifp; - int argc, i, last; - char *lbuf, *argv[4], buf[512]; - - if ((ifp = fopen("/dev/tty", "r")) == NULL) { - (void)fprintf(stderr, - "/dev/tty: %s\n", strerror(errno)); - exit(1); - } - for (last = 0;;) { - (void)printf("> "); - (void)fflush(stdout); - if ((lbuf = fgets(&buf[0], 512, ifp)) == NULL) - break; - if (lbuf[0] == '\n') { - i = last; - goto uselast; - } - lbuf[strlen(lbuf) - 1] = '\0'; - - if (lbuf[0] == 'q') - break; - - argc = parse(lbuf, &argv[0], 3); - if (argc == 0) - continue; - - for (i = 0; commands[i].cmd != NULL; i++) - if (strncmp(commands[i].cmd, argv[0], - strlen(commands[i].cmd)) == 0) - break; - - if (commands[i].cmd == NULL) { - (void)fprintf(stderr, - "%s: command unknown ('help' for help)\n", lbuf); - continue; - } - - if (commands[i].nargs != argc - 1) { - (void)fprintf(stderr, "usage: %s\n", commands[i].usage); - continue; - } - - if (recno && commands[i].rconv) { - static recno_t nlong; - nlong = atoi(argv[1]); - argv[1] = (char *)&nlong; - } -uselast: last = i; - (*commands[i].func)(db, argv); - } - if ((db->sync)(db) == RET_ERROR) - perror("dbsync"); - else if ((db->close)(db) == RET_ERROR) - perror("dbclose"); -} - -int -parse(lbuf, argv, maxargc) - char *lbuf, **argv; - int maxargc; -{ - int argc = 0; - char *c; - - c = lbuf; - while (isspace(*c)) - c++; - while (*c != '\0' && argc < maxargc) { - *argv++ = c; - argc++; - while (!isspace(*c) && *c != '\0') { - c++; - } - while (isspace(*c)) - *c++ = '\0'; - } - return (argc); -} - -void -append(db, argv) - DB *db; - char **argv; -{ - DBT key, data; - int status; - - if (!recno) { - (void)fprintf(stderr, - "append only available for recno db's.\n"); - return; - } - key.data = argv[1]; - key.size = sizeof(recno_t); - data.data = argv[2]; - data.size = strlen(data.data); - status = (db->put)(db, &key, &data, R_APPEND); - switch (status) { - case RET_ERROR: - perror("append/put"); - break; - case RET_SPECIAL: - (void)printf("%s (duplicate key)\n", argv[1]); - break; - case RET_SUCCESS: - break; - } -} - -void -cursor(db, argv) - DB *db; - char **argv; -{ - DBT data, key; - int status; - - key.data = argv[1]; - if (recno) - key.size = sizeof(recno_t); - else - key.size = strlen(argv[1]) + 1; - status = (*db->seq)(db, &key, &data, R_CURSOR); - switch (status) { - case RET_ERROR: - perror("cursor/seq"); - break; - case RET_SPECIAL: - (void)printf("key not found\n"); - break; - case RET_SUCCESS: - keydata(&key, &data); - break; - } -} - -void -delcur(db, argv) - DB *db; - char **argv; -{ - int status; - - status = (*db->del)(db, NULL, R_CURSOR); - - if (status == RET_ERROR) - perror("delcur/del"); -} - -void -delete(db, argv) - DB *db; - char **argv; -{ - DBT key; - int status; - - key.data = argv[1]; - if (recno) - key.size = sizeof(recno_t); - else - key.size = strlen(argv[1]) + 1; - - status = (*db->del)(db, &key, 0); - switch (status) { - case RET_ERROR: - perror("delete/del"); - break; - case RET_SPECIAL: - (void)printf("key not found\n"); - break; - case RET_SUCCESS: - break; - } -} - -void -dump(db, argv) - DB *db; - char **argv; -{ - __bt_dump(db); -} - -void -first(db, argv) - DB *db; - char **argv; -{ - DBT data, key; - int status; - - status = (*db->seq)(db, &key, &data, R_FIRST); - - switch (status) { - case RET_ERROR: - perror("first/seq"); - break; - case RET_SPECIAL: - (void)printf("no more keys\n"); - break; - case RET_SUCCESS: - keydata(&key, &data); - break; - } -} - -void -get(db, argv) - DB *db; - char **argv; -{ - DBT data, key; - int status; - - key.data = argv[1]; - if (recno) - key.size = sizeof(recno_t); - else - key.size = strlen(argv[1]) + 1; - - status = (*db->get)(db, &key, &data, 0); - - switch (status) { - case RET_ERROR: - perror("get/get"); - break; - case RET_SPECIAL: - (void)printf("key not found\n"); - break; - case RET_SUCCESS: - keydata(&key, &data); - break; - } -} - -void -help(db, argv) - DB *db; - char **argv; -{ - int i; - - for (i = 0; commands[i].cmd; i++) - if (commands[i].descrip) - (void)printf("%s: %s\n", - commands[i].usage, commands[i].descrip); -} - -void -iafter(db, argv) - DB *db; - char **argv; -{ - DBT key, data; - int status; - - if (!recno) { - (void)fprintf(stderr, - "iafter only available for recno db's.\n"); - return; - } - key.data = argv[1]; - key.size = sizeof(recno_t); - data.data = argv[2]; - data.size = strlen(data.data); - status = (db->put)(db, &key, &data, R_IAFTER); - switch (status) { - case RET_ERROR: - perror("iafter/put"); - break; - case RET_SPECIAL: - (void)printf("%s (duplicate key)\n", argv[1]); - break; - case RET_SUCCESS: - break; - } -} - -void -ibefore(db, argv) - DB *db; - char **argv; -{ - DBT key, data; - int status; - - if (!recno) { - (void)fprintf(stderr, - "ibefore only available for recno db's.\n"); - return; - } - key.data = argv[1]; - key.size = sizeof(recno_t); - data.data = argv[2]; - data.size = strlen(data.data); - status = (db->put)(db, &key, &data, R_IBEFORE); - switch (status) { - case RET_ERROR: - perror("ibefore/put"); - break; - case RET_SPECIAL: - (void)printf("%s (duplicate key)\n", argv[1]); - break; - case RET_SUCCESS: - break; - } -} - -void -icursor(db, argv) - DB *db; - char **argv; -{ - int status; - DBT data, key; - - key.data = argv[1]; - if (recno) - key.size = sizeof(recno_t); - else - key.size = strlen(argv[1]) + 1; - data.data = argv[2]; - data.size = strlen(argv[2]) + 1; - - status = (*db->put)(db, &key, &data, R_CURSOR); - switch (status) { - case RET_ERROR: - perror("icursor/put"); - break; - case RET_SPECIAL: - (void)printf("%s (duplicate key)\n", argv[1]); - break; - case RET_SUCCESS: - break; - } -} - -void -insert(db, argv) - DB *db; - char **argv; -{ - int status; - DBT data, key; - - key.data = argv[1]; - if (recno) - key.size = sizeof(recno_t); - else - key.size = strlen(argv[1]) + 1; - data.data = argv[2]; - data.size = strlen(argv[2]) + 1; - - status = (*db->put)(db, &key, &data, R_NOOVERWRITE); - switch (status) { - case RET_ERROR: - perror("insert/put"); - break; - case RET_SPECIAL: - (void)printf("%s (duplicate key)\n", argv[1]); - break; - case RET_SUCCESS: - break; - } -} - -void -last(db, argv) - DB *db; - char **argv; -{ - DBT data, key; - int status; - - status = (*db->seq)(db, &key, &data, R_LAST); - - switch (status) { - case RET_ERROR: - perror("last/seq"); - break; - case RET_SPECIAL: - (void)printf("no more keys\n"); - break; - case RET_SUCCESS: - keydata(&key, &data); - break; - } -} - -void -list(db, argv) - DB *db; - char **argv; -{ - DBT data, key; - FILE *fp; - int status; - - if ((fp = fopen(argv[1], "w")) == NULL) { - (void)fprintf(stderr, "%s: %s\n", argv[1], strerror(errno)); - return; - } - status = (*db->seq)(db, &key, &data, R_FIRST); - while (status == RET_SUCCESS) { - (void)fprintf(fp, "%s\n", key.data); - status = (*db->seq)(db, &key, &data, R_NEXT); - } - if (status == RET_ERROR) - perror("list/seq"); -} - -DB *BUGdb; -void -load(db, argv) - DB *db; - char **argv; -{ - register char *p, *t; - FILE *fp; - DBT data, key; - recno_t cnt; - size_t len; - int status; - char *lp, buf[16 * 1024]; - - BUGdb = db; - if ((fp = fopen(argv[1], "r")) == NULL) { - (void)fprintf(stderr, "%s: %s\n", argv[1], strerror(errno)); - return; - } - (void)printf("loading %s...\n", argv[1]); - - for (cnt = 1; (lp = fgetline(fp, &len)) != NULL; ++cnt) { - if (recno) { - key.data = &cnt; - key.size = sizeof(recno_t); - data.data = lp; - data.size = len + 1; - } else { - key.data = lp; - key.size = len + 1; - for (p = lp + len - 1, t = buf; p >= lp; *t++ = *p--); - *t = '\0'; - data.data = buf; - data.size = len + 1; - } - - status = (*db->put)(db, &key, &data, R_NOOVERWRITE); - switch (status) { - case RET_ERROR: - perror("load/put"); - exit(1); - case RET_SPECIAL: - if (recno) - (void)fprintf(stderr, - "duplicate: %ld {%s}\n", cnt, data.data); - else - (void)fprintf(stderr, - "duplicate: %ld {%s}\n", cnt, key.data); - exit(1); - case RET_SUCCESS: - break; - } - } - (void)fclose(fp); -} - -void -next(db, argv) - DB *db; - char **argv; -{ - DBT data, key; - int status; - - status = (*db->seq)(db, &key, &data, R_NEXT); - - switch (status) { - case RET_ERROR: - perror("next/seq"); - break; - case RET_SPECIAL: - (void)printf("no more keys\n"); - break; - case RET_SUCCESS: - keydata(&key, &data); - break; - } -} - -void -previous(db, argv) - DB *db; - char **argv; -{ - DBT data, key; - int status; - - status = (*db->seq)(db, &key, &data, R_PREV); - - switch (status) { - case RET_ERROR: - perror("previous/seq"); - break; - case RET_SPECIAL: - (void)printf("no more keys\n"); - break; - case RET_SUCCESS: - keydata(&key, &data); - break; - } -} - -void -show(db, argv) - DB *db; - char **argv; -{ - BTREE *t; - PAGE *h; - pgno_t pg; - - pg = atoi(argv[1]); - t = db->internal; - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) { - (void)printf("getpage of %ld failed\n", pg); - return; - } - if (pg == 0) - __bt_dmpage(h); - else - __bt_dpage(h); - mpool_put(t->bt_mp, h, 0); -} - -void -bstat(db, argv) - DB *db; - char **argv; -{ - (void)printf("BTREE\n"); - __bt_stat(db); -} - -void -mstat(db, argv) - DB *db; - char **argv; -{ - (void)printf("MPOOL\n"); - mpool_stat(((BTREE *)db->internal)->bt_mp); -} - -void -keydata(key, data) - DBT *key, *data; -{ - if (!recno && key->size > 0) - (void)printf("%s/", key->data); - if (data->size > 0) - (void)printf("%s", data->data); - (void)printf("\n"); -} - -void -usage() -{ - (void)fprintf(stderr, - "usage: %s [-bdlu] [-c cache] [-i file] [-p page] [file]\n", - progname); - exit (1); -} diff --git a/lib/libc/db/test/dbtest.c b/lib/libc/db/test/dbtest.c deleted file mode 100644 index 4341b4c..0000000 --- a/lib/libc/db/test/dbtest.c +++ /dev/null @@ -1,753 +0,0 @@ -/*- - * Copyright (c) 1992, 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. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1992, 1993, 1994\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)dbtest.c 8.17 (Berkeley) 9/1/94"; -#endif /* not lint */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -enum S { COMMAND, COMPARE, GET, PUT, REMOVE, SEQ, SEQFLAG, KEY, DATA }; - -void compare __P((DBT *, DBT *)); -DBTYPE dbtype __P((char *)); -void dump __P((DB *, int)); -void err __P((const char *, ...)); -void get __P((DB *, DBT *)); -void getdata __P((DB *, DBT *, DBT *)); -void put __P((DB *, DBT *, DBT *)); -void rem __P((DB *, DBT *)); -char *sflags __P((int)); -void synk __P((DB *)); -void *rfile __P((char *, size_t *)); -void seq __P((DB *, DBT *)); -u_int setflags __P((char *)); -void *setinfo __P((DBTYPE, char *)); -void usage __P((void)); -void *xmalloc __P((char *, size_t)); - -DBTYPE type; /* Database type. */ -void *infop; /* Iflags. */ -u_long lineno; /* Current line in test script. */ -u_int flags; /* Current DB flags. */ -int ofd = STDOUT_FILENO; /* Standard output fd. */ - -DB *XXdbp; /* Global for gdb. */ -int XXlineno; /* Fast breakpoint for gdb. */ - -int -main(argc, argv) - int argc; - char *argv[]; -{ - extern int optind; - extern char *optarg; - enum S command, state; - DB *dbp; - DBT data, key, keydata; - size_t len; - int ch, oflags, sflag; - char *fname, *infoarg, *p, *t, buf[8 * 1024]; - - infoarg = NULL; - fname = NULL; - oflags = O_CREAT | O_RDWR; - sflag = 0; - while ((ch = getopt(argc, argv, "f:i:lo:s")) != EOF) - switch (ch) { - case 'f': - fname = optarg; - break; - case 'i': - infoarg = optarg; - break; - case 'l': - oflags |= DB_LOCK; - break; - case 'o': - if ((ofd = open(optarg, - O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0) - err("%s: %s", optarg, strerror(errno)); - break; - case 's': - sflag = 1; - break; - case '?': - default: - usage(); - } - argc -= optind; - argv += optind; - - if (argc != 2) - usage(); - - /* Set the type. */ - type = dbtype(*argv++); - - /* Open the descriptor file. */ - if (strcmp(*argv, "-") && freopen(*argv, "r", stdin) == NULL) - err("%s: %s", *argv, strerror(errno)); - - /* Set up the db structure as necessary. */ - if (infoarg == NULL) - infop = NULL; - else - for (p = strtok(infoarg, ",\t "); p != NULL; - p = strtok(0, ",\t ")) - if (*p != '\0') - infop = setinfo(type, p); - - /* - * Open the DB. Delete any preexisting copy, you almost never - * want it around, and it often screws up tests. - */ - if (fname == NULL) { - p = getenv("TMPDIR"); - if (p == NULL) - p = "/var/tmp"; - (void)sprintf(buf, "%s/__dbtest", p); - fname = buf; - (void)unlink(buf); - } else if (!sflag) - (void)unlink(fname); - - if ((dbp = dbopen(fname, - oflags, S_IRUSR | S_IWUSR, type, infop)) == NULL) - err("dbopen: %s", strerror(errno)); - XXdbp = dbp; - - state = COMMAND; - for (lineno = 1; - (p = fgets(buf, sizeof(buf), stdin)) != NULL; ++lineno) { - /* Delete the newline, displaying the key/data is easier. */ - if (ofd == STDOUT_FILENO && (t = strchr(p, '\n')) != NULL) - *t = '\0'; - if ((len = strlen(buf)) == 0 || isspace(*p) || *p == '#') - continue; - - /* Convenient gdb break point. */ - if (XXlineno == lineno) - XXlineno = 1; - switch (*p) { - case 'c': /* compare */ - if (state != COMMAND) - err("line %lu: not expecting command", lineno); - state = KEY; - command = COMPARE; - break; - case 'e': /* echo */ - if (state != COMMAND) - err("line %lu: not expecting command", lineno); - /* Don't display the newline, if CR at EOL. */ - if (p[len - 2] == '\r') - --len; - if (write(ofd, p + 1, len - 1) != len - 1 || - write(ofd, "\n", 1) != 1) - err("write: %s", strerror(errno)); - break; - case 'g': /* get */ - if (state != COMMAND) - err("line %lu: not expecting command", lineno); - state = KEY; - command = GET; - break; - case 'p': /* put */ - if (state != COMMAND) - err("line %lu: not expecting command", lineno); - state = KEY; - command = PUT; - break; - case 'r': /* remove */ - if (state != COMMAND) - err("line %lu: not expecting command", lineno); - if (flags == R_CURSOR) { - rem(dbp, &key); - state = COMMAND; - } else { - state = KEY; - command = REMOVE; - } - break; - case 'S': /* sync */ - if (state != COMMAND) - err("line %lu: not expecting command", lineno); - synk(dbp); - state = COMMAND; - break; - case 's': /* seq */ - if (state != COMMAND) - err("line %lu: not expecting command", lineno); - if (flags == R_CURSOR) { - state = KEY; - command = SEQ; - } else - seq(dbp, &key); - break; - case 'f': - flags = setflags(p + 1); - break; - case 'D': /* data file */ - if (state != DATA) - err("line %lu: not expecting data", lineno); - data.data = rfile(p + 1, &data.size); - goto ldata; - case 'd': /* data */ - if (state != DATA) - err("line %lu: not expecting data", lineno); - data.data = xmalloc(p + 1, len - 1); - data.size = len - 1; -ldata: switch (command) { - case COMPARE: - compare(&keydata, &data); - break; - case PUT: - put(dbp, &key, &data); - break; - default: - err("line %lu: command doesn't take data", - lineno); - } - if (type != DB_RECNO) - free(key.data); - free(data.data); - state = COMMAND; - break; - case 'K': /* key file */ - if (state != KEY) - err("line %lu: not expecting a key", lineno); - if (type == DB_RECNO) - err("line %lu: 'K' not available for recno", - lineno); - key.data = rfile(p + 1, &key.size); - goto lkey; - case 'k': /* key */ - if (state != KEY) - err("line %lu: not expecting a key", lineno); - if (type == DB_RECNO) { - static recno_t recno; - recno = atoi(p + 1); - key.data = &recno; - key.size = sizeof(recno); - } else { - key.data = xmalloc(p + 1, len - 1); - key.size = len - 1; - } -lkey: switch (command) { - case COMPARE: - getdata(dbp, &key, &keydata); - state = DATA; - break; - case GET: - get(dbp, &key); - if (type != DB_RECNO) - free(key.data); - state = COMMAND; - break; - case PUT: - state = DATA; - break; - case REMOVE: - rem(dbp, &key); - if ((type != DB_RECNO) && (flags != R_CURSOR)) - free(key.data); - state = COMMAND; - break; - case SEQ: - seq(dbp, &key); - if ((type != DB_RECNO) && (flags != R_CURSOR)) - free(key.data); - state = COMMAND; - break; - default: - err("line %lu: command doesn't take a key", - lineno); - } - break; - case 'o': - dump(dbp, p[1] == 'r'); - break; - default: - err("line %lu: %s: unknown command character", - lineno, p); - } - } -#ifdef STATISTICS - /* - * -l must be used (DB_LOCK must be set) for this to be - * used, otherwise a page will be locked and it will fail. - */ - if (type == DB_BTREE && oflags & DB_LOCK) - __bt_stat(dbp); -#endif - if (dbp->close(dbp)) - err("db->close: %s", strerror(errno)); - (void)close(ofd); - exit(0); -} - -#define NOOVERWRITE "put failed, would overwrite key\n" - -void -compare(db1, db2) - DBT *db1, *db2; -{ - register size_t len; - register u_char *p1, *p2; - - if (db1->size != db2->size) - printf("compare failed: key->data len %lu != data len %lu\n", - db1->size, db2->size); - - len = MIN(db1->size, db2->size); - for (p1 = db1->data, p2 = db2->data; len--;) - if (*p1++ != *p2++) { - printf("compare failed at offset %d\n", - p1 - (u_char *)db1->data); - break; - } -} - -void -get(dbp, kp) - DB *dbp; - DBT *kp; -{ - DBT data; - - switch (dbp->get(dbp, kp, &data, flags)) { - case 0: - (void)write(ofd, data.data, data.size); - if (ofd == STDOUT_FILENO) - (void)write(ofd, "\n", 1); - break; - case -1: - err("line %lu: get: %s", lineno, strerror(errno)); - /* NOTREACHED */ - case 1: -#define NOSUCHKEY "get failed, no such key\n" - if (ofd != STDOUT_FILENO) - (void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1); - else - (void)fprintf(stderr, "%d: %.*s: %s", - lineno, MIN(kp->size, 20), kp->data, NOSUCHKEY); -#undef NOSUCHKEY - break; - } -} - -void -getdata(dbp, kp, dp) - DB *dbp; - DBT *kp, *dp; -{ - switch (dbp->get(dbp, kp, dp, flags)) { - case 0: - return; - case -1: - err("line %lu: getdata: %s", lineno, strerror(errno)); - /* NOTREACHED */ - case 1: - err("line %lu: getdata failed, no such key", lineno); - /* NOTREACHED */ - } -} - -void -put(dbp, kp, dp) - DB *dbp; - DBT *kp, *dp; -{ - switch (dbp->put(dbp, kp, dp, flags)) { - case 0: - break; - case -1: - err("line %lu: put: %s", lineno, strerror(errno)); - /* NOTREACHED */ - case 1: - (void)write(ofd, NOOVERWRITE, sizeof(NOOVERWRITE) - 1); - break; - } -} - -void -rem(dbp, kp) - DB *dbp; - DBT *kp; -{ - switch (dbp->del(dbp, kp, flags)) { - case 0: - break; - case -1: - err("line %lu: rem: %s", lineno, strerror(errno)); - /* NOTREACHED */ - case 1: -#define NOSUCHKEY "rem failed, no such key\n" - if (ofd != STDOUT_FILENO) - (void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1); - else if (flags != R_CURSOR) - (void)fprintf(stderr, "%d: %.*s: %s", - lineno, MIN(kp->size, 20), kp->data, NOSUCHKEY); - else - (void)fprintf(stderr, - "%d: rem of cursor failed\n", lineno); -#undef NOSUCHKEY - break; - } -} - -void -synk(dbp) - DB *dbp; -{ - switch (dbp->sync(dbp, flags)) { - case 0: - break; - case -1: - err("line %lu: synk: %s", lineno, strerror(errno)); - /* NOTREACHED */ - } -} - -void -seq(dbp, kp) - DB *dbp; - DBT *kp; -{ - DBT data; - - switch (dbp->seq(dbp, kp, &data, flags)) { - case 0: - (void)write(ofd, data.data, data.size); - if (ofd == STDOUT_FILENO) - (void)write(ofd, "\n", 1); - break; - case -1: - err("line %lu: seq: %s", lineno, strerror(errno)); - /* NOTREACHED */ - case 1: -#define NOSUCHKEY "seq failed, no such key\n" - if (ofd != STDOUT_FILENO) - (void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1); - else if (flags == R_CURSOR) - (void)fprintf(stderr, "%d: %.*s: %s", - lineno, MIN(kp->size, 20), kp->data, NOSUCHKEY); - else - (void)fprintf(stderr, - "%d: seq (%s) failed\n", lineno, sflags(flags)); -#undef NOSUCHKEY - break; - } -} - -void -dump(dbp, rev) - DB *dbp; - int rev; -{ - DBT key, data; - int flags, nflags; - - if (rev) { - flags = R_LAST; - nflags = R_PREV; - } else { - flags = R_FIRST; - nflags = R_NEXT; - } - for (;; flags = nflags) - switch (dbp->seq(dbp, &key, &data, flags)) { - case 0: - (void)write(ofd, data.data, data.size); - if (ofd == STDOUT_FILENO) - (void)write(ofd, "\n", 1); - break; - case 1: - goto done; - case -1: - err("line %lu: (dump) seq: %s", - lineno, strerror(errno)); - /* NOTREACHED */ - } -done: return; -} - -u_int -setflags(s) - char *s; -{ - char *p, *index(); - - for (; isspace(*s); ++s); - if (*s == '\n' || *s == '\0') - return (0); - if ((p = index(s, '\n')) != NULL) - *p = '\0'; - if (!strcmp(s, "R_CURSOR")) return (R_CURSOR); - if (!strcmp(s, "R_FIRST")) return (R_FIRST); - if (!strcmp(s, "R_IAFTER")) return (R_IAFTER); - if (!strcmp(s, "R_IBEFORE")) return (R_IBEFORE); - if (!strcmp(s, "R_LAST")) return (R_LAST); - if (!strcmp(s, "R_NEXT")) return (R_NEXT); - if (!strcmp(s, "R_NOOVERWRITE")) return (R_NOOVERWRITE); - if (!strcmp(s, "R_PREV")) return (R_PREV); - if (!strcmp(s, "R_SETCURSOR")) return (R_SETCURSOR); - - err("line %lu: %s: unknown flag", lineno, s); - /* NOTREACHED */ -} - -char * -sflags(flags) - int flags; -{ - switch (flags) { - case R_CURSOR: return ("R_CURSOR"); - case R_FIRST: return ("R_FIRST"); - case R_IAFTER: return ("R_IAFTER"); - case R_IBEFORE: return ("R_IBEFORE"); - case R_LAST: return ("R_LAST"); - case R_NEXT: return ("R_NEXT"); - case R_NOOVERWRITE: return ("R_NOOVERWRITE"); - case R_PREV: return ("R_PREV"); - case R_SETCURSOR: return ("R_SETCURSOR"); - } - - return ("UNKNOWN!"); -} - -DBTYPE -dbtype(s) - char *s; -{ - if (!strcmp(s, "btree")) - return (DB_BTREE); - if (!strcmp(s, "hash")) - return (DB_HASH); - if (!strcmp(s, "recno")) - return (DB_RECNO); - err("%s: unknown type (use btree, hash or recno)", s); - /* NOTREACHED */ -} - -void * -setinfo(type, s) - DBTYPE type; - char *s; -{ - static BTREEINFO ib; - static HASHINFO ih; - static RECNOINFO rh; - char *eq, *index(); - - if ((eq = index(s, '=')) == NULL) - err("%s: illegal structure set statement", s); - *eq++ = '\0'; - if (!isdigit(*eq)) - err("%s: structure set statement must be a number", s); - - switch (type) { - case DB_BTREE: - if (!strcmp("flags", s)) { - ib.flags = atoi(eq); - return (&ib); - } - if (!strcmp("cachesize", s)) { - ib.cachesize = atoi(eq); - return (&ib); - } - if (!strcmp("maxkeypage", s)) { - ib.maxkeypage = atoi(eq); - return (&ib); - } - if (!strcmp("minkeypage", s)) { - ib.minkeypage = atoi(eq); - return (&ib); - } - if (!strcmp("lorder", s)) { - ib.lorder = atoi(eq); - return (&ib); - } - if (!strcmp("psize", s)) { - ib.psize = atoi(eq); - return (&ib); - } - break; - case DB_HASH: - if (!strcmp("bsize", s)) { - ih.bsize = atoi(eq); - return (&ih); - } - if (!strcmp("ffactor", s)) { - ih.ffactor = atoi(eq); - return (&ih); - } - if (!strcmp("nelem", s)) { - ih.nelem = atoi(eq); - return (&ih); - } - if (!strcmp("cachesize", s)) { - ih.cachesize = atoi(eq); - return (&ih); - } - if (!strcmp("lorder", s)) { - ih.lorder = atoi(eq); - return (&ih); - } - break; - case DB_RECNO: - if (!strcmp("flags", s)) { - rh.flags = atoi(eq); - return (&rh); - } - if (!strcmp("cachesize", s)) { - rh.cachesize = atoi(eq); - return (&rh); - } - if (!strcmp("lorder", s)) { - rh.lorder = atoi(eq); - return (&rh); - } - if (!strcmp("reclen", s)) { - rh.reclen = atoi(eq); - return (&rh); - } - if (!strcmp("bval", s)) { - rh.bval = atoi(eq); - return (&rh); - } - if (!strcmp("psize", s)) { - rh.psize = atoi(eq); - return (&rh); - } - break; - } - err("%s: unknown structure value", s); - /* NOTREACHED */ -} - -void * -rfile(name, lenp) - char *name; - size_t *lenp; -{ - struct stat sb; - void *p; - int fd; - char *np, *index(); - - for (; isspace(*name); ++name); - if ((np = index(name, '\n')) != NULL) - *np = '\0'; - if ((fd = open(name, O_RDONLY, 0)) < 0 || - fstat(fd, &sb)) - err("%s: %s\n", name, strerror(errno)); -#ifdef NOT_PORTABLE - if (sb.st_size > (off_t)SIZE_T_MAX) - err("%s: %s\n", name, strerror(E2BIG)); -#endif - if ((p = (void *)malloc((u_int)sb.st_size)) == NULL) - err("%s", strerror(errno)); - (void)read(fd, p, (int)sb.st_size); - *lenp = sb.st_size; - (void)close(fd); - return (p); -} - -void * -xmalloc(text, len) - char *text; - size_t len; -{ - void *p; - - if ((p = (void *)malloc(len)) == NULL) - err("%s", strerror(errno)); - memmove(p, text, len); - return (p); -} - -void -usage() -{ - (void)fprintf(stderr, - "usage: dbtest [-l] [-f file] [-i info] [-o file] type script\n"); - exit(1); -} - -#if __STDC__ -#include -#else -#include -#endif - -void -#if __STDC__ -err(const char *fmt, ...) -#else -err(fmt, va_alist) - char *fmt; - va_dcl -#endif -{ - va_list ap; -#if __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - (void)fprintf(stderr, "dbtest: "); - (void)vfprintf(stderr, fmt, ap); - va_end(ap); - (void)fprintf(stderr, "\n"); - exit(1); - /* NOTREACHED */ -} diff --git a/lib/libc/db/test/hash.tests/driver2.c b/lib/libc/db/test/hash.tests/driver2.c deleted file mode 100644 index 896820c..0000000 --- a/lib/libc/db/test/hash.tests/driver2.c +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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) 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)driver2.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -/* - * Test driver, to try to tackle the large ugly-split problem. - */ - -#include -#include -#include "ndbm.h" - -int my_hash(key, len) - char *key; - int len; -{ - return(17); /* So I'm cruel... */ -} - -main(argc, argv) - int argc; -{ - DB *db; - DBT key, content; - char keybuf[2049]; - char contentbuf[2049]; - char buf[256]; - int i; - HASHINFO info; - - info.bsize = 1024; - info.ffactor = 5; - info.nelem = 1; - info.cachesize = NULL; -#ifdef HASH_ID_PROGRAM_SPECIFIED - info.hash_id = HASH_ID_PROGRAM_SPECIFIED; - info.hash_func = my_hash; -#else - info.hash = my_hash; -#endif - info.lorder = 0; - if (!(db = dbopen("bigtest", O_RDWR | O_CREAT, 0644, DB_HASH, &info))) { - sprintf(buf, "dbopen: failed on file bigtest"); - perror(buf); - exit(1); - } - srandom(17); - key.data = keybuf; - content.data = contentbuf; - bzero(keybuf, sizeof(keybuf)); - bzero(contentbuf, sizeof(contentbuf)); - for (i=1; i <= 500; i++) { - key.size = 128 + (random()&1023); - content.size = 128 + (random()&1023); -/* printf("%d: Key size %d, data size %d\n", i, key.size, - content.size); */ - sprintf(keybuf, "Key #%d", i); - sprintf(contentbuf, "Contents #%d", i); - if ((db->put)(db, &key, &content, R_NOOVERWRITE)) { - sprintf(buf, "dbm_store #%d", i); - perror(buf); - } - } - if ((db->close)(db)) { - perror("closing hash file"); - exit(1); - } - exit(0); -} - - - diff --git a/lib/libc/db/test/hash.tests/makedb.sh b/lib/libc/db/test/hash.tests/makedb.sh deleted file mode 100644 index f28e281..0000000 --- a/lib/libc/db/test/hash.tests/makedb.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# -# @(#)makedb.sh 8.1 (Berkeley) 6/4/93 - -awk '{i++; print $0; print i;}' /usr/share/dict/words > WORDS -ls /bin /usr/bin /usr/ucb /etc | egrep '^(...|....|.....|......)$' | \ -sort | uniq | \ -awk '{ - printf "%s\n", $0 - for (i = 0; i < 1000; i++) - printf "%s+", $0 - printf "\n" -}' > LONG.DATA diff --git a/lib/libc/db/test/hash.tests/tcreat3.c b/lib/libc/db/test/hash.tests/tcreat3.c deleted file mode 100644 index 31211c5..0000000 --- a/lib/libc/db/test/hash.tests/tcreat3.c +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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) 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)tcreat3.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#include -#include -#include -#include - -#define INITIAL 25000 -#define MAXWORDS 25000 /* # of elements in search table */ - -char wp1[8192]; -char wp2[8192]; -main(argc, argv) -char **argv; -{ - DBT item, key; - DB *dbp; - HASHINFO ctl; - FILE *fp; - int trash; - - int i = 0; - - argv++; - ctl.hash = NULL; - ctl.bsize = atoi(*argv++); - ctl.ffactor = atoi(*argv++); - ctl.nelem = atoi(*argv++); - ctl.lorder = 0; - if (!(dbp = dbopen( "hashtest", - O_CREAT|O_TRUNC|O_RDWR, 0600, DB_HASH, &ctl))){ - /* create table */ - fprintf(stderr, "cannot create: hash table (size %d)\n", - INITIAL); - exit(1); - } - - key.data = wp1; - item.data = wp2; - while ( fgets(wp1, 8192, stdin) && - fgets(wp2, 8192, stdin) && - i++ < MAXWORDS) { -/* -* put info in structure, and structure in the item -*/ - key.size = strlen(wp1); - item.size = strlen(wp2); - -/* - * enter key/data pair into the table - */ - if ((dbp->put)(dbp, &key, &item, R_NOOVERWRITE) != NULL) { - fprintf(stderr, "cannot enter: key %s\n", - item.data); - exit(1); - } - } - - (dbp->close)(dbp); - exit(0); -} diff --git a/lib/libc/db/test/hash.tests/tdel.c b/lib/libc/db/test/hash.tests/tdel.c deleted file mode 100644 index fb99431..0000000 --- a/lib/libc/db/test/hash.tests/tdel.c +++ /dev/null @@ -1,122 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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) 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)tdel.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#include -#include -#include -#include - -#define INITIAL 25000 -#define MAXWORDS 25000 /* # of elements in search table */ - -/* Usage: thash pagesize fillfactor file */ -char wp1[8192]; -char wp2[8192]; -main(argc, argv) -char **argv; -{ - DBT item, key; - DB *dbp; - HASHINFO ctl; - FILE *fp; - int stat; - - int i = 0; - - argv++; - ctl.nelem = INITIAL; - ctl.hash = NULL; - ctl.bsize = atoi(*argv++); - ctl.ffactor = atoi(*argv++); - ctl.cachesize = 1024 * 1024; /* 1 MEG */ - ctl.lorder = 0; - argc -= 2; - if (!(dbp = dbopen( NULL, O_CREAT|O_RDWR, 0400, DB_HASH, &ctl))) { - /* create table */ - fprintf(stderr, "cannot create: hash table size %d)\n", - INITIAL); - exit(1); - } - - key.data = wp1; - item.data = wp2; - while ( fgets(wp1, 8192, stdin) && - fgets(wp2, 8192, stdin) && - i++ < MAXWORDS) { -/* -* put info in structure, and structure in the item -*/ - key.size = strlen(wp1); - item.size = strlen(wp2); - -/* - * enter key/data pair into the table - */ - if ((dbp->put)(dbp, &key, &item, R_NOOVERWRITE) != NULL) { - fprintf(stderr, "cannot enter: key %s\n", - item.data); - exit(1); - } - } - - if ( --argc ) { - fp = fopen ( argv[0], "r"); - i = 0; - while ( fgets(wp1, 8192, fp) && - fgets(wp2, 8192, fp) && - i++ < MAXWORDS) { - key.size = strlen(wp1); - stat = (dbp->del)(dbp, &key, 0); - if (stat) { - fprintf ( stderr, "Error retrieving %s\n", key.data ); - exit(1); - } - } - fclose(fp); - } - (dbp->close)(dbp); - exit(0); -} diff --git a/lib/libc/db/test/hash.tests/testit b/lib/libc/db/test/hash.tests/testit deleted file mode 100644 index 039457a..0000000 --- a/lib/libc/db/test/hash.tests/testit +++ /dev/null @@ -1,147 +0,0 @@ -#!/bin/csh -f -# -# @(#)testit 8.1 (Berkeley) 6/4/93 -# - -echo "" -echo "PAGE FILL " -set name=WORDS - set i = 256 - foreach j ( 11 14 21 ) - thash4 $i $j 25000 65536 $name < $name - end - set i = 512 - foreach j ( 21 28 43 ) - thash4 $i $j 25000 65536 $name < $name - end - set i = 1024 - foreach j ( 43 57 85 ) - thash4 $i $j 25000 65536 $name < $name - end - set i = 2048 - foreach j ( 85 114 171 ) - thash4 $i $j 25000 65536 $name < $name - end - set i = 4096 - foreach j ( 171 228 341 ) - thash4 $i $j 25000 65536 $name < $name - end - set i = 8192 - foreach j ( 341 455 683 ) - thash4 $i $j 25000 65536 $name < $name - end - echo "PAGE FILL " - set i = 256 - foreach j ( 11 14 21 ) - echo "$i"_"$j" - tcreat3 $i $j 25000 $name < $name - tread2 65536 < $name - tverify $name < $name - tseq > /dev/null - tdel $i $j $name < $name - end - set i = 512 - foreach j ( 21 28 43 ) - echo "$i"_"$j" - tcreat3 $i $j 25000 $name < $name - tread2 65536 < $name - tverify $name < $name - tseq > /dev/null - tdel $i $j $name < $name - end - set i = 1024 - foreach j ( 43 57 85 ) - echo "$i"_"$j" - tcreat3 $i $j 25000 $name < $name - tread2 65536 < $name - tverify $name < $name - tseq > /dev/null - tdel $i $j $name < $name - end - set i = 2048 - foreach j ( 85 114 171 ) - echo "$i"_"$j" - tcreat3 $i $j 25000 $name < $name - tread2 65536 < $name - tverify $name < $name - tseq > /dev/null - tdel $i $j $name < $name - end - set i = 4096 - foreach j ( 171 228 341 ) - echo "$i"_"$j" - tcreat3 $i $j 25000 $name < $name - tread2 65536 < $name - tverify $name < $name - tseq > /dev/null - tdel $i $j $name < $name - end - set i = 8192 - foreach j ( 341 455 683 ) - echo "$i"_"$j" - tcreat3 $i $j 25000 $name < $name - tread2 65536 < $name - tverify $name < $name - tseq > /dev/null - tdel $i $j $name < $name - end -set name=LONG.DATA - set i = 1024 - foreach j ( 1 2 4 ) - echo thash4 $i $j 600 65536 $name - thash4 $i $j 600 65536 $name < $name - end - - set i = 2048 - foreach j ( 1 2 4 ) - echo thash4 $i $j 600 65536 $name - thash4 $i $j 600 65536 $name < $name - end - set i = 4096 - foreach j ( 1 2 4 ) - echo thash4 $i $j 600 65536 $name - thash4 $i $j 600 65536 $name < $name - end - set i = 8192 - foreach j ( 2 4 8 ) - echo thash4 $i $j 600 65536 $name - thash4 $i $j 600 65536 $name < $name - end - echo "PAGE FILL " - set i = 1024 - foreach j ( 1 2 4 ) - echo "$i"_"$j" - tcreat3 $i $j 600 $name < $name - tread2 65536 < $name - tverify $name < $name - tseq > /dev/null - tdel $i $j $name < $name - end - set i = 2048 - foreach j ( 1 2 4 ) - echo "$i"_"$j" - tcreat3 $i $j 600 $name < $name - tread2 65536 < $name - tverify $name < $name - tseq > /dev/null - tdel $i $j $name < $name - end - set i = 4096 - foreach j ( 1 2 4 ) - echo "$i"_"$j" - tcreat3 $i $j 600 $name < $name - tread2 65536 < $name - tverify $name < $name - tseq > /dev/null - tdel $i $j $name < $name - end - set i = 8192 - foreach j ( 2 4 8 ) - echo "$i"_"$j" - tcreat3 $i $j 600 $name < $name - tread2 65536 < $name - tverify $name < $name - tseq > /dev/null - tdel $i $j $name < $name - end -driver2 diff --git a/lib/libc/db/test/hash.tests/thash4.c b/lib/libc/db/test/hash.tests/thash4.c deleted file mode 100644 index 952dccb..0000000 --- a/lib/libc/db/test/hash.tests/thash4.c +++ /dev/null @@ -1,132 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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) 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)thash4.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#include -#include -#include -#include -#include -#include - -#define INITIAL 25000 -#define MAXWORDS 25000 /* # of elements in search table */ - -/* Usage: thash pagesize fillfactor file */ -char wp1[8192]; -char wp2[8192]; -main(argc, argv) -char **argv; -{ - DBT item, key, res; - DB *dbp; - HASHINFO ctl; - FILE *fp; - int stat; - time_t t; - - int i = 0; - - argv++; - ctl.hash = NULL; - ctl.bsize = atoi(*argv++); - ctl.ffactor = atoi(*argv++); - ctl.nelem = atoi(*argv++); - ctl.cachesize = atoi(*argv++); - ctl.lorder = 0; - if (!(dbp = dbopen( NULL, O_CREAT|O_RDWR, 0400, DB_HASH, &ctl))) { - /* create table */ - fprintf(stderr, "cannot create: hash table size %d)\n", - INITIAL); - fprintf(stderr, "\terrno: %d\n", errno); - exit(1); - } - - key.data = wp1; - item.data = wp2; - while ( fgets(wp1, 8192, stdin) && - fgets(wp2, 8192, stdin) && - i++ < MAXWORDS) { -/* -* put info in structure, and structure in the item -*/ - key.size = strlen(wp1); - item.size = strlen(wp2); - -/* - * enter key/data pair into the table - */ - if ((dbp->put)(dbp, &key, &item, R_NOOVERWRITE) != NULL) { - fprintf(stderr, "cannot enter: key %s\n", - item.data); - fprintf(stderr, "\terrno: %d\n", errno); - exit(1); - } - } - - if ( --argc ) { - fp = fopen ( argv[0], "r"); - i = 0; - while ( fgets(wp1, 256, fp) && - fgets(wp2, 8192, fp) && - i++ < MAXWORDS) { - - key.size = strlen(wp1); - stat = (dbp->get)(dbp, &key, &res, 0); - if (stat < 0 ) { - fprintf ( stderr, "Error retrieving %s\n", key.data ); - fprintf(stderr, "\terrno: %d\n", errno); - exit(1); - } else if ( stat > 0 ) { - fprintf ( stderr, "%s not found\n", key.data ); - fprintf(stderr, "\terrno: %d\n", errno); - exit(1); - } - } - fclose(fp); - } - dbp->close(dbp); - exit(0); -} diff --git a/lib/libc/db/test/hash.tests/tread2.c b/lib/libc/db/test/hash.tests/tread2.c deleted file mode 100644 index 8f01556..0000000 --- a/lib/libc/db/test/hash.tests/tread2.c +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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) 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)tread2.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#include -#include -#include -#include - -#define INITIAL 25000 -#define MAXWORDS 25000 /* # of elements in search table */ - -typedef struct { /* info to be stored */ - int num, siz; -} info; - -char wp1[8192]; -char wp2[8192]; -main(argc, argv) -char **argv; -{ - DBT item, key, res; - DB *dbp; - HASHINFO ctl; - int stat; - - int i = 0; - - ctl.nelem = INITIAL; - ctl.hash = NULL; - ctl.bsize = 64; - ctl.ffactor = 1; - ctl.cachesize = atoi(*argv++); - ctl.lorder = 0; - if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, &ctl))) { - /* create table */ - fprintf(stderr, "cannot open: hash table\n" ); - exit(1); - } - - key.data = wp1; - item.data = wp2; - while ( fgets(wp1, 8192, stdin) && - fgets(wp2, 8192, stdin) && - i++ < MAXWORDS) { -/* -* put info in structure, and structure in the item -*/ - key.size = strlen(wp1); - item.size = strlen(wp2); - - stat = (dbp->get)(dbp, &key, &res,0); - if (stat < 0) { - fprintf ( stderr, "Error retrieving %s\n", key.data ); - exit(1); - } else if ( stat > 0 ) { - fprintf ( stderr, "%s not found\n", key.data ); - exit(1); - } - } - (dbp->close)(dbp); - exit(0); -} diff --git a/lib/libc/db/test/hash.tests/tseq.c b/lib/libc/db/test/hash.tests/tseq.c deleted file mode 100644 index f41c172..0000000 --- a/lib/libc/db/test/hash.tests/tseq.c +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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) 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)tseq.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#include -#include -#include -#include - -#define INITIAL 25000 -#define MAXWORDS 25000 /* # of elements in search table */ - - -char wp[8192]; -char cp[8192]; -main(argc, argv) -char **argv; -{ - DBT item, key, res; - DB *dbp; - FILE *fp; - int stat; - - if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, NULL))) { - /* create table */ - fprintf(stderr, "cannot open: hash table\n" ); - exit(1); - } - -/* -* put info in structure, and structure in the item -*/ - for ( stat = (dbp->seq) (dbp, &res, &item, 1 ); - stat == 0; - stat = (dbp->seq) (dbp, &res, &item, 0 ) ) { - - bcopy ( res.data, wp, res.size ); - wp[res.size] = 0; - bcopy ( item.data, cp, item.size ); - cp[item.size] = 0; - - printf ( "%s %s\n", wp, cp ); - } - (dbp->close)(dbp); - exit(0); -} diff --git a/lib/libc/db/test/hash.tests/tverify.c b/lib/libc/db/test/hash.tests/tverify.c deleted file mode 100644 index ac5d2f9..0000000 --- a/lib/libc/db/test/hash.tests/tverify.c +++ /dev/null @@ -1,107 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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) 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)tverify.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#include -#include -#include -#include - -#define INITIAL 25000 -#define MAXWORDS 25000 /* # of elements in search table */ - -typedef struct { /* info to be stored */ - int num, siz; -} info; - -char wp1[8192]; -char wp2[8192]; -main(argc, argv) -char **argv; -{ - DBT key, res; - DB *dbp; - HASHINFO ctl; - int trash; - int stat; - - int i = 0; - - ctl.nelem = INITIAL; - ctl.hash = NULL; - ctl.bsize = 64; - ctl.ffactor = 1; - ctl.cachesize = 1024 * 1024; /* 1 MEG */ - ctl.lorder = 0; - if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, &ctl))) { - /* create table */ - fprintf(stderr, "cannot open: hash table\n" ); - exit(1); - } - - key.data = wp1; - while ( fgets(wp1, 8192, stdin) && - fgets(wp2, 8192, stdin) && - i++ < MAXWORDS) { -/* -* put info in structure, and structure in the item -*/ - key.size = strlen(wp1); - - stat = (dbp->get)(dbp, &key, &res,0); - if (stat < 0) { - fprintf ( stderr, "Error retrieving %s\n", key.data ); - exit(1); - } else if ( stat > 0 ) { - fprintf ( stderr, "%s not found\n", key.data ); - exit(1); - } - if ( memcmp ( res.data, wp2, res.size ) ) { - fprintf ( stderr, "data for %s is incorrect. Data was %s. Should have been %s\n", key.data, res.data, wp2 ); - } - } - (dbp->close)(dbp); - exit(0); -} diff --git a/lib/libc/db/test/run.test b/lib/libc/db/test/run.test deleted file mode 100644 index 52b74c3..0000000 --- a/lib/libc/db/test/run.test +++ /dev/null @@ -1,705 +0,0 @@ -#!/bin/sh - -# -# @(#)run.test 8.10 (Berkeley) 7/26/94 -# - -# db regression tests -main() -{ - - PROG=./dbtest - TMP1=t1 - TMP2=t2 - TMP3=t3 - - if [ -f /usr/share/dict/words ]; then - DICT=/usr/share/dict/words - elif [ -f /usr/dict/words ]; then - DICT=/usr/dict/words - else - echo 'run.test: no dictionary' - exit 1 - fi - - if [ $# -eq 0 ]; then - for t in 1 2 3 4 5 6 7 8 9 10 11 12 13 20; do - test$t - done - else - while [ $# -gt 0 ] - do case "$1" in - test*) - $1;; - [0-9]*) - test$1;; - btree) - for t in 1 2 3 7 8 9 10 12 13; do - test$t - done;; - hash) - for t in 1 2 3 8 13 20; do - test$t - done;; - recno) - for t in 1 2 3 4 5 6 7 10 11; do - test$t - done;; - *) - echo "run.test: unknown test $1" - echo "usage: run.test test# | type" - exit 1 - esac - shift - done - fi - rm -f $TMP1 $TMP2 $TMP3 - exit 0 -} - -# Take the first hundred entries in the dictionary, and make them -# be key/data pairs. -test1() -{ - echo "Test 1: btree, hash: small key, small data pairs" - sed 200q $DICT > $TMP1 - for type in btree hash; do - rm -f $TMP2 $TMP3 - for i in `sed 200q $DICT`; do - echo p - echo k$i - echo d$i - echo g - echo k$i - done > $TMP2 - $PROG -o $TMP3 $type $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test1: type $type: failed" - exit 1 - fi - done - echo "Test 1: recno: small key, small data pairs" - rm -f $TMP2 $TMP3 - sed 200q $DICT | - awk '{ - ++i; - printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i); - }' > $TMP2 - $PROG -o $TMP3 recno $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test1: type recno: failed" - exit 1 - fi -} - -# Take the first 200 entries in the dictionary, and give them -# each a medium size data entry. -test2() -{ - echo "Test 2: btree, hash: small key, medium data pairs" - mdata=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz - echo $mdata | - awk '{ for (i = 1; i < 201; ++i) print $0 }' > $TMP1 - for type in hash btree; do - rm -f $TMP2 $TMP3 - for i in `sed 200q $DICT`; do - echo p - echo k$i - echo d$mdata - echo g - echo k$i - done > $TMP2 - $PROG -o $TMP3 $type $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test2: type $type: failed" - exit 1 - fi - done - echo "Test 2: recno: small key, medium data pairs" - rm -f $TMP2 $TMP3 - echo $mdata | - awk '{ for (i = 1; i < 201; ++i) - printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i); - }' > $TMP2 - $PROG -o $TMP3 recno $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test2: type recno: failed" - exit 1 - fi -} - -# Insert the programs in /bin with their paths as their keys. -test3() -{ - echo "Test 3: hash: small key, big data pairs" - rm -f $TMP1 - (find /bin -type f -print | xargs cat) > $TMP1 - for type in hash; do - rm -f $TMP2 $TMP3 - for i in `find /bin -type f -print`; do - echo p - echo k$i - echo D$i - echo g - echo k$i - done > $TMP2 - $PROG -o $TMP3 $type $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test3: $type: failed" - exit 1 - fi - done - echo "Test 3: btree: small key, big data pairs" - for psize in 512 16384 65536; do - echo " page size $psize" - for type in btree; do - rm -f $TMP2 $TMP3 - for i in `find /bin -type f -print`; do - echo p - echo k$i - echo D$i - echo g - echo k$i - done > $TMP2 - $PROG -i psize=$psize -o $TMP3 $type $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test3: $type: page size $psize: failed" - exit 1 - fi - done - done - echo "Test 3: recno: big data pairs" - rm -f $TMP2 $TMP3 - find /bin -type f -print | - awk '{ - ++i; - printf("p\nk%d\nD%s\ng\nk%d\n", i, $0, i); - }' > $TMP2 - for psize in 512 16384 65536; do - echo " page size $psize" - $PROG -i psize=$psize -o $TMP3 recno $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test3: recno: page size $psize: failed" - exit 1 - fi - done -} - -# Do random recno entries. -test4() -{ - echo "Test 4: recno: random entries" - echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | - awk '{ - for (i = 37; i <= 37 + 88 * 17; i += 17) { - if (i % 41) - s = substr($0, 1, i % 41); - else - s = substr($0, 1); - printf("input key %d: %s\n", i, s); - } - for (i = 1; i <= 15; ++i) { - if (i % 41) - s = substr($0, 1, i % 41); - else - s = substr($0, 1); - printf("input key %d: %s\n", i, s); - } - for (i = 19234; i <= 19234 + 61 * 27; i += 27) { - if (i % 41) - s = substr($0, 1, i % 41); - else - s = substr($0, 1); - printf("input key %d: %s\n", i, s); - } - exit - }' > $TMP1 - rm -f $TMP2 $TMP3 - cat $TMP1 | - awk 'BEGIN { - i = 37; - incr = 17; - } - { - printf("p\nk%d\nd%s\n", i, $0); - if (i == 19234 + 61 * 27) - exit; - if (i == 37 + 88 * 17) { - i = 1; - incr = 1; - } else if (i == 15) { - i = 19234; - incr = 27; - } else - i += incr; - } - END { - for (i = 37; i <= 37 + 88 * 17; i += 17) - printf("g\nk%d\n", i); - for (i = 1; i <= 15; ++i) - printf("g\nk%d\n", i); - for (i = 19234; i <= 19234 + 61 * 27; i += 27) - printf("g\nk%d\n", i); - }' > $TMP2 - $PROG -o $TMP3 recno $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test4: type recno: failed" - exit 1 - fi -} - -# Do reverse order recno entries. -test5() -{ - echo "Test 5: recno: reverse order entries" - echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | - awk ' { - for (i = 1500; i; --i) { - if (i % 34) - s = substr($0, 1, i % 34); - else - s = substr($0, 1); - printf("input key %d: %s\n", i, s); - } - exit; - }' > $TMP1 - rm -f $TMP2 $TMP3 - cat $TMP1 | - awk 'BEGIN { - i = 1500; - } - { - printf("p\nk%d\nd%s\n", i, $0); - --i; - } - END { - for (i = 1500; i; --i) - printf("g\nk%d\n", i); - }' > $TMP2 - $PROG -o $TMP3 recno $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test5: type recno: failed" - exit 1 - fi -} - -# Do alternating order recno entries. -test6() -{ - echo "Test 6: recno: alternating order entries" - echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | - awk ' { - for (i = 1; i < 1200; i += 2) { - if (i % 34) - s = substr($0, 1, i % 34); - else - s = substr($0, 1); - printf("input key %d: %s\n", i, s); - } - for (i = 2; i < 1200; i += 2) { - if (i % 34) - s = substr($0, 1, i % 34); - else - s = substr($0, 1); - printf("input key %d: %s\n", i, s); - } - exit; - }' > $TMP1 - rm -f $TMP2 $TMP3 - cat $TMP1 | - awk 'BEGIN { - i = 1; - even = 0; - } - { - printf("p\nk%d\nd%s\n", i, $0); - i += 2; - if (i >= 1200) { - if (even == 1) - exit; - even = 1; - i = 2; - } - } - END { - for (i = 1; i < 1200; ++i) - printf("g\nk%d\n", i); - }' > $TMP2 - $PROG -o $TMP3 recno $TMP2 - sort -o $TMP1 $TMP1 - sort -o $TMP3 $TMP3 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test6: type recno: failed" - exit 1 - fi -} - -# Delete cursor record -test7() -{ - echo "Test 7: btree, recno: delete cursor record" - echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | - awk '{ - for (i = 1; i <= 120; ++i) - printf("%05d: input key %d: %s\n", i, i, $0); - printf("%05d: input key %d: %s\n", 120, 120, $0); - printf("seq failed, no such key\n"); - printf("%05d: input key %d: %s\n", 1, 1, $0); - printf("%05d: input key %d: %s\n", 2, 2, $0); - exit; - }' > $TMP1 - rm -f $TMP2 $TMP3 - - for type in btree recno; do - cat $TMP1 | - awk '{ - if (i == 120) - exit; - printf("p\nk%d\nd%s\n", ++i, $0); - } - END { - printf("fR_NEXT\n"); - for (i = 1; i <= 120; ++i) - printf("s\n"); - printf("fR_CURSOR\ns\nk120\n"); - printf("r\n"); - printf("fR_NEXT\ns\n"); - printf("fR_CURSOR\ns\nk1\n"); - printf("r\n"); - printf("fR_FIRST\ns\n"); - }' > $TMP2 - $PROG -o $TMP3 recno $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test7: type $type: failed" - exit 1 - fi - done -} - -# Make sure that overflow pages are reused. -test8() -{ - echo "Test 8: btree, hash: repeated small key, big data pairs" - rm -f $TMP1 - echo "" | - awk 'BEGIN { - for (i = 1; i <= 10; ++i) { - printf("p\nkkey1\nD/bin/sh\n"); - printf("p\nkkey2\nD/bin/csh\n"); - if (i % 8 == 0) { - printf("c\nkkey2\nD/bin/csh\n"); - printf("c\nkkey1\nD/bin/sh\n"); - printf("e\t%d of 10 (comparison)\n", i); - } else - printf("e\t%d of 10 \n", i); - printf("r\nkkey1\nr\nkkey2\n"); - } - }' > $TMP1 - $PROG btree $TMP1 -# $PROG hash $TMP1 - # No explicit test for success. -} - -# Test btree duplicate keys -test9() -{ - echo "Test 9: btree: duplicate keys" - echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | - awk '{ - for (i = 1; i <= 543; ++i) - printf("%05d: input key %d: %s\n", i, i, $0); - exit; - }' > $TMP1 - rm -f $TMP2 $TMP3 - - for type in btree; do - cat $TMP1 | - awk '{ - if (i++ % 2) - printf("p\nkduplicatekey\nd%s\n", $0); - else - printf("p\nkunique%dkey\nd%s\n", i, $0); - } - END { - printf("o\n"); - }' > $TMP2 - $PROG -iflags=1 -o $TMP3 $type $TMP2 - sort -o $TMP3 $TMP3 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test9: type $type: failed" - exit 1 - fi - done -} - -# Test use of cursor flags without initialization -test10() -{ - echo "Test 10: btree, recno: test cursor flag use" - echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | - awk '{ - for (i = 1; i <= 20; ++i) - printf("%05d: input key %d: %s\n", i, i, $0); - exit; - }' > $TMP1 - rm -f $TMP2 $TMP3 - - # Test that R_CURSOR doesn't succeed before cursor initialized - for type in btree recno; do - cat $TMP1 | - awk '{ - if (i == 10) - exit; - printf("p\nk%d\nd%s\n", ++i, $0); - } - END { - printf("fR_CURSOR\nr\n"); - printf("eR_CURSOR SHOULD HAVE FAILED\n"); - }' > $TMP2 - $PROG -o $TMP3 $type $TMP2 > /dev/null 2>&1 - if [ -s $TMP3 ] ; then - echo "Test 10: delete: R_CURSOR SHOULD HAVE FAILED" - exit 1 - fi - done - for type in btree recno; do - cat $TMP1 | - awk '{ - if (i == 10) - exit; - printf("p\nk%d\nd%s\n", ++i, $0); - } - END { - printf("fR_CURSOR\np\nk1\ndsome data\n"); - printf("eR_CURSOR SHOULD HAVE FAILED\n"); - }' > $TMP2 - $PROG -o $TMP3 $type $TMP2 > /dev/null 2>&1 - if [ -s $TMP3 ] ; then - echo "Test 10: put: R_CURSOR SHOULD HAVE FAILED" - exit 1 - fi - done -} - -# Test insert in reverse order. -test11() -{ - echo "Test 11: recno: reverse order insert" - echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | - awk '{ - for (i = 1; i <= 779; ++i) - printf("%05d: input key %d: %s\n", i, i, $0); - exit; - }' > $TMP1 - rm -f $TMP2 $TMP3 - - for type in recno; do - cat $TMP1 | - awk '{ - if (i == 0) { - i = 1; - printf("p\nk1\nd%s\n", $0); - printf("%s\n", "fR_IBEFORE"); - } else - printf("p\nk1\nd%s\n", $0); - } - END { - printf("or\n"); - }' > $TMP2 - $PROG -o $TMP3 $type $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test11: type $type: failed" - exit 1 - fi - done -} - -# Take the first 20000 entries in the dictionary, reverse them, and give -# them each a small size data entry. Use a small page size to make sure -# the btree split code gets hammered. -test12() -{ - echo "Test 12: btree: lots of keys, small page size" - mdata=abcdefghijklmnopqrstuvwxy - echo $mdata | - awk '{ for (i = 1; i < 20001; ++i) print $0 }' > $TMP1 - for type in btree; do - rm -f $TMP2 $TMP3 - for i in `sed 20000q $DICT | rev`; do - echo p - echo k$i - echo d$mdata - echo g - echo k$i - done > $TMP2 - $PROG -i psize=512 -o $TMP3 $type $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test12: type $type: failed" - exit 1 - fi - done -} - -# Test different byte orders. -test13() -{ - echo "Test 13: btree, hash: differing byte orders" - sed 50q $DICT > $TMP1 - for order in 1234 4321; do - for type in btree hash; do - rm -f byte.file $TMP2 $TMP3 - for i in `sed 50q $DICT`; do - echo p - echo k$i - echo d$i - echo g - echo k$i - done > $TMP2 - $PROG -ilorder=$order -f byte.file -o $TMP3 $type $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test13: $type/$order put failed" - exit 1 - fi - for i in `sed 50q $DICT`; do - echo g - echo k$i - done > $TMP2 - $PROG -s \ - -ilorder=$order -f byte.file -o $TMP3 $type $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test13: $type/$order get failed" - exit 1 - fi - done - done - rm -f byte.file -} - -# Try a variety of bucketsizes and fill factors for hashing -test20() -{ - echo\ - "Test 20: hash: bucketsize, fill factor; nelem 25000 cachesize 65536" - echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | - awk '{ - for (i = 1; i <= 10000; ++i) { - if (i % 34) - s = substr($0, 1, i % 34); - else - s = substr($0, 1); - printf("%s\n", s); - } - exit; - }' > $TMP1 - sed 10000q $DICT | - awk 'BEGIN { - ds="abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" - } - { - if (++i % 34) - s = substr(ds, 1, i % 34); - else - s = substr(ds, 1); - printf("p\nk%s\nd%s\n", $0, s); - }' > $TMP2 - sed 10000q $DICT | - awk '{ - ++i; - printf("g\nk%s\n", $0); - }' >> $TMP2 - bsize=256 - for ffactor in 11 14 21; do - echo " bucketsize $bsize, fill factor $ffactor" - $PROG -o$TMP3 \ - -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ - hash $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test20: type hash:\ -bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" - exit 1 - fi - done - bsize=512 - for ffactor in 21 28 43; do - echo " bucketsize $bsize, fill factor $ffactor" - $PROG -o$TMP3 \ - -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ - hash $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test20: type hash:\ -bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" - exit 1 - fi - done - bsize=1024 - for ffactor in 43 57 85; do - echo " bucketsize $bsize, fill factor $ffactor" - $PROG -o$TMP3 \ - -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ - hash $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test20: type hash:\ -bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" - exit 1 - fi - done - bsize=2048 - for ffactor in 85 114 171; do - echo " bucketsize $bsize, fill factor $ffactor" - $PROG -o$TMP3 \ - -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ - hash $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test20: type hash:\ -bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" - exit 1 - fi - done - bsize=4096 - for ffactor in 171 228 341; do - echo " bucketsize $bsize, fill factor $ffactor" - $PROG -o$TMP3 \ - -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ - hash $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test20: type hash:\ -bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" - exit 1 - fi - done - bsize=8192 - for ffactor in 341 455 683; do - echo " bucketsize $bsize, fill factor $ffactor" - $PROG -o$TMP3 \ - -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ - hash $TMP2 - if (cmp -s $TMP1 $TMP3) ; then : - else - echo "test20: type hash:\ -bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" - exit 1 - fi - done -} - -main $* diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc deleted file mode 100644 index 2722265..0000000 --- a/lib/libc/gen/Makefile.inc +++ /dev/null @@ -1,122 +0,0 @@ -# @(#)Makefile.inc 8.6 (Berkeley) 5/4/95 -# $FreeBSD$ - -# machine-independent gen sources -.PATH: ${.CURDIR}/../libc/${MACHINE_ARCH}/gen ${.CURDIR}/../libc/gen - -SRCS+= _rand48.c _spinlock_stub.c alarm.c arc4random.c assert.c \ - clock.c closedir.c confstr.c \ - crypt.c ctermid.c daemon.c devname.c disklabel.c \ - dlfcn.c drand48.c erand48.c err.c errlst.c \ - exec.c fnmatch.c fstab.c ftok.c fts.c getbootfile.c getbsize.c \ - getcap.c getcwd.c getdomainname.c getgrent.c getgrouplist.c \ - gethostname.c getloadavg.c getlogin.c getmntinfo.c getnetgrent.c \ - getobjformat.c getosreldate.c getpagesize.c \ - getpass.c getpwent.c getttyent.c \ - getusershell.c getvfsbyname.c getvfsent.c glob.c \ - initgroups.c isatty.c jrand48.c lcong48.c \ - lockf.c lrand48.c mrand48.c msgctl.c \ - msgget.c msgrcv.c msgsnd.c nice.c \ - nlist.c nrand48.c ntp_gettime.c opendir.c \ - pause.c popen.c psignal.c pwcache.c raise.c readdir.c rewinddir.c \ - scandir.c seed48.c seekdir.c semconfig.c semctl.c semget.c semop.c \ - setdomainname.c sethostname.c setjmperr.c setmode.c shmat.c \ - shmctl.c shmdt.c shmget.c siginterrupt.c siglist.c signal.c \ - sigsetops.c sleep.c srand48.c stringlist.c \ - sysconf.c sysctl.c sysctlbyname.c \ - syslog.c telldir.c termios.c time.c times.c timezone.c ttyname.c \ - ttyslot.c ualarm.c uname.c unvis.c usleep.c utime.c valloc.c vis.c \ - wait.c wait3.c waitpid.c - -# machine-dependent gen sources -.include "${.CURDIR}/../libc/${MACHINE_ARCH}/gen/Makefile.inc" - -.if ${LIB} == "c" -MAN3+= alarm.3 arc4random.3 clock.3 \ - confstr.3 ctermid.3 daemon.3 \ - devname.3 directory.3 dladdr.3 dllockinit.3 dlopen.3 \ - err.3 exec.3 fnmatch.3 frexp.3 ftok.3 fts.3 \ - getbootfile.3 getbsize.3 getcap.3 getcwd.3 \ - getdiskbyname.3 getdomainname.3 getfsent.3 \ - getgrent.3 getgrouplist.3 gethostname.3 getloadavg.3 \ - getmntinfo.3 getnetgrent.3 getobjformat.3 \ - getpagesize.3 getpass.3 getpwent.3 \ - getttyent.3 getusershell.3 getvfsbyname.3 getvfsent.3 \ - glob.3 initgroups.3 isinf.3 \ - ldexp.3 lockf.3 modf.3 msgctl.3 msgget.3 msgrcv.3 msgsnd.3 \ - nice.3 nlist.3 pause.3 popen.3 psignal.3 pwcache.3 \ - raise.3 rand48.3 scandir.3 setjmp.3 setmode.3 siginterrupt.3 \ - signal.3 sigsetops.3 sleep.3 stringlist.3 \ - sysconf.3 sysctl.3 syslog.3 tcgetpgrp.3 \ - tcsendbreak.3 tcsetattr.3 tcsetpgrp.3 time.3 times.3 timezone.3 \ - ttyname.3 tzset.3 ualarm.3 uname.3 unvis.3 usleep.3 utime.3 \ - valloc.3 vis.3 - -MLINKS+=arc4random.3 arc4random_addrandom.3 arc4random.3 arc4random_stir.3 -MLINKS+=crypt.3 des_cipher.3 crypt.3 des_setkey.3 crypt.3 encrypt.3 \ - crypt.3 setkey.3 -MLINKS+=ctermid.3 ctermid_r.3 -MLINKS+=directory.3 closedir.3 directory.3 dirfd.3 directory.3 opendir.3 \ - directory.3 readdir.3 directory.3 rewinddir.3 directory.3 seekdir.3 \ - directory.3 telldir.3 -MLINKS+=dlopen.3 dlclose.3 dlopen.3 dlerror.3 dlopen.3 dlsym.3 -MLINKS+=err.3 err_set_exit.3 err.3 err_set_file.3 err.3 errc.3 err.3 errx.3 \ - err.3 verr.3 err.3 verrc.3 err.3 verrx.3 err.3 vwarn.3 err.3 vwarnc.3 \ - err.3 vwarnx.3 err.3 warnc.3 err.3 warn.3 err.3 warnx.3 -MLINKS+=exec.3 execl.3 exec.3 execle.3 exec.3 execlp.3 exec.3 exect.3 \ - exec.3 execv.3 exec.3 execvp.3 -MLINKS+=fts.3 fts_children.3 fts.3 fts_close.3 fts.3 fts_open.3 \ - fts.3 fts_read.3 fts.3 fts_set.3 -MLINKS+=getcap.3 cgetcap.3 getcap.3 cgetclose.3 getcap.3 cgetent.3 \ - getcap.3 cgetfirst.3 getcap.3 cgetmatch.3 getcap.3 cgetnext.3 \ - getcap.3 cgetnum.3 getcap.3 cgetset.3 getcap.3 cgetstr.3 \ - getcap.3 cgetustr.3 -MLINKS+=getcwd.3 getwd.3 -MLINKS+=getdomainname.3 setdomainname.3 -MLINKS+=getfsent.3 endfsent.3 getfsent.3 getfsfile.3 getfsent.3 getfsspec.3 \ - getfsent.3 getfstype.3 getfsent.3 setfsent.3 -MLINKS+=getgrent.3 endgrent.3 getgrent.3 getgrgid.3 getgrent.3 getgrnam.3 \ - getgrent.3 setgrent.3 getgrent.3 setgroupent.3 -MLINKS+=gethostname.3 sethostname.3 -MLINKS+=getnetgrent.3 endnetgrent.3 getnetgrent.3 innetgr.3 \ - getnetgrent.3 setnetgrent.3 -MLINKS+=getpwent.3 endpwent.3 getpwent.3 getpwnam.3 getpwent.3 getpwuid.3 \ - getpwent.3 setpassent.3 getpwent.3 setpwent.3 getpwent.3 setpwfile.3 -MLINKS+=getttyent.3 endttyent.3 getttyent.3 getttynam.3 \ - getttyent.3 isdialuptty.3 getttyent.3 isnettty.3 \ - getttyent.3 setttyent.3 -MLINKS+=getusershell.3 endusershell.3 getusershell.3 setusershell.3 -MLINKS+=getvfsent.3 endvfsent.3 getvfsent.3 getvfsbytype.3 \ - getvfsent.3 setvfsent.3 getvfsent.3 vfsisloadable.3 \ - getvfsent.3 vfsload.3 -MLINKS+=glob.3 globfree.3 -MLINKS+=isinf.3 isnan.3 isinf.3 isnanf.3 -MLINKS+=popen.3 pclose.3 -MLINKS+=psignal.3 sys_siglist.3 psignal.3 sys_signame.3 -MLINKS+=psignal.3 strsignal.3 psignal.3 sys_siglist.3 psignal.3 sys_signame.3 -MLINKS+=pwcache.3 group_from_gid.3 pwcache.3 user_from_uid.3 -MLINKS+=rand48.3 _rand48.3 rand48.3 drand48.3 rand48.3 erand48.3 \ - rand48.3 jrand48.3 rand48.3 lcong48.3 rand48.3 lrand48.3 \ - rand48.3 mrand48.3 rand48.3 nrand48.3 rand48.3 seed48.3 \ - rand48.3 srand48.3 -MLINKS+=scandir.3 alphasort.3 -MLINKS+=setjmp.3 _longjmp.3 setjmp.3 _setjmp.3 setjmp.3 longjmp.3 \ - setjmp.3 longjmperr.3 setjmp.3 longjmperror.3 \ - setjmp.3 siglongjmp.3 setjmp.3 sigsetjmp.3 -MLINKS+=setmode.3 getmode.3 -MLINKS+=sigsetops.3 sigaddset.3 sigsetops.3 sigdelset.3 \ - sigsetops.3 sigemptyset.3 sigsetops.3 sigfillset.3 \ - sigsetops.3 sigismember.3 -MLINKS+=sysctl.3 sysctlbyname.3 -MLINKS+=syslog.3 closelog.3 syslog.3 openlog.3 syslog.3 setlogmask.3 \ - syslog.3 vsyslog.3 -MLINKS+=tcsendbreak.3 tcdrain.3 tcsendbreak.3 tcflow.3 tcsendbreak.3 tcflush.3 -MLINKS+=tcsetattr.3 cfgetispeed.3 tcsetattr.3 cfgetospeed.3 \ - tcsetattr.3 cfmakeraw.3 tcsetattr.3 cfsetispeed.3 \ - tcsetattr.3 cfsetospeed.3 tcsetattr.3 cfsetspeed.3 \ - tcsetattr.3 tcgetattr.3 -MLINKS+=ttyname.3 isatty.3 ttyname.3 ttyslot.3 -MLINKS+=tzset.3 tzsetwall.3 -MLINKS+=unvis.3 strunvis.3 -MLINKS+=vis.3 strvis.3 vis.3 strvisx.3 -.endif diff --git a/lib/libc/gen/__xuname.c b/lib/libc/gen/__xuname.c deleted file mode 100644 index 944c2dc..0000000 --- a/lib/libc/gen/__xuname.c +++ /dev/null @@ -1,125 +0,0 @@ -/*- - * Copyright (c) 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char sccsid[] = "From: @(#)uname.c 8.1 (Berkeley) 1/4/94";*/ -static const char rcsid[] = - "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -int -uname(name) - struct utsname *name; -{ - int mib[2], rval; - size_t len; - char *p; - int oerrno; - - rval = 0; - - mib[0] = CTL_KERN; - mib[1] = KERN_OSTYPE; - len = sizeof(name->sysname); - oerrno = errno; - if (sysctl(mib, 2, &name->sysname, &len, NULL, 0) == -1) { - if(errno == ENOMEM) - errno = oerrno; - else - rval = -1; - } - name->sysname[sizeof(name->sysname) - 1] = '\0'; - - mib[0] = CTL_KERN; - mib[1] = KERN_HOSTNAME; - len = sizeof(name->nodename); - oerrno = errno; - if (sysctl(mib, 2, &name->nodename, &len, NULL, 0) == -1) { - if(errno == ENOMEM) - errno = oerrno; - else - rval = -1; - } - name->nodename[sizeof(name->nodename) - 1] = '\0'; - - mib[0] = CTL_KERN; - mib[1] = KERN_OSRELEASE; - len = sizeof(name->release); - oerrno = errno; - if (sysctl(mib, 2, &name->release, &len, NULL, 0) == -1) { - if(errno == ENOMEM) - errno = oerrno; - else - rval = -1; - } - name->release[sizeof(name->release) - 1] = '\0'; - - /* The version may have newlines in it, turn them into spaces. */ - mib[0] = CTL_KERN; - mib[1] = KERN_VERSION; - len = sizeof(name->version); - oerrno = errno; - if (sysctl(mib, 2, &name->version, &len, NULL, 0) == -1) { - if (errno == ENOMEM) - errno = oerrno; - else - rval = -1; - } - name->version[sizeof(name->version) - 1] = '\0'; - for (p = name->version; len--; ++p) { - if (*p == '\n' || *p == '\t') { - if (len > 1) - *p = ' '; - else - *p = '\0'; - } - } - - mib[0] = CTL_HW; - mib[1] = HW_MACHINE; - len = sizeof(name->machine); - oerrno = errno; - if (sysctl(mib, 2, &name->machine, &len, NULL, 0) == -1) { - if (errno == ENOMEM) - errno = oerrno; - else - rval = -1; - } - name->machine[sizeof(name->machine) - 1] = '\0'; - return (rval); -} diff --git a/lib/libc/gen/_rand48.c b/lib/libc/gen/_rand48.c deleted file mode 100644 index 990e2c8..0000000 --- a/lib/libc/gen/_rand48.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 1993 Martin Birgmeier - * All rights reserved. - * - * You may redistribute unmodified or modified versions of this source - * code provided that the above copyright notice and this and the - * following conditions are retained. - * - * This software is provided ``as is'', and comes with no warranties - * of any kind. I shall in no event be liable for anything that happens - * to anyone/anything when using this software. - */ - -#include "rand48.h" - -unsigned short _rand48_seed[3] = { - RAND48_SEED_0, - RAND48_SEED_1, - RAND48_SEED_2 -}; -unsigned short _rand48_mult[3] = { - RAND48_MULT_0, - RAND48_MULT_1, - RAND48_MULT_2 -}; -unsigned short _rand48_add = RAND48_ADD; - -void -_dorand48(unsigned short xseed[3]) -{ - unsigned long accu; - unsigned short temp[2]; - - accu = (unsigned long) _rand48_mult[0] * (unsigned long) xseed[0] + - (unsigned long) _rand48_add; - temp[0] = (unsigned short) accu; /* lower 16 bits */ - accu >>= sizeof(unsigned short) * 8; - accu += (unsigned long) _rand48_mult[0] * (unsigned long) xseed[1] + - (unsigned long) _rand48_mult[1] * (unsigned long) xseed[0]; - temp[1] = (unsigned short) accu; /* middle 16 bits */ - accu >>= sizeof(unsigned short) * 8; - accu += _rand48_mult[0] * xseed[2] + _rand48_mult[1] * xseed[1] + _rand48_mult[2] * xseed[0]; - xseed[0] = temp[0]; - xseed[1] = temp[1]; - xseed[2] = (unsigned short) accu; -} diff --git a/lib/libc/gen/_spinlock_stub.c b/lib/libc/gen/_spinlock_stub.c deleted file mode 100644 index e3a800d..0000000 --- a/lib/libc/gen/_spinlock_stub.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 1998 John Birrell . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - * - */ - -#include - -/* Don't build these stubs into libc_r: */ -#ifndef _THREAD_SAFE -#include "spinlock.h" - -/* - * Declare weak references in case the application is not linked - * with libpthread. - */ -#pragma weak _spinlock=_spinlock_stub -#pragma weak _spinlock_debug=_spinlock_debug_stub - -/* - * This function is a stub for the spinlock function in libpthread. - */ -void -_spinlock_stub(spinlock_t *lck) -{ -} - -/* - * This function is a stub for the debug spinlock function in libpthread. - */ -void -_spinlock_debug_stub(spinlock_t *lck, char *fname, int lineno) -{ -} -#endif diff --git a/lib/libc/gen/alarm.3 b/lib/libc/gen/alarm.3 deleted file mode 100644 index 0265180..0000000 --- a/lib/libc/gen/alarm.3 +++ /dev/null @@ -1,96 +0,0 @@ -.\" Copyright (c) 1980, 1991, 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. -.\" -.\" @(#)alarm.3 8.2 (Berkeley) 4/19/94 -.\" $FreeBSD$ -.\" -.Dd April 19, 1994 -.Dt ALARM 3 -.Os BSD 4 -.Sh NAME -.Nm alarm -.Nd set signal timer alarm -.Sh SYNOPSIS -.Fd #include -.Ft unsigned int -.Fn alarm "unsigned int seconds" -.Sh DESCRIPTION -.Bf -symbolic -This interface is made obsolete by setitimer(2). -.Ef -.Pp -The -.Fn alarm -function sets a timer to deliver the signal -.Dv SIGALRM -to the calling process after the specified number of -.Fa seconds . -If an alarm has already been set with -.Fn alarm -but has not been delivered, another call to -.Fn alarm -will supersede the prior call. -The request -.Fn alarm "0" -voids the current -alarm and the signal SIGALRM will not be delivered. -.Pp -Due to -.Xr setitimer 2 -restriction the maximum number of -.Ar seconds -allowed is 100000000. -.Sh RETURN VALUES -.Pp -The return value of -.Fn alarm -is the amount of time left on the timer from a previous call to -.Fn alarm . -If no alarm is currently set, the return value is 0. -.Sh SEE ALSO -.Xr setitimer 2 , -.Xr sigaction 2 , -.Xr sigpause 2 , -.Xr sigvec 2 , -.Xr signal 3 , -.Xr sleep 3 , -.Xr ualarm 3 , -.Xr usleep 3 -.\" .Sh STANDARDS -.\" The -.\" .Fn alarm -.\" function conforms to -.\" .St -p1003.1-90 . -.Sh HISTORY -An -.Fn alarm -function appeared in -.At v7 . diff --git a/lib/libc/gen/alarm.c b/lib/libc/gen/alarm.c deleted file mode 100644 index 7a7dc68..0000000 --- a/lib/libc/gen/alarm.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)alarm.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -/* - * Backwards compatible alarm. - */ -#include -#include - -unsigned int -alarm(secs) - unsigned int secs; -{ - struct itimerval it, oitv; - register struct itimerval *itp = ⁢ - - timerclear(&itp->it_interval); - itp->it_value.tv_sec = secs; - itp->it_value.tv_usec = 0; - if (setitimer(ITIMER_REAL, itp, &oitv) < 0) - return (-1); - if (oitv.it_value.tv_usec) - oitv.it_value.tv_sec++; - return (oitv.it_value.tv_sec); -} diff --git a/lib/libc/gen/arc4random.3 b/lib/libc/gen/arc4random.3 deleted file mode 100644 index e83bb47..0000000 --- a/lib/libc/gen/arc4random.3 +++ /dev/null @@ -1,87 +0,0 @@ -.\" $OpenBSD: arc4random.3,v 1.2 1997/04/27 22:40:25 angelos Exp $ -.\" Copyright 1997 Niels Provos -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by Niels Provos. -.\" 4. The name of the author may not be used to endorse or promote products -.\" derived from this software without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" Manual page, using -mandoc macros -.\" $FreeBSD$ -.\" -.Dd April 15, 1997 -.Dt ARC4RANDOM 3 -.Os -.Sh NAME -.Nm arc4random , -.Nm arc4random_stir , -.Nm arc4random_addrandom -.Nd arc4 random number generator. -.Sh SYNOPSIS -.Fd #include -.Ft u_int32_t -.Fn arc4random "void" -.Ft void -.Fn arc4random_stir "void" -.Ft void -.Fn arc4random_addrandom "unsigned char *dat" "int datlen" -.Sh DESCRIPTION -The -.Fn arc4random -function uses the key stream generator employed by the -arc4 cipher, which uses 8*8 8 bit S-Boxes. -The S-Boxes -can be in about -.if t 2\u\s71700\s10\d -.if n (2**1700) -states. -.Pp -The -.Fn arc4random_stir -function reads data from -.Pa /dev/urandom -and uses it to permute the S-Boxes via -.Fn arc4random_addrandom . -.Pp -There is no need to call -.Fn arc4random_stir -before using -.Fn arc4random , -since -.Fn arc4random -automatically initializes itself. -.Sh SEE ALSO -.Xr rand 3 , -.Xr random 3 , -.Xr srandomdev 3 -.Sh HISTORY -.Pa RC4 -has been designed by RSA Data Security, Inc. -It was posted anonymously -to the USENET and was confirmed to be equivalent by several sources who -had access to the original cipher. -Since -.Pa RC4 -used to be a trade secret, the cipher is now referred to as -.Pa ARC4 . diff --git a/lib/libc/gen/arc4random.c b/lib/libc/gen/arc4random.c deleted file mode 100644 index c0569e5..0000000 --- a/lib/libc/gen/arc4random.c +++ /dev/null @@ -1,172 +0,0 @@ -/* $FreeBSD$ */ - -/* - * Arc4 random number generator for OpenBSD. - * Copyright 1996 David Mazieres . - * - * Modification and redistribution in source and binary forms is - * permitted provided that due credit is given to the author and the - * OpenBSD project (for instance by leaving this copyright notice - * intact). - */ - -/* - * This code is derived from section 17.1 of Applied Cryptography, - * second edition, which describes a stream cipher allegedly - * compatible with RSA Labs "RC4" cipher (the actual description of - * which is a trade secret). The same algorithm is used as a stream - * cipher called "arcfour" in Tatu Ylonen's ssh package. - * - * Here the stream cipher has been modified always to include the time - * when initializing the state. That makes it impossible to - * regenerate the same random sequence twice, so this can't be used - * for encryption, but will generate good random numbers. - * - * RC4 is a registered trademark of RSA Laboratories. - */ - -#include -#include -#include -#include -#include - -struct arc4_stream { - u_int8_t i; - u_int8_t j; - u_int8_t s[256]; -}; - -static int rs_initialized; -static struct arc4_stream rs; - -static inline void -arc4_init(as) - struct arc4_stream *as; -{ - int n; - - for (n = 0; n < 256; n++) - as->s[n] = n; - as->i = 0; - as->j = 0; -} - -static inline void -arc4_addrandom(as, dat, datlen) - struct arc4_stream *as; - u_char *dat; - int datlen; -{ - int n; - u_int8_t si; - - as->i--; - for (n = 0; n < 256; n++) { - as->i = (as->i + 1); - si = as->s[as->i]; - as->j = (as->j + si + dat[n % datlen]); - as->s[as->i] = as->s[as->j]; - as->s[as->j] = si; - } -} - -static void -arc4_stir(as) - struct arc4_stream *as; -{ - int fd; - struct { - struct timeval tv; - pid_t pid; - u_int8_t rnd[128 - sizeof(struct timeval) - sizeof(pid_t)]; - } rdat; - - gettimeofday(&rdat.tv, NULL); - rdat.pid = getpid(); - fd = _open("/dev/urandom", O_RDONLY, 0); - if (fd >= 0) { - (void) _read(fd, rdat.rnd, sizeof(rdat.rnd)); - _close(fd); - } - /* fd < 0? Ah, what the heck. We'll just take whatever was on the - * stack... */ - - arc4_addrandom(as, (void *) &rdat, sizeof(rdat)); -} - -static inline u_int8_t -arc4_getbyte(as) - struct arc4_stream *as; -{ - u_int8_t si, sj; - - as->i = (as->i + 1); - si = as->s[as->i]; - as->j = (as->j + si); - sj = as->s[as->j]; - as->s[as->i] = sj; - as->s[as->j] = si; - return (as->s[(si + sj) & 0xff]); -} - -static inline u_int32_t -arc4_getword(as) - struct arc4_stream *as; -{ - u_int32_t val; - val = arc4_getbyte(as) << 24; - val |= arc4_getbyte(as) << 16; - val |= arc4_getbyte(as) << 8; - val |= arc4_getbyte(as); - return val; -} - -void -arc4random_stir() -{ - if (!rs_initialized) { - arc4_init(&rs); - rs_initialized = 1; - } - arc4_stir(&rs); -} - -void -arc4random_addrandom(dat, datlen) - u_char *dat; - int datlen; -{ - if (!rs_initialized) - arc4random_stir(); - arc4_addrandom(&rs, dat, datlen); -} - -u_int32_t -arc4random() -{ - if (!rs_initialized) - arc4random_stir(); - return arc4_getword(&rs); -} - -#if 0 -/*-------- Test code for i386 --------*/ -#include -#include -int -main(int argc, char **argv) -{ - const int iter = 1000000; - int i; - pctrval v; - - v = rdtsc(); - for (i = 0; i < iter; i++) - arc4random(); - v = rdtsc() - v; - v /= iter; - - printf("%qd cycles\n", v); -} -#endif diff --git a/lib/libc/gen/assert.c b/lib/libc/gen/assert.c deleted file mode 100644 index eb2748c..0000000 --- a/lib/libc/gen/assert.c +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 1992, 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)assert.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -void -__assert(file, line, failedexpr) - const char *file, *failedexpr; - int line; -{ - (void)fprintf(stderr, - "assertion \"%s\" failed: file \"%s\", line %d\n", - failedexpr, file, line); - abort(); - /* NOTREACHED */ -} diff --git a/lib/libc/gen/clock.3 b/lib/libc/gen/clock.3 deleted file mode 100644 index 1d0f8fa..0000000 --- a/lib/libc/gen/clock.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)clock.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt CLOCK 3 -.Os -.Sh NAME -.Nm clock -.Nd determine processor time used -.Sh SYNOPSIS -.Fd #include -.Ft clock_t -.Fn clock void -.Sh DESCRIPTION -The -.Fn clock -function -determines the amount of processor time used since the invocation of the -calling process, measured in -.Dv CLOCKS_PER_SEC Ns 's -of a second. -.Sh RETURN VALUES -The -.Fn clock -function returns the amount of time used unless an error occurs, in which -case the return value is \-1. -.Sh SEE ALSO -.Xr getrusage 2 , -.Xr clocks 7 -.Sh STANDARDS -The -.Fn clock -function conforms to -.St -ansiC . diff --git a/lib/libc/gen/clock.c b/lib/libc/gen/clock.c deleted file mode 100644 index fe867c2..0000000 --- a/lib/libc/gen/clock.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)clock.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -/* - * Convert usec to clock ticks; could do (usec * CLOCKS_PER_SEC) / 1000000, - * but this would overflow if we switch to nanosec. - */ -#define CONVTCK(r) ((r).tv_sec * CLOCKS_PER_SEC \ - + (r).tv_usec / (1000000 / CLOCKS_PER_SEC)) - -clock_t -clock() -{ - struct rusage ru; - - if (getrusage(RUSAGE_SELF, &ru)) - return ((clock_t) -1); - return((clock_t)((CONVTCK(ru.ru_utime) + CONVTCK(ru.ru_stime)))); -} diff --git a/lib/libc/gen/closedir.c b/lib/libc/gen/closedir.c deleted file mode 100644 index 86de88d..0000000 --- a/lib/libc/gen/closedir.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)closedir.c 8.1 (Berkeley) 6/10/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -extern void _reclaim_telldir __P(( const DIR * )); - -/* - * close a directory. - */ -int -closedir(dirp) - register DIR *dirp; -{ - int fd; - - seekdir(dirp, dirp->dd_rewind); /* free seekdir storage */ - fd = dirp->dd_fd; - dirp->dd_fd = -1; - dirp->dd_loc = 0; - free((void *)dirp->dd_buf); - free((void *)dirp); - _reclaim_telldir(dirp); - return(_close(fd)); -} diff --git a/lib/libc/gen/confstr.3 b/lib/libc/gen/confstr.3 deleted file mode 100644 index 6ba8e7c..0000000 --- a/lib/libc/gen/confstr.3 +++ /dev/null @@ -1,126 +0,0 @@ -.\" Copyright (c) 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. -.\" -.\" @(#)confstr.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt CONFSTR 3 -.Os BSD 4 -.Sh NAME -.Nm confstr -.Nd get string-valued configurable variables -.Sh SYNOPSIS -.Fd #include -.Ft size_t -.Fn confstr "int name" "char *buf" "size_t len" -.Sh DESCRIPTION -.Bf -symbolic -This interface is obsoleted by -.Xr sysctl 3 . -.Ef -.Pp -The -.Fn confstr -function provides a method for applications to get configuration -defined string values. -.Pp -The -.Fa name -argument specifies the system variable to be queried. -Symbolic constants for each name value are found in the include file -.Li . -The -.Fa len -argument specifies the size of the buffer referenced by the -argument -.Fa buf . -If -.Fa len -is non-zero, -.Fa buf -is a non-null pointer, and -.Fa name -has a value, up to -.Fa len -\- 1 bytes of the value are copied into the buffer -.Fa buf . -The copied value is always null terminated. -.Pp -The available values are as follows: -.Pp -.Bl -tag -width "123456" -.Pp -.It Li _CS_PATH -Return a value for the -.Ev PATH -environment variable that finds all the standard utilities. -.El -.Sh RETURN VALUES -If the call to -.Fn confstr -is not successful, \-1 is returned and -.Va errno -is set appropriately. -Otherwise, if the variable does not have a configuration defined value, -0 is returned and -.Va errno -is not modified. -Otherwise, the buffer size needed to hold the entire configuration-defined -value is returned. -If this size is greater than the argument -.Fa len , -the string in -.Fa buf -was truncated. -.Sh ERRORS -The -.Fn confstr -function may fail and set -.Va error -for any of the errors specified for the library functions -.Xr malloc 3 -and -.Xr sysctl 3 . -.Pp -In addition, the following errors may be reported: -.Bl -tag -width Er -.It Bq Er EINVAL -The value of the -.Fa name -argument is invalid. -.Sh SEE ALSO -.Xr sysctl 3 -.Sh HISTORY -The -.Fn confstr -function first appeared in -.Bx 4.4 . diff --git a/lib/libc/gen/confstr.c b/lib/libc/gen/confstr.c deleted file mode 100644 index 0a7078e..0000000 --- a/lib/libc/gen/confstr.c +++ /dev/null @@ -1,86 +0,0 @@ -/*- - * Copyright (c) 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)confstr.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#include -#include -#include -#include -#include - -size_t -confstr(name, buf, len) - int name; - char *buf; - size_t len; -{ - size_t tlen; - int mib[2], sverrno; - char *p; - - switch (name) { - case _CS_PATH: - mib[0] = CTL_USER; - mib[1] = USER_CS_PATH; - if (sysctl(mib, 2, NULL, &tlen, NULL, 0) == -1) - return (-1); - if (len != 0 && buf != NULL) { - if ((p = malloc(tlen)) == NULL) - return (-1); - if (sysctl(mib, 2, p, &tlen, NULL, 0) == -1) { - sverrno = errno; - free(p); - errno = sverrno; - return (-1); - } - /* - * POSIX 1003.2 requires partial return of - * the string -- that should be *real* useful. - */ - (void)strncpy(buf, p, len - 1); - buf[len - 1] = '\0'; - free(p); - } - return (tlen + 1); - default: - errno = EINVAL; - return (0); - } - /* NOTREACHED */ -} diff --git a/lib/libc/gen/crypt.c b/lib/libc/gen/crypt.c deleted file mode 100644 index 8012b06..0000000 --- a/lib/libc/gen/crypt.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 1989 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Tom Truscott. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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) -/* from static char sccsid[] = "@(#)crypt.c 5.11 (Berkeley) 6/25/91"; */ -static char rcsid[] = "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -/* - * UNIX password, and DES, encryption. - * - * since this is non-exportable, this is just a dummy. if you want real - * encryption, make sure you've got libcrypt.a around. - */ - -__warn_references(des_setkey, - "WARNING! des_setkey(3) not present in the system!"); - -int -des_setkey(key) - register const char *key; -{ - fprintf(stderr, "WARNING! des_setkey(3) not present in the system!\n"); - return (0); -} - -__warn_references(des_cipher, - "WARNING! des_cipher(3) not present in the system!"); - -int -des_cipher(in, out, salt, num_iter) - const char *in; - char *out; - long salt; - int num_iter; -{ - fprintf(stderr, "WARNING! des_cipher(3) not present in the system!\n"); - bcopy(in, out, 8); - return (0); -} - -__warn_references(setkey, - "WARNING! setkey(3) not present in the system!"); - -int -setkey(key) - register const char *key; -{ - fprintf(stderr, "WARNING! setkey(3) not present in the system!\n"); - return (0); -} - -__warn_references(encrypt, - "WARNING! encrypt(3) not present in the system!"); - -int -encrypt(block, flag) - register char *block; - int flag; -{ - fprintf(stderr, "WARNING! encrypt(3) not present in the system!\n"); - return (0); -} diff --git a/lib/libc/gen/ctermid.3 b/lib/libc/gen/ctermid.3 deleted file mode 100644 index 3b1668f..0000000 --- a/lib/libc/gen/ctermid.3 +++ /dev/null @@ -1,107 +0,0 @@ -.\" Copyright (c) 1990, 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. -.\" -.\" @(#)ctermid.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt CTERMID 3 -.Os -.Sh NAME -.Nm ctermid -.Nd generate terminal pathname -.Sh SYNOPSIS -.Fd #include -.Ft char * -.Fn ctermid "char *buf" -.Ft char * -.Fn ctermid_r "char *buf" -.Sh DESCRIPTION -The -.Fn ctermid -function generates a string, that, when used as a pathname, refers to -the current controlling terminal of the calling process. -.Pp -If -.Ar buf -is the -.Dv NULL -pointer, a pointer to a static area is returned. -Otherwise, the pathname is copied into the memory referenced by -.Ar buf . -The argument -.Ar buf -is assumed to be at least -.Dv L_ctermid -(as defined in the include -file -.Aq Pa stdio.h ) -bytes long. -.Pp -.Fn ctermid_r -provides the same functionality as -.Fn ctermid -except that if -.Ar buf -is a -.Dv NULL -pointer, -.Dv NULL -is returned. -.Pp -The current implementation simply returns -.Ql /dev/tty . -.Sh RETURN VALUES -Upon successful completion, a -.Pf non- Dv NULL -pointer is returned. -Otherwise, a -.Dv NULL -pointer is returned and the global variable -.Va errno -is set to indicate the error. -.Sh ERRORS -The current implementation detects no error conditions. -.Sh SEE ALSO -.Xr ttyname 3 -.Sh STANDARDS -The -.Fn ctermid -function conforms to -.St -p1003.1-88 . -.Sh BUGS -By default the -.Fn ctermid -function -writes all information to an internal static object. -Subsequent calls to -.Fn ctermid -will modify the same object. diff --git a/lib/libc/gen/ctermid.c b/lib/libc/gen/ctermid.c deleted file mode 100644 index e43d6ab..0000000 --- a/lib/libc/gen/ctermid.c +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * Copyright (c) 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)ctermid.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -char * -ctermid(char *s) -{ - static char def[] = _PATH_TTY; - - if (s) { - bcopy(def, s, sizeof(_PATH_TTY)); - return(s); - } - return(def); -} - - -char * -ctermid_r(char *s) -{ - return (s) ? ctermid(s) : NULL; -} diff --git a/lib/libc/gen/daemon.3 b/lib/libc/gen/daemon.3 deleted file mode 100644 index fa423d6..0000000 --- a/lib/libc/gen/daemon.3 +++ /dev/null @@ -1,80 +0,0 @@ -.\" Copyright (c) 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. -.\" -.\" @(#)daemon.3 8.1 (Berkeley) 6/9/93 -.\" $FreeBSD$ -.\" -.Dd June 9, 1993 -.Dt DAEMON 3 -.Os -.Sh NAME -.Nm daemon -.Nd run in the background -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn daemon "int nochdir" "int noclose" -.Sh DESCRIPTION -.Pp -The -.Fn daemon -function is for programs wishing to detach themselves from the -controlling terminal and run in the background as system daemons. -.Pp -Unless the argument -.Fa nochdir -is non-zero, -.Fn daemon -changes the current working directory to the root (``/''). -.Pp -Unless the argument -.Fa noclose -is non-zero, -.Fn daemon -will redirect standard input, standard output and standard error -to ``/dev/null''. -.Sh ERRORS -If an error occurs, -.Fn daemon -returns -1 and sets the global variable -.Va errno -to any of the errors specified for the library functions -.Xr fork 2 -and -.Xr setsid 2 . -.Sh SEE ALSO -.Xr fork 2 , -.Xr setsid 2 -.Sh HISTORY -The -.Fn daemon -function first appeared in -.Bx 4.4 . diff --git a/lib/libc/gen/daemon.c b/lib/libc/gen/daemon.c deleted file mode 100644 index 4f6c2f3..0000000 --- a/lib/libc/gen/daemon.c +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * Copyright (c) 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)daemon.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -int -daemon(nochdir, noclose) - int nochdir, noclose; -{ - int fd; - - switch (fork()) { - case -1: - return (-1); - case 0: - break; - default: - _exit(0); - } - - if (setsid() == -1) - return (-1); - - if (!nochdir) - (void)chdir("/"); - - if (!noclose && (fd = _open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { - (void)dup2(fd, STDIN_FILENO); - (void)dup2(fd, STDOUT_FILENO); - (void)dup2(fd, STDERR_FILENO); - if (fd > 2) - (void)_close(fd); - } - return (0); -} diff --git a/lib/libc/gen/devname.3 b/lib/libc/gen/devname.3 deleted file mode 100644 index 2030125..0000000 --- a/lib/libc/gen/devname.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" Copyright (c) 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. -.\" -.\" @(#)devname.3 8.2 (Berkeley) 4/29/95 -.\" $FreeBSD$ -.\" -.Dd April 29, 1995 -.Dt DEVNAME 3 -.Os BSD 4.4 -.Sh NAME -.Nm devname -.Nd get device name -.Sh SYNOPSIS -.Fd #include -.Ft char * -.Fn devname "dev_t dev" "mode_t type" -.Sh DESCRIPTION -The -.Fn devname -function returns a pointer to the name of the block or character -device in -.Dq Pa /dev -with a device number of -.Fa dev , -and a file type matching the one encoded in -.Fa type -which must be one of S_IFBLK or S_IFCHR. -If no device matches the specified values, or no information is -available, NULL is returned. -.Pp -The traditional display for applications when no device is -found is the string -.Dq ?? . -.Sh SEE ALSO -.Xr stat 2 , -.Xr dev_mkdb 8 -.Sh HISTORY -The -.Fn devname -function call appeared in -.Bx 4.4 . diff --git a/lib/libc/gen/devname.c b/lib/libc/gen/devname.c deleted file mode 100644 index 898c8e8..0000000 --- a/lib/libc/gen/devname.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)devname.c 8.2 (Berkeley) 4/29/95"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -static char * -xdevname(dev, type) - dev_t dev; - mode_t type; -{ - struct { - mode_t type; - dev_t dev; - } bkey; - static DB *db; - static int failure; - DBT data, key; - - if (!db && !failure && - !(db = dbopen(_PATH_DEVDB, O_RDONLY, 0, DB_HASH, NULL))) { - warn("warning: %s", _PATH_DEVDB); - failure = 1; - } - if (failure) - return (NULL); - - /* - * Keys are a mode_t followed by a dev_t. The former is the type of - * the file (mode & S_IFMT), the latter is the st_rdev field. Be - * sure to clear any padding that may be found in bkey. - */ - memset(&bkey, 0, sizeof(bkey)); - bkey.dev = dev; - bkey.type = type; - key.data = &bkey; - key.size = sizeof(bkey); - return ((db->get)(db, &key, &data, 0) ? NULL : (char *)data.data); -} - -char * -devname(dev, type) - dev_t dev; - mode_t type; -{ - static char buf[20]; - char *r; - - r = xdevname(dev, type); - if (!r) { - r = buf; - if (minor(dev) > 255) { - sprintf(buf, "#%c%d:0x%x", - (type & S_IFMT) == S_IFCHR ? 'C' : 'B', - major(dev), minor(dev)); - } else { - sprintf(buf, "#%c%d:%d", - (type & S_IFMT) == S_IFCHR ? 'C' : 'B', - major(dev), minor(dev)); - } - } - return (r); -} diff --git a/lib/libc/gen/directory.3 b/lib/libc/gen/directory.3 deleted file mode 100644 index 6334d38..0000000 --- a/lib/libc/gen/directory.3 +++ /dev/null @@ -1,198 +0,0 @@ -.\" Copyright (c) 1983, 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. -.\" -.\" @(#)directory.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt DIRECTORY 3 -.Os BSD 4.2 -.Sh NAME -.Nm opendir , -.Nm readdir , -.Nm readdir_r , -.Nm telldir , -.Nm seekdir , -.Nm rewinddir , -.Nm closedir , -.Nm dirfd -.Nd directory operations -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Ft DIR * -.Fn opendir "const char *filename" -.Ft struct dirent * -.Fn readdir "DIR *dirp" -.Ft int -.Fn readdir_r "DIR *dirp" "struct dirent *entry" "struct dirent **result" -.Ft long -.Fn telldir "const DIR *dirp" -.Ft void -.Fn seekdir "DIR *dirp" "long loc" -.Ft void -.Fn rewinddir "DIR *dirp" -.Ft int -.Fn closedir "DIR *dirp" -.Ft int -.Fn dirfd "DIR *dirp" -.Sh DESCRIPTION -The -.Fn opendir -function -opens the directory named by -.Fa filename , -associates a -.Em directory stream -with it -and -returns a pointer to be used to identify the -.Em directory stream -in subsequent operations. The pointer -.Dv NULL -is returned if -.Fa filename -cannot be accessed, or if it cannot -.Xr malloc 3 -enough memory to hold the whole thing. -.Pp -The -.Fn readdir -function -returns a pointer to the next directory entry. It returns -.Dv NULL -upon reaching the end of the directory or detecting an invalid -.Fn seekdir -operation. -.Pp -.Fn readdir_r -provides the same functionality as -.Fn readdir , -but the caller must provide a directory -.Fa entry -buffer to store the results in. If the read succeeds, -.Fa result -is pointed at the -.Fa entry ; -upon reaching the end of the directory -.Fa result -is set to -.Dv NULL . -.Fn readdir_r -returns 0 on success or an error number to indicate failure. -.Pp -The -.Fn telldir -function -returns the current location associated with the named -.Em directory stream . -Values returned by -.Fn telldir -are good only for the lifetime of the -.Dv DIR -pointer, -.Fa dirp , -from which they are derived. If the directory is closed and then -reopened, prior values returned by -.Fn telldir -will no longer be valid. -.Pp -The -.Fn seekdir -function -sets the position of the next -.Fn readdir -operation on the -.Em directory stream . -The new position reverts to the one associated with the -.Em directory stream -when the -.Fn telldir -operation was performed. -.Pp -The -.Fn rewinddir -function -resets the position of the named -.Em directory stream -to the beginning of the directory. -.Pp -The -.Fn closedir -function -closes the named -.Em directory stream -and frees the structure associated with the -.Fa dirp -pointer, -returning 0 on success. -On failure, \-1 is returned and the global variable -.Va errno -is set to indicate the error. -.Pp -The -.Fn dirfd -function -returns the integer file descriptor associated with the named -.Em directory stream , -see -.Xr open 2 . -.Pp -Sample code which searches a directory for entry ``name'' is: -.Bd -literal -offset indent -len = strlen(name); -dirp = opendir("."); -while ((dp = readdir(dirp)) != NULL) - if (dp->d_namlen == len && !strcmp(dp->d_name, name)) { - (void)closedir(dirp); - return FOUND; - } -(void)closedir(dirp); -return NOT_FOUND; -.Ed -.Sh SEE ALSO -.Xr close 2 , -.Xr lseek 2 , -.Xr open 2 , -.Xr read 2 , -.Xr dir 5 -.Sh HISTORY -The -.Fn opendir , -.Fn readdir , -.Fn telldir , -.Fn seekdir , -.Fn rewinddir , -.Fn closedir , -and -.Fn dirfd -functions appeared in -.Bx 4.2 . diff --git a/lib/libc/gen/disklabel.c b/lib/libc/gen/disklabel.c deleted file mode 100644 index c7ac0b4..0000000 --- a/lib/libc/gen/disklabel.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 1983, 1987, 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. - */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)disklabel.c 8.2 (Berkeley) 5/3/95"; -#endif -static const char rcsid[] = - "$FreeBSD$"; -#endif /* not lint */ - -#include -#define DKTYPENAMES -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -static int gettype __P((char *, char **)); - -struct disklabel * -getdiskbyname(name) - const char *name; -{ - static struct disklabel disk; - register struct disklabel *dp = &disk; - register struct partition *pp; - char *buf; - char *db_array[2] = { _PATH_DISKTAB, 0 }; - char *cp, *cq; /* can't be register */ - char p, max, psize[3], pbsize[3], - pfsize[3], poffset[3], ptype[3]; - u_int32_t *dx; - - if (cgetent(&buf, db_array, (char *) name) < 0) - return NULL; - - bzero((char *)&disk, sizeof(disk)); - /* - * typename - */ - cq = dp->d_typename; - cp = buf; - while (cq < dp->d_typename + sizeof(dp->d_typename) - 1 && - (*cq = *cp) && *cq != '|' && *cq != ':') - cq++, cp++; - *cq = '\0'; - /* - * boot name (optional) xxboot, bootxx - */ - cgetstr(buf, "b0", &dp->d_boot0); - cgetstr(buf, "b1", &dp->d_boot1); - - if (cgetstr(buf, "ty", &cq) > 0 && strcmp(cq, "removable") == 0) - dp->d_flags |= D_REMOVABLE; - else if (cq && strcmp(cq, "simulated") == 0) - dp->d_flags |= D_RAMDISK; - if (cgetcap(buf, "sf", ':') != NULL) - dp->d_flags |= D_BADSECT; - -#define getnumdflt(field, dname, dflt) \ - { long f; (field) = (cgetnum(buf, dname, &f) == -1) ? (dflt) : f; } - - getnumdflt(dp->d_secsize, "se", DEV_BSIZE); - getnumdflt(dp->d_ntracks, "nt", 0); - getnumdflt(dp->d_nsectors, "ns", 0); - getnumdflt(dp->d_ncylinders, "nc", 0); - - if (cgetstr(buf, "dt", &cq) > 0) - dp->d_type = gettype(cq, dktypenames); - else - getnumdflt(dp->d_type, "dt", 0); - getnumdflt(dp->d_secpercyl, "sc", dp->d_nsectors * dp->d_ntracks); - getnumdflt(dp->d_secperunit, "su", dp->d_secpercyl * dp->d_ncylinders); - getnumdflt(dp->d_rpm, "rm", 3600); - getnumdflt(dp->d_interleave, "il", 1); - getnumdflt(dp->d_trackskew, "sk", 0); - getnumdflt(dp->d_cylskew, "cs", 0); - getnumdflt(dp->d_headswitch, "hs", 0); - getnumdflt(dp->d_trkseek, "ts", 0); - getnumdflt(dp->d_bbsize, "bs", BBSIZE); - getnumdflt(dp->d_sbsize, "sb", SBSIZE); - strcpy(psize, "px"); - strcpy(pbsize, "bx"); - strcpy(pfsize, "fx"); - strcpy(poffset, "ox"); - strcpy(ptype, "tx"); - max = 'a' - 1; - pp = &dp->d_partitions[0]; - for (p = 'a'; p < 'a' + MAXPARTITIONS; p++, pp++) { - long l; - psize[1] = pbsize[1] = pfsize[1] = poffset[1] = ptype[1] = p; - if (cgetnum(buf, psize, &l) == -1) - pp->p_size = 0; - else { - pp->p_size = l; - cgetnum(buf, poffset, &l); - pp->p_offset = l; - getnumdflt(pp->p_fsize, pfsize, 0); - if (pp->p_fsize) { - long bsize; - - if (cgetnum(buf, pbsize, &bsize) == 0) - pp->p_frag = bsize / pp->p_fsize; - else - pp->p_frag = 8; - } - getnumdflt(pp->p_fstype, ptype, 0); - if (pp->p_fstype == 0 && cgetstr(buf, ptype, &cq) > 0) - pp->p_fstype = gettype(cq, fstypenames); - max = p; - } - } - dp->d_npartitions = max + 1 - 'a'; - (void)strcpy(psize, "dx"); - dx = dp->d_drivedata; - for (p = '0'; p < '0' + NDDATA; p++, dx++) { - psize[1] = p; - getnumdflt(*dx, psize, 0); - } - dp->d_magic = DISKMAGIC; - dp->d_magic2 = DISKMAGIC; - free(buf); - return (dp); -} - -static int -gettype(t, names) - char *t; - char **names; -{ - register char **nm; - - for (nm = names; *nm; nm++) - if (strcasecmp(t, *nm) == 0) - return (nm - names); - if (isdigit((unsigned char)*t)) - return (atoi(t)); - return (0); -} diff --git a/lib/libc/gen/dladdr.3 b/lib/libc/gen/dladdr.3 deleted file mode 100644 index 9938a7a..0000000 --- a/lib/libc/gen/dladdr.3 +++ /dev/null @@ -1,121 +0,0 @@ -.\" -.\" Copyright (c) 1998 John D. Polstra -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd February 5, 1998 -.Os FreeBSD -.Dt DLADDR 3 -.Sh NAME -.Nm dladdr -.Nd find the shared object containing a given address -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn dladdr "const void *addr" "Dl_info *info" -.Sh DESCRIPTION -.Nm -queries the dynamic linker for information about the shared object -containing the address -.Fa addr . -The information is returned in the structure specified by -.Fa info . -The structure contains at least the following members: -.Bl -tag -width "XXXconst char *dli_fname" -.It Li "const char *dli_fname" -The pathname of the shared object containing the address. -.It Li "void *dli_fbase" -The base address at which the shared object is mapped into the -address space of the calling process. -.It Li "const char *dli_sname" -The name of the nearest run-time symbol with a value less than or -equal to -.Fa addr . -When possible, the symbol name is returned as it would appear in C -source code. -.Pp -If no symbol with a suitable value is found, both this field and -.Va dli_saddr -are set to -.Dv NULL . -.It Li "void *dli_saddr" -The value of the symbol returned in -.Li dli_sname . -.El -.Pp -.Nm -is available only in dynamically linked programs. -.Sh ERRORS -If a mapped shared object containing -.Fa addr -cannot be found, -.Nm -returns 0. -In that case, a message detailing the failure can be retrieved by -calling -.Fn dlerror . -.Pp -On success, a non-zero value is returned. -.Sh SEE ALSO -.Xr rtld 1 , -.Xr dlopen 3 -.Sh HISTORY -The -.Nm -function first appeared in the Solaris operating system. -.Sh BUGS -This implementation is bug-compatible with the Solaris -implementation. In particular, the following bugs are present: -.Bl -bullet -.It -If -.Fa addr -lies in the main executable rather than in a shared library, the -pathname returned in -.Va dli_fname -may not be correct. The pathname is taken directly from -.Va argv[0] -of the calling process. When executing a program specified by its -full pathname, most shells set -.Va argv[0] -to the pathname. But this is not required of shells or guaranteed -by the operating system. -.It -If -.Fa addr -is of the form -.Va &func , -where -.Va func -is a global function, its value may be an unpleasant surprise. In -dynamically linked programs, the address of a global function is -considered to point to its program linkage table entry, rather than to -the entry point of the function itself. This causes most global -functions to appear to be defined within the main executable, rather -than in the shared libraries where the actual code resides. -.It -Returning 0 as an indication of failure goes against long-standing -Unix tradition. -.El diff --git a/lib/libc/gen/dlfcn.c b/lib/libc/gen/dlfcn.c deleted file mode 100644 index fd0be34..0000000 --- a/lib/libc/gen/dlfcn.c +++ /dev/null @@ -1,182 +0,0 @@ -/*- - * Copyright (c) 1998 John D. Polstra - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -/* - * Linkage to services provided by the dynamic linker. These are - * implemented differently in ELF and a.out, because the dynamic - * linkers have different interfaces. - */ - -#ifdef __ELF__ - -#include -#include - -static const char sorry[] = "Service unavailable"; - -/* - * For ELF, the dynamic linker directly resolves references to its - * services to functions inside the dynamic linker itself. These - * weak-symbol stubs are necessary so that "ld" won't complain about - * undefined symbols. The stubs are executed only when the program is - * linked statically, or when a given service isn't implemented in the - * dynamic linker. They must return an error if called, and they must - * be weak symbols so that the dynamic linker can override them. - */ - -#pragma weak _rtld_error -void -_rtld_error(const char *fmt, ...) -{ -} - -#pragma weak dladdr -int -dladdr(const void *addr, Dl_info *dlip) -{ - _rtld_error(sorry); - return 0; -} - -#pragma weak dlclose -int -dlclose(void *handle) -{ - _rtld_error(sorry); - return -1; -} - -#pragma weak dlerror -const char * -dlerror(void) -{ - return sorry; -} - -#pragma weak dllockinit -void -dllockinit(void *context, - void *(*lock_create)(void *context), - void (*rlock_acquire)(void *lock), - void (*wlock_acquire)(void *lock), - void (*lock_release)(void *lock), - void (*lock_destroy)(void *lock), - void (*context_destroy)(void *context)) -{ - if (context_destroy != NULL) - context_destroy(context); -} - -#pragma weak dlopen -void * -dlopen(const char *name, int mode) -{ - _rtld_error(sorry); - return NULL; -} - -#pragma weak dlsym -void * -dlsym(void *handle, const char *name) -{ - _rtld_error(sorry); - return NULL; -} - -#else /* a.out format */ - -#include -#include /* XXX - Required by link.h */ -#include -#include -#include - -/* - * For a.out, entry to the dynamic linker is via these trampolines. - * They enter the dynamic linker through the ld_entry struct that was - * passed back from the dynamic linker at startup time. - */ - -/* GCC is needed because we use its __builtin_return_address construct. */ - -#ifndef __GNUC__ -#error "GCC is needed to compile this file" -#endif - -/* - * These variables are set by code in crt0.o. For compatibility with - * old executables, they must be common, not extern. - */ -struct ld_entry *__ldso_entry; /* Entry points to dynamic linker */ -int __ldso_version; /* Dynamic linker version number */ - -int -dladdr(const void *addr, Dl_info *dlip) -{ - if (__ldso_entry == NULL || __ldso_version < LDSO_VERSION_HAS_DLADDR) - return 0; - return (__ldso_entry->dladdr)(addr, dlip); -} - -int -dlclose(void *handle) -{ - if (__ldso_entry == NULL) - return -1; - return (__ldso_entry->dlclose)(handle); -} - -const char * -dlerror(void) -{ - if (__ldso_entry == NULL) - return "Service unavailable"; - return (__ldso_entry->dlerror)(); -} - -void * -dlopen(const char *name, int mode) -{ - if (__ldso_entry == NULL) - return NULL; - return (__ldso_entry->dlopen)(name, mode); -} - -void * -dlsym(void *handle, const char *name) -{ - if (__ldso_entry == NULL) - return NULL; - if (__ldso_version >= LDSO_VERSION_HAS_DLSYM3) { - void *retaddr = __builtin_return_address(0); /* __GNUC__ only */ - return (__ldso_entry->dlsym3)(handle, name, retaddr); - } else - return (__ldso_entry->dlsym)(handle, name); -} - -#endif /* __ELF__ */ diff --git a/lib/libc/gen/dllockinit.3 b/lib/libc/gen/dllockinit.3 deleted file mode 100644 index 5597c00..0000000 --- a/lib/libc/gen/dllockinit.3 +++ /dev/null @@ -1,111 +0,0 @@ -.\" -.\" Copyright (c) 1999, 2000 John D. Polstra -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd December 26, 1999 -.Os FreeBSD -.Dt DLLOCKINIT 3 -.Sh NAME -.Nm dllockinit -.Nd register thread locking methods with the dynamic linker -.Sh SYNOPSIS -.Fd #include -.Ft void -.Fn dllockinit "void *context" "void *(*lock_create)(void *context)" "void (*rlock_acquire)(void *lock)" "void (*wlock_acquire)(void *lock)" "void (*lock_release)(void *lock)" "void (*lock_destroy)(void *lock)" "void (*context_destroy)(void *context)" -.Sh DESCRIPTION -.Bf Sy -This interface is experimental. It may be changed or eliminated in -future releases. -.Ef -.Pp -Threads packages can call -.Nm -at initialization time to register locking functions for the dynamic -linker to use. This enables the dynamic linker to prevent multiple -threads from entering its critical sections simultaneously. -.Pp -The -.Fa context -parameter specifies an opaque context for creating locks. The -dynamic linker will pass it to the -.Fa lock_create -function when creating the locks it needs. When the dynamic linker -is permanently finished using the locking functions (e.g., if the -program makes a subsequent call to -.Nm -to register new locking functions) it will call -.Fa context_destroy -to destroy the context. -.Pp -The -.Fa lock_create -parameter specifies a function for creating a read/write lock. It -must return a pointer to the new lock. -.Pp -The -.Fa rlock_acquire -and -.Fa wlock_acquire -parameters specify functions which lock a lock for reading or -writing, respectively. The -.Fa lock_release -parameter specifies a function which unlocks a lock. Each of these -functions is passed a pointer to the lock. -.Pp -The -.Fa lock_destroy -parameter specifies a function to destroy a lock. It may be -.Dv NULL -if locks do not need to be destroyed. The -.Fa context_destroy -parameter specifies a function to destroy the context. It may be -.Dv NULL -if the context does not need to be destroyed. -.Pp -Until -.Nm -is called, the dynamic linker protects its critical sections using -a default locking mechanism which works by blocking the -.Dv SIGVTALRM , -.Dv SIGPROF , -and -.Dv SIGALRM -signals. This is sufficient for many application level threads -packages, which typically use one of these signals to implement -preemption. An application which has registered its own locking -methods with -.Nm -can restore the default locking by calling -.Nm -with all arguments -.Dv NULL . -.Sh SEE ALSO -.Xr rtld 1 , -.Xr signal 3 -.Sh HISTORY -The -.Nm -function first appeared in FreeBSD 4.0. diff --git a/lib/libc/gen/dlopen.3 b/lib/libc/gen/dlopen.3 deleted file mode 100644 index 6485e75..0000000 --- a/lib/libc/gen/dlopen.3 +++ /dev/null @@ -1,230 +0,0 @@ -.\" This source code is a product of Sun Microsystems, Inc. and is provided -.\" for unrestricted use provided that this legend is included on all tape -.\" media and as a part of the software program in whole or part. Users -.\" may copy or modify this source code without charge, but are not authorized -.\" to license or distribute it to anyone else except as part of a product or -.\" program developed by the user. -.\" -.\" THIS PROGRAM CONTAINS SOURCE CODE COPYRIGHTED BY SUN MICROSYSTEMS, INC. -.\" SUN MICROSYSTEMS, INC., MAKES NO REPRESENTATIONS ABOUT THE SUITABLITY -.\" OF SUCH SOURCE CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT -.\" EXPRESS OR IMPLIED WARRANTY OF ANY KIND. SUN MICROSYSTEMS, INC. DISCLAIMS -.\" ALL WARRANTIES WITH REGARD TO SUCH SOURCE CODE, INCLUDING ALL IMPLIED -.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN -.\" NO EVENT SHALL SUN MICROSYSTEMS, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT, -.\" INCIDENTAL, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING -.\" FROM USE OF SUCH SOURCE CODE, REGARDLESS OF THE THEORY OF LIABILITY. -.\" -.\" This source code is provided with no support and without any obligation on -.\" the part of Sun Microsystems, Inc. to assist in its use, correction, -.\" modification or enhancement. -.\" -.\" SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE -.\" INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS -.\" SOURCE CODE OR ANY PART THEREOF. -.\" -.\" Sun Microsystems, Inc. -.\" 2550 Garcia Avenue -.\" Mountain View, California 94043 -.\" -.\" Copyright (c) 1991 Sun Microsystems, Inc. -.\" -.\" @(#) dlopen.3 1.6 90/01/31 SMI -.\" $FreeBSD$ -.\" -.Dd September 24, 1989 -.Os FreeBSD -.Dt DLOPEN 3 -.Sh NAME -.Nm dlopen, dlsym, dlerror, dlclose -.Nd programmatic interface to the dynamic linker -.Sh SYNOPSIS -.Fd #include -.Ft void * -.Fn dlopen "const char *path" "int mode" -.Ft void * -.Fn dlsym "void *handle" "const char *symbol" -.Ft const char * -.Fn dlerror "void" -.Ft int -.Fn dlclose "void *handle" -.Sh DESCRIPTION -These functions provide a simple programmatic interface to the services of the -dynamic linker. -Operations are provided to add new shared objects to a -program's address space, to obtain the address bindings of symbols -defined by such -objects, and to remove such objects when their use is no longer required. -.Pp -.Fn dlopen -provides access to the shared object in -.Fa path , -returning a descriptor that can be used for later -references to the object in calls to -.Fn dlsym -and -.Fn dlclose . -If -.Fa path -was not in the address space prior to the call to -.Fn dlopen , -it is placed in the address space. -When an object is first loaded into the address space in this way, its -function -.Fn _init , -if any, is called by the dynamic linker. -If -.Fa path -has already been placed in the address space in a previous call to -.Fn dlopen , -it is not added a second time, although a reference count of -.Fn dlopen -operations on -.Fa path -is maintained. -A null pointer supplied for -.Fa path -is interpreted as a reference to the main -executable of the process. -.Fa mode -controls the way in which external function references from the -loaded object are bound to their referents. -It must contain one of the following values: -.Bl -tag -width RTLD_LAZYX -.It Dv RTLD_LAZY -Each external function reference is resolved when the function is first -called. -.It Dv RTLD_NOW -All external function references are bound immediately by -.Fn dlopen . -.El -.Pp -.Dv RTLD_LAZY -is normally preferred, for reasons of efficiency. -However, -.Dv RTLD_NOW -is useful to ensure that any undefined symbols are discovered during the -call to -.Fn dlopen . -If -.Fn dlopen -fails, it returns a null pointer, and sets an error condition which may -be interrogated with -.Fn dlerror . -.Pp -.Fn dlsym -returns the address binding of the symbol described in the null-terminated -character string -.Fa symbol , -as it occurs in the shared object identified by -.Fa handle . -The symbols exported by objects added to the address space by -.Fn dlopen -can be accessed only through calls to -.Fn dlsym . -Such symbols do not supersede any definition of those symbols already present -in the address space when the object is loaded, nor are they available to -satisfy normal dynamic linking references. -A null pointer supplied as the value of -.Fa handle -is interpreted as a reference to the executable from which the call to -.Fn dlsym -is being made. Thus a shared object can reference its own symbols. -.Fn dlsym -returns a null pointer if the symbol cannot be found, and sets an error -condition which may be queried with -.Fn dlerror . -.Pp -If -.Fn dlsym -is called with the special -.Fa handle -.Dv RTLD_NEXT , -then the search for the symbol is limited to the shared objects -which were loaded after the one issuing the call to -.Fn dlsym . -Thus, if the function is called from the main program, all -the shared libraries are searched. -If it is called from a shared library, all subsequent shared -libraries are searched. -.Dv RTLD_NEXT -is useful for implementing wrappers around library functions. -For example, a wrapper function -.Fn getpid -could access the -.Dq real -.Fn getpid -with -.Li dlsym(RTLD_NEXT, \&"getpid\&") . -.Pp -.Fn dlerror -returns a null-terminated character string describing the last error that -occurred during a call to -.Fn dlopen , -.Fn dlsym , -or -.Fn dlclose . -If no such error has occurred, -.Fn dlerror -returns a null pointer. -At each call to -.Fn dlerror , -the error indication is reset. Thus in the case of two calls -to -.Fn dlerror , -where the second call follows the first immediately, the second call -will always return a null pointer. -.Pp -.Fn dlclose -deletes a reference to the shared object referenced by -.Fa handle . -If the reference count drops to 0, the object is removed from the -address space, and -.Fa handle -is rendered invalid. -Just before removing a shared object in this way, the dynamic linker -calls the object's -.Fn _fini -function, if such a function is defined by the object. -If -.Fn dlclose -is successful, it returns a value of 0. -Otherwise it returns -1, and sets an error condition that can be -interrogated with -.Fn dlerror . -.Pp -The object-intrinsic functions -.Fn _init -and -.Fn _fini -are called with no arguments, and are not expected to return values. -.Sh NOTES -ELF executables need to be linked -using the -.Fl export-dynamic -option to -.Xr ld 1 -for symbols defined in the executable to become visible to -.Fn dlsym . -.Pp -In previous implementations, it was necessary to prepend an underscore -to all external symbols in order to gain symbol -compatibility with object code compiled from the C language. This is -still the case when using the (obsolete) -.Fl aout -option to the C language compiler. -.Sh ERRORS -.Fn dlopen -and -.Fn dlsym -return the null pointer in the event of errors. -.Fn dlclose -returns 0 on success, or -1 if an error occurred. -Whenever an error has been detected, a message detailing it can be -retrieved via a call to -.Fn dlerror . -.Sh SEE ALSO -.Xr ld 1 , -.Xr rtld 1 , -.Xr link 5 - diff --git a/lib/libc/gen/drand48.c b/lib/libc/gen/drand48.c deleted file mode 100644 index cec04a6..0000000 --- a/lib/libc/gen/drand48.c +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 1993 Martin Birgmeier - * All rights reserved. - * - * You may redistribute unmodified or modified versions of this source - * code provided that the above copyright notice and this and the - * following conditions are retained. - * - * This software is provided ``as is'', and comes with no warranties - * of any kind. I shall in no event be liable for anything that happens - * to anyone/anything when using this software. - */ - -#include "rand48.h" - -extern unsigned short _rand48_seed[3]; - -double -drand48(void) -{ - return erand48(_rand48_seed); -} diff --git a/lib/libc/gen/erand48.c b/lib/libc/gen/erand48.c deleted file mode 100644 index 286904c..0000000 --- a/lib/libc/gen/erand48.c +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 1993 Martin Birgmeier - * All rights reserved. - * - * You may redistribute unmodified or modified versions of this source - * code provided that the above copyright notice and this and the - * following conditions are retained. - * - * This software is provided ``as is'', and comes with no warranties - * of any kind. I shall in no event be liable for anything that happens - * to anyone/anything when using this software. - */ - -#include "rand48.h" - -double -erand48(unsigned short xseed[3]) -{ - _dorand48(xseed); - return ldexp((double) xseed[0], -48) + - ldexp((double) xseed[1], -32) + - ldexp((double) xseed[2], -16); -} diff --git a/lib/libc/gen/err.3 b/lib/libc/gen/err.3 deleted file mode 100644 index 468fd1f..0000000 --- a/lib/libc/gen/err.3 +++ /dev/null @@ -1,204 +0,0 @@ -.\" Copyright (c) 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: @(#)err.3 8.1 (Berkeley) 6/9/93 -.\" $FreeBSD$ -.\" -.Dd Mar 6, 1999 -.Dt ERR 3 -.Os BSD 4 -.Sh NAME -.Nm err , -.Nm verr , -.Nm errc , -.Nm verrc , -.Nm errx , -.Nm verrx , -.Nm warn , -.Nm vwarn , -.Nm warnc , -.Nm vwarnc , -.Nm warnx , -.Nm vwarnx , -.Nm err_set_exit , -.Nm err_set_file -.Nd formatted error messages -.Sh SYNOPSIS -.Fd #include -.Ft void -.Fn err "int eval" "const char *fmt" "..." -.Ft void -.Fn err_set_exit "void (*exitf)(int)" -.Ft void -.Fn err_set_file "void *vfp" -.Ft void -.Fn errc "int eval" "int code" "const char *fmt" "..." -.Ft void -.Fn errx "int eval" "const char *fmt" "..." -.Ft void -.Fn warn "const char *fmt" "..." -.Ft void -.Fn warnc "int code" "const char *fmt" "..." -.Ft void -.Fn warnx "const char *fmt" "..." -.Fd #include -.Ft void -.Fn verr "int eval" "const char *fmt" "va_list args" -.Ft void -.Fn verrc "int eval" "int code" "const char *fmt" "va_list args" -.Ft void -.Fn verrx "int eval" "const char *fmt" "va_list args" -.Ft void -.Fn vwarn "const char *fmt" "va_list args" -.Ft void -.Fn vwarnc "int code" "const char *fmt" "va_list args" -.Ft void -.Fn vwarnx "const char *fmt" "va_list args" -.Sh DESCRIPTION -The -.Fn err -and -.Fn warn -family of functions display a formatted error message on the standard -error output, or on another file specified using the -.Fn err_set_file -function. -In all cases, the last component of the program name, a colon character, -and a space are output. -If the -.Va fmt -argument is not NULL, the formatted error message is output. -In the case of the -.Fn errc , -.Fn verrc , -.Fn warnc , -and -.Fn vwarnc -functions, -the error message string affiliated with the -.Va code -argument is also output, -preceded by another colon and space if necessary. -In all cases, the output is followed by a newline character. -.Pp -The -.Fn err , -.Fn verr , -.Fn warn , -and -.Fn vwarn -functions use the global variable -.Va errno -rather than the -.Va code -argument of the -.Fn errc -family -.Pp -The -.Fn err , -.Fn verr , -.Fn errc , -.Fn verrc , -.Fn errx , -and -.Fn verrx -functions do not return, but exit with the value of the argument -.Fa eval . -The -.Fn err_set_exit -function can be used to specify a function which is called before -.Xr exit 3 -to perform any necessary cleanup; passing a null function pointer for -.Va exitf -resets the hook to do nothing. -The -.Fn err_set_file -function sets the output stream used by the other functions. -Its -.Va vfp -argument must be either a pointer to an open stream -(possibly already converted to void *) -or a null pointer -(in which case the output stream is set to standard error). -.Sh EXAMPLES -Display the current errno information string and exit: -.Bd -literal -offset indent -if ((p = malloc(size)) == NULL) - err(1, NULL); -if ((fd = open(file_name, O_RDONLY, 0)) == -1) - err(1, "%s", file_name); -.Ed -.Pp -Display an error message and exit: -.Bd -literal -offset indent -if (tm.tm_hour < START_TIME) - errx(1, "too early, wait until %s", start_time_string); -.Ed -.Pp -Warn of an error: -.Bd -literal -offset indent -if ((fd = open(raw_device, O_RDONLY, 0)) == -1) - warnx("%s: %s: trying the block device", - raw_device, strerror(errno)); -if ((fd = open(block_device, O_RDONLY, 0)) == -1) - err(1, "%s", block_device); -.Ed -.Pp -Warn of an error without using the global variable -.Va errno : -.Bd -literal -offset indent -error = my_function(); /* returns a value from */ -if (error != 0) - warnc(error, "my_function"); -.Ed -.Sh SEE ALSO -.Xr exit 3 , -.Xr strerror 3 -.Sh HISTORY -The -.Fn err -and -.Fn warn -functions first appeared in -.Bx 4.4 . -The -.Fn err_set_exit -and -.Fn err_set_file -functions first appeared in -.Fx 2.1 . -The -.Fn errc -and -.Fn warnc -functions first appeared in -.Fx 3.0 . diff --git a/lib/libc/gen/err.c b/lib/libc/gen/err.c deleted file mode 100644 index 6d1766c..0000000 --- a/lib/libc/gen/err.c +++ /dev/null @@ -1,208 +0,0 @@ -/*- - * Copyright (c) 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: @(#)err.c 8.1 (Berkeley) 6/4/93 - */ - -#if defined(LIBC_RCS) && !defined(lint) -static const char rcsid[] = - "$FreeBSD$"; -#endif /* LIBC_RCS and not lint */ - -#include -#include -#include -#include -#include - -#include - -extern char *__progname; /* Program name, from crt0. */ - -static FILE *err_file; /* file to use for error output */ -static void (*err_exit)(int); - -/* - * This is declared to take a `void *' so that the caller is not required - * to include first. However, it is really a `FILE *', and the - * manual page documents it as such. - */ -void -err_set_file(void *fp) -{ - if (fp) - err_file = fp; - else - err_file = stderr; -} - -void -err_set_exit(void (*ef)(int)) -{ - err_exit = ef; -} - -void -err(int eval, const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - verrc(eval, errno, fmt, ap); - va_end(ap); -} - -void -verr(eval, fmt, ap) - int eval; - const char *fmt; - va_list ap; -{ - verrc(eval, errno, fmt, ap); -} - -void -errc(int eval, int code, const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - verrc(eval, code, fmt, ap); - va_end(ap); -} - -void -verrc(eval, code, fmt, ap) - int eval; - int code; - const char *fmt; - va_list ap; -{ - if (err_file == 0) - err_set_file((FILE *)0); - fprintf(err_file, "%s: ", __progname); - if (fmt != NULL) { - vfprintf(err_file, fmt, ap); - fprintf(err_file, ": "); - } - fprintf(err_file, "%s\n", strerror(code)); - if (err_exit) - err_exit(eval); - exit(eval); -} - -void -errx(int eval, const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - verrx(eval, fmt, ap); - va_end(ap); -} - -void -verrx(eval, fmt, ap) - int eval; - const char *fmt; - va_list ap; -{ - if (err_file == 0) - err_set_file((FILE *)0); - fprintf(err_file, "%s: ", __progname); - if (fmt != NULL) - vfprintf(err_file, fmt, ap); - fprintf(err_file, "\n"); - if (err_exit) - err_exit(eval); - exit(eval); -} - -void -warn(const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - vwarnc(errno, fmt, ap); - va_end(ap); -} - -void -vwarn(fmt, ap) - const char *fmt; - va_list ap; -{ - vwarnc(errno, fmt, ap); -} - -void -warnc(int code, const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - vwarnc(code, fmt, ap); - va_end(ap); -} - -void -vwarnc(code, fmt, ap) - int code; - const char *fmt; - va_list ap; -{ - if (err_file == 0) - err_set_file((FILE *)0); - fprintf(err_file, "%s: ", __progname); - if (fmt != NULL) { - vfprintf(err_file, fmt, ap); - fprintf(err_file, ": "); - } - fprintf(err_file, "%s\n", strerror(code)); -} - -void -warnx(const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - vwarnx(fmt, ap); - va_end(ap); -} - -void -vwarnx(fmt, ap) - const char *fmt; - va_list ap; -{ - if (err_file == 0) - err_set_file((FILE *)0); - fprintf(err_file, "%s: ", __progname); - if (fmt != NULL) - vfprintf(err_file, fmt, ap); - fprintf(err_file, "\n"); -} diff --git a/lib/libc/gen/errlst.c b/lib/libc/gen/errlst.c deleted file mode 100644 index a643794..0000000 --- a/lib/libc/gen/errlst.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 1982, 1985, 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)errlst.c 8.2 (Berkeley) 11/16/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -const char *const sys_errlist[] = { - "Undefined error: 0", /* 0 - ENOERROR */ - "Operation not permitted", /* 1 - EPERM */ - "No such file or directory", /* 2 - ENOENT */ - "No such process", /* 3 - ESRCH */ - "Interrupted system call", /* 4 - EINTR */ - "Input/output error", /* 5 - EIO */ - "Device not configured", /* 6 - ENXIO */ - "Argument list too long", /* 7 - E2BIG */ - "Exec format error", /* 8 - ENOEXEC */ - "Bad file descriptor", /* 9 - EBADF */ - "No child processes", /* 10 - ECHILD */ - "Resource deadlock avoided", /* 11 - EDEADLK */ - "Cannot allocate memory", /* 12 - ENOMEM */ - "Permission denied", /* 13 - EACCES */ - "Bad address", /* 14 - EFAULT */ - "Block device required", /* 15 - ENOTBLK */ - "Device busy", /* 16 - EBUSY */ - "File exists", /* 17 - EEXIST */ - "Cross-device link", /* 18 - EXDEV */ - "Operation not supported by device", /* 19 - ENODEV */ - "Not a directory", /* 20 - ENOTDIR */ - "Is a directory", /* 21 - EISDIR */ - "Invalid argument", /* 22 - EINVAL */ - "Too many open files in system", /* 23 - ENFILE */ - "Too many open files", /* 24 - EMFILE */ - "Inappropriate ioctl for device", /* 25 - ENOTTY */ - "Text file busy", /* 26 - ETXTBSY */ - "File too large", /* 27 - EFBIG */ - "No space left on device", /* 28 - ENOSPC */ - "Illegal seek", /* 29 - ESPIPE */ - "Read-only file system", /* 30 - EROFS */ - "Too many links", /* 31 - EMLINK */ - "Broken pipe", /* 32 - EPIPE */ - -/* math software */ - "Numerical argument out of domain", /* 33 - EDOM */ - "Result too large", /* 34 - ERANGE */ - -/* non-blocking and interrupt i/o */ - "Resource temporarily unavailable", /* 35 - EAGAIN */ - /* 35 - EWOULDBLOCK */ - "Operation now in progress", /* 36 - EINPROGRESS */ - "Operation already in progress", /* 37 - EALREADY */ - -/* ipc/network software -- argument errors */ - "Socket operation on non-socket", /* 38 - ENOTSOCK */ - "Destination address required", /* 39 - EDESTADDRREQ */ - "Message too long", /* 40 - EMSGSIZE */ - "Protocol wrong type for socket", /* 41 - EPROTOTYPE */ - "Protocol not available", /* 42 - ENOPROTOOPT */ - "Protocol not supported", /* 43 - EPROTONOSUPPORT */ - "Socket type not supported", /* 44 - ESOCKTNOSUPPORT */ - "Operation not supported", /* 45 - EOPNOTSUPP */ - "Protocol family not supported", /* 46 - EPFNOSUPPORT */ - /* 47 - EAFNOSUPPORT */ - "Address family not supported by protocol family", - "Address already in use", /* 48 - EADDRINUSE */ - "Can't assign requested address", /* 49 - EADDRNOTAVAIL */ - -/* ipc/network software -- operational errors */ - "Network is down", /* 50 - ENETDOWN */ - "Network is unreachable", /* 51 - ENETUNREACH */ - "Network dropped connection on reset", /* 52 - ENETRESET */ - "Software caused connection abort", /* 53 - ECONNABORTED */ - "Connection reset by peer", /* 54 - ECONNRESET */ - "No buffer space available", /* 55 - ENOBUFS */ - "Socket is already connected", /* 56 - EISCONN */ - "Socket is not connected", /* 57 - ENOTCONN */ - "Can't send after socket shutdown", /* 58 - ESHUTDOWN */ - "Too many references: can't splice", /* 59 - ETOOMANYREFS */ - "Operation timed out", /* 60 - ETIMEDOUT */ - "Connection refused", /* 61 - ECONNREFUSED */ - - "Too many levels of symbolic links", /* 62 - ELOOP */ - "File name too long", /* 63 - ENAMETOOLONG */ - -/* should be rearranged */ - "Host is down", /* 64 - EHOSTDOWN */ - "No route to host", /* 65 - EHOSTUNREACH */ - "Directory not empty", /* 66 - ENOTEMPTY */ - -/* quotas & mush */ - "Too many processes", /* 67 - EPROCLIM */ - "Too many users", /* 68 - EUSERS */ - "Disc quota exceeded", /* 69 - EDQUOT */ - -/* Network File System */ - "Stale NFS file handle", /* 70 - ESTALE */ - "Too many levels of remote in path", /* 71 - EREMOTE */ - "RPC struct is bad", /* 72 - EBADRPC */ - "RPC version wrong", /* 73 - ERPCMISMATCH */ - "RPC prog. not avail", /* 74 - EPROGUNAVAIL */ - "Program version wrong", /* 75 - EPROGMISMATCH */ - "Bad procedure for program", /* 76 - EPROCUNAVAIL */ - - "No locks available", /* 77 - ENOLCK */ - "Function not implemented", /* 78 - ENOSYS */ - "Inappropriate file type or format", /* 79 - EFTYPE */ - "Authentication error", /* 80 - EAUTH */ - "Need authenticator", /* 81 - ENEEDAUTH */ - "Identifier removed", /* 82 - EIDRM */ - "No message of desired type", /* 83 - ENOMSG */ - "Value too large to be stored in data type", /* 84 - EOVERFLOW */ - "Operation canceled", /* 85 - ECANCELED */ - "Illegal byte sequence", /* 86 - EILSEQ */ -}; -int errno; -const int sys_nerr = sizeof(sys_errlist) / sizeof(sys_errlist[0]); diff --git a/lib/libc/gen/exec.3 b/lib/libc/gen/exec.3 deleted file mode 100644 index 8da1247..0000000 --- a/lib/libc/gen/exec.3 +++ /dev/null @@ -1,291 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)exec.3 8.3 (Berkeley) 1/24/94 -.\" $FreeBSD$ -.\" -.Dd January 24, 1994 -.Dt EXEC 3 -.Os -.Sh NAME -.Nm execl , -.Nm execlp , -.Nm execle , -.Nm exect , -.Nm execv , -.Nm execvp -.Nd execute a file -.Sh SYNOPSIS -.Fd #include -.Vt extern char **environ; -.Ft int -.Fn execl "const char *path" "const char *arg" ... -.Ft int -.Fn execlp "const char *file" "const char *arg" ... -.Ft int -.Fn execle "const char *path" "const char *arg" ... -.Ft int -.Fn exect "const char *path" "char *const argv[]" "char *const envp[]" -.Ft int -.Fn execv "const char *path" "char *const argv[]" -.Ft int -.Fn execvp "const char *file" "char *const argv[]" -.Sh DESCRIPTION -The -.Nm exec -family of functions replaces the current process image with a -new process image. -The functions described in this manual page are front-ends for the function -.Xr execve 2 . -(See the manual page for -.Xr execve 2 -for detailed information about the replacement of the current process.) -.Pp -The initial argument for these functions is the pathname of a file which -is to be executed. -.Pp -The -.Fa "const char *arg" -and subsequent ellipses in the -.Fn execl , -.Fn execlp , -and -.Fn execle -functions can be thought of as -.Em arg0 , -.Em arg1 , -\&..., -.Em argn . -Together they describe a list of one or more pointers to null-terminated -strings that represent the argument list available to the executed program. -The first argument, by convention, should point to the file name associated -with the file being executed. -The list of arguments -.Em must -be terminated by a -.Dv NULL -pointer. -.Pp -The -.Fn exect , -.Fn execv , -and -.Fn execvp -functions provide an array of pointers to null-terminated strings that -represent the argument list available to the new program. -The first argument, by convention, should point to the file name associated -with the file begin executed. -The array of pointers -.Sy must -be terminated by a -.Dv NULL -pointer. -.Pp -The -.Fn execle -and -.Fn exect -functions also specify the environment of the executed process by following -the -.Dv NULL -pointer that terminates the list of arguments in the parameter list -or the pointer to the argv array with an additional parameter. -This additional parameter is an array of pointers to null-terminated strings -and -.Em must -be terminated by a -.Dv NULL -pointer. -The other functions take the environment for the new process image from the -external variable -.Va environ -in the current process. -.Pp -Some of these functions have special semantics. -.Pp -The functions -.Fn execlp -and -.Fn execvp -will duplicate the actions of the shell in searching for an executable file -if the specified file name does not contain a slash -.Dq Li / -character. -The search path is the path specified in the environment by -.Dq Ev PATH -variable. -If this variable isn't specified, the default path -.Dq Ev /bin:/usr/bin: -is -used. -In addition, certain errors are treated specially. -.Pp -If an error is ambiguous (for simplicity, we shall consider all -errors except -.Er ENOEXEC -as being ambiguous here, although only the critical error -.Er EACCES -is really ambiguous), -then these functions will act as if they stat the file to determine -whether the file exists and has suitable execute permissions. -If it does, they will return immediately with the global variable -.Va errno -restored to the value set by -.Fn execve . -Otherwise, the search will be continued. -If the search completes without performing a successful -.Fn execve -or terminating due to an error, -these functions will return with the global variable -.Va errno -set to -.Er EACCES -or -.Er ENOENT -according to whether at least one file with suitable execute permissions -was found. -.Pp -If the header of a file isn't recognized (the attempted -.Fn execve -returned -.Er ENOEXEC ) , -these functions will execute the shell with the path of -the file as its first argument. -(If this attempt fails, no further searching is done.) -.Pp -The function -.Fn exect -executes a file with the program tracing facilities enabled (see -.Xr ptrace 2 ) . -.Sh RETURN VALUES -If any of the -.Fn exec -functions returns, an error will have occurred. -The return value is \-1, and the global variable -.Va errno -will be set to indicate the error. -.Sh FILES -.Bl -tag -width /bin/sh -compact -.It Pa /bin/sh -The shell. -.El -.Sh ERRORS -.Fn Execl , -.Fn execle , -.Fn execlp -and -.Fn execvp -may fail and set -.Va errno -for any of the errors specified for the library functions -.Xr execve 2 -and -.Xr malloc 3 . -.Pp -.Fn Exect -and -.Fn execv -may fail and set -.Va errno -for any of the errors specified for the library function -.Xr execve 2 . -.Sh SEE ALSO -.Xr sh 1 , -.Xr execve 2 , -.Xr fork 2 , -.Xr ktrace 2 , -.Xr ptrace 2 , -.Xr environ 7 . -.Sh COMPATIBILITY -Historically, the default path for the -.Fn execlp -and -.Fn execvp -functions was -.Dq Pa :/bin:/usr/bin . -This was changed to place the current directory last to enhance system -security. -.Pp -The behavior of -.Fn execlp -and -.Fn execvp -when errors occur while attempting to execute the file is not quite historic -practice, and has not traditionally been documented and is not specified -by the -.Tn POSIX -standard. -.Pp -Traditionally, the functions -.Fn execlp -and -.Fn execvp -ignored all errors except for the ones described above and -.Er ETXTBSY , -upon which they retried after sleeping for several seconds, and -.Er ENOMEM -and -.Er E2BIG , -upon which they returned. -They now return for -.Er ETXTBSY , -and determine existence and executability more carefully. -In particular, -.Er EACCES -for inaccessible directories in the path prefix is no longer -confused with -.Er EACCES -for files with unsuitable execute permissions. -In -.Bx 4.4 , -they returned upon all errors except -.Er EACCES , -.Er ENOENT , -.Er ENOEXEC -and -.Er ETXTBSY . -This was inferior to the traditional error handling, -since it it breaks the ignoring of errors for path prefixes -and only improves the handling of the unusual ambiguous error -.Er EFAULT -and the unusual error -.Er EIO . -The behaviour was changed to match the behaviour of -.Xr sh 1 . -.Sh STANDARDS -.Fn Execl , -.Fn execv , -.Fn execle , -.Fn execlp -and -.Fn execvp -conform to -.St -p1003.1-88 . diff --git a/lib/libc/gen/exec.c b/lib/libc/gen/exec.c deleted file mode 100644 index 04bd2d2..0000000 --- a/lib/libc/gen/exec.c +++ /dev/null @@ -1,318 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 6/4/93"; -#endif -static const char rcsid[] = - "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if __STDC__ -#include -#else -#include -#endif - -extern char **environ; - -int -#if __STDC__ -execl(const char *name, const char *arg, ...) -#else -execl(name, arg, va_alist) - const char *name; - const char *arg; - va_dcl -#endif -{ - va_list ap; - char **argv; - int n; - -#if __STDC__ - va_start(ap, arg); -#else - va_start(ap); -#endif - n = 1; - while (va_arg(ap, char *) != NULL) - n++; - va_end(ap); - argv = alloca((n + 1) * sizeof(*argv)); - if (argv == NULL) { - errno = ENOMEM; - return (-1); - } -#if __STDC__ - va_start(ap, arg); -#else - va_start(ap); -#endif - n = 1; - argv[0] = (char *)arg; - while ((argv[n] = va_arg(ap, char *)) != NULL) - n++; - va_end(ap); - return (execve(name, argv, environ)); -} - -int -#if __STDC__ -execle(const char *name, const char *arg, ...) -#else -execle(name, arg, va_alist) - const char *name; - const char *arg; - va_dcl -#endif -{ - va_list ap; - char **argv, **envp; - int n; - -#if __STDC__ - va_start(ap, arg); -#else - va_start(ap); -#endif - n = 1; - while (va_arg(ap, char *) != NULL) - n++; - va_end(ap); - argv = alloca((n + 1) * sizeof(*argv)); - if (argv == NULL) { - errno = ENOMEM; - return (-1); - } -#if __STDC__ - va_start(ap, arg); -#else - va_start(ap); -#endif - n = 1; - argv[0] = (char *)arg; - while ((argv[n] = va_arg(ap, char *)) != NULL) - n++; - envp = va_arg(ap, char **); - va_end(ap); - return (execve(name, argv, envp)); -} - -int -#if __STDC__ -execlp(const char *name, const char *arg, ...) -#else -execlp(name, arg, va_alist) - const char *name; - const char *arg; - va_dcl -#endif -{ - va_list ap; - int sverrno; - char **argv; - int n; - -#if __STDC__ - va_start(ap, arg); -#else - va_start(ap); -#endif - n = 1; - while (va_arg(ap, char *) != NULL) - n++; - va_end(ap); - argv = alloca((n + 1) * sizeof(*argv)); - if (argv == NULL) { - errno = ENOMEM; - return (-1); - } -#if __STDC__ - va_start(ap, arg); -#else - va_start(ap); -#endif - n = 1; - argv[0] = (char *)arg; - while ((argv[n] = va_arg(ap, char *)) != NULL) - n++; - va_end(ap); - return (execvp(name, argv)); -} - -int -execv(name, argv) - const char *name; - char * const *argv; -{ - (void)execve(name, argv, environ); - return (-1); -} - -int -execvp(name, argv) - const char *name; - char * const *argv; -{ - char **memp; - register int cnt, lp, ln; - register char *p; - int eacces, save_errno; - char *bp, *cur, *path, buf[MAXPATHLEN]; - struct stat sb; - - eacces = 0; - - /* If it's an absolute or relative path name, it's easy. */ - if (index(name, '/')) { - bp = (char *)name; - cur = path = NULL; - goto retry; - } - bp = buf; - - /* If it's an empty path name, fail in the usual POSIX way. */ - if (*name == '\0') { - errno = ENOENT; - return (-1); - } - - /* Get the path we're searching. */ - if (!(path = getenv("PATH"))) - path = _PATH_DEFPATH; - cur = alloca(strlen(path) + 1); - if (cur == NULL) { - errno = ENOMEM; - return (-1); - } - strcpy(cur, path); - path = cur; - while ( (p = strsep(&cur, ":")) ) { - /* - * It's a SHELL path -- double, leading and trailing colons - * mean the current directory. - */ - if (!*p) { - p = "."; - lp = 1; - } else - lp = strlen(p); - ln = strlen(name); - - /* - * If the path is too long complain. This is a possible - * security issue; given a way to make the path too long - * the user may execute the wrong program. - */ - if (lp + ln + 2 > sizeof(buf)) { - (void)_write(STDERR_FILENO, "execvp: ", 8); - (void)_write(STDERR_FILENO, p, lp); - (void)_write(STDERR_FILENO, ": path too long\n", - 16); - continue; - } - bcopy(p, buf, lp); - buf[lp] = '/'; - bcopy(name, buf + lp + 1, ln); - buf[lp + ln + 1] = '\0'; - -retry: (void)execve(bp, argv, environ); - switch(errno) { - case E2BIG: - goto done; - case ELOOP: - case ENAMETOOLONG: - case ENOENT: - break; - case ENOEXEC: - for (cnt = 0; argv[cnt]; ++cnt) - ; - memp = alloca((cnt + 2) * sizeof(char *)); - if (memp == NULL) { - /* errno = ENOMEM; XXX override ENOEXEC? */ - goto done; - } - memp[0] = "sh"; - memp[1] = bp; - bcopy(argv + 1, memp + 2, cnt * sizeof(char *)); - (void)execve(_PATH_BSHELL, memp, environ); - goto done; - case ENOMEM: - goto done; - case ENOTDIR: - break; - case ETXTBSY: - /* - * We used to retry here, but sh(1) doesn't. - */ - goto done; - default: - /* - * EACCES may be for an inaccessible directory or - * a non-executable file. Call stat() to decide - * which. This also handles ambiguities for EFAULT - * and EIO, and undocumented errors like ESTALE. - * We hope that the race for a stat() is unimportant. - */ - save_errno = errno; - if (stat(bp, &sb) != 0) - break; - if (save_errno == EACCES) { - eacces = 1; - continue; - } - errno = save_errno; - goto done; - } - } - if (eacces) - errno = EACCES; - else - errno = ENOENT; -done: - return (-1); -} diff --git a/lib/libc/gen/fnmatch.3 b/lib/libc/gen/fnmatch.3 deleted file mode 100644 index 8b556b5..0000000 --- a/lib/libc/gen/fnmatch.3 +++ /dev/null @@ -1,149 +0,0 @@ -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Guido van Rossum. -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)fnmatch.3 8.3 (Berkeley) 4/28/95 -.\" $FreeBSD$ -.\" -.Dd April 28, 1995 -.Dt FNMATCH 3 -.Os -.Sh NAME -.Nm fnmatch -.Nd match filename or pathname -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn fnmatch "const char *pattern" "const char *string" "int flags" -.Sh DESCRIPTION -The -.Fn fnmatch -function -matches patterns according to the rules used by the shell. -It checks the string specified by the -.Fa string -argument to see if it matches the pattern specified by the -.Fa pattern -argument. -.Pp -The -.Fa flags -argument modifies the interpretation of -.Fa pattern -and -.Fa string . -The value of -.Fa flags -is the bitwise inclusive -.Tn OR -of any of the following -constants, which are defined in the include file -.Pa fnmatch.h . -.Bl -tag -width FNM_PATHNAME -.It Dv FNM_NOESCAPE -Normally, every occurrence of a backslash -.Pq Ql \e -followed by a character in -.Fa pattern -is replaced by that character. -This is done to negate any special meaning for the character. -If the -.Dv FNM_NOESCAPE -flag is set, a backslash character is treated as an ordinary character. -.It Dv FNM_PATHNAME -Slash characters in -.Fa string -must be explicitly matched by slashes in -.Fa pattern . -If this flag is not set, then slashes are treated as regular characters. -.It Dv FNM_PERIOD -Leading periods in -.Fa string -must be explicitly matched by periods in -.Fa pattern . -If this flag is not set, then leading periods are treated as regular -characters. -The definition of -.Dq leading -is related to the specification of -.Dv FNM_PATHNAME . -A period is always -.Dq leading -if it is the first character in -.Ar string . -Additionally, if -.Dv FNM_PATHNAME -is set, -a period is -leading -if it immediately follows a slash. -.It Dv FNM_LEADING_DIR -Ignore -.Nm /* -rest after successful -.Fa pattern -matching. -.It Dv FNM_CASEFOLD -Ignore case distinctions in both the -.Fa pattern -and the -.Fa string . -.El -.Sh RETURN VALUES -The -.Fn fnmatch -function returns zero if -.Fa string -matches the pattern specified by -.Fa pattern , -otherwise, it returns the value -.Dv FNM_NOMATCH . -.Sh SEE ALSO -.Xr sh 1 , -.Xr glob 3 , -.Xr regex 3 -.Sh STANDARDS -The -.Fn fnmatch -function conforms to -.St -p1003.2 . -.Sh HISTORY -The -.Fn fnmatch -function first appeared in -.Bx 4.4 . -.Sh BUGS -The pattern -.Ql * -matches the empty string, even if -.Dv FNM_PATHNAME -is specified. diff --git a/lib/libc/gen/fnmatch.c b/lib/libc/gen/fnmatch.c deleted file mode 100644 index c3312b4..0000000 --- a/lib/libc/gen/fnmatch.c +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright (c) 1989, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Guido van Rossum. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94"; -#endif /* LIBC_SCCS and not lint */ - -/* - * Function fnmatch() as specified in POSIX 1003.2-1992, section B.6. - * Compares a filename or pathname to a pattern. - */ - -#include -#include -#include -#include - -#include "collate.h" - -#define EOS '\0' - -#define RANGE_MATCH 1 -#define RANGE_NOMATCH 0 -#define RANGE_ERROR (-1) - -static int rangematch __P((const char *, char, int, char **)); - -int -fnmatch(pattern, string, flags) - const char *pattern, *string; - int flags; -{ - const char *stringstart; - char *newp; - char c, test; - - for (stringstart = string;;) - switch (c = *pattern++) { - case EOS: - if ((flags & FNM_LEADING_DIR) && *string == '/') - return (0); - return (*string == EOS ? 0 : FNM_NOMATCH); - case '?': - if (*string == EOS) - return (FNM_NOMATCH); - if (*string == '/' && (flags & FNM_PATHNAME)) - return (FNM_NOMATCH); - if (*string == '.' && (flags & FNM_PERIOD) && - (string == stringstart || - ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) - return (FNM_NOMATCH); - ++string; - break; - case '*': - c = *pattern; - /* Collapse multiple stars. */ - while (c == '*') - c = *++pattern; - - if (*string == '.' && (flags & FNM_PERIOD) && - (string == stringstart || - ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) - return (FNM_NOMATCH); - - /* Optimize for pattern with * at end or before /. */ - if (c == EOS) - if (flags & FNM_PATHNAME) - return ((flags & FNM_LEADING_DIR) || - strchr(string, '/') == NULL ? - 0 : FNM_NOMATCH); - else - return (0); - else if (c == '/' && flags & FNM_PATHNAME) { - if ((string = strchr(string, '/')) == NULL) - return (FNM_NOMATCH); - break; - } - - /* General case, use recursion. */ - while ((test = *string) != EOS) { - if (!fnmatch(pattern, string, flags & ~FNM_PERIOD)) - return (0); - if (test == '/' && flags & FNM_PATHNAME) - break; - ++string; - } - return (FNM_NOMATCH); - case '[': - if (*string == EOS) - return (FNM_NOMATCH); - if (*string == '/' && (flags & FNM_PATHNAME)) - return (FNM_NOMATCH); - if (*string == '.' && (flags & FNM_PERIOD) && - (string == stringstart || - ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) - return (FNM_NOMATCH); - - switch (rangematch(pattern, *string, flags, &newp)) { - case RANGE_ERROR: - goto norm; - case RANGE_MATCH: - pattern = newp; - break; - case RANGE_NOMATCH: - return (FNM_NOMATCH); - } - ++string; - break; - case '\\': - if (!(flags & FNM_NOESCAPE)) { - if ((c = *pattern++) == EOS) { - c = '\\'; - --pattern; - } - } - /* FALLTHROUGH */ - default: - norm: - if (c == *string) - ; - else if ((flags & FNM_CASEFOLD) && - (tolower((unsigned char)c) == - tolower((unsigned char)*string))) - ; - else - return (FNM_NOMATCH); - string++; - break; - } - /* NOTREACHED */ -} - -static int -rangematch(pattern, test, flags, newp) - const char *pattern; - char test; - int flags; - char **newp; -{ - int negate, ok; - char c, c2; - - /* - * A bracket expression starting with an unquoted circumflex - * character produces unspecified results (IEEE 1003.2-1992, - * 3.13.2). This implementation treats it like '!', for - * consistency with the regular expression syntax. - * J.T. Conklin (conklin@ngai.kaleida.com) - */ - if ( (negate = (*pattern == '!' || *pattern == '^')) ) - ++pattern; - - if (flags & FNM_CASEFOLD) - test = tolower((unsigned char)test); - - /* - * A right bracket shall lose its special meaning and represent - * itself in a bracket expression if it occurs first in the list. - * -- POSIX.2 2.8.3.2 - */ - ok = 0; - c = *pattern++; - do { - if (c == '\\' && !(flags & FNM_NOESCAPE)) - c = *pattern++; - if (c == EOS) - return (RANGE_ERROR); - - if (c == '/' && (flags & FNM_PATHNAME)) - return (RANGE_NOMATCH); - - if (flags & FNM_CASEFOLD) - c = tolower((unsigned char)c); - - if (*pattern == '-' - && (c2 = *(pattern+1)) != EOS && c2 != ']') { - pattern += 2; - if (c2 == '\\' && !(flags & FNM_NOESCAPE)) - c2 = *pattern++; - if (c2 == EOS) - return (RANGE_ERROR); - - if (flags & FNM_CASEFOLD) - c2 = tolower((unsigned char)c2); - - if (__collate_load_error ? - c <= test && test <= c2 : - __collate_range_cmp(c, test) <= 0 - && __collate_range_cmp(test, c2) <= 0 - ) - ok = 1; - } else if (c == test) - ok = 1; - } while ((c = *pattern++) != ']'); - - *newp = (char *)pattern; - return (ok == negate ? RANGE_NOMATCH : RANGE_MATCH); -} diff --git a/lib/libc/gen/frexp.3 b/lib/libc/gen/frexp.3 deleted file mode 100644 index f2a6b5c..0000000 --- a/lib/libc/gen/frexp.3 +++ /dev/null @@ -1,86 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)frexp.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt FREXP 3 -.Os -.Sh NAME -.Nm frexp -.Nd convert floating-point number to fractional and integral components -.Sh SYNOPSIS -.Fd #include -.Ft double -.Fn frexp "double value" "int *exp" -.Sh DESCRIPTION -The -.Fn frexp -function breaks a floating-point number into a normalized -fraction and an integral power of 2. -It stores the integer in the -.Em int -object pointed to by -.Fa exp . -.Sh RETURN VALUES -The -.Fn frexp -function returns the value -.Em x , -such that -.Em x -is a -.Em double -with magnitude in the interval -.Bq 1/2 , 1 -or zero, and -.Fa value -equals -.Em x -times 2 raised to the power -.Fa *exp . -If -.Fa value -is zero, both parts of the result are zero. -.Sh SEE ALSO -.Xr ldexp 3 , -.Xr math 3 , -.Xr modf 3 -.Sh STANDARDS -The -.Fn frexp -function conforms to -.St -ansiC . diff --git a/lib/libc/gen/fstab.c b/lib/libc/gen/fstab.c deleted file mode 100644 index ecd79fb..0000000 --- a/lib/libc/gen/fstab.c +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (c) 1980, 1988, 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)fstab.c 8.1 (Berkeley) 6/4/93"; -#else -static char rcsid[] = - "$FreeBSD$"; -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -static FILE *_fs_fp; -static struct fstab _fs_fstab; -static int LineNo = 0; - -static void error __P((int)); -static void fixfsfile __P((void)); -static int fstabscan __P((void)); - -static void -fixfsfile() -{ - static char buf[sizeof(_PATH_DEV) + MNAMELEN]; - struct stat sb; - struct statfs sf; - - if (strcmp(_fs_fstab.fs_file, "/") != 0) - return; - if (statfs("/", &sf) != 0) - return; - if (sf.f_mntfromname[0] == '/') - buf[0] = '\0'; - else - strcpy(buf, _PATH_DEV); - strcat(buf, sf.f_mntfromname); - if (stat(buf, &sb) != 0 || - (!S_ISBLK(sb.st_mode) && !S_ISCHR(sb.st_mode))) - return; - _fs_fstab.fs_spec = buf; -} - -static int -fstabscan() -{ - char *cp, *p; -#define MAXLINELENGTH 1024 - static char line[MAXLINELENGTH]; - char subline[MAXLINELENGTH]; - int typexx; - - for (;;) { - - if (!(p = fgets(line, sizeof(line), _fs_fp))) - return(0); -/* OLD_STYLE_FSTAB */ - ++LineNo; - if (*line == '#' || *line == '\n') - continue; - if (!strpbrk(p, " \t")) { - _fs_fstab.fs_spec = strsep(&p, ":\n"); - _fs_fstab.fs_file = strsep(&p, ":\n"); - fixfsfile(); - _fs_fstab.fs_type = strsep(&p, ":\n"); - if (_fs_fstab.fs_type) { - if (!strcmp(_fs_fstab.fs_type, FSTAB_XX)) - continue; - _fs_fstab.fs_mntops = _fs_fstab.fs_type; - _fs_fstab.fs_vfstype = - strcmp(_fs_fstab.fs_type, FSTAB_SW) ? - "ufs" : "swap"; - if ((cp = strsep(&p, ":\n")) != NULL) { - _fs_fstab.fs_freq = atoi(cp); - if ((cp = strsep(&p, ":\n")) != NULL) { - _fs_fstab.fs_passno = atoi(cp); - return(1); - } - } - } - goto bad; - } -/* OLD_STYLE_FSTAB */ - while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0') - ; - _fs_fstab.fs_spec = cp; - if (!_fs_fstab.fs_spec || *_fs_fstab.fs_spec == '#') - continue; - while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0') - ; - _fs_fstab.fs_file = cp; - fixfsfile(); - while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0') - ; - _fs_fstab.fs_vfstype = cp; - while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0') - ; - _fs_fstab.fs_mntops = cp; - if (_fs_fstab.fs_mntops == NULL) - goto bad; - _fs_fstab.fs_freq = 0; - _fs_fstab.fs_passno = 0; - while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0') - ; - if (cp != NULL) { - _fs_fstab.fs_freq = atoi(cp); - while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0') - ; - if (cp != NULL) - _fs_fstab.fs_passno = atoi(cp); - } - strcpy(subline, _fs_fstab.fs_mntops); - p = subline; - for (typexx = 0, cp = strsep(&p, ","); cp; - cp = strsep(&p, ",")) { - if (strlen(cp) != 2) - continue; - if (!strcmp(cp, FSTAB_RW)) { - _fs_fstab.fs_type = FSTAB_RW; - break; - } - if (!strcmp(cp, FSTAB_RQ)) { - _fs_fstab.fs_type = FSTAB_RQ; - break; - } - if (!strcmp(cp, FSTAB_RO)) { - _fs_fstab.fs_type = FSTAB_RO; - break; - } - if (!strcmp(cp, FSTAB_SW)) { - _fs_fstab.fs_type = FSTAB_SW; - break; - } - if (!strcmp(cp, FSTAB_XX)) { - _fs_fstab.fs_type = FSTAB_XX; - typexx++; - break; - } - } - if (typexx) - continue; - if (cp != NULL) - return(1); - -bad: /* no way to distinguish between EOF and syntax error */ - error(EFTYPE); - } - /* NOTREACHED */ -} - -struct fstab * -getfsent() -{ - if ((!_fs_fp && !setfsent()) || !fstabscan()) - return((struct fstab *)NULL); - return(&_fs_fstab); -} - -struct fstab * -getfsspec(name) - register const char *name; -{ - if (setfsent()) - while (fstabscan()) - if (!strcmp(_fs_fstab.fs_spec, name)) - return(&_fs_fstab); - return((struct fstab *)NULL); -} - -struct fstab * -getfsfile(name) - register const char *name; -{ - if (setfsent()) - while (fstabscan()) - if (!strcmp(_fs_fstab.fs_file, name)) - return(&_fs_fstab); - return((struct fstab *)NULL); -} - -int -setfsent() -{ - if (_fs_fp) { - rewind(_fs_fp); - LineNo = 0; - return(1); - } - if ((_fs_fp = fopen(_PATH_FSTAB, "r")) != NULL) { - LineNo = 0; - return(1); - } - error(errno); - return(0); -} - -void -endfsent() -{ - if (_fs_fp) { - (void)fclose(_fs_fp); - _fs_fp = NULL; - } -} - -static void -error(err) - int err; -{ - char *p; - char num[30]; - - (void)_write(STDERR_FILENO, "fstab: ", 7); - (void)_write(STDERR_FILENO, _PATH_FSTAB, sizeof(_PATH_FSTAB) - 1); - (void)_write(STDERR_FILENO, ":", 1); - sprintf(num, "%d: ", LineNo); - (void)_write(STDERR_FILENO, num, strlen(num)); - p = strerror(err); - (void)_write(STDERR_FILENO, p, strlen(p)); - (void)_write(STDERR_FILENO, "\n", 1); -} diff --git a/lib/libc/gen/ftok.3 b/lib/libc/gen/ftok.3 deleted file mode 100644 index 611bf30..0000000 --- a/lib/libc/gen/ftok.3 +++ /dev/null @@ -1,83 +0,0 @@ -.\" Copyright (c) 1994 SigmaSoft, Th. Lockert -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. The name of the author may not be used to endorse or promote products -.\" derived from this software without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -.\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -.\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd June 24, 1994 -.Os -.Dt FTOK 3 -.Sh NAME -.Nm ftok -.Nd create IPC identifier from path name -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Ft key_t -.Fn ftok "const char *path" "int id" -.Sh DESCRIPTION -.Bf -symbolic -This function is available from the compatibility library, libcompat. -.Ef -The -.Fn ftok -function attempts to create a unique key suitable for use with the -.Xr msgget 3 , -.Xr semget 2 -and -.Xr shmget 2 -functions given the -.Fa path -of an existing file and a user-selectable -.Fa id . -.Pp -The specified -.Fa path -must specify an existing file that is accessible to the calling process -or the call will fail. Also, note that links to files will return the -same key, given the same -.Fa id . -.Sh RETURN VALUES -The -.Fn ftok -function will return -1 if -.Fa path -does not exist or if it cannot be accessed by the calling process. -.Sh SEE ALSO -.Xr semget 2 , -.Xr shmget 2 , -.Xr msgget 3 -.Sh HISTORY -The -.Fn ftok -function originates with System V and is typically used by programs -that use the System V IPC routines. -.Sh AUTHORS -.An Thorsten Lockert Aq tholo@sigmasoft.com -.Sh BUGS -The returned key is computed based on the device minor number and inode of the -specified -.Fa path -in combination with the lower 8 bits of the given -.Fa id . -Thus it is quite possible for the routine to return duplicate keys. diff --git a/lib/libc/gen/ftok.c b/lib/libc/gen/ftok.c deleted file mode 100644 index 24cfe7d..0000000 --- a/lib/libc/gen/ftok.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 1994 SigmaSoft, Th. Lockert - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (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 *rcsid = "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -key_t -ftok(path, id) - const char *path; - char id; -{ - struct stat st; - - if (stat(path, &st) < 0) - return (key_t)-1; - - return (key_t) (id << 24 | (st.st_dev & 0xff) << 16 | (st.st_ino & 0xffff)); -} diff --git a/lib/libc/gen/fts-compat.c b/lib/libc/gen/fts-compat.c deleted file mode 100644 index 6b92a12..0000000 --- a/lib/libc/gen/fts-compat.c +++ /dev/null @@ -1,1114 +0,0 @@ -/*- - * Copyright (c) 1990, 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. - * - * $OpenBSD: fts.c,v 1.22 1999/10/03 19:22:22 millert Exp $ - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; -#else -static char rcsid[] = "$FreeBSD$"; -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -static FTSENT *fts_alloc __P((FTS *, char *, int)); -static FTSENT *fts_build __P((FTS *, int)); -static void fts_lfree __P((FTSENT *)); -static void fts_load __P((FTS *, FTSENT *)); -static size_t fts_maxarglen __P((char * const *)); -static void fts_padjust __P((FTS *, FTSENT *)); -static int fts_palloc __P((FTS *, size_t)); -static FTSENT *fts_sort __P((FTS *, FTSENT *, int)); -static u_short fts_stat __P((FTS *, FTSENT *, int)); -static int fts_safe_changedir __P((FTS *, FTSENT *, int)); - -#define ISDOT(a) (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2]))) - -#define CLR(opt) (sp->fts_options &= ~(opt)) -#define ISSET(opt) (sp->fts_options & (opt)) -#define SET(opt) (sp->fts_options |= (opt)) - -#define CHDIR(sp, path) (!ISSET(FTS_NOCHDIR) && chdir(path)) -#define FCHDIR(sp, fd) (!ISSET(FTS_NOCHDIR) && fchdir(fd)) - -/* fts_build flags */ -#define BCHILD 1 /* fts_children */ -#define BNAMES 2 /* fts_children, names only */ -#define BREAD 3 /* fts_read */ - -FTS * -fts_open(argv, options, compar) - char * const *argv; - register int options; - int (*compar) __P((const FTSENT **, const FTSENT **)); -{ - register FTS *sp; - register FTSENT *p, *root; - register int nitems; - FTSENT *parent, *tmp; - int len; - - /* Options check. */ - if (options & ~FTS_OPTIONMASK) { - errno = EINVAL; - return (NULL); - } - - /* Allocate/initialize the stream */ - if ((sp = malloc((u_int)sizeof(FTS))) == NULL) - return (NULL); - memset(sp, 0, sizeof(FTS)); - sp->fts_compar = compar; - sp->fts_options = options; - - /* Shush, GCC. */ - tmp = NULL; - - /* Logical walks turn on NOCHDIR; symbolic links are too hard. */ - if (ISSET(FTS_LOGICAL)) - SET(FTS_NOCHDIR); - - /* - * Start out with 1K of path space, and enough, in any case, - * to hold the user's paths. - */ - if (fts_palloc(sp, MAX(fts_maxarglen(argv), MAXPATHLEN))) - goto mem1; - - /* Allocate/initialize root's parent. */ - if ((parent = fts_alloc(sp, "", 0)) == NULL) - goto mem2; - parent->fts_level = FTS_ROOTPARENTLEVEL; - - /* Allocate/initialize root(s). */ - for (root = NULL, nitems = 0; *argv; ++argv, ++nitems) { - /* Don't allow zero-length paths. */ - if ((len = strlen(*argv)) == 0) { - errno = ENOENT; - goto mem3; - } - - p = fts_alloc(sp, *argv, len); - p->fts_level = FTS_ROOTLEVEL; - p->fts_parent = parent; - p->fts_accpath = p->fts_name; - p->fts_info = fts_stat(sp, p, ISSET(FTS_COMFOLLOW)); - - /* Command-line "." and ".." are real directories. */ - if (p->fts_info == FTS_DOT) - p->fts_info = FTS_D; - - /* - * If comparison routine supplied, traverse in sorted - * order; otherwise traverse in the order specified. - */ - if (compar) { - p->fts_link = root; - root = p; - } else { - p->fts_link = NULL; - if (root == NULL) - tmp = root = p; - else { - tmp->fts_link = p; - tmp = p; - } - } - } - if (compar && nitems > 1) - root = fts_sort(sp, root, nitems); - - /* - * Allocate a dummy pointer and make fts_read think that we've just - * finished the node before the root(s); set p->fts_info to FTS_INIT - * so that everything about the "current" node is ignored. - */ - if ((sp->fts_cur = fts_alloc(sp, "", 0)) == NULL) - goto mem3; - sp->fts_cur->fts_link = root; - sp->fts_cur->fts_info = FTS_INIT; - - /* - * If using chdir(2), grab a file descriptor pointing to dot to ensure - * that we can get back here; this could be avoided for some paths, - * but almost certainly not worth the effort. Slashes, symbolic links, - * and ".." are all fairly nasty problems. Note, if we can't get the - * descriptor we run anyway, just more slowly. - */ - if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = _open(".", O_RDONLY, 0)) < 0) - SET(FTS_NOCHDIR); - - return (sp); - -mem3: fts_lfree(root); - free(parent); -mem2: free(sp->fts_path); -mem1: free(sp); - return (NULL); -} - -static void -fts_load(sp, p) - FTS *sp; - register FTSENT *p; -{ - register int len; - register char *cp; - - /* - * Load the stream structure for the next traversal. Since we don't - * actually enter the directory until after the preorder visit, set - * the fts_accpath field specially so the chdir gets done to the right - * place and the user can access the first node. From fts_open it's - * known that the path will fit. - */ - len = p->fts_pathlen = p->fts_namelen; - memmove(sp->fts_path, p->fts_name, len + 1); - if ((cp = strrchr(p->fts_name, '/')) && (cp != p->fts_name || cp[1])) { - len = strlen(++cp); - memmove(p->fts_name, cp, len + 1); - p->fts_namelen = len; - } - p->fts_accpath = p->fts_path = sp->fts_path; - sp->fts_dev = p->fts_dev; -} - -int -fts_close(sp) - FTS *sp; -{ - register FTSENT *freep, *p; - int saved_errno; - - /* - * This still works if we haven't read anything -- the dummy structure - * points to the root list, so we step through to the end of the root - * list which has a valid parent pointer. - */ - if (sp->fts_cur) { - for (p = sp->fts_cur; p->fts_level >= FTS_ROOTLEVEL;) { - freep = p; - p = p->fts_link ? p->fts_link : p->fts_parent; - free(freep); - } - free(p); - } - - /* Free up child linked list, sort array, path buffer. */ - if (sp->fts_child) - fts_lfree(sp->fts_child); - if (sp->fts_array) - free(sp->fts_array); - free(sp->fts_path); - - /* Return to original directory, save errno if necessary. */ - if (!ISSET(FTS_NOCHDIR)) { - saved_errno = fchdir(sp->fts_rfd) ? errno : 0; - (void)_close(sp->fts_rfd); - - /* Set errno and return. */ - if (saved_errno != 0) { - /* Free up the stream pointer. */ - free(sp); - errno = saved_errno; - return (-1); - } - } - - /* Free up the stream pointer. */ - free(sp); - return (0); -} - -/* - * Special case of "/" at the end of the path so that slashes aren't - * appended which would cause paths to be written as "....//foo". - */ -#define NAPPEND(p) \ - (p->fts_path[p->fts_pathlen - 1] == '/' \ - ? p->fts_pathlen - 1 : p->fts_pathlen) - -FTSENT * -fts_read(sp) - register FTS *sp; -{ - register FTSENT *p, *tmp; - register int instr; - register char *t; - int saved_errno; - - /* If finished or unrecoverable error, return NULL. */ - if (sp->fts_cur == NULL || ISSET(FTS_STOP)) - return (NULL); - - /* Set current node pointer. */ - p = sp->fts_cur; - - /* Save and zero out user instructions. */ - instr = p->fts_instr; - p->fts_instr = FTS_NOINSTR; - - /* Any type of file may be re-visited; re-stat and re-turn. */ - if (instr == FTS_AGAIN) { - p->fts_info = fts_stat(sp, p, 0); - return (p); - } - - /* - * Following a symlink -- SLNONE test allows application to see - * SLNONE and recover. If indirecting through a symlink, have - * keep a pointer to current location. If unable to get that - * pointer, follow fails. - */ - if (instr == FTS_FOLLOW && - (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) { - p->fts_info = fts_stat(sp, p, 1); - if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { - if ((p->fts_symfd = _open(".", O_RDONLY, 0)) < 0) { - p->fts_errno = errno; - p->fts_info = FTS_ERR; - } else - p->fts_flags |= FTS_SYMFOLLOW; - } - return (p); - } - - /* Directory in pre-order. */ - if (p->fts_info == FTS_D) { - /* If skipped or crossed mount point, do post-order visit. */ - if (instr == FTS_SKIP || - (ISSET(FTS_XDEV) && p->fts_dev != sp->fts_dev)) { - if (p->fts_flags & FTS_SYMFOLLOW) - (void)_close(p->fts_symfd); - if (sp->fts_child) { - fts_lfree(sp->fts_child); - sp->fts_child = NULL; - } - p->fts_info = FTS_DP; - return (p); - } - - /* Rebuild if only read the names and now traversing. */ - if (sp->fts_child && ISSET(FTS_NAMEONLY)) { - CLR(FTS_NAMEONLY); - fts_lfree(sp->fts_child); - sp->fts_child = NULL; - } - - /* - * Cd to the subdirectory. - * - * If have already read and now fail to chdir, whack the list - * to make the names come out right, and set the parent errno - * so the application will eventually get an error condition. - * Set the FTS_DONTCHDIR flag so that when we logically change - * directories back to the parent we don't do a chdir. - * - * If haven't read do so. If the read fails, fts_build sets - * FTS_STOP or the fts_info field of the node. - */ - if (sp->fts_child) { - if (fts_safe_changedir(sp, p, -1)) { - p->fts_errno = errno; - p->fts_flags |= FTS_DONTCHDIR; - for (p = sp->fts_child; p; p = p->fts_link) - p->fts_accpath = - p->fts_parent->fts_accpath; - } - } else if ((sp->fts_child = fts_build(sp, BREAD)) == NULL) { - if (ISSET(FTS_STOP)) - return (NULL); - return (p); - } - p = sp->fts_child; - sp->fts_child = NULL; - goto name; - } - - /* Move to the next node on this level. */ -next: tmp = p; - if ((p = p->fts_link)) { - free(tmp); - - /* - * If reached the top, return to the original directory (or - * the root of the tree), and load the paths for the next root. - */ - if (p->fts_level == FTS_ROOTLEVEL) { - if (FCHDIR(sp, sp->fts_rfd)) { - SET(FTS_STOP); - return (NULL); - } - fts_load(sp, p); - return (sp->fts_cur = p); - } - - /* - * User may have called fts_set on the node. If skipped, - * ignore. If followed, get a file descriptor so we can - * get back if necessary. - */ - if (p->fts_instr == FTS_SKIP) - goto next; - if (p->fts_instr == FTS_FOLLOW) { - p->fts_info = fts_stat(sp, p, 1); - if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { - if ((p->fts_symfd = - _open(".", O_RDONLY, 0)) < 0) { - p->fts_errno = errno; - p->fts_info = FTS_ERR; - } else - p->fts_flags |= FTS_SYMFOLLOW; - } - p->fts_instr = FTS_NOINSTR; - } - -name: t = sp->fts_path + NAPPEND(p->fts_parent); - *t++ = '/'; - memmove(t, p->fts_name, p->fts_namelen + 1); - return (sp->fts_cur = p); - } - - /* Move up to the parent node. */ - p = tmp->fts_parent; - free(tmp); - - if (p->fts_level == FTS_ROOTPARENTLEVEL) { - /* - * Done; free everything up and set errno to 0 so the user - * can distinguish between error and EOF. - */ - free(p); - errno = 0; - return (sp->fts_cur = NULL); - } - - /* NUL terminate the pathname. */ - sp->fts_path[p->fts_pathlen] = '\0'; - - /* - * Return to the parent directory. If at a root node or came through - * a symlink, go back through the file descriptor. Otherwise, cd up - * one directory. - */ - if (p->fts_level == FTS_ROOTLEVEL) { - if (FCHDIR(sp, sp->fts_rfd)) { - SET(FTS_STOP); - return (NULL); - } - } else if (p->fts_flags & FTS_SYMFOLLOW) { - if (FCHDIR(sp, p->fts_symfd)) { - saved_errno = errno; - (void)_close(p->fts_symfd); - errno = saved_errno; - SET(FTS_STOP); - return (NULL); - } - (void)_close(p->fts_symfd); - } else if (!(p->fts_flags & FTS_DONTCHDIR)) { - if (CHDIR(sp, "..")) { - SET(FTS_STOP); - return (NULL); - } - } - p->fts_info = p->fts_errno ? FTS_ERR : FTS_DP; - return (sp->fts_cur = p); -} - -/* - * Fts_set takes the stream as an argument although it's not used in this - * implementation; it would be necessary if anyone wanted to add global - * semantics to fts using fts_set. An error return is allowed for similar - * reasons. - */ -/* ARGSUSED */ -int -fts_set(sp, p, instr) - FTS *sp; - FTSENT *p; - int instr; -{ - if (instr && instr != FTS_AGAIN && instr != FTS_FOLLOW && - instr != FTS_NOINSTR && instr != FTS_SKIP) { - errno = EINVAL; - return (1); - } - p->fts_instr = instr; - return (0); -} - -FTSENT * -fts_children(sp, instr) - register FTS *sp; - int instr; -{ - register FTSENT *p; - int fd; - - if (instr && instr != FTS_NAMEONLY) { - errno = EINVAL; - return (NULL); - } - - /* Set current node pointer. */ - p = sp->fts_cur; - - /* - * Errno set to 0 so user can distinguish empty directory from - * an error. - */ - errno = 0; - - /* Fatal errors stop here. */ - if (ISSET(FTS_STOP)) - return (NULL); - - /* Return logical hierarchy of user's arguments. */ - if (p->fts_info == FTS_INIT) - return (p->fts_link); - - /* - * If not a directory being visited in pre-order, stop here. Could - * allow FTS_DNR, assuming the user has fixed the problem, but the - * same effect is available with FTS_AGAIN. - */ - if (p->fts_info != FTS_D /* && p->fts_info != FTS_DNR */) - return (NULL); - - /* Free up any previous child list. */ - if (sp->fts_child) - fts_lfree(sp->fts_child); - - if (instr == FTS_NAMEONLY) { - SET(FTS_NAMEONLY); - instr = BNAMES; - } else - instr = BCHILD; - - /* - * If using chdir on a relative path and called BEFORE fts_read does - * its chdir to the root of a traversal, we can lose -- we need to - * chdir into the subdirectory, and we don't know where the current - * directory is, so we can't get back so that the upcoming chdir by - * fts_read will work. - */ - if (p->fts_level != FTS_ROOTLEVEL || p->fts_accpath[0] == '/' || - ISSET(FTS_NOCHDIR)) - return (sp->fts_child = fts_build(sp, instr)); - - if ((fd = _open(".", O_RDONLY, 0)) < 0) - return (NULL); - sp->fts_child = fts_build(sp, instr); - if (fchdir(fd)) - return (NULL); - (void)_close(fd); - return (sp->fts_child); -} - -/* - * This is the tricky part -- do not casually change *anything* in here. The - * idea is to build the linked list of entries that are used by fts_children - * and fts_read. There are lots of special cases. - * - * The real slowdown in walking the tree is the stat calls. If FTS_NOSTAT is - * set and it's a physical walk (so that symbolic links can't be directories), - * we can do things quickly. First, if it's a 4.4BSD file system, the type - * of the file is in the directory entry. Otherwise, we assume that the number - * of subdirectories in a node is equal to the number of links to the parent. - * The former skips all stat calls. The latter skips stat calls in any leaf - * directories and for any files after the subdirectories in the directory have - * been found, cutting the stat calls by about 2/3. - */ -static FTSENT * -fts_build(sp, type) - register FTS *sp; - int type; -{ - register struct dirent *dp; - register FTSENT *p, *head; - register int nitems; - FTSENT *cur, *tail; - DIR *dirp; - void *oldaddr; - int cderrno, descend, len, level, maxlen, nlinks, oflag, saved_errno, - nostat, doadjust; - char *cp; - - /* Set current node pointer. */ - cur = sp->fts_cur; - - /* - * Open the directory for reading. If this fails, we're done. - * If being called from fts_read, set the fts_info field. - */ -#ifdef FTS_WHITEOUT - if (ISSET(FTS_WHITEOUT)) - oflag = DTF_NODUP|DTF_REWIND; - else - oflag = DTF_HIDEW|DTF_NODUP|DTF_REWIND; -#else -#define __opendir2(path, flag) opendir(path) -#endif - if ((dirp = __opendir2(cur->fts_accpath, oflag)) == NULL) { - if (type == BREAD) { - cur->fts_info = FTS_DNR; - cur->fts_errno = errno; - } - return (NULL); - } - - /* - * Nlinks is the number of possible entries of type directory in the - * directory if we're cheating on stat calls, 0 if we're not doing - * any stat calls at all, -1 if we're doing stats on everything. - */ - if (type == BNAMES) { - nlinks = 0; - /* Be quiet about nostat, GCC. */ - nostat = 0; - } else if (ISSET(FTS_NOSTAT) && ISSET(FTS_PHYSICAL)) { - nlinks = cur->fts_nlink - (ISSET(FTS_SEEDOT) ? 0 : 2); - nostat = 1; - } else { - nlinks = -1; - nostat = 0; - } - -#ifdef notdef - (void)printf("nlinks == %d (cur: %d)\n", nlinks, cur->fts_nlink); - (void)printf("NOSTAT %d PHYSICAL %d SEEDOT %d\n", - ISSET(FTS_NOSTAT), ISSET(FTS_PHYSICAL), ISSET(FTS_SEEDOT)); -#endif - /* - * If we're going to need to stat anything or we want to descend - * and stay in the directory, chdir. If this fails we keep going, - * but set a flag so we don't chdir after the post-order visit. - * We won't be able to stat anything, but we can still return the - * names themselves. Note, that since fts_read won't be able to - * chdir into the directory, it will have to return different path - * names than before, i.e. "a/b" instead of "b". Since the node - * has already been visited in pre-order, have to wait until the - * post-order visit to return the error. There is a special case - * here, if there was nothing to stat then it's not an error to - * not be able to stat. This is all fairly nasty. If a program - * needed sorted entries or stat information, they had better be - * checking FTS_NS on the returned nodes. - */ - cderrno = 0; - if (nlinks || type == BREAD) { - if (fts_safe_changedir(sp, cur, dirfd(dirp))) { - if (nlinks && type == BREAD) - cur->fts_errno = errno; - cur->fts_flags |= FTS_DONTCHDIR; - descend = 0; - cderrno = errno; - (void)closedir(dirp); - dirp = NULL; - } else - descend = 1; - } else - descend = 0; - - /* - * Figure out the max file name length that can be stored in the - * current path -- the inner loop allocates more path as necessary. - * We really wouldn't have to do the maxlen calculations here, we - * could do them in fts_read before returning the path, but it's a - * lot easier here since the length is part of the dirent structure. - * - * If not changing directories set a pointer so that can just append - * each new name into the path. - */ - len = NAPPEND(cur); - if (ISSET(FTS_NOCHDIR)) { - cp = sp->fts_path + len; - *cp++ = '/'; - } else { - /* GCC, you're too verbose. */ - cp = NULL; - } - len++; - maxlen = sp->fts_pathlen - len; - - level = cur->fts_level + 1; - - /* Read the directory, attaching each entry to the `link' pointer. */ - doadjust = 0; - for (head = tail = NULL, nitems = 0; dirp && (dp = readdir(dirp));) { - if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name)) - continue; - - if ((p = fts_alloc(sp, dp->d_name, (int)dp->d_namlen)) == NULL) - goto mem1; - if (dp->d_namlen >= maxlen) { /* include space for NUL */ - oldaddr = sp->fts_path; - if (fts_palloc(sp, dp->d_namlen +len + 1)) { - /* - * No more memory for path or structures. Save - * errno, free up the current structure and the - * structures already allocated. - */ -mem1: saved_errno = errno; - if (p) - free(p); - fts_lfree(head); - (void)closedir(dirp); - cur->fts_info = FTS_ERR; - SET(FTS_STOP); - errno = saved_errno; - return (NULL); - } - /* Did realloc() change the pointer? */ - if (oldaddr != sp->fts_path) { - doadjust = 1; - if (ISSET(FTS_NOCHDIR)) - cp = sp->fts_path + len; - } - maxlen = sp->fts_pathlen - len; - } - - if (len + dp->d_namlen >= USHRT_MAX) { - /* - * In an FTSENT, fts_pathlen is a u_short so it is - * possible to wraparound here. If we do, free up - * the current structure and the structures already - * allocated, then error out with ENAMETOOLONG. - */ - free(p); - fts_lfree(head); - (void)closedir(dirp); - cur->fts_info = FTS_ERR; - SET(FTS_STOP); - errno = ENAMETOOLONG; - return (NULL); - } - p->fts_level = level; - p->fts_parent = sp->fts_cur; - p->fts_pathlen = len + dp->d_namlen; - -#ifdef FTS_WHITEOUT - if (dp->d_type == DT_WHT) - p->fts_flags |= FTS_ISW; -#endif - - if (cderrno) { - if (nlinks) { - p->fts_info = FTS_NS; - p->fts_errno = cderrno; - } else - p->fts_info = FTS_NSOK; - p->fts_accpath = cur->fts_accpath; - } else if (nlinks == 0 -#ifdef DT_DIR - || (nostat && - dp->d_type != DT_DIR && dp->d_type != DT_UNKNOWN) -#endif - ) { - p->fts_accpath = - ISSET(FTS_NOCHDIR) ? p->fts_path : p->fts_name; - p->fts_info = FTS_NSOK; - } else { - /* Build a file name for fts_stat to stat. */ - if (ISSET(FTS_NOCHDIR)) { - p->fts_accpath = p->fts_path; - memmove(cp, p->fts_name, p->fts_namelen + 1); - } else - p->fts_accpath = p->fts_name; - /* Stat it. */ - p->fts_info = fts_stat(sp, p, 0); - - /* Decrement link count if applicable. */ - if (nlinks > 0 && (p->fts_info == FTS_D || - p->fts_info == FTS_DC || p->fts_info == FTS_DOT)) - --nlinks; - } - - /* We walk in directory order so "ls -f" doesn't get upset. */ - p->fts_link = NULL; - if (head == NULL) - head = tail = p; - else { - tail->fts_link = p; - tail = p; - } - ++nitems; - } - if (dirp) - (void)closedir(dirp); - - /* - * If realloc() changed the address of the path, adjust the - * addresses for the rest of the tree and the dir list. - */ - if (doadjust) - fts_padjust(sp, head); - - /* - * If not changing directories, reset the path back to original - * state. - */ - if (ISSET(FTS_NOCHDIR)) { - if (len == sp->fts_pathlen || nitems == 0) - --cp; - *cp = '\0'; - } - - /* - * If descended after called from fts_children or after called from - * fts_read and nothing found, get back. At the root level we use - * the saved fd; if one of fts_open()'s arguments is a relative path - * to an empty directory, we wind up here with no other way back. If - * can't get back, we're done. - */ - if (descend && (type == BCHILD || !nitems) && - (cur->fts_level == FTS_ROOTLEVEL ? - FCHDIR(sp, sp->fts_rfd) : CHDIR(sp, ".."))) { - cur->fts_info = FTS_ERR; - SET(FTS_STOP); - return (NULL); - } - - /* If didn't find anything, return NULL. */ - if (!nitems) { - if (type == BREAD) - cur->fts_info = FTS_DP; - return (NULL); - } - - /* Sort the entries. */ - if (sp->fts_compar && nitems > 1) - head = fts_sort(sp, head, nitems); - return (head); -} - -static u_short -fts_stat(sp, p, follow) - FTS *sp; - register FTSENT *p; - int follow; -{ - register FTSENT *t; - register dev_t dev; - register ino_t ino; - struct stat *sbp, sb; - int saved_errno; - - /* If user needs stat info, stat buffer already allocated. */ - sbp = ISSET(FTS_NOSTAT) ? &sb : p->fts_statp; - -#ifdef FTS_WHITEOUT - /* check for whiteout */ - if (p->fts_flags & FTS_ISW) { - if (sbp != &sb) { - memset(sbp, '\0', sizeof (*sbp)); - sbp->st_mode = S_IFWHT; - } - return (FTS_W); - } -#endif - - /* - * If doing a logical walk, or application requested FTS_FOLLOW, do - * a stat(2). If that fails, check for a non-existent symlink. If - * fail, set the errno from the stat call. - */ - if (ISSET(FTS_LOGICAL) || follow) { - if (stat(p->fts_accpath, sbp)) { - saved_errno = errno; - if (!lstat(p->fts_accpath, sbp)) { - errno = 0; - return (FTS_SLNONE); - } - p->fts_errno = saved_errno; - goto err; - } - } else if (lstat(p->fts_accpath, sbp)) { - p->fts_errno = errno; -err: memset(sbp, 0, sizeof(struct stat)); - return (FTS_NS); - } - - if (S_ISDIR(sbp->st_mode)) { - /* - * Set the device/inode. Used to find cycles and check for - * crossing mount points. Also remember the link count, used - * in fts_build to limit the number of stat calls. It is - * understood that these fields are only referenced if fts_info - * is set to FTS_D. - */ - dev = p->fts_dev = sbp->st_dev; - ino = p->fts_ino = sbp->st_ino; - p->fts_nlink = sbp->st_nlink; - - if (ISDOT(p->fts_name)) - return (FTS_DOT); - - /* - * Cycle detection is done by brute force when the directory - * is first encountered. If the tree gets deep enough or the - * number of symbolic links to directories is high enough, - * something faster might be worthwhile. - */ - for (t = p->fts_parent; - t->fts_level >= FTS_ROOTLEVEL; t = t->fts_parent) - if (ino == t->fts_ino && dev == t->fts_dev) { - p->fts_cycle = t; - return (FTS_DC); - } - return (FTS_D); - } - if (S_ISLNK(sbp->st_mode)) - return (FTS_SL); - if (S_ISREG(sbp->st_mode)) - return (FTS_F); - return (FTS_DEFAULT); -} - -static FTSENT * -fts_sort(sp, head, nitems) - FTS *sp; - FTSENT *head; - register int nitems; -{ - register FTSENT **ap, *p; - - /* - * Construct an array of pointers to the structures and call qsort(3). - * Reassemble the array in the order returned by qsort. If unable to - * sort for memory reasons, return the directory entries in their - * current order. Allocate enough space for the current needs plus - * 40 so don't realloc one entry at a time. - */ - if (nitems > sp->fts_nitems) { - struct _ftsent **a; - - sp->fts_nitems = nitems + 40; - if ((a = realloc(sp->fts_array, - sp->fts_nitems * sizeof(FTSENT *))) == NULL) { - if (sp->fts_array) - free(sp->fts_array); - sp->fts_array = NULL; - sp->fts_nitems = 0; - return (head); - } - sp->fts_array = a; - } - for (ap = sp->fts_array, p = head; p; p = p->fts_link) - *ap++ = p; - qsort((void *)sp->fts_array, nitems, sizeof(FTSENT *), sp->fts_compar); - for (head = *(ap = sp->fts_array); --nitems; ++ap) - ap[0]->fts_link = ap[1]; - ap[0]->fts_link = NULL; - return (head); -} - -static FTSENT * -fts_alloc(sp, name, namelen) - FTS *sp; - char *name; - register int namelen; -{ - register FTSENT *p; - size_t len; - - /* - * The file name is a variable length array and no stat structure is - * necessary if the user has set the nostat bit. Allocate the FTSENT - * structure, the file name and the stat structure in one chunk, but - * be careful that the stat structure is reasonably aligned. Since the - * fts_name field is declared to be of size 1, the fts_name pointer is - * namelen + 2 before the first possible address of the stat structure. - */ - len = sizeof(FTSENT) + namelen; - if (!ISSET(FTS_NOSTAT)) - len += sizeof(struct stat) + ALIGNBYTES; - if ((p = malloc(len)) == NULL) - return (NULL); - - /* Copy the name and guarantee NUL termination. */ - memmove(p->fts_name, name, namelen); - p->fts_name[namelen] = '\0'; - - if (!ISSET(FTS_NOSTAT)) - p->fts_statp = (struct stat *)ALIGN(p->fts_name + namelen + 2); - p->fts_namelen = namelen; - p->fts_path = sp->fts_path; - p->fts_errno = 0; - p->fts_flags = 0; - p->fts_instr = FTS_NOINSTR; - p->fts_number = 0; - p->fts_pointer = NULL; - return (p); -} - -static void -fts_lfree(head) - register FTSENT *head; -{ - register FTSENT *p; - - /* Free a linked list of structures. */ - while ((p = head)) { - head = head->fts_link; - free(p); - } -} - -/* - * Allow essentially unlimited paths; find, rm, ls should all work on any tree. - * Most systems will allow creation of paths much longer than MAXPATHLEN, even - * though the kernel won't resolve them. Add the size (not just what's needed) - * plus 256 bytes so don't realloc the path 2 bytes at a time. - */ -static int -fts_palloc(sp, more) - FTS *sp; - size_t more; -{ - char *p; - - sp->fts_pathlen += more + 256; - /* - * Check for possible wraparound. In an FTS, fts_pathlen is - * a signed int but in an FTSENT it is an unsigned short. - * We limit fts_pathlen to USHRT_MAX to be safe in both cases. - */ - if (sp->fts_pathlen < 0 || sp->fts_pathlen >= USHRT_MAX) { - if (sp->fts_path) - free(sp->fts_path); - sp->fts_path = NULL; - errno = ENAMETOOLONG; - return (1); - } - p = realloc(sp->fts_path, sp->fts_pathlen); - if (p == NULL) { - if (sp->fts_path) - free(sp->fts_path); - sp->fts_path = NULL; - return (1); - } - sp->fts_path = p; - return (0); -} - -/* - * When the path is realloc'd, have to fix all of the pointers in structures - * already returned. - */ -static void -fts_padjust(sp, head) - FTS *sp; - FTSENT *head; -{ - FTSENT *p; - char *addr = sp->fts_path; - -#define ADJUST(p) { \ - if ((p)->fts_accpath != (p)->fts_name) { \ - (p)->fts_accpath = \ - (char *)addr + ((p)->fts_accpath - (p)->fts_path); \ - } \ - (p)->fts_path = addr; \ -} - /* Adjust the current set of children. */ - for (p = sp->fts_child; p; p = p->fts_link) - ADJUST(p); - - /* Adjust the rest of the tree, including the current level. */ - for (p = head; p->fts_level >= FTS_ROOTLEVEL;) { - ADJUST(p); - p = p->fts_link ? p->fts_link : p->fts_parent; - } -} - -static size_t -fts_maxarglen(argv) - char * const *argv; -{ - size_t len, max; - - for (max = 0; *argv; ++argv) - if ((len = strlen(*argv)) > max) - max = len; - return (max + 1); -} - -/* - * Change to dir specified by fd or p->fts_accpath without getting - * tricked by someone changing the world out from underneath us. - * Assumes p->fts_dev and p->fts_ino are filled in. - */ -static int -fts_safe_changedir(sp, p, fd) - FTS *sp; - FTSENT *p; - int fd; -{ - int ret, oerrno, newfd; - struct stat sb; - - newfd = fd; - if (ISSET(FTS_NOCHDIR)) - return (0); - if (fd < 0 && (newfd = _open(p->fts_accpath, O_RDONLY, 0)) < 0) - return (-1); - if (fstat(newfd, &sb)) { - ret = -1; - goto bail; - } - if (p->fts_dev != sb.st_dev || p->fts_ino != sb.st_ino) { - errno = ENOENT; /* disinformation */ - ret = -1; - goto bail; - } - ret = fchdir(newfd); -bail: - oerrno = errno; - if (fd < 0) - (void)_close(newfd); - errno = oerrno; - return (ret); -} diff --git a/lib/libc/gen/fts-compat.h b/lib/libc/gen/fts-compat.h deleted file mode 100644 index 4fa4a3a..0000000 --- a/lib/libc/gen/fts-compat.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * 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. - * - * @(#)fts.h 8.3 (Berkeley) 8/14/94 - */ - -#ifndef _FTS_H_ -#define _FTS_H_ - -typedef struct { - struct _ftsent *fts_cur; /* current node */ - struct _ftsent *fts_child; /* linked list of children */ - struct _ftsent **fts_array; /* sort array */ - dev_t fts_dev; /* starting device # */ - char *fts_path; /* path for this descent */ - int fts_rfd; /* fd for root */ - int fts_pathlen; /* sizeof(path) */ - int fts_nitems; /* elements in the sort array */ - int (*fts_compar)(); /* compare function */ - -#define FTS_COMFOLLOW 0x001 /* follow command line symlinks */ -#define FTS_LOGICAL 0x002 /* logical walk */ -#define FTS_NOCHDIR 0x004 /* don't change directories */ -#define FTS_NOSTAT 0x008 /* don't get stat info */ -#define FTS_PHYSICAL 0x010 /* physical walk */ -#define FTS_SEEDOT 0x020 /* return dot and dot-dot */ -#define FTS_XDEV 0x040 /* don't cross devices */ -#define FTS_WHITEOUT 0x080 /* return whiteout information */ -#define FTS_OPTIONMASK 0x0ff /* valid user option mask */ - -#define FTS_NAMEONLY 0x100 /* (private) child names only */ -#define FTS_STOP 0x200 /* (private) unrecoverable error */ - int fts_options; /* fts_open options, global flags */ -} FTS; - -typedef struct _ftsent { - struct _ftsent *fts_cycle; /* cycle node */ - struct _ftsent *fts_parent; /* parent directory */ - struct _ftsent *fts_link; /* next file in directory */ - long fts_number; /* local numeric value */ - void *fts_pointer; /* local address value */ - char *fts_accpath; /* access path */ - char *fts_path; /* root path */ - int fts_errno; /* errno for this node */ - int fts_symfd; /* fd for symlink */ - u_short fts_pathlen; /* strlen(fts_path) */ - u_short fts_namelen; /* strlen(fts_name) */ - - ino_t fts_ino; /* inode */ - dev_t fts_dev; /* device */ - nlink_t fts_nlink; /* link count */ - -#define FTS_ROOTPARENTLEVEL -1 -#define FTS_ROOTLEVEL 0 - short fts_level; /* depth (-1 to N) */ - -#define FTS_D 1 /* preorder directory */ -#define FTS_DC 2 /* directory that causes cycles */ -#define FTS_DEFAULT 3 /* none of the above */ -#define FTS_DNR 4 /* unreadable directory */ -#define FTS_DOT 5 /* dot or dot-dot */ -#define FTS_DP 6 /* postorder directory */ -#define FTS_ERR 7 /* error; errno is set */ -#define FTS_F 8 /* regular file */ -#define FTS_INIT 9 /* initialized only */ -#define FTS_NS 10 /* stat(2) failed */ -#define FTS_NSOK 11 /* no stat(2) requested */ -#define FTS_SL 12 /* symbolic link */ -#define FTS_SLNONE 13 /* symbolic link without target */ -#define FTS_W 14 /* whiteout object */ - u_short fts_info; /* user flags for FTSENT structure */ - -#define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ -#define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ -#define FTS_ISW 0x04 /* this is a whiteout object */ - u_short fts_flags; /* private flags for FTSENT structure */ - -#define FTS_AGAIN 1 /* read node again */ -#define FTS_FOLLOW 2 /* follow symbolic link */ -#define FTS_NOINSTR 3 /* no instructions */ -#define FTS_SKIP 4 /* discard node */ - u_short fts_instr; /* fts_set() instructions */ - - struct stat *fts_statp; /* stat(2) information */ - char fts_name[1]; /* file name */ -} FTSENT; - -#include - -__BEGIN_DECLS -FTSENT *fts_children __P((FTS *, int)); -int fts_close __P((FTS *)); -FTS *fts_open __P((char * const *, int, - int (*)(const FTSENT **, const FTSENT **))); -FTSENT *fts_read __P((FTS *)); -int fts_set __P((FTS *, FTSENT *, int)); -__END_DECLS - -#endif /* !_FTS_H_ */ diff --git a/lib/libc/gen/fts.3 b/lib/libc/gen/fts.3 deleted file mode 100644 index ba21c89..0000000 --- a/lib/libc/gen/fts.3 +++ /dev/null @@ -1,755 +0,0 @@ -.\" Copyright (c) 1989, 1991, 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. -.\" -.\" @(#)fts.3 8.5 (Berkeley) 4/16/94 -.\" $FreeBSD$ -.\" -.Dd April 16, 1994 -.Dt FTS 3 -.Os -.Sh NAME -.Nm fts -.Nd traverse a file hierarchy -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Fd #include -.Ft FTS * -.Fn fts_open "char * const *path_argv" "int options" "int (*compar)(const FTSENT **, const FTSENT **)" -.Ft FTSENT * -.Fn fts_read "FTS *ftsp" -.Ft FTSENT * -.Fn fts_children "FTS *ftsp" "int options" -.Ft int -.Fn fts_set "FTS *ftsp" "FTSENT *f" "int options" -.Ft int -.Fn fts_close "FTS *ftsp" -.Sh DESCRIPTION -The -.Nm fts -functions are provided for traversing -.Tn UNIX -file hierarchies. -A simple overview is that the -.Fn fts_open -function returns a -.Dq handle -on a file hierarchy, which is then supplied to -the other -.Nm fts -functions. -The function -.Fn fts_read -returns a pointer to a structure describing one of the files in the file -hierarchy. -The function -.Fn fts_children -returns a pointer to a linked list of structures, each of which describes -one of the files contained in a directory in the hierarchy. -In general, directories are visited two distinguishable times; in pre-order -(before any of their descendants are visited) and in post-order (after all -of their descendants have been visited). -Files are visited once. -It is possible to walk the hierarchy -.Dq logically -(ignoring symbolic links) -or physically (visiting symbolic links), order the walk of the hierarchy or -prune and/or re-visit portions of the hierarchy. -.Pp -Two structures are defined (and typedef'd) in the include file -.Aq Pa fts.h . -The first is -.Fa FTS , -the structure that represents the file hierarchy itself. -The second is -.Fa FTSENT , -the structure that represents a file in the file -hierarchy. -Normally, an -.Fa FTSENT -structure is returned for every file in the file -hierarchy. -In this manual page, -.Dq file -and -.Dq Fa FTSENT No structure -are generally -interchangeable. -The -.Fa FTSENT -structure contains at least the following fields, which are -described in greater detail below: -.Bd -literal -typedef struct _ftsent { - u_short fts_info; /* flags for FTSENT structure */ - char *fts_accpath; /* access path */ - char *fts_path; /* root path */ - u_short fts_pathlen; /* strlen(fts_path) */ - char *fts_name; /* file name */ - u_short fts_namelen; /* strlen(fts_name) */ - short fts_level; /* depth (\-1 to N) */ - int fts_errno; /* file errno */ - long fts_number; /* local numeric value */ - void *fts_pointer; /* local address value */ - struct ftsent *fts_parent; /* parent directory */ - struct ftsent *fts_link; /* next file structure */ - struct ftsent *fts_cycle; /* cycle structure */ - struct stat *fts_statp; /* stat(2) information */ -} FTSENT; -.Ed -.Pp -These fields are defined as follows: -.Bl -tag -width "fts_namelen" -.It Fa fts_info -One of the following values describing the returned -.Fa FTSENT -structure and -the file it represents. -With the exception of directories without errors -.Pq Dv FTS_D , -all of these -entries are terminal, that is, they will not be revisited, nor will any -of their descendants be visited. -.Bl -tag -width FTS_DEFAULT -.It Dv FTS_D -A directory being visited in pre-order. -.It Dv FTS_DC -A directory that causes a cycle in the tree. -(The -.Fa fts_cycle -field of the -.Fa FTSENT -structure will be filled in as well.) -.It Dv FTS_DEFAULT -Any -.Fa FTSENT -structure that represents a file type not explicitly described -by one of the other -.Fa fts_info -values. -.It Dv FTS_DNR -A directory which cannot be read. -This is an error return, and the -.Fa fts_errno -field will be set to indicate what caused the error. -.It Dv FTS_DOT -A file named -.Ql \&. -or -.Ql .. -which was not specified as a file name to -.Fn fts_open -(see -.Dv FTS_SEEDOT ) . -.It Dv FTS_DP -A directory being visited in post-order. -The contents of the -.Fa FTSENT -structure will be unchanged from when -it was returned in pre-order, i.e. with the -.Fa fts_info -field set to -.Dv FTS_D . -.It Dv FTS_ERR -This is an error return, and the -.Fa fts_errno -field will be set to indicate what caused the error. -.It Dv FTS_F -A regular file. -.It Dv FTS_NS -A file for which no -.Xr stat 2 -information was available. -The contents of the -.Fa fts_statp -field are undefined. -This is an error return, and the -.Fa fts_errno -field will be set to indicate what caused the error. -.It Dv FTS_NSOK -A file for which no -.Xr stat 2 -information was requested. -The contents of the -.Fa fts_statp -field are undefined. -.It Dv FTS_SL -A symbolic link. -.It Dv FTS_SLNONE -A symbolic link with a non-existent target. -The contents of the -.Fa fts_statp -field reference the file characteristic information for the symbolic link -itself. -.El -.It Fa fts_accpath -A path for accessing the file from the current directory. -.It Fa fts_path -The path for the file relative to the root of the traversal. -This path contains the path specified to -.Fn fts_open -as a prefix. -.It Fa fts_pathlen -The length of the string referenced by -.Fa fts_path . -.It Fa fts_name -The name of the file. -.It Fa fts_namelen -The length of the string referenced by -.Fa fts_name . -.It Fa fts_level -The depth of the traversal, numbered from \-1 to N, where this file -was found. -The -.Fa FTSENT -structure representing the parent of the starting point (or root) -of the traversal is numbered \-1, and the -.Fa FTSENT -structure for the root -itself is numbered 0. -.It Fa fts_errno -Upon return of a -.Fa FTSENT -structure from the -.Fn fts_children -or -.Fn fts_read -functions, with its -.Fa fts_info -field set to -.Dv FTS_DNR , -.Dv FTS_ERR -or -.Dv FTS_NS , -the -.Fa fts_errno -field contains the value of the external variable -.Va errno -specifying the cause of the error. -Otherwise, the contents of the -.Fa fts_errno -field are undefined. -.It Fa fts_number -This field is provided for the use of the application program and is -not modified by the -.Nm fts -functions. -It is initialized to 0. -.It Fa fts_pointer -This field is provided for the use of the application program and is -not modified by the -.Nm fts -functions. -It is initialized to -.Dv NULL . -.It Fa fts_parent -A pointer to the -.Fa FTSENT -structure referencing the file in the hierarchy -immediately above the current file, i.e. the directory of which this -file is a member. -A parent structure for the initial entry point is provided as well, -however, only the -.Fa fts_level , -.Fa fts_number -and -.Fa fts_pointer -fields are guaranteed to be initialized. -.It Fa fts_link -Upon return from the -.Fn fts_children -function, the -.Fa fts_link -field points to the next structure in the NULL-terminated linked list of -directory members. -Otherwise, the contents of the -.Fa fts_link -field are undefined. -.It Fa fts_cycle -If a directory causes a cycle in the hierarchy (see -.Dv FTS_DC ) , -either because -of a hard link between two directories, or a symbolic link pointing to a -directory, the -.Fa fts_cycle -field of the structure will point to the -.Fa FTSENT -structure in the hierarchy that references the same file as the current -.Fa FTSENT -structure. -Otherwise, the contents of the -.Fa fts_cycle -field are undefined. -.It Fa fts_statp -A pointer to -.Xr stat 2 -information for the file. -.El -.Pp -A single buffer is used for all of the paths of all of the files in the -file hierarchy. -Therefore, the -.Fa fts_path -and -.Fa fts_accpath -fields are guaranteed to be -.Dv NUL Ns -terminated -.Em only -for the file most recently returned by -.Fn fts_read . -To use these fields to reference any files represented by other -.Fa FTSENT -structures will require that the path buffer be modified using the -information contained in that -.Fa FTSENT -structure's -.Fa fts_pathlen -field. -Any such modifications should be undone before further calls to -.Fn fts_read -are attempted. -The -.Fa fts_name -field is always -.Dv NUL Ns -terminated. -.Sh FTS_OPEN -The -.Fn fts_open -function takes a pointer to an array of character pointers naming one -or more paths which make up a logical file hierarchy to be traversed. -The array must be terminated by a -.Dv NULL -pointer. -.Pp -There are -a number of options, at least one of which (either -.Dv FTS_LOGICAL -or -.Dv FTS_PHYSICAL ) -must be specified. -The options are selected by -.Em or Ns 'ing -the following values: -.Bl -tag -width "FTS_PHYSICAL" -.It Dv FTS_COMFOLLOW -This option causes any symbolic link specified as a root path to be -followed immediately whether or not -.Dv FTS_LOGICAL -is also specified. -.It Dv FTS_LOGICAL -This option causes the -.Nm fts -routines to return -.Fa FTSENT -structures for the targets of symbolic links -instead of the symbolic links themselves. -If this option is set, the only symbolic links for which -.Fa FTSENT -structures -are returned to the application are those referencing non-existent files. -Either -.Dv FTS_LOGICAL -or -.Dv FTS_PHYSICAL -.Em must -be provided to the -.Fn fts_open -function. -.It Dv FTS_NOCHDIR -As a performance optimization, the -.Nm fts -functions change directories as they walk the file hierarchy. -This has the side-effect that an application cannot rely on being -in any particular directory during the traversal. -The -.Dv FTS_NOCHDIR -option turns off this optimization, and the -.Nm fts -functions will not change the current directory. -Note that applications should not themselves change their current directory -and try to access files unless -.Dv FTS_NOCHDIR -is specified and absolute -pathnames were provided as arguments to -.Fn fts_open . -.It Dv FTS_NOSTAT -By default, returned -.Fa FTSENT -structures reference file characteristic information (the -.Fa statp -field) for each file visited. -This option relaxes that requirement as a performance optimization, -allowing the -.Nm fts -functions to set the -.Fa fts_info -field to -.Dv FTS_NSOK -and leave the contents of the -.Fa statp -field undefined. -.It Dv FTS_PHYSICAL -This option causes the -.Nm fts -routines to return -.Fa FTSENT -structures for symbolic links themselves instead -of the target files they point to. -If this option is set, -.Fa FTSENT -structures for all symbolic links in the -hierarchy are returned to the application. -Either -.Dv FTS_LOGICAL -or -.Dv FTS_PHYSICAL -.Em must -be provided to the -.Fn fts_open -function. -.It Dv FTS_SEEDOT -By default, unless they are specified as path arguments to -.Fn fts_open , -any files named -.Ql \&. -or -.Ql .. -encountered in the file hierarchy are ignored. -This option causes the -.Nm fts -routines to return -.Fa FTSENT -structures for them. -.It Dv FTS_XDEV -This option prevents -.Nm fts -from descending into directories that have a different device number -than the file from which the descent began. -.El -.Pp -The argument -.Fn compar -specifies a user-defined function which may be used to order the traversal -of the hierarchy. -It -takes two pointers to pointers to -.Fa FTSENT -structures as arguments and -should return a negative value, zero, or a positive value to indicate -if the file referenced by its first argument comes before, in any order -with respect to, or after, the file referenced by its second argument. -The -.Fa fts_accpath , -.Fa fts_path -and -.Fa fts_pathlen -fields of the -.Fa FTSENT -structures may -.Em never -be used in this comparison. -If the -.Fa fts_info -field is set to -.Dv FTS_NS -or -.Dv FTS_NSOK , -the -.Fa fts_statp -field may not either. -If the -.Fn compar -argument is -.Dv NULL , -the directory traversal order is in the order listed in -.Fa path_argv -for the root paths, and in the order listed in the directory for -everything else. -.Sh FTS_READ -The -.Fn fts_read -function returns a pointer to an -.Fa FTSENT -structure describing a file in -the hierarchy. -Directories (that are readable and do not cause cycles) are visited at -least twice, once in pre-order and once in post-order. -All other files are visited at least once. -(Hard links between directories that do not cause cycles or symbolic -links to symbolic links may cause files to be visited more than once, -or directories more than twice.) -.Pp -If all the members of the hierarchy have been returned, -.Fn fts_read -returns -.Dv NULL -and sets the external variable -.Va errno -to 0. -If an error unrelated to a file in the hierarchy occurs, -.Fn fts_read -returns -.Dv NULL -and sets -.Va errno -appropriately. -If an error related to a returned file occurs, a pointer to an -.Fa FTSENT -structure is returned, and -.Va errno -may or may not have been set (see -.Fa fts_info ) . -.Pp -The -.Fa FTSENT -structures returned by -.Fn fts_read -may be overwritten after a call to -.Fn fts_close -on the same file hierarchy stream, or, after a call to -.Fn fts_read -on the same file hierarchy stream unless they represent a file of type -directory, in which case they will not be overwritten until after a call to -.Fn fts_read -after the -.Fa FTSENT -structure has been returned by the function -.Fn fts_read -in post-order. -.Sh FTS_CHILDREN -The -.Fn fts_children -function returns a pointer to an -.Fa FTSENT -structure describing the first entry in a NULL-terminated linked list of -the files in the directory represented by the -.Fa FTSENT -structure most recently returned by -.Fn fts_read . -The list is linked through the -.Fa fts_link -field of the -.Fa FTSENT -structure, and is ordered by the user-specified comparison function, if any. -Repeated calls to -.Fn fts_children -will recreate this linked list. -.Pp -As a special case, if -.Fn fts_read -has not yet been called for a hierarchy, -.Fn fts_children -will return a pointer to the files in the logical directory specified to -.Fn fts_open , -i.e. the arguments specified to -.Fn fts_open . -Otherwise, if the -.Fa FTSENT -structure most recently returned by -.Fn fts_read -is not a directory being visited in pre-order, -or the directory does not contain any files, -.Fn fts_children -returns -.Dv NULL -and sets -.Va errno -to zero. -If an error occurs, -.Fn fts_children -returns -.Dv NULL -and sets -.Va errno -appropriately. -.Pp -The -.Fa FTSENT -structures returned by -.Fn fts_children -may be overwritten after a call to -.Fn fts_children , -.Fn fts_close -or -.Fn fts_read -on the same file hierarchy stream. -.Pp -.Em Option -may be set to the following value: -.Bl -tag -width FTS_NAMEONLY -.It Dv FTS_NAMEONLY -Only the names of the files are needed. -The contents of all the fields in the returned linked list of structures -are undefined with the exception of the -.Fa fts_name -and -.Fa fts_namelen -fields. -.El -.Sh FTS_SET -The function -.Fn fts_set -allows the user application to determine further processing for the -file -.Fa f -of the stream -.Fa ftsp . -The -.Fn fts_set -function -returns 0 on success, and \-1 if an error occurs. -.Em Option -must be set to one of the following values: -.Bl -tag -width FTS_PHYSICAL -.It Dv FTS_AGAIN -Re-visit the file; any file type may be re-visited. -The next call to -.Fn fts_read -will return the referenced file. -The -.Fa fts_stat -and -.Fa fts_info -fields of the structure will be reinitialized at that time, -but no other fields will have been changed. -This option is meaningful only for the most recently returned -file from -.Fn fts_read . -Normal use is for post-order directory visits, where it causes the -directory to be re-visited (in both pre and post-order) as well as all -of its descendants. -.It Dv FTS_FOLLOW -The referenced file must be a symbolic link. -If the referenced file is the one most recently returned by -.Fn fts_read , -the next call to -.Fn fts_read -returns the file with the -.Fa fts_info -and -.Fa fts_statp -fields reinitialized to reflect the target of the symbolic link instead -of the symbolic link itself. -If the file is one of those most recently returned by -.Fn fts_children , -the -.Fa fts_info -and -.Fa fts_statp -fields of the structure, when returned by -.Fn fts_read , -will reflect the target of the symbolic link instead of the symbolic link -itself. -In either case, if the target of the symbolic link does not exist the -fields of the returned structure will be unchanged and the -.Fa fts_info -field will be set to -.Dv FTS_SLNONE . -.Pp -If the target of the link is a directory, the pre-order return, followed -by the return of all of its descendants, followed by a post-order return, -is done. -.It Dv FTS_SKIP -No descendants of this file are visited. -The file may be one of those most recently returned by either -.Fn fts_children -or -.Fn fts_read . -.El -.Sh FTS_CLOSE -The -.Fn fts_close -function closes a file hierarchy stream -.Fa ftsp -and restores the current directory to the directory from which -.Fn fts_open -was called to open -.Fa ftsp . -The -.Fn fts_close -function -returns 0 on success, and \-1 if an error occurs. -.Sh ERRORS -The function -.Fn fts_open -may fail and set -.Va errno -for any of the errors specified for the library functions -.Xr open 2 -and -.Xr malloc 3 . -.Pp -The function -.Fn fts_close -may fail and set -.Va errno -for any of the errors specified for the library functions -.Xr chdir 2 -and -.Xr close 2 . -.Pp -The functions -.Fn fts_read -and -.Fn fts_children -may fail and set -.Va errno -for any of the errors specified for the library functions -.Xr chdir 2 , -.Xr malloc 3 , -.Xr opendir 3 , -.Xr readdir 3 -and -.Xr stat 2 . -.Pp -In addition, -.Fn fts_children , -.Fn fts_open -and -.Fn fts_set -may fail and set -.Va errno -as follows: -.Bl -tag -width Er -.It Bq Er EINVAL -The options were invalid. -.El -.Sh SEE ALSO -.Xr find 1 , -.Xr chdir 2 , -.Xr stat 2 , -.Xr qsort 3 -.Sh STANDARDS -The -.Nm fts -utility is expected to be included in a future -.St -p1003.1-88 -revision. diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c deleted file mode 100644 index 6b92a12..0000000 --- a/lib/libc/gen/fts.c +++ /dev/null @@ -1,1114 +0,0 @@ -/*- - * Copyright (c) 1990, 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. - * - * $OpenBSD: fts.c,v 1.22 1999/10/03 19:22:22 millert Exp $ - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; -#else -static char rcsid[] = "$FreeBSD$"; -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -static FTSENT *fts_alloc __P((FTS *, char *, int)); -static FTSENT *fts_build __P((FTS *, int)); -static void fts_lfree __P((FTSENT *)); -static void fts_load __P((FTS *, FTSENT *)); -static size_t fts_maxarglen __P((char * const *)); -static void fts_padjust __P((FTS *, FTSENT *)); -static int fts_palloc __P((FTS *, size_t)); -static FTSENT *fts_sort __P((FTS *, FTSENT *, int)); -static u_short fts_stat __P((FTS *, FTSENT *, int)); -static int fts_safe_changedir __P((FTS *, FTSENT *, int)); - -#define ISDOT(a) (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2]))) - -#define CLR(opt) (sp->fts_options &= ~(opt)) -#define ISSET(opt) (sp->fts_options & (opt)) -#define SET(opt) (sp->fts_options |= (opt)) - -#define CHDIR(sp, path) (!ISSET(FTS_NOCHDIR) && chdir(path)) -#define FCHDIR(sp, fd) (!ISSET(FTS_NOCHDIR) && fchdir(fd)) - -/* fts_build flags */ -#define BCHILD 1 /* fts_children */ -#define BNAMES 2 /* fts_children, names only */ -#define BREAD 3 /* fts_read */ - -FTS * -fts_open(argv, options, compar) - char * const *argv; - register int options; - int (*compar) __P((const FTSENT **, const FTSENT **)); -{ - register FTS *sp; - register FTSENT *p, *root; - register int nitems; - FTSENT *parent, *tmp; - int len; - - /* Options check. */ - if (options & ~FTS_OPTIONMASK) { - errno = EINVAL; - return (NULL); - } - - /* Allocate/initialize the stream */ - if ((sp = malloc((u_int)sizeof(FTS))) == NULL) - return (NULL); - memset(sp, 0, sizeof(FTS)); - sp->fts_compar = compar; - sp->fts_options = options; - - /* Shush, GCC. */ - tmp = NULL; - - /* Logical walks turn on NOCHDIR; symbolic links are too hard. */ - if (ISSET(FTS_LOGICAL)) - SET(FTS_NOCHDIR); - - /* - * Start out with 1K of path space, and enough, in any case, - * to hold the user's paths. - */ - if (fts_palloc(sp, MAX(fts_maxarglen(argv), MAXPATHLEN))) - goto mem1; - - /* Allocate/initialize root's parent. */ - if ((parent = fts_alloc(sp, "", 0)) == NULL) - goto mem2; - parent->fts_level = FTS_ROOTPARENTLEVEL; - - /* Allocate/initialize root(s). */ - for (root = NULL, nitems = 0; *argv; ++argv, ++nitems) { - /* Don't allow zero-length paths. */ - if ((len = strlen(*argv)) == 0) { - errno = ENOENT; - goto mem3; - } - - p = fts_alloc(sp, *argv, len); - p->fts_level = FTS_ROOTLEVEL; - p->fts_parent = parent; - p->fts_accpath = p->fts_name; - p->fts_info = fts_stat(sp, p, ISSET(FTS_COMFOLLOW)); - - /* Command-line "." and ".." are real directories. */ - if (p->fts_info == FTS_DOT) - p->fts_info = FTS_D; - - /* - * If comparison routine supplied, traverse in sorted - * order; otherwise traverse in the order specified. - */ - if (compar) { - p->fts_link = root; - root = p; - } else { - p->fts_link = NULL; - if (root == NULL) - tmp = root = p; - else { - tmp->fts_link = p; - tmp = p; - } - } - } - if (compar && nitems > 1) - root = fts_sort(sp, root, nitems); - - /* - * Allocate a dummy pointer and make fts_read think that we've just - * finished the node before the root(s); set p->fts_info to FTS_INIT - * so that everything about the "current" node is ignored. - */ - if ((sp->fts_cur = fts_alloc(sp, "", 0)) == NULL) - goto mem3; - sp->fts_cur->fts_link = root; - sp->fts_cur->fts_info = FTS_INIT; - - /* - * If using chdir(2), grab a file descriptor pointing to dot to ensure - * that we can get back here; this could be avoided for some paths, - * but almost certainly not worth the effort. Slashes, symbolic links, - * and ".." are all fairly nasty problems. Note, if we can't get the - * descriptor we run anyway, just more slowly. - */ - if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = _open(".", O_RDONLY, 0)) < 0) - SET(FTS_NOCHDIR); - - return (sp); - -mem3: fts_lfree(root); - free(parent); -mem2: free(sp->fts_path); -mem1: free(sp); - return (NULL); -} - -static void -fts_load(sp, p) - FTS *sp; - register FTSENT *p; -{ - register int len; - register char *cp; - - /* - * Load the stream structure for the next traversal. Since we don't - * actually enter the directory until after the preorder visit, set - * the fts_accpath field specially so the chdir gets done to the right - * place and the user can access the first node. From fts_open it's - * known that the path will fit. - */ - len = p->fts_pathlen = p->fts_namelen; - memmove(sp->fts_path, p->fts_name, len + 1); - if ((cp = strrchr(p->fts_name, '/')) && (cp != p->fts_name || cp[1])) { - len = strlen(++cp); - memmove(p->fts_name, cp, len + 1); - p->fts_namelen = len; - } - p->fts_accpath = p->fts_path = sp->fts_path; - sp->fts_dev = p->fts_dev; -} - -int -fts_close(sp) - FTS *sp; -{ - register FTSENT *freep, *p; - int saved_errno; - - /* - * This still works if we haven't read anything -- the dummy structure - * points to the root list, so we step through to the end of the root - * list which has a valid parent pointer. - */ - if (sp->fts_cur) { - for (p = sp->fts_cur; p->fts_level >= FTS_ROOTLEVEL;) { - freep = p; - p = p->fts_link ? p->fts_link : p->fts_parent; - free(freep); - } - free(p); - } - - /* Free up child linked list, sort array, path buffer. */ - if (sp->fts_child) - fts_lfree(sp->fts_child); - if (sp->fts_array) - free(sp->fts_array); - free(sp->fts_path); - - /* Return to original directory, save errno if necessary. */ - if (!ISSET(FTS_NOCHDIR)) { - saved_errno = fchdir(sp->fts_rfd) ? errno : 0; - (void)_close(sp->fts_rfd); - - /* Set errno and return. */ - if (saved_errno != 0) { - /* Free up the stream pointer. */ - free(sp); - errno = saved_errno; - return (-1); - } - } - - /* Free up the stream pointer. */ - free(sp); - return (0); -} - -/* - * Special case of "/" at the end of the path so that slashes aren't - * appended which would cause paths to be written as "....//foo". - */ -#define NAPPEND(p) \ - (p->fts_path[p->fts_pathlen - 1] == '/' \ - ? p->fts_pathlen - 1 : p->fts_pathlen) - -FTSENT * -fts_read(sp) - register FTS *sp; -{ - register FTSENT *p, *tmp; - register int instr; - register char *t; - int saved_errno; - - /* If finished or unrecoverable error, return NULL. */ - if (sp->fts_cur == NULL || ISSET(FTS_STOP)) - return (NULL); - - /* Set current node pointer. */ - p = sp->fts_cur; - - /* Save and zero out user instructions. */ - instr = p->fts_instr; - p->fts_instr = FTS_NOINSTR; - - /* Any type of file may be re-visited; re-stat and re-turn. */ - if (instr == FTS_AGAIN) { - p->fts_info = fts_stat(sp, p, 0); - return (p); - } - - /* - * Following a symlink -- SLNONE test allows application to see - * SLNONE and recover. If indirecting through a symlink, have - * keep a pointer to current location. If unable to get that - * pointer, follow fails. - */ - if (instr == FTS_FOLLOW && - (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) { - p->fts_info = fts_stat(sp, p, 1); - if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { - if ((p->fts_symfd = _open(".", O_RDONLY, 0)) < 0) { - p->fts_errno = errno; - p->fts_info = FTS_ERR; - } else - p->fts_flags |= FTS_SYMFOLLOW; - } - return (p); - } - - /* Directory in pre-order. */ - if (p->fts_info == FTS_D) { - /* If skipped or crossed mount point, do post-order visit. */ - if (instr == FTS_SKIP || - (ISSET(FTS_XDEV) && p->fts_dev != sp->fts_dev)) { - if (p->fts_flags & FTS_SYMFOLLOW) - (void)_close(p->fts_symfd); - if (sp->fts_child) { - fts_lfree(sp->fts_child); - sp->fts_child = NULL; - } - p->fts_info = FTS_DP; - return (p); - } - - /* Rebuild if only read the names and now traversing. */ - if (sp->fts_child && ISSET(FTS_NAMEONLY)) { - CLR(FTS_NAMEONLY); - fts_lfree(sp->fts_child); - sp->fts_child = NULL; - } - - /* - * Cd to the subdirectory. - * - * If have already read and now fail to chdir, whack the list - * to make the names come out right, and set the parent errno - * so the application will eventually get an error condition. - * Set the FTS_DONTCHDIR flag so that when we logically change - * directories back to the parent we don't do a chdir. - * - * If haven't read do so. If the read fails, fts_build sets - * FTS_STOP or the fts_info field of the node. - */ - if (sp->fts_child) { - if (fts_safe_changedir(sp, p, -1)) { - p->fts_errno = errno; - p->fts_flags |= FTS_DONTCHDIR; - for (p = sp->fts_child; p; p = p->fts_link) - p->fts_accpath = - p->fts_parent->fts_accpath; - } - } else if ((sp->fts_child = fts_build(sp, BREAD)) == NULL) { - if (ISSET(FTS_STOP)) - return (NULL); - return (p); - } - p = sp->fts_child; - sp->fts_child = NULL; - goto name; - } - - /* Move to the next node on this level. */ -next: tmp = p; - if ((p = p->fts_link)) { - free(tmp); - - /* - * If reached the top, return to the original directory (or - * the root of the tree), and load the paths for the next root. - */ - if (p->fts_level == FTS_ROOTLEVEL) { - if (FCHDIR(sp, sp->fts_rfd)) { - SET(FTS_STOP); - return (NULL); - } - fts_load(sp, p); - return (sp->fts_cur = p); - } - - /* - * User may have called fts_set on the node. If skipped, - * ignore. If followed, get a file descriptor so we can - * get back if necessary. - */ - if (p->fts_instr == FTS_SKIP) - goto next; - if (p->fts_instr == FTS_FOLLOW) { - p->fts_info = fts_stat(sp, p, 1); - if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { - if ((p->fts_symfd = - _open(".", O_RDONLY, 0)) < 0) { - p->fts_errno = errno; - p->fts_info = FTS_ERR; - } else - p->fts_flags |= FTS_SYMFOLLOW; - } - p->fts_instr = FTS_NOINSTR; - } - -name: t = sp->fts_path + NAPPEND(p->fts_parent); - *t++ = '/'; - memmove(t, p->fts_name, p->fts_namelen + 1); - return (sp->fts_cur = p); - } - - /* Move up to the parent node. */ - p = tmp->fts_parent; - free(tmp); - - if (p->fts_level == FTS_ROOTPARENTLEVEL) { - /* - * Done; free everything up and set errno to 0 so the user - * can distinguish between error and EOF. - */ - free(p); - errno = 0; - return (sp->fts_cur = NULL); - } - - /* NUL terminate the pathname. */ - sp->fts_path[p->fts_pathlen] = '\0'; - - /* - * Return to the parent directory. If at a root node or came through - * a symlink, go back through the file descriptor. Otherwise, cd up - * one directory. - */ - if (p->fts_level == FTS_ROOTLEVEL) { - if (FCHDIR(sp, sp->fts_rfd)) { - SET(FTS_STOP); - return (NULL); - } - } else if (p->fts_flags & FTS_SYMFOLLOW) { - if (FCHDIR(sp, p->fts_symfd)) { - saved_errno = errno; - (void)_close(p->fts_symfd); - errno = saved_errno; - SET(FTS_STOP); - return (NULL); - } - (void)_close(p->fts_symfd); - } else if (!(p->fts_flags & FTS_DONTCHDIR)) { - if (CHDIR(sp, "..")) { - SET(FTS_STOP); - return (NULL); - } - } - p->fts_info = p->fts_errno ? FTS_ERR : FTS_DP; - return (sp->fts_cur = p); -} - -/* - * Fts_set takes the stream as an argument although it's not used in this - * implementation; it would be necessary if anyone wanted to add global - * semantics to fts using fts_set. An error return is allowed for similar - * reasons. - */ -/* ARGSUSED */ -int -fts_set(sp, p, instr) - FTS *sp; - FTSENT *p; - int instr; -{ - if (instr && instr != FTS_AGAIN && instr != FTS_FOLLOW && - instr != FTS_NOINSTR && instr != FTS_SKIP) { - errno = EINVAL; - return (1); - } - p->fts_instr = instr; - return (0); -} - -FTSENT * -fts_children(sp, instr) - register FTS *sp; - int instr; -{ - register FTSENT *p; - int fd; - - if (instr && instr != FTS_NAMEONLY) { - errno = EINVAL; - return (NULL); - } - - /* Set current node pointer. */ - p = sp->fts_cur; - - /* - * Errno set to 0 so user can distinguish empty directory from - * an error. - */ - errno = 0; - - /* Fatal errors stop here. */ - if (ISSET(FTS_STOP)) - return (NULL); - - /* Return logical hierarchy of user's arguments. */ - if (p->fts_info == FTS_INIT) - return (p->fts_link); - - /* - * If not a directory being visited in pre-order, stop here. Could - * allow FTS_DNR, assuming the user has fixed the problem, but the - * same effect is available with FTS_AGAIN. - */ - if (p->fts_info != FTS_D /* && p->fts_info != FTS_DNR */) - return (NULL); - - /* Free up any previous child list. */ - if (sp->fts_child) - fts_lfree(sp->fts_child); - - if (instr == FTS_NAMEONLY) { - SET(FTS_NAMEONLY); - instr = BNAMES; - } else - instr = BCHILD; - - /* - * If using chdir on a relative path and called BEFORE fts_read does - * its chdir to the root of a traversal, we can lose -- we need to - * chdir into the subdirectory, and we don't know where the current - * directory is, so we can't get back so that the upcoming chdir by - * fts_read will work. - */ - if (p->fts_level != FTS_ROOTLEVEL || p->fts_accpath[0] == '/' || - ISSET(FTS_NOCHDIR)) - return (sp->fts_child = fts_build(sp, instr)); - - if ((fd = _open(".", O_RDONLY, 0)) < 0) - return (NULL); - sp->fts_child = fts_build(sp, instr); - if (fchdir(fd)) - return (NULL); - (void)_close(fd); - return (sp->fts_child); -} - -/* - * This is the tricky part -- do not casually change *anything* in here. The - * idea is to build the linked list of entries that are used by fts_children - * and fts_read. There are lots of special cases. - * - * The real slowdown in walking the tree is the stat calls. If FTS_NOSTAT is - * set and it's a physical walk (so that symbolic links can't be directories), - * we can do things quickly. First, if it's a 4.4BSD file system, the type - * of the file is in the directory entry. Otherwise, we assume that the number - * of subdirectories in a node is equal to the number of links to the parent. - * The former skips all stat calls. The latter skips stat calls in any leaf - * directories and for any files after the subdirectories in the directory have - * been found, cutting the stat calls by about 2/3. - */ -static FTSENT * -fts_build(sp, type) - register FTS *sp; - int type; -{ - register struct dirent *dp; - register FTSENT *p, *head; - register int nitems; - FTSENT *cur, *tail; - DIR *dirp; - void *oldaddr; - int cderrno, descend, len, level, maxlen, nlinks, oflag, saved_errno, - nostat, doadjust; - char *cp; - - /* Set current node pointer. */ - cur = sp->fts_cur; - - /* - * Open the directory for reading. If this fails, we're done. - * If being called from fts_read, set the fts_info field. - */ -#ifdef FTS_WHITEOUT - if (ISSET(FTS_WHITEOUT)) - oflag = DTF_NODUP|DTF_REWIND; - else - oflag = DTF_HIDEW|DTF_NODUP|DTF_REWIND; -#else -#define __opendir2(path, flag) opendir(path) -#endif - if ((dirp = __opendir2(cur->fts_accpath, oflag)) == NULL) { - if (type == BREAD) { - cur->fts_info = FTS_DNR; - cur->fts_errno = errno; - } - return (NULL); - } - - /* - * Nlinks is the number of possible entries of type directory in the - * directory if we're cheating on stat calls, 0 if we're not doing - * any stat calls at all, -1 if we're doing stats on everything. - */ - if (type == BNAMES) { - nlinks = 0; - /* Be quiet about nostat, GCC. */ - nostat = 0; - } else if (ISSET(FTS_NOSTAT) && ISSET(FTS_PHYSICAL)) { - nlinks = cur->fts_nlink - (ISSET(FTS_SEEDOT) ? 0 : 2); - nostat = 1; - } else { - nlinks = -1; - nostat = 0; - } - -#ifdef notdef - (void)printf("nlinks == %d (cur: %d)\n", nlinks, cur->fts_nlink); - (void)printf("NOSTAT %d PHYSICAL %d SEEDOT %d\n", - ISSET(FTS_NOSTAT), ISSET(FTS_PHYSICAL), ISSET(FTS_SEEDOT)); -#endif - /* - * If we're going to need to stat anything or we want to descend - * and stay in the directory, chdir. If this fails we keep going, - * but set a flag so we don't chdir after the post-order visit. - * We won't be able to stat anything, but we can still return the - * names themselves. Note, that since fts_read won't be able to - * chdir into the directory, it will have to return different path - * names than before, i.e. "a/b" instead of "b". Since the node - * has already been visited in pre-order, have to wait until the - * post-order visit to return the error. There is a special case - * here, if there was nothing to stat then it's not an error to - * not be able to stat. This is all fairly nasty. If a program - * needed sorted entries or stat information, they had better be - * checking FTS_NS on the returned nodes. - */ - cderrno = 0; - if (nlinks || type == BREAD) { - if (fts_safe_changedir(sp, cur, dirfd(dirp))) { - if (nlinks && type == BREAD) - cur->fts_errno = errno; - cur->fts_flags |= FTS_DONTCHDIR; - descend = 0; - cderrno = errno; - (void)closedir(dirp); - dirp = NULL; - } else - descend = 1; - } else - descend = 0; - - /* - * Figure out the max file name length that can be stored in the - * current path -- the inner loop allocates more path as necessary. - * We really wouldn't have to do the maxlen calculations here, we - * could do them in fts_read before returning the path, but it's a - * lot easier here since the length is part of the dirent structure. - * - * If not changing directories set a pointer so that can just append - * each new name into the path. - */ - len = NAPPEND(cur); - if (ISSET(FTS_NOCHDIR)) { - cp = sp->fts_path + len; - *cp++ = '/'; - } else { - /* GCC, you're too verbose. */ - cp = NULL; - } - len++; - maxlen = sp->fts_pathlen - len; - - level = cur->fts_level + 1; - - /* Read the directory, attaching each entry to the `link' pointer. */ - doadjust = 0; - for (head = tail = NULL, nitems = 0; dirp && (dp = readdir(dirp));) { - if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name)) - continue; - - if ((p = fts_alloc(sp, dp->d_name, (int)dp->d_namlen)) == NULL) - goto mem1; - if (dp->d_namlen >= maxlen) { /* include space for NUL */ - oldaddr = sp->fts_path; - if (fts_palloc(sp, dp->d_namlen +len + 1)) { - /* - * No more memory for path or structures. Save - * errno, free up the current structure and the - * structures already allocated. - */ -mem1: saved_errno = errno; - if (p) - free(p); - fts_lfree(head); - (void)closedir(dirp); - cur->fts_info = FTS_ERR; - SET(FTS_STOP); - errno = saved_errno; - return (NULL); - } - /* Did realloc() change the pointer? */ - if (oldaddr != sp->fts_path) { - doadjust = 1; - if (ISSET(FTS_NOCHDIR)) - cp = sp->fts_path + len; - } - maxlen = sp->fts_pathlen - len; - } - - if (len + dp->d_namlen >= USHRT_MAX) { - /* - * In an FTSENT, fts_pathlen is a u_short so it is - * possible to wraparound here. If we do, free up - * the current structure and the structures already - * allocated, then error out with ENAMETOOLONG. - */ - free(p); - fts_lfree(head); - (void)closedir(dirp); - cur->fts_info = FTS_ERR; - SET(FTS_STOP); - errno = ENAMETOOLONG; - return (NULL); - } - p->fts_level = level; - p->fts_parent = sp->fts_cur; - p->fts_pathlen = len + dp->d_namlen; - -#ifdef FTS_WHITEOUT - if (dp->d_type == DT_WHT) - p->fts_flags |= FTS_ISW; -#endif - - if (cderrno) { - if (nlinks) { - p->fts_info = FTS_NS; - p->fts_errno = cderrno; - } else - p->fts_info = FTS_NSOK; - p->fts_accpath = cur->fts_accpath; - } else if (nlinks == 0 -#ifdef DT_DIR - || (nostat && - dp->d_type != DT_DIR && dp->d_type != DT_UNKNOWN) -#endif - ) { - p->fts_accpath = - ISSET(FTS_NOCHDIR) ? p->fts_path : p->fts_name; - p->fts_info = FTS_NSOK; - } else { - /* Build a file name for fts_stat to stat. */ - if (ISSET(FTS_NOCHDIR)) { - p->fts_accpath = p->fts_path; - memmove(cp, p->fts_name, p->fts_namelen + 1); - } else - p->fts_accpath = p->fts_name; - /* Stat it. */ - p->fts_info = fts_stat(sp, p, 0); - - /* Decrement link count if applicable. */ - if (nlinks > 0 && (p->fts_info == FTS_D || - p->fts_info == FTS_DC || p->fts_info == FTS_DOT)) - --nlinks; - } - - /* We walk in directory order so "ls -f" doesn't get upset. */ - p->fts_link = NULL; - if (head == NULL) - head = tail = p; - else { - tail->fts_link = p; - tail = p; - } - ++nitems; - } - if (dirp) - (void)closedir(dirp); - - /* - * If realloc() changed the address of the path, adjust the - * addresses for the rest of the tree and the dir list. - */ - if (doadjust) - fts_padjust(sp, head); - - /* - * If not changing directories, reset the path back to original - * state. - */ - if (ISSET(FTS_NOCHDIR)) { - if (len == sp->fts_pathlen || nitems == 0) - --cp; - *cp = '\0'; - } - - /* - * If descended after called from fts_children or after called from - * fts_read and nothing found, get back. At the root level we use - * the saved fd; if one of fts_open()'s arguments is a relative path - * to an empty directory, we wind up here with no other way back. If - * can't get back, we're done. - */ - if (descend && (type == BCHILD || !nitems) && - (cur->fts_level == FTS_ROOTLEVEL ? - FCHDIR(sp, sp->fts_rfd) : CHDIR(sp, ".."))) { - cur->fts_info = FTS_ERR; - SET(FTS_STOP); - return (NULL); - } - - /* If didn't find anything, return NULL. */ - if (!nitems) { - if (type == BREAD) - cur->fts_info = FTS_DP; - return (NULL); - } - - /* Sort the entries. */ - if (sp->fts_compar && nitems > 1) - head = fts_sort(sp, head, nitems); - return (head); -} - -static u_short -fts_stat(sp, p, follow) - FTS *sp; - register FTSENT *p; - int follow; -{ - register FTSENT *t; - register dev_t dev; - register ino_t ino; - struct stat *sbp, sb; - int saved_errno; - - /* If user needs stat info, stat buffer already allocated. */ - sbp = ISSET(FTS_NOSTAT) ? &sb : p->fts_statp; - -#ifdef FTS_WHITEOUT - /* check for whiteout */ - if (p->fts_flags & FTS_ISW) { - if (sbp != &sb) { - memset(sbp, '\0', sizeof (*sbp)); - sbp->st_mode = S_IFWHT; - } - return (FTS_W); - } -#endif - - /* - * If doing a logical walk, or application requested FTS_FOLLOW, do - * a stat(2). If that fails, check for a non-existent symlink. If - * fail, set the errno from the stat call. - */ - if (ISSET(FTS_LOGICAL) || follow) { - if (stat(p->fts_accpath, sbp)) { - saved_errno = errno; - if (!lstat(p->fts_accpath, sbp)) { - errno = 0; - return (FTS_SLNONE); - } - p->fts_errno = saved_errno; - goto err; - } - } else if (lstat(p->fts_accpath, sbp)) { - p->fts_errno = errno; -err: memset(sbp, 0, sizeof(struct stat)); - return (FTS_NS); - } - - if (S_ISDIR(sbp->st_mode)) { - /* - * Set the device/inode. Used to find cycles and check for - * crossing mount points. Also remember the link count, used - * in fts_build to limit the number of stat calls. It is - * understood that these fields are only referenced if fts_info - * is set to FTS_D. - */ - dev = p->fts_dev = sbp->st_dev; - ino = p->fts_ino = sbp->st_ino; - p->fts_nlink = sbp->st_nlink; - - if (ISDOT(p->fts_name)) - return (FTS_DOT); - - /* - * Cycle detection is done by brute force when the directory - * is first encountered. If the tree gets deep enough or the - * number of symbolic links to directories is high enough, - * something faster might be worthwhile. - */ - for (t = p->fts_parent; - t->fts_level >= FTS_ROOTLEVEL; t = t->fts_parent) - if (ino == t->fts_ino && dev == t->fts_dev) { - p->fts_cycle = t; - return (FTS_DC); - } - return (FTS_D); - } - if (S_ISLNK(sbp->st_mode)) - return (FTS_SL); - if (S_ISREG(sbp->st_mode)) - return (FTS_F); - return (FTS_DEFAULT); -} - -static FTSENT * -fts_sort(sp, head, nitems) - FTS *sp; - FTSENT *head; - register int nitems; -{ - register FTSENT **ap, *p; - - /* - * Construct an array of pointers to the structures and call qsort(3). - * Reassemble the array in the order returned by qsort. If unable to - * sort for memory reasons, return the directory entries in their - * current order. Allocate enough space for the current needs plus - * 40 so don't realloc one entry at a time. - */ - if (nitems > sp->fts_nitems) { - struct _ftsent **a; - - sp->fts_nitems = nitems + 40; - if ((a = realloc(sp->fts_array, - sp->fts_nitems * sizeof(FTSENT *))) == NULL) { - if (sp->fts_array) - free(sp->fts_array); - sp->fts_array = NULL; - sp->fts_nitems = 0; - return (head); - } - sp->fts_array = a; - } - for (ap = sp->fts_array, p = head; p; p = p->fts_link) - *ap++ = p; - qsort((void *)sp->fts_array, nitems, sizeof(FTSENT *), sp->fts_compar); - for (head = *(ap = sp->fts_array); --nitems; ++ap) - ap[0]->fts_link = ap[1]; - ap[0]->fts_link = NULL; - return (head); -} - -static FTSENT * -fts_alloc(sp, name, namelen) - FTS *sp; - char *name; - register int namelen; -{ - register FTSENT *p; - size_t len; - - /* - * The file name is a variable length array and no stat structure is - * necessary if the user has set the nostat bit. Allocate the FTSENT - * structure, the file name and the stat structure in one chunk, but - * be careful that the stat structure is reasonably aligned. Since the - * fts_name field is declared to be of size 1, the fts_name pointer is - * namelen + 2 before the first possible address of the stat structure. - */ - len = sizeof(FTSENT) + namelen; - if (!ISSET(FTS_NOSTAT)) - len += sizeof(struct stat) + ALIGNBYTES; - if ((p = malloc(len)) == NULL) - return (NULL); - - /* Copy the name and guarantee NUL termination. */ - memmove(p->fts_name, name, namelen); - p->fts_name[namelen] = '\0'; - - if (!ISSET(FTS_NOSTAT)) - p->fts_statp = (struct stat *)ALIGN(p->fts_name + namelen + 2); - p->fts_namelen = namelen; - p->fts_path = sp->fts_path; - p->fts_errno = 0; - p->fts_flags = 0; - p->fts_instr = FTS_NOINSTR; - p->fts_number = 0; - p->fts_pointer = NULL; - return (p); -} - -static void -fts_lfree(head) - register FTSENT *head; -{ - register FTSENT *p; - - /* Free a linked list of structures. */ - while ((p = head)) { - head = head->fts_link; - free(p); - } -} - -/* - * Allow essentially unlimited paths; find, rm, ls should all work on any tree. - * Most systems will allow creation of paths much longer than MAXPATHLEN, even - * though the kernel won't resolve them. Add the size (not just what's needed) - * plus 256 bytes so don't realloc the path 2 bytes at a time. - */ -static int -fts_palloc(sp, more) - FTS *sp; - size_t more; -{ - char *p; - - sp->fts_pathlen += more + 256; - /* - * Check for possible wraparound. In an FTS, fts_pathlen is - * a signed int but in an FTSENT it is an unsigned short. - * We limit fts_pathlen to USHRT_MAX to be safe in both cases. - */ - if (sp->fts_pathlen < 0 || sp->fts_pathlen >= USHRT_MAX) { - if (sp->fts_path) - free(sp->fts_path); - sp->fts_path = NULL; - errno = ENAMETOOLONG; - return (1); - } - p = realloc(sp->fts_path, sp->fts_pathlen); - if (p == NULL) { - if (sp->fts_path) - free(sp->fts_path); - sp->fts_path = NULL; - return (1); - } - sp->fts_path = p; - return (0); -} - -/* - * When the path is realloc'd, have to fix all of the pointers in structures - * already returned. - */ -static void -fts_padjust(sp, head) - FTS *sp; - FTSENT *head; -{ - FTSENT *p; - char *addr = sp->fts_path; - -#define ADJUST(p) { \ - if ((p)->fts_accpath != (p)->fts_name) { \ - (p)->fts_accpath = \ - (char *)addr + ((p)->fts_accpath - (p)->fts_path); \ - } \ - (p)->fts_path = addr; \ -} - /* Adjust the current set of children. */ - for (p = sp->fts_child; p; p = p->fts_link) - ADJUST(p); - - /* Adjust the rest of the tree, including the current level. */ - for (p = head; p->fts_level >= FTS_ROOTLEVEL;) { - ADJUST(p); - p = p->fts_link ? p->fts_link : p->fts_parent; - } -} - -static size_t -fts_maxarglen(argv) - char * const *argv; -{ - size_t len, max; - - for (max = 0; *argv; ++argv) - if ((len = strlen(*argv)) > max) - max = len; - return (max + 1); -} - -/* - * Change to dir specified by fd or p->fts_accpath without getting - * tricked by someone changing the world out from underneath us. - * Assumes p->fts_dev and p->fts_ino are filled in. - */ -static int -fts_safe_changedir(sp, p, fd) - FTS *sp; - FTSENT *p; - int fd; -{ - int ret, oerrno, newfd; - struct stat sb; - - newfd = fd; - if (ISSET(FTS_NOCHDIR)) - return (0); - if (fd < 0 && (newfd = _open(p->fts_accpath, O_RDONLY, 0)) < 0) - return (-1); - if (fstat(newfd, &sb)) { - ret = -1; - goto bail; - } - if (p->fts_dev != sb.st_dev || p->fts_ino != sb.st_ino) { - errno = ENOENT; /* disinformation */ - ret = -1; - goto bail; - } - ret = fchdir(newfd); -bail: - oerrno = errno; - if (fd < 0) - (void)_close(newfd); - errno = oerrno; - return (ret); -} diff --git a/lib/libc/gen/getbootfile.3 b/lib/libc/gen/getbootfile.3 deleted file mode 100644 index 1ad2b8e..0000000 --- a/lib/libc/gen/getbootfile.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" Copyright (c) 1983, 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. -.\" -.\" From: @(#)gethostname.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd September 23, 1994 -.Dt GETBOOTFILE 3 -.Os -.Sh NAME -.Nm getbootfile -.Nd get kernel boot file name -.Sh SYNOPSIS -.Fd #include -.Ft const char * -.Fn getbootfile void -.Sh DESCRIPTION -The -.Fn getbootfile -function retrieves the full pathname of the file from which the -current kernel was loaded, and returns a static pointer to the name. -A read/write interface to this information is available via the -.Xr sysctl 3 -MIB variable -.Dq Li kern.bootfile . -.Sh RETURN VALUES -If the call succeeds a string giving the pathname is returned. If it -fails, a a null pointer is returned and an error code is -placed in the global location -.Va errno . -.Sh SEE ALSO -.Xr sysctl 3 -.Sh BUGS -If the boot blocks have not been modified to pass this information into -the kernel at boot time, the static string -.Dq Pa /kernel -is returned instead of the real boot file. -.Sh HISTORY -The -.Fn getbootfile -function call appeared in -.Fx 2.0 . diff --git a/lib/libc/gen/getbootfile.c b/lib/libc/gen/getbootfile.c deleted file mode 100644 index c2d1558..0000000 --- a/lib/libc/gen/getbootfile.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char sccsid[] = "From: @(#)gethostname.c 8.1 (Berkeley) 6/4/93";*/ -static const char rcsid[] = - "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -const char * -getbootfile(void) -{ - static char name[MAXPATHLEN]; - size_t size = sizeof name; - int mib[2]; - - mib[0] = CTL_KERN; - mib[1] = KERN_BOOTFILE; - if (sysctl(mib, 2, name, &size, NULL, 0) == -1) - return ("/kernel"); - return (name); -} diff --git a/lib/libc/gen/getbsize.3 b/lib/libc/gen/getbsize.3 deleted file mode 100644 index 00b09c6..0000000 --- a/lib/libc/gen/getbsize.3 +++ /dev/null @@ -1,80 +0,0 @@ -.\" Copyright (c) 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. -.\" -.\" @(#)getbsize.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt GETBSIZE 3 -.Os BSD 4.4 -.Sh NAME -.Nm getbsize -.Nd get user block size -.Sh SYNOPSIS -.Fd #include -.Ft char * -.Fn getbsize "int *headerlenp" "long *blocksizep" -.Sh DESCRIPTION -The -.Fn getbsize -function determines the user's preferred block size based on the value of the -.Dq BLOCKSIZE -environment variable; see -.Xr environ 7 -for details on its use and format. -.Pp -The -.Fn getbsize -function returns a pointer to a null-terminated string describing -the block size, something like -.Dq 1K-blocks . -The memory referenced by -.Fa headerlenp -is filled in with the length of the string (not including the -terminating null). -The memory referenced by -.Fa blocksizep -is filled in with block size, in bytes. -.Pp -If the user's block size is unreasonable, a warning message is -written to standard error and the returned information reflects -a block size of 512 bytes. -.Sh SEE ALSO -.Xr df 1 , -.Xr du 1 , -.Xr ls 1 , -.Xr systat 1 , -.Xr environ 7 -.Sh HISTORY -The -.Fn getbsize -function first appeared in -.Bx 4.4 . diff --git a/lib/libc/gen/getbsize.c b/lib/libc/gen/getbsize.c deleted file mode 100644 index 6f951e7..0000000 --- a/lib/libc/gen/getbsize.c +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)getbsize.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#include -#include -#include -#include - -char * -getbsize(headerlenp, blocksizep) - int *headerlenp; - long *blocksizep; -{ - static char header[20]; - long n, max, mul, blocksize; - char *ep, *p, *form; - -#define KB (1024L) -#define MB (1024L * 1024L) -#define GB (1024L * 1024L * 1024L) -#define MAXB GB /* No tera, peta, nor exa. */ - form = ""; - if ((p = getenv("BLOCKSIZE")) != NULL && *p != '\0') { - if ((n = strtol(p, &ep, 10)) < 0) - goto underflow; - if (n == 0) - n = 1; - if (*ep && ep[1]) - goto fmterr; - switch (*ep) { - case 'G': case 'g': - form = "G"; - max = MAXB / GB; - mul = GB; - break; - case 'K': case 'k': - form = "K"; - max = MAXB / KB; - mul = KB; - break; - case 'M': case 'm': - form = "M"; - max = MAXB / MB; - mul = MB; - break; - case '\0': - max = MAXB; - mul = 1; - break; - default: -fmterr: warnx("%s: unknown blocksize", p); - n = 512; - mul = 1; - break; - } - if (n > max) { - warnx("maximum blocksize is %ldG", MAXB / GB); - n = max; - } - if ((blocksize = n * mul) < 512) { -underflow: warnx("minimum blocksize is 512"); - form = ""; - blocksize = n = 512; - } - } else - blocksize = n = 512; - - (void)snprintf(header, sizeof(header), "%ld%s-blocks", n, form); - *headerlenp = strlen(header); - *blocksizep = blocksize; - return (header); -} diff --git a/lib/libc/gen/getcap.3 b/lib/libc/gen/getcap.3 deleted file mode 100644 index 43d9685..0000000 --- a/lib/libc/gen/getcap.3 +++ /dev/null @@ -1,529 +0,0 @@ -.\" Copyright (c) 1992, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Casey Leedom of Lawrence Livermore National Laboratory. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)getcap.3 8.4 (Berkeley) 5/13/94 -.\" $FreeBSD$ -.\" -.Dd May 13, 1994 -.Dt GETCAP 3 -.Os -.Sh NAME -.Nm cgetent , -.Nm cgetset , -.Nm cgetmatch , -.Nm cgetcap , -.Nm cgetnum , -.Nm cgetstr , -.Nm cgetustr , -.Nm cgetfirst , -.Nm cgetnext , -.Nm cgetclose -.Nd capability database access routines -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn cgetent "char **buf" "char **db_array" "char *name" -.Ft int -.Fn cgetset "char *ent" -.Ft int -.Fn cgetmatch "char *buf" "char *name" -.Ft char * -.Fn cgetcap "char *buf" "char *cap" "int type" -.Ft int -.Fn cgetnum "char *buf" "char *cap" "long *num" -.Ft int -.Fn cgetstr "char *buf" "char *cap" "char **str" -.Ft int -.Fn cgetustr "char *buf" "char *cap" "char **str" -.Ft int -.Fn cgetfirst "char **buf" "char **db_array" -.Ft int -.Fn cgetnext "char **buf" "char **db_array" -.Ft int -.Fn cgetclose "void" -.Sh DESCRIPTION -.Fn Cgetent -extracts the capability -.Fa name -from the database specified by the -.Dv NULL -terminated file array -.Fa db_array -and returns a pointer to a -.Xr malloc Ns \&'d -copy of it in -.Fa buf . -The -.Fn cgetent -function will first look for files ending in -.Nm .db -(see -.Xr cap_mkdb 1 ) -before accessing the ASCII file. -.Fa Buf -must be retained through all subsequent calls to -.Fn cgetmatch , -.Fn cgetcap , -.Fn cgetnum , -.Fn cgetstr , -and -.Fn cgetustr , -but may then be -.Xr free 3 Ns \&'d. -On success 0 is returned, 1 if the returned -record contains an unresolved -.Nm tc -expansion, -\-1 if the requested record couldn't be found, -\-2 if a system error was encountered (couldn't open/read a file, etc.) also -setting -.Va errno , -and \-3 if a potential reference loop is detected (see -.Ic tc= -comments below). -.Pp -The -.Fn cgetset -function enables the addition of a character buffer containing a single capability -record entry -to the capability database. -Conceptually, the entry is added as the first ``file'' in the database, and -is therefore searched first on the call to -.Fn cgetent . -The entry is passed in -.Fa ent . -If -.Fa ent -is -.Dv NULL , -the current entry is removed from the database. -A call to -.Fn cgetset -must precede the database traversal. It must be called before the -.Fn cgetent -call. If a sequential access is being performed (see below), it must be called -before the first sequential access call ( -.Fn cgetfirst -or -.Fn cgetnext -), or be directly preceded by a -.Fn cgetclose -call. -On success 0 is returned and \-1 on failure. -.Pp -The -.Fn cgetmatch -function will return 0 if -.Fa name -is one of the names of the capability record -.Fa buf , -\-1 if -not. -.Pp -The -.Fn cgetcap -function searches the capability record -.Fa buf -for the capability -.Fa cap -with type -.Fa type . -A -.Fa type -is specified using any single character. If a colon (`:') is used, an -untyped capability will be searched for (see below for explanation of -types). A pointer to the value of -.Fa cap -in -.Fa buf -is returned on success, -.Dv NULL -if the requested capability couldn't be -found. The end of the capability value is signaled by a `:' or -.Tn ASCII -.Dv NUL -(see below for capability database syntax). -.Pp -The -.Fn cgetnum -function retrieves the value of the numeric capability -.Fa cap -from the capability record pointed to by -.Fa buf . -The numeric value is returned in the -.Ft long -pointed to by -.Fa num . -0 is returned on success, \-1 if the requested numeric capability couldn't -be found. -.Pp -The -.Fn cgetstr -function retrieves the value of the string capability -.Fa cap -from the capability record pointed to by -.Fa buf . -A pointer to a decoded, -.Dv NUL -terminated, -.Xr malloc Ns \&'d -copy of the string is returned in the -.Ft char * -pointed to by -.Fa str . -The number of characters in the decoded string not including the trailing -.Dv NUL -is returned on success, \-1 if the requested string capability couldn't -be found, \-2 if a system error was encountered (storage allocation -failure). -.Pp -The -.Fn cgetustr -function is identical to -.Fn cgetstr -except that it does not expand special characters, but rather returns each -character of the capability string literally. -.Pp -The -.Fn cgetfirst -and -.Fn cgetnext -functions comprise a function group that provides for sequential -access of the -.Dv NULL -pointer terminated array of file names, -.Fa db_array . -The -.Fn cgetfirst -function returns the first record in the database and resets the access -to the first record. -The -.Fn cgetnext -function returns the next record in the database with respect to the -record returned by the previous -.Fn cgetfirst -or -.Fn cgetnext -call. If there is no such previous call, the first record in the database is -returned. -Each record is returned in a -.Xr malloc Ns \&'d -copy pointed to by -.Fa buf . -.Ic Tc -expansion is done (see -.Ic tc= -comments below). -Upon completion of the database 0 is returned, 1 is returned upon successful -return of record with possibly more remaining (we haven't reached the end of -the database yet), 2 is returned if the record contains an unresolved -.Nm tc -expansion, \-1 is returned if an system error occurred, and \-2 -is returned if a potential reference loop is detected (see -.Ic tc= -comments below). -Upon completion of database (0 return) the database is closed. -.Pp -The -.Fn cgetclose -function closes the sequential access and frees any memory and file descriptors -being used. Note that it does not erase the buffer pushed by a call to -.Fn cgetset . -.Sh CAPABILITY DATABASE SYNTAX -Capability databases are normally -.Tn ASCII -and may be edited with standard -text editors. Blank lines and lines beginning with a `#' are comments -and are ignored. Lines ending with a `\|\e' indicate that the next line -is a continuation of the current line; the `\|\e' and following newline -are ignored. Long lines are usually continued onto several physical -lines by ending each line except the last with a `\|\e'. -.Pp -Capability databases consist of a series of records, one per logical -line. Each record contains a variable number of `:'-separated fields -(capabilities). Empty fields consisting entirely of white space -characters (spaces and tabs) are ignored. -.Pp -The first capability of each record specifies its names, separated by `|' -characters. These names are used to reference records in the database. -By convention, the last name is usually a comment and is not intended as -a lookup tag. For example, the -.Em vt100 -record from the -.Nm termcap -database begins: -.Pp -.Dl "d0\||\|vt100\||\|vt100-am\||\|vt100am\||\|dec vt100:" -.Pp -giving four names that can be used to access the record. -.Pp -The remaining non-empty capabilities describe a set of (name, value) -bindings, consisting of a names optionally followed by a typed values: -.Bl -column "nameTvalue" -.It name Ta "typeless [boolean] capability" -.Em name No "is present [true]" -.It name Ns Em \&T Ns value Ta capability -.Pq Em name , \&T -has value -.Em value -.It name@ Ta "no capability" Em name No exists -.It name Ns Em T Ns \&@ Ta capability -.Pq Em name , T -does not exist -.El -.Pp -Names consist of one or more characters. Names may contain any character -except `:', but it's usually best to restrict them to the printable -characters and avoid use of graphics like `#', `=', `%', `@', etc. Types -are single characters used to separate capability names from their -associated typed values. Types may be any character except a `:'. -Typically, graphics like `#', `=', `%', etc. are used. Values may be any -number of characters and may contain any character except `:'. -.Sh CAPABILITY DATABASE SEMANTICS -Capability records describe a set of (name, value) bindings. Names may -have multiple values bound to them. Different values for a name are -distinguished by their -.Fa types . -The -.Fn cgetcap -function will return a pointer to a value of a name given the capability -name and the type of the value. -.Pp -The types `#' and `=' are conventionally used to denote numeric and -string typed values, but no restriction on those types is enforced. The -functions -.Fn cgetnum -and -.Fn cgetstr -can be used to implement the traditional syntax and semantics of `#' -and `='. -Typeless capabilities are typically used to denote boolean objects with -presence or absence indicating truth and false values respectively. -This interpretation is conveniently represented by: -.Pp -.Dl "(getcap(buf, name, ':') != NULL)" -.Pp -A special capability, -.Ic tc= name , -is used to indicate that the record specified by -.Fa name -should be substituted for the -.Ic tc -capability. -.Ic Tc -capabilities may interpolate records which also contain -.Ic tc -capabilities and more than one -.Ic tc -capability may be used in a record. A -.Ic tc -expansion scope (i.e., where the argument is searched for) contains the -file in which the -.Ic tc -is declared and all subsequent files in the file array. -.Pp -When a database is searched for a capability record, the first matching -record in the search is returned. When a record is scanned for a -capability, the first matching capability is returned; the capability -.Ic :nameT@: -will hide any following definition of a value of type -.Em T -for -.Fa name ; -and the capability -.Ic :name@: -will prevent any following values of -.Fa name -from being seen. -.Pp -These features combined with -.Ic tc -capabilities can be used to generate variations of other databases and -records by either adding new capabilities, overriding definitions with new -definitions, or hiding following definitions via `@' capabilities. -.Sh EXAMPLES -.Bd -unfilled -offset indent -example\||\|an example of binding multiple values to names:\e - :foo%bar:foo^blah:foo@:\e - :abc%xyz:abc^frap:abc$@:\e - :tc=more: -.Ed -.Pp -The capability foo has two values bound to it (bar of type `%' and blah of -type `^') and any other value bindings are hidden. The capability abc -also has two values bound but only a value of type `$' is prevented from -being defined in the capability record more. -.Pp -.Bd -unfilled -offset indent -file1: - new\||\|new_record\||\|a modification of "old":\e - :fript=bar:who-cares@:tc=old:blah:tc=extensions: -file2: - old\||\|old_record\||\|an old database record:\e - :fript=foo:who-cares:glork#200: -.Ed -.Pp -The records are extracted by calling -.Fn cgetent -with file1 preceding file2. -In the capability record new in file1, fript=bar overrides the definition -of fript=foo interpolated from the capability record old in file2, -who-cares@ prevents the definition of any who-cares definitions in old -from being seen, glork#200 is inherited from old, and blah and anything -defined by the record extensions is added to those definitions in old. -Note that the position of the fript=bar and who-cares@ definitions before -tc=old is important here. If they were after, the definitions in old -would take precedence. -.Sh CGETNUM AND CGETSTR SYNTAX AND SEMANTICS -Two types are predefined by -.Fn cgetnum -and -.Fn cgetstr : -.Bl -column "nameXnumber" -.Sm off -.It Em name No \&# Em number Ta numeric -capability -.Em name -has value -.Em number -.It Em name No = Em string Ta "string capability" -.Em name -has value -.Em string -.It Em name No \&#@ Ta "the numeric capability" -.Em name -does not exist -.It Em name No \&=@ Ta "the string capability" -.Em name -does not exist -.El -.Pp -Numeric capability values may be given in one of three numeric bases. -If the number starts with either -.Ql 0x -or -.Ql 0X -it is interpreted as a hexadecimal number (both upper and lower case a-f -may be used to denote the extended hexadecimal digits). -Otherwise, if the number starts with a -.Ql 0 -it is interpreted as an octal number. -Otherwise the number is interpreted as a decimal number. -.Pp -String capability values may contain any character. Non-printable -.Dv ASCII -codes, new lines, and colons may be conveniently represented by the use -of escape sequences: -.Bl -column "\e\|X,X\e\|X" "(ASCII octal nnn)" -^X ('X' & 037) control-X -\e\|b, \e\|B (ASCII 010) backspace -\e\|t, \e\|T (ASCII 011) tab -\e\|n, \e\|N (ASCII 012) line feed (newline) -\e\|f, \e\|F (ASCII 014) form feed -\e\|r, \e\|R (ASCII 015) carriage return -\e\|e, \e\|E (ASCII 027) escape -\e\|c, \e\|C (:) colon -\e\|\e (\e\|) back slash -\e\|^ (^) caret -\e\|nnn (ASCII octal nnn) -.El -.Pp -A `\|\e' may be followed by up to three octal digits directly specifies -the numeric code for a character. The use of -.Tn ASCII -.Dv NUL Ns s , -while easily -encoded, causes all sorts of problems and must be used with care since -.Dv NUL Ns s -are typically used to denote the end of strings; many applications -use `\e\|200' to represent a -.Dv NUL . -.Sh DIAGNOSTICS -.Fn Cgetent , -.Fn cgetset , -.Fn cgetmatch , -.Fn cgetnum , -.Fn cgetstr , -.Fn cgetustr , -.Fn cgetfirst , -and -.Fn cgetnext -return a value greater than or equal to 0 on success and a value less -than 0 on failure. -The -.Fn cgetcap -function returns a character pointer on success and a -.Dv NULL -on failure. -.Pp -The -.Fn cgetent , -and -.Fn cgetseq -functions may fail and set -.Va errno -for any of the errors specified for the library functions: -.Xr fopen 3 , -.Xr fclose 3 , -.Xr open 2 , -and -.Xr close 2 . -.Pp -The -.Fn cgetent , -.Fn cgetset , -.Fn cgetstr , -and -.Fn cgetustr -may fail and set -.Va errno -as follows: -.Bl -tag -width Er -.It Bq Er ENOMEM -No memory to allocate. -.El -.Sh SEE ALSO -.Xr cap_mkdb 1 , -.Xr malloc 3 -.Sh BUGS -Colons (`:') can't be used in names, types, or values. -.Pp -There are no checks for -.Ic tc= name -loops in -.Fn cgetent . -.Pp -The buffer added to the database by a call to -.Fn cgetset -is not unique to the database but is rather prepended to any database used. diff --git a/lib/libc/gen/getcap.c b/lib/libc/gen/getcap.c deleted file mode 100644 index 4e41a79..0000000 --- a/lib/libc/gen/getcap.c +++ /dev/null @@ -1,1046 +0,0 @@ -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Casey Leedom of Lawrence Livermore National Laboratory. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getcap.c 8.3 (Berkeley) 3/25/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define BFRAG 1024 -#define BSIZE 1024 -#define ESC ('[' & 037) /* ASCII ESC */ -#define MAX_RECURSION 32 /* maximum getent recursion */ -#define SFRAG 100 /* cgetstr mallocs in SFRAG chunks */ - -#define RECOK (char)0 -#define TCERR (char)1 -#define SHADOW (char)2 - -static size_t topreclen; /* toprec length */ -static char *toprec; /* Additional record specified by cgetset() */ -static int gottoprec; /* Flag indicating retrieval of toprecord */ - -static int cdbget __P((DB *, char **, char *)); -static int getent __P((char **, u_int *, char **, int, char *, int, char *)); -static int nfcmp __P((char *, char *)); - -/* - * Cgetset() allows the addition of a user specified buffer to be added - * to the database array, in effect "pushing" the buffer on top of the - * virtual database. 0 is returned on success, -1 on failure. - */ -int -cgetset(ent) - char *ent; -{ - if (ent == NULL) { - if (toprec) - free(toprec); - toprec = NULL; - topreclen = 0; - return (0); - } - topreclen = strlen(ent); - if ((toprec = malloc (topreclen + 1)) == NULL) { - errno = ENOMEM; - return (-1); - } - gottoprec = 0; - (void)strcpy(toprec, ent); - return (0); -} - -/* - * Cgetcap searches the capability record buf for the capability cap with - * type `type'. A pointer to the value of cap is returned on success, NULL - * if the requested capability couldn't be found. - * - * Specifying a type of ':' means that nothing should follow cap (:cap:). - * In this case a pointer to the terminating ':' or NUL will be returned if - * cap is found. - * - * If (cap, '@') or (cap, terminator, '@') is found before (cap, terminator) - * return NULL. - */ -char * -cgetcap(buf, cap, type) - char *buf, *cap; - int type; -{ - register char *bp, *cp; - - bp = buf; - for (;;) { - /* - * Skip past the current capability field - it's either the - * name field if this is the first time through the loop, or - * the remainder of a field whose name failed to match cap. - */ - for (;;) - if (*bp == '\0') - return (NULL); - else - if (*bp++ == ':') - break; - - /* - * Try to match (cap, type) in buf. - */ - for (cp = cap; *cp == *bp && *bp != '\0'; cp++, bp++) - continue; - if (*cp != '\0') - continue; - if (*bp == '@') - return (NULL); - if (type == ':') { - if (*bp != '\0' && *bp != ':') - continue; - return(bp); - } - if (*bp != type) - continue; - bp++; - return (*bp == '@' ? NULL : bp); - } - /* NOTREACHED */ -} - -/* - * Cgetent extracts the capability record name from the NULL terminated file - * array db_array and returns a pointer to a malloc'd copy of it in buf. - * Buf must be retained through all subsequent calls to cgetcap, cgetnum, - * cgetflag, and cgetstr, but may then be free'd. 0 is returned on success, - * -1 if the requested record couldn't be found, -2 if a system error was - * encountered (couldn't open/read a file, etc.), and -3 if a potential - * reference loop is detected. - */ -int -cgetent(buf, db_array, name) - char **buf, **db_array, *name; -{ - u_int dummy; - - return (getent(buf, &dummy, db_array, -1, name, 0, NULL)); -} - -/* - * Getent implements the functions of cgetent. If fd is non-negative, - * *db_array has already been opened and fd is the open file descriptor. We - * do this to save time and avoid using up file descriptors for tc= - * recursions. - * - * Getent returns the same success/failure codes as cgetent. On success, a - * pointer to a malloc'ed capability record with all tc= capabilities fully - * expanded and its length (not including trailing ASCII NUL) are left in - * *cap and *len. - * - * Basic algorithm: - * + Allocate memory incrementally as needed in chunks of size BFRAG - * for capability buffer. - * + Recurse for each tc=name and interpolate result. Stop when all - * names interpolated, a name can't be found, or depth exceeds - * MAX_RECURSION. - */ -static int -getent(cap, len, db_array, fd, name, depth, nfield) - char **cap, **db_array, *name, *nfield; - u_int *len; - int fd, depth; -{ - DB *capdbp; - register char *r_end, *rp, **db_p; - int myfd, eof, foundit, retval, clen; - char *record, *cbuf; - int tc_not_resolved; - char pbuf[_POSIX_PATH_MAX]; - - /* - * Return with ``loop detected'' error if we've recursed more than - * MAX_RECURSION times. - */ - if (depth > MAX_RECURSION) - return (-3); - - /* - * Check if we have a top record from cgetset(). - */ - if (depth == 0 && toprec != NULL && cgetmatch(toprec, name) == 0) { - if ((record = malloc (topreclen + BFRAG)) == NULL) { - errno = ENOMEM; - return (-2); - } - (void)strcpy(record, toprec); - myfd = 0; - db_p = db_array; - rp = record + topreclen + 1; - r_end = rp + BFRAG; - goto tc_exp; - } - /* - * Allocate first chunk of memory. - */ - if ((record = malloc(BFRAG)) == NULL) { - errno = ENOMEM; - return (-2); - } - r_end = record + BFRAG; - foundit = 0; - /* - * Loop through database array until finding the record. - */ - - for (db_p = db_array; *db_p != NULL; db_p++) { - eof = 0; - - /* - * Open database if not already open. - */ - - if (fd >= 0) { - (void)lseek(fd, (off_t)0, SEEK_SET); - myfd = 0; - } else { - (void)snprintf(pbuf, sizeof(pbuf), "%s.db", *db_p); - if ((capdbp = dbopen(pbuf, O_RDONLY, 0, DB_HASH, 0)) - != NULL) { - free(record); - retval = cdbget(capdbp, &record, name); - if (retval < 0) { - /* no record available */ - (void)capdbp->close(capdbp); - return (retval); - } - /* save the data; close frees it */ - clen = strlen(record); - cbuf = malloc(clen + 1); - memcpy(cbuf, record, clen + 1); - if (capdbp->close(capdbp) < 0) { - free(cbuf); - return (-2); - } - *len = clen; - *cap = cbuf; - return (retval); - } else { - fd = _open(*db_p, O_RDONLY, 0); - if (fd < 0) - continue; - myfd = 1; - } - } - /* - * Find the requested capability record ... - */ - { - char buf[BUFSIZ]; - register char *b_end, *bp; - register int c; - - /* - * Loop invariants: - * There is always room for one more character in record. - * R_end always points just past end of record. - * Rp always points just past last character in record. - * B_end always points just past last character in buf. - * Bp always points at next character in buf. - */ - b_end = buf; - bp = buf; - for (;;) { - - /* - * Read in a line implementing (\, newline) - * line continuation. - */ - rp = record; - for (;;) { - if (bp >= b_end) { - int n; - - n = _read(fd, buf, sizeof(buf)); - if (n <= 0) { - if (myfd) - (void)_close(fd); - if (n < 0) { - free(record); - return (-2); - } else { - fd = -1; - eof = 1; - break; - } - } - b_end = buf+n; - bp = buf; - } - - c = *bp++; - if (c == '\n') { - if (rp > record && *(rp-1) == '\\') { - rp--; - continue; - } else - break; - } - *rp++ = c; - - /* - * Enforce loop invariant: if no room - * left in record buffer, try to get - * some more. - */ - if (rp >= r_end) { - u_int pos; - size_t newsize; - - pos = rp - record; - newsize = r_end - record + BFRAG; - record = reallocf(record, newsize); - if (record == NULL) { - errno = ENOMEM; - if (myfd) - (void)_close(fd); - return (-2); - } - r_end = record + newsize; - rp = record + pos; - } - } - /* loop invariant let's us do this */ - *rp++ = '\0'; - - /* - * If encountered eof check next file. - */ - if (eof) - break; - - /* - * Toss blank lines and comments. - */ - if (*record == '\0' || *record == '#') - continue; - - /* - * See if this is the record we want ... - */ - if (cgetmatch(record, name) == 0) { - if (nfield == NULL || !nfcmp(nfield, record)) { - foundit = 1; - break; /* found it! */ - } - } - } - } - if (foundit) - break; - } - - if (!foundit) - return (-1); - - /* - * Got the capability record, but now we have to expand all tc=name - * references in it ... - */ -tc_exp: { - register char *newicap, *s; - register int newilen; - u_int ilen; - int diff, iret, tclen; - char *icap, *scan, *tc, *tcstart, *tcend; - - /* - * Loop invariants: - * There is room for one more character in record. - * R_end points just past end of record. - * Rp points just past last character in record. - * Scan points at remainder of record that needs to be - * scanned for tc=name constructs. - */ - scan = record; - tc_not_resolved = 0; - for (;;) { - if ((tc = cgetcap(scan, "tc", '=')) == NULL) - break; - - /* - * Find end of tc=name and stomp on the trailing `:' - * (if present) so we can use it to call ourselves. - */ - s = tc; - for (;;) - if (*s == '\0') - break; - else - if (*s++ == ':') { - *(s - 1) = '\0'; - break; - } - tcstart = tc - 3; - tclen = s - tcstart; - tcend = s; - - iret = getent(&icap, &ilen, db_p, fd, tc, depth+1, - NULL); - newicap = icap; /* Put into a register. */ - newilen = ilen; - if (iret != 0) { - /* an error */ - if (iret < -1) { - if (myfd) - (void)_close(fd); - free(record); - return (iret); - } - if (iret == 1) - tc_not_resolved = 1; - /* couldn't resolve tc */ - if (iret == -1) { - *(s - 1) = ':'; - scan = s - 1; - tc_not_resolved = 1; - continue; - - } - } - /* not interested in name field of tc'ed record */ - s = newicap; - for (;;) - if (*s == '\0') - break; - else - if (*s++ == ':') - break; - newilen -= s - newicap; - newicap = s; - - /* make sure interpolated record is `:'-terminated */ - s += newilen; - if (*(s-1) != ':') { - *s = ':'; /* overwrite NUL with : */ - newilen++; - } - - /* - * Make sure there's enough room to insert the - * new record. - */ - diff = newilen - tclen; - if (diff >= r_end - rp) { - u_int pos, tcpos, tcposend; - size_t newsize; - - pos = rp - record; - newsize = r_end - record + diff + BFRAG; - tcpos = tcstart - record; - tcposend = tcend - record; - record = reallocf(record, newsize); - if (record == NULL) { - errno = ENOMEM; - if (myfd) - (void)_close(fd); - free(icap); - return (-2); - } - r_end = record + newsize; - rp = record + pos; - tcstart = record + tcpos; - tcend = record + tcposend; - } - - /* - * Insert tc'ed record into our record. - */ - s = tcstart + newilen; - bcopy(tcend, s, rp - tcend); - bcopy(newicap, tcstart, newilen); - rp += diff; - free(icap); - - /* - * Start scan on `:' so next cgetcap works properly - * (cgetcap always skips first field). - */ - scan = s-1; - } - - } - /* - * Close file (if we opened it), give back any extra memory, and - * return capability, length and success. - */ - if (myfd) - (void)_close(fd); - *len = rp - record - 1; /* don't count NUL */ - if (r_end > rp) - if ((record = - reallocf(record, (size_t)(rp - record))) == NULL) { - errno = ENOMEM; - return (-2); - } - - *cap = record; - if (tc_not_resolved) - return (1); - return (0); -} - -static int -cdbget(capdbp, bp, name) - DB *capdbp; - char **bp, *name; -{ - DBT key, data; - - key.data = name; - key.size = strlen(name); - - for (;;) { - /* Get the reference. */ - switch(capdbp->get(capdbp, &key, &data, 0)) { - case -1: - return (-2); - case 1: - return (-1); - } - - /* If not an index to another record, leave. */ - if (((char *)data.data)[0] != SHADOW) - break; - - key.data = (char *)data.data + 1; - key.size = data.size - 1; - } - - *bp = (char *)data.data + 1; - return (((char *)(data.data))[0] == TCERR ? 1 : 0); -} - -/* - * Cgetmatch will return 0 if name is one of the names of the capability - * record buf, -1 if not. - */ -int -cgetmatch(buf, name) - char *buf, *name; -{ - register char *np, *bp; - - /* - * Start search at beginning of record. - */ - bp = buf; - for (;;) { - /* - * Try to match a record name. - */ - np = name; - for (;;) - if (*np == '\0') - if (*bp == '|' || *bp == ':' || *bp == '\0') - return (0); - else - break; - else - if (*bp++ != *np++) - break; - - /* - * Match failed, skip to next name in record. - */ - bp--; /* a '|' or ':' may have stopped the match */ - for (;;) - if (*bp == '\0' || *bp == ':') - return (-1); /* match failed totally */ - else - if (*bp++ == '|') - break; /* found next name */ - } -} - - - - - -int -cgetfirst(buf, db_array) - char **buf, **db_array; -{ - (void)cgetclose(); - return (cgetnext(buf, db_array)); -} - -static FILE *pfp; -static int slash; -static char **dbp; - -int -cgetclose() -{ - if (pfp != NULL) { - (void)fclose(pfp); - pfp = NULL; - } - dbp = NULL; - gottoprec = 0; - slash = 0; - return(0); -} - -/* - * Cgetnext() gets either the first or next entry in the logical database - * specified by db_array. It returns 0 upon completion of the database, 1 - * upon returning an entry with more remaining, and -1 if an error occurs. - */ -int -cgetnext(bp, db_array) - register char **bp; - char **db_array; -{ - size_t len; - int status, i, done; - char *cp, *line, *rp, *np, buf[BSIZE], nbuf[BSIZE]; - u_int dummy; - - if (dbp == NULL) - dbp = db_array; - - if (pfp == NULL && (pfp = fopen(*dbp, "r")) == NULL) { - (void)cgetclose(); - return (-1); - } - for(;;) { - if (toprec && !gottoprec) { - gottoprec = 1; - line = toprec; - } else { - line = fgetln(pfp, &len); - if (line == NULL && pfp) { - (void)fclose(pfp); - if (ferror(pfp)) { - (void)cgetclose(); - return (-1); - } else { - if (*++dbp == NULL) { - (void)cgetclose(); - return (0); - } else if ((pfp = - fopen(*dbp, "r")) == NULL) { - (void)cgetclose(); - return (-1); - } else - continue; - } - } else - line[len - 1] = '\0'; - if (len == 1) { - slash = 0; - continue; - } - if (isspace((unsigned char)*line) || - *line == ':' || *line == '#' || slash) { - if (line[len - 2] == '\\') - slash = 1; - else - slash = 0; - continue; - } - if (line[len - 2] == '\\') - slash = 1; - else - slash = 0; - } - - - /* - * Line points to a name line. - */ - i = 0; - done = 0; - np = nbuf; - for (;;) { - for (cp = line; *cp != '\0'; cp++) { - if (*cp == ':') { - *np++ = ':'; - done = 1; - break; - } - if (*cp == '\\') - break; - *np++ = *cp; - } - if (done) { - *np = '\0'; - break; - } else { /* name field extends beyond the line */ - line = fgetln(pfp, &len); - if (line == NULL && pfp) { - (void)fclose(pfp); - if (ferror(pfp)) { - (void)cgetclose(); - return (-1); - } - } else - line[len - 1] = '\0'; - } - } - rp = buf; - for(cp = nbuf; *cp != '\0'; cp++) - if (*cp == '|' || *cp == ':') - break; - else - *rp++ = *cp; - - *rp = '\0'; - /* - * XXX - * Last argument of getent here should be nbuf if we want true - * sequential access in the case of duplicates. - * With NULL, getent will return the first entry found - * rather than the duplicate entry record. This is a - * matter of semantics that should be resolved. - */ - status = getent(bp, &dummy, db_array, -1, buf, 0, NULL); - if (status == -2 || status == -3) - (void)cgetclose(); - - return (status + 1); - } - /* NOTREACHED */ -} - -/* - * Cgetstr retrieves the value of the string capability cap from the - * capability record pointed to by buf. A pointer to a decoded, NUL - * terminated, malloc'd copy of the string is returned in the char * - * pointed to by str. The length of the string not including the trailing - * NUL is returned on success, -1 if the requested string capability - * couldn't be found, -2 if a system error was encountered (storage - * allocation failure). - */ -int -cgetstr(buf, cap, str) - char *buf, *cap; - char **str; -{ - register u_int m_room; - register char *bp, *mp; - int len; - char *mem; - - /* - * Find string capability cap - */ - bp = cgetcap(buf, cap, '='); - if (bp == NULL) - return (-1); - - /* - * Conversion / storage allocation loop ... Allocate memory in - * chunks SFRAG in size. - */ - if ((mem = malloc(SFRAG)) == NULL) { - errno = ENOMEM; - return (-2); /* couldn't even allocate the first fragment */ - } - m_room = SFRAG; - mp = mem; - - while (*bp != ':' && *bp != '\0') { - /* - * Loop invariants: - * There is always room for one more character in mem. - * Mp always points just past last character in mem. - * Bp always points at next character in buf. - */ - if (*bp == '^') { - bp++; - if (*bp == ':' || *bp == '\0') - break; /* drop unfinished escape */ - if (*bp == '?') { - *mp++ = '\177'; - bp++; - } else - *mp++ = *bp++ & 037; - } else if (*bp == '\\') { - bp++; - if (*bp == ':' || *bp == '\0') - break; /* drop unfinished escape */ - if ('0' <= *bp && *bp <= '7') { - register int n, i; - - n = 0; - i = 3; /* maximum of three octal digits */ - do { - n = n * 8 + (*bp++ - '0'); - } while (--i && '0' <= *bp && *bp <= '7'); - *mp++ = n; - } - else switch (*bp++) { - case 'b': case 'B': - *mp++ = '\b'; - break; - case 't': case 'T': - *mp++ = '\t'; - break; - case 'n': case 'N': - *mp++ = '\n'; - break; - case 'f': case 'F': - *mp++ = '\f'; - break; - case 'r': case 'R': - *mp++ = '\r'; - break; - case 'e': case 'E': - *mp++ = ESC; - break; - case 'c': case 'C': - *mp++ = ':'; - break; - default: - /* - * Catches '\', '^', and - * everything else. - */ - *mp++ = *(bp-1); - break; - } - } else - *mp++ = *bp++; - m_room--; - - /* - * Enforce loop invariant: if no room left in current - * buffer, try to get some more. - */ - if (m_room == 0) { - size_t size = mp - mem; - - if ((mem = reallocf(mem, size + SFRAG)) == NULL) - return (-2); - m_room = SFRAG; - mp = mem + size; - } - } - *mp++ = '\0'; /* loop invariant let's us do this */ - m_room--; - len = mp - mem - 1; - - /* - * Give back any extra memory and return value and success. - */ - if (m_room != 0) - if ((mem = reallocf(mem, (size_t)(mp - mem))) == NULL) - return (-2); - *str = mem; - return (len); -} - -/* - * Cgetustr retrieves the value of the string capability cap from the - * capability record pointed to by buf. The difference between cgetustr() - * and cgetstr() is that cgetustr does not decode escapes but rather treats - * all characters literally. A pointer to a NUL terminated malloc'd - * copy of the string is returned in the char pointed to by str. The - * length of the string not including the trailing NUL is returned on success, - * -1 if the requested string capability couldn't be found, -2 if a system - * error was encountered (storage allocation failure). - */ -int -cgetustr(buf, cap, str) - char *buf, *cap, **str; -{ - register u_int m_room; - register char *bp, *mp; - int len; - char *mem; - - /* - * Find string capability cap - */ - if ((bp = cgetcap(buf, cap, '=')) == NULL) - return (-1); - - /* - * Conversion / storage allocation loop ... Allocate memory in - * chunks SFRAG in size. - */ - if ((mem = malloc(SFRAG)) == NULL) { - errno = ENOMEM; - return (-2); /* couldn't even allocate the first fragment */ - } - m_room = SFRAG; - mp = mem; - - while (*bp != ':' && *bp != '\0') { - /* - * Loop invariants: - * There is always room for one more character in mem. - * Mp always points just past last character in mem. - * Bp always points at next character in buf. - */ - *mp++ = *bp++; - m_room--; - - /* - * Enforce loop invariant: if no room left in current - * buffer, try to get some more. - */ - if (m_room == 0) { - size_t size = mp - mem; - - if ((mem = reallocf(mem, size + SFRAG)) == NULL) - return (-2); - m_room = SFRAG; - mp = mem + size; - } - } - *mp++ = '\0'; /* loop invariant let's us do this */ - m_room--; - len = mp - mem - 1; - - /* - * Give back any extra memory and return value and success. - */ - if (m_room != 0) - if ((mem = reallocf(mem, (size_t)(mp - mem))) == NULL) - return (-2); - *str = mem; - return (len); -} - -/* - * Cgetnum retrieves the value of the numeric capability cap from the - * capability record pointed to by buf. The numeric value is returned in - * the long pointed to by num. 0 is returned on success, -1 if the requested - * numeric capability couldn't be found. - */ -int -cgetnum(buf, cap, num) - char *buf, *cap; - long *num; -{ - register long n; - register int base, digit; - register char *bp; - - /* - * Find numeric capability cap - */ - bp = cgetcap(buf, cap, '#'); - if (bp == NULL) - return (-1); - - /* - * Look at value and determine numeric base: - * 0x... or 0X... hexadecimal, - * else 0... octal, - * else decimal. - */ - if (*bp == '0') { - bp++; - if (*bp == 'x' || *bp == 'X') { - bp++; - base = 16; - } else - base = 8; - } else - base = 10; - - /* - * Conversion loop ... - */ - n = 0; - for (;;) { - if ('0' <= *bp && *bp <= '9') - digit = *bp - '0'; - else if ('a' <= *bp && *bp <= 'f') - digit = 10 + *bp - 'a'; - else if ('A' <= *bp && *bp <= 'F') - digit = 10 + *bp - 'A'; - else - break; - - if (digit >= base) - break; - - n = n * base + digit; - bp++; - } - - /* - * Return value and success. - */ - *num = n; - return (0); -} - - -/* - * Compare name field of record. - */ -static int -nfcmp(nf, rec) - char *nf, *rec; -{ - char *cp, tmp; - int ret; - - for (cp = rec; *cp != ':'; cp++) - ; - - tmp = *(cp + 1); - *(cp + 1) = '\0'; - ret = strcmp(nf, rec); - *(cp + 1) = tmp; - - return (ret); -} diff --git a/lib/libc/gen/getcwd.3 b/lib/libc/gen/getcwd.3 deleted file mode 100644 index 357fdf3..0000000 --- a/lib/libc/gen/getcwd.3 +++ /dev/null @@ -1,156 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)getcwd.3 8.2 (Berkeley) 12/11/93 -.\" $FreeBSD$ -.\" -.Dd November 24, 1997 -.Dt GETCWD 3 -.Os BSD 4.2 -.Sh NAME -.Nm getcwd , -.Nm getwd -.Nd get working directory pathname -.Sh SYNOPSIS -.Fd #include -.Ft char * -.Fn getcwd "char *buf" "size_t size" -.Ft char * -.Fn getwd "char *buf" -.Sh DESCRIPTION -The -.Fn getcwd -function copies the absolute pathname of the current working directory -into the memory referenced by -.Fa buf -and returns a pointer to -.Fa buf . -The -.Fa size -argument is the size, in bytes, of the array referenced by -.Fa buf . -.Pp -If -.Fa buf -is -.Dv NULL , -space is allocated as necessary to store the pathname. -This space may later be -.Xr free 3 Ns 'd. -.Pp -The function -.Fn getwd -is a compatibility routine which calls -.Fn getcwd -with its -.Fa buf -argument and a size of -.Dv MAXPATHLEN -(as defined in the include -file -.Aq Pa sys/param.h ) . -Obviously, -.Fa buf -should be at least -.Dv MAXPATHLEN -bytes in length. -.Pp -These routines have traditionally been used by programs to save the -name of a working directory for the purpose of returning to it. -A much faster and less error-prone method of accomplishing this is to -open the current directory -.Pq Ql \&. -and use the -.Xr fchdir 2 -function to return. -.Sh RETURN VALUES -Upon successful completion, a pointer to the pathname is returned. -Otherwise a -.Dv NULL -pointer is returned and the global variable -.Va errno -is set to indicate the error. -In addition, -.Fn getwd -copies the error message associated with -.Va errno -into the memory referenced by -.Fa buf . -.Sh ERRORS -The -.Fn getcwd -function -will fail if: -.Bl -tag -width [EACCES] -.It Bq Er EACCES -Read or search permission was denied for a component of the pathname. -.It Bq Er EINVAL -The -.Fa size -argument is zero. -.It Bq Er ENOENT -A component of the pathname no longer exists. -.It Bq Er ENOMEM -Insufficient memory is available. -.It Bq Er ERANGE -The -.Fa size -argument is greater than zero but smaller than the length of the pathname -plus 1. -.El -.Sh SEE ALSO -.Xr chdir 2 , -.Xr fchdir 2 , -.Xr malloc 3 , -.Xr strerror 3 -.Sh STANDARDS -The -.Fn getcwd -function -conforms to -.St -ansiC . -The ability to specify a -.Dv NULL -pointer and have -.Fn getcwd -allocate memory as necessary is an extension. -.Sh HISTORY -The -.Fn getwd -function appeared in -.Bx 4.0 . -.Sh BUGS -The -.Fn getwd -function -does not do sufficient error checking and is not able to return very -long, but valid, paths. -It is provided for compatibility. diff --git a/lib/libc/gen/getcwd.c b/lib/libc/gen/getcwd.c deleted file mode 100644 index 9b1ccf3..0000000 --- a/lib/libc/gen/getcwd.c +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Copyright (c) 1989, 1991, 1993, 1995 - * 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getcwd.c 8.5 (Berkeley) 2/7/95"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#define ISDOT(dp) \ - (dp->d_name[0] == '.' && (dp->d_name[1] == '\0' || \ - (dp->d_name[1] == '.' && dp->d_name[2] == '\0'))) - -static int have__getcwd = 1; /* 0 = no, 1 = perhaps, 2 = yes */ - -char * -getcwd(pt, size) - char *pt; - size_t size; -{ - register struct dirent *dp; - register DIR *dir = NULL; - 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; - int save_errno; - char *ept, *eup, *up, c; - - /* - * 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 (NULL); - } - if (size == 1) { - errno = ERANGE; - return (NULL); - } - ept = pt + size; - } else { - if ((pt = malloc(ptsize = 1024 - 4)) == NULL) - return (NULL); - ept = pt + ptsize; - } -#if defined(__NETBSD_SYSCALLS) - have__getcwd = 0; -#else - if (have__getcwd) { - struct sigaction sa, osa; - int sigsys_installed = 0; - int ret; - - if (have__getcwd == 1) { /* unsure? */ - sigemptyset(&sa.sa_mask); - sa.sa_flags = 0; - sa.sa_handler = SIG_IGN; - if (sigaction(SIGSYS, &sa, &osa) >= 0) - sigsys_installed = 1; - } - ret = __getcwd(pt, ept - pt); - if (sigsys_installed == 1) { - int oerrno = errno; - sigaction(SIGSYS, &osa, NULL); - errno = oerrno; - } - /* XXX a bogus syscall seems to return EINVAL(!) */ - if (ret < 0 && (errno == ENOSYS || errno == EINVAL)) - have__getcwd = 0; - else if (have__getcwd == 1) - have__getcwd = 2; /* yep, remember we have it */ - if (ret == 0) { - if (*pt != '/') { - bpt = pt; - ept = pt + strlen(pt) - 1; - while (bpt < ept) { - c = *bpt; - *bpt++ = *ept; - *ept-- = c; - } - } - return (pt); - } - } -#endif - 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 = malloc(upsize = 1024 - 4)) == NULL) - 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; - - errno = 0; /* XXX readdir has no error return. */ - - 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. - */ - bcopy(bpt, pt, 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 = reallocf(up, upsize *= 2)) == NULL) - goto err; - bup = up; - eup = up + upsize; - } - *bup++ = '.'; - *bup++ = '.'; - *bup = '\0'; - - /* Open and stat parent directory. */ - if (!(dir = opendir(up)) || fstat(dirfd(dir), &s)) - goto err; - - /* Add trailing slash for next directory. */ - *bup++ = '/'; - *bup = '\0'; - - /* - * 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 (!(dp = readdir(dir))) - goto notfound; - if (dp->d_fileno == ino) - break; - } - } else - for (;;) { - if (!(dp = readdir(dir))) - goto notfound; - if (ISDOT(dp)) - continue; - bcopy(dp->d_name, bup, dp->d_namlen + 1); - - /* Save the first error for later. */ - if (lstat(up, &s)) { - if (!save_errno) - save_errno = errno; - errno = 0; - continue; - } - if (s.st_dev == dev && s.st_ino == ino) - break; - } - - /* - * Check for length of the current name, preceding slash, - * leading slash. - */ - if (bpt - pt < dp->d_namlen + (first ? 1 : 2)) { - size_t len, off; - - if (!ptsize) { - errno = ERANGE; - goto err; - } - off = bpt - pt; - len = ept - bpt; - if ((pt = realloc(pt, ptsize *= 2)) == NULL) - goto err; - bpt = pt + off; - ept = pt + ptsize; - bcopy(bpt, ept - len, len); - bpt = ept - len; - } - if (!first) - *--bpt = '/'; - bpt -= dp->d_namlen; - bcopy(dp->d_name, bpt, dp->d_namlen); - (void) closedir(dir); - dir = NULL; - - /* 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) - errno = save_errno ? save_errno : ENOENT; - /* FALLTHROUGH */ -err: - save_errno = errno; - - if (ptsize) - free(pt); - if (dir) - (void) closedir(dir); - free(up); - - errno = save_errno; - return (NULL); -} diff --git a/lib/libc/gen/getdiskbyname.3 b/lib/libc/gen/getdiskbyname.3 deleted file mode 100644 index 14d8824..0000000 --- a/lib/libc/gen/getdiskbyname.3 +++ /dev/null @@ -1,65 +0,0 @@ -.\" Copyright (c) 1983, 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. -.\" -.\" @(#)getdiskbyname.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt GETDISKBYNAME 3 -.Os BSD 4.2 -.Sh NAME -.Nm getdiskbyname -.Nd get generic disk description by its name -.Sh SYNOPSIS -.Fd #include -.Ft struct disklabel * -.Fn getdiskbyname "const char *name" -.Sh DESCRIPTION -The -.Fn getdiskbyname -function -takes a disk name (e.g. -.Ql rm03 ) -and returns a prototype disk label -describing its geometry information and the standard -disk partition tables. All information is obtained from -the -.Xr disktab 5 -file. -.Sh SEE ALSO -.Xr disklabel 5 , -.Xr disktab 5 , -.Xr disklabel 8 -.Sh HISTORY -The -.Fn getdiskbyname -function appeared in -.Bx 4.3 . diff --git a/lib/libc/gen/getdomainname.3 b/lib/libc/gen/getdomainname.3 deleted file mode 100644 index 60a8099..0000000 --- a/lib/libc/gen/getdomainname.3 +++ /dev/null @@ -1,99 +0,0 @@ -.\" Copyright (c) 1983, 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. -.\" -.\" @(#)gethostname.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd May 6, 1994 -.Dt GETDOMAINNAME 3 -.Os BSD 4.2 -.Sh NAME -.Nm getdomainname , -.Nm setdomainname -.Nd get/set domain name of current host -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn getdomainname "char *name" "int namelen" -.Ft int -.Fn setdomainname "const char *name" "int namelen" -.Sh DESCRIPTION -.Fn Getdomainname -returns the standard domain name for the current processor, as -previously set by -.Fn setdomainname . -The parameter -.Fa namelen -specifies the size of the -.Fa name -array. The returned name is null-terminated unless insufficient -space is provided. -.Pp -.Fn Setdomainname -sets the domain name of the host machine to be -.Fa name , -which has length -.Fa namelen . -This call is restricted to the super-user and -is normally used only when the system is bootstrapped. -.Sh RETURN VALUES -If the call succeeds a value of 0 is returned. If the call -fails, a value of -1 is returned and an error code is -placed in the global location -.Va errno . -.Sh ERRORS -The following errors may be returned by these calls: -.Bl -tag -width Er -.It Bq Er EFAULT -The -.Fa name -or -.Fa namelen -parameter gave an -invalid address. -.It Bq Er EPERM -The caller tried to set the hostname and was not the super-user. -.El -.Sh SEE ALSO -.Xr gethostid 3 , -.Xr gethostname 3 , -.Xr sysctl 3 -.Sh BUGS -Domain names are limited to -.Dv MAXHOSTNAMELEN -(from -.Ao Pa sys/param.h Ac ) -characters, currently 256. -.Sh HISTORY -The -.Fn getdomainname -function call appeared in -.Bx 4.2 . diff --git a/lib/libc/gen/getdomainname.c b/lib/libc/gen/getdomainname.c deleted file mode 100644 index aafb010..0000000 --- a/lib/libc/gen/getdomainname.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/* -static char sccsid[] = "From: @(#)gethostname.c 8.1 (Berkeley) 6/4/93"; -*/ -static const char rcsid[] = - "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#include - -int -getdomainname(name, namelen) - char *name; - int namelen; -{ - int mib[2]; - size_t size; - - mib[0] = CTL_KERN; - mib[1] = KERN_NISDOMAINNAME; - size = namelen; - if (sysctl(mib, 2, name, &size, NULL, 0) == -1) - return (-1); - return (0); -} diff --git a/lib/libc/gen/getfsent.3 b/lib/libc/gen/getfsent.3 deleted file mode 100644 index 98064fc..0000000 --- a/lib/libc/gen/getfsent.3 +++ /dev/null @@ -1,151 +0,0 @@ -.\" Copyright (c) 1983, 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. -.\" -.\" @(#)getfsent.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt GETFSENT 3 -.Os BSD 4 -.Sh NAME -.Nm getfsent , -.Nm getfsspec , -.Nm getfsfile , -.Nm setfsent , -.Nm endfsent -.Nd get file system descriptor file entry -.Sh SYNOPSIS -.Fd #include -.Ft struct fstab * -.Fn getfsent void -.Ft struct fstab * -.Fn getfsspec "const char *spec" -.Ft struct fstab * -.Fn getfsfile "const char *file" -.Ft int -.Fn setfsent void -.Ft void -.Fn endfsent void -.Sh DESCRIPTION -The -.Fn getfsent , -.Fn getfsspec , -and -.Fn getfsfile -functions -each return a pointer to an object with the following structure -containing the broken-out fields of a line in the file system -description file, -.Aq Pa fstab.h . -.Bd -literal -offset indent -struct fstab { - char *fs_spec; /* block special device name */ - char *fs_file; /* file system path prefix */ - char *fs_vfstype; /* File system type, ufs, nfs */ - char *fs_mntops; /* Mount options ala -o */ - char *fs_type; /* FSTAB_* from fs_mntops */ - int fs_freq; /* dump frequency, in days */ - int fs_passno; /* pass number on parallel fsck */ -}; -.Ed -.Pp -The fields have meanings described in -.Xr fstab 5 . -.Pp -The -.Fn setfsent -function -opens the file (closing any previously opened file) or rewinds it -if it is already open. -.Pp -The -.Fn endfsent -function -closes the file. -.Pp -The -.Fn getfsspec -and -.Fn getfsfile -functions -search the entire file (opening it if necessary) for a matching special -file name or file system file name. -.Pp -For programs wishing to read the entire database, -.Fn getfsent -reads the next entry (opening the file if necessary). -.Pp -All entries in the file with a type field equivalent to -.Dv FSTAB_XX -are ignored. -.Sh RETURN VALUES -The -.Fn getfsent , -.Fn getfsspec , -and -.Fn getfsfile -functions -return a -.Dv NULL -pointer on -.Dv EOF -or error. -The -.Fn setfsent -function -returns 0 on failure, 1 on success. -The -.Fn endfsent -function -returns nothing. -.Sh FILES -.Bl -tag -width /etc/fstab -compact -.It Pa /etc/fstab -.El -.Sh SEE ALSO -.Xr fstab 5 -.Sh HISTORY -The -.Fn getfsent -function appeared in -.Bx 4.0 ; -the -.Fn endfsent , -.Fn getfsfile , -.Fn getfsspec , -and -.Fn setfsent -functions appeared in -.Bx 4.3 . -.Sh BUGS -These functions use static data storage; -if the data is needed for future use, it should be -copied before any subsequent calls overwrite it. diff --git a/lib/libc/gen/getgrent.3 b/lib/libc/gen/getgrent.3 deleted file mode 100644 index ffac782..0000000 --- a/lib/libc/gen/getgrent.3 +++ /dev/null @@ -1,206 +0,0 @@ -.\" Copyright (c) 1989, 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. -.\" -.\" From: @(#)getgrent.3 8.2 (Berkeley) 4/19/94 -.\" $FreeBSD$ -.\" -.Dd September 29, 1994 -.Dt GETGRENT 3 -.Os -.Sh NAME -.Nm getgrent , -.Nm getgrnam , -.Nm getgrgid , -.Nm setgroupent , -.\" .Nm setgrfile , -.Nm setgrent , -.Nm endgrent -.Nd group database operations -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Ft struct group * -.Fn getgrent void -.Ft struct group * -.Fn getgrnam "const char *name" -.Ft struct group * -.Fn getgrgid "gid_t gid" -.Ft int -.Fn setgroupent "int stayopen" -.\" .Ft void -.\" .Fn setgrfile "const char *name" -.Ft int -.Fn setgrent void -.Ft void -.Fn endgrent void -.Sh DESCRIPTION -These functions operate on the group database file -.Pa /etc/group -which is described -in -.Xr group 5 . -Each line of the database is defined by the structure -.Ar group -found in the include -file -.Aq Pa grp.h : -.Bd -literal -offset indent -struct group { - char *gr_name; /* group name */ - char *gr_passwd; /* group password */ - int gr_gid; /* group id */ - char **gr_mem; /* group members */ -}; -.Ed -.Pp -The functions -.Fn getgrnam -and -.Fn getgrgid -search the group database for the given group name pointed to by -.Ar name -or the group id pointed to by -.Ar gid , -respectively, returning the first one encountered. Identical group -names or group gids may result in undefined behavior. -.Pp -The -.Fn getgrent -function -sequentially reads the group database and is intended for programs -that wish to step through the complete list of groups. -.Pp -All three routines will open the group file for reading, if necessary. -.Pp -The -.Fn setgroupent -function -opens the file, or rewinds it if it is already open. If -.Fa stayopen -is non-zero, file descriptors are left open, significantly speeding -functions subsequent calls. This functionality is unnecessary for -.Fn getgrent -as it doesn't close its file descriptors by default. It should also -be noted that it is dangerous for long-running programs to use this -functionality as the group file may be updated. -.Pp -The -.Fn setgrent -function -is identical to -.Fn setgroupent -with an argument of zero. -.Pp -The -.Fn endgrent -function -closes any open files. -.Sh YP/NIS INTERACTION -When the -.Xr yp 4 -group database is enabled, the -.Fn getgrnam -and -.Fn getgrgid -functions use the YP maps -.Dq Li group.byname -and -.Dq Li group.bygid , -respectively, if the requested group is not found in the local -.Pa /etc/group -file. The -.Fn getgrent -function will step through the YP map -.Dq Li group.byname -if the entire map is enabled as described in -.Xr group 5 . -.Sh RETURN VALUES -The functions -.Fn getgrent , -.Fn getgrnam , -and -.Fn getgrgid , -return a pointer to the group entry if successful; if end-of-file -is reached or an error occurs a null pointer is returned. -The functions -.Fn setgroupent -and -.Fn setgrent -return the value 1 if successful, otherwise the value -0 is returned. -The functions -.Fn endgrent -and -.Fn setgrfile -have no return value. -.Sh FILES -.Bl -tag -width /etc/group -compact -.It Pa /etc/group -group database file -.El -.Sh SEE ALSO -.Xr getpwent 3 , -.Xr yp 4 , -.Xr group 5 -.Sh HISTORY -The functions -.Fn endgrent , -.Fn getgrent , -.Fn getgrnam , -.Fn getgrgid , -and -.Fn setgrent -appeared in -.At v7 . -The functions -.Fn setgrfile -and -.Fn setgroupent -appeared in -.Bx 4.3 Reno . -.Sh COMPATIBILITY -The historic function -.Fn setgrfile , -which allowed the specification of alternate password databases, has -been deprecated and is no longer available. -.Sh BUGS -The functions -.Fn getgrent , -.Fn getgrnam , -.Fn getgrgid , -.Fn setgroupent -and -.Fn setgrent -leave their results in an internal static object and return -a pointer to that object. -Subsequent calls to -the same function -will modify the same object. diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c deleted file mode 100644 index 5b5c9da..0000000 --- a/lib/libc/gen/getgrent.c +++ /dev/null @@ -1,553 +0,0 @@ -/* - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getgrent.c 8.2 (Berkeley) 3/21/94"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include - -static FILE *_gr_fp; -static struct group _gr_group; -static int _gr_stayopen; -static int grscan(), start_gr(); -#ifdef YP -#include -#include -#include -static int _gr_stepping_yp; -static int _gr_yp_enabled; -static int _getypgroup(struct group *, const char *, char *); -static int _nextypgroup(struct group *); -#endif - -/* initial size for malloc and increase steps for realloc */ -#define MAXGRP 64 -#define MAXLINELENGTH 256 - -static char **members; /* list of group members */ -static int maxgrp; /* current length of **mebers */ -static char *line; /* temp buffer for group line */ -static int maxlinelength; /* current length of *line */ - -/* - * Lines longer than MAXLINELENGTHLIMIT will be count as an error. - * <= 0 disable check for maximum line length - * 256K is enough for 64,000 uids - */ -#define MAXLINELENGTHLIMIT (256 * 1024) -#define GROUP_IGNORE_COMMENTS 1 /* allow comments in /etc/group */ - -struct group * -getgrent() -{ - if (!_gr_fp && !start_gr()) { - return NULL; - } - -#ifdef YP - if (_gr_stepping_yp) { - if (_nextypgroup(&_gr_group)) - return(&_gr_group); - } -tryagain: -#endif - - if (!grscan(0, 0, NULL)) - return(NULL); -#ifdef YP - if(_gr_group.gr_name[0] == '+' && _gr_group.gr_name[1]) { - _getypgroup(&_gr_group, &_gr_group.gr_name[1], - "group.byname"); - } else if(_gr_group.gr_name[0] == '+') { - if (!_nextypgroup(&_gr_group)) - goto tryagain; - else - return(&_gr_group); - } -#endif - return(&_gr_group); -} - -struct group * -getgrnam(name) - const char *name; -{ - int rval; - - if (!start_gr()) - return(NULL); -#ifdef YP - tryagain: -#endif - rval = grscan(1, 0, name); -#ifdef YP - if(rval == -1 && (_gr_yp_enabled < 0 || (_gr_yp_enabled && - _gr_group.gr_name[0] == '+'))) { - if (!(rval = _getypgroup(&_gr_group, name, "group.byname"))) - goto tryagain; - } -#endif - if (!_gr_stayopen) - endgrent(); - return(rval ? &_gr_group : NULL); -} - -struct group * -#ifdef __STDC__ -getgrgid(gid_t gid) -#else -getgrgid(gid) - gid_t gid; -#endif -{ - int rval; - - if (!start_gr()) - return(NULL); -#ifdef YP - tryagain: -#endif - rval = grscan(1, gid, NULL); -#ifdef YP - if(rval == -1 && _gr_yp_enabled) { - char buf[16]; - snprintf(buf, sizeof buf, "%d", (unsigned)gid); - if (!(rval = _getypgroup(&_gr_group, buf, "group.bygid"))) - goto tryagain; - } -#endif - if (!_gr_stayopen) - endgrent(); - return(rval ? &_gr_group : NULL); -} - -static int -start_gr() -{ - if (_gr_fp) { - rewind(_gr_fp); - return(1); - } - _gr_fp = fopen(_PATH_GROUP, "r"); - if(!_gr_fp) return 0; -#ifdef YP - /* - * This is a disgusting hack, used to determine when YP is enabled. - * This would be easier if we had a group database to go along with - * the password database. - */ - { - char *line; - size_t linelen; - _gr_yp_enabled = 0; - while((line = fgetln(_gr_fp, &linelen)) != NULL) { - if(line[0] == '+') { - if(line[1] && line[1] != ':' && !_gr_yp_enabled) { - _gr_yp_enabled = 1; - } else { - _gr_yp_enabled = -1; - break; - } - } - } - rewind(_gr_fp); - } -#endif - - if (maxlinelength == 0) { - if ((line = (char *)malloc(sizeof(char) * - MAXLINELENGTH)) == NULL) - return(0); - maxlinelength += MAXLINELENGTH; - } - - if (maxgrp == 0) { - if ((members = (char **)malloc(sizeof(char **) * - MAXGRP)) == NULL) - return(0); - maxgrp += MAXGRP; - } - - return 1; -} - -int -setgrent() -{ - return(setgroupent(0)); -} - -int -setgroupent(stayopen) - int stayopen; -{ - if (!start_gr()) - return(0); - _gr_stayopen = stayopen; -#ifdef YP - _gr_stepping_yp = 0; -#endif - return(1); -} - -void -endgrent() -{ -#ifdef YP - _gr_stepping_yp = 0; -#endif - if (_gr_fp) { - (void)fclose(_gr_fp); - _gr_fp = NULL; - } -} - -static int -grscan(search, gid, name) - register int search, gid; - register char *name; -{ - register char *cp, **m; - char *bp; - - -#ifdef YP - int _ypfound; -#endif - for (;;) { -#ifdef YP - _ypfound = 0; -#endif - if (fgets(line, maxlinelength, _gr_fp) == NULL) - return(0); - - if (!index(line, '\n')) { - do { - if (feof(_gr_fp)) - return(0); - - /* don't allocate infinite memory */ - if (MAXLINELENGTHLIMIT > 0 && - maxlinelength >= MAXLINELENGTHLIMIT) - return(0); - - if ((line = (char *)reallocf(line, - sizeof(char) * - (maxlinelength + MAXLINELENGTH))) == NULL) - return(0); - - if (fgets(line + maxlinelength - 1, - MAXLINELENGTH + 1, _gr_fp) == NULL) - return(0); - - maxlinelength += MAXLINELENGTH; - } while (!index(line + maxlinelength - - MAXLINELENGTH - 1, '\n')); - } - -#ifdef GROUP_IGNORE_COMMENTS - /* - * Ignore comments: ^[ \t]*# - */ - for (cp = line; *cp != '\0'; cp++) - if (*cp != ' ' && *cp != '\t') - break; - if (*cp == '#' || *cp == '\0') - continue; -#endif - - bp = line; - - if ((_gr_group.gr_name = strsep(&bp, ":\n")) == NULL) - break; -#ifdef YP - /* - * XXX We need to be careful to avoid proceeding - * past this point under certain circumstances or - * we risk dereferencing null pointers down below. - */ - if (_gr_group.gr_name[0] == '+') { - if (strlen(_gr_group.gr_name) == 1) { - switch(search) { - case 0: - return(1); - case 1: - return(-1); - default: - return(0); - } - } else { - cp = &_gr_group.gr_name[1]; - if (search && name != NULL) - if (strcmp(cp, name)) - continue; - if (!_getypgroup(&_gr_group, cp, - "group.byname")) - continue; - if (search && name == NULL) - if (gid != _gr_group.gr_gid) - continue; - /* We're going to override -- tell the world. */ - _ypfound++; - } - } -#else - if (_gr_group.gr_name[0] == '+') - continue; -#endif /* YP */ - if (search && name) { - if(strcmp(_gr_group.gr_name, name)) { - continue; - } - } -#ifdef YP - if ((cp = strsep(&bp, ":\n")) == NULL) - if (_ypfound) - return(1); - else - break; - if (strlen(cp) || !_ypfound) - _gr_group.gr_passwd = cp; -#else - if ((_gr_group.gr_passwd = strsep(&bp, ":\n")) == NULL) - break; -#endif - if (!(cp = strsep(&bp, ":\n"))) -#ifdef YP - if (_ypfound) - return(1); - else -#endif - continue; -#ifdef YP - /* - * Hurm. Should we be doing this? We allow UIDs to - * be overridden -- what about GIDs? - */ - if (!_ypfound) -#endif - _gr_group.gr_gid = atoi(cp); - if (search && name == NULL && _gr_group.gr_gid != gid) - continue; - cp = NULL; - if (bp == NULL) /* !!! Must check for this! */ - break; -#ifdef YP - if ((cp = strsep(&bp, ":\n")) == NULL) - break; - - if (!strlen(cp) && _ypfound) - return(1); - else - members[0] = NULL; - bp = cp; - cp = NULL; -#endif - for (m = members; ; bp++) { - if (m == (members + maxgrp - 1)) { - if ((members = (char **) - reallocf(members, - sizeof(char **) * - (maxgrp + MAXGRP))) == NULL) - return(0); - m = members + maxgrp - 1; - maxgrp += MAXGRP; - } - if (*bp == ',') { - if (cp) { - *bp = '\0'; - *m++ = cp; - cp = NULL; - } - } else if (*bp == '\0' || *bp == '\n' || *bp == ' ') { - if (cp) { - *bp = '\0'; - *m++ = cp; - } - break; - } else if (cp == NULL) - cp = bp; - - } - _gr_group.gr_mem = members; - *m = NULL; - return(1); - } - /* NOTREACHED */ - return (0); -} - -#ifdef YP - -static int -_gr_breakout_yp(struct group *gr, char *result) -{ - char *s, *cp; - char **m; - - /* - * XXX If 's' ends up being a NULL pointer, punt on this group. - * It means the NIS group entry is badly formatted and should - * be skipped. - */ - if ((s = strsep(&result, ":")) == NULL) return 0; /* name */ - gr->gr_name = s; - - if ((s = strsep(&result, ":")) == NULL) return 0; /* password */ - gr->gr_passwd = s; - - if ((s = strsep(&result, ":")) == NULL) return 0; /* gid */ - gr->gr_gid = atoi(s); - - if ((s = result) == NULL) return 0; - cp = 0; - - for (m = members; ; s++) { - if (m == members + maxgrp - 1) { - if ((members = (char **)reallocf(members, - sizeof(char **) * (maxgrp + MAXGRP))) == NULL) - return(0); - m = members + maxgrp - 1; - maxgrp += MAXGRP; - } - if (*s == ',') { - if (cp) { - *s = '\0'; - *m++ = cp; - cp = NULL; - } - } else if (*s == '\0' || *s == '\n' || *s == ' ') { - if (cp) { - *s = '\0'; - *m++ = cp; - } - break; - } else if (cp == NULL) { - cp = s; - } - } - _gr_group.gr_mem = members; - *m = NULL; - - return 1; -} - -static char *_gr_yp_domain; - -static int -_getypgroup(struct group *gr, const char *name, char *map) -{ - char *result, *s; - static char resultbuf[YPMAXRECORD + 2]; - int resultlen; - - if(!_gr_yp_domain) { - if(yp_get_default_domain(&_gr_yp_domain)) - return 0; - } - - if(yp_match(_gr_yp_domain, map, name, strlen(name), - &result, &resultlen)) - return 0; - - s = strchr(result, '\n'); - if(s) *s = '\0'; - - if(resultlen >= sizeof resultbuf) return 0; - strncpy(resultbuf, result, resultlen); - resultbuf[resultlen] = '\0'; - free(result); - return(_gr_breakout_yp(gr, resultbuf)); - -} - - -static int -_nextypgroup(struct group *gr) -{ - static char *key; - static int keylen; - char *lastkey, *result; - static char resultbuf[YPMAXRECORD + 2]; - int resultlen; - int rv; - - if(!_gr_yp_domain) { - if(yp_get_default_domain(&_gr_yp_domain)) - return 0; - } - - if(!_gr_stepping_yp) { - if(key) free(key); - rv = yp_first(_gr_yp_domain, "group.byname", - &key, &keylen, &result, &resultlen); - if(rv) { - return 0; - } - _gr_stepping_yp = 1; - goto unpack; - } else { -tryagain: - lastkey = key; - rv = yp_next(_gr_yp_domain, "group.byname", key, keylen, - &key, &keylen, &result, &resultlen); - free(lastkey); -unpack: - if(rv) { - _gr_stepping_yp = 0; - return 0; - } - - if(resultlen > sizeof(resultbuf)) { - free(result); - goto tryagain; - } - - strncpy(resultbuf, result, resultlen); - resultbuf[resultlen] = '\0'; - free(result); - if((result = strchr(resultbuf, '\n')) != NULL) - *result = '\0'; - if (_gr_breakout_yp(gr, resultbuf)) - return(1); - else - goto tryagain; - } -} - -#endif /* YP */ diff --git a/lib/libc/gen/getgrouplist.3 b/lib/libc/gen/getgrouplist.3 deleted file mode 100644 index e85eaa5..0000000 --- a/lib/libc/gen/getgrouplist.3 +++ /dev/null @@ -1,94 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)getgrouplist.3 8.1 (Berkeley) 6/9/93 -.\" $FreeBSD$ -.\" -.Dd June 9, 1993 -.Dt GETGROUPLIST 3 -.Os -.Sh NAME -.Nm getgrouplist -.Nd calculate group access list -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn getgrouplist "const char *name" "int basegid" "int *groups" "int *ngroups" -.Sh DESCRIPTION -The -.Fn getgrouplist -function reads through the group file and calculates -the group access list for the user specified in -.Fa name . -The -.Fa basegid -is automatically included in the groups list. -Typically this value is given as -the group number from the password file. -.Pp -The resulting group list is returned in the integer array pointed to by -.Fa groups . -The caller specifies the size of the -.Fa groups -array in the integer pointed to by -.Fa ngroups ; -the actual number of groups found is returned in -.Fa ngroups . -.Sh RETURN VALUES -The -.Fn getgrouplist -function -returns \-1 if the size of the group list is too small to -hold all the user's groups. -Here, the group array will be filled with as many groups as will fit. -.Sh FILES -.Bl -tag -width /etc/group -compact -.It Pa /etc/group -group membership list -.El -.Sh SEE ALSO -.Xr setgroups 2 , -.Xr initgroups 3 -.Sh HISTORY -The -.Fn getgrouplist -function first appeared in -.Bx 4.4 . -.Sh BUGS -The -.Fn getgrouplist -function -uses the routines based on -.Xr getgrent 3 . -If the invoking program uses any of these routines, -the group structure will -be overwritten in the call to -.Fn getgrouplist . diff --git a/lib/libc/gen/getgrouplist.c b/lib/libc/gen/getgrouplist.c deleted file mode 100644 index 31f90b4..0000000 --- a/lib/libc/gen/getgrouplist.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getgrouplist.c 8.2 (Berkeley) 12/8/94"; -#endif /* LIBC_SCCS and not lint */ - -/* - * get credential - */ -#include -#include -#include - -int -getgrouplist(uname, agroup, groups, grpcnt) - const char *uname; - int agroup; - register int *groups; - int *grpcnt; -{ - register struct group *grp; - register int i, ngroups; - int ret, maxgroups; - - ret = 0; - ngroups = 0; - maxgroups = *grpcnt; - /* - * When installing primary group, duplicate it; - * the first element of groups is the effective gid - * and will be overwritten when a setgid file is executed. - */ - groups[ngroups++] = agroup; - if (maxgroups > 1) - groups[ngroups++] = agroup; - /* - * Scan the group file to find additional groups. - */ - setgrent(); - while (grp = getgrent()) { - for (i = 0; i < ngroups; i++) { - if (grp->gr_gid == groups[i]) - goto skip; - } - for (i = 0; grp->gr_mem[i]; i++) { - if (!strcmp(grp->gr_mem[i], uname)) { - if (ngroups >= maxgroups) { - ret = -1; - break; - } - groups[ngroups++] = grp->gr_gid; - break; - } - } -skip: - } - endgrent(); - *grpcnt = ngroups; - return (ret); -} diff --git a/lib/libc/gen/gethostname.3 b/lib/libc/gen/gethostname.3 deleted file mode 100644 index f4d2d04..0000000 --- a/lib/libc/gen/gethostname.3 +++ /dev/null @@ -1,98 +0,0 @@ -.\" Copyright (c) 1983, 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. -.\" -.\" @(#)gethostname.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt GETHOSTNAME 3 -.Os BSD 4.2 -.Sh NAME -.Nm gethostname , -.Nm sethostname -.Nd get/set name of current host -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn gethostname "char *name" "int namelen" -.Ft int -.Fn sethostname "const char *name" "int namelen" -.Sh DESCRIPTION -.Fn Gethostname -returns the standard host name for the current processor, as -previously set by -.Fn sethostname . -The parameter -.Fa namelen -specifies the size of the -.Fa name -array. The returned name is null-terminated unless insufficient -space is provided. -.Pp -.Fn Sethostname -sets the name of the host machine to be -.Fa name , -which has length -.Fa namelen . -This call is restricted to the super-user and -is normally used only when the system is bootstrapped. -.Sh RETURN VALUES -If the call succeeds a value of 0 is returned. If the call -fails, a value of -1 is returned and an error code is -placed in the global location -.Va errno . -.Sh ERRORS -The following errors may be returned by these calls: -.Bl -tag -width Er -.It Bq Er EFAULT -The -.Fa name -or -.Fa namelen -parameter gave an -invalid address. -.It Bq Er EPERM -The caller tried to set the hostname and was not the super-user. -.El -.Sh SEE ALSO -.Xr gethostid 3 , -.Xr sysctl 3 -.Sh BUGS -Host names are limited to -.Dv MAXHOSTNAMELEN -(from -.Ao Pa sys/param.h Ac ) -characters, currently 256. -.Sh HISTORY -The -.Fn gethostname -function call appeared in -.Bx 4.2 . diff --git a/lib/libc/gen/gethostname.c b/lib/libc/gen/gethostname.c deleted file mode 100644 index 64bd64d..0000000 --- a/lib/libc/gen/gethostname.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)gethostname.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -int -gethostname(name, namelen) - char *name; - int namelen; -{ - int mib[2]; - size_t size; - - mib[0] = CTL_KERN; - mib[1] = KERN_HOSTNAME; - size = namelen; - if (sysctl(mib, 2, name, &size, NULL, 0) == -1) - return (-1); - return (0); -} diff --git a/lib/libc/gen/getloadavg.3 b/lib/libc/gen/getloadavg.3 deleted file mode 100644 index 737f699..0000000 --- a/lib/libc/gen/getloadavg.3 +++ /dev/null @@ -1,67 +0,0 @@ -.\" Copyright (c) 1989, 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. -.\" -.\" @(#)getloadavg.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt GETLOADAVG 3 -.Os -.Sh NAME -.Nm getloadavg -.Nd get system load averages -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn getloadavg "double loadavg[]" "int nelem" -.Sh DESCRIPTION -The -.Fn getloadavg -function returns the number of processes in the system run queue -averaged over various periods of time. -Up to -.Fa nelem -samples are retrieved and assigned to successive elements of -.Fa loadavg Ns Bq . -The system imposes a maximum of 3 samples, representing averages -over the last 1, 5, and 15 minutes, respectively. -.Sh DIAGNOSTICS -If the load average was unobtainable, \-1 is returned; otherwise, -the number of samples actually retrieved is returned. -.Sh SEE ALSO -.Xr uptime 1 , -.Xr kvm_getloadavg 3 , -.Xr sysctl 3 -.Sh HISTORY -The -.Fn getloadavg -function appeared in -.Bx 4.3 Reno . diff --git a/lib/libc/gen/getloadavg.c b/lib/libc/gen/getloadavg.c deleted file mode 100644 index 811dbda..0000000 --- a/lib/libc/gen/getloadavg.c +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getloadavg.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include - -#include - -/* - * getloadavg() -- Get system load averages. - * - * Put `nelem' samples into `loadavg' array. - * Return number of samples retrieved, or -1 on error. - */ -int -getloadavg(loadavg, nelem) - double loadavg[]; - int nelem; -{ - struct loadavg loadinfo; - int i, mib[2]; - size_t size; - - mib[0] = CTL_VM; - mib[1] = VM_LOADAVG; - size = sizeof(loadinfo); - if (sysctl(mib, 2, &loadinfo, &size, NULL, 0) < 0) - return (-1); - - nelem = MIN(nelem, sizeof(loadinfo.ldavg) / sizeof(fixpt_t)); - for (i = 0; i < nelem; i++) - loadavg[i] = (double) loadinfo.ldavg[i] / loadinfo.fscale; - return (nelem); -} diff --git a/lib/libc/gen/getlogin.c b/lib/libc/gen/getlogin.c deleted file mode 100644 index 044689d..0000000 --- a/lib/libc/gen/getlogin.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 1988, 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getlogin.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include - -int _logname_valid; /* known to setlogin() */ - -char * -getlogin() -{ - static char logname[MAXLOGNAME]; - - if (_logname_valid == 0) { -#ifdef __NETBSD_SYSCALLS - if (__getlogin(logname, sizeof(logname) - 1) < 0) -#else - if (_getlogin(logname, sizeof(logname)) < 0) -#endif - return ((char *)NULL); - _logname_valid = 1; - } - return (*logname ? logname : (char *)NULL); -} - - -char * -getlogin_r(char *logname, int namelen) -{ - if (_logname_valid == 0) { -#ifdef __NETBSD_SYSCALLS - if (__getlogin(logname, namelen - 1) < 0) -#else - if (_getlogin(logname, namelen) < 0) -#endif - return ((char *)NULL); - _logname_valid = 1; - } - return (*logname ? logname : (char *)NULL); -} diff --git a/lib/libc/gen/getmntinfo.3 b/lib/libc/gen/getmntinfo.3 deleted file mode 100644 index f1a7fa5..0000000 --- a/lib/libc/gen/getmntinfo.3 +++ /dev/null @@ -1,111 +0,0 @@ -.\" Copyright (c) 1989, 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. -.\" -.\" @(#)getmntinfo.3 8.1 (Berkeley) 6/9/93 -.\" $FreeBSD$ -.\" -.Dd June 9, 1993 -.Dt GETMNTINFO 3 -.Os -.Sh NAME -.Nm getmntinfo -.Nd get information about mounted file systems -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Fd #include -.Ft int -.Fn getmntinfo "struct statfs **mntbufp" "int flags" -.Sh DESCRIPTION -The -.Fn getmntinfo -function -returns an array of -.Fn statfs -structures describing each currently mounted file system (see -.Xr statfs 2 ) . -.Pp -The -.Fn getmntinfo -function -passes its -.Fa flags -parameter transparently to -.Xr getfsstat 2 . -.Sh RETURN VALUES -On successful completion, -.Fn getmntinfo -returns a count of the number of elements in the array. -The pointer to the array is stored into -.Fa mntbufp . -.Pp -If an error occurs, zero is returned and the external variable -.Va errno -is set to indicate the error. -Although the pointer -.Fa mntbufp -will be unmodified, any information previously returned by -.Fn getmntinfo -will be lost. -.Sh ERRORS -The -.Fn getmntinfo -function -may fail and set errno for any of the errors specified for the library -routines -.Xr getfsstat 2 -or -.Xr malloc 3 . -.Sh SEE ALSO -.Xr getfsstat 2 , -.Xr mount 2 , -.Xr statfs 2 , -.Xr mount 8 -.Sh HISTORY -The -.Fn getmntinfo -function first appeared in -.Bx 4.4 . -.Sh BUGS -The -.Fn getmntinfo -function writes the array of structures to an internal static object -and returns -a pointer to that object. -Subsequent calls to -.Fn getmntinfo -will modify the same object. -.Pp -The memory allocated by -.Fn getmntinfo -cannot be -.Xr free 3 Ns 'd -by the application. diff --git a/lib/libc/gen/getmntinfo.c b/lib/libc/gen/getmntinfo.c deleted file mode 100644 index 6e167a3..0000000 --- a/lib/libc/gen/getmntinfo.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getmntinfo.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -/* - * Return information about mounted filesystems. - */ -int -getmntinfo(mntbufp, flags) - struct statfs **mntbufp; - int flags; -{ - static struct statfs *mntbuf; - static int mntsize; - static long bufsize; - - if (mntsize <= 0 && (mntsize = getfsstat(0, 0, MNT_NOWAIT)) < 0) - return (0); - if (bufsize > 0 && (mntsize = getfsstat(mntbuf, bufsize, flags)) < 0) - return (0); - while (bufsize <= mntsize * sizeof(struct statfs)) { - if (mntbuf) - free(mntbuf); - bufsize = (mntsize + 1) * sizeof(struct statfs); - if ((mntbuf = (struct statfs *)malloc(bufsize)) == 0) - return (0); - if ((mntsize = getfsstat(mntbuf, bufsize, flags)) < 0) - return (0); - } - *mntbufp = mntbuf; - return (mntsize); -} diff --git a/lib/libc/gen/getnetgrent.3 b/lib/libc/gen/getnetgrent.3 deleted file mode 100644 index db8f550..0000000 --- a/lib/libc/gen/getnetgrent.3 +++ /dev/null @@ -1,129 +0,0 @@ -.\" Copyright (c) 1992, 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. -.\" -.\" @(#)getnetgrent.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt GETNETGRENT 3 -.Os -.Sh NAME -.Nm getnetgrent , -.Nm innetgr , -.Nm setnetgrent , -.Nm endnetgrent -.Nd netgroup database operations -.Sh SYNOPSIS -.Ft int -.Fn getnetgrent "char **host" "char **user" "char **domain" -.Ft int -.Fn innetgr "const char *netgroup" "const char *host" "const char *user" "const char *domain" -.Ft void -.Fn setnetgrent "const char *netgroup" -.Ft void -.Fn endnetgrent void -.Sh DESCRIPTION -These functions operate on the netgroup database file -.Pa /etc/netgroup -which is described -in -.Xr netgroup 5 . -The database defines a set of netgroups, each made up of one or more triples: -.Bd -literal -offset indent -(host, user, domain) -.Ed -that defines a combination of host, user and domain. -Any of the three fields may be specified as ``wildcards'' that match any -string. -.Pp -The function -.Fn getnetgrent -sets the three pointer arguments to the strings of the next member of the -current netgroup. -If any of the string pointers are -.Sy (char *)0 -that field is considered a wildcard. -.Pp -The functions -.Fn setnetgrent -and -.Fn endnetgrent -set the current netgroup and terminate the current netgroup respectively. -If -.Fn setnetgrent -is called with a different netgroup than the previous call, an implicit -.Fn endnetgrent -is implied. -.Fn Setnetgrent -also sets the offset to the first member of the netgroup. -.Pp -The function -.Fn innetgr -searches for a match of all fields within the specified group. -If any of the -.Sy host , -.Sy user , -or -.Sy domain -arguments are -.Sy (char *)0 -those fields will match any string value in the netgroup member. -.Sh RETURN VALUES -The function -.Fn getnetgrent -returns 0 for ``no more netgroup members'' and 1 otherwise. -The function -.Fn innetgr -returns 1 for a successful match and 0 otherwise. -The functions -.Fn setnetgrent -and -.Fn endnetgrent -have no return value. -.Sh FILES -.Bl -tag -width /etc/netgroup -compact -.It Pa /etc/netgroup -netgroup database file -.El -.Sh SEE ALSO -.Xr netgroup 5 -.Sh COMPATIBILITY -The netgroup members have three string fields to maintain compatibility -with other vendor implementations, however it is not obvious what use the -.Sy domain -string has within BSD. -.Sh BUGS -The function -.Fn getnetgrent -returns pointers to dynamically allocated data areas that are freed when -the function -.Fn endnetgrent -is called. diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c deleted file mode 100644 index a26c86c..0000000 --- a/lib/libc/gen/getnetgrent.c +++ /dev/null @@ -1,634 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Rick Macklem at The University of Guelph. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getnetgrent.c 8.2 (Berkeley) 4/27/95"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -#ifdef YP -/* - * Notes: - * We want to be able to use NIS netgroups properly while retaining - * the ability to use a local /etc/netgroup file. Unfortunately, you - * can't really do both at the same time - at least, not efficiently. - * NetBSD deals with this problem by creating a netgroup database - * using Berkeley DB (just like the password database) that allows - * for lookups using netgroup, netgroup.byuser or netgroup.byhost - * searches. This is a neat idea, but I don't have time to implement - * something like that now. (I think ultimately it would be nice - * if we DB-fied the group and netgroup stuff all in one shot, but - * for now I'm satisfied just to have something that works well - * without requiring massive code changes.) - * - * Therefore, to still permit the use of the local file and maintain - * optimum NIS performance, we allow for the following conditions: - * - * - If /etc/netgroup does not exist and NIS is turned on, we use - * NIS netgroups only. - * - * - If /etc/netgroup exists but is empty, we use NIS netgroups - * only. - * - * - If /etc/netgroup exists and contains _only_ a '+', we use - * NIS netgroups only. - * - * - If /etc/netgroup exists, contains locally defined netgroups - * and a '+', we use a mixture of NIS and the local entries. - * This method should return the same NIS data as just using - * NIS alone, but it will be slower if the NIS netgroup database - * is large (innetgr() in particular will suffer since extra - * processing has to be done in order to determine memberships - * using just the raw netgroup data). - * - * - If /etc/netgroup exists and contains only locally defined - * netgroup entries, we use just those local entries and ignore - * NIS (this is the original, pre-NIS behavior). - */ - -#include -#include -#include -#include -#include -#include -#include -static char *_netgr_yp_domain; -int _use_only_yp; -static int _netgr_yp_enabled; -static int _yp_innetgr; -#endif - -#ifndef _PATH_NETGROUP -#define _PATH_NETGROUP "/etc/netgroup" -#endif - -/* - * Static Variables and functions used by setnetgrent(), getnetgrent() and - * endnetgrent(). - * There are two linked lists: - * - linelist is just used by setnetgrent() to parse the net group file via. - * parse_netgrp() - * - netgrp is the list of entries for the current netgroup - */ -struct linelist { - struct linelist *l_next; /* Chain ptr. */ - int l_parsed; /* Flag for cycles */ - char *l_groupname; /* Name of netgroup */ - char *l_line; /* Netgroup entrie(s) to be parsed */ -}; - -struct netgrp { - struct netgrp *ng_next; /* Chain ptr */ - char *ng_str[3]; /* Field pointers, see below */ -}; -#define NG_HOST 0 /* Host name */ -#define NG_USER 1 /* User name */ -#define NG_DOM 2 /* and Domain name */ - -static struct linelist *linehead = (struct linelist *)0; -static struct netgrp *nextgrp = (struct netgrp *)0; -static struct { - struct netgrp *gr; - char *grname; -} grouphead = { - (struct netgrp *)0, - (char *)0, -}; -static FILE *netf = (FILE *)0; -static int parse_netgrp(); -static struct linelist *read_for_group(); -void setnetgrent(), endnetgrent(); -int getnetgrent(), innetgr(); - -#define LINSIZ 1024 /* Length of netgroup file line */ - -/* - * setnetgrent() - * Parse the netgroup file looking for the netgroup and build the list - * of netgrp structures. Let parse_netgrp() and read_for_group() do - * most of the work. - */ -void -setnetgrent(group) - char *group; -{ -#ifdef YP - struct stat _yp_statp; - char _yp_plus; -#endif - - /* Sanity check */ - - if (group == NULL || !strlen(group)) - return; - - if (grouphead.gr == (struct netgrp *)0 || - strcmp(group, grouphead.grname)) { - endnetgrent(); -#ifdef YP - /* Presumed guilty until proven innocent. */ - _use_only_yp = 0; - /* - * If /etc/netgroup doesn't exist or is empty, - * use NIS exclusively. - */ - if (((stat(_PATH_NETGROUP, &_yp_statp) < 0) && - errno == ENOENT) || _yp_statp.st_size == 0) - _use_only_yp = _netgr_yp_enabled = 1; - if ((netf = fopen(_PATH_NETGROUP,"r")) != NULL ||_use_only_yp){ - /* - * Icky: grab the first character of the netgroup file - * and turn on NIS if it's a '+'. rewind the stream - * afterwards so we don't goof up read_for_group() later. - */ - if (netf) { - fscanf(netf, "%c", &_yp_plus); - rewind(netf); - if (_yp_plus == '+') - _use_only_yp = _netgr_yp_enabled = 1; - } - /* - * If we were called specifically for an innetgr() - * lookup and we're in NIS-only mode, short-circuit - * parse_netgroup() and cut directly to the chase. - */ - if (_use_only_yp && _yp_innetgr) { - /* dohw! */ - if (netf != NULL) - fclose(netf); - return; - } -#else - if (netf = fopen(_PATH_NETGROUP, "r")) { -#endif - if (parse_netgrp(group)) - endnetgrent(); - else { - grouphead.grname = (char *) - malloc(strlen(group) + 1); - strcpy(grouphead.grname, group); - } - if (netf) - fclose(netf); - } - } - nextgrp = grouphead.gr; -} - -/* - * Get the next netgroup off the list. - */ -int -getnetgrent(hostp, userp, domp) - char **hostp, **userp, **domp; -{ -#ifdef YP - _yp_innetgr = 0; -#endif - - if (nextgrp) { - *hostp = nextgrp->ng_str[NG_HOST]; - *userp = nextgrp->ng_str[NG_USER]; - *domp = nextgrp->ng_str[NG_DOM]; - nextgrp = nextgrp->ng_next; - return (1); - } - return (0); -} - -/* - * endnetgrent() - cleanup - */ -void -endnetgrent() -{ - register struct linelist *lp, *olp; - register struct netgrp *gp, *ogp; - - lp = linehead; - while (lp) { - olp = lp; - lp = lp->l_next; - free(olp->l_groupname); - free(olp->l_line); - free((char *)olp); - } - linehead = (struct linelist *)0; - if (grouphead.grname) { - free(grouphead.grname); - grouphead.grname = (char *)0; - } - gp = grouphead.gr; - while (gp) { - ogp = gp; - gp = gp->ng_next; - if (ogp->ng_str[NG_HOST]) - free(ogp->ng_str[NG_HOST]); - if (ogp->ng_str[NG_USER]) - free(ogp->ng_str[NG_USER]); - if (ogp->ng_str[NG_DOM]) - free(ogp->ng_str[NG_DOM]); - free((char *)ogp); - } - grouphead.gr = (struct netgrp *)0; -#ifdef YP - _netgr_yp_enabled = 0; -#endif -} - -#ifdef YP -static int _listmatch(list, group, len) - char *list, *group; - int len; -{ - char *ptr = list, *cptr; - int glen = strlen(group); - - /* skip possible leading whitespace */ - while(isspace((unsigned char)*ptr)) - ptr++; - - while (ptr < list + len) { - cptr = ptr; - while(*ptr != ',' && *ptr != '\0' && !isspace((unsigned char)*ptr)) - ptr++; - if (strncmp(cptr, group, glen) == 0 && glen == (ptr - cptr)) - return(1); - while(*ptr == ',' || isspace((unsigned char)*ptr)) - ptr++; - } - - return(0); -} - -static int _buildkey(key, str, dom, rotation) -char *key, *str, *dom; -int *rotation; -{ - (*rotation)++; - if (*rotation > 4) - return(0); - switch(*rotation) { - case(1): sprintf((char *)key, "%s.%s", str, dom ? dom : "*"); - break; - case(2): sprintf((char *)key, "%s.*", str); - break; - case(3): sprintf((char *)key, "*.%s", dom ? dom : "*"); - break; - case(4): sprintf((char *)key, "*.*"); - break; - } - return(1); -} -#endif - -/* - * Search for a match in a netgroup. - */ -int -innetgr(group, host, user, dom) - const char *group, *host, *user, *dom; -{ - char *hst, *usr, *dm; -#ifdef YP - char *result; - int resultlen; - int rv; -#endif - /* Sanity check */ - - if (group == NULL || !strlen(group)) - return (0); - -#ifdef YP - _yp_innetgr = 1; -#endif - setnetgrent(group); -#ifdef YP - _yp_innetgr = 0; - /* - * If we're in NIS-only mode, do the search using - * NIS 'reverse netgroup' lookups. - */ - if (_use_only_yp) { - char _key[MAXHOSTNAMELEN]; - int rot = 0, y = 0; - - if(yp_get_default_domain(&_netgr_yp_domain)) - return(0); - while(_buildkey(_key, user ? user : host, dom, &rot)) { - y = yp_match(_netgr_yp_domain, user? "netgroup.byuser": - "netgroup.byhost", _key, strlen(_key), &result, - &resultlen); - if (y) { - /* - * If we get an error other than 'no - * such key in map' then something is - * wrong and we should stop the search. - */ - if (y != YPERR_KEY) - break; - } else { - rv = _listmatch(result, group, resultlen); - free(result); - if (rv) - return(1); - else - return(0); - } - } - /* - * Couldn't match using NIS-exclusive mode. If the error - * was YPERR_MAP, then the failure happened because there - * was no netgroup.byhost or netgroup.byuser map. The odds - * are we are talking to an Sun NIS+ server in YP emulation - * mode; if this is the case, then we have to do the check - * the 'old-fashioned' way by grovelling through the netgroup - * map and resolving memberships on the fly. - */ - if (y != YPERR_MAP) - return(0); - } - - setnetgrent(group); -#endif /* YP */ - - while (getnetgrent(&hst, &usr, &dm)) - if ((host == NULL || hst == NULL || !strcmp(host, hst)) && - (user == NULL || usr == NULL || !strcmp(user, usr)) && - ( dom == NULL || dm == NULL || !strcmp(dom, dm))) { - endnetgrent(); - return (1); - } - endnetgrent(); - return (0); -} - -/* - * Parse the netgroup file setting up the linked lists. - */ -static int -parse_netgrp(group) - char *group; -{ - register char *spos, *epos; - register int len, strpos; -#ifdef DEBUG - register int fields; -#endif - char *pos, *gpos; - struct netgrp *grp; - struct linelist *lp = linehead; - - /* - * First, see if the line has already been read in. - */ - while (lp) { - if (!strcmp(group, lp->l_groupname)) - break; - lp = lp->l_next; - } - if (lp == (struct linelist *)0 && - (lp = read_for_group(group)) == (struct linelist *)0) - return (1); - if (lp->l_parsed) { -#ifdef DEBUG - /* - * This error message is largely superflous since the - * code handles the error condition sucessfully, and - * spewing it out from inside libc can actually hose - * certain programs. - */ - fprintf(stderr, "Cycle in netgroup %s\n", lp->l_groupname); -#endif - return (1); - } else - lp->l_parsed = 1; - pos = lp->l_line; - /* Watch for null pointer dereferences, dammit! */ - while (pos != NULL && *pos != '\0') { - if (*pos == '(') { - grp = (struct netgrp *)malloc(sizeof (struct netgrp)); - bzero((char *)grp, sizeof (struct netgrp)); - grp->ng_next = grouphead.gr; - grouphead.gr = grp; - pos++; - gpos = strsep(&pos, ")"); -#ifdef DEBUG - fields = 0; -#endif - for (strpos = 0; strpos < 3; strpos++) { - if ((spos = strsep(&gpos, ","))) { -#ifdef DEBUG - fields++; -#endif - while (*spos == ' ' || *spos == '\t') - spos++; - if ((epos = strpbrk(spos, " \t"))) { - *epos = '\0'; - len = epos - spos; - } else - len = strlen(spos); - if (len > 0) { - grp->ng_str[strpos] = (char *) - malloc(len + 1); - bcopy(spos, grp->ng_str[strpos], - len + 1); - } - } else { - /* - * All other systems I've tested - * return NULL for empty netgroup - * fields. It's up to user programs - * to handle the NULLs appropriately. - */ - grp->ng_str[strpos] = NULL; - } - } -#ifdef DEBUG - /* - * Note: on other platforms, malformed netgroup - * entries are not normally flagged. While we - * can catch bad entries and report them, we should - * stay silent by default for compatibility's sake. - */ - if (fields < 3) - fprintf(stderr, "Bad entry (%s%s%s%s%s) in netgroup \"%s\"\n", - grp->ng_str[NG_HOST] == NULL ? "" : grp->ng_str[NG_HOST], - grp->ng_str[NG_USER] == NULL ? "" : ",", - grp->ng_str[NG_USER] == NULL ? "" : grp->ng_str[NG_USER], - grp->ng_str[NG_DOM] == NULL ? "" : ",", - grp->ng_str[NG_DOM] == NULL ? "" : grp->ng_str[NG_DOM], - lp->l_groupname); -#endif - } else { - spos = strsep(&pos, ", \t"); - if (parse_netgrp(spos)) - continue; - } - if (pos == NULL) - break; - while (*pos == ' ' || *pos == ',' || *pos == '\t') - pos++; - } - return (0); -} - -/* - * Read the netgroup file and save lines until the line for the netgroup - * is found. Return 1 if eof is encountered. - */ -static struct linelist * -read_for_group(group) - char *group; -{ - register char *pos, *spos, *linep, *olinep; - register int len, olen; - int cont; - struct linelist *lp; - char line[LINSIZ + 2]; -#ifdef YP - char *result; - int resultlen; - - while (_netgr_yp_enabled || fgets(line, LINSIZ, netf) != NULL) { - if (_netgr_yp_enabled) { - if(!_netgr_yp_domain) - if(yp_get_default_domain(&_netgr_yp_domain)) - continue; - if (yp_match(_netgr_yp_domain, "netgroup", group, - strlen(group), &result, &resultlen)) { - free(result); - if (_use_only_yp) - return ((struct linelist *)0); - else { - _netgr_yp_enabled = 0; - continue; - } - } - snprintf(line, LINSIZ, "%s %s", group, result); - free(result); - } -#else - while (fgets(line, LINSIZ, netf) != NULL) { -#endif - pos = (char *)&line; -#ifdef YP - if (*pos == '+') { - _netgr_yp_enabled = 1; - continue; - } -#endif - if (*pos == '#') - continue; - while (*pos == ' ' || *pos == '\t') - pos++; - spos = pos; - while (*pos != ' ' && *pos != '\t' && *pos != '\n' && - *pos != '\0') - pos++; - len = pos - spos; - while (*pos == ' ' || *pos == '\t') - pos++; - if (*pos != '\n' && *pos != '\0') { - lp = (struct linelist *)malloc(sizeof (*lp)); - lp->l_parsed = 0; - lp->l_groupname = (char *)malloc(len + 1); - bcopy(spos, lp->l_groupname, len); - *(lp->l_groupname + len) = '\0'; - len = strlen(pos); - olen = 0; - - /* - * Loop around handling line continuations. - */ - do { - if (*(pos + len - 1) == '\n') - len--; - if (*(pos + len - 1) == '\\') { - len--; - cont = 1; - } else - cont = 0; - if (len > 0) { - linep = (char *)malloc(olen + len + 1); - if (olen > 0) { - bcopy(olinep, linep, olen); - free(olinep); - } - bcopy(pos, linep + olen, len); - olen += len; - *(linep + olen) = '\0'; - olinep = linep; - } - if (cont) { - if (fgets(line, LINSIZ, netf)) { - pos = line; - len = strlen(pos); - } else - cont = 0; - } - } while (cont); - lp->l_line = linep; - lp->l_next = linehead; - linehead = lp; - - /* - * If this is the one we wanted, we are done. - */ - if (!strcmp(lp->l_groupname, group)) - return (lp); - } - } -#ifdef YP - /* - * Yucky. The recursive nature of this whole mess might require - * us to make more than one pass through the netgroup file. - * This might be best left outside the #ifdef YP, but YP is - * defined by default anyway, so I'll leave it like this - * until I know better. - */ - rewind(netf); -#endif - return ((struct linelist *)0); -} diff --git a/lib/libc/gen/getobjformat.3 b/lib/libc/gen/getobjformat.3 deleted file mode 100644 index 3862d82..0000000 --- a/lib/libc/gen/getobjformat.3 +++ /dev/null @@ -1,124 +0,0 @@ -.\" Copyright (c) 1998 John D. Polstra -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd September 7, 1998 -.Dt GETOBJFORMAT 3 -.Os FreeBSD -.Sh NAME -.Nm getobjformat -.Nd get preferred object file format -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn getobjformat "char *buf" "size_t bufsize" "int *argcp" "char **argv" -.Sh DESCRIPTION -.Fn getobjformat -queries several sources to determine the preferred object file -format, and copies its name into a buffer provided by the caller. -.Pp -The object file format is determined as follows. If -.Va argv -is -.No non- Ns Ev NULL -and an explicit command line argument such as -.Fl aout -or -.Fl elf -is present, then that determines the object file format. -.Pp -Otherwise, if the variable -.Ev OBJFORMAT -is set in the environment, the object file format is taken from its -value. -.Pp -Otherwise, if the file -.Pa /etc/objformat -is readable and contains a line of the form -.Ql OBJFORMAT=xxx , -the object file format is taken from there. -.Pp -Otherwise, a built-in system default object file format is returned. -.Pp -.Va buf -points to a user-supplied buffer into which the name of the object -file format is copied. -.Va bufsize -gives the size of the buffer in bytes. The string placed in -.Va buf -is always null-terminated. It is an error if the buffer is too -small to hold the null-terminated name. -.Pp -.Va argv -points to a -.Dv NULL Ns -terminated -argument vector to be scanned for object -format options. -.Va argv -may be -.Dv NULL , -in which case the argument vector is not scanned. -.Pp -If -.Va argcp -is non-NULL, any object format options are deleted from the -argument vector, and the updated argument count is stored into -the integer referenced by -.Va argcp . -If -.Va argcp -is -.Dv NULL , -the argument vector is left unchanged. -.Sh RETURN VALUES -On success, -.Fn getobjformat -returns the length of the object file format name, not counting the -null terminator. -If the supplied buffer is too small to hold the object file format -and its null terminator, -.Fn getobjformat -returns -1. In that case, the contents of the buffer and argument -vector supplied by the caller are indeterminate. -.Sh ENVIRONMENT -.Bl -tag -width OBJFORMAT -.It Ev OBJFORMAT -If the environment variable -.Ev OBJFORMAT -is set, it overrides the default object file format. -.Ev OBJFORMAT takes precedence over -.Pa /etc/objformat . -.Sh FILES -.Bl -tag -width /etc/objformat -compact -.It Pa /etc/objformat -If present, specifies the object file format to use. Syntax is -.Ql OBJFORMAT=xxx . -.Sh SEE ALSO -.Xr objformat 1 -.Sh HISTORY -The -.Fn getobjformat -function first appeared in -.Fx 3.0 . diff --git a/lib/libc/gen/getobjformat.c b/lib/libc/gen/getobjformat.c deleted file mode 100644 index 98e6ab0..0000000 --- a/lib/libc/gen/getobjformat.c +++ /dev/null @@ -1,119 +0,0 @@ -/*- - * Copyright (c) 1998 John D. Polstra - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include -#include -#include -#include -#include - -#define PATH_OBJFORMAT "/etc/objformat" - -static int copyformat(char *, const char *, size_t); - -static const char *known_formats[] = { OBJFORMAT_NAMES, NULL }; - -static int -copyformat(char *buf, const char *fmt, size_t bufsize) -{ - size_t len; - - len = strlen(fmt); - if (len > bufsize - 1) - return -1; - strcpy(buf, fmt); - return len; -} - -int -getobjformat(char *buf, size_t bufsize, int *argcp, char **argv) -{ - const char *fmt; - char **src, **dst; - const char *env; - FILE *fp; - - fmt = NULL; - - if (argv != NULL) { - /* - * Scan for arguments setting known formats, e.g., "-elf". - * If "argcp" is non-NULL, delete these arguments from the - * list and update the argument count in "*argcp". - */ - for (dst = src = argv; *src != NULL; src++) { - if ((*src)[0] == '-') { - const char **p; - - for (p = known_formats; *p != NULL; p++) - if (strcmp(*src + 1, *p) == 0) - break; - if (*p != NULL) { - fmt = *p; - if (argcp == NULL) /* Don't delete */ - *dst++ = *src; - } else - *dst++ = *src; - } else - *dst++ = *src; - } - *dst = NULL; - if (argcp != NULL) - *argcp -= src - dst; - if (fmt != NULL) - return copyformat(buf, fmt, bufsize); - } - - /* Check the OBJFORMAT environment variable. */ - if ((env = getenv("OBJFORMAT")) != NULL) - return copyformat(buf, env, bufsize); - - /* Take a look at "/etc/objformat". */ - if ((fp = fopen(PATH_OBJFORMAT, "r")) != NULL) { - char line[1024]; - int found; - int len; - - found = len = 0; - while (fgets(line, sizeof line, fp) != NULL) { - if (strncmp(line, "OBJFORMAT=", 10) == 0) { - char *p = &line[10]; - - p[strcspn(p, " \t\n")] = '\0'; - len = copyformat(buf, p, bufsize); - found = 1; - } - } - fclose(fp); - if (found) - return len; - } - - /* As a last resort, use the compiled in default. */ - return copyformat(buf, OBJFORMAT_DEFAULT, bufsize); -} diff --git a/lib/libc/gen/getosreldate.c b/lib/libc/gen/getosreldate.c deleted file mode 100644 index b6e91f4..0000000 --- a/lib/libc/gen/getosreldate.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/* From: -static char sccsid[] = "@(#)gethostid.c 8.1 (Berkeley) 6/2/93"; -*/ -static const char rcsid[] = - "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#if __STDC__ -int -getosreldate(void) -#else -int -getosreldate() -#endif -{ - int mib[2]; - size_t size; - int value; - - mib[0] = CTL_KERN; - mib[1] = KERN_OSRELDATE; - size = sizeof value; - if (sysctl(mib, 2, &value, &size, NULL, 0) == -1) - return (-1); - return (value); -} diff --git a/lib/libc/gen/getpagesize.3 b/lib/libc/gen/getpagesize.3 deleted file mode 100644 index 549cfe7..0000000 --- a/lib/libc/gen/getpagesize.3 +++ /dev/null @@ -1,61 +0,0 @@ -.\" Copyright (c) 1983, 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. -.\" -.\" @(#)getpagesize.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt GETPAGESIZE 3 -.Os BSD 4.2 -.Sh NAME -.Nm getpagesize -.Nd get system page size -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn getpagesize void -.Sh DESCRIPTION -.Fn Getpagesize -returns the number of bytes in a page. -Page granularity is the granularity of many of the memory -management calls. -.Pp -The page size is a system -page size and may not be the same as the underlying -hardware page size. -.Sh SEE ALSO -.Xr pagesize 1 , -.Xr sbrk 2 -.Sh HISTORY -The -.Fn getpagesze -function call appeared in -.Bx 4.2 . diff --git a/lib/libc/gen/getpagesize.c b/lib/libc/gen/getpagesize.c deleted file mode 100644 index 556ff9e..0000000 --- a/lib/libc/gen/getpagesize.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getpagesize.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* - * This is unlikely to change over the running time of any - * program, so we cache the result to save some syscalls. - */ - -int -getpagesize() -{ - int mib[2]; - static int value; - size_t size; - - if (!value) { - mib[0] = CTL_HW; - mib[1] = HW_PAGESIZE; - size = sizeof value; - if (sysctl(mib, 2, &value, &size, NULL, 0) == -1) - return (-1); - } - return (value); -} diff --git a/lib/libc/gen/getpass.3 b/lib/libc/gen/getpass.3 deleted file mode 100644 index 4fe2636..0000000 --- a/lib/libc/gen/getpass.3 +++ /dev/null @@ -1,95 +0,0 @@ -.\" Copyright (c) 1989, 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. -.\" -.\" @(#)getpass.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt GETPASS 3 -.Os -.Sh NAME -.Nm getpass -.Nd get a password -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Ft char * -.Fn getpass "const char *prompt" -.Sh DESCRIPTION -The -.Fn getpass -function displays a prompt to, and reads in a password from, -.Pa /dev/tty . -If this file is not accessible, -.Fn getpass -displays the prompt on the standard error output and reads from the standard -input. -.Pp -The password may be up to _PASSWORD_LEN (currently 128) -characters in length. -Any additional -characters and the terminating newline character are discarded. -.Pp -The -.Fn getpass -function turns off character echoing while reading the password. -.Pp -.Sh RETURN VALUES -The -.Fn getpass -function returns a pointer to the null terminated password. -.Sh FILES -.Bl -tag -width /dev/tty -compact -.It Pa /dev/tty -.El -.Sh SEE ALSO -.Xr crypt 3 -.Sh HISTORY -A -.Fn getpass -function appeared in -.At v7 . -.Sh BUGS -The -.Fn getpass -function leaves its result in an internal static object and returns -a pointer to that object. -Subsequent calls to -.Fn getpass -will modify the same object. -.Pp -The calling process should zero the password as soon as possible to -avoid leaving the cleartext password visible in the process's address -space. -.Pp -Upon receipt of a SIGTSTP, the input buffer will be flushed, so any -partially typed password must be retyped when the process -continues. diff --git a/lib/libc/gen/getpass.c b/lib/libc/gen/getpass.c deleted file mode 100644 index 60e92b7..0000000 --- a/lib/libc/gen/getpass.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 1988, 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getpass.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#include -#include -#include -#include - -static struct termios oterm, term; -static FILE *fp; - -char * -getpass(prompt) - const char *prompt; -{ - register int ch; - register char *p; - FILE *outfp; - static char buf[_PASSWORD_LEN + 1]; - sigset_t oset, nset; - - /* - * read and write to /dev/tty if possible; else read from - * stdin and write to stderr. - */ - if ((outfp = fp = fopen(_PATH_TTY, "w+")) == NULL) { - outfp = stderr; - fp = stdin; - } - - /* - * note - blocking signals isn't necessarily the - * right thing, but we leave it for now. - */ - sigemptyset(&nset); - sigaddset(&nset, SIGINT); - sigaddset(&nset, SIGTSTP); - (void)sigprocmask(SIG_BLOCK, &nset, &oset); - - (void)tcgetattr(fileno(fp), &oterm); - term = oterm; - term.c_lflag &= ~ECHO; - (void)tcsetattr(fileno(fp), TCSAFLUSH|TCSASOFT, &term); - (void)fputs(prompt, outfp); - rewind(outfp); /* implied flush */ - for (p = buf; (ch = getc(fp)) != EOF && ch != '\n';) - if (p < buf + _PASSWORD_LEN) - *p++ = ch; - *p = '\0'; - (void)_write(fileno(outfp), "\n", 1); - (void)tcsetattr(fileno(fp), TCSAFLUSH|TCSASOFT, &oterm); - - (void)sigprocmask(SIG_SETMASK, &oset, NULL); - - if (fp != stdin) - (void)fclose(fp); - return(buf); -} diff --git a/lib/libc/gen/getpwent.3 b/lib/libc/gen/getpwent.3 deleted file mode 100644 index d925055..0000000 --- a/lib/libc/gen/getpwent.3 +++ /dev/null @@ -1,220 +0,0 @@ -.\" Copyright (c) 1988, 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. -.\" -.\" From: @(#)getpwent.3 8.2 (Berkeley) 12/11/93 -.\" $FreeBSD$ -.\" -.Dd September 20, 1994 -.Dt GETPWENT 3 -.Os -.Sh NAME -.Nm getpwent , -.Nm getpwnam , -.Nm getpwuid , -.Nm setpassent , -.Nm setpwent , -.Nm endpwent -.Nd password database operations -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Ft struct passwd * -.Fn getpwent void -.Ft struct passwd * -.Fn getpwnam "const char *login" -.Ft struct passwd * -.Fn getpwuid "uid_t uid" -.Ft int -.Fn setpassent "int stayopen" -.Ft void -.Fn setpwent void -.Ft void -.Fn endpwent void -.Sh DESCRIPTION -These functions -operate on the password database file -which is described -in -.Xr passwd 5 . -Each entry in the database is defined by the structure -.Ar passwd -found in the include -file -.Aq Pa pwd.h : -.Bd -literal -offset indent -struct passwd { - char *pw_name; /* user name */ - char *pw_passwd; /* encrypted password */ - uid_t pw_uid; /* user uid */ - gid_t 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 */ - int pw_fields; /* internal: fields filled in */ -}; -.Ed -.Pp -The functions -.Fn getpwnam -and -.Fn getpwuid -search the password database for the given login name or user uid, -respectively, always returning the first one encountered. -.Pp -The -.Fn getpwent -function -sequentially reads the password database and is intended for programs -that wish to process the complete list of users. -.Pp -The -.Fn setpassent -function -accomplishes two purposes. -First, it causes -.Fn getpwent -to ``rewind'' to the beginning of the database. -Additionally, if -.Fa stayopen -is non-zero, file descriptors are left open, significantly speeding -up subsequent accesses for all of the routines. -(This latter functionality is unnecessary for -.Fn getpwent -as it doesn't close its file descriptors by default.) -.Pp -It is dangerous for long-running programs to keep the file descriptors -open as the database will become out of date if it is updated while the -program is running. -.Pp -The -.Fn setpwent -function -is identical to -.Fn setpassent -with an argument of zero. -.Pp -The -.Fn endpwent -function -closes any open files. -.Pp -These routines have been written to ``shadow'' the password file, e.g. -allow only certain programs to have access to the encrypted password. -If the process which calls them has an effective uid of 0, the encrypted -password will be returned, otherwise, the password field of the returned -structure will point to the string -.Ql * . -.Sh YP/NIS INTERACTION -When the -.Xr yp 4 -password database is enabled, the -.Fn getpwnam -and -.Fn getpwuid -functions use the YP maps -.Dq Li passwd.byname -and -.Dq Li passwd.byuid , -respectively, if the requested password entry is not found in the -local database. The -.Fn getpwent -function will step through the YP map -.Dq Li passwd.byname -if the entire map is enabled as described in -.Xr passwd 5 . -.Sh RETURN VALUES -The functions -.Fn getpwent , -.Fn getpwnam , -and -.Fn getpwuid , -return a valid pointer to a passwd structure on success -and a null pointer if end-of-file is reached or an error occurs. -The -.Fn setpassent -function returns 0 on failure and 1 on success. -The -.Fn endpwent -and -.Fn setpwent -functions -have no return value. -.Sh FILES -.Bl -tag -width /etc/master.passwd -compact -.It Pa /etc/pwd.db -The insecure password database file -.It Pa /etc/spwd.db -The secure password database file -.It Pa /etc/master.passwd -The current password file -.It Pa /etc/passwd -A Version 7 format password file -.El -.Sh SEE ALSO -.Xr getlogin 2 , -.Xr getgrent 3 , -.Xr yp 4 , -.Xr passwd 5 , -.Xr pwd_mkdb 8 , -.Xr vipw 8 -.Sh HISTORY -The -.Fn getpwent , -.Fn getpwnam , -.Fn getpwuid , -.Fn setpwent, -and -.Fn endpwent -functions appeared in -.At v7 . -The -.Fn setpassent -function appeared in -.Bx 4.3 Reno . -.Sh COMPATIBILITY -The historic function -.Xr setpwfile 3 , -which allowed the specification of alternate password databases, -has been deprecated and is no longer available. -.Sh BUGS -The functions -.Fn getpwent , -.Fn getpwnam , -and -.Fn getpwuid , -leave their results in an internal static object and return -a pointer to that object. -Subsequent calls to -the same function -will modify the same object. diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c deleted file mode 100644 index 90dbb4a..0000000 --- a/lib/libc/gen/getpwent.c +++ /dev/null @@ -1,860 +0,0 @@ -/* - * Copyright (c) 1988, 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getpwent.c 8.2 (Berkeley) 4/27/95"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -extern void setnetgrent __P(( char * )); -extern int getnetgrent __P(( char **, char **, char ** )); -extern int innetgr __P(( const char *, const char *, const char *, const char * )); - -/* - * The lookup techniques and data extraction code here must be kept - * in sync with that in `pwd_mkdb'. - */ - -static struct passwd _pw_passwd; /* password structure */ -static DB *_pw_db; /* password database */ -static int _pw_keynum; /* key counter */ -static int _pw_stayopen; /* keep fd's open */ -#ifdef YP -#include -#include -#include - -static struct passwd _pw_copy; -static DBT empty = { NULL, 0 }; -static DB *_ypcache = (DB *)NULL; -static int _yp_exclusions = 0; -static int _yp_enabled = -1; -static int _pw_stepping_yp; /* set true when stepping thru map */ -static char _ypnam[YPMAXRECORD]; -#define YP_HAVE_MASTER 2 -#define YP_HAVE_ADJUNCT 1 -#define YP_HAVE_NONE 0 -static int _gotmaster; -static char *_pw_yp_domain; -static inline int unwind __P(( char * )); -static void _ypinitdb __P(( void )); -static int _havemaster __P((char *)); -static int _getyppass __P((struct passwd *, const char *, const char * )); -static int _nextyppass __P((struct passwd *)); -static inline int lookup __P((const char *)); -static inline void store __P((const char *)); -static inline int ingr __P((const char *, const char*)); -static inline int verf __P((const char *)); -static char * _get_adjunct_pw __P((const char *)); -#endif -static int __hashpw(DBT *); -static int __initdb(void); - -struct passwd * -getpwent() -{ - DBT key; - char bf[sizeof(_pw_keynum) + 1]; - int rv; - - if (!_pw_db && !__initdb()) - return((struct passwd *)NULL); - -#ifdef YP - if(_pw_stepping_yp) { - _pw_passwd = _pw_copy; - if (unwind((char *)&_ypnam)) - return(&_pw_passwd); - } -#endif -tryagain: - - ++_pw_keynum; - bf[0] = _PW_KEYBYNUM; - bcopy((char *)&_pw_keynum, bf + 1, sizeof(_pw_keynum)); - key.data = (u_char *)bf; - key.size = sizeof(_pw_keynum) + 1; - rv = __hashpw(&key); - if(!rv) return (struct passwd *)NULL; -#ifdef YP - if(_pw_passwd.pw_name[0] == '+' || _pw_passwd.pw_name[0] == '-') { - if (_yp_enabled == -1) - _ypinitdb(); - bzero((char *)&_ypnam, sizeof(_ypnam)); - bcopy(_pw_passwd.pw_name, _ypnam, - strlen(_pw_passwd.pw_name)); - _pw_copy = _pw_passwd; - if (unwind((char *)&_ypnam) == 0) - goto tryagain; - else - return(&_pw_passwd); - } -#else - /* Ignore YP password file entries when YP is disabled. */ - if(_pw_passwd.pw_name[0] == '+' || _pw_passwd.pw_name[0] == '-') { - goto tryagain; - } -#endif - return(&_pw_passwd); -} - -struct passwd * -getpwnam(name) - const char *name; -{ - DBT key; - int len, rval; - char bf[UT_NAMESIZE + 2]; - - if (!_pw_db && !__initdb()) - return((struct passwd *)NULL); - - bf[0] = _PW_KEYBYNAME; - len = strlen(name); - if (len > UT_NAMESIZE) - return(NULL); - bcopy(name, bf + 1, len); - key.data = (u_char *)bf; - key.size = len + 1; - rval = __hashpw(&key); - -#ifdef YP - if (!rval) { - if (_yp_enabled == -1) - _ypinitdb(); - if (_yp_enabled) - rval = _getyppass(&_pw_passwd, name, "passwd.byname"); - } -#endif - /* - * Prevent login attempts when YP is not enabled but YP entries - * are in /etc/master.passwd. - */ - if (rval && (_pw_passwd.pw_name[0] == '+'|| - _pw_passwd.pw_name[0] == '-')) rval = 0; - - if (!_pw_stayopen) - endpwent(); - return(rval ? &_pw_passwd : (struct passwd *)NULL); -} - -struct passwd * -getpwuid(uid) - uid_t uid; -{ - DBT key; - int keyuid, rval; - char bf[sizeof(keyuid) + 1]; - - if (!_pw_db && !__initdb()) - return((struct passwd *)NULL); - - bf[0] = _PW_KEYBYUID; - keyuid = uid; - bcopy(&keyuid, bf + 1, sizeof(keyuid)); - key.data = (u_char *)bf; - key.size = sizeof(keyuid) + 1; - rval = __hashpw(&key); - -#ifdef YP - if (!rval) { - if (_yp_enabled == -1) - _ypinitdb(); - if (_yp_enabled) { - char ypbuf[16]; /* big enough for 32-bit uids */ - snprintf(ypbuf, sizeof ypbuf, "%u", (unsigned)uid); - rval = _getyppass(&_pw_passwd, ypbuf, "passwd.byuid"); - } - } -#endif - /* - * Prevent login attempts when YP is not enabled but YP entries - * are in /etc/master.passwd. - */ - if (rval && (_pw_passwd.pw_name[0] == '+'|| - _pw_passwd.pw_name[0] == '-')) rval = 0; - - if (!_pw_stayopen) - endpwent(); - return(rval ? &_pw_passwd : (struct passwd *)NULL); -} - -int -setpassent(stayopen) - int stayopen; -{ - _pw_keynum = 0; -#ifdef YP - _pw_stepping_yp = 0; - if (stayopen) - setgroupent(1); -#endif - _pw_stayopen = stayopen; - return(1); -} - -void -setpwent() -{ - (void)setpassent(0); -} - -void -endpwent() -{ - _pw_keynum = 0; -#ifdef YP - _pw_stepping_yp = 0; -#endif - if (_pw_db) { - (void)(_pw_db->close)(_pw_db); - _pw_db = (DB *)NULL; - } -#ifdef YP - if (_ypcache) { - (void)(_ypcache->close)(_ypcache); - _ypcache = (DB *)NULL; - _yp_exclusions = 0; - } - /* Fix for PR #12008 */ - _yp_enabled = -1; -#endif -} - -static int -__initdb() -{ - static int warned; - char *p; - - p = (geteuid()) ? _PATH_MP_DB : _PATH_SMP_DB; - _pw_db = dbopen(p, O_RDONLY, 0, DB_HASH, NULL); - if (_pw_db) - return(1); - if (!warned++) - syslog(LOG_ERR, "%s: %m", p); - return(0); -} - -static int -__hashpw(key) - DBT *key; -{ - register char *p, *t; - static u_int max; - static char *line; - DBT data; - - if ((_pw_db->get)(_pw_db, key, &data, 0)) - return(0); - p = (char *)data.data; - - /* Increase buffer size for long lines if necessary. */ - if (data.size > max) { - max = data.size + 1024; - if (!(line = reallocf(line, max))) - return(0); - } - - /* THIS CODE MUST MATCH THAT IN pwd_mkdb. */ - t = line; -#define EXPAND(e) e = t; while ( (*t++ = *p++) ); -#define SCALAR(v) memmove(&(v), p, sizeof v); p += sizeof v - EXPAND(_pw_passwd.pw_name); - EXPAND(_pw_passwd.pw_passwd); - SCALAR(_pw_passwd.pw_uid); - SCALAR(_pw_passwd.pw_gid); - SCALAR(_pw_passwd.pw_change); - EXPAND(_pw_passwd.pw_class); - EXPAND(_pw_passwd.pw_gecos); - EXPAND(_pw_passwd.pw_dir); - EXPAND(_pw_passwd.pw_shell); - SCALAR(_pw_passwd.pw_expire); - bcopy(p, (char *)&_pw_passwd.pw_fields, sizeof _pw_passwd.pw_fields); - p += sizeof _pw_passwd.pw_fields; - return(1); -} - -#ifdef YP - -static void -_ypinitdb() -{ - DBT key, data; - char buf[] = { _PW_KEYYPENABLED }; - key.data = buf; - key.size = 1; - _yp_enabled = 0; - if ((_pw_db->get)(_pw_db, &key, &data, 0) == 0) { - _yp_enabled = (int)*((char *)data.data) - 2; - /* Don't even bother with this if we aren't root. */ - if (!geteuid()) { - if (!_pw_yp_domain) - if (yp_get_default_domain(&_pw_yp_domain)) - return; - _gotmaster = _havemaster(_pw_yp_domain); - } else _gotmaster = YP_HAVE_NONE; - /* - * Create a DB hash database in memory. Bet you didn't know you - * could do a dbopen() with a NULL filename, did you. - */ - if (_ypcache == (DB *)NULL) - _ypcache = dbopen(NULL, O_RDWR, 600, DB_HASH, NULL); - } -} - -/* - * See if a user is in the blackballed list. - */ -static inline int -lookup(name) - const char *name; -{ - DBT key; - - if (!_yp_exclusions) - return(0); - - key.data = (char *)name; - key.size = strlen(name); - - if ((_ypcache->get)(_ypcache, &key, &empty, 0)) { - return(0); - } - - return(1); -} - -/* - * Store a blackballed user in an in-core hash database. - */ -static inline void -store(key) - const char *key; -{ - DBT lkey; -/* - if (lookup(key)) - return; -*/ - - _yp_exclusions = 1; - - lkey.data = (char *)key; - lkey.size = strlen(key); - - (void)(_ypcache->put)(_ypcache, &lkey, &empty, R_NOOVERWRITE); -} - -/* - * Parse the + entries in the password database and do appropriate - * NIS lookups. While ugly to look at, this is optimized to do only - * as many lookups as are absolutely necessary in any given case. - * Basically, the getpwent() function will feed us + and - lines - * as they appear in the database. For + lines, we do netgroup/group - * and user lookups to find all usernames that match the rule and - * extract them from the NIS passwd maps. For - lines, we save the - * matching names in a database and a) exlude them, and b) make sure - * we don't consider them when processing other + lines that appear - * later. - */ -static inline int -unwind(grp) - char *grp; -{ - char *user, *host, *domain; - static int latch = 0; - static struct group *gr = NULL; - int rv = 0; - - if (grp[0] == '+') { - if (strlen(grp) == 1) { - return(_nextyppass(&_pw_passwd)); - } - if (grp[1] == '@') { - _pw_stepping_yp = 1; -grpagain: - if (gr != NULL) { - if (*gr->gr_mem != NULL) { - if (lookup(*gr->gr_mem)) { - gr->gr_mem++; - goto grpagain; - } - rv = _getyppass(&_pw_passwd, - *gr->gr_mem, - "passwd.byname"); - gr->gr_mem++; - return(rv); - } else { - latch = 0; - _pw_stepping_yp = 0; - gr = NULL; - return(0); - } - } - if (!latch) { - setnetgrent(grp+2); - latch++; - } -again: - if (getnetgrent(&host, &user, &domain) == 0) { - if ((gr = getgrnam(grp+2)) != NULL) - goto grpagain; - latch = 0; - _pw_stepping_yp = 0; - return(0); - } else { - if (lookup(user)) - goto again; - if (_getyppass(&_pw_passwd, user, - "passwd.byname")) - return(1); - else - goto again; - } - } else { - if (lookup(grp+1)) - return(0); - return(_getyppass(&_pw_passwd, grp+1, "passwd.byname")); - } - } else { - if (grp[1] == '@') { - setnetgrent(grp+2); - rv = 0; - while(getnetgrent(&host, &user, &domain) != 0) { - store(user); - rv++; - } - if (!rv && (gr = getgrnam(grp+2)) != NULL) { - while(*gr->gr_mem) { - store(*gr->gr_mem); - gr->gr_mem++; - } - } - } else { - store(grp+1); - } - } - return(0); -} - -/* - * See if a user is a member of a particular group. - */ -static inline int -ingr(grp, name) - const char *grp; - const char *name; -{ - register struct group *gr; - - if ((gr = getgrnam(grp)) == NULL) - return(0); - - while(*gr->gr_mem) { - if (!strcmp(*gr->gr_mem, name)) - return(1); - gr->gr_mem++; - } - - return(0); -} - -/* - * Check a user against the +@netgroup/-@netgroup lines listed in - * the local password database. Also checks +user/-user lines. - * If no netgroup exists that matches +@netgroup/-@netgroup, - * try searching regular groups with the same name. - */ -static inline int -verf(name) - const char *name; -{ - DBT key; - char bf[sizeof(_pw_keynum) + 1]; - int keynum = 0; - -again: - ++keynum; - bf[0] = _PW_KEYYPBYNUM; - bcopy((char *)&keynum, bf + 1, sizeof(keynum)); - key.data = (u_char *)bf; - key.size = sizeof(keynum) + 1; - if (!__hashpw(&key)) { - /* Try again using old format */ - bf[0] = _PW_KEYBYNUM; - bcopy((char *)&keynum, bf + 1, sizeof(keynum)); - key.data = (u_char *)bf; - if (!__hashpw(&key)) - return(0); - } - if (_pw_passwd.pw_name[0] != '+' && (_pw_passwd.pw_name[0] != '-')) - goto again; - if (_pw_passwd.pw_name[0] == '+') { - if (strlen(_pw_passwd.pw_name) == 1) /* Wildcard */ - return(1); - if (_pw_passwd.pw_name[1] == '@') { - if ((innetgr(_pw_passwd.pw_name+2, NULL, name, - _pw_yp_domain) || - ingr(_pw_passwd.pw_name+2, name)) && !lookup(name)) - return(1); - else - goto again; - } else { - if (!strcmp(name, _pw_passwd.pw_name+1) && - !lookup(name)) - return(1); - else - goto again; - } - } - if (_pw_passwd.pw_name[0] == '-') { - /* Note that a minus wildcard is a no-op. */ - if (_pw_passwd.pw_name[1] == '@') { - if (innetgr(_pw_passwd.pw_name+2, NULL, name, - _pw_yp_domain) || - ingr(_pw_passwd.pw_name+2, name)) { - store(name); - return(0); - } else - goto again; - } else { - if (!strcmp(name, _pw_passwd.pw_name+1)) { - store(name); - return(0); - } else - goto again; - } - - } - return(0); -} - -static char * -_get_adjunct_pw(name) - const char *name; -{ - static char adjunctbuf[YPMAXRECORD+2]; - int rval; - char *result; - int resultlen; - char *map = "passwd.adjunct.byname"; - char *s; - - if ((rval = yp_match(_pw_yp_domain, map, name, strlen(name), - &result, &resultlen))) - return(NULL); - - strncpy(adjunctbuf, result, resultlen); - adjunctbuf[resultlen] = '\0'; - free(result); - result = (char *)&adjunctbuf; - - /* Don't care about the name. */ - if ((s = strsep(&result, ":")) == NULL) - return (NULL); /* name */ - if ((s = strsep(&result, ":")) == NULL) - return (NULL); /* password */ - - return(s); -} - -static int -_pw_breakout_yp(struct passwd *pw, char *res, int resultlen, int master) -{ - char *s, *result; - static char resbuf[YPMAXRECORD+2]; - - /* - * Be triple, ultra super-duper paranoid: reject entries - * that start with a + or -. yp_mkdb and /var/yp/Makefile - * are _both_ supposed to strip these out, but you never - * know. - */ - if (*res == '+' || *res == '-') - return 0; - - /* - * The NIS protocol definition limits the size of an NIS - * record to YPMAXRECORD bytes. We need to do a copy to - * a static buffer here since the memory pointed to by - * res will be free()ed when this function returns. - */ - strncpy((char *)&resbuf, res, resultlen); - resbuf[resultlen] = '\0'; - result = (char *)&resbuf; - - /* - * XXX Sanity check: make sure all fields are valid (no NULLs). - * If we find a badly formatted entry, we punt. - */ - if ((s = strsep(&result, ":")) == NULL) return 0; /* name */ - /* - * We don't care what pw_fields says: we _always_ want the - * username returned to us by NIS. - */ - pw->pw_name = s; - pw->pw_fields |= _PWF_NAME; - - if ((s = strsep(&result, ":")) == NULL) return 0; /* password */ - if(!(pw->pw_fields & _PWF_PASSWD)) { - /* SunOS passwd.adjunct hack */ - if (master == YP_HAVE_ADJUNCT && strstr(s, "##") != NULL) { - char *realpw; - realpw = _get_adjunct_pw(pw->pw_name); - if (realpw == NULL) - pw->pw_passwd = s; - else - pw->pw_passwd = realpw; - } else { - pw->pw_passwd = s; - } - pw->pw_fields |= _PWF_PASSWD; - } - - if ((s = strsep(&result, ":")) == NULL) return 0; /* uid */ - if(!(pw->pw_fields & _PWF_UID)) { - pw->pw_uid = atoi(s); - pw->pw_fields |= _PWF_UID; - } - - if ((s = strsep(&result, ":")) == NULL) return 0; /* gid */ - if(!(pw->pw_fields & _PWF_GID)) { - pw->pw_gid = atoi(s); - pw->pw_fields |= _PWF_GID; - } - - if (master == YP_HAVE_MASTER) { - if ((s = strsep(&result, ":")) == NULL) return 0; /* class */ - if(!(pw->pw_fields & _PWF_CLASS)) { - pw->pw_class = s; - pw->pw_fields |= _PWF_CLASS; - } - - if ((s = strsep(&result, ":")) == NULL) return 0; /* change */ - if(!(pw->pw_fields & _PWF_CHANGE)) { - pw->pw_change = atol(s); - pw->pw_fields |= _PWF_CHANGE; - } - - if ((s = strsep(&result, ":")) == NULL) return 0; /* expire */ - if(!(pw->pw_fields & _PWF_EXPIRE)) { - pw->pw_expire = atol(s); - pw->pw_fields |= _PWF_EXPIRE; - } - } - - if ((s = strsep(&result, ":")) == NULL) return 0; /* gecos */ - if(!(pw->pw_fields & _PWF_GECOS)) { - pw->pw_gecos = s; - pw->pw_fields |= _PWF_GECOS; - } - - if ((s = strsep(&result, ":")) == NULL) return 0; /* dir */ - if(!(pw->pw_fields & _PWF_DIR)) { - pw->pw_dir = s; - pw->pw_fields |= _PWF_DIR; - } - - if ((s = strsep(&result, ":")) == NULL) return 0; /* shell */ - if(!(pw->pw_fields & _PWF_SHELL)) { - pw->pw_shell = s; - pw->pw_fields |= _PWF_SHELL; - } - - /* Be consistent. */ - if ((s = strchr(pw->pw_shell, '\n'))) *s = '\0'; - - return 1; -} - -static int -_havemaster(char *_yp_domain) -{ - int order; - int rval; - - if (!(rval = yp_order(_yp_domain, "master.passwd.byname", &order))) - return(YP_HAVE_MASTER); - - /* - * NIS+ in YP compat mode doesn't support - * YPPROC_ORDER -- no point in continuing. - */ - if (rval == YPERR_YPERR) - return(YP_HAVE_NONE); - - /* master.passwd doesn't exist -- try passwd.adjunct */ - if (rval == YPERR_MAP) { - rval = yp_order(_yp_domain, "passwd.adjunct.byname", &order); - if (!rval) - return(YP_HAVE_ADJUNCT); - } - - return (YP_HAVE_NONE); -} - -static int -_getyppass(struct passwd *pw, const char *name, const char *map) -{ - char *result, *s; - int resultlen; - int rv; - char mastermap[YPMAXRECORD]; - - if(!_pw_yp_domain) { - if(yp_get_default_domain(&_pw_yp_domain)) - return 0; - } - - if (_gotmaster == YP_HAVE_MASTER) - sprintf(mastermap,"master.%s", map); - else - sprintf(mastermap,"%s",map); - - if(yp_match(_pw_yp_domain, (char *)&mastermap, name, strlen(name), - &result, &resultlen)) { - if (_gotmaster != YP_HAVE_MASTER) - return 0; - sprintf(mastermap,"%s",map); - if (yp_match(_pw_yp_domain, (char *)&mastermap, - name, strlen(name), &result, &resultlen)) - return 0; - _gotmaster = YP_HAVE_NONE; - } - - if (!_pw_stepping_yp) { - s = strchr(result, ':'); - if (s) { - *s = '\0'; - } else { - /* Must be a malformed entry if no colons. */ - free(result); - return(0); - } - - if (!verf(result)) { - *s = ':'; - free(result); - return(0); - } - - *s = ':'; /* Put back the colon we previously replaced with a NUL. */ - } - - rv = _pw_breakout_yp(pw, result, resultlen, _gotmaster); - free(result); - return(rv); -} - -static int -_nextyppass(struct passwd *pw) -{ - static char *key; - static int keylen; - char *lastkey, *result, *s; - int resultlen; - int rv; - char *map = "passwd.byname"; - - if(!_pw_yp_domain) { - if(yp_get_default_domain(&_pw_yp_domain)) - return 0; - } - - if (_gotmaster == YP_HAVE_MASTER) - map = "master.passwd.byname"; - - if(!_pw_stepping_yp) { - if(key) free(key); - rv = yp_first(_pw_yp_domain, map, - &key, &keylen, &result, &resultlen); - if(rv) { - return 0; - } - _pw_stepping_yp = 1; - goto unpack; - } else { -tryagain: - lastkey = key; - rv = yp_next(_pw_yp_domain, map, key, keylen, - &key, &keylen, &result, &resultlen); - free(lastkey); -unpack: - if(rv) { - _pw_stepping_yp = 0; - return 0; - } - - s = strchr(result, ':'); - if (s) { - *s = '\0'; - } else { - /* Must be a malformed entry if no colons. */ - free(result); - goto tryagain; - } - - if (lookup(result)) { - *s = ':'; - free(result); - goto tryagain; - } - - *s = ':'; /* Put back the colon we previously replaced with a NUL. */ - if (_pw_breakout_yp(pw, result, resultlen, _gotmaster)) { - free(result); - return(1); - } else { - free(result); - goto tryagain; - } - } -} - -#endif /* YP */ diff --git a/lib/libc/gen/getttyent.3 b/lib/libc/gen/getttyent.3 deleted file mode 100644 index ab3ff1d..0000000 --- a/lib/libc/gen/getttyent.3 +++ /dev/null @@ -1,210 +0,0 @@ -.\" Copyright (c) 1989, 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. -.\" -.\" @(#)getttyent.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd November 17, 1996 -.Dt GETTTYENT 3 -.Os BSD 4.3 -.Sh NAME -.Nm getttyent , -.Nm getttynam , -.Nm setttyent , -.Nm endttyent -.Nd get ttys file entry -.Nm isdialuptty , -.Nm isnettty -.Nd determine tty type from ttys file entry -.Sh SYNOPSIS -.Fd #include -.Ft struct ttyent * -.Fn getttyent void -.Ft struct ttyent * -.Fn getttynam "const char *name" -.Ft int -.Fn setttyent void -.Ft int -.Fn endttyent void -.Ft int -.Fn isdialuptty "const char *name" -.Ft int -.Fn isnettty "const char *name" -.Sh DESCRIPTION -The -.Fn getttyent , -and -.Fn getttynam -functions -each return a pointer to an object, with the following structure, -containing the broken-out fields of a line from the tty description -file. -.Bd -literal -struct ttyent { - char *ty_name; /* terminal device name */ - char *ty_getty; /* command to execute, usually getty */ - char *ty_type; /* terminal type for termcap */ -#define TTY_ON 0x01 /* enable logins (start ty_getty program) */ -#define TTY_SECURE 0x02 /* allow uid of 0 to login */ -#define TTY_DIALUP 0x04 /* is a dialup tty */ -#define TTY_NETWORK 0x08 /* is a network tty */ - int ty_status; /* status flags */ - char *ty_window; /* command to start up window manager */ - char *ty_comment; /* comment field */ - char *ty_group; /* tty group name */ -}; -.Ed -.Pp -The fields are as follows: -.Bl -tag -width ty_comment -.It Fa ty_name -The name of the character-special file. -.It Fa ty_getty -The name of the command invoked by -.Xr init 8 -to initialize tty line characteristics. -.It Fa ty_type -The name of the default terminal type connected to this tty line. -.It Fa ty_status -A mask of bit fields which indicate various actions allowed on this -tty line. -The possible flags are as follows: -.Bl -tag -width TTY_NETWORK -.It Dv TTY_ON -Enables logins (i.e., -.Xr init 8 -will start the command referenced by -.Fa ty_getty -on this entry). -.It Dv TTY_SECURE -Allow users with a uid of 0 to login on this terminal. -.It Dv TTY_DIALUP -Identifies a tty as a dialin line. -If this flag is set, then -.Fn isdialuptty -will return a non-zero value. -.It Dv TTY_NETWORK -Identifies a tty used for network connections. -If this flag is set, then -.Fn isnettty -will return a non-zero value. -.El -.It Fa ty_window -The command to execute for a window system associated with the line. -.It Fa ty_group -A group name to which the tty belongs. -If no group is specified in the ttys description file, -then the tty is placed in an anonymous group called "none". -.It Fa ty_comment -Any trailing comment field, with any leading hash marks (``#'') or -whitespace removed. -.El -.Pp -If any of the fields pointing to character strings are unspecified, -they are returned as null pointers. -The field -.Fa ty_status -will be zero if no flag values are specified. -.Pp -See -.Xr ttys 5 -for a more complete discussion of the meaning and usage of the -fields. -.Pp -The -.Fn getttyent -function -reads the next line from the ttys file, opening the file if necessary. -The -.Fn setttyent -function -rewinds the file if open, or opens the file if it is unopened. -The -.Fn endttyent -function -closes any open files. -.Pp -The -.Fn getttynam -function -searches from the beginning of the file until a matching -.Fa name -is found -(or until -.Dv EOF -is encountered). -.Sh RETURN VALUES -The routines -.Fn getttyent -and -.Fn getttynam -return a null pointer on -.Dv EOF -or error. -The -.Fn setttyent -function -and -.Fn endttyent -return 0 on failure and 1 on success. -.Pp -The routines -.Fn isdialuptty -and -.Fn isnettty -return non-zero if the dialup or network flag is set for the -tty entry relating to the tty named by the parameter, and -zero otherwise. -.Sh FILES -.Bl -tag -width /etc/ttys -compact -.It Pa /etc/ttys -.El -.Sh SEE ALSO -.Xr login 1 , -.Xr ttyslot 3 , -.Xr gettytab 5 , -.Xr termcap 5 , -.Xr ttys 5 , -.Xr getty 8 , -.Xr init 8 -.Sh HISTORY -The -.Fn getttyent , -.Fn getttynam , -.Fn setttyent , -and -.Fn endttyent -functions appeared in -.Bx 4.3 . -.Sh BUGS -These functions use static data storage; -if the data is needed for future use, it should be -copied before any subsequent calls overwrite it. diff --git a/lib/libc/gen/getttyent.c b/lib/libc/gen/getttyent.c deleted file mode 100644 index bfbe833..0000000 --- a/lib/libc/gen/getttyent.c +++ /dev/null @@ -1,266 +0,0 @@ -/* - * 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getttyent.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include - -static char zapchar; -static FILE *tf; -static size_t lbsize; -static char *line; - -#define MALLOCCHUNK 100 - -static char *skip __P((char *)); -static char *value __P((char *)); - -struct ttyent * -getttynam(tty) - const char *tty; -{ - register struct ttyent *t; - - if (strncmp(tty, "/dev/", 5) == 0) - tty += 5; - setttyent(); - while ( (t = getttyent()) ) - if (!strcmp(tty, t->ty_name)) - break; - endttyent(); - return (t); -} - -struct ttyent * -getttyent() -{ - static struct ttyent tty; - register char *p; - register int c; - size_t i; - - if (!tf && !setttyent()) - return (NULL); - for (;;) { - if (!fgets(p = line, lbsize, tf)) - return (NULL); - /* extend buffer if line was too big, and retry */ - while (!index(p, '\n')) { - i = strlen(p); - lbsize += MALLOCCHUNK; - if ((p = realloc(line, lbsize)) == NULL) { - (void)endttyent(); - return (NULL); - } - line = p; - if (!fgets(&line[i], lbsize - i, tf)) - return (NULL); - } - while (isspace((unsigned char)*p)) - ++p; - if (*p && *p != '#') - break; - } - -#define scmp(e) !strncmp(p, e, sizeof(e) - 1) && isspace((unsigned char)p[sizeof(e) - 1]) -#define vcmp(e) !strncmp(p, e, sizeof(e) - 1) && p[sizeof(e) - 1] == '=' - - zapchar = 0; - tty.ty_name = p; - p = skip(p); - if (!*(tty.ty_getty = p)) - tty.ty_getty = tty.ty_type = NULL; - else { - p = skip(p); - if (!*(tty.ty_type = p)) - tty.ty_type = NULL; - else { - /* compatibility kludge: handle network/dialup specially */ - if (scmp(_TTYS_DIALUP)) - tty.ty_status |= TTY_DIALUP; - else if (scmp(_TTYS_NETWORK)) - tty.ty_status |= TTY_NETWORK; - p = skip(p); - } - } - tty.ty_status = 0; - tty.ty_window = NULL; - tty.ty_group = _TTYS_NOGROUP; - - for (; *p; p = skip(p)) { - if (scmp(_TTYS_OFF)) - tty.ty_status &= ~TTY_ON; - else if (scmp(_TTYS_ON)) - tty.ty_status |= TTY_ON; - else if (scmp(_TTYS_SECURE)) - tty.ty_status |= TTY_SECURE; - else if (scmp(_TTYS_INSECURE)) - tty.ty_status &= ~TTY_SECURE; - else if (scmp(_TTYS_DIALUP)) - tty.ty_status |= TTY_DIALUP; - else if (scmp(_TTYS_NETWORK)) - tty.ty_status |= TTY_NETWORK; - else if (vcmp(_TTYS_WINDOW)) - tty.ty_window = value(p); - else if (vcmp(_TTYS_GROUP)) - tty.ty_group = value(p); - else - break; - } - - if (zapchar == '#' || *p == '#') - while ((c = *++p) == ' ' || c == '\t') - ; - tty.ty_comment = p; - if (*p == 0) - tty.ty_comment = 0; - if ( (p = index(p, '\n')) ) - *p = '\0'; - return (&tty); -} - -#define QUOTED 1 - -/* - * Skip over the current field, removing quotes, and return a pointer to - * the next field. - */ -static char * -skip(p) - register char *p; -{ - register char *t; - register int c, q; - - for (q = 0, t = p; (c = *p) != '\0'; p++) { - if (c == '"') { - q ^= QUOTED; /* obscure, but nice */ - continue; - } - if (q == QUOTED && *p == '\\' && *(p+1) == '"') - p++; - *t++ = *p; - if (q == QUOTED) - continue; - if (c == '#') { - zapchar = c; - *p = 0; - break; - } - if (c == '\t' || c == ' ' || c == '\n') { - zapchar = c; - *p++ = 0; - while ((c = *p) == '\t' || c == ' ' || c == '\n') - p++; - break; - } - } - *--t = '\0'; - return (p); -} - -static char * -value(p) - register char *p; -{ - - return ((p = index(p, '=')) ? ++p : NULL); -} - -int -setttyent() -{ - - if (line == NULL) { - if ((line = malloc(MALLOCCHUNK)) == NULL) - return (0); - lbsize = MALLOCCHUNK; - } - if (tf) { - rewind(tf); - return (1); - } else if ( (tf = fopen(_PATH_TTYS, "r")) ) - return (1); - return (0); -} - -int -endttyent() -{ - int rval; - - /* - * NB: Don't free `line' because getttynam() - * may still be referencing it - */ - if (tf) { - rval = (fclose(tf) != EOF); - tf = NULL; - return (rval); - } - return (1); -} - -static int -isttystat(tty, flag) - const char *tty; - int flag; -{ - register struct ttyent *t; - - return ((t = getttynam(tty)) == NULL) ? 0 : !!(t->ty_status & flag); -} - - -int -isdialuptty(tty) - const char *tty; -{ - - return isttystat(tty, TTY_DIALUP); -} - -int isnettty(tty) - const char *tty; -{ - - return isttystat(tty, TTY_NETWORK); -} diff --git a/lib/libc/gen/getusershell.3 b/lib/libc/gen/getusershell.3 deleted file mode 100644 index 8541762..0000000 --- a/lib/libc/gen/getusershell.3 +++ /dev/null @@ -1,100 +0,0 @@ -.\" Copyright (c) 1985, 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. -.\" -.\" @(#)getusershell.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt GETUSERSHELL 3 -.Os BSD 4.3 -.Sh NAME -.Nm getusershell , -.Nm setusershell , -.Nm endusershell -.Nd get legal user shells -.Sh SYNOPSIS -.Fd #include -.Ft char * -.Fn getusershell void -.Ft void -.Fn setusershell void -.Ft void -.Fn endusershell void -.Sh DESCRIPTION -The -.Fn getusershell -function -returns a pointer to a legal user shell as defined by the -system manager in the file -.Pa /etc/shells . -If -.Pa /etc/shells -is unreadable or does not exist, -.Fn getusershell -behaves as if -.Pa /bin/sh -and -.Pa /bin/csh -were listed in the file. -.Pp -The -.Fn getusershell -function -reads the next -line (opening the file if necessary); -.Fn setusershell -rewinds the file; -.Fn endusershell -closes it. -.Sh FILES -.Bl -tag -width /etc/shells -compact -.It Pa /etc/shells -.El -.Sh DIAGNOSTICS -The routine -.Fn getusershell -returns a null pointer (0) on -.Dv EOF . -.Sh SEE ALSO -.Xr shells 5 -.Sh HISTORY -The -.Fn getusershell -function appeared in -.Bx 4.3 . -.Sh BUGS -The -.Fn getusershell -function leaves its result in an internal static object and returns -a pointer to that object. -Subsequent calls to -.Fn getusershell -will modify the same object. diff --git a/lib/libc/gen/getusershell.c b/lib/libc/gen/getusershell.c deleted file mode 100644 index be1a77a..0000000 --- a/lib/libc/gen/getusershell.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 1985, 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getusershell.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * Local shells should NOT be added here. They should be added in - * /etc/shells. - */ - -static char *okshells[] = { _PATH_BSHELL, _PATH_CSHELL, NULL }; -static char **curshell, **shells, *strings; -static char **initshells __P((void)); - -/* - * Get a list of shells from _PATH_SHELLS, if it exists. - */ -char * -getusershell() -{ - char *ret; - - if (curshell == NULL) - curshell = initshells(); - ret = *curshell; - if (ret != NULL) - curshell++; - return (ret); -} - -void -endusershell() -{ - - if (shells != NULL) - free(shells); - shells = NULL; - if (strings != NULL) - free(strings); - strings = NULL; - curshell = NULL; -} - -void -setusershell() -{ - - curshell = initshells(); -} - -static char ** -initshells() -{ - register char **sp, *cp; - register FILE *fp; - struct stat statb; - - if (shells != NULL) - free(shells); - shells = NULL; - if (strings != NULL) - free(strings); - strings = NULL; - if ((fp = fopen(_PATH_SHELLS, "r")) == NULL) - return (okshells); - if (fstat(fileno(fp), &statb) == -1) { - (void)fclose(fp); - return (okshells); - } - if ((strings = malloc((u_int)statb.st_size)) == NULL) { - (void)fclose(fp); - return (okshells); - } - shells = calloc((unsigned)statb.st_size / 3, sizeof (char *)); - if (shells == NULL) { - (void)fclose(fp); - free(strings); - strings = NULL; - return (okshells); - } - sp = shells; - cp = strings; - while (fgets(cp, MAXPATHLEN + 1, fp) != NULL) { - while (*cp != '#' && *cp != '/' && *cp != '\0') - cp++; - if (*cp == '#' || *cp == '\0') - continue; - *sp++ = cp; - while (!isspace((unsigned char)*cp) && *cp != '#' && *cp != '\0') - cp++; - *cp++ = '\0'; - } - *sp = NULL; - (void)fclose(fp); - return (shells); -} diff --git a/lib/libc/gen/getvfsbyname.3 b/lib/libc/gen/getvfsbyname.3 deleted file mode 100644 index c33fbea..0000000 --- a/lib/libc/gen/getvfsbyname.3 +++ /dev/null @@ -1,98 +0,0 @@ -.\" Copyright (c) 1995 -.\" 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. -.\" -.\" @(#)kvm_getvfsbyname.3 8.3 (Berkeley) 5/4/95 -.\" $FreeBSD$ -.\" -.Dd May 4, 1995 -.Dt GETVFSBYNAME 3 -.Os -.Sh NAME -.Nm getvfsbyname -.Nd get information about a filesystem -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Ft int -.Fn getvfsbyname "const char *name" "struct vfsconf *vfc" -.Sh DESCRIPTION -The -.Fn getvfsbyname -function provides access to information about a -filesystem module that is configured in the kernel. -If successful, -the requested filesystem -.Fa vfsconf -is returned in the location pointed to by -.Fa vfc . -The fields in a -.Dq Li struct vfsconf -are defined as follows: -.Pp -.Bl -tag -compact -width vfc_refcount -.It vfc_name -the name of the filesystem -.It vfc_typenum -the filesystem type number assigned by the kernel -.It vfc_refcount -the number of active mount points using the filesystem -.It vfc_flags -flag bits that are used to initialize a new mount point -using the filesystem -.El -.Sh RETURN VALUES -If the call to -.Nm getvfsbyname -is successful, 0 is returned. -Otherwise \-1 is returned and -.Va errno -is set appropriately. -.Sh ERRORS -The following errors may be reported: -.Bl -tag -width Er -.It Bq Er EFAULT -The -.Fa vfc -pointer contains an invalid address. -.It Bq Er ENOENT -The -.Fa name -specifies a filesystem that is unknown or not configured in the kernel. -.Sh SEE ALSO -.Xr mount 2 , -.Xr sysctl 3 , -.Xr mount 8 , -.Xr sysctl 8 -.Sh HISTORY -A variant of the -.Fn getvfsbyname -function first appeared in -.Fx 2.0 . diff --git a/lib/libc/gen/getvfsbyname.c b/lib/libc/gen/getvfsbyname.c deleted file mode 100644 index a8f6913..0000000 --- a/lib/libc/gen/getvfsbyname.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 1995 - * 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. - */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)kvm_getvfsbyname.c 8.1 (Berkeley) 4/3/95"; -#endif -static const char rcsid[] = - "$FreeBSD$"; -#endif /* not lint */ - -#include -#include -#include -#include - -/* - * Given a filesystem name, determine if it is resident in the kernel, - * and if it is resident, return its vfsconf structure. - */ -getvfsbyname(fsname, vfcp) - const char *fsname; - struct vfsconf *vfcp; -{ -#ifdef __NETBSD_SYSCALLS - errno = ENOSYS; -#else - int name[4], maxtypenum, cnt; - size_t buflen; - - name[0] = CTL_VFS; - name[1] = VFS_GENERIC; - name[2] = VFS_MAXTYPENUM; - buflen = 4; - if (sysctl(name, 3, &maxtypenum, &buflen, (void *)0, (size_t)0) < 0) - return (-1); - name[2] = VFS_CONF; - buflen = sizeof *vfcp; - for (cnt = 0; cnt < maxtypenum; cnt++) { - name[3] = cnt; - if (sysctl(name, 4, vfcp, &buflen, (void *)0, (size_t)0) < 0) { - if (errno != EOPNOTSUPP) - return (-1); - continue; - } - if (!strcmp(fsname, vfcp->vfc_name)) - return (0); - } - errno = ENOENT; -#endif - return (-1); -} diff --git a/lib/libc/gen/getvfsent.3 b/lib/libc/gen/getvfsent.3 deleted file mode 100644 index 127e0f3..0000000 --- a/lib/libc/gen/getvfsent.3 +++ /dev/null @@ -1,163 +0,0 @@ -.\" $FreeBSD$ -.\" Written by Garrett A. Wollman, September 1994. -.\" This manual page is in the public domain. -.\" -.Dd September 24, 1994 -.Dt GETVFSENT 3 -.Os -.Sh NAME -.Nm getvfsent , -.Nm setvfsent , -.Nm endvfsent , -.Nm vfsisloadable , -.Nm vfsload -.Nd manage virtual filesystem modules -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Ft struct ovfsconf * -.Fn getvfsent "void" -.Ft void -.Fn setvfsent "int cachelist" -.Ft void -.Fn endvfsent "void" -.Ft int -.Fn vfsisloadable "const char *name" -.Ft int -.Fn vfsload "const char *name" -.Sh DESCRIPTION -The -.Fn getvfsent -function provides convenient access to a list of installed virtual -filesystem modules managed by the kernel. It steps through the -list of filesystems one at a time. A null pointer is returned when -no more data is available. The fields in a -.Dq Li struct ovfsconf -are as follows: -.Pp -.Bl -tag -compact -width vfc_refcount -.It vfc_name -the name of the filesystem -.It vfc_index -the filesystem type number assigned by the kernel and used in calls to -.Xr mount 2 -.It vfc_refcount -the number of references to this filesystem -(usually the number of mounts, but one greater for filesystems which -cannot be unloaded or which are statically linked into the kernel) -.It vfc_flags -flag bits, of which none are currently defined -.El -.Pp -The -.Fn setvfsent -and -.Fn endvfsent -functions are used to control caching of the filesystem list, which is -obtained in toto from the kernel via -.Xr sysctl 3 . -If the -.Fa cachelist -parameter to -.Fn setvfsent -is non-zero, the list will be retrieved only once, upon the first call -to one of the retrieval functions, until -.Fn endvfsent -is called to clear the cache. In general, -.Fn setvfsent 1 -should be called by programs using the -.Fn getvfsent -function, and -.Fn setvfsent 0 -(which is also the default state) -should be called by programs using the -.Fn vfsload -function. -.Pp -The -.Fn vfsisloadable -function returns a non-zero value if a later call to -.Fn vfsload name -is likely to succeed. We say -.Dq likely -because -.Fn vfsisloadable -does not check any of the conditions necessary for -.Fn vfsload -to succeed. -.Pp -The -.Fn vfsload -function attempts to load a kernel module implementing filesystem -.Fa name . -It returns zero if the filesystem module was successfully located and -loaded, or non-zero otherwise. It should only be called in the -following circumstances: -.Bl -enum -.It -.Fn getvfsbyname -has been called and returned a non-zero value. -.It -.Fn vfsisloadable -has been called and returned a non-zero value. -.El -.Pp -Here is an example, taken from the source to -.Xr mount_cd9660 8 : -.Bd -literal -offset indent - -struct vfsconf *vfc; -int error; - -/* setup code here */ - -error = getvfsbyname("cd9660", &vfc); -if (error && vfsisloadable("cd9660")) { - if (vfsload("cd9660")) - err(EX_OSERR, "vfsload(cd9660)"); - endvfsent(); /* flush cache */ - error = getvfsbyname("cd9660", &vfc); -} -if (error) - errx(1, "cd9660 filesystem is not available"); - -if (mount(vfc.vfc_name, dir, mntflags, &args) < 0) - err(1, NULL); - -.Ed -.Sh RETURN VALUES -The -.Fn getvfsent -routine returns a pointer to a static data structure when -it succeeds, and returns a null pointer when it fails. On failure, -.Va errno -may be set to one of the values documented for -.Xr sysctl 3 -or -.Xr malloc 3 , -if a failure of that function was the cause; otherwise -.Va errno -will be unmodified. -.Pp -The -.Fn vfsload -function returns a non-zero value on failure, or zero on success. If -.Fn vfsload -fails, -.Va errno -may be set to one of the values documented for -.Xr kldload 2 . -.Sh SEE ALSO -.Xr kldload 2 , -.Xr mount 2 , -.Xr mount 8 -.Sh AUTHORS -The loadable filesystem support was written by -.An Garrett A. Wollman , -based on generic loadable kernel module support by -.An Terry Lambert . -.Sh HISTORY -The -.Fn getvfsent -family of functions first appeared in -.Fx 2.0 . diff --git a/lib/libc/gen/getvfsent.c b/lib/libc/gen/getvfsent.c deleted file mode 100644 index bf3ca20..0000000 --- a/lib/libc/gen/getvfsent.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * getvfsent.c - get a listing of installed filesystems - * Written September 1994 by Garrett A. Wollman - * This file is in the public domain. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* XXX hide some compatibility problems. */ -#undef getvfsbyname -#define vfsconf ovfsconf - -static struct vfsconf *_vfslist = 0; -static struct vfsconf _vfsconf; -static size_t _vfslistlen = 0; -static int _vfs_keeplist = 0; -static int _vfs_index = 0; - -static int -initvfs(void) -{ - int mib[2] = { CTL_VFS, VFS_VFSCONF }; - size_t size = 0; - int rv; - - rv = sysctl(mib, 2, (void *)0, &size, (void *)0, (size_t)0); - if(rv < 0) - return 0; - - if(_vfslist) - free(_vfslist); - _vfslist = malloc(size); - if(!_vfslist) - return 0; - - rv = sysctl(mib, 2, _vfslist, &size, (void *)0, (size_t)0); - if(rv < 0) { - free(_vfslist); - _vfslist = 0; - return 0; - } - - _vfslistlen = size / sizeof _vfslist[0]; - return 1; -} - -struct vfsconf * -getvfsent(void) -{ - if(!_vfslist && !initvfs()) { - return 0; - } - - do { - if(_vfs_index >= _vfslistlen) { - return 0; - } - - _vfsconf = _vfslist[_vfs_index++]; - } while(!_vfsconf.vfc_vfsops); - - if(!_vfs_keeplist) { - free(_vfslist); - _vfslist = 0; - } - return &_vfsconf; -} - -struct vfsconf * -getvfsbyname(const char *name) -{ - int i; - - if(!_vfslist && !initvfs()) { - return 0; - } - - for(i = 0; i < _vfslistlen; i++) { - if( ! strcmp(_vfslist[i].vfc_name, name) ) - break; - } - - if(i < _vfslistlen) { - _vfsconf = _vfslist[i]; - } - - if(!_vfs_keeplist) { - free(_vfslist); - _vfslist = 0; - } - - if(i < _vfslistlen) { - return &_vfsconf; - } else { - return 0; - } -} - -struct vfsconf * -getvfsbytype(int type) -{ - int i; - - if(!_vfslist && !initvfs()) { - return 0; - } - - for(i = 0; i < _vfslistlen; i++) { - if(_vfslist[i].vfc_index == type) - break; - } - - if(i < _vfslistlen) { - _vfsconf = _vfslist[i]; - } - - if(!_vfs_keeplist) { - free(_vfslist); - _vfslist = 0; - } - - if(i < _vfslistlen) { - return &_vfsconf; - } else { - return 0; - } -} - -void -setvfsent(int keep) -{ - if(_vfslist && !keep) { - free(_vfslist); - _vfslist = 0; - } - - _vfs_keeplist = keep; - _vfs_index = 0; -} - -void -endvfsent(void) -{ - if(_vfslist) { - free(_vfslist); - _vfslist = 0; - } - - _vfs_index = 0; -} - -int -vfsisloadable(const char *name) -{ - return 1; -} - -int -vfsload(const char *name) -{ - int status; - - status = kldload(name); - return status == -1 ? status : 0; -} - diff --git a/lib/libc/gen/glob.3 b/lib/libc/gen/glob.3 deleted file mode 100644 index d99dc9f..0000000 --- a/lib/libc/gen/glob.3 +++ /dev/null @@ -1,447 +0,0 @@ -.\" Copyright (c) 1989, 1991, 1993, 1994 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Guido van Rossum. -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)glob.3 8.3 (Berkeley) 4/16/94 -.\" $FreeBSD$ -.\" -.Dd April 16, 1994 -.Dt GLOB 3 -.Os -.Sh NAME -.Nm glob , -.Nm globfree -.Nd generate pathnames matching a pattern -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn glob "const char *pattern" "int flags" "int (*errfunc)(const char *, int)" "glob_t *pglob" -.Ft void -.Fn globfree "glob_t *pglob" -.Sh DESCRIPTION -The -.Fn glob -function -is a pathname generator that implements the rules for file name pattern -matching used by the shell. -.Pp -The include file -.Pa glob.h -defines the structure type -.Fa glob_t , -which contains at least the following fields: -.Bd -literal -typedef struct { - int gl_pathc; /* count of total paths so far */ - int gl_matchc; /* count of paths matching pattern */ - int gl_offs; /* reserved at beginning of gl_pathv */ - int gl_flags; /* returned flags */ - char **gl_pathv; /* list of paths matching pattern */ -} glob_t; -.Ed -.Pp -The argument -.Fa pattern -is a pointer to a pathname pattern to be expanded. -The -.Fn glob -argument -matches all accessible pathnames against the pattern and creates -a list of the pathnames that match. -In order to have access to a pathname, -.Fn glob -requires search permission on every component of a path except the last -and read permission on each directory of any filename component of -.Fa pattern -that contains any of the special characters -.Ql * , -.Ql ? -or -.Ql [ . -.Pp -The -.Fn glob -argument -stores the number of matched pathnames into the -.Fa gl_pathc -field, and a pointer to a list of pointers to pathnames into the -.Fa gl_pathv -field. -The first pointer after the last pathname is -.Dv NULL . -If the pattern does not match any pathnames, the returned number of -matched paths is set to zero. -.Pp -It is the caller's responsibility to create the structure pointed to by -.Fa pglob . -The -.Fn glob -function allocates other space as needed, including the memory pointed -to by -.Fa gl_pathv . -.Pp -The argument -.Fa flags -is used to modify the behavior of -.Fn glob . -The value of -.Fa flags -is the bitwise inclusive -.Tn OR -of any of the following -values defined in -.Pa glob.h : -.Bl -tag -width GLOB_ALTDIRFUNC -.It Dv GLOB_APPEND -Append pathnames generated to the ones from a previous call (or calls) -to -.Fn glob . -The value of -.Fa gl_pathc -will be the total matches found by this call and the previous call(s). -The pathnames are appended to, not merged with the pathnames returned by -the previous call(s). -Between calls, the caller must not change the setting of the -.Dv GLOB_DOOFFS -flag, nor change the value of -.Fa gl_offs -when -.Dv GLOB_DOOFFS -is set, nor (obviously) call -.Fn globfree -for -.Fa pglob . -.It Dv GLOB_DOOFFS -Make use of the -.Fa gl_offs -field. -If this flag is set, -.Fa gl_offs -is used to specify how many -.Dv NULL -pointers to prepend to the beginning -of the -.Fa gl_pathv -field. -In other words, -.Fa gl_pathv -will point to -.Fa gl_offs -.Dv NULL -pointers, -followed by -.Fa gl_pathc -pathname pointers, followed by a -.Dv NULL -pointer. -.It Dv GLOB_ERR -Causes -.Fn glob -to return when it encounters a directory that it cannot open or read. -Ordinarily, -.Fn glob -continues to find matches. -.It Dv GLOB_MARK -Each pathname that is a directory that matches -.Fa pattern -has a slash -appended. -.It Dv GLOB_NOCHECK -If -.Fa pattern -does not match any pathname, then -.Fn glob -returns a list -consisting of only -.Fa pattern , -with the number of total pathnames is set to 1, and the number of matched -pathnames set to 0. -If -.Dv GLOB_QUOTE -is set, its effect is present in the pattern returned. -.It Dv GLOB_NOSORT -By default, the pathnames are sorted in ascending -.Tn ASCII -order; -this flag prevents that sorting (speeding up -.Fn glob ) . -.El -.Pp -The following values may also be included in -.Fa flags , -however, they are non-standard extensions to -.St -p1003.2 . -.Bl -tag -width GLOB_ALTDIRFUNC -.It Dv GLOB_ALTDIRFUNC -The following additional fields in the pglob structure have been -initialized with alternate functions for glob to use to open, read, -and close directories and to get stat information on names found -in those directories. -.Bd -literal -void *(*gl_opendir)(const char * name); -struct dirent *(*gl_readdir)(void *); -void (*gl_closedir)(void *); -int (*gl_lstat)(const char *name, struct stat *st); -int (*gl_stat)(const char *name, struct stat *st); -.Ed -.Pp -This extension is provided to allow programs such as -.Xr restore 8 -to provide globbing from directories stored on tape. -.It Dv GLOB_BRACE -Pre-process the pattern string to expand -.Ql {pat,pat,...} -strings like -.Xr csh 1 . -The pattern -.Ql {} -is left unexpanded for historical reasons (and -.Xr csh 1 -does the same thing to -ease typing -of -.Xr find 1 -patterns). -.It Dv GLOB_MAGCHAR -Set by the -.Fn glob -function if the pattern included globbing characters. -See the description of the usage of the -.Fa gl_matchc -structure member for more details. -.It Dv GLOB_NOMAGIC -Is the same as -.Dv GLOB_NOCHECK -but it only appends the -.Fa pattern -if it does not contain any of the special characters ``*'', ``?'' or ``[''. -.Dv GLOB_NOMAGIC -is provided to simplify implementing the historic -.Xr csh 1 -globbing behavior and should probably not be used anywhere else. -.It Dv GLOB_QUOTE -Use the backslash -.Pq Ql \e -character for quoting: every occurrence of -a backslash followed by a character in the pattern is replaced by that -character, avoiding any special interpretation of the character. -.It Dv GLOB_TILDE -Expand patterns that start with -.Ql ~ -to user name home directories. -.El -.Pp -If, during the search, a directory is encountered that cannot be opened -or read and -.Fa errfunc -is -.Pf non- Dv NULL , -.Fn glob -calls -.Fa (*errfunc)(path, errno) . -This may be unintuitive: a pattern like -.Ql */Makefile -will try to -.Xr stat 2 -.Ql foo/Makefile -even if -.Ql foo -is not a directory, resulting in a -call to -.Fa errfunc . -The error routine can suppress this action by testing for -.Dv ENOENT -and -.Dv ENOTDIR ; -however, the -.Dv GLOB_ERR -flag will still cause an immediate -return when this happens. -.Pp -If -.Fa errfunc -returns non-zero, -.Fn glob -stops the scan and returns -.Dv GLOB_ABEND -after setting -.Fa gl_pathc -and -.Fa gl_pathv -to reflect any paths already matched. -This also happens if an error is encountered and -.Dv GLOB_ERR -is set in -.Fa flags , -regardless of the return value of -.Fa errfunc , -if called. -If -.Dv GLOB_ERR -is not set and either -.Fa errfunc -is -.Dv NULL -or -.Fa errfunc -returns zero, the error is ignored. -.Pp -The -.Fn globfree -function frees any space associated with -.Fa pglob -from a previous call(s) to -.Fn glob . -.Sh RETURN VALUES -On successful completion, -.Fn glob -returns zero. -In addition the fields of -.Fa pglob -contain the values described below: -.Bl -tag -width GLOB_NOCHECK -.It Fa gl_pathc -contains the total number of matched pathnames so far. -This includes other matches from previous invocations of -.Fn glob -if -.Dv GLOB_APPEND -was specified. -.It Fa gl_matchc -contains the number of matched pathnames in the current invocation of -.Fn glob . -.It Fa gl_flags -contains a copy of the -.Fa flags -parameter with the bit -.Dv GLOB_MAGCHAR -set if -.Fa pattern -contained any of the special characters ``*'', ``?'' or ``['', cleared -if not. -.It Fa gl_pathv -contains a pointer to a -.Dv NULL Ns -terminated -list of matched pathnames. -However, if -.Fa gl_pathc -is zero, the contents of -.Fa gl_pathv -are undefined. -.El -.Pp -If -.Fn glob -terminates due to an error, it sets errno and returns one of the -following non-zero constants, which are defined in the include -file -.Aq Pa glob.h : -.Bl -tag -width GLOB_NOCHECK -.It Dv GLOB_NOSPACE -An attempt to allocate memory failed. -.It Dv GLOB_ABEND -The scan was stopped because an error was encountered and either -.Dv GLOB_ERR -was set or -.Fa (*errfunc)() -returned non-zero. -.El -.Pp -The arguments -.Fa pglob\->gl_pathc -and -.Fa pglob\->gl_pathv -are still set as specified above. -.Sh EXAMPLE -A rough equivalent of -.Ql "ls -l *.c *.h" -can be obtained with the -following code: -.Bd -literal -offset indent -glob_t g; - -g.gl_offs = 2; -glob("*.c", GLOB_DOOFFS, NULL, &g); -glob("*.h", GLOB_DOOFFS | GLOB_APPEND, NULL, &g); -g.gl_pathv[0] = "ls"; -g.gl_pathv[1] = "-l"; -execvp("ls", g.gl_pathv); -.Ed -.Sh SEE ALSO -.Xr sh 1 , -.Xr fnmatch 3 , -.Xr regexp 3 -.Sh STANDARDS -The -.Fn glob -function is expected to be -.St -p1003.2 -compatible with the exception -that the flags -.Dv GLOB_ALTDIRFUNC, -.Dv GLOB_BRACE -.Dv GLOB_MAGCHAR, -.Dv GLOB_NOMAGIC, -.Dv GLOB_QUOTE, -and -.Dv GLOB_TILDE, -and the fields -.Fa gl_matchc -and -.Fa gl_flags -should not be used by applications striving for strict -.Tn POSIX -conformance. -.Sh HISTORY -The -.Fn glob -and -.Fn globfree -functions first appeared in -.Bx 4.4 . -.Sh BUGS -Patterns longer than -.Dv MAXPATHLEN -may cause unchecked errors. -.Pp -The -.Fn glob -argument -may fail and set errno for any of the errors specified for the -library routines -.Xr stat 2 , -.Xr closedir 3 , -.Xr opendir 3 , -.Xr readdir 3 , -.Xr malloc 3 , -and -.Xr free 3 . diff --git a/lib/libc/gen/glob.c b/lib/libc/gen/glob.c deleted file mode 100644 index 09dfd7a..0000000 --- a/lib/libc/gen/glob.c +++ /dev/null @@ -1,864 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Guido van Rossum. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93"; -#endif /* LIBC_SCCS and not lint */ - -/* - * glob(3) -- a superset of the one defined in POSIX 1003.2. - * - * The [!...] convention to negate a range is supported (SysV, Posix, ksh). - * - * Optional extra services, controlled by flags not defined by POSIX: - * - * GLOB_QUOTE: - * Escaping convention: \ inhibits any special meaning the following - * character might have (except \ at end of string is retained). - * GLOB_MAGCHAR: - * Set in gl_flags if pattern contained a globbing character. - * GLOB_NOMAGIC: - * Same as GLOB_NOCHECK, but it will only append pattern if it did - * not contain any magic characters. [Used in csh style globbing] - * GLOB_ALTDIRFUNC: - * Use alternately specified directory access functions. - * GLOB_TILDE: - * expand ~user/foo to the /home/dir/of/user/foo - * GLOB_BRACE: - * expand {1,2}{a,b} to 1a 1b 2a 2b - * gl_matchc: - * Number of matches in the current invocation of glob. - */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "collate.h" - -#define DOLLAR '$' -#define DOT '.' -#define EOS '\0' -#define LBRACKET '[' -#define NOT '!' -#define QUESTION '?' -#define QUOTE '\\' -#define RANGE '-' -#define RBRACKET ']' -#define SEP '/' -#define STAR '*' -#define TILDE '~' -#define UNDERSCORE '_' -#define LBRACE '{' -#define RBRACE '}' -#define SLASH '/' -#define COMMA ',' - -#ifndef DEBUG - -#define M_QUOTE 0x8000 -#define M_PROTECT 0x4000 -#define M_MASK 0xffff -#define M_ASCII 0x00ff - -typedef u_short Char; - -#else - -#define M_QUOTE 0x80 -#define M_PROTECT 0x40 -#define M_MASK 0xff -#define M_ASCII 0x7f - -typedef char Char; - -#endif - - -#define CHAR(c) ((Char)((c)&M_ASCII)) -#define META(c) ((Char)((c)|M_QUOTE)) -#define M_ALL META('*') -#define M_END META(']') -#define M_NOT META('!') -#define M_ONE META('?') -#define M_RNG META('-') -#define M_SET META('[') -#define ismeta(c) (((c)&M_QUOTE) != 0) - - -static int compare __P((const void *, const void *)); -static void g_Ctoc __P((const Char *, char *)); -static int g_lstat __P((Char *, struct stat *, glob_t *)); -static DIR *g_opendir __P((Char *, glob_t *)); -static Char *g_strchr __P((Char *, int)); -#ifdef notdef -static Char *g_strcat __P((Char *, const Char *)); -#endif -static int g_stat __P((Char *, struct stat *, glob_t *)); -static int glob0 __P((const Char *, glob_t *)); -static int glob1 __P((Char *, glob_t *)); -static int glob2 __P((Char *, Char *, Char *, glob_t *)); -static int glob3 __P((Char *, Char *, Char *, Char *, glob_t *)); -static int globextend __P((const Char *, glob_t *)); -static const Char * globtilde __P((const Char *, Char *, size_t, glob_t *)); -static int globexp1 __P((const Char *, glob_t *)); -static int globexp2 __P((const Char *, const Char *, glob_t *, int *)); -static int match __P((Char *, Char *, Char *)); -#ifdef DEBUG -static void qprintf __P((const char *, Char *)); -#endif - -int -glob(pattern, flags, errfunc, pglob) - const char *pattern; - int flags, (*errfunc) __P((const char *, int)); - glob_t *pglob; -{ - const u_char *patnext; - int c; - Char *bufnext, *bufend, patbuf[MAXPATHLEN+1]; - - patnext = (u_char *) pattern; - if (!(flags & GLOB_APPEND)) { - pglob->gl_pathc = 0; - pglob->gl_pathv = NULL; - if (!(flags & GLOB_DOOFFS)) - pglob->gl_offs = 0; - } - pglob->gl_flags = flags & ~GLOB_MAGCHAR; - pglob->gl_errfunc = errfunc; - pglob->gl_matchc = 0; - - bufnext = patbuf; - bufend = bufnext + MAXPATHLEN; - if (flags & GLOB_QUOTE) { - /* Protect the quoted characters. */ - while (bufnext < bufend && (c = *patnext++) != EOS) - if (c == QUOTE) { - if ((c = *patnext++) == EOS) { - c = QUOTE; - --patnext; - } - *bufnext++ = c | M_PROTECT; - } - else - *bufnext++ = c; - } - else - while (bufnext < bufend && (c = *patnext++) != EOS) - *bufnext++ = c; - *bufnext = EOS; - - if (flags & GLOB_BRACE) - return globexp1(patbuf, pglob); - else - return glob0(patbuf, pglob); -} - -/* - * Expand recursively a glob {} pattern. When there is no more expansion - * invoke the standard globbing routine to glob the rest of the magic - * characters - */ -static int globexp1(pattern, pglob) - const Char *pattern; - glob_t *pglob; -{ - const Char* ptr = pattern; - int rv; - - /* Protect a single {}, for find(1), like csh */ - if (pattern[0] == LBRACE && pattern[1] == RBRACE && pattern[2] == EOS) - return glob0(pattern, pglob); - - while ((ptr = (const Char *) g_strchr((Char *) ptr, LBRACE)) != NULL) - if (!globexp2(ptr, pattern, pglob, &rv)) - return rv; - - return glob0(pattern, pglob); -} - - -/* - * Recursive brace globbing helper. Tries to expand a single brace. - * If it succeeds then it invokes globexp1 with the new pattern. - * If it fails then it tries to glob the rest of the pattern and returns. - */ -static int globexp2(ptr, pattern, pglob, rv) - const Char *ptr, *pattern; - glob_t *pglob; - int *rv; -{ - int i; - Char *lm, *ls; - const Char *pe, *pm, *pl; - Char patbuf[MAXPATHLEN + 1]; - - /* copy part up to the brace */ - for (lm = patbuf, pm = pattern; pm != ptr; *lm++ = *pm++) - continue; - ls = lm; - - /* Find the balanced brace */ - for (i = 0, pe = ++ptr; *pe; pe++) - if (*pe == LBRACKET) { - /* Ignore everything between [] */ - for (pm = pe++; *pe != RBRACKET && *pe != EOS; pe++) - continue; - if (*pe == EOS) { - /* - * We could not find a matching RBRACKET. - * Ignore and just look for RBRACE - */ - pe = pm; - } - } - else if (*pe == LBRACE) - i++; - else if (*pe == RBRACE) { - if (i == 0) - break; - i--; - } - - /* Non matching braces; just glob the pattern */ - if (i != 0 || *pe == EOS) { - *rv = glob0(patbuf, pglob); - return 0; - } - - for (i = 0, pl = pm = ptr; pm <= pe; pm++) - switch (*pm) { - case LBRACKET: - /* Ignore everything between [] */ - for (pl = pm++; *pm != RBRACKET && *pm != EOS; pm++) - continue; - if (*pm == EOS) { - /* - * We could not find a matching RBRACKET. - * Ignore and just look for RBRACE - */ - pm = pl; - } - break; - - case LBRACE: - i++; - break; - - case RBRACE: - if (i) { - i--; - break; - } - /* FALLTHROUGH */ - case COMMA: - if (i && *pm == COMMA) - break; - else { - /* Append the current string */ - for (lm = ls; (pl < pm); *lm++ = *pl++) - continue; - /* - * Append the rest of the pattern after the - * closing brace - */ - for (pl = pe + 1; (*lm++ = *pl++) != EOS;) - continue; - - /* Expand the current pattern */ -#ifdef DEBUG - qprintf("globexp2:", patbuf); -#endif - *rv = globexp1(patbuf, pglob); - - /* move after the comma, to the next string */ - pl = pm + 1; - } - break; - - default: - break; - } - *rv = 0; - return 0; -} - - - -/* - * expand tilde from the passwd file. - */ -static const Char * -globtilde(pattern, patbuf, patbuf_len, pglob) - const Char *pattern; - Char *patbuf; - size_t patbuf_len; - glob_t *pglob; -{ - struct passwd *pwd; - char *h; - const Char *p; - Char *b, *eb; - - if (*pattern != TILDE || !(pglob->gl_flags & GLOB_TILDE)) - return pattern; - - /* - * Copy up to the end of the string or / - */ - eb = &patbuf[patbuf_len - 1]; - for (p = pattern + 1, h = (char *) patbuf; - h < (char *)eb && *p && *p != SLASH; *h++ = *p++) - continue; - - *h = EOS; - - if (((char *) patbuf)[0] == EOS) { - /* - * handle a plain ~ or ~/ by expanding $HOME first (iff - * we're not running setuid or setgid) and then trying - * the password file - */ - if ( -#ifndef __NETBSD_SYSCALLS - issetugid() != 0 || -#endif - (h = getenv("HOME")) == NULL) { - if (((h = getlogin()) != NULL && - (pwd = getpwnam(h)) != NULL) || - (pwd = getpwuid(getuid())) != NULL) - h = pwd->pw_dir; - else - return pattern; - } - } - else { - /* - * Expand a ~user - */ - if ((pwd = getpwnam((char*) patbuf)) == NULL) - return pattern; - else - h = pwd->pw_dir; - } - - /* Copy the home directory */ - for (b = patbuf; b < eb && *h; *b++ = *h++) - continue; - - /* Append the rest of the pattern */ - while (b < eb && (*b++ = *p++) != EOS) - continue; - *b = EOS; - - return patbuf; -} - - -/* - * The main glob() routine: compiles the pattern (optionally processing - * quotes), calls glob1() to do the real pattern matching, and finally - * sorts the list (unless unsorted operation is requested). Returns 0 - * if things went well, nonzero if errors occurred. It is not an error - * to find no matches. - */ -static int -glob0(pattern, pglob) - const Char *pattern; - glob_t *pglob; -{ - const Char *qpatnext; - int c, err, oldpathc; - Char *bufnext, patbuf[MAXPATHLEN+1]; - - qpatnext = globtilde(pattern, patbuf, sizeof(patbuf) / sizeof(Char), - pglob); - oldpathc = pglob->gl_pathc; - bufnext = patbuf; - - /* We don't need to check for buffer overflow any more. */ - while ((c = *qpatnext++) != EOS) { - switch (c) { - case LBRACKET: - c = *qpatnext; - if (c == NOT) - ++qpatnext; - if (*qpatnext == EOS || - g_strchr((Char *) qpatnext+1, RBRACKET) == NULL) { - *bufnext++ = LBRACKET; - if (c == NOT) - --qpatnext; - break; - } - *bufnext++ = M_SET; - if (c == NOT) - *bufnext++ = M_NOT; - c = *qpatnext++; - do { - *bufnext++ = CHAR(c); - if (*qpatnext == RANGE && - (c = qpatnext[1]) != RBRACKET) { - *bufnext++ = M_RNG; - *bufnext++ = CHAR(c); - qpatnext += 2; - } - } while ((c = *qpatnext++) != RBRACKET); - pglob->gl_flags |= GLOB_MAGCHAR; - *bufnext++ = M_END; - break; - case QUESTION: - pglob->gl_flags |= GLOB_MAGCHAR; - *bufnext++ = M_ONE; - break; - case STAR: - pglob->gl_flags |= GLOB_MAGCHAR; - /* collapse adjacent stars to one, - * to avoid exponential behavior - */ - if (bufnext == patbuf || bufnext[-1] != M_ALL) - *bufnext++ = M_ALL; - break; - default: - *bufnext++ = CHAR(c); - break; - } - } - *bufnext = EOS; -#ifdef DEBUG - qprintf("glob0:", patbuf); -#endif - - if ((err = glob1(patbuf, pglob)) != 0) - return(err); - - /* - * If there was no match we are going to append the pattern - * if GLOB_NOCHECK was specified or if GLOB_NOMAGIC was specified - * and the pattern did not contain any magic characters - * GLOB_NOMAGIC is there just for compatibility with csh. - */ - if (pglob->gl_pathc == oldpathc && - ((pglob->gl_flags & GLOB_NOCHECK) || - ((pglob->gl_flags & GLOB_NOMAGIC) && - !(pglob->gl_flags & GLOB_MAGCHAR)))) - return(globextend(pattern, pglob)); - else if (!(pglob->gl_flags & GLOB_NOSORT)) - qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc, - pglob->gl_pathc - oldpathc, sizeof(char *), compare); - return(0); -} - -static int -compare(p, q) - const void *p, *q; -{ - return(strcmp(*(char **)p, *(char **)q)); -} - -static int -glob1(pattern, pglob) - Char *pattern; - glob_t *pglob; -{ - Char pathbuf[MAXPATHLEN+1]; - - /* A null pathname is invalid -- POSIX 1003.1 sect. 2.4. */ - if (*pattern == EOS) - return(0); - return(glob2(pathbuf, pathbuf, pattern, pglob)); -} - -/* - * The functions glob2 and glob3 are mutually recursive; there is one level - * of recursion for each segment in the pattern that contains one or more - * meta characters. - */ -static int -glob2(pathbuf, pathend, pattern, pglob) - Char *pathbuf, *pathend, *pattern; - glob_t *pglob; -{ - struct stat sb; - Char *p, *q; - int anymeta; - - /* - * Loop over pattern segments until end of pattern or until - * segment with meta character found. - */ - for (anymeta = 0;;) { - if (*pattern == EOS) { /* End of pattern? */ - *pathend = EOS; - if (g_lstat(pathbuf, &sb, pglob)) - return(0); - - if (((pglob->gl_flags & GLOB_MARK) && - pathend[-1] != SEP) && (S_ISDIR(sb.st_mode) - || (S_ISLNK(sb.st_mode) && - (g_stat(pathbuf, &sb, pglob) == 0) && - S_ISDIR(sb.st_mode)))) { - *pathend++ = SEP; - *pathend = EOS; - } - ++pglob->gl_matchc; - return(globextend(pathbuf, pglob)); - } - - /* Find end of next segment, copy tentatively to pathend. */ - q = pathend; - p = pattern; - while (*p != EOS && *p != SEP) { - if (ismeta(*p)) - anymeta = 1; - *q++ = *p++; - } - - if (!anymeta) { /* No expansion, do next segment. */ - pathend = q; - pattern = p; - while (*pattern == SEP) - *pathend++ = *pattern++; - } else /* Need expansion, recurse. */ - return(glob3(pathbuf, pathend, pattern, p, pglob)); - } - /* NOTREACHED */ -} - -static int -glob3(pathbuf, pathend, pattern, restpattern, pglob) - Char *pathbuf, *pathend, *pattern, *restpattern; - glob_t *pglob; -{ - register struct dirent *dp; - DIR *dirp; - int err; - char buf[MAXPATHLEN]; - - /* - * The readdirfunc declaration can't be prototyped, because it is - * assigned, below, to two functions which are prototyped in glob.h - * and dirent.h as taking pointers to differently typed opaque - * structures. - */ - struct dirent *(*readdirfunc)(); - - *pathend = EOS; - errno = 0; - - if ((dirp = g_opendir(pathbuf, pglob)) == NULL) { - /* TODO: don't call for ENOENT or ENOTDIR? */ - if (pglob->gl_errfunc) { - g_Ctoc(pathbuf, buf); - if (pglob->gl_errfunc(buf, errno) || - pglob->gl_flags & GLOB_ERR) - return (GLOB_ABEND); - } - return(0); - } - - err = 0; - - /* Search directory for matching names. */ - if (pglob->gl_flags & GLOB_ALTDIRFUNC) - readdirfunc = pglob->gl_readdir; - else - readdirfunc = readdir; - while ((dp = (*readdirfunc)(dirp))) { - register u_char *sc; - register Char *dc; - - /* Initial DOT must be matched literally. */ - if (dp->d_name[0] == DOT && *pattern != DOT) - continue; - for (sc = (u_char *) dp->d_name, dc = pathend; - (*dc++ = *sc++) != EOS;) - continue; - if (!match(pathend, pattern, restpattern)) { - *pathend = EOS; - continue; - } - err = glob2(pathbuf, --dc, restpattern, pglob); - if (err) - break; - } - - if (pglob->gl_flags & GLOB_ALTDIRFUNC) - (*pglob->gl_closedir)(dirp); - else - closedir(dirp); - return(err); -} - - -/* - * Extend the gl_pathv member of a glob_t structure to accomodate a new item, - * add the new item, and update gl_pathc. - * - * This assumes the BSD realloc, which only copies the block when its size - * crosses a power-of-two boundary; for v7 realloc, this would cause quadratic - * behavior. - * - * Return 0 if new item added, error code if memory couldn't be allocated. - * - * Invariant of the glob_t structure: - * Either gl_pathc is zero and gl_pathv is NULL; or gl_pathc > 0 and - * gl_pathv points to (gl_offs + gl_pathc + 1) items. - */ -static int -globextend(path, pglob) - const Char *path; - glob_t *pglob; -{ - register char **pathv; - register int i; - u_int newsize; - char *copy; - const Char *p; - - newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs); - pathv = pglob->gl_pathv ? - realloc((char *)pglob->gl_pathv, newsize) : - malloc(newsize); - if (pathv == NULL) - return(GLOB_NOSPACE); - - if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) { - /* first time around -- clear initial gl_offs items */ - pathv += pglob->gl_offs; - for (i = pglob->gl_offs; --i >= 0; ) - *--pathv = NULL; - } - pglob->gl_pathv = pathv; - - for (p = path; *p++;) - continue; - if ((copy = malloc(p - path)) != NULL) { - g_Ctoc(path, copy); - pathv[pglob->gl_offs + pglob->gl_pathc++] = copy; - } - pathv[pglob->gl_offs + pglob->gl_pathc] = NULL; - return(copy == NULL ? GLOB_NOSPACE : 0); -} - -/* - * pattern matching function for filenames. Each occurrence of the * - * pattern causes a recursion level. - */ -static int -match(name, pat, patend) - register Char *name, *pat, *patend; -{ - int ok, negate_range; - Char c, k; - - while (pat < patend) { - c = *pat++; - switch (c & M_MASK) { - case M_ALL: - if (pat == patend) - return(1); - do - if (match(name, pat, patend)) - return(1); - while (*name++ != EOS); - return(0); - case M_ONE: - if (*name++ == EOS) - return(0); - break; - case M_SET: - ok = 0; - if ((k = *name++) == EOS) - return(0); - if ((negate_range = ((*pat & M_MASK) == M_NOT)) != EOS) - ++pat; - while (((c = *pat++) & M_MASK) != M_END) - if ((*pat & M_MASK) == M_RNG) { - if (__collate_load_error ? - CHAR(c) <= CHAR(k) && CHAR(k) <= CHAR(pat[1]) : - __collate_range_cmp(CHAR(c), CHAR(k)) <= 0 - && __collate_range_cmp(CHAR(k), CHAR(pat[1])) <= 0 - ) - ok = 1; - pat += 2; - } else if (c == k) - ok = 1; - if (ok == negate_range) - return(0); - break; - default: - if (*name++ != c) - return(0); - break; - } - } - return(*name == EOS); -} - -/* Free allocated data belonging to a glob_t structure. */ -void -globfree(pglob) - glob_t *pglob; -{ - register int i; - register char **pp; - - if (pglob->gl_pathv != NULL) { - pp = pglob->gl_pathv + pglob->gl_offs; - for (i = pglob->gl_pathc; i--; ++pp) - if (*pp) - free(*pp); - free(pglob->gl_pathv); - } -} - -static DIR * -g_opendir(str, pglob) - register Char *str; - glob_t *pglob; -{ - char buf[MAXPATHLEN]; - - if (!*str) - strcpy(buf, "."); - else - g_Ctoc(str, buf); - - if (pglob->gl_flags & GLOB_ALTDIRFUNC) - return((*pglob->gl_opendir)(buf)); - - return(opendir(buf)); -} - -static int -g_lstat(fn, sb, pglob) - register Char *fn; - struct stat *sb; - glob_t *pglob; -{ - char buf[MAXPATHLEN]; - - g_Ctoc(fn, buf); - if (pglob->gl_flags & GLOB_ALTDIRFUNC) - return((*pglob->gl_lstat)(buf, sb)); - return(lstat(buf, sb)); -} - -static int -g_stat(fn, sb, pglob) - register Char *fn; - struct stat *sb; - glob_t *pglob; -{ - char buf[MAXPATHLEN]; - - g_Ctoc(fn, buf); - if (pglob->gl_flags & GLOB_ALTDIRFUNC) - return((*pglob->gl_stat)(buf, sb)); - return(stat(buf, sb)); -} - -static Char * -g_strchr(str, ch) - Char *str; - int ch; -{ - do { - if (*str == ch) - return (str); - } while (*str++); - return (NULL); -} - -#ifdef notdef -static Char * -g_strcat(dst, src) - Char *dst; - const Char* src; -{ - Char *sdst = dst; - - while (*dst++) - continue; - --dst; - while((*dst++ = *src++) != EOS) - continue; - - return (sdst); -} -#endif - -static void -g_Ctoc(str, buf) - register const Char *str; - char *buf; -{ - register char *dc; - - for (dc = buf; (*dc++ = *str++) != EOS;) - continue; -} - -#ifdef DEBUG -static void -qprintf(str, s) - const char *str; - register Char *s; -{ - register Char *p; - - (void)printf("%s:\n", str); - for (p = s; *p; p++) - (void)printf("%c", CHAR(*p)); - (void)printf("\n"); - for (p = s; *p; p++) - (void)printf("%c", *p & M_PROTECT ? '"' : ' '); - (void)printf("\n"); - for (p = s; *p; p++) - (void)printf("%c", ismeta(*p) ? '_' : ' '); - (void)printf("\n"); -} -#endif diff --git a/lib/libc/gen/initgroups.3 b/lib/libc/gen/initgroups.3 deleted file mode 100644 index 5ed1e06..0000000 --- a/lib/libc/gen/initgroups.3 +++ /dev/null @@ -1,84 +0,0 @@ -.\" Copyright (c) 1983, 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. -.\" -.\" @(#)initgroups.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt INITGROUPS 3 -.Os BSD 4.2 -.Sh NAME -.Nm initgroups -.Nd initialize group access list -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn initgroups "const char *name" "int basegid" -.Sh DESCRIPTION -The -.Fn initgroups -function -uses the -.Xr getgrouplist 3 -function to calculate the group access list for the user -specified in -.Fa name . -This group list is then setup for the current process using -.Xr setgroups 2 . -The -.Fa basegid -is automatically included in the groups list. -Typically this value is given as -the group number from the password file. -.Sh RETURN VALUES -The -.Fn initgroups -function -returns \-1 if it was not invoked by the super-user. -.Sh SEE ALSO -.Xr setgroups 2 , -.Xr getgrouplist 3 -.Sh HISTORY -The -.Fn initgroups -function appeared in -.Bx 4.2 . -.Sh BUGS -The -.Fn getgrouplist -function called by -.Fn initgroups -uses the routines based on -.Xr getgrent 3 . -If the invoking program uses any of these routines, -the group structure will -be overwritten in the call to -.Fn initgroups . diff --git a/lib/libc/gen/initgroups.c b/lib/libc/gen/initgroups.c deleted file mode 100644 index b1ddd86..0000000 --- a/lib/libc/gen/initgroups.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)initgroups.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -int -initgroups(uname, agroup) - const char *uname; - int agroup; -{ - int groups[NGROUPS], ngroups; - - ngroups = NGROUPS; - if (getgrouplist(uname, agroup, groups, &ngroups) < 0) - warnx("%s is in too many groups, using first %d", - uname, ngroups); - if (setgroups(ngroups, groups) < 0) { - warn("setgroups"); - return (-1); - } - return (0); -} diff --git a/lib/libc/gen/isatty.c b/lib/libc/gen/isatty.c deleted file mode 100644 index f14f470..0000000 --- a/lib/libc/gen/isatty.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 1988, 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)isatty.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#ifdef _THREAD_SAFE -#include -#include "pthread_private.h" -#endif - -int -isatty(fd) - int fd; -{ - int retval; - struct termios t; - -#ifdef _THREAD_SAFE - if (_FD_LOCK(fd, FD_READ, NULL) == 0) { -#endif - retval = (tcgetattr(fd, &t) != -1); -#ifdef _THREAD_SAFE - _FD_UNLOCK(fd, FD_READ); - } else { - retval = 0; - } -#endif - return(retval); -} diff --git a/lib/libc/gen/isinf.3 b/lib/libc/gen/isinf.3 deleted file mode 100644 index a60bc4e..0000000 --- a/lib/libc/gen/isinf.3 +++ /dev/null @@ -1,78 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)isinf.3 8.2 (Berkeley) 1/29/94 -.\" $FreeBSD$ -.\" -.Dd January 29, 1994 -.Dt ISINF 3 -.Os -.Sh NAME -.Nm isinf , -.Nm isnan , -.Nm isnanf -.Nd test for infinity or not-a-number -.Sh SYNOPSIS -.Ft int -.Fn isinf double -.Ft int -.Fn isnan double -.Ft int -.Fn isnanf float -.Sh DESCRIPTION -The -.Fn isinf -function -returns 1 if the number is -.Dq \\*(If , -otherwise 0. -.Pp -The -.Fn isnan -and -.Fn isnanf -functions -return 1 if the double or float (respectively) is -.Dq not-a-number , -otherwise 0. -.Sh SEE ALSO -.Xr math 3 -.Rs -.%T "IEEE Standard for Binary Floating-Point Arithmetic" -.%Q ANSI -.%R Std 754-1985 -.Re -.Sh BUGS -Neither the -.Tn VAX -nor the Tahoe floating point have distinguished values -for either infinity or not-a-number. -These routines always return 0 on those architectures. diff --git a/lib/libc/gen/jrand48.c b/lib/libc/gen/jrand48.c deleted file mode 100644 index 051d5a6..0000000 --- a/lib/libc/gen/jrand48.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 1993 Martin Birgmeier - * All rights reserved. - * - * You may redistribute unmodified or modified versions of this source - * code provided that the above copyright notice and this and the - * following conditions are retained. - * - * This software is provided ``as is'', and comes with no warranties - * of any kind. I shall in no event be liable for anything that happens - * to anyone/anything when using this software. - */ - -#include "rand48.h" - -long -jrand48(unsigned short xseed[3]) -{ - _dorand48(xseed); - return ((long) xseed[2] << 16) + (long) xseed[1]; -} diff --git a/lib/libc/gen/lcong48.c b/lib/libc/gen/lcong48.c deleted file mode 100644 index f13826b..0000000 --- a/lib/libc/gen/lcong48.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 1993 Martin Birgmeier - * All rights reserved. - * - * You may redistribute unmodified or modified versions of this source - * code provided that the above copyright notice and this and the - * following conditions are retained. - * - * This software is provided ``as is'', and comes with no warranties - * of any kind. I shall in no event be liable for anything that happens - * to anyone/anything when using this software. - */ - -#include "rand48.h" - -extern unsigned short _rand48_seed[3]; -extern unsigned short _rand48_mult[3]; -extern unsigned short _rand48_add; - -void -lcong48(unsigned short p[7]) -{ - _rand48_seed[0] = p[0]; - _rand48_seed[1] = p[1]; - _rand48_seed[2] = p[2]; - _rand48_mult[0] = p[3]; - _rand48_mult[1] = p[4]; - _rand48_mult[2] = p[5]; - _rand48_add = p[6]; -} diff --git a/lib/libc/gen/ldexp.3 b/lib/libc/gen/ldexp.3 deleted file mode 100644 index 8a0ffef..0000000 --- a/lib/libc/gen/ldexp.3 +++ /dev/null @@ -1,78 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)ldexp.3 8.2 (Berkeley) 4/19/94 -.\" $FreeBSD$ -.\" -.Dd April 19, 1994 -.Dt LDEXP 3 -.Os -.Sh NAME -.Nm ldexp -.Nd multiply floating-point number by integral power of 2 -.Sh SYNOPSIS -.Fd #include -.Ft double -.Fn ldexp "double x" "int exp" -.Sh DESCRIPTION -The -.Fn ldexp -function multiplies a floating-point number by an integral -power of 2. -.Sh RETURN VALUES -The -.Fn ldexp -function returns the value of -.Fa x -times 2 raised to the power -.Fa exp . -.Pp -If the resultant value would cause an overflow, -the global variable -.Va errno -is set to -.Er ERANGE -and the value -.Dv HUGE -is returned. -.Sh SEE ALSO -.Xr frexp 3 , -.Xr math 3 , -.Xr modf 3 -.Sh STANDARDS -The -.Fn ldexp -function conforms to -.St -ansiC . diff --git a/lib/libc/gen/lockf.3 b/lib/libc/gen/lockf.3 deleted file mode 100644 index fe877bd..0000000 --- a/lib/libc/gen/lockf.3 +++ /dev/null @@ -1,255 +0,0 @@ -.\" $NetBSD: lockf.3,v 1.2 1998/02/05 18:47:28 perry Exp $ -.\" -.\" Copyright (c) 1997 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Klaus Klein and S.P. Zeidler. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the NetBSD -.\" Foundation, Inc. and its contributors. -.\" 4. Neither the name of The NetBSD Foundation nor the names of its -.\" contributors may be used to endorse or promote products derived -.\" from this software without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd December 19, 1997 -.Dt LOCKF 3 -.Os NetBSD 1.4 -.Sh NAME -.Nm lockf -.Nd record locking on files -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn lockf "int filedes" "int function" "off_t size" -.Sh DESCRIPTION -The -.Fn lockf -function allows sections of a file to be locked with advisory-mode locks. -Calls to -.Fn lockf -from other processes which attempt to lock the locked file section will -either return an error value or block until the section becomes unlocked. -All the locks for a process are removed when the process terminates. -.Pp -The argument -.Fa filedes -is an open file descriptor. -The file descriptor must have been opened either for write-only -.Dv ( O_WRONLY ) -or read/write -.Dv ( O_RDWR ) -operation. -.Pp -The -.Fa function -argument is a control value which specifies the action to be taken. -The permissible values for -.Fa function -are as follows: -.Bl -tag -width F_ULOCKXX -compact -offset indent -.It Sy Function -.Sy Description -.It Dv F_ULOCK -unlock locked sections -.It Dv F_LOCK -lock a section for exclusive use -.It Dv F_TLOCK -test and lock a section for exclusive use -.It Dv F_TEST -test a section for locks by other processes -.El -.Pp -.Dv F_ULOCK -removes locks from a section of the file; -.Dv F_LOCK -and -.Dv F_TLOCK -both lock a section of a file if the section is available; -.Dv F_TEST -detects if a lock by another process is present on the specified section. -.Pp -The -.Fa size -argument is the number of contiguous bytes to be locked or -unlocked. -The section to be locked or unlocked starts at the current -offset in the file and extends forward for a positive size or backward -for a negative size (the preceding bytes up to but not including the -current offset). However, it is not permitted to lock a section that -starts or extends before the beginning of the file. -If -.Fa size -is 0, the section from the current offset through the largest possible -file offset is locked (that is, from the current offset through the -present or any future end-of-file). -.Pp -The sections locked with -.Dv F_LOCK -or -.Dv F_TLOCK -may, in whole or in part, contain or be contained by a previously -locked section for the same process. -When this occurs, or if adjacent -locked sections would occur, the sections are combined into a single -locked section. -If the request would cause the number of locks to -exceed a system-imposed limit, the request will fail. -.Pp -.Dv F_LOCK -and -.Dv F_TLOCK -requests differ only by the action taken if the section is not -available. -.Dv F_LOCK -blocks the calling process until the section is available. -.Dv F_TLOCK -makes the function fail if the section is already locked by another -process. -.Pp -File locks are released on first close by the locking process of any -file descriptor for the file. -.Pp -.Dv F_ULOCK -requests release (wholly or in part) one or more locked sections -controlled by the process. -Locked sections will be unlocked starting -at the current file offset through -.Fa size -bytes or to the end of file if size is 0. When all of a locked section -is not released (that is, when the beginning or end of the area to be -unlocked falls within a locked section), the remaining portions of -that section are still locked by the process. -Releasing the center -portion of a locked section will cause the remaining locked beginning -and end portions to become two separate locked sections. -If the -request would cause the number of locks in the system to exceed a -system-imposed limit, the request will fail. -.Pp -An -.Dv F_ULOCK -request in which size is non-zero and the offset of the last byte of -the requested section is the maximum value for an object of type -off_t, when the process has an existing lock in which size is 0 and -which includes the last byte of the requested section, will be treated -as a request to unlock from the start of the requested section with a -size equal to 0. Otherwise an -.Dv F_ULOCK -request will attempt to unlock only the requested section. -.Pp -A potential for deadlock occurs if a process controlling a locked -region is put to sleep by attempting to lock the locked region of -another process. This implementation detects that sleeping until a -locked region is unlocked would cause a deadlock and fails with an -.Er EDEADLK -error. -.Pp -.Fn lockf , -.Xr fcntl 2 -and -.Xr flock 2 -locks may be safely used concurrently. -.Pp -Blocking on a section is interrupted by any signal. -.Sh RETURN VALUES -If successful, the -.Fn lockf -function returns 0. -Otherwise, it returns -1, sets -.Dv errno -to indicate an error, and existing locks are not changed. -.Sh ERRORS -.Fn lockf -will fail if: -.Bl -tag -width Er -.It Bq Er EAGAIN -The argument -.Fa function -is -.Dv F_TLOCK -or -.Dv F_TEST -and the section is already locked by another process. -.It Bq Er EBADF -The argument -.Fa filedes -is not a valid open file descriptor. -.Pp -The argument -.Fa function -is -.Dv F_LOCK -or -.Dv F_TLOCK , -and -.Fa filedes -is not a valid file descriptor open for writing. -.It Bq Er EDEADLK -The argument -.Fa function -is -.Dv F_LOCK -and a deadlock is detected. -.It Bq Er EINTR -The argument -.Fa function -is F_LOCK -and -.Fn lockf -was interrupted by the delivery of a signal. -.It Bq Er EINVAL -The argument -.Fa function -is not one of -.Dv F_ULOCK , -.Dv F_LOCK , -.Dv F_TLOCK -or -.Dv F_TEST . -.Pp -The argument -.Fa filedes -refers to a file that does not support locking. -.It Bq Er ENOLCK -The argument -.Fa function -is -.Dv F_ULOCK , -.Dv F_LOCK -or -.Dv F_TLOCK , -and satisfying the lock or unlock request would result in the number -of locked regions in the system exceeding a system-imposed limit. -.Sh SEE ALSO -.Xr fcntl 2 , -.Xr flock 2 -.Sh STANDARDS -The -.Fn lockf -function conforms to -.St -xpg4.2 . diff --git a/lib/libc/gen/lockf.c b/lib/libc/gen/lockf.c deleted file mode 100644 index 15b5b21..0000000 --- a/lib/libc/gen/lockf.c +++ /dev/null @@ -1,92 +0,0 @@ -/* $NetBSD: lockf.c,v 1.1 1997/12/20 20:23:18 kleink Exp $ */ - -/*- - * Copyright (c) 1997 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[]= - "$FreeBSD$"; -#endif - -#include -#include -#include - -int -lockf(filedes, function, size) - int filedes; - int function; - off_t size; -{ - struct flock fl; - int cmd; - - fl.l_start = 0; - fl.l_len = size; - fl.l_whence = SEEK_CUR; - - switch (function) { - case F_ULOCK: - cmd = F_SETLK; - fl.l_type = F_UNLCK; - break; - case F_LOCK: - cmd = F_SETLKW; - fl.l_type = F_WRLCK; - break; - case F_TLOCK: - cmd = F_SETLK; - fl.l_type = F_WRLCK; - break; - case F_TEST: - fl.l_type = F_WRLCK; - if (_fcntl(filedes, F_GETLK, &fl) == -1) - return (-1); - if (fl.l_type == F_UNLCK || fl.l_pid == getpid()) - return (0); - errno = EAGAIN; - return (-1); - /* NOTREACHED */ - default: - errno = EINVAL; - return (-1); - /* NOTREACHED */ - } - - return (_fcntl(filedes, cmd, &fl)); -} diff --git a/lib/libc/gen/lrand48.c b/lib/libc/gen/lrand48.c deleted file mode 100644 index a3d0111..0000000 --- a/lib/libc/gen/lrand48.c +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 1993 Martin Birgmeier - * All rights reserved. - * - * You may redistribute unmodified or modified versions of this source - * code provided that the above copyright notice and this and the - * following conditions are retained. - * - * This software is provided ``as is'', and comes with no warranties - * of any kind. I shall in no event be liable for anything that happens - * to anyone/anything when using this software. - */ - -#include "rand48.h" - -extern unsigned short _rand48_seed[3]; - -long -lrand48(void) -{ - _dorand48(_rand48_seed); - return ((long) _rand48_seed[2] << 15) + ((long) _rand48_seed[1] >> 1); -} diff --git a/lib/libc/gen/modf.3 b/lib/libc/gen/modf.3 deleted file mode 100644 index c2941a8..0000000 --- a/lib/libc/gen/modf.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)modf.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt MODF 3 -.Os -.Sh NAME -.Nm modf -.Nd extract signed integral and fractional values from floating-point number -.Sh SYNOPSIS -.Fd #include -.Ft double -.Fn modf "double value" "double *iptr" -.Sh DESCRIPTION -The -.Fn modf -function breaks the argument -.Fa value -into integral and fractional parts, each of which has the -same sign as the argument. -It stores the integral part as a -.Em double -in the object pointed to by -.Fa iptr . -.Sh RETURN VALUES -The -.Fn modf -function returns the signed fractional part of -.Fa value . -.Sh SEE ALSO -.Xr frexp 3 , -.Xr ldexp 3 , -.Xr math 3 -.Sh STANDARDS -The -.Fn modf -function conforms to -.St -ansiC . diff --git a/lib/libc/gen/mrand48.c b/lib/libc/gen/mrand48.c deleted file mode 100644 index b23db51..0000000 --- a/lib/libc/gen/mrand48.c +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 1993 Martin Birgmeier - * All rights reserved. - * - * You may redistribute unmodified or modified versions of this source - * code provided that the above copyright notice and this and the - * following conditions are retained. - * - * This software is provided ``as is'', and comes with no warranties - * of any kind. I shall in no event be liable for anything that happens - * to anyone/anything when using this software. - */ - -#include "rand48.h" - -extern unsigned short _rand48_seed[3]; - -long -mrand48(void) -{ - _dorand48(_rand48_seed); - return ((long) _rand48_seed[2] << 16) + (long) _rand48_seed[1]; -} diff --git a/lib/libc/gen/msgctl.3 b/lib/libc/gen/msgctl.3 deleted file mode 100644 index e95284c..0000000 --- a/lib/libc/gen/msgctl.3 +++ /dev/null @@ -1,213 +0,0 @@ -.\" $NetBSD: msgctl.2,v 1.1 1995/10/16 23:49:15 jtc Exp $ -.\" -.\" Copyright (c) 1995 Frank van der Linden -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed for the NetBSD Project -.\" by Frank van der Linden -.\" 4. The name of the author may not be used to endorse or promote products -.\" derived from this software without specific prior written permission -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\"/ -.Dd November 24, 1997 -.Dt MSGCTL 3 -.Os FreeBSD -.Sh NAME -.Nm msgctl -.Nd message control operations -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Fd #include -.Ft int -.Fn msgctl "int msqid" "int cmd" "struct msqid_ds *buf" -.Sh DESCRIPTION -The -.Fn msgctl -system call performs some control operations on the message queue specified -by -.Fa msqid . - -Each message queue has a data structure associated with it, parts of which -may be altered by -.Fn msgctl -and parts of which determine the actions of -.Fn msgctl . -The data structure is defined in -.Aq Pa sys/msg.h -and contains (amongst others) the following members: -.Bd -literal -struct msqid_ds { - struct ipc_perm msg_perm; /* msg queue permission bits */ - struct msg *msg_first; /* first message in the queue */ - struct msg *msg_last; /* last message in the queue */ - u_long msg_cbytes; /* number of bytes in use on the queue */ - u_long msg_qnum; /* number of msgs in the queue */ - u_long msg_qbytes; /* max # of bytes on the queue */ - pid_t msg_lspid; /* pid of last msgsnd() */ - pid_t msg_lrpid; /* pid of last msgrcv() */ - time_t msg_stime; /* time of last msgsnd() */ - long msg_pad1; - time_t msg_rtime; /* time of last msgrcv() */ - long msg_pad2; - time_t msg_ctime; /* time of last msgctl() */ - long msg_pad3; - long msg_pad4[4]; -}; -.Ed -.Pp -The -.Bf -literal -ipc_perm -.Ef -structure used inside the -.Bf -literal -shmid_ds -.Ef -structure is defined in -.Aq Pa sys/ipc.h -and looks like this: -.Bd -literal -struct ipc_perm { - ushort cuid; /* creator user id */ - ushort cgid; /* creator group id */ - ushort uid; /* user id */ - ushort gid; /* group id */ - ushort mode; /* r/w permission */ - ushort seq; /* sequence # (to generate unique msg/sem/shm id) */ - key_t key; /* user specified msg/sem/shm key */ -}; -.Ed -.Pp -The operation to be performed by -.Fn msgctl -is specified in -.Fa cmd -and is one of: -.Bl -tag -width IPC_RMIDX -.It Dv IPC_STAT -Gather information about the message queue and place it in the -structure pointed to by -.Fa buf . -.It Dv IPC_SET -Set the value of the -.Va msg_perm.uid , -.Va msg_perm.gid , -.Va msg_perm.mode -and -.Va msg_qbytes -fields in the structure associated with -.Fa msqid . -The values are taken from the corresponding fields in the structure -pointed to by -.Fa buf . -This operation can only be executed by the super-user, or a process that -has an effective user id equal to either -.Va msg_perm.cuid -or -.Va msg_perm.uid -in the data structure associated with the message queue. -The value of -.Va msg_qbytes -can only be increased by the super-user. -Values for -.Va msg_qbytes -that exceed the system limit (MSGMNB from -.Aq Pa sys/msg.h ) -are silently truncated to that limit. - -.It Dv IPC_RMID -Remove the message queue specified by -.Fa msqid -and destroy the data associated with it. -Only the super-user or a process -with an effective uid equal to the -.Va msg_perm.cuid -or -.Va msg_perm.uid -values in the data structure associated with the queue can do this. -.El - -The permission to read from or write to a message queue (see -.Xr msgsnd 3 -and -.Xr msgrcv 3 ) -is determined by the -.Va msg_perm.mode -field in the same way as is -done with files (see -.Xr chmod 2 ), -but the effective uid can match either the -.Va msg_perm.cuid -field or the -.Va msg_perm.uid -field, and the -effective gid can match either -.Va msg_perm.cgid -or -.Va msg_perm.gid . -.Sh RETURN VALUES -Upon successful completion, a value of 0 is returned. -Otherwise, -1 is -returned and the global variable -.Va errno -is set to indicate the error. -.Sh ERRORS -.Fn msgctl -will fail if: -.Bl -tag -width Er -.It Bq Er EPERM -.Fa cmd -is equal to IPC_SET or IPC_RMID and the caller is not the super-user, nor does -the effective uid match either the -.Va msg_perm.uid -or -.Va msg_perm.cuid -fields of the data structure associated with the message queue. - -An attempt is made to increase the value of -.Va msg_qbytes -through IPC_SET -but the caller is not the super-user. -.It Bq Er EACCES -The command is IPC_STAT -and the caller has no read permission for this message queue. -.It Bq Er EINVAL -.Fa msqid -is not a valid message queue identifier. - -.Va cmd -is not a valid command. -.It Bq Er EFAULT -.Fa buf -specifies an invalid address. -.El -.Sh SEE ALSO -.Xr msgget 3 , -.Xr msgrcv 3 , -.Xr msgsnd 3 -.Sh HISTORY -Message queues appeared in the first release of -.At V . diff --git a/lib/libc/gen/msgctl.c b/lib/libc/gen/msgctl.c deleted file mode 100644 index 7b74c51e..0000000 --- a/lib/libc/gen/msgctl.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include - -#if __STDC__ -int msgctl(int msqid, int cmd, struct msqid_ds *buf) -#else -int msgctl(msqid,cmd,buf) - int msqid; - int cmd; - caddr_t buf; -#endif -{ - return (msgsys(0, msqid, cmd, buf)); -} diff --git a/lib/libc/gen/msgget.3 b/lib/libc/gen/msgget.3 deleted file mode 100644 index f68cd8a..0000000 --- a/lib/libc/gen/msgget.3 +++ /dev/null @@ -1,137 +0,0 @@ -.\" $NetBSD: msgget.2,v 1.1 1995/10/16 23:49:19 jtc Exp $ -.\" -.\" Copyright (c) 1995 Frank van der Linden -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed for the NetBSD Project -.\" by Frank van der Linden -.\" 4. The name of the author may not be used to endorse or promote products -.\" derived from this software without specific prior written permission -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" $FreeBSD$ -.\" -.\"/ -.Dd August 17, 1995 -.Dt MSGGET 3 -.Os FreeBSD -.Sh NAME -.Nm msgget -.Nd get message queue -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Fd #include -.Ft int -.Fn msgget "key_t key" "int msgflg" -.Sh DESCRIPTION -.Fn msgget -returns the message queue identifier associated with -.Fa key . -A message queue identifier is a unique integer greater than zero. -.Pp -A message queue is created if either -.Fa key -is equal to -.Dv IPC_PRIVATE , -or -.Fa key -does not have a message queue identifier associated with it, and the -.Dv IPC_CREAT -bit is set in -.Fa msgflg. -.Pp -If a new message queue is created, the data structure associated with it (the -.Va msqid_ds -structure, see -.Xr msgctl 3 ) -is initialized as follows: -.Bl -bullet -.It -.Va msg_perm.cuid -and -.Va msg_perm.uid -are set to the effective uid of the calling process. -.It -.Va msg_perm.gid -and -.Va msg_perm.cgid -are set to the effective gid of the calling process. -.It -.Va msg_perm.mode -is set to the lower 9 bits of -.Fa msgflg . -.It -.Va msg_cbytes , -.Va msg_qnum , -.Va msg_lspid , -.Va msg_lrpid , -.Va msg_rtime , -and -.Va msg_stime -are set to 0. -.It -.Va msg_qbytes -is set to the system wide maximum value for the number of bytes in a queue -.Pf ( Dv MSGMNB ) . -.It -.Va msg_ctime -is set to the current time. -.El -.Sh RETURN VALUES -Upon successful completion a positive message queue identifier is returned. -Otherwise, -1 is returned and the global variable -.Va errno -is set to indicate the error. -.Sh ERRORS -.Bl -tag -width Er -.It Bq Er EACCES -A message queue is already associated with -.Fa key -and the caller has no permission to access it. -.It Bq Er EEXIST -Both -.Dv IPC_CREAT -and -.Dv IPC_EXCL -are set in -.Fa msgflg , -and a message queue is already associated with -.Fa key . -.It Bq Er ENOSPC -A new message queue could not be created because the system limit for -the number of message queues has been reached. -.It Bq Er ENOENT -.Dv IPC_CREAT -was not set in -.Fa msgflg -and no message queue associated with -.Fa key -was found. -.El -.Sh SEE ALSO -.Xr msgctl 3 , -.Xr msgrcv 3 , -.Xr msgsnd 3 -.Sh HISTORY -Message queues appeared in the first release of -.At V . diff --git a/lib/libc/gen/msgget.c b/lib/libc/gen/msgget.c deleted file mode 100644 index 3e146b0..0000000 --- a/lib/libc/gen/msgget.c +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include - -#if __STDC__ -int msgget(key_t key, int msgflg) -#else -int msgget(key,msgflg) - key_t key; - int msgflg; -#endif -{ - return (msgsys(1, key, msgflg)); -} diff --git a/lib/libc/gen/msgrcv.3 b/lib/libc/gen/msgrcv.3 deleted file mode 100644 index 846ac6f..0000000 --- a/lib/libc/gen/msgrcv.3 +++ /dev/null @@ -1,211 +0,0 @@ -.\" $NetBSD: msgrcv.2,v 1.1 1995/10/16 23:49:20 jtc Exp $ -.\" -.\" Copyright (c) 1995 Frank van der Linden -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed for the NetBSD Project -.\" by Frank van der Linden -.\" 4. The name of the author may not be used to endorse or promote products -.\" derived from this software without specific prior written permission -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" $FreeBSD$ -.\" -.\"/ -.Dd November 24, 1997 -.Dt MSGRCV 3 -.Os FreeBSD -.Sh NAME -.Nm msgrcv -.Nd receive a message from a message queue -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Fd #include -.Ft int -.Fn msgrcv "int msqid" "void *msgp" "size_t msgsz" "long msgtyp" "int msgflg" -.Sh DESCRIPTION -The -.Fn msgrcv -function receives a message from the message queue specified in -.Fa msqid , -and places it into the structure pointed to by -.Fa msgp . -This structure should consist of the following members: -.Bd -literal - long mtype; /* message type */ - char mtext[1]; /* body of message */ -.Ed -.Pp -.Va mtype -is an integer greater than 0 that can be used for selecting messages, -.Va mtext -is an array of bytes, with a size up to that of the system limit -.Pf ( Dv MSGMAX ) . -.Pp -The value of -.Fa msgtyp -has one of the following meanings: -.Bl -bullet -.It -.Fa msgtyp -is greater than 0. The first message of type -.Fa msgtyp -will be received. -.It -.Fa msgtyp -is equal to 0. The first message on the queue will be received. -.It -.Fa msgtyp -is less than 0. The first message of the lowest message type that is -less than or equal to the absolute value of -.Fa msgtyp -will be received. -.El -.Pp -.Fa msgsz -specifies the maximum length of the requested message. -If the received -message has a length greater than -.Fa msgsz -it will be silently truncated if the -.Dv MSG_NOERROR -flag is set in -.Fa msgflg , -otherwise an error will be returned. -.Pp -If no matching message is present on the message queue specified by -.Fa msqid , -the behavior of -.Fn msgrcv -depends on whether the -.Dv IPC_NOWAIT -flag is set in -.Fa msgflg -or not. -If -.Dv IPC_NOWAIT -is set, -.Fn msgrcv -will immediately return a value of -1, and set -.Va errno -to -.Er EAGAIN . -If -.Dv IPC_NOWAIT -is not set, the calling process will be blocked -until: -.Bl -bullet -.It -A message of the requested type becomes available on the message queue. -.It -The message queue is removed, in which case -1 will be returned, and -.Va errno -set to -.Er EINVAL . -.It -A signal is received and caught. -1 is returned, and -.Va errno -set to -.Er EINTR . -.El -.Pp -If a message is successfully received, the data structure associated with -.Fa msqid -is updated as follows: -.Bl -bullet -.It -.Va msg_cbytes -is decremented by the size of the message. -.It -.Va msg_lrpid -is set to the pid of the caller. -.It -.Va msg_lrtime -is set to the current time. -.It -.Va msg_qnum -is decremented by 1. -.Sh RETURN VALUES -Upon successful completion, -.Fn msgrcv -returns the number of bytes received into the -.Va mtext -field of the structure pointed to by -.Fa msgp . -Otherwise, -1 is returned, and -.Va errno -set to indicate the error. -.Sh ERRORS -.Fn msgrcv -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -.Fa msqid -is not a valid message queue identifier. -.Pp -The message queue was removed while -.Fn msgrcv -was waiting for a message of the requested type to become available on it. -.Pp -.Fa msgsz -is less than 0. -.It Bq Er E2BIG -A matching message was received, but its size was greater than -.Fa msgsz -and the -.Dv MSG_NOERROR -flag was not set in -.Fa msgflg . -.It Bq Er EACCES -The calling process does not have read access to the message queue. -.It Bq Er EFAULT -.Fa msgp -points to an invalid address. -.It Bq Er EINTR -The system call was interrupted by the delivery of a signal. -.It Bq Er EAGAIN -There is no message of the requested type available on the message queue, -and -.Dv IPC_NOWAIT -is set in -.Fa msgflg . -.Sh SEE ALSO -.Xr msgctl 3 , -.Xr msgget 3 , -.Xr msgsnd 3 -.Sh BUGS -.Tn NetBSD -and -.Tn FreeBSD -do not define the -.Er EIDRM -error value, which should be used in -the case of a removed message queue, nor the -.Er ENOMSG -value, which -should be used when no suitable message is available and -.Dv IPC_NOWAIT -is set. -.Sh HISTORY -Message queues appeared in the first release of -.At V . diff --git a/lib/libc/gen/msgrcv.c b/lib/libc/gen/msgrcv.c deleted file mode 100644 index 5c1e387..0000000 --- a/lib/libc/gen/msgrcv.c +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include -#include - -#if __STDC__ -int msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) -#else -int msgrcv(msqid, msgp, msgsz, msgtyp, msgflg) - int msqid; - void *msgp; - size_t msgsz; - long msgtyp; - int msgflg; -#endif -{ - return (msgsys(3, msqid, msgp, msgsz, msgtyp, msgflg)); -} diff --git a/lib/libc/gen/msgsnd.3 b/lib/libc/gen/msgsnd.3 deleted file mode 100644 index 2ede183..0000000 --- a/lib/libc/gen/msgsnd.3 +++ /dev/null @@ -1,168 +0,0 @@ -.\" $NetBSD: msgsnd.2,v 1.1 1995/10/16 23:49:24 jtc Exp $ -.\" -.\" Copyright (c) 1995 Frank van der Linden -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed for the NetBSD Project -.\" by Frank van der Linden -.\" 4. The name of the author may not be used to endorse or promote products -.\" derived from this software without specific prior written permission -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd November 24, 1997 -.Dt MSGSND 3 -.Os FreeBSD -.Sh NAME -.Nm msgsnd -.Nd send a message to a message queue -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Fd #include -.Ft int -.Fn msgsnd "int msqid" "void *msgp" "size_t msgsz" "int msgflg" -.Sh DESCRIPTION -The -.Fn msgsnd -function sends a message to the message queue specified in -.Fa msqid . -.Fa msgp -points to a structure containing the message. -This structure should -consist of the following members: -.Bd -literal - long mtype; /* message type */ - char mtext[1]; /* body of message */ -.Ed -.Pp -.Va mtype -is an integer greater than 0 that can be used for selecting messages (see -.Xr msgrcv 3 ) , -.Va mtext -is an array of bytes, with a size up to that of the system limit -.Pf ( Dv MSGMAX ) . -.Pp -If the number of bytes already on the message queue plus -.Fa msgsz -is bigger than the maximum number of bytes on the message queue -.Pf ( Va msg_qbytes , -see -.Xr msgctl 3 ) , -or the number of messages on all queues system-wide is already equal to -the system limit, -.Fa msgflg -determines the action of -.Fn msgsnd . -If -.Fa msgflg -has -.Dv IPC_NOWAIT -mask set in it, the call will return immediately. -If -.Fa msgflg -does not have -.Dv IPC_NOWAIT -set in it, the call will block until: -.Bl -bullet -.It -The condition which caused the call to block does no longer exist. -The message will be sent. -.It -The message queue is removed, in which case -1 will be returned, and -.Va errno -is set to -.Er EINVAL . -.It -The caller catches a signal. -The call returns with -.Va errno -set to -.Er EINTR . -.El -.Pp -After a successful call, the data structure associated with the message -queue is updated in the following way: -.Bl -bullet -.It -.Va msg_cbytes -is incremented by the size of the message. -.It -.Va msg_qnum -is incremented by 1. -.It -.Va msg_lspid -is set to the pid of the calling process. -.It -.Va msg_stime -is set to the current time. -.El -.Sh RETURN VALUES -Upon successful completion, 0 is returned. -Otherwise, -1 is returned and -.Va errno -is set to indicate the error. -.Sh ERRORS -.Fn msgsnd -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -.Fa msqid -is not a valid message queue identifier -.Pp -The message queue was removed while -.Fn msgsnd -was waiting for a resource to become available in order to deliver the -message. -.Pp -.Fa msgsz -is less than 0, or greater than -.Va msg_qbytes . -.Pp -.Fa mtype -is not greater than 0. -.It Bq Er EACCES -The calling process does not have write access to the message queue. -.It Bq Er EAGAIN -There was no space for this message either on the queue, or in the whole -system, and -.Dv IPC_NOWAIT -was set in -.Fa msgflg . -.It Bq Er EFAULT -.Fa msgp -points to an invalid address. -.It Bq Er EINTR -The system call was interrupted by the delivery of a signal. -.El -.Sh BUGS -.Tn NetBSD -and -.Tn FreeBSD -do not define the -.Er EIDRM -error value, which should be used -in the case of a removed message queue. -.Sh HISTORY -Message queues appeared in the first release of AT&T Unix System V. diff --git a/lib/libc/gen/msgsnd.c b/lib/libc/gen/msgsnd.c deleted file mode 100644 index a620915..0000000 --- a/lib/libc/gen/msgsnd.c +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include -#include - -#if __STDC__ -int msgsnd(int msqid, void *msgp, size_t msgsz, int msgflg) -#else -int msgsnd(msqid, msgp, msgsz, msgflg) - int msqid; - void *msgp; - size_t msgsz; - int msgflg; -#endif -{ - return (msgsys(2, msqid, msgp, msgsz, msgflg)); -} diff --git a/lib/libc/gen/nice.3 b/lib/libc/gen/nice.3 deleted file mode 100644 index d61ec2e..0000000 --- a/lib/libc/gen/nice.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" Copyright (c) 1980, 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. -.\" -.\" @(#)nice.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt NICE 3 -.Os BSD 4 -.Sh NAME -.Nm nice -.Nd set program scheduling priority -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn nice "int incr" -.Sh DESCRIPTION -.Bf -symbolic -This interface is obsoleted by setpriority(2). -.Ef -.Pp -The -.Fn nice -function obtains the scheduling priority of the process -from the system and sets it to the priority value specified in -.Fa incr . -The priority is a value in the range -20 to 20. -The default priority is 0; lower priorities cause more favorable scheduling. -Only the super-user may lower priorities. -.Pp -Children inherit the priority of their parent processes via -.Xr fork 2 . -.Sh SEE ALSO -.Xr nice 1 , -.Xr fork 2 , -.Xr setpriority 2 , -.Xr renice 8 -.Sh HISTORY -A -.Fn nice -syscall appeared in -.At v6 . diff --git a/lib/libc/gen/nice.c b/lib/libc/gen/nice.c deleted file mode 100644 index 104c1a2..0000000 --- a/lib/libc/gen/nice.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)nice.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include - -/* - * Backwards compatible nice. - */ -int -nice(incr) - int incr; -{ - int prio; - - errno = 0; - prio = getpriority(PRIO_PROCESS, 0); - if (prio == -1 && errno) - return (-1); - return (setpriority(PRIO_PROCESS, 0, prio + incr)); -} diff --git a/lib/libc/gen/nlist.3 b/lib/libc/gen/nlist.3 deleted file mode 100644 index 69add4a..0000000 --- a/lib/libc/gen/nlist.3 +++ /dev/null @@ -1,79 +0,0 @@ -.\" Copyright (c) 1980, 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. -.\" -.\" @(#)nlist.3 8.3 (Berkeley) 4/19/94 -.\" $FreeBSD$ -.\" -.Dd April 19, 1994 -.Dt NLIST 3 -.Os BSD 4 -.Sh NAME -.Nm nlist -.Nd retrieve symbol table name list from an executable file -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn nlist "const char *filename" "struct nlist *nl" -.Sh DESCRIPTION -The -.Fn nlist -function -retrieves name list entries from the symbol table of an -executable file (see -.Xr a.out 5 ) . -The argument -.Fa \&nl -is set to reference the -beginning of the list. -The list is preened of binary and invalid data; -if an entry in the -name list is valid, the -.Fa n_type -and -.Fa n_value -for the entry are copied into the list -referenced by -.Fa \&nl . -No other data is copied. -The last entry in the list is always -.Dv NULL . -.Sh RETURN VALUES -The number of invalid entries is returned if successful; otherwise, -if the file -.Fa filename -does not exist or is not executable, the returned value is \-1. -.Sh SEE ALSO -.Xr a.out 5 -.Sh HISTORY -A -.Fn nlist -function appeared in -.At v6 . diff --git a/lib/libc/gen/nlist.c b/lib/libc/gen/nlist.c deleted file mode 100644 index f459067..0000000 --- a/lib/libc/gen/nlist.c +++ /dev/null @@ -1,413 +0,0 @@ -/* - * 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)nlist.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#define _NLIST_DO_AOUT -#define _NLIST_DO_ELF - -#ifdef _NLIST_DO_ELF -#include -#endif - -int __fdnlist __P((int, struct nlist *)); -int __aout_fdnlist __P((int, struct nlist *)); -int __elf_fdnlist __P((int, struct nlist *)); - -int -nlist(name, list) - const char *name; - struct nlist *list; -{ - int fd, n; - - fd = _open(name, O_RDONLY, 0); - if (fd < 0) - return (-1); - n = __fdnlist(fd, list); - (void)_close(fd); - return (n); -} - -static struct nlist_handlers { - int (*fn) __P((int fd, struct nlist *list)); -} nlist_fn[] = { -#ifdef _NLIST_DO_AOUT - { __aout_fdnlist }, -#endif -#ifdef _NLIST_DO_ELF - { __elf_fdnlist }, -#endif -}; - -int -__fdnlist(fd, list) - register int fd; - register struct nlist *list; -{ - int n = -1, i; - - for (i = 0; i < sizeof(nlist_fn) / sizeof(nlist_fn[0]); i++) { - n = (nlist_fn[i].fn)(fd, list); - if (n != -1) - break; - } - return (n); -} - -#define ISLAST(p) (p->n_un.n_name == 0 || p->n_un.n_name[0] == 0) - -#ifdef _NLIST_DO_AOUT -int -__aout_fdnlist(fd, list) - register int fd; - register struct nlist *list; -{ - register struct nlist *p, *symtab; - register caddr_t strtab, a_out_mmap; - register off_t stroff, symoff; - register u_long symsize; - register int nent; - struct exec * exec; - struct stat st; - - /* check that file is at least as large as struct exec! */ - if ((fstat(fd, &st) < 0) || (st.st_size < sizeof(struct exec))) - return (-1); - - /* Check for files too large to mmap. */ - if (st.st_size > SIZE_T_MAX) { - errno = EFBIG; - return (-1); - } - - /* - * Map the whole a.out file into our address space. - * We then find the string table withing this area. - * We do not just mmap the string table, as it probably - * does not start at a page boundary - we save ourselves a - * lot of nastiness by mmapping the whole file. - * - * This gives us an easy way to randomly access all the strings, - * without making the memory allocation permanent as with - * malloc/free (i.e., munmap will return it to the system). - */ - a_out_mmap = mmap(NULL, (size_t)st.st_size, PROT_READ, MAP_PRIVATE, fd, (off_t)0); - if (a_out_mmap == MAP_FAILED) - return (-1); - - exec = (struct exec *)a_out_mmap; - if (N_BADMAG(*exec)) { - munmap(a_out_mmap, (size_t)st.st_size); - return (-1); - } - - symoff = N_SYMOFF(*exec); - symsize = exec->a_syms; - stroff = symoff + symsize; - - /* find the string table in our mmapped area */ - strtab = a_out_mmap + stroff; - symtab = (struct nlist *)(a_out_mmap + symoff); - - /* - * clean out any left-over information for all valid entries. - * Type and value defined to be 0 if not found; historical - * versions cleared other and desc as well. Also figure out - * the largest string length so don't read any more of the - * string table than we have to. - * - * XXX clearing anything other than n_type and n_value violates - * the semantics given in the man page. - */ - nent = 0; - for (p = list; !ISLAST(p); ++p) { - p->n_type = 0; - p->n_other = 0; - p->n_desc = 0; - p->n_value = 0; - ++nent; - } - - while (symsize > 0) { - register int soff; - - symsize-= sizeof(struct nlist); - soff = symtab->n_un.n_strx; - - - if (soff != 0 && (symtab->n_type & N_STAB) == 0) - for (p = list; !ISLAST(p); p++) - if (!strcmp(&strtab[soff], p->n_un.n_name)) { - p->n_value = symtab->n_value; - p->n_type = symtab->n_type; - p->n_desc = symtab->n_desc; - p->n_other = symtab->n_other; - if (--nent <= 0) - break; - } - symtab++; - } - munmap(a_out_mmap, (size_t)st.st_size); - return (nent); -} -#endif - -#ifdef _NLIST_DO_ELF -static void elf_sym_to_nlist __P((struct nlist *, Elf_Sym *, Elf_Shdr *, int)); - -/* - * __elf_is_okay__ - Determine if ehdr really - * is ELF and valid for the target platform. - * - * WARNING: This is NOT a ELF ABI function and - * as such it's use should be restricted. - */ -int -__elf_is_okay__(ehdr) - register Elf_Ehdr *ehdr; -{ - register int retval = 0; - /* - * We need to check magic, class size, endianess, - * and version before we look at the rest of the - * Elf_Ehdr structure. These few elements are - * represented in a machine independant fashion. - */ - if (IS_ELF(*ehdr) && - ehdr->e_ident[EI_CLASS] == ELF_TARG_CLASS && - ehdr->e_ident[EI_DATA] == ELF_TARG_DATA && - ehdr->e_ident[EI_VERSION] == ELF_TARG_VER) { - - /* Now check the machine dependant header */ - if (ehdr->e_machine == ELF_TARG_MACH && - ehdr->e_version == ELF_TARG_VER) - retval = 1; - } - return retval; -} - -int -__elf_fdnlist(fd, list) - register int fd; - register struct nlist *list; -{ - register struct nlist *p; - register Elf_Off symoff = 0, symstroff = 0; - register Elf_Word symsize = 0, symstrsize = 0; - register Elf_Sword cc, i; - int nent = -1; - int errsave; - Elf_Sym sbuf[1024]; - Elf_Sym *s; - Elf_Ehdr ehdr; - char *strtab = NULL; - Elf_Shdr *shdr = NULL; - Elf_Shdr *sh; - Elf_Word shdr_size; - void *base; - struct stat st; - - /* Make sure obj is OK */ - if (lseek(fd, (off_t)0, SEEK_SET) == -1 || - _read(fd, &ehdr, sizeof(Elf_Ehdr)) != sizeof(Elf_Ehdr) || - !__elf_is_okay__(&ehdr) || - fstat(fd, &st) < 0) - return (-1); - - /* calculate section header table size */ - shdr_size = ehdr.e_shentsize * ehdr.e_shnum; - - /* Make sure it's not too big to mmap */ - if (shdr_size > SIZE_T_MAX) { - errno = EFBIG; - return (-1); - } - - /* mmap section header table */ - base = mmap(NULL, (size_t)shdr_size, PROT_READ, 0, fd, - (off_t)ehdr.e_shoff); - if (base == MAP_FAILED) - return (-1); - shdr = (Elf_Shdr *)base; - - /* - * Find the symbol table entry and it's corresponding - * string table entry. Version 1.1 of the ABI states - * that there is only one symbol table but that this - * could change in the future. - */ - for (i = 0; i < ehdr.e_shnum; i++) { - if (shdr[i].sh_type == SHT_SYMTAB) { - symoff = shdr[i].sh_offset; - symsize = shdr[i].sh_size; - symstroff = shdr[shdr[i].sh_link].sh_offset; - symstrsize = shdr[shdr[i].sh_link].sh_size; - break; - } - } - - /* Check for files too large to mmap. */ - if (symstrsize > SIZE_T_MAX) { - errno = EFBIG; - goto done; - } - /* - * Map string table into our address space. This gives us - * an easy way to randomly access all the strings, without - * making the memory allocation permanent as with malloc/free - * (i.e., munmap will return it to the system). - */ - base = mmap(NULL, (size_t)symstrsize, PROT_READ, 0, fd, - (off_t)symstroff); - if (base == MAP_FAILED) - goto done; - strtab = (char *)base; - - /* - * clean out any left-over information for all valid entries. - * Type and value defined to be 0 if not found; historical - * versions cleared other and desc as well. Also figure out - * the largest string length so don't read any more of the - * string table than we have to. - * - * XXX clearing anything other than n_type and n_value violates - * the semantics given in the man page. - */ - nent = 0; - for (p = list; !ISLAST(p); ++p) { - p->n_type = 0; - p->n_other = 0; - p->n_desc = 0; - p->n_value = 0; - ++nent; - } - - /* Don't process any further if object is stripped. */ - if (symoff == 0) - goto done; - - if (lseek(fd, (off_t) symoff, SEEK_SET) == -1) { - nent = -1; - goto done; - } - - while (symsize > 0 && nent > 0) { - cc = MIN(symsize, sizeof(sbuf)); - if (_read(fd, sbuf, cc) != cc) - break; - symsize -= cc; - for (s = sbuf; cc > 0 && nent > 0; ++s, cc -= sizeof(*s)) { - char *name; - struct nlist *p; - - name = strtab + s->st_name; - if (name[0] == '\0') - continue; - for (p = list; !ISLAST(p); p++) { - if ((p->n_un.n_name[0] == '_' && - strcmp(name, p->n_un.n_name+1) == 0) - || strcmp(name, p->n_un.n_name) == 0) { - elf_sym_to_nlist(p, s, shdr, - ehdr.e_shnum); - if (--nent <= 0) - break; - } - } - } - } - done: - errsave = errno; - if (strtab != NULL) - munmap(strtab, symstrsize); - if (shdr != NULL) - munmap(shdr, shdr_size); - errno = errsave; - return (nent); -} - -/* - * Convert an Elf_Sym into an nlist structure. This fills in only the - * n_value and n_type members. - */ -static void -elf_sym_to_nlist(nl, s, shdr, shnum) - struct nlist *nl; - Elf_Sym *s; - Elf_Shdr *shdr; - int shnum; -{ - nl->n_value = s->st_value; - - switch (s->st_shndx) { - case SHN_UNDEF: - case SHN_COMMON: - nl->n_type = N_UNDF; - break; - case SHN_ABS: - nl->n_type = ELF_ST_TYPE(s->st_info) == STT_FILE ? - N_FN : N_ABS; - break; - default: - if (s->st_shndx >= shnum) - nl->n_type = N_UNDF; - else { - Elf_Shdr *sh = shdr + s->st_shndx; - - nl->n_type = sh->sh_type == SHT_PROGBITS ? - (sh->sh_flags & SHF_WRITE ? N_DATA : N_TEXT) : - (sh->sh_type == SHT_NOBITS ? N_BSS : N_UNDF); - } - break; - } - - if (ELF_ST_BIND(s->st_info) == STB_GLOBAL || - ELF_ST_BIND(s->st_info) == STB_WEAK) - nl->n_type |= N_EXT; -} -#endif /* _NLIST_DO_ELF */ diff --git a/lib/libc/gen/nrand48.c b/lib/libc/gen/nrand48.c deleted file mode 100644 index 6c54065..0000000 --- a/lib/libc/gen/nrand48.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 1993 Martin Birgmeier - * All rights reserved. - * - * You may redistribute unmodified or modified versions of this source - * code provided that the above copyright notice and this and the - * following conditions are retained. - * - * This software is provided ``as is'', and comes with no warranties - * of any kind. I shall in no event be liable for anything that happens - * to anyone/anything when using this software. - */ - -#include "rand48.h" - -long -nrand48(unsigned short xseed[3]) -{ - _dorand48(xseed); - return ((long) xseed[2] << 15) + ((long) xseed[1] >> 1); -} diff --git a/lib/libc/gen/ntp_gettime.c b/lib/libc/gen/ntp_gettime.c deleted file mode 100644 index 3bb71c1..0000000 --- a/lib/libc/gen/ntp_gettime.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = - "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -int -ntp_gettime(struct ntptimeval *ntv) -{ - struct ntptimeval tv; - size_t size = sizeof tv; - - if (sysctlbyname("kern.ntp_pll.gettime", &tv, &size, NULL, 0) == -1) - return TIME_ERROR; - if(ntv) *ntv = tv; - return tv.time_state; -} - diff --git a/lib/libc/gen/opendir.c b/lib/libc/gen/opendir.c deleted file mode 100644 index d94b9af..0000000 --- a/lib/libc/gen/opendir.c +++ /dev/null @@ -1,276 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)opendir.c 8.8 (Berkeley) 5/1/95"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#include -#include -#include -#include -#include - -/* - * Open a directory. - */ -DIR * -opendir(name) - const char *name; -{ - - return (__opendir2(name, DTF_HIDEW|DTF_NODUP)); -} - -DIR * -__opendir2(name, flags) - const char *name; - int flags; -{ - DIR *dirp; - int fd; - int incr; - int saved_errno; - int unionstack; - struct stat statb; - - /* - * stat() before open() because opening of special files may be - * harmful. fstat() after open because the file may have changed. - */ - if (stat(name, &statb) != 0) - return (NULL); - if (!S_ISDIR(statb.st_mode)) { - errno = ENOTDIR; - return (NULL); - } - if ((fd = _open(name, O_RDONLY | O_NONBLOCK)) == -1) - return (NULL); - dirp = NULL; - if (fstat(fd, &statb) != 0) - goto fail; - if (!S_ISDIR(statb.st_mode)) { - errno = ENOTDIR; - goto fail; - } - if (_fcntl(fd, F_SETFD, FD_CLOEXEC) == -1 || - (dirp = malloc(sizeof(DIR))) == NULL) - goto fail; - - /* - * Use the system page size if that is a multiple of DIRBLKSIZ. - * Hopefully this can be a big win someday by allowing page - * trades to user space to be done by getdirentries(). - */ - incr = getpagesize(); - if ((incr % DIRBLKSIZ) != 0) - incr = DIRBLKSIZ; - - /* - * Determine whether this directory is the top of a union stack. - */ - if (flags & DTF_NODUP) { - struct statfs sfb; - - if (fstatfs(fd, &sfb) < 0) - goto fail; - unionstack = !strcmp(sfb.f_fstypename, "union"); - } else { - unionstack = 0; - } - - if (unionstack) { - int len = 0; - int space = 0; - char *buf = 0; - char *ddptr = 0; - char *ddeptr; - int n; - struct dirent **dpv; - - /* - * The strategy here is to read all the directory - * entries into a buffer, sort the buffer, and - * remove duplicate entries by setting the inode - * number to zero. - */ - - do { - /* - * Always make at least DIRBLKSIZ bytes - * available to getdirentries - */ - if (space < DIRBLKSIZ) { - space += incr; - len += incr; - buf = reallocf(buf, len); - if (buf == NULL) - goto fail; - ddptr = buf + (len - space); - } - - n = getdirentries(fd, ddptr, space, &dirp->dd_seek); - if (n > 0) { - ddptr += n; - space -= n; - } - } while (n > 0); - - ddeptr = ddptr; - flags |= __DTF_READALL; - - /* - * Re-open the directory. - * This has the effect of rewinding back to the - * top of the union stack and is needed by - * programs which plan to fchdir to a descriptor - * which has also been read -- see fts.c. - */ - if (flags & DTF_REWIND) { - (void)_close(fd); - if ((fd = _open(name, O_RDONLY)) == -1) { - saved_errno = errno; - free(buf); - free(dirp); - errno = saved_errno; - return (NULL); - } - } - - /* - * There is now a buffer full of (possibly) duplicate - * names. - */ - dirp->dd_buf = buf; - - /* - * Go round this loop twice... - * - * Scan through the buffer, counting entries. - * On the second pass, save pointers to each one. - * Then sort the pointers and remove duplicate names. - */ - for (dpv = 0;;) { - n = 0; - ddptr = buf; - while (ddptr < ddeptr) { - struct dirent *dp; - - dp = (struct dirent *) ddptr; - if ((long)dp & 03L) - break; - if ((dp->d_reclen <= 0) || - (dp->d_reclen > (ddeptr + 1 - ddptr))) - break; - ddptr += dp->d_reclen; - if (dp->d_fileno) { - if (dpv) - dpv[n] = dp; - n++; - } - } - - if (dpv) { - struct dirent *xp; - - /* - * This sort must be stable. - */ - mergesort(dpv, n, sizeof(*dpv), alphasort); - - dpv[n] = NULL; - xp = NULL; - - /* - * Scan through the buffer in sort order, - * zapping the inode number of any - * duplicate names. - */ - for (n = 0; dpv[n]; n++) { - struct dirent *dp = dpv[n]; - - if ((xp == NULL) || - strcmp(dp->d_name, xp->d_name)) { - xp = dp; - } else { - dp->d_fileno = 0; - } - if (dp->d_type == DT_WHT && - (flags & DTF_HIDEW)) - dp->d_fileno = 0; - } - - free(dpv); - break; - } else { - dpv = malloc((n+1) * sizeof(struct dirent *)); - if (dpv == NULL) - break; - } - } - - dirp->dd_len = len; - dirp->dd_size = ddptr - dirp->dd_buf; - } else { - dirp->dd_len = incr; - dirp->dd_buf = malloc(dirp->dd_len); - if (dirp->dd_buf == NULL) - goto fail; - dirp->dd_seek = 0; - flags &= ~DTF_REWIND; - } - - dirp->dd_loc = 0; - dirp->dd_fd = fd; - dirp->dd_flags = flags; - - /* - * Set up seek point for rewinddir. - */ - dirp->dd_rewind = telldir(dirp); - - return (dirp); - -fail: - saved_errno = errno; - free(dirp); - (void)_close(fd); - errno = saved_errno; - return (NULL); -} diff --git a/lib/libc/gen/pause.3 b/lib/libc/gen/pause.3 deleted file mode 100644 index e48bc8e..0000000 --- a/lib/libc/gen/pause.3 +++ /dev/null @@ -1,84 +0,0 @@ -.\" Copyright (c) 1980, 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. -.\" -.\" @(#)pause.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt PAUSE 3 -.Os BSD 4 -.Sh NAME -.Nm pause -.Nd stop until signal -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn pause void -.Sh DESCRIPTION -.Sy Pause is made obsolete by -.Xr sigsuspend 2 . -.Pp -The -.Fn pause -function -forces a process to pause until -a signal is received from either the -.Xr kill 2 -function -or an interval timer. -(See -.Xr setitimer 2 . ) -Upon termination of a signal handler started during a -.Fn pause , -the -.Fn pause -call will return. -.Sh RETURN VALUES -Always returns \-1. -.Sh ERRORS -The -.Fn pause -function -always returns: -.Bl -tag -width [EINTR] -.It Bq Er EINTR -The call was interrupted. -.El -.Sh SEE ALSO -.Xr kill 2 , -.Xr select 2 , -.Xr sigsuspend 2 -.Sh HISTORY -A -.Fn pause -syscall -appeared in -.At v6 . diff --git a/lib/libc/gen/pause.c b/lib/libc/gen/pause.c deleted file mode 100644 index f7ddb18..0000000 --- a/lib/libc/gen/pause.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)pause.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* - * Backwards compatible pause. - */ -int -__pause() -{ - return sigpause(sigblock(0L)); -} - -#ifndef _THREAD_SAFE -__weak_reference(__pause, pause); -#endif diff --git a/lib/libc/gen/popen.3 b/lib/libc/gen/popen.3 deleted file mode 100644 index 53004c0..0000000 --- a/lib/libc/gen/popen.3 +++ /dev/null @@ -1,200 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)popen.3 8.2 (Berkeley) 5/3/95 -.\" $FreeBSD$ -.\" -.Dd May 3, 1995 -.Dt POPEN 3 -.Os -.Sh NAME -.Nm popen , -.Nm pclose -.Nd process -.Tn I/O -.Sh SYNOPSIS -.Fd #include -.Ft FILE * -.Fn popen "const char *command" "const char *type" -.Ft int -.Fn pclose "FILE *stream" -.Sh DESCRIPTION -The -.Fn popen -function -.Dq opens -a process by creating a bidirectional pipe -forking, -and invoking the shell. -Any streams opened by previous -.Fn popen -calls in the parent process are closed in the new child process. -Historically, -.Fn popen -was implemented with a unidirectional pipe; -hence many implementations of -.Fn popen -only allow the -.Fa type -argument to specify reading or writing, not both. -Since -.Fn popen -is now implemented using a bidirectional pipe, the -.Fa type -argument may request a bidirectional data flow. -The -.Fa type -argument is a pointer to a null-terminated string -which must be -.Ql r -for reading, -.Ql w -for writing, or -.Ql r+ -for reading and writing. -.Pp -The -.Fa command -argument is a pointer to a null-terminated string -containing a shell command line. -This command is passed to -.Pa /bin/sh -using the -.Fl c -flag; interpretation, if any, is performed by the shell. -.Pp -The return value from -.Fn popen -is a normal standard -.Tn I/O -stream in all respects -save that it must be closed with -.Fn pclose -rather than -.Fn fclose . -Writing to such a stream -writes to the standard input of the command; -the command's standard output is the same as that of the process that called -.Fn popen , -unless this is altered by the command itself. -Conversely, reading from a -.Dq popened -stream reads the command's standard output, and -the command's standard input is the same as that of the process that called -.Fn popen . -.Pp -Note that output -.Fn popen -streams are fully buffered by default. -.Pp -The -.Fn pclose -function waits for the associated process to terminate -and returns the exit status of the command -as returned by -.Fn wait4 . -.Sh RETURN VALUE -The -.Fn popen -function returns -.Dv NULL -if the -.Xr fork 2 -or -.Xr pipe 2 -calls fail, -or if it cannot allocate memory. -.Pp -The -.Fn pclose -function -returns \-1 if -.Fa stream -is not associated with a -.Dq popened -command, if -.Fa stream -already -.Dq pclosed , -or if -.Xr wait4 -returns an error. -.Sh ERRORS -The -.Fn popen -function does not reliably set -.Va errno . -.Sh SEE ALSO -.Xr sh 1 , -.Xr fork 2 , -.Xr pipe 2 , -.Xr wait4 2 , -.Xr fclose 3 , -.Xr fflush 3 , -.Xr fopen 3 , -.Xr stdio 3 , -.Xr system 3 -.Sh BUGS -Since the standard input of a command opened for reading -shares its seek offset with the process that called -.Fn popen , -if the original process has done a buffered read, -the command's input position may not be as expected. -Similarly, the output from a command opened for writing -may become intermingled with that of the original process. -The latter can be avoided by calling -.Xr fflush 3 -before -.Fn popen . -.Pp -Failure to execute the shell -is indistinguishable from the shell's failure to execute command, -or an immediate exit of the command. -The only hint is an exit status of 127. -.Pp -The -.Fn popen -argument -always calls -.Xr sh 1 , -never calls -.Xr csh 1 . -.Sh HISTORY -A -.Fn popen -and a -.Fn pclose -function appeared in -.At v7 . -.br -Bidirectional functionality was added in -.Tn FreeBSD -2.2.6. diff --git a/lib/libc/gen/popen.c b/lib/libc/gen/popen.c deleted file mode 100644 index 7939b8f..0000000 --- a/lib/libc/gen/popen.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software written by Ken Arnold and - * published in UNIX Review, Vol. 6, No. 8. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 5/3/95"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -extern char **environ; - -static struct pid { - struct pid *next; - FILE *fp; - pid_t pid; -} *pidlist; - -FILE * -popen(command, type) - const char *command, *type; -{ - struct pid *cur; - FILE *iop; - int pdes[2], pid, twoway; - char *argv[4]; - struct pid *p; - - /* - * Lite2 introduced two-way popen() pipes using socketpair(). - * FreeBSD's pipe() is bidirectional, so we use that. - */ - if (strchr(type, '+')) { - twoway = 1; - type = "r+"; - } else { - twoway = 0; - if ((*type != 'r' && *type != 'w') || type[1]) - return (NULL); - } - if (pipe(pdes) < 0) - return (NULL); - - if ((cur = malloc(sizeof(struct pid))) == NULL) { - (void)_close(pdes[0]); - (void)_close(pdes[1]); - return (NULL); - } - - argv[0] = "sh"; - argv[1] = "-c"; - argv[2] = (char *)command; - argv[3] = NULL; - - switch (pid = vfork()) { - case -1: /* Error. */ - (void)_close(pdes[0]); - (void)_close(pdes[1]); - free(cur); - return (NULL); - /* NOTREACHED */ - case 0: /* Child. */ - if (*type == 'r') { - /* - * The dup2() to STDIN_FILENO is repeated to avoid - * writing to pdes[1], which might corrupt the - * parent's copy. This isn't good enough in - * general, since the _exit() is no return, so - * the compiler is free to corrupt all the local - * variables. - */ - (void)_close(pdes[0]); - if (pdes[1] != STDOUT_FILENO) { - (void)dup2(pdes[1], STDOUT_FILENO); - (void)_close(pdes[1]); - if (twoway) - (void)dup2(STDOUT_FILENO, STDIN_FILENO); - } else if (twoway && (pdes[1] != STDIN_FILENO)) - (void)dup2(pdes[1], STDIN_FILENO); - } else { - if (pdes[0] != STDIN_FILENO) { - (void)dup2(pdes[0], STDIN_FILENO); - (void)_close(pdes[0]); - } - (void)_close(pdes[1]); - } - for (p = pidlist; p; p = p->next) { - (void)_close(fileno(p->fp)); - } - execve(_PATH_BSHELL, argv, environ); - _exit(127); - /* NOTREACHED */ - } - - /* Parent; assume fdopen can't fail. */ - if (*type == 'r') { - iop = fdopen(pdes[0], type); - (void)_close(pdes[1]); - } else { - iop = fdopen(pdes[1], type); - (void)_close(pdes[0]); - } - - /* Link into list of file descriptors. */ - cur->fp = iop; - cur->pid = pid; - cur->next = pidlist; - pidlist = cur; - - return (iop); -} - -/* - * pclose -- - * Pclose returns -1 if stream is not associated with a `popened' command, - * if already `pclosed', or waitpid returns an error. - */ -int -pclose(iop) - FILE *iop; -{ - register struct pid *cur, *last; - int omask; - int pstat; - pid_t pid; - - /* Find the appropriate file pointer. */ - for (last = NULL, cur = pidlist; cur; last = cur, cur = cur->next) - if (cur->fp == iop) - break; - if (cur == NULL) - return (-1); - - (void)fclose(iop); - - do { - pid = _wait4(cur->pid, &pstat, 0, (struct rusage *)0); - } while (pid == -1 && errno == EINTR); - - /* Remove the entry from the linked list. */ - if (last == NULL) - pidlist = cur->next; - else - last->next = cur->next; - free(cur); - - return (pid == -1 ? -1 : pstat); -} diff --git a/lib/libc/gen/psignal.3 b/lib/libc/gen/psignal.3 deleted file mode 100644 index aad4133..0000000 --- a/lib/libc/gen/psignal.3 +++ /dev/null @@ -1,111 +0,0 @@ -.\" Copyright (c) 1983, 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. -.\" -.\" @(#)psignal.3 8.2 (Berkeley) 2/27/95 -.\" $FreeBSD$ -.\" -.Dd February 27, 1995 -.Dt PSIGNAL 3 -.Os BSD 4.2 -.Sh NAME -.Nm psignal , -.Nm strsignal , -.Nm sys_siglist , -.Nm sys_signame -.Nd system signal messages -.Sh SYNOPSIS -.Fd #include -.Ft void -.Fn psignal "unsigned sig" "const char *s" -.Vt extern const char * const sys_siglist[]; -.Vt extern const char * const sys_signame[]; -.Fd #include -.Ft "char *" -.Fn strsignal "int sig" -.Sh DESCRIPTION -The -.Fn psignal -and -.Fn strsignal -functions locate the descriptive message -string for a signal number. -.Pp -The -.Fn strsignal -function accepts a signal number argument -.Fa sig -and returns a pointer to the corresponding message string. -.Pp -The -.Fn psignal -function accepts an signal number argument -.Fa sig -and writes it to the standard error. -If the argument -.Fa s -is -.Pf non- Dv NULL -and does not point to the null character, -.Fa s -is written to the standard error file descriptor -prior to the message string, -immediately followed by a colon and a space. -If the signal number is not recognized -.Pq Xr sigaction 2 , -the string -.Dq "Unknown signal -is produced. -.Pp -The message strings can be accessed directly -through the external array -.Va sys_siglist , -indexed by recognized signal numbers. -The external array -.Va sys_signame -is used similarly and -contains short, lower-case abbreviations for signals -which are useful for recognizing signal names -in user input. -The defined variable -.Dv NSIG -contains a count of the strings in -.Va sys_siglist -and -.Va sys_signame . -.Sh SEE ALSO -.Xr sigaction 2 , -.Xr perror 3 , -.Xr strerror 3 -.Sh HISTORY -The -.Fn psignal -function appeared in -.Bx 4.2 . diff --git a/lib/libc/gen/psignal.c b/lib/libc/gen/psignal.c deleted file mode 100644 index 7c25476..0000000 --- a/lib/libc/gen/psignal.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)psignal.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -/* - * Print the name of the signal indicated - * along with the supplied message. - */ -#include -#include -#include - -void -psignal(sig, s) - unsigned int sig; - const char *s; -{ - register const char *c; - - if (sig < NSIG) - c = sys_siglist[sig]; - else - c = "Unknown signal"; - if (s != NULL && *s != '\0') { - (void)_write(STDERR_FILENO, s, strlen(s)); - (void)_write(STDERR_FILENO, ": ", 2); - } - (void)_write(STDERR_FILENO, c, strlen(c)); - (void)_write(STDERR_FILENO, "\n", 1); -} diff --git a/lib/libc/gen/pw_scan.c b/lib/libc/gen/pw_scan.c deleted file mode 100644 index d0fb5f1..0000000 --- a/lib/libc/gen/pw_scan.c +++ /dev/null @@ -1,174 +0,0 @@ -/*- - * Copyright (c) 1990, 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. - */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)pw_scan.c 8.3 (Berkeley) 4/2/94"; -#endif -static const char rcsid[] = - "$FreeBSD$"; -#endif /* not lint */ - -/* - * This module is used to "verify" password entries by chpass(1) and - * pwd_mkdb(8). - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "pw_scan.h" - -/* - * Some software assumes that IDs are short. We should emit warnings - * for id's which can not be stored in a short, but we are more liberal - * by default, warning for IDs greater than USHRT_MAX. - * - * If pw_big_ids_warning is anything other than -1 on entry to pw_scan() - * it will be set based on the existance of PW_SCAN_BIG_IDS in the - * environment. - */ -int pw_big_ids_warning = -1; - -int -pw_scan(bp, pw) - char *bp; - struct passwd *pw; -{ - uid_t id; - int root; - char *p, *sh; - - if (pw_big_ids_warning == -1) - pw_big_ids_warning = getenv("PW_SCAN_BIG_IDS") == NULL ? 1 : 0; - - pw->pw_fields = 0; - if (!(pw->pw_name = strsep(&bp, ":"))) /* login */ - goto fmt; - root = !strcmp(pw->pw_name, "root"); - if(pw->pw_name[0] && (pw->pw_name[0] != '+' || pw->pw_name[1] == '\0')) - pw->pw_fields |= _PWF_NAME; - - if (!(pw->pw_passwd = strsep(&bp, ":"))) /* passwd */ - goto fmt; - if(pw->pw_passwd[0]) pw->pw_fields |= _PWF_PASSWD; - - if (!(p = strsep(&bp, ":"))) /* uid */ - goto fmt; - if (p[0]) - pw->pw_fields |= _PWF_UID; - else { - if (pw->pw_name[0] != '+' && pw->pw_name[0] != '-') { - warnx("no uid for user %s", pw->pw_name); - return (0); - } - } - id = strtoul(p, (char **)NULL, 10); - if (errno == ERANGE) { - warnx("%s > max uid value (%u)", p, ULONG_MAX); - return (0); - } - if (root && id) { - warnx("root uid should be 0"); - return (0); - } - if (pw_big_ids_warning && id > USHRT_MAX) { - warnx("%s > recommended max uid value (%u)", p, USHRT_MAX); - /*return (0);*/ /* THIS SHOULD NOT BE FATAL! */ - } - pw->pw_uid = id; - - if (!(p = strsep(&bp, ":"))) /* gid */ - goto fmt; - if(p[0]) pw->pw_fields |= _PWF_GID; - id = strtoul(p, (char **)NULL, 10); - if (errno == ERANGE) { - warnx("%s > max gid value (%u)", p, ULONG_MAX); - return (0); - } - if (pw_big_ids_warning && id > USHRT_MAX) { - warnx("%s > recommended max gid value (%u)", p, USHRT_MAX); - /* return (0); This should not be fatal! */ - } - pw->pw_gid = id; - - pw->pw_class = strsep(&bp, ":"); /* class */ - if(pw->pw_class[0]) pw->pw_fields |= _PWF_CLASS; - - if (!(p = strsep(&bp, ":"))) /* change */ - goto fmt; - if(p[0]) pw->pw_fields |= _PWF_CHANGE; - pw->pw_change = atol(p); - - if (!(p = strsep(&bp, ":"))) /* expire */ - goto fmt; - if(p[0]) pw->pw_fields |= _PWF_EXPIRE; - pw->pw_expire = atol(p); - - if (!(pw->pw_gecos = strsep(&bp, ":"))) /* gecos */ - goto fmt; - if(pw->pw_gecos[0]) pw->pw_fields |= _PWF_GECOS; - - if (!(pw->pw_dir = strsep(&bp, ":"))) /* directory */ - goto fmt; - if(pw->pw_dir[0]) pw->pw_fields |= _PWF_DIR; - - if (!(pw->pw_shell = strsep(&bp, ":"))) /* shell */ - goto fmt; - - p = pw->pw_shell; - if (root && *p) /* empty == /bin/sh */ - for (setusershell();;) { - if (!(sh = getusershell())) { - warnx("warning, unknown root shell"); - break; - } - if (!strcmp(p, sh)) - break; - } - if(p[0]) pw->pw_fields |= _PWF_SHELL; - - if ((p = strsep(&bp, ":"))) { /* too many */ -fmt: warnx("corrupted entry"); - return (0); - } - return (1); -} diff --git a/lib/libc/gen/pw_scan.h b/lib/libc/gen/pw_scan.h deleted file mode 100644 index 2519bd4..0000000 --- a/lib/libc/gen/pw_scan.h +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * Copyright (c) 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. - * - * @(#)pw_scan.h 8.1 (Berkeley) 4/1/94 - * - * $FreeBSD$ - */ - -extern int pw_big_ids_warning; - -extern int pw_scan __P((char *, struct passwd *)); diff --git a/lib/libc/gen/pwcache.3 b/lib/libc/gen/pwcache.3 deleted file mode 100644 index d5f08a2..0000000 --- a/lib/libc/gen/pwcache.3 +++ /dev/null @@ -1,95 +0,0 @@ -.\" Copyright (c) 1989, 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. -.\" -.\" @(#)pwcache.3 8.1 (Berkeley) 6/9/93 -.\" $FreeBSD$ -.\" -.Dd June 9, 1993 -.Dt PWCACHE 3 -.Os -.Sh NAME -.Nm pwcache -.Nd cache password and group entries -.Sh SYNOPSIS -.Fd #include -.Ft char * -.Fn user_from_uid "unsigned long uid" "int nouser" -.Ft char * -.Fn group_from_gid "unsigned long gid" "int nogroup" -.Sh DESCRIPTION -.Pp -The -.Fn user_from_uid -function returns the user name associated with the argument -.Fa uid . -The user name is cached so that multiple calls with the same -.Fa uid -do not require additional calls to -.Xr getpwuid 3 . -If there is no user associated with the -.Fa uid , -a pointer is returned -to a string representation of the -.Fa uid , -unless the argument -.Fa nouser -is non-zero, in which case a -.Dv NULL -pointer is returned. -.Pp -The -.Fn group_from_gid -function returns the group name associated with the argument -.Fa gid . -The group name is cached so that multiple calls with the same -.Fa gid -do not require additional calls to -.Xr getgrgid 3 . -If there is no group associated with the -.Fa gid , -a pointer is returned -to a string representation of the -.Fa gid , -unless the argument -.Fa nogroup -is non-zero, in which case a -.Dv NULL -pointer is returned. -.Sh SEE ALSO -.Xr getgrgid 3 , -.Xr getpwuid 3 -.Sh HISTORY -The -.Fn user_from_uid -and -.Fn group_from_gid -functions first appeared in -.Bx 4.4 . diff --git a/lib/libc/gen/pwcache.c b/lib/libc/gen/pwcache.c deleted file mode 100644 index aea7f55..0000000 --- a/lib/libc/gen/pwcache.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)pwcache.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include -#include - -#define NCACHE 64 /* power of 2 */ -#define MASK (NCACHE - 1) /* bits to store with */ - -char * -user_from_uid(uid, nouser) - uid_t uid; - int nouser; -{ - static struct ncache { - uid_t uid; - int found; - char name[UT_NAMESIZE + 1]; - } c_uid[NCACHE]; - static int pwopen; - register struct passwd *pw; - register struct ncache *cp; - - cp = c_uid + (uid & MASK); - if (cp->uid != uid || !*cp->name) { - if (pwopen == 0) { - setpassent(1); - pwopen = 1; - } - pw = getpwuid(uid); - cp->uid = uid; - if (pw != NULL) { - cp->found = 1; - (void)strncpy(cp->name, pw->pw_name, UT_NAMESIZE); - cp->name[UT_NAMESIZE] = '\0'; - } else { - cp->found = 0; - (void)snprintf(cp->name, UT_NAMESIZE, "%u", uid); - if (nouser) - return (NULL); - } - } - return ((nouser && !cp->found) ? NULL : cp->name); -} - -char * -group_from_gid(gid, nogroup) - gid_t gid; - int nogroup; -{ - static struct ncache { - gid_t gid; - int found; - char name[UT_NAMESIZE + 1]; - } c_gid[NCACHE]; - static int gropen; - struct group *gr; - struct ncache *cp; - - cp = c_gid + (gid & MASK); - if (cp->gid != gid || !*cp->name) { - if (gropen == 0) { - setgroupent(1); - gropen = 1; - } - gr = getgrgid(gid); - cp->gid = gid; - if (gr != NULL) { - cp->found = 1; - (void)strncpy(cp->name, gr->gr_name, UT_NAMESIZE); - cp->name[UT_NAMESIZE] = '\0'; - } else { - cp->found = 0; - (void)snprintf(cp->name, UT_NAMESIZE, "%u", gid); - if (nogroup) - return (NULL); - } - } - return ((nogroup && !cp->found) ? NULL : cp->name); -} diff --git a/lib/libc/gen/raise.3 b/lib/libc/gen/raise.3 deleted file mode 100644 index 556ad2a..0000000 --- a/lib/libc/gen/raise.3 +++ /dev/null @@ -1,78 +0,0 @@ -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)raise.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt RAISE 3 -.Os -.Sh NAME -.Nm raise -.Nd send a signal to the current process -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn raise "int sig" -.Sh DESCRIPTION -The -.Fn raise -function sends the signal -.Fa sig -to the current process. -.Sh RETURN VALUES -Upon successful completion, a value of 0 is returned. -Otherwise, a value of \-1 is returned and the global variable -.Va errno -is set to indicate the error. -.Sh ERRORS -The -.Fn raise -function -may fail and set -.Va errno -for any of the errors specified for the -library functions -.Xr getpid 2 -and -.Xr kill 2 . -.Sh SEE ALSO -.Xr kill 2 -.Sh STANDARDS -The -.Fn raise -function -conforms to -.St -ansiC . diff --git a/lib/libc/gen/raise.c b/lib/libc/gen/raise.c deleted file mode 100644 index 2562c81..0000000 --- a/lib/libc/gen/raise.c +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * Copyright (c) 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)raise.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -int -raise(s) - int s; -{ - return(kill(getpid(), s)); -} diff --git a/lib/libc/gen/rand48.3 b/lib/libc/gen/rand48.3 deleted file mode 100644 index a6b2eef..0000000 --- a/lib/libc/gen/rand48.3 +++ /dev/null @@ -1,165 +0,0 @@ -\" Copyright (c) 1993 Martin Birgmeier -.\" All rights reserved. -.\" -.\" You may redistribute unmodified or modified versions of this source -.\" code provided that the above copyright notice and this and the -.\" following conditions are retained. -.\" -.\" This software is provided ``as is'', and comes with no warranties -.\" of any kind. I shall in no event be liable for anything that happens -.\" to anyone/anything when using this software. -.\" -.\" @(#)rand48.3 V1.0 MB 8 Oct 1993 -.\" $FreeBSD$ -.\" -.Dd October 8, 1993 -.Dt RAND48 3 -.Os FreeBSD -.Sh NAME -.Nm drand48 , -.Nm erand48 , -.Nm lrand48 , -.Nm nrand48 , -.Nm mrand48 , -.Nm jrand48 , -.Nm srand48 , -.Nm seed48 , -.Nm lcong48 -.Nd pseudo random number generators and initialization routines -.Sh SYNOPSIS -.Fd #include -.Ft double -.Fn drand48 void -.Ft double -.Fn erand48 "unsigned short xseed[3]" -.Ft long -.Fn lrand48 void -.Ft long -.Fn nrand48 "unsigned short xseed[3]" -.Ft long -.Fn mrand48 void -.Ft long -.Fn jrand48 "unsigned short xseed[3]" -.Ft void -.Fn srand48 "long seed" -.Ft "unsigned short *" -.Fn seed48 "unsigned short xseed[3]" -.Ft void -.Fn lcong48 "unsigned short p[7]" -.Sh DESCRIPTION -The -.Fn rand48 -family of functions generates pseudo-random numbers using a linear -congruential algorithm working on integers 48 bits in size. -The -particular formula employed is -r(n+1) = (a * r(n) + c) mod m -where the default values are -for the multiplicand a = 0xfdeece66d = 25214903917 and -the addend c = 0xb = 11. -The modulo is always fixed at m = 2 ** 48. -r(n) is called the seed of the random number generator. -.Pp -For all the six generator routines described next, the first -computational step is to perform a single iteration of the algorithm. -.Pp -.Fn drand48 -and -.Fn erand48 -return values of type double. -The full 48 bits of r(n+1) are -loaded into the mantissa of the returned value, with the exponent set -such that the values produced lie in the interval [0.0, 1.0). -.Pp -.Fn lrand48 -and -.Fn nrand48 -return values of type long in the range -[0, 2**31-1]. The high-order (31) bits of -r(n+1) are loaded into the lower bits of the returned value, with -the topmost (sign) bit set to zero. -.Pp -.Fn mrand48 -and -.Fn jrand48 -return values of type long in the range -[-2**31, 2**31-1]. The high-order (32) bits of -r(n+1) are loaded into the returned value. -.Pp -.Fn drand48 , -.Fn lrand48 , -and -.Fn mrand48 -use an internal buffer to store r(n). For these functions -the initial value of r(0) = 0x1234abcd330e = 20017429951246. -.Pp -On the other hand, -.Fn erand48 , -.Fn nrand48 , -and -.Fn jrand48 -use a user-supplied buffer to store the seed r(n), -which consists of an array of 3 shorts, where the zeroth member -holds the least significant bits. -.Pp -All functions share the same multiplicand and addend. -.Pp -.Fn srand48 -is used to initialize the internal buffer r(n) of -.Fn drand48 , -.Fn lrand48 , -and -.Fn mrand48 -such that the 32 bits of the seed value are copied into the upper 32 bits -of r(n), with the lower 16 bits of r(n) arbitrarily being set to 0x330e. -Additionally, the constant multiplicand and addend of the algorithm are -reset to the default values given above. -.Pp -.Fn seed48 -also initializes the internal buffer r(n) of -.Fn drand48 , -.Fn lrand48 , -and -.Fn mrand48 , -but here all 48 bits of the seed can be specified in an array of 3 shorts, -where the zeroth member specifies the lowest bits. -Again, -the constant multiplicand and addend of the algorithm are -reset to the default values given above. -.Fn seed48 -returns a pointer to an array of 3 shorts which contains the old seed. -This array is statically allocated, thus its contents are lost after -each new call to -.Fn seed48 . -.Pp -Finally, -.Fn lcong48 -allows full control over the multiplicand and addend used in -.Fn drand48 , -.Fn erand48 , -.Fn lrand48 , -.Fn nrand48 , -.Fn mrand48 , -and -.Fn jrand48 , -and the seed used in -.Fn drand48 , -.Fn lrand48 , -and -.Fn mrand48 . -An array of 7 shorts is passed as parameter; the first three shorts are -used to initialize the seed; the second three are used to initialize the -multiplicand; and the last short is used to initialize the addend. -It is thus not possible to use values greater than 0xffff as the addend. -.Pp -Note that all three methods of seeding the random number generator -always also set the multiplicand and addend for any of the six -generator calls. -.Pp -For a more powerful random number generator, see -.Xr random 3 . -.Sh AUTHORS -.An Martin Birgmeier -.Sh SEE ALSO -.Xr rand 3 , -.Xr random 3 diff --git a/lib/libc/gen/rand48.h b/lib/libc/gen/rand48.h deleted file mode 100644 index 5b9f87d..0000000 --- a/lib/libc/gen/rand48.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 1993 Martin Birgmeier - * All rights reserved. - * - * You may redistribute unmodified or modified versions of this source - * code provided that the above copyright notice and this and the - * following conditions are retained. - * - * This software is provided ``as is'', and comes with no warranties - * of any kind. I shall in no event be liable for anything that happens - * to anyone/anything when using this software. - */ - -#ifndef _RAND48_H_ -#define _RAND48_H_ - -#include -#include - -void _dorand48 __P((unsigned short[3])); - -#define RAND48_SEED_0 (0x330e) -#define RAND48_SEED_1 (0xabcd) -#define RAND48_SEED_2 (0x1234) -#define RAND48_MULT_0 (0xe66d) -#define RAND48_MULT_1 (0xdeec) -#define RAND48_MULT_2 (0x0005) -#define RAND48_ADD (0x000b) - -#endif /* _RAND48_H_ */ diff --git a/lib/libc/gen/readdir.c b/lib/libc/gen/readdir.c deleted file mode 100644 index 2e91a9a..0000000 --- a/lib/libc/gen/readdir.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - * - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)readdir.c 8.3 (Berkeley) 9/29/94"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#ifdef _THREAD_SAFE -#include -#include "pthread_private.h" -#endif _THREAD_SAFE - -/* - * get next entry in a directory. - */ -struct dirent * -readdir(dirp) - register DIR *dirp; -{ - register struct dirent *dp; - - for (;;) { - if (dirp->dd_loc >= dirp->dd_size) { - if (dirp->dd_flags & __DTF_READALL) - return (NULL); - dirp->dd_loc = 0; - } - if (dirp->dd_loc == 0 && !(dirp->dd_flags & __DTF_READALL)) { - dirp->dd_size = getdirentries(dirp->dd_fd, - dirp->dd_buf, dirp->dd_len, &dirp->dd_seek); - if (dirp->dd_size <= 0) - return (NULL); - } - dp = (struct dirent *)(dirp->dd_buf + dirp->dd_loc); - if ((long)dp & 03L) /* bogus pointer check */ - return (NULL); - if (dp->d_reclen <= 0 || - dp->d_reclen > dirp->dd_len + 1 - dirp->dd_loc) - return (NULL); - dirp->dd_loc += dp->d_reclen; - if (dp->d_ino == 0) - continue; - if (dp->d_type == DT_WHT && (dirp->dd_flags & DTF_HIDEW)) - continue; - return (dp); - } -} - -int -readdir_r(dirp, entry, result) - DIR *dirp; - struct dirent *entry; - struct dirent **result; -{ - struct dirent *dp; - int ret, saved_errno; - -#ifdef _THREAD_SAFE - if ((ret = _FD_LOCK(dirp->dd_fd, FD_READ, NULL)) != 0) - return (ret); -#endif - - saved_errno = errno; - errno = 0; - dp = readdir(dirp); - if (errno != 0) { - if (dp == NULL) { -#ifdef _THREAD_SAFE - _FD_UNLOCK(dirp->dd_fd, FD_READ); -#endif - return (errno); - } - } else - errno = saved_errno; - - if (dp != NULL) - memcpy(entry, dp, sizeof *entry); - -#ifdef _THREAD_SAFE - _FD_UNLOCK(dirp->dd_fd, FD_READ); -#endif - - if (dp != NULL) - *result = entry; - else - *result = NULL; - - return (0); -} diff --git a/lib/libc/gen/rewinddir.c b/lib/libc/gen/rewinddir.c deleted file mode 100644 index 2076ddd..0000000 --- a/lib/libc/gen/rewinddir.c +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rewinddir.c 8.1 (Berkeley) 6/8/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -extern void _seekdir __P(( DIR *, long )); - -void -rewinddir(dirp) - DIR *dirp; -{ - - _seekdir(dirp, dirp->dd_rewind); - dirp->dd_rewind = telldir(dirp); -} diff --git a/lib/libc/gen/scandir.3 b/lib/libc/gen/scandir.3 deleted file mode 100644 index afcde28..0000000 --- a/lib/libc/gen/scandir.3 +++ /dev/null @@ -1,107 +0,0 @@ -.\" Copyright (c) 1983, 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. -.\" -.\" @(#)scandir.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt SCANDIR 3 -.Os BSD 4.2 -.Sh NAME -.Nm scandir , -.Nm alphasort -.Nd scan a directory -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Ft int -.Fn scandir "const char *dirname" "struct dirent ***namelist" "int \\*(lp*select\\*(rp\\*(lpstruct dirent *\\*(rp" "int \\*(lp*compar\\*(rp\\*(lpconst void *, const void *\\*(rp" -.Ft int -.Fn alphasort "const void *d1" "const void *d2" -.Sh DESCRIPTION -The -.Fn scandir -function -reads the directory -.Fa dirname -and builds an array of pointers to directory -entries using -.Xr malloc 3 . -It returns the number of entries in the array. -A pointer to the array of directory entries is stored in the location -referenced by -.Fa namelist . -.Pp -The -.Fa select -parameter is a pointer to a user supplied subroutine which is called by -.Fn scandir -to select which entries are to be included in the array. -The select routine is passed a -pointer to a directory entry and should return a non-zero -value if the directory entry is to be included in the array. -If -.Fa select -is null, then all the directory entries will be included. -.Pp -The -.Fa compar -parameter is a pointer to a user supplied subroutine which is passed to -.Xr qsort 3 -to sort the completed array. -If this pointer is null, the array is not sorted. -.Pp -The -.Fn alphasort -function -is a routine which can be used for the -.Fa compar -parameter to sort the array alphabetically. -.Pp -The memory allocated for the array can be deallocated with -.Xr free 3 , -by freeing each pointer in the array and then the array itself. -.Sh DIAGNOSTICS -Returns \-1 if the directory cannot be opened for reading or if -.Xr malloc 3 -cannot allocate enough memory to hold all the data structures. -.Sh SEE ALSO -.Xr directory 3 , -.Xr malloc 3 , -.Xr qsort 3 , -.Xr dir 5 -.Sh HISTORY -The -.Fn scandir -and -.Fn alphasort -functions appeared in -.Bx 4.2 . diff --git a/lib/libc/gen/scandir.c b/lib/libc/gen/scandir.c deleted file mode 100644 index 5c64b29..0000000 --- a/lib/libc/gen/scandir.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)scandir.c 8.3 (Berkeley) 1/2/94"; -#endif /* LIBC_SCCS and not lint */ - -/* - * Scan the directory dirname calling select to make a list of selected - * directory entries then sort using qsort and compare routine dcomp. - * Returns the number of entries and a pointer to a list of pointers to - * struct dirent (through namelist). Returns -1 if there were any errors. - */ - -#include -#include -#include -#include -#include - -/* - * The DIRSIZ macro is 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 and a terminating nul byte - * (dp->d_namlen + 1), rounded up to a 4 byte boundary. - */ -#undef DIRSIZ -#define DIRSIZ(dp) \ - ((sizeof(struct dirent) - sizeof(dp)->d_name) + \ - (((dp)->d_namlen + 1 + 3) &~ 3)) - -int -scandir(dirname, namelist, select, dcomp) - const char *dirname; - struct dirent ***namelist; - int (*select) __P((struct dirent *)); - int (*dcomp) __P((const void *, const void *)); -{ - register struct dirent *d, *p, **names = NULL; - register size_t nitems = 0; - struct stat stb; - long arraysz; - DIR *dirp; - - if ((dirp = opendir(dirname)) == NULL) - return(-1); - if (fstat(dirp->dd_fd, &stb) < 0) - goto fail; - - /* - * estimate the array size by taking the size of the directory file - * and dividing it by a multiple of the minimum size entry. - */ - arraysz = (stb.st_size / 24); - names = (struct dirent **)malloc(arraysz * sizeof(struct dirent *)); - if (names == NULL) - goto fail; - - while ((d = readdir(dirp)) != NULL) { - if (select != NULL && !(*select)(d)) - continue; /* just selected names */ - /* - * Make a minimum size copy of the data - */ - p = (struct dirent *)malloc(DIRSIZ(d)); - if (p == NULL) - goto fail; - p->d_fileno = d->d_fileno; - p->d_type = d->d_type; - p->d_reclen = d->d_reclen; - p->d_namlen = d->d_namlen; - bcopy(d->d_name, p->d_name, p->d_namlen + 1); - /* - * Check to make sure the array has space left and - * realloc the maximum size. - */ - if (nitems >= arraysz) { - const int inc = 10; /* increase by this much */ - struct dirent **names2; - - names2 = (struct dirent **)realloc((char *)names, - (arraysz + inc) * sizeof(struct dirent *)); - if (names2 == NULL) { - free(p); - goto fail; - } - names = names2; - arraysz += inc; - } - names[nitems++] = p; - } - closedir(dirp); - if (nitems && dcomp != NULL) - qsort(names, nitems, sizeof(struct dirent *), dcomp); - *namelist = names; - return(nitems); - -fail: - while (nitems > 0) - free(names[--nitems]); - free(names); - closedir(dirp); - return -1; -} - -/* - * Alphabetic order comparison routine for those who want it. - */ -int -alphasort(d1, d2) - const void *d1; - const void *d2; -{ - return(strcmp((*(struct dirent **)d1)->d_name, - (*(struct dirent **)d2)->d_name)); -} diff --git a/lib/libc/gen/seed48.c b/lib/libc/gen/seed48.c deleted file mode 100644 index 258c4ba..0000000 --- a/lib/libc/gen/seed48.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 1993 Martin Birgmeier - * All rights reserved. - * - * You may redistribute unmodified or modified versions of this source - * code provided that the above copyright notice and this and the - * following conditions are retained. - * - * This software is provided ``as is'', and comes with no warranties - * of any kind. I shall in no event be liable for anything that happens - * to anyone/anything when using this software. - */ - -#include "rand48.h" - -extern unsigned short _rand48_seed[3]; -extern unsigned short _rand48_mult[3]; -extern unsigned short _rand48_add; - -unsigned short * -seed48(unsigned short xseed[3]) -{ - static unsigned short sseed[3]; - - sseed[0] = _rand48_seed[0]; - sseed[1] = _rand48_seed[1]; - sseed[2] = _rand48_seed[2]; - _rand48_seed[0] = xseed[0]; - _rand48_seed[1] = xseed[1]; - _rand48_seed[2] = xseed[2]; - _rand48_mult[0] = RAND48_MULT_0; - _rand48_mult[1] = RAND48_MULT_1; - _rand48_mult[2] = RAND48_MULT_2; - _rand48_add = RAND48_ADD; - return sseed; -} diff --git a/lib/libc/gen/seekdir.c b/lib/libc/gen/seekdir.c deleted file mode 100644 index 1934bcc..0000000 --- a/lib/libc/gen/seekdir.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)seekdir.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -extern void _seekdir __P(( DIR *, long )); - -/* - * Seek to an entry in a directory. - * _seekdir is in telldir.c so that it can share opaque data structures. - */ -void -seekdir(dirp, loc) - DIR *dirp; - long loc; -{ - - _seekdir(dirp, loc); -} diff --git a/lib/libc/gen/sem_destroy.3 b/lib/libc/gen/sem_destroy.3 deleted file mode 100644 index 770349d..0000000 --- a/lib/libc/gen/sem_destroy.3 +++ /dev/null @@ -1,83 +0,0 @@ -.\" Copyright (C) 2000 Jason Evans . -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice(s), this list of conditions and the following disclaimer as -.\" the first lines of this file unmodified other than the possible -.\" addition of one or more copyright notices. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice(s), this list of conditions and the following disclaimer in -.\" the documentation and/or other materials provided with the -.\" distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd February 15, 2000 -.Dt SEM_DESTROY 3 -.Os -.Sh NAME -.Nm sem_destroy -.Nd destroy an unnamed semaphore -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn sem_destroy "sem_t *sem" -.Sh DESCRIPTION -The -.Fn sem_destroy -function destroys the unnamed semaphore pointed to by -.Fa sem . -After a successful call to -.Fn sem_destroy , -.Fa sem -is unuseable until re-initialized by another call to -.Fn sem_init . -.Sh RETURN VALUES -If successful, -.Fn sem_destroy -returns 0. Otherwise, -1 is returned and -.Va errno -is set to indicate the type of -error. -.Sh ERRORS -.Fn sem_destroy -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -.Fa sem -points to an invalid semaphore. -.It Bq Er EBUSY -There are currently threads blocked on the semaphore that -.Fa sem -points to. -.El -.Sh SEE ALSO -.Xr sem_init 3 -.Sh STANDARDS -.Fn sem_destroy -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 1996 Edition. -.Pp -POSIX does not define the behavior of -.Fn sem_destroy -if called while there are threads blocked on -.Fa sem , -but this implementation is guaranteed to return -1 and set -.Va errno -to EBUSY if there are threads blocked on -.Fa sem . diff --git a/lib/libc/gen/sem_getvalue.3 b/lib/libc/gen/sem_getvalue.3 deleted file mode 100644 index be0cbae..0000000 --- a/lib/libc/gen/sem_getvalue.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" Copyright (C) 2000 Jason Evans . -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice(s), this list of conditions and the following disclaimer as -.\" the first lines of this file unmodified other than the possible -.\" addition of one or more copyright notices. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice(s), this list of conditions and the following disclaimer in -.\" the documentation and/or other materials provided with the -.\" distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd February 15, 2000 -.Dt SEM_GETVALUE 3 -.Os -.Sh NAME -.Nm sem_getvalue -.Nd get the value of a semaphore -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn sem_getvalue "sem_t *sem" "int *sval" -.Sh DESCRIPTION -The -.Fn sem_getvalue -function sets the variable pointed to by -.Fa sval -to the current value of the semaphore pointed to by -.Fa sem , -as of the time that the call to -.Fn sem_getvalue -is actually run. -.Sh RETURN VALUES -If successful, -.Fn sem_getvalue -returns 0. Otherwise, -1 is returned and -.Va errno -is set to indicate the type of -error. -.Sh ERRORS -.Fn sem_getvalue -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -.Fa sem -points to an invalid semaphore. -.El -.Sh SEE ALSO -.Xr sem_post 3 , -.Xr sem_wait 3 , -.Xr sem_trywait 3 -.Sh STANDARDS -.Fn sem_getvalue -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 1996 Edition. -.Pp -The value of the semaphore is never negative, even if there are threads blocked -on the semaphore. POSIX is somewhat ambiguous in its wording with regard to -what the value of the semaphore should be if there are blocked waiting threads, -but this behavior is conformant, given the wording of the specification. diff --git a/lib/libc/gen/sem_init.3 b/lib/libc/gen/sem_init.3 deleted file mode 100644 index 059a9c6..0000000 --- a/lib/libc/gen/sem_init.3 +++ /dev/null @@ -1,100 +0,0 @@ -.\" Copyright (C) 2000 Jason Evans . -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice(s), this list of conditions and the following disclaimer as -.\" the first lines of this file unmodified other than the possible -.\" addition of one or more copyright notices. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice(s), this list of conditions and the following disclaimer in -.\" the documentation and/or other materials provided with the -.\" distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd February 15, 2000 -.Dt SEM_INIT 3 -.Os -.Sh NAME -.Nm sem_init -.Nd initialize an unnamed semaphore -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn sem_init "sem_t *sem" "int pshared" "unsigned int value" -.Sh DESCRIPTION -The -.Fn sem_init -function initializes the unnamed semaphore pointed to by -.Fa sem -to have the value -.Fa value . -A non-zero value for -.Fa pshared -specifies a shared semaphore that can be used by multiple processes, which this -implementation is not capable of. -.Pp -Following a successful call to -.Fn sem_init , -.Fa sem -can be used as an argument in subsequent calls to -.Fa sem_wait , -.Fa sem_trywait , -.Fa sem_post , -and -.Fa sem_destroy . -.Fa sem -is no longer valid after a successful call to -.Fa sem_destroy . -.Sh RETURN VALUES -If successful, -.Fn sem_init -returns 0. Otherwise, -1 is returned and -.Va errno -is set to indicate the type of -error. -.Sh ERRORS -.Fn sem_init -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -.Fa value -exceeds SEM_VALUE_MAX. -.It Bq Er ENOSPC -Memory allocation error. -.It Bq Er EPERM -Unable to initialize a shared semaphore. -.El -.Sh SEE ALSO -.Xr sem_wait 3 , -.Xr sem_trywait 3 , -.Xr sem_post 3 , -.Xr sem_destroy -.Sh STANDARDS -.Fn sem_init -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 1996 Edition. -.Pp -This implementation does not support shared semaphores, and reports this fact -by setting -.Va errno -to EPERM. This is perhaps a stretch of the intention of POSIX, but is -compliant, with the caveat that -.Fn sem_init -always reports a permissions error when an attempt to create a shared semaphore -is made. diff --git a/lib/libc/gen/sem_open.3 b/lib/libc/gen/sem_open.3 deleted file mode 100644 index a4729f9..0000000 --- a/lib/libc/gen/sem_open.3 +++ /dev/null @@ -1,80 +0,0 @@ -.\" Copyright (C) 2000 Jason Evans . -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice(s), this list of conditions and the following disclaimer as -.\" the first lines of this file unmodified other than the possible -.\" addition of one or more copyright notices. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice(s), this list of conditions and the following disclaimer in -.\" the documentation and/or other materials provided with the -.\" distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd February 15, 2000 -.Dt SEM_OPEN 3 -.Os -.Sh NAME -.Nm sem_open , -.Nm sem_close , -.Nm sem_unlink -.Nd named semaphore operations -.Sh SYNOPSIS -.Fd #include -.Ft sem_t * -.Fn sem_open "const char *name" "int oflag" "..." -.Ft int -.Fn sem_close "sem_t *sem" -.Ft int -.Fn sem_unlink "const char *name" -.Sh DESCRIPTION -The -.Fn sem_open , -.Fn sem_close , -and -.Fn sem_unlink -functions are not supported by this implementation. -.Sh RETURN VALUES -.Fn sem_open -returns SEM_FAILED and sets -.Va errno -to indicate an error. -.Fn sem_close -and -.Fn sem_unlink -return -1 and set -.Va errno -to indicate an error. -.Sh ERRORS -.Fn sem_open , -.Fn sem_close , -and -.Fn sem_unlink -will fail: -.Bl -tag -width Er -.It Bq Er ENOSYS -Function not supported by this implementation. -.El -.Sh STANDARDS -.Fn sem_open , -.Fn sem_close , -and -.Fn sem_unlink -conform to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 1996 Edition. diff --git a/lib/libc/gen/sem_post.3 b/lib/libc/gen/sem_post.3 deleted file mode 100644 index c578e6d..0000000 --- a/lib/libc/gen/sem_post.3 +++ /dev/null @@ -1,71 +0,0 @@ -.\" Copyright (C) 2000 Jason Evans . -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice(s), this list of conditions and the following disclaimer as -.\" the first lines of this file unmodified other than the possible -.\" addition of one or more copyright notices. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice(s), this list of conditions and the following disclaimer in -.\" the documentation and/or other materials provided with the -.\" distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd February 15, 2000 -.Dt SEM_POST 3 -.Os -.Sh NAME -.Nm sem_post -.Nd increment (unlock) a semaphore -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn sem_post "sem_t *sem" -.Sh DESCRIPTION -The -.Fn sem_post -function increments (unlocks) the semaphore pointed to by -.Fa sem . -If there are threads blocked on the semaphore when -.Fn sem_post -is called, then the highest priority thread that has been blocked the longest on -the semaphore will be allowed to return from -.Fn sem_wait . -.Sh RETURN VALUES -If successful, -.Fn sem_post -returns 0. Otherwise, -1 is returned and -.Va errno -is set to indicate the type of -error. -.Sh ERRORS -.Fn sem_post -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -.Fa sem -points to an invalid semaphore. -.El -.Sh SEE ALSO -.Xr sem_wait 3 , -.Xr sem_trywait 3 -.Sh STANDARDS -.Fn sem_post -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 1996 Edition. diff --git a/lib/libc/gen/sem_wait.3 b/lib/libc/gen/sem_wait.3 deleted file mode 100644 index c60c8ee..0000000 --- a/lib/libc/gen/sem_wait.3 +++ /dev/null @@ -1,92 +0,0 @@ -.\" Copyright (C) 2000 Jason Evans . -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice(s), this list of conditions and the following disclaimer as -.\" the first lines of this file unmodified other than the possible -.\" addition of one or more copyright notices. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice(s), this list of conditions and the following disclaimer in -.\" the documentation and/or other materials provided with the -.\" distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd February 15, 2000 -.Dt SEM_WAIT 3 -.Os -.Sh NAME -.Nm sem_wait , -.Nm sem_trywait -.Nd decrement (lock) a semaphore -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn sem_wait "sem_t *sem" -.Ft int -.Fn sem_trywait "sem_t *sem" -.Sh DESCRIPTION -The -.Fn sem_wait -function decrements (locks) the semaphore pointed to by -.Fa sem , -but blocks if the value of -.Fa sem -is zero, until the value is non-zero and the value can be decremented. -.Pp -The -.Fn sem_trywait -function decrements (locks) the semaphore pointed to by -.Fa sem -only if the value is non-zero. Otherwise, the semaphore is not decremented and -an error is returned. -.Sh RETURN VALUES -If successful, -.Fn sem_wait -and -.Fn sem_trywait -return 0. Otherwise, -1 is returned and -.Va errno -is set to indicate the type of -error. -.Sh ERRORS -.Fn sem_wait -and -.Fn sem_trywait -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -.Fa sem -points to an invalid semaphore. -.El -.Pp -Additionally, -.Fn sem_trywait -will fail if: -.Bl -tag -width Er -.It Bq Er EAGAIN -The semaphore value was zero, and thus could not be decremented. -.El -.Sh SEE ALSO -.Xr sem_post 3 -.Sh STANDARDS -.Fn sem_wait -and -.Fn sem_trywait -conform to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 1996 Edition. diff --git a/lib/libc/gen/semconfig.c b/lib/libc/gen/semconfig.c deleted file mode 100644 index cf5399b..0000000 --- a/lib/libc/gen/semconfig.c +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include -#include - -#if __STDC__ -int semconfig(int cmd, int p1, int p2, int p3) -#else -int semconfig(cmd, p1, p2, p3) - int cmd, p1, p2, p3; -#endif -{ - return (semsys(3, cmd, p1, p2, p3)); -} diff --git a/lib/libc/gen/semctl.c b/lib/libc/gen/semctl.c deleted file mode 100644 index 03ecdbc..0000000 --- a/lib/libc/gen/semctl.c +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include -#include -#if __STDC__ -#include -#else -#include -#endif -#include - -#if __STDC__ -int semctl(int semid, int semnum, int cmd, ...) -#else -int semctl(semid, semnum, cmd, va_alist) - int semid, semnum; - int cmd; - va_dcl -#endif -{ - va_list ap; - union semun semun; - union semun *semun_ptr; -#if __STDC__ - va_start(ap, cmd); -#else - va_start(ap); -#endif - if (cmd == IPC_SET || cmd == IPC_STAT || cmd == GETALL - || cmd == SETVAL || cmd == SETALL) { - semun = va_arg(ap, union semun); - semun_ptr = &semun; - } else { - semun_ptr = NULL; - } - va_end(ap); - -#ifdef __NETBSD_SYSCALLS - return (__semctl(semid, semnum, cmd, semun_ptr)); -#else - return (semsys(0, semid, semnum, cmd, semun_ptr)); -#endif -} diff --git a/lib/libc/gen/semget.c b/lib/libc/gen/semget.c deleted file mode 100644 index 81c6a86..0000000 --- a/lib/libc/gen/semget.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include - -#if __STDC__ -int semget(key_t key, int nsems, int semflg) -#else -int semget(key, nsems, semflg) - key_t key; - int nsems; - int semflg; -#endif -{ - return (semsys(1, key, nsems, semflg)); -} diff --git a/lib/libc/gen/semop.c b/lib/libc/gen/semop.c deleted file mode 100644 index 0b97c6a..0000000 --- a/lib/libc/gen/semop.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include - -#if __STDC__ -int semop(int semid, struct sembuf *sops, unsigned nsops) -#else -int semop(semid, sops, nsops) - int semid; - struct sembuf *sops; - unsigned nsops; -#endif -{ - return (semsys(2, semid, sops, nsops, 0)); -} diff --git a/lib/libc/gen/setdomainname.c b/lib/libc/gen/setdomainname.c deleted file mode 100644 index 8d46166..0000000 --- a/lib/libc/gen/setdomainname.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/* -static char sccsid[] = "From: @(#)sethostname.c 8.1 (Berkeley) 6/4/93"; -*/ -static const char rcsid[] = - "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#include - -int -setdomainname(const char *name, int namelen) -{ - int mib[2]; - - mib[0] = CTL_KERN; - mib[1] = KERN_NISDOMAINNAME; - if (sysctl(mib, 2, NULL, NULL, (void *)name, namelen) == -1) - return (-1); - return (0); -} diff --git a/lib/libc/gen/setflags.3 b/lib/libc/gen/setflags.3 deleted file mode 100644 index 09c6208..0000000 --- a/lib/libc/gen/setflags.3 +++ /dev/null @@ -1,78 +0,0 @@ -.\" Copyright (c) 1989, 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. -.\" -.\" @(#)setmode.3 8.2 (Berkeley) 4/28/95 -.\" $FreeBSD$ -.\" -.Dd January 1, 2000 -.Dt SETFLAGS 3 -.Os -.Sh NAME -.Nm getflags , -.Nm setflags -.Nd modify file flag bits -.Sh SYNOPSIS -.Fd #include -.Ft char * -.Fn getflags "u_long flags" "char *def" -.Ft int -.Fn setflags "char **stringp" "u_long *setp" "u_long *clrp" -.Sh DESCRIPTION -The -.Fn getflags -function returns a comma separated string of the file flags represented by -.Fa flags . -If no flags are set the string -.Fa def -is returned instead. -.Pp -The -.Fn setflags -function takes a string of file flags, as described in -.Xr chflags 1 , -parses it, and returns the 'set' flags and 'clear' flags -such as would be given as arguments to -.Xr chflags 2 . -On success -.Fn setflags -returns 0, otherwise it returns non-zero and -.Fa stringp -is left pointing to the offending token. -.Sh SEE ALSO -.Xr chflags 1 , -.Xr chflags 2 , -.Sh HISTORY -The -.Fn getflags -and -.Fn setflags -functions first appeared in -.Fx 4.0 . diff --git a/lib/libc/gen/setflags.c b/lib/libc/gen/setflags.c deleted file mode 100644 index c1fe6c5..0000000 --- a/lib/libc/gen/setflags.c +++ /dev/null @@ -1,154 +0,0 @@ -/*- - * Copyright (c) 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. - */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)stat_flags.c 8.1 (Berkeley) 5/31/93"; -#else -static const char rcsid[] = - "$FreeBSD$"; -#endif -#endif /* not lint */ - -#include -#include - -#include -#include - -static struct { - char *name; - u_long flag; - int invert; -} mapping[] = { - /* shorter names per flag first, all prefixed by "no" */ - { "nosappnd", SF_APPEND, 0 }, - { "nosappend", SF_APPEND, 0 }, - { "noarch", SF_ARCHIVED, 0 }, - { "noarchived", SF_ARCHIVED, 0 }, - { "noschg", SF_IMMUTABLE, 0 }, - { "noschange", SF_IMMUTABLE, 0 }, - { "nosimmutable", SF_IMMUTABLE, 0 }, - { "nosunlnk", SF_NOUNLINK, 0 }, - { "nosunlink", SF_NOUNLINK, 0 }, - { "nouappnd", UF_APPEND, 0 }, - { "nouappend", UF_APPEND, 0 }, - { "nouchg", UF_IMMUTABLE, 0 }, - { "nouchange", UF_IMMUTABLE, 0 }, - { "nouimmutable", UF_IMMUTABLE, 0 }, - { "nodump", UF_NODUMP, 1 }, - { "noopaque", UF_OPAQUE, 0 }, - { "nouunlnk", UF_NOUNLINK, 0 }, - { "nouunlink", UF_NOUNLINK, 0 } -}; -#define nmappings (sizeof(mapping) / sizeof(mapping[0])) - -/* - * getflags -- - * Convert stat flags to a comma-separated string. If no flags - * are set, return the default string. - */ -char * -getflags(flags, def) - u_long flags; - char *def; -{ - static char string[128]; - char *sp, *dp; - u_long setflags; - int i; - - setflags = flags; - dp = string; - for (i = 0; i < nmappings; i++) { - if (setflags & mapping[i].flag) { - if (dp > string) - *dp++ = ','; - for (sp = mapping[i].invert ? mapping[i].name : - mapping[i].name + 2; *sp; *dp++ = *sp++) ; - setflags &= ~mapping[i].flag; - } - } - *dp = '\0'; - return (dp == string && def != NULL ? def : string); -} - -/* - * setflags -- - * Take string of arguments and return stat flags. Return 0 on - * success, 1 on failure. On failure, stringp is set to point - * to the offending token. - */ -int -setflags(stringp, setp, clrp) - char **stringp; - u_long *setp, *clrp; -{ - char *string, *p; - int i; - - if (setp) - *setp = 0; - if (clrp) - *clrp = 0; - string = *stringp; - while ((p = strsep(&string, "\t ,")) != NULL) { - *stringp = p; - if (*p == '\0') - continue; - for (i = 0; i < nmappings; i++) { - if (strcmp(p, mapping[i].name + 2) == 0) { - if (mapping[i].invert) { - if (clrp) - *clrp |= mapping[i].flag; - } else { - if (setp) - *setp |= mapping[i].flag; - } - break; - } else if (strcmp(p, mapping[i].name) == 0) { - if (mapping[i].invert) { - if (setp) - *setp |= mapping[i].flag; - } else { - if (clrp) - *clrp |= mapping[i].flag; - } - break; - } - } - if (i == nmappings) - return 1; - } - return 0; -} diff --git a/lib/libc/gen/setflagsbyname.3 b/lib/libc/gen/setflagsbyname.3 deleted file mode 100644 index 09c6208..0000000 --- a/lib/libc/gen/setflagsbyname.3 +++ /dev/null @@ -1,78 +0,0 @@ -.\" Copyright (c) 1989, 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. -.\" -.\" @(#)setmode.3 8.2 (Berkeley) 4/28/95 -.\" $FreeBSD$ -.\" -.Dd January 1, 2000 -.Dt SETFLAGS 3 -.Os -.Sh NAME -.Nm getflags , -.Nm setflags -.Nd modify file flag bits -.Sh SYNOPSIS -.Fd #include -.Ft char * -.Fn getflags "u_long flags" "char *def" -.Ft int -.Fn setflags "char **stringp" "u_long *setp" "u_long *clrp" -.Sh DESCRIPTION -The -.Fn getflags -function returns a comma separated string of the file flags represented by -.Fa flags . -If no flags are set the string -.Fa def -is returned instead. -.Pp -The -.Fn setflags -function takes a string of file flags, as described in -.Xr chflags 1 , -parses it, and returns the 'set' flags and 'clear' flags -such as would be given as arguments to -.Xr chflags 2 . -On success -.Fn setflags -returns 0, otherwise it returns non-zero and -.Fa stringp -is left pointing to the offending token. -.Sh SEE ALSO -.Xr chflags 1 , -.Xr chflags 2 , -.Sh HISTORY -The -.Fn getflags -and -.Fn setflags -functions first appeared in -.Fx 4.0 . diff --git a/lib/libc/gen/setflagsbyname.c b/lib/libc/gen/setflagsbyname.c deleted file mode 100644 index c1fe6c5..0000000 --- a/lib/libc/gen/setflagsbyname.c +++ /dev/null @@ -1,154 +0,0 @@ -/*- - * Copyright (c) 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. - */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)stat_flags.c 8.1 (Berkeley) 5/31/93"; -#else -static const char rcsid[] = - "$FreeBSD$"; -#endif -#endif /* not lint */ - -#include -#include - -#include -#include - -static struct { - char *name; - u_long flag; - int invert; -} mapping[] = { - /* shorter names per flag first, all prefixed by "no" */ - { "nosappnd", SF_APPEND, 0 }, - { "nosappend", SF_APPEND, 0 }, - { "noarch", SF_ARCHIVED, 0 }, - { "noarchived", SF_ARCHIVED, 0 }, - { "noschg", SF_IMMUTABLE, 0 }, - { "noschange", SF_IMMUTABLE, 0 }, - { "nosimmutable", SF_IMMUTABLE, 0 }, - { "nosunlnk", SF_NOUNLINK, 0 }, - { "nosunlink", SF_NOUNLINK, 0 }, - { "nouappnd", UF_APPEND, 0 }, - { "nouappend", UF_APPEND, 0 }, - { "nouchg", UF_IMMUTABLE, 0 }, - { "nouchange", UF_IMMUTABLE, 0 }, - { "nouimmutable", UF_IMMUTABLE, 0 }, - { "nodump", UF_NODUMP, 1 }, - { "noopaque", UF_OPAQUE, 0 }, - { "nouunlnk", UF_NOUNLINK, 0 }, - { "nouunlink", UF_NOUNLINK, 0 } -}; -#define nmappings (sizeof(mapping) / sizeof(mapping[0])) - -/* - * getflags -- - * Convert stat flags to a comma-separated string. If no flags - * are set, return the default string. - */ -char * -getflags(flags, def) - u_long flags; - char *def; -{ - static char string[128]; - char *sp, *dp; - u_long setflags; - int i; - - setflags = flags; - dp = string; - for (i = 0; i < nmappings; i++) { - if (setflags & mapping[i].flag) { - if (dp > string) - *dp++ = ','; - for (sp = mapping[i].invert ? mapping[i].name : - mapping[i].name + 2; *sp; *dp++ = *sp++) ; - setflags &= ~mapping[i].flag; - } - } - *dp = '\0'; - return (dp == string && def != NULL ? def : string); -} - -/* - * setflags -- - * Take string of arguments and return stat flags. Return 0 on - * success, 1 on failure. On failure, stringp is set to point - * to the offending token. - */ -int -setflags(stringp, setp, clrp) - char **stringp; - u_long *setp, *clrp; -{ - char *string, *p; - int i; - - if (setp) - *setp = 0; - if (clrp) - *clrp = 0; - string = *stringp; - while ((p = strsep(&string, "\t ,")) != NULL) { - *stringp = p; - if (*p == '\0') - continue; - for (i = 0; i < nmappings; i++) { - if (strcmp(p, mapping[i].name + 2) == 0) { - if (mapping[i].invert) { - if (clrp) - *clrp |= mapping[i].flag; - } else { - if (setp) - *setp |= mapping[i].flag; - } - break; - } else if (strcmp(p, mapping[i].name) == 0) { - if (mapping[i].invert) { - if (setp) - *setp |= mapping[i].flag; - } else { - if (clrp) - *clrp |= mapping[i].flag; - } - break; - } - } - if (i == nmappings) - return 1; - } - return 0; -} diff --git a/lib/libc/gen/sethostname.c b/lib/libc/gen/sethostname.c deleted file mode 100644 index 6c3adc3..0000000 --- a/lib/libc/gen/sethostname.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)sethostname.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#if __STDC__ -int -sethostname(const char *name, int namelen) -#else -int -sethostname(name, namelen) - char *name; - int namelen; -#endif -{ - int mib[2]; - - mib[0] = CTL_KERN; - mib[1] = KERN_HOSTNAME; - if (sysctl(mib, 2, NULL, NULL, (void *)name, namelen) == -1) - return (-1); - return (0); -} diff --git a/lib/libc/gen/setjmp.3 b/lib/libc/gen/setjmp.3 deleted file mode 100644 index 779239c..0000000 --- a/lib/libc/gen/setjmp.3 +++ /dev/null @@ -1,174 +0,0 @@ -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)setjmp.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt SETJMP 3 -.Os BSD 4 -.Sh NAME -.Nm sigsetjmp , -.Nm siglongjmp , -.Nm setjmp , -.Nm longjmp , -.Nm _setjmp , -.Nm _longjmp , -.Nm longjmperror -.Nd non-local jumps -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn sigsetjmp "sigjmp_buf env" "int savemask" -.Ft void -.Fn siglongjmp "sigjmp_buf env" "int val" -.Ft int -.Fn setjmp "jmp_buf env" -.Ft void -.Fn longjmp "jmp_buf env" "int val" -.Ft int -.Fn _setjmp "jmp_buf env" -.Ft void -.Fn _longjmp "jmp_buf env" "int val" -.Ft void -.Fn longjmperror void -.Sh DESCRIPTION -The -.Fn sigsetjmp , -.Fn setjmp , -and -.Fn _setjmp -functions save their calling environment in -.Fa env . -Each of these functions returns 0. -.Pp -The corresponding -.Fn longjmp -functions restore the environment saved by their most recent respective -invocations -of the -.Fn setjmp -function. -They then return so that program execution continues as if the corresponding -invocation of the -.Fn setjmp -call had just returned the value specified by -.Fa val , -instead of 0. -.Pp -Pairs of calls may be intermixed, i.e. both -.Fn sigsetjmp -and -.Fn siglongjmp -and -.Fn setjmp -and -.Fn longjmp -combinations may be used in the same program, however, individual -calls may not, e.g. the -.Fa env -argument to -.Fn setjmp -may not be passed to -.Fn siglongjmp . -.Pp -The -.Fn longjmp -routines may not be called after the routine which called the -.Fn setjmp -routines returns. -.Pp -All accessible objects have values as of the time -.Fn longjmp -routine was called, except that the values of objects of automatic storage -invocation duration that do not have the -.Em volatile -type and have been changed between the -.Fn setjmp -invocation and -.Fn longjmp -call are indeterminate. -.Pp -The -.Fn setjmp Ns / Ns Fn longjmp -pairs save and restore the signal mask while -.Fn _setjmp Ns / Ns Fn _longjmp -pairs save and restore only the register set and the stack. -(See -.Fn sigprocmask 2 . ) -.Pp -The -.Fn sigsetjmp Ns / Ns Fn siglongjmp -function -pairs save and restore the signal mask if the argument -.Fa savemask -is non-zero, otherwise only the register set and the stack are saved. -.Sh ERRORS -If the contents of the -.Fa env -are corrupted, or correspond to an environment that has already returned, -the -.Fn longjmp -routine calls the routine -.Fn longjmperror 3 . -If -.Fn longjmperror -returns the program is aborted (see -.Xr abort 3 ) . -The default version of -.Fn longjmperror -prints the message -.Dq Li longjmp botch -to standard error and returns. -User programs wishing to exit more gracefully should write their own -versions of -.Fn longjmperror . -.Sh SEE ALSO -.Xr sigaction 2 , -.Xr sigaltstack 2 , -.Xr signal 3 -.Sh STANDARDS -The -.Fn setjmp -and -.Fn longjmp -functions conform to -.St -ansiC . -The -.Fn sigsetjmp -and -.Fn siglongjmp -functions conform to -.St -p1003.1-88 . diff --git a/lib/libc/gen/setjmperr.c b/lib/libc/gen/setjmperr.c deleted file mode 100644 index e9b5d45..0000000 --- a/lib/libc/gen/setjmperr.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 1980, 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)setjmperr.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -/* - * This routine is called from longjmp() when an error occurs. - * Programs that wish to exit gracefully from this error may - * write their own versions. - * If this routine returns, the program is aborted. - */ - -#include -#include - -void -longjmperror() -{ -#define ERRMSG "longjmp botch.\n" - (void)_write(STDERR_FILENO, ERRMSG, sizeof(ERRMSG) - 1); -} diff --git a/lib/libc/gen/setmode.3 b/lib/libc/gen/setmode.3 deleted file mode 100644 index 20a26fe..0000000 --- a/lib/libc/gen/setmode.3 +++ /dev/null @@ -1,116 +0,0 @@ -.\" Copyright (c) 1989, 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. -.\" -.\" @(#)setmode.3 8.2 (Berkeley) 4/28/95 -.\" $FreeBSD$ -.\" -.Dd April 28, 1995 -.Dt SETMODE 3 -.Os -.Sh NAME -.Nm getmode , -.Nm setmode -.Nd modify mode bits -.Sh SYNOPSIS -.Fd #include -.Ft mode_t -.Fn getmode "const void *set" "mode_t mode" -.Ft void * -.Fn setmode "const char *mode_str" -.Sh DESCRIPTION -The -.Fn getmode -function -returns a copy of the file permission bits -.Fa mode -as altered by the values pointed to by -.Fa set . -While only the mode bits are altered, other parts of the file mode -may be examined. -.Pp -The -.Fn setmode -function -takes an absolute (octal) or symbolic value, as described in -.Xr chmod 1 , -as an argument -and returns a pointer to mode values to be supplied to -.Fn getmode . -Because some of the symbolic values are relative to the file -creation mask, -.Fn setmode -may call -.Xr umask 2 . -If this occurs, the file creation mask will be restored before -.Fn setmode -returns. -If the calling program changes the value of its file creation mask -after calling -.Fn setmode , -.Fn setmode -must be called again if -.Fn getmode -is to modify future file modes correctly. -.Pp -If the mode passed to -.Fn setmode -is invalid or if memory cannot be allocated for the return value, -.Fn setmode -returns -.Dv NULL . -.Pp -The value returned from -.Fn setmode -is obtained from -.Fn malloc -and should be returned to the system with -.Fn free -when the program is done with it, generally after a call to -.Fn getmode . -.Sh ERRORS -The -.Fn setmode -function -may fail and set errno for any of the errors specified for the library -routine -.Xr malloc 3 . -.Sh SEE ALSO -.Xr chmod 1 , -.Xr stat 2 , -.Xr umask 2 , -.Xr malloc 3 -.Sh HISTORY -The -.Fn getmode -and -.Fn setmode -functions first appeared in -.Bx 4.4 . diff --git a/lib/libc/gen/setmode.c b/lib/libc/gen/setmode.c deleted file mode 100644 index 2c12b81..0000000 --- a/lib/libc/gen/setmode.c +++ /dev/null @@ -1,457 +0,0 @@ -/* - * Copyright (c) 1989, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Dave Borman at Cray Research, 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) -#if 0 -static char sccsid[] = "@(#)setmode.c 8.2 (Berkeley) 3/25/94"; -#endif -static const char rcsid[] = - "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#include -#include -#include -#include -#include - -#ifdef SETMODE_DEBUG -#include -#endif - -#define SET_LEN 6 /* initial # of bitcmd struct to malloc */ -#define SET_LEN_INCR 4 /* # of bitcmd structs to add as needed */ - -typedef struct bitcmd { - char cmd; - char cmd2; - mode_t bits; -} BITCMD; - -#define CMD2_CLR 0x01 -#define CMD2_SET 0x02 -#define CMD2_GBITS 0x04 -#define CMD2_OBITS 0x08 -#define CMD2_UBITS 0x10 - -static BITCMD *addcmd __P((BITCMD *, int, int, int, u_int)); -static void compress_mode __P((BITCMD *)); -#ifdef SETMODE_DEBUG -static void dumpmode __P((BITCMD *)); -#endif - -/* - * Given the old mode and an array of bitcmd structures, apply the operations - * described in the bitcmd structures to the old mode, and return the new mode. - * Note that there is no '=' command; a strict assignment is just a '-' (clear - * bits) followed by a '+' (set bits). - */ -mode_t -getmode(bbox, omode) - void *bbox; - mode_t omode; -{ - register BITCMD *set; - register mode_t clrval, newmode, value; - - set = (BITCMD *)bbox; - newmode = omode; - for (value = 0;; set++) - switch(set->cmd) { - /* - * When copying the user, group or other bits around, we "know" - * where the bits are in the mode so that we can do shifts to - * copy them around. If we don't use shifts, it gets real - * grundgy with lots of single bit checks and bit sets. - */ - case 'u': - value = (newmode & S_IRWXU) >> 6; - goto common; - - case 'g': - value = (newmode & S_IRWXG) >> 3; - goto common; - - case 'o': - value = newmode & S_IRWXO; -common: if (set->cmd2 & CMD2_CLR) { - clrval = - (set->cmd2 & CMD2_SET) ? S_IRWXO : value; - if (set->cmd2 & CMD2_UBITS) - newmode &= ~((clrval<<6) & set->bits); - if (set->cmd2 & CMD2_GBITS) - newmode &= ~((clrval<<3) & set->bits); - if (set->cmd2 & CMD2_OBITS) - newmode &= ~(clrval & set->bits); - } - if (set->cmd2 & CMD2_SET) { - if (set->cmd2 & CMD2_UBITS) - newmode |= (value<<6) & set->bits; - if (set->cmd2 & CMD2_GBITS) - newmode |= (value<<3) & set->bits; - if (set->cmd2 & CMD2_OBITS) - newmode |= value & set->bits; - } - break; - - case '+': - newmode |= set->bits; - break; - - case '-': - newmode &= ~set->bits; - break; - - case 'X': - if (omode & (S_IFDIR|S_IXUSR|S_IXGRP|S_IXOTH)) - newmode |= set->bits; - break; - - case '\0': - default: -#ifdef SETMODE_DEBUG - (void)printf("getmode:%04o -> %04o\n", omode, newmode); -#endif - return (newmode); - } -} - -#define ADDCMD(a, b, c, d) \ - if (set >= endset) { \ - register BITCMD *newset; \ - setlen += SET_LEN_INCR; \ - newset = realloc(saveset, sizeof(BITCMD) * setlen); \ - if (!saveset) \ - return (NULL); \ - set = newset + (set - saveset); \ - saveset = newset; \ - endset = newset + (setlen - 2); \ - } \ - set = addcmd(set, (a), (b), (c), (d)) - -#define STANDARD_BITS (S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO) - -void * -setmode(p) - register char *p; -{ - register int perm, who; - register char op; - BITCMD *set, *saveset, *endset; - sigset_t sigset, sigoset; - mode_t mask; - int equalopdone=0, permXbits, setlen; - - if (!*p) - return (NULL); - - /* - * Get a copy of the mask for the permissions that are mask relative. - * Flip the bits, we want what's not set. Since it's possible that - * the caller is opening files inside a signal handler, protect them - * as best we can. - */ - sigfillset(&sigset); - (void)sigprocmask(SIG_BLOCK, &sigset, &sigoset); - (void)umask(mask = umask(0)); - mask = ~mask; - (void)sigprocmask(SIG_SETMASK, &sigoset, NULL); - - setlen = SET_LEN + 2; - - if ((set = malloc((u_int)(sizeof(BITCMD) * setlen))) == NULL) - return (NULL); - saveset = set; - endset = set + (setlen - 2); - - /* - * If an absolute number, get it and return; disallow non-octal digits - * or illegal bits. - */ - if (isdigit((unsigned char)*p)) { - perm = (mode_t)strtol(p, NULL, 8); - if (perm & ~(STANDARD_BITS|S_ISTXT)) { - free(saveset); - return (NULL); - } - while (*++p) - if (*p < '0' || *p > '7') { - free(saveset); - return (NULL); - } - ADDCMD('=', (STANDARD_BITS|S_ISTXT), perm, mask); - return (saveset); - } - - /* - * Build list of structures to set/clear/copy bits as described by - * each clause of the symbolic mode. - */ - for (;;) { - /* First, find out which bits might be modified. */ - for (who = 0;; ++p) { - switch (*p) { - case 'a': - who |= STANDARD_BITS; - break; - case 'u': - who |= S_ISUID|S_IRWXU; - break; - case 'g': - who |= S_ISGID|S_IRWXG; - break; - case 'o': - who |= S_IRWXO; - break; - default: - goto getop; - } - } - -getop: if ((op = *p++) != '+' && op != '-' && op != '=') { - free(saveset); - return (NULL); - } - if (op == '=') - equalopdone = 0; - - who &= ~S_ISTXT; - for (perm = 0, permXbits = 0;; ++p) { - switch (*p) { - case 'r': - perm |= S_IRUSR|S_IRGRP|S_IROTH; - break; - case 's': - /* If only "other" bits ignore set-id. */ - if (!who || who & ~S_IRWXO) - perm |= S_ISUID|S_ISGID; - break; - case 't': - /* If only "other" bits ignore sticky. */ - if (!who || who & ~S_IRWXO) { - who |= S_ISTXT; - perm |= S_ISTXT; - } - break; - case 'w': - perm |= S_IWUSR|S_IWGRP|S_IWOTH; - break; - case 'X': - permXbits = S_IXUSR|S_IXGRP|S_IXOTH; - break; - case 'x': - perm |= S_IXUSR|S_IXGRP|S_IXOTH; - break; - case 'u': - case 'g': - case 'o': - /* - * When ever we hit 'u', 'g', or 'o', we have - * to flush out any partial mode that we have, - * and then do the copying of the mode bits. - */ - if (perm) { - ADDCMD(op, who, perm, mask); - perm = 0; - } - if (op == '=') - equalopdone = 1; - if (op == '+' && permXbits) { - ADDCMD('X', who, permXbits, mask); - permXbits = 0; - } - ADDCMD(*p, who, op, mask); - break; - - default: - /* - * Add any permissions that we haven't already - * done. - */ - if (perm || (op == '=' && !equalopdone)) { - if (op == '=') - equalopdone = 1; - ADDCMD(op, who, perm, mask); - perm = 0; - } - if (permXbits) { - ADDCMD('X', who, permXbits, mask); - permXbits = 0; - } - goto apply; - } - } - -apply: if (!*p) - break; - if (*p != ',') - goto getop; - ++p; - } - set->cmd = 0; -#ifdef SETMODE_DEBUG - (void)printf("Before compress_mode()\n"); - dumpmode(saveset); -#endif - compress_mode(saveset); -#ifdef SETMODE_DEBUG - (void)printf("After compress_mode()\n"); - dumpmode(saveset); -#endif - return (saveset); -} - -static BITCMD * -addcmd(set, op, who, oparg, mask) - BITCMD *set; - register int oparg, who; - register int op; - u_int mask; -{ - switch (op) { - case '=': - set->cmd = '-'; - set->bits = who ? who : STANDARD_BITS; - set++; - - op = '+'; - /* FALLTHROUGH */ - case '+': - case '-': - case 'X': - set->cmd = op; - set->bits = (who ? who : mask) & oparg; - break; - - case 'u': - case 'g': - case 'o': - set->cmd = op; - if (who) { - set->cmd2 = ((who & S_IRUSR) ? CMD2_UBITS : 0) | - ((who & S_IRGRP) ? CMD2_GBITS : 0) | - ((who & S_IROTH) ? CMD2_OBITS : 0); - set->bits = ~0; - } else { - set->cmd2 = CMD2_UBITS | CMD2_GBITS | CMD2_OBITS; - set->bits = mask; - } - - if (oparg == '+') - set->cmd2 |= CMD2_SET; - else if (oparg == '-') - set->cmd2 |= CMD2_CLR; - else if (oparg == '=') - set->cmd2 |= CMD2_SET|CMD2_CLR; - break; - } - return (set + 1); -} - -#ifdef SETMODE_DEBUG -static void -dumpmode(set) - register BITCMD *set; -{ - for (; set->cmd; ++set) - (void)printf("cmd: '%c' bits %04o%s%s%s%s%s%s\n", - set->cmd, set->bits, set->cmd2 ? " cmd2:" : "", - set->cmd2 & CMD2_CLR ? " CLR" : "", - set->cmd2 & CMD2_SET ? " SET" : "", - set->cmd2 & CMD2_UBITS ? " UBITS" : "", - set->cmd2 & CMD2_GBITS ? " GBITS" : "", - set->cmd2 & CMD2_OBITS ? " OBITS" : ""); -} -#endif - -/* - * Given an array of bitcmd structures, compress by compacting consecutive - * '+', '-' and 'X' commands into at most 3 commands, one of each. The 'u', - * 'g' and 'o' commands continue to be separate. They could probably be - * compacted, but it's not worth the effort. - */ -static void -compress_mode(set) - register BITCMD *set; -{ - register BITCMD *nset; - register int setbits, clrbits, Xbits, op; - - for (nset = set;;) { - /* Copy over any 'u', 'g' and 'o' commands. */ - while ((op = nset->cmd) != '+' && op != '-' && op != 'X') { - *set++ = *nset++; - if (!op) - return; - } - - for (setbits = clrbits = Xbits = 0;; nset++) { - if ((op = nset->cmd) == '-') { - clrbits |= nset->bits; - setbits &= ~nset->bits; - Xbits &= ~nset->bits; - } else if (op == '+') { - setbits |= nset->bits; - clrbits &= ~nset->bits; - Xbits &= ~nset->bits; - } else if (op == 'X') - Xbits |= nset->bits & ~setbits; - else - break; - } - if (clrbits) { - set->cmd = '-'; - set->cmd2 = 0; - set->bits = clrbits; - set++; - } - if (setbits) { - set->cmd = '+'; - set->cmd2 = 0; - set->bits = setbits; - set++; - } - if (Xbits) { - set->cmd = 'X'; - set->cmd2 = 0; - set->bits = Xbits; - set++; - } - } -} diff --git a/lib/libc/gen/setproctitle.3 b/lib/libc/gen/setproctitle.3 deleted file mode 100644 index 10eae65..0000000 --- a/lib/libc/gen/setproctitle.3 +++ /dev/null @@ -1,101 +0,0 @@ -.\" Copyright (c) 1995 Peter Wemm -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, is permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice immediately at the beginning of the file, without modification, -.\" this list of conditions, and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. This work was done expressly for inclusion into FreeBSD. Other use -.\" is permitted provided this notation is included. -.\" 4. Absolutely no warranty of function or purpose is made by the author -.\" Peter Wemm. -.\" 5. Modifications may be freely made to this file providing the above -.\" conditions are met. -.\" -.\" $FreeBSD$ -.\" -.\" The following requests are required for all man pages. -.Dd December 16, 1995 -.Os FreeBSD -.Dt SETPROCTITLE 3 -.Sh NAME -.Nm setproctitle -.Nd set the process title for -.Xr ps 1 -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Ft void -.Fn setproctitle "const char *fmt" "..." -.Pp -Link with -.Va -lutil -on the -.Xr cc 1 -command line. -.Sh DESCRIPTION -The -.Fn setproctitle -library routine sets the process title that appears on the -.Xr ps 1 -command. -.Pp -The title is set from the executable's name, followed by the -result of a -.Xr printf 3 -style expansion of the arguments as specified by the -.Va fmt -argument. -.Pp -If -.Va fmt -is NULL, the process title is restored. -.Sh EXAMPLES -To set the title on a daemon to indicate its activity: -.Bd -literal -offset indent -setproctitle("talking to %s", inet_ntoa(addr)); -.Ed -.Sh SEE ALSO -.Xr ps 1 , -.Xr w 1 , -.Xr kvm 3 , -.Xr kvm_getargv 3 , -.Xr printf 3 -.Sh STANDARDS -.Fn setproctitle -is implicitly non-standard. Other methods of causing the -.Xr ps 1 -command line to change, including copying over the argv[0] string are -also implicitly non-portable. It is preferable to use an operating system -supplied -.Fn setproctitle -if present. -.Pp -Unfortunately, it is possible that there are other calling conventions -to other versions of -.Fn setproctitle , -although none have been found by the author as yet. This is believed to be -the predominant convention. -.Pp -It is thought that the implementation is compatible with other systems, -including -.Nx -and -.Tn BSD/OS . -.Sh HISTORY -.Fn setproctitle -first appeared in -.Fx 2.2 . -Other operating systems have -similar functions. -.Sh AUTHORS -.An Peter Wemm Aq peter@FreeBSD.org -stole the idea from the -.Sy "Sendmail 8.7.3" -source code by -.An Eric Allman Aq eric@sendmail.org . diff --git a/lib/libc/gen/setproctitle.c b/lib/libc/gen/setproctitle.c deleted file mode 100644 index 37b9fab..0000000 --- a/lib/libc/gen/setproctitle.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 1995 Peter Wemm - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, is permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice immediately at the beginning of the file, without modification, - * this list of conditions, and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Absolutely no warranty of function or purpose is made by the author - * Peter Wemm. - * - * $FreeBSD$ - */ - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -/* - * Older FreeBSD 2.0, 2.1 and 2.2 had different ps_strings structures and - * in different locations. - * 1: old_ps_strings at the very top of the stack. - * 2: old_ps_strings at SPARE_USRSPACE below the top of the stack. - * 3: ps_strings at the very top of the stack. - * This attempts to support a kernel built in the #2 and #3 era. - */ - -struct old_ps_strings { - char *old_ps_argvstr; - int old_ps_nargvstr; - char *old_ps_envstr; - int old_ps_nenvstr; -}; -#define OLD_PS_STRINGS ((struct old_ps_strings *) \ - (USRSTACK - SPARE_USRSPACE - sizeof(struct old_ps_strings))) - -#if defined(__STDC__) /* from other parts of sendmail */ -#include -#else -#include -#endif - - -#define SPT_BUFSIZE 2048 /* from other parts of sendmail */ -extern char * __progname; /* is this defined in a .h anywhere? */ - -void -#if defined(__STDC__) -setproctitle(const char *fmt, ...) -#else -setproctitle(fmt, va_alist) - const char *fmt; - va_dcl -#endif -{ - static struct ps_strings *ps_strings; - static char buf[SPT_BUFSIZE]; - static char obuf[SPT_BUFSIZE]; - static char **oargv, *kbuf; - static int oargc = -1; - static char *nargv[2] = { buf, NULL }; - char **nargvp; - int nargc; - va_list ap; - size_t len; - unsigned long ul_ps_strings; - int oid[4]; - -#if defined(__STDC__) - va_start(ap, fmt); -#else - va_start(ap); -#endif - - if (fmt) { - buf[sizeof(buf) - 1] = '\0'; - - /* print program name heading for grep */ - (void) snprintf(buf, sizeof(buf), "%s: ", __progname); - - /* - * can't use return from sprintf, as that is the count of how - * much it wanted to write, not how much it actually did. - */ - - len = strlen(buf); - - /* print the argument string */ - (void) vsnprintf(buf + len, sizeof(buf) - len, fmt, ap); - - nargvp = nargv; - nargc = 1; - kbuf = buf; - } else if (*obuf != '\0') { - /* Idea from NetBSD - reset the title on fmt == NULL */ - nargvp = oargv; - nargc = oargc; - kbuf = obuf; - } else - /* Nothing to restore */ - return; - - va_end(ap); - - /* Set the title into the kernel cached command line */ - oid[0] = CTL_KERN; - oid[1] = KERN_PROC; - oid[2] = KERN_PROC_ARGS; - oid[3] = getpid(); - sysctl(oid, 4, 0, 0, kbuf, strlen(kbuf) + 1); - - if (ps_strings == NULL) { - len = sizeof(ul_ps_strings); - if (sysctlbyname("kern.ps_strings", &ul_ps_strings, &len, NULL, - 0) == -1) - ul_ps_strings = PS_STRINGS; - ps_strings = (struct ps_strings *)ul_ps_strings; - } - - /* PS_STRINGS points to zeroed memory on a style #2 kernel */ - if (ps_strings->ps_argvstr) { - /* style #3 */ - if (oargc == -1) { - /* Record our original args */ - oargc = ps_strings->ps_nargvstr; - oargv = ps_strings->ps_argvstr; - for (nargc = len = 0; nargc < oargc; nargc++) { - snprintf(obuf + len, sizeof(obuf) - len, "%s%s", - len ? " " : "", oargv[nargc]); - if (len) - len++; - len += strlen(oargv[nargc]); - if (len >= sizeof(obuf)) - break; - } - } - ps_strings->ps_nargvstr = nargc; - ps_strings->ps_argvstr = nargvp; - } else { - /* style #2 - we can only restore our first arg :-( */ - if (*obuf == '\0') - strncpy(obuf, OLD_PS_STRINGS->old_ps_argvstr, - sizeof(obuf) - 1); - OLD_PS_STRINGS->old_ps_nargvstr = 1; - OLD_PS_STRINGS->old_ps_argvstr = nargvp[0]; - } -} diff --git a/lib/libc/gen/shmat.c b/lib/libc/gen/shmat.c deleted file mode 100644 index 45b9143..0000000 --- a/lib/libc/gen/shmat.c +++ /dev/null @@ -1,19 +0,0 @@ -#if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#if __STDC__ -void *shmat(int shmid, void *shmaddr, int shmflg) -#else -void *shmat(shmid, shmaddr, shmflg) - int shmid; - void *shmaddr; - int shmflg; -#endif -{ - return ((void *)shmsys(0, shmid, shmaddr, shmflg)); -} diff --git a/lib/libc/gen/shmctl.c b/lib/libc/gen/shmctl.c deleted file mode 100644 index eae9fbb..0000000 --- a/lib/libc/gen/shmctl.c +++ /dev/null @@ -1,19 +0,0 @@ -#if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#if __STDC__ -int shmctl(int shmid, int cmd, struct shmid_ds *buf) -#else -int shmctl(shmid, cmd, buf) - int shmid; - int cmd; - struct shmid_ds *buf; -#endif -{ - return (shmsys(4, shmid, cmd, buf)); -} diff --git a/lib/libc/gen/shmdt.c b/lib/libc/gen/shmdt.c deleted file mode 100644 index f39ad18..0000000 --- a/lib/libc/gen/shmdt.c +++ /dev/null @@ -1,17 +0,0 @@ -#if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#if __STDC__ -int shmdt(void *shmaddr) -#else -int shmdt(shmaddr) - void *shmaddr; -#endif -{ - return (shmsys(2, shmaddr)); -} diff --git a/lib/libc/gen/shmget.c b/lib/libc/gen/shmget.c deleted file mode 100644 index 8976d1c..0000000 --- a/lib/libc/gen/shmget.c +++ /dev/null @@ -1,19 +0,0 @@ -#if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#if __STDC__ -int shmget(key_t key, int size, int shmflg) -#else -int shmget(key, size, shmflg) - key_t key; - int size; - int shmflg; -#endif -{ - return (shmsys(3, key, size, shmflg)); -} diff --git a/lib/libc/gen/siginterrupt.3 b/lib/libc/gen/siginterrupt.3 deleted file mode 100644 index ffce99c..0000000 --- a/lib/libc/gen/siginterrupt.3 +++ /dev/null @@ -1,112 +0,0 @@ -.\" Copyright (c) 1985, 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. -.\" -.\" @(#)siginterrupt.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt SIGINTERRUPT 3 -.Os BSD 4.3 -.Sh NAME -.Nm siginterrupt -.Nd allow signals to interrupt system calls -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn siginterrupt "int sig" "int flag" -.Sh DESCRIPTION -The -.Fn siginterrupt -function -is used to change the system call restart -behavior when a system call is interrupted by the specified signal. -If the flag is false (0), then system calls will be restarted if -they are interrupted by the specified signal -and no data has been transferred yet. -System call restart has been the default behavior since -.Bx 4.2 , -and is the default behaviour for -.Xr signal 3 -on -.Tn FreeBSD . -.Pp -If the flag is true (1), -then restarting of system calls is disabled. -If a system call is interrupted by the specified signal -and no data has been transferred, -the system call will return \-1 with the global variable -.Va errno -set to -.Dv EINTR . -Interrupted system calls that have started transferring -data will return the amount of data actually transferred. -System call interrupt is the signal behavior found on -.Bx 4.1 -and -.At V -systems. -.Pp -Note that the new -.Bx 4.2 -signal handling semantics are not -altered in any other way. -Most notably, signal handlers always remain installed until -explicitly changed by a subsequent -.Xr sigaction 2 -call, and the signal mask operates as documented in -.Xr sigaction 2 . -Programs may switch between restartable and interruptible -system call operation as often as desired in the execution of a program. -.Pp -Issuing a -.Fn siginterrupt 3 -call during the execution of a signal handler will cause -the new action to take place on the next signal to be caught. -.Sh NOTES -This library routine uses an extension of the -.Xr sigaction 2 -system call that is not available in -.Bx 4.2 , -hence it should not be used if backward compatibility is needed. -.Sh RETURN VALUES -A 0 value indicates that the call succeeded. -A \-1 value indicates that an invalid signal number has been supplied. -.Sh SEE ALSO -.Xr sigaction 2 , -.Xr sigblock 2 , -.Xr sigpause 2 , -.Xr sigsetmask 2 , -.Xr signal 3 -.Sh HISTORY -The -.Fn siginterrupt -function appeared in -.Bx 4.3 . diff --git a/lib/libc/gen/siginterrupt.c b/lib/libc/gen/siginterrupt.c deleted file mode 100644 index 06960ab..0000000 --- a/lib/libc/gen/siginterrupt.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)siginterrupt.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -/* - * Set signal state to prevent restart of system calls - * after an instance of the indicated signal. - */ -int -siginterrupt(sig, flag) - int sig, flag; -{ - extern sigset_t _sigintr; - struct sigaction sa; - int ret; - - if ((ret = sigaction(sig, (struct sigaction *)0, &sa)) < 0) - return (ret); - if (flag) { - sigaddset(&_sigintr, sig); - sa.sa_flags &= ~SA_RESTART; - } else { - sigdelset(&_sigintr, sig); - sa.sa_flags |= SA_RESTART; - } - return (sigaction(sig, &sa, (struct sigaction *)0)); -} diff --git a/lib/libc/gen/siglist.c b/lib/libc/gen/siglist.c deleted file mode 100644 index e6987d5..0000000 --- a/lib/libc/gen/siglist.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)siglist.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -const char *const sys_signame[NSIG] = { - "Signal 0", - "hup", /* SIGHUP */ - "int", /* SIGINT */ - "quit", /* SIGQUIT */ - "ill", /* SIGILL */ - "trap", /* SIGTRAP */ - "abrt", /* SIGABRT */ - "emt", /* SIGEMT */ - "fpe", /* SIGFPE */ - "kill", /* SIGKILL */ - "bus", /* SIGBUS */ - "segv", /* SIGSEGV */ - "sys", /* SIGSYS */ - "pipe", /* SIGPIPE */ - "alrm", /* SIGALRM */ - "term", /* SIGTERM */ - "urg", /* SIGURG */ - "stop", /* SIGSTOP */ - "tstp", /* SIGTSTP */ - "cont", /* SIGCONT */ - "chld", /* SIGCHLD */ - "ttin", /* SIGTTIN */ - "ttou", /* SIGTTOU */ - "io", /* SIGIO */ - "xcpu", /* SIGXCPU */ - "xfsz", /* SIGXFSZ */ - "vtalrm", /* SIGVTALRM */ - "prof", /* SIGPROF */ - "winch", /* SIGWINCH */ - "info", /* SIGINFO */ - "usr1", /* SIGUSR1 */ - "usr2", /* SIGUSR2 */ -}; - -const char *const sys_siglist[NSIG] = { - "Signal 0", - "Hangup", /* SIGHUP */ - "Interrupt", /* SIGINT */ - "Quit", /* SIGQUIT */ - "Illegal instruction", /* SIGILL */ - "Trace/BPT trap", /* SIGTRAP */ - "Abort trap", /* SIGABRT */ - "EMT trap", /* SIGEMT */ - "Floating point exception", /* SIGFPE */ - "Killed", /* SIGKILL */ - "Bus error", /* SIGBUS */ - "Segmentation fault", /* SIGSEGV */ - "Bad system call", /* SIGSYS */ - "Broken pipe", /* SIGPIPE */ - "Alarm clock", /* SIGALRM */ - "Terminated", /* SIGTERM */ - "Urgent I/O condition", /* SIGURG */ - "Suspended (signal)", /* SIGSTOP */ - "Suspended", /* SIGTSTP */ - "Continued", /* SIGCONT */ - "Child exited", /* SIGCHLD */ - "Stopped (tty input)", /* SIGTTIN */ - "Stopped (tty output)", /* SIGTTOU */ - "I/O possible", /* SIGIO */ - "Cputime limit exceeded", /* SIGXCPU */ - "Filesize limit exceeded", /* SIGXFSZ */ - "Virtual timer expired", /* SIGVTALRM */ - "Profiling timer expired", /* SIGPROF */ - "Window size changes", /* SIGWINCH */ - "Information request", /* SIGINFO */ - "User defined signal 1", /* SIGUSR1 */ - "User defined signal 2" /* SIGUSR2 */ -}; -const int sys_nsig = sizeof(sys_siglist) / sizeof(sys_siglist[0]); diff --git a/lib/libc/gen/signal.3 b/lib/libc/gen/signal.3 deleted file mode 100644 index 589331f..0000000 --- a/lib/libc/gen/signal.3 +++ /dev/null @@ -1,233 +0,0 @@ -.\" Copyright (c) 1980, 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.3 8.3 (Berkeley) 4/19/94 -.\" $FreeBSD$ -.\" -.Dd April 19, 1994 -.Dt SIGNAL 3 -.Os BSD 4 -.Sh NAME -.Nm signal -.Nd simplified software signal facilities -.Sh SYNOPSIS -.Fd #include -.\" The following is Quite Ugly, but syntactically correct. Don't try to -.\" fix it. -.Ft void \*(lp* -.Fn signal "int sig" "void \*(lp*func\*(rp\*(lpint\*(rp\*(rp\*(rp\*(lpint" - -or in FreeBSD's equivalent but easier to read typedef'd version: -.Ft typedef "void \*(lp*sig_t\*(rp \*(lpint\*(rp" -.Ft sig_t -.Fn signal "int sig" "sig_t func" -.Sh DESCRIPTION -This -.Fn signal -facility -is a simplified interface to the more general -.Xr sigaction 2 -facility. -.Pp -Signals allow the manipulation of a process from outside its -domain as well as allowing the process to manipulate itself or -copies of itself (children). There are two general types of signals: -those that cause termination of a process and those that do not. -Signals which cause termination of a program might result from -an irrecoverable error or might be the result of a user at a terminal -typing the `interrupt' character. -Signals are used when a process is stopped because it wishes to access -its control terminal while in the background (see -.Xr tty 4 ) . -Signals are optionally generated -when a process resumes after being stopped, -when the status of child processes changes, -or when input is ready at the control terminal. -Most signals result in the termination of the process receiving them -if no action -is taken; some signals instead cause the process receiving them -to be stopped, or are simply discarded if the process has not -requested otherwise. -Except for the -.Dv SIGKILL -and -.Dv SIGSTOP -signals, the -.Fn signal -function allows for a signal to be caught, to be ignored, or to generate -an interrupt. -These signals are defined in the file -.Aq Pa signal.h : -.Bl -column SIGVTALARMXX "create core imagexxx" -.It Sy Name Default Action Description -.It Dv SIGHUP Ta "terminate process" Ta "terminal line hangup" -.It Dv SIGINT Ta "terminate process" Ta "interrupt program" -.It Dv SIGQUIT Ta "create core image" Ta "quit program" -.It Dv SIGILL Ta "create core image" Ta "illegal instruction" -.It Dv SIGTRAP Ta "create core image" Ta "trace trap" -.It Dv SIGABRT Ta "create core image" Ta Xr abort 2 -call (formerly -.Dv SIGIOT ) -.It Dv SIGEMT Ta "create core image" Ta "emulate instruction executed" -.It Dv SIGFPE Ta "create core image" Ta "floating-point exception" -.It Dv SIGKILL Ta "terminate process" Ta "kill program" -.It Dv SIGBUS Ta "create core image" Ta "bus error" -.It Dv SIGSEGV Ta "create core image" Ta "segmentation violation" -.It Dv SIGSYS Ta "create core image" Ta "non-existent system call invoked" -.It Dv SIGPIPE Ta "terminate process" Ta "write on a pipe with no reader" -.It Dv SIGALRM Ta "terminate process" Ta "real-time timer expired" -.It Dv SIGTERM Ta "terminate process" Ta "software termination signal" -.It Dv SIGURG Ta "discard signal" Ta "urgent condition present on socket" -.It Dv SIGSTOP Ta "stop process" Ta "stop (cannot be caught or ignored)" -.It Dv SIGTSTP Ta "stop process" Ta "stop signal generated from keyboard" -.It Dv SIGCONT Ta "discard signal" Ta "continue after stop" -.It Dv SIGCHLD Ta "discard signal" Ta "child status has changed" -.It Dv SIGTTIN Ta "stop process" Ta "background read attempted from control terminal" -.It Dv SIGTTOU Ta "stop process" Ta "background write attempted to control terminal" -.It Dv SIGIO Ta "discard signal" Ta Tn "I/O" -is possible on a descriptor (see -.Xr fcntl 2 ) -.It Dv SIGXCPU Ta "terminate process" Ta "cpu time limit exceeded (see" -.Xr setrlimit 2 ) -.It Dv SIGXFSZ Ta "terminate process" Ta "file size limit exceeded (see" -.Xr setrlimit 2 ) -.It Dv SIGVTALRM Ta "terminate process" Ta "virtual time alarm (see" -.Xr setitimer 2 ) -.It Dv SIGPROF Ta "terminate process" Ta "profiling timer alarm (see" -.Xr setitimer 2 ) -.It Dv SIGWINCH Ta "discard signal" Ta "Window size change" -.It Dv SIGINFO Ta "discard signal" Ta "status request from keyboard" -.It Dv SIGUSR1 Ta "terminate process" Ta "User defined signal 1" -.It Dv SIGUSR2 Ta "terminate process" Ta "User defined signal 2" -.El -.Pp -The -.Fa sig -parameter specifies which signal was received. -The -.Fa func -procedure allows a user to choose the action upon receipt of a signal. -To set the default action of the signal to occur as listed above, -.Fa func -should be -.Dv SIG_DFL . -A -.Dv SIG_DFL -resets the default action. -To ignore the signal -.Fa func -should be -.Dv SIG_IGN . -This will cause subsequent instances of the signal to be ignored -and pending instances to be discarded. -If -.Dv SIG_IGN -is not used, -further occurrences of the signal are -automatically blocked and -.Fa func -is called. -.Pp -The handled signal is unblocked when the -function returns and -the process continues from where it left off when the signal occurred. -.Bf -symbolic -Unlike previous signal facilities, the handler -func() remains installed after a signal has been delivered. -.Ef -.Pp -For some system calls, if a signal is caught while the call is -executing and the call is prematurely terminated, -the call is automatically restarted. -(The handler is installed using the -.Dv SA_RESTART -flag with -.Xr sigaction 2 . ) -The affected system calls include -.Xr read 2 , -.Xr write 2 , -.Xr sendto 2 , -.Xr recvfrom 2 , -.Xr sendmsg 2 -and -.Xr recvmsg 2 -on a communications channel or a low speed device -and during a -.Xr ioctl 2 -or -.Xr wait 2 . -However, calls that have already committed are not restarted, -but instead return a partial success (for example, a short read count). -This semantics could be changed with -.Xr siginterrupt 3 . -.Pp -When a process which has installed signal handlers forks, -the child process inherits the signals. -All caught signals may be reset to their default action by a call -to the -.Xr execve 2 -function; -ignored signals remain ignored. -.Sh RETURN VALUES -The previous action is returned on a successful call. -Otherwise, SIG_ERR is returned and the global variable -.Va errno -is set to indicate the error. -.Sh ERRORS -.Fn Signal -will fail and no action will take place if one of the -following occur: -.Bl -tag -width [EINVAL] -.It Bq Er EINVAL -.Em Sig -is not a valid signal number. -.It Bq Er EINVAL -An attempt is made to ignore or supply a handler for -.Dv SIGKILL -or -.Ev SIGSTOP . -.Sh SEE ALSO -.Xr kill 1 , -.Xr kill 2 , -.Xr ptrace 2 , -.Xr sigaction 2 , -.Xr sigaltstack 2 , -.Xr sigprocmask 2 , -.Xr sigsuspend 2 , -.Xr fpsetmask 3 , -.Xr setjmp 3 , -.Xr siginterrupt 3 , -.Xr tty 4 -.Sh HISTORY -This -.Nm signal -facility appeared in -.Bx 4.0 . diff --git a/lib/libc/gen/signal.c b/lib/libc/gen/signal.c deleted file mode 100644 index c4057f5..0000000 --- a/lib/libc/gen/signal.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 1985, 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)signal.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -/* - * Almost backwards compatible signal. - */ -#include - -sigset_t _sigintr; /* shared with siginterrupt */ - -sig_t -signal(s, a) - int s; - sig_t a; -{ - struct sigaction sa, osa; - - sa.sa_handler = a; - sigemptyset(&sa.sa_mask); - sa.sa_flags = 0; - if (!sigismember(&_sigintr, s)) - sa.sa_flags |= SA_RESTART; - if (sigaction(s, &sa, &osa) < 0) - return (SIG_ERR); - return (osa.sa_handler); -} diff --git a/lib/libc/gen/sigsetops.3 b/lib/libc/gen/sigsetops.3 deleted file mode 100644 index a32daf6..0000000 --- a/lib/libc/gen/sigsetops.3 +++ /dev/null @@ -1,114 +0,0 @@ -.\" Copyright (c) 1983, 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. -.\" -.\" @(#)sigsetops.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt SIGSETOPS 3 -.Os -.Sh NAME -.Nm sigemptyset , -.Nm sigfillset , -.Nm sigaddset , -.Nm sigdelset , -.Nm sigismember -.Nd manipulate signal sets -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn sigemptyset "sigset_t *set" -.Ft int -.Fn sigfillset "sigset_t *set" -.Ft int -.Fn sigaddset "sigset_t *set" "int signo" -.Ft int -.Fn sigdelset "sigset_t *set" "int signo" -.Ft int -.Fn sigismember "const sigset_t *set" "int signo" -.Sh DESCRIPTION -These functions manipulate signal sets stored in a -.Fa sigset_t . -Either -.Fn sigemptyset -or -.Fn sigfillset -must be called for every object of type -.Fa sigset_t -before any other use of the object. -.Pp -The -.Fn sigemptyset -function initializes a signal set to be empty. -.Pp -The -.Fn sigfillset -function initializes a signal set to contain all signals. -.Pp -The -.Fn sigaddset -function adds the specified signal -.Fa signo -to the signal set. -.Pp -The -.Fn sigdelset -function deletes the specified signal -.Fa signo -from the signal set. -.Pp -The -.Fn sigismember -function returns whether a specified signal -.Fa signo -is contained in the signal set. -.Pp -These functions -are provided as macros in the include file . -Actual functions are available -if their names are undefined (with #undef -.Em name ) . -.Sh RETURN VALUES -The -.Fn sigismember -function returns 1 -if the signal is a member of the set, -0 otherwise. -The other functions return 0. -.Sh ERRORS -Currently no errors are detected. -.Sh SEE ALSO -.Xr kill 2 , -.Xr sigaction 2 , -.Xr sigsuspend 2 -.Sh STANDARDS -These functions are defined by -.St -p1003.1-88 . diff --git a/lib/libc/gen/sigsetops.c b/lib/libc/gen/sigsetops.c deleted file mode 100644 index ffba20c..0000000 --- a/lib/libc/gen/sigsetops.c +++ /dev/null @@ -1,108 +0,0 @@ -/*- - * 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. - * - * @(#)sigsetops.c 8.1 (Berkeley) 6/4/93 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)sigsetops.c 8.1 (Berkeley) 6/4/93"; -#endif -static const char rcsid[] = - "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -int -sigaddset(set, signo) - sigset_t *set; - int signo; -{ - - if (signo <= 0 || signo > _SIG_MAXSIG) { - errno = EINVAL; - return (-1); - } - set->__bits[_SIG_WORD(signo)] |= _SIG_BIT(signo); - return (0); -} - -int -sigdelset(set, signo) - sigset_t *set; - int signo; -{ - - if (signo <= 0 || signo > _SIG_MAXSIG) { - errno = EINVAL; - return (-1); - } - set->__bits[_SIG_WORD(signo)] &= ~_SIG_BIT(signo); - return (0); -} - -int -sigemptyset(set) - sigset_t *set; -{ - int i; - - for (i = 0; i < _SIG_WORDS; i++) - set->__bits[i] = 0; - return (0); -} - -int -sigfillset(set) - sigset_t *set; -{ - int i; - - for (i = 0; i < _SIG_WORDS; i++) - set->__bits[i] = ~0U; - return (0); -} - -int -sigismember(set, signo) - const sigset_t *set; - int signo; -{ - - if (signo <= 0 || signo > _SIG_MAXSIG) { - errno = EINVAL; - return (-1); - } - return ((set->__bits[_SIG_WORD(signo)] & _SIG_BIT(signo)) ? 1 : 0); -} diff --git a/lib/libc/gen/sleep.3 b/lib/libc/gen/sleep.3 deleted file mode 100644 index e59aad5..0000000 --- a/lib/libc/gen/sleep.3 +++ /dev/null @@ -1,84 +0,0 @@ -.\" Copyright (c) 1986, 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. -.\" -.\" @(#)sleep.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd Feb 13, 1998 -.Dt SLEEP 3 -.Os -.Sh NAME -.Nm sleep -.Nd suspend process execution for an interval measured in seconds -.Sh SYNOPSIS -.Fd #include -.Ft unsigned int -.Fn sleep "unsigned int seconds" -.Sh DESCRIPTION -The -.Fn sleep -function suspends execution of the calling process until either -.Fa seconds -seconds have elapsed or a signal is delivered to the process and its -action is to invoke a signal-catching function or to terminate the -process. -System activity may lengthen the sleep by an indeterminate amount. -.Pp -This function is implemented using -.Xr nanosleep 2 -by pausing for -.Fa seconds -seconds or until a signal occurs. -Consequently, in this implementation, -sleeping has no effect on the state of process timers, -and there is no special handling for SIGALRM. -.Sh RETURN VALUES -If the -.Fn sleep -function returns because the requested time has elapsed, the value -returned will be zero. If the -.Fn sleep -function returns due to the delivery of a signal, the value returned -will be the unslept amount (the requested time minus the time actually -slept) in seconds. -.Sh SEE ALSO -.Xr nanosleep 2 , -.Xr usleep 3 -.Sh STANDARDS -The -.Fn sleep -function conforms to -.St -p1003.1-90 . -.Sh HISTORY -A -.Fn sleep -function appeared in -.At v7 . diff --git a/lib/libc/gen/sleep.c b/lib/libc/gen/sleep.c deleted file mode 100644 index e4c4fbd..0000000 --- a/lib/libc/gen/sleep.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)sleep.c 8.1 (Berkeley) 6/4/93"; -#endif -static char rcsid[] = - "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -unsigned int -__sleep(seconds) - unsigned int seconds; -{ - struct timespec time_to_sleep; - struct timespec time_remaining; - - /* - * Avoid overflow when `seconds' is huge. This assumes that - * the maximum value for a time_t is >= INT_MAX. - */ - if (seconds > INT_MAX) - return (seconds - INT_MAX + __sleep(INT_MAX)); - - time_to_sleep.tv_sec = seconds; - time_to_sleep.tv_nsec = 0; - if (_nanosleep(&time_to_sleep, &time_remaining) != -1) - return (0); - if (errno != EINTR) - return (seconds); /* best guess */ - return (time_remaining.tv_sec + - (time_remaining.tv_nsec != 0)); /* round up */ -} - -#ifndef _THREAD_SAFE -__weak_reference(__sleep, sleep); -#endif diff --git a/lib/libc/gen/srand48.c b/lib/libc/gen/srand48.c deleted file mode 100644 index fd369a0..0000000 --- a/lib/libc/gen/srand48.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 1993 Martin Birgmeier - * All rights reserved. - * - * You may redistribute unmodified or modified versions of this source - * code provided that the above copyright notice and this and the - * following conditions are retained. - * - * This software is provided ``as is'', and comes with no warranties - * of any kind. I shall in no event be liable for anything that happens - * to anyone/anything when using this software. - */ - -#include "rand48.h" - -extern unsigned short _rand48_seed[3]; -extern unsigned short _rand48_mult[3]; -extern unsigned short _rand48_add; - -void -srand48(long seed) -{ - _rand48_seed[0] = RAND48_SEED_0; - _rand48_seed[1] = (unsigned short) seed; - _rand48_seed[2] = (unsigned short) (seed >> 16); - _rand48_mult[0] = RAND48_MULT_0; - _rand48_mult[1] = RAND48_MULT_1; - _rand48_mult[2] = RAND48_MULT_2; - _rand48_add = RAND48_ADD; -} diff --git a/lib/libc/gen/stringlist.3 b/lib/libc/gen/stringlist.3 deleted file mode 100644 index 21fb2db..0000000 --- a/lib/libc/gen/stringlist.3 +++ /dev/null @@ -1,122 +0,0 @@ -.\" $NetBSD: stringlist.3,v 1.2 1997/04/09 08:59:25 kleink Exp $ -.\" -.\" Copyright (c) 1997 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This file was contributed to The NetBSD Foundation by Luke Mewburn. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the NetBSD -.\" Foundation, Inc. and its contributors. -.\" 4. Neither the name of The NetBSD Foundation nor the names of its -.\" contributors may be used to endorse or promote products derived -.\" from this software without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd February 24, 1997 -.Os NetBSD 1.3 -.Dt STRINGLIST 3 -.Sh NAME -.Nm stringlist , -.Nm sl_init , -.Nm sl_add , -.Nm sl_free , -.Nm sl_find -.Nd stringlist manipulation functions -.Sh SYNOPSIS -.Fd #include -.Ft StringList * -.Fn sl_init -.Ft void -.Fn sl_add "StringList *sl" "char *item" -.Ft void -.Fn sl_free "StringList *sl" "int freeall" -.Ft char * -.Fn sl_find "StringList *sl" "char *item" -.Sh DESCRIPTION -The -.Nm -functions manipulate stringlists, which are lists of -strings that extend automatically if necessary. -.Pp -The -.Ar StringList -structure has the following definition: -.Bd -literal -offset indent -typedef struct _stringlist { - char **sl_str; - size_t sl_max; - size_t sl_cur; -} StringList; -.Ed -.Pp -.Bl -tag -width "sl_str" -offset indent -.It Ar sl_str -a pointer to the base of the array containing the list. -.It Ar sl_max -the size of -.Ar sl_str . -.It Ar sl_cur -the offset in -.Ar sl_str -of the current element. -.El -.Pp -The following stringlist manipulation functions are available: -.Bl -tag -width "sl_init()" -.It Fn sl_init -Create a stringlist. -Returns a pointer to a -.Ar StringList . -.It Fn sl_free -Releases memory occupied by -.Ar sl -and the -.Ar sl->sl_str -array. -If -.Ar freeall -is non-zero, then each of the items within -.Ar sl->sl_str -is released as well. -.It Fn sl_add -Add -.Ar item -to -.Ar sl->sl_str -at -.Ar sl->sl_cur , -extending the size of -.Ar sl->sl_str -.It Fn sl_find -Find -.Ar item -in -.Ar sl , -returning NULL if it's not found. -.El -.Sh SEE ALSO -.Xr free 3 , -.Xr malloc 3 diff --git a/lib/libc/gen/stringlist.c b/lib/libc/gen/stringlist.c deleted file mode 100644 index bb74919..0000000 --- a/lib/libc/gen/stringlist.c +++ /dev/null @@ -1,120 +0,0 @@ -/* $NetBSD: stringlist.c,v 1.2 1997/01/17 07:26:20 lukem Exp $ */ - -/* - * Copyright (c) 1994 Christos Zoulas - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christos Zoulas. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 *rcsid = "$NetBSD: stringlist.c,v 1.2 1997/01/17 07:26:20 lukem Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include - -#define _SL_CHUNKSIZE 20 - -/* - * sl_init(): Initialize a string list - */ -StringList * -sl_init() -{ - StringList *sl = malloc(sizeof(StringList)); - if (sl == NULL) - err(1, "stringlist: %m"); - - sl->sl_cur = 0; - sl->sl_max = _SL_CHUNKSIZE; - sl->sl_str = malloc(sl->sl_max * sizeof(char *)); - if (sl->sl_str == NULL) - err(1, "stringlist: %m"); - return sl; -} - - -/* - * sl_add(): Add an item to the string list - */ -void -sl_add(sl, name) - StringList *sl; - char *name; -{ - if (sl->sl_cur == sl->sl_max - 1) { - sl->sl_max += _SL_CHUNKSIZE; - sl->sl_str = reallocf(sl->sl_str, sl->sl_max * sizeof(char *)); - if (sl->sl_str == NULL) - err(1, "stringlist: %m"); - } - sl->sl_str[sl->sl_cur++] = name; -} - - -/* - * sl_free(): Free a stringlist - */ -void -sl_free(sl, all) - StringList *sl; - int all; -{ - size_t i; - - if (sl == NULL) - return; - if (sl->sl_str) { - if (all) - for (i = 0; i < sl->sl_cur; i++) - free(sl->sl_str[i]); - free(sl->sl_str); - } - free(sl); -} - - -/* - * sl_find(): Find a name in the string list - */ -char * -sl_find(sl, name) - StringList *sl; - char *name; -{ - size_t i; - - for (i = 0; i < sl->sl_cur; i++) - if (strcmp(sl->sl_str[i], name) == 0) - return sl->sl_str[i]; - - return NULL; -} diff --git a/lib/libc/gen/strtofflags.3 b/lib/libc/gen/strtofflags.3 deleted file mode 100644 index 09c6208..0000000 --- a/lib/libc/gen/strtofflags.3 +++ /dev/null @@ -1,78 +0,0 @@ -.\" Copyright (c) 1989, 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. -.\" -.\" @(#)setmode.3 8.2 (Berkeley) 4/28/95 -.\" $FreeBSD$ -.\" -.Dd January 1, 2000 -.Dt SETFLAGS 3 -.Os -.Sh NAME -.Nm getflags , -.Nm setflags -.Nd modify file flag bits -.Sh SYNOPSIS -.Fd #include -.Ft char * -.Fn getflags "u_long flags" "char *def" -.Ft int -.Fn setflags "char **stringp" "u_long *setp" "u_long *clrp" -.Sh DESCRIPTION -The -.Fn getflags -function returns a comma separated string of the file flags represented by -.Fa flags . -If no flags are set the string -.Fa def -is returned instead. -.Pp -The -.Fn setflags -function takes a string of file flags, as described in -.Xr chflags 1 , -parses it, and returns the 'set' flags and 'clear' flags -such as would be given as arguments to -.Xr chflags 2 . -On success -.Fn setflags -returns 0, otherwise it returns non-zero and -.Fa stringp -is left pointing to the offending token. -.Sh SEE ALSO -.Xr chflags 1 , -.Xr chflags 2 , -.Sh HISTORY -The -.Fn getflags -and -.Fn setflags -functions first appeared in -.Fx 4.0 . diff --git a/lib/libc/gen/strtofflags.c b/lib/libc/gen/strtofflags.c deleted file mode 100644 index c1fe6c5..0000000 --- a/lib/libc/gen/strtofflags.c +++ /dev/null @@ -1,154 +0,0 @@ -/*- - * Copyright (c) 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. - */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)stat_flags.c 8.1 (Berkeley) 5/31/93"; -#else -static const char rcsid[] = - "$FreeBSD$"; -#endif -#endif /* not lint */ - -#include -#include - -#include -#include - -static struct { - char *name; - u_long flag; - int invert; -} mapping[] = { - /* shorter names per flag first, all prefixed by "no" */ - { "nosappnd", SF_APPEND, 0 }, - { "nosappend", SF_APPEND, 0 }, - { "noarch", SF_ARCHIVED, 0 }, - { "noarchived", SF_ARCHIVED, 0 }, - { "noschg", SF_IMMUTABLE, 0 }, - { "noschange", SF_IMMUTABLE, 0 }, - { "nosimmutable", SF_IMMUTABLE, 0 }, - { "nosunlnk", SF_NOUNLINK, 0 }, - { "nosunlink", SF_NOUNLINK, 0 }, - { "nouappnd", UF_APPEND, 0 }, - { "nouappend", UF_APPEND, 0 }, - { "nouchg", UF_IMMUTABLE, 0 }, - { "nouchange", UF_IMMUTABLE, 0 }, - { "nouimmutable", UF_IMMUTABLE, 0 }, - { "nodump", UF_NODUMP, 1 }, - { "noopaque", UF_OPAQUE, 0 }, - { "nouunlnk", UF_NOUNLINK, 0 }, - { "nouunlink", UF_NOUNLINK, 0 } -}; -#define nmappings (sizeof(mapping) / sizeof(mapping[0])) - -/* - * getflags -- - * Convert stat flags to a comma-separated string. If no flags - * are set, return the default string. - */ -char * -getflags(flags, def) - u_long flags; - char *def; -{ - static char string[128]; - char *sp, *dp; - u_long setflags; - int i; - - setflags = flags; - dp = string; - for (i = 0; i < nmappings; i++) { - if (setflags & mapping[i].flag) { - if (dp > string) - *dp++ = ','; - for (sp = mapping[i].invert ? mapping[i].name : - mapping[i].name + 2; *sp; *dp++ = *sp++) ; - setflags &= ~mapping[i].flag; - } - } - *dp = '\0'; - return (dp == string && def != NULL ? def : string); -} - -/* - * setflags -- - * Take string of arguments and return stat flags. Return 0 on - * success, 1 on failure. On failure, stringp is set to point - * to the offending token. - */ -int -setflags(stringp, setp, clrp) - char **stringp; - u_long *setp, *clrp; -{ - char *string, *p; - int i; - - if (setp) - *setp = 0; - if (clrp) - *clrp = 0; - string = *stringp; - while ((p = strsep(&string, "\t ,")) != NULL) { - *stringp = p; - if (*p == '\0') - continue; - for (i = 0; i < nmappings; i++) { - if (strcmp(p, mapping[i].name + 2) == 0) { - if (mapping[i].invert) { - if (clrp) - *clrp |= mapping[i].flag; - } else { - if (setp) - *setp |= mapping[i].flag; - } - break; - } else if (strcmp(p, mapping[i].name) == 0) { - if (mapping[i].invert) { - if (setp) - *setp |= mapping[i].flag; - } else { - if (clrp) - *clrp |= mapping[i].flag; - } - break; - } - } - if (i == nmappings) - return 1; - } - return 0; -} diff --git a/lib/libc/gen/sysconf.3 b/lib/libc/gen/sysconf.3 deleted file mode 100644 index e18c045..0000000 --- a/lib/libc/gen/sysconf.3 +++ /dev/null @@ -1,187 +0,0 @@ -.\" Copyright (c) 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. -.\" -.\" @(#)sysconf.3 8.3 (Berkeley) 4/19/94 -.\" $FreeBSD$ -.\" -.Dd April 19, 1994 -.Dt SYSCONF 3 -.Os BSD 4 -.Sh NAME -.Nm sysconf -.Nd get configurable system variables -.Sh SYNOPSIS -.Fd #include -.Ft long -.Fn sysconf "int name" -.Sh DESCRIPTION -.Pp -This interface is defined by -.St -p1003.1-88 . -A far more complete interface is available using -.Xr sysctl 3 . -.Pp -The -.Fn sysconf -function provides a method for applications to determine the current -value of a configurable system limit or option variable. -The -.Fa name -argument specifies the system variable to be queried. -Symbolic constants for each name value are found in the include file -.Li . -.Pp -The available values are as follows: -.Pp -.Bl -tag -width "123456" -.Pp -.It Li _SC_ARG_MAX -The maximum bytes of argument to -.Xr execve 2 . -.It Li _SC_CHILD_MAX -The maximum number of simultaneous processes per user id. -.It Li _SC_CLK_TCK -The frequency of the statistics clock in ticks per second. -.It Li _SC_NGROUPS_MAX -The maximum number of supplemental groups. -.It Li _SC_OPEN_MAX -The maximum number of open files per user id. -.It Li _SC_STREAM_MAX -The minimum maximum number of streams that a process may have open -at any one time. -.It Li _SC_TZNAME_MAX -The minimum maximum number of types supported for the name of a -timezone. -.It Li _SC_JOB_CONTROL -Return 1 if job control is available on this system, otherwise \-1. -.It Li _SC_SAVED_IDS -Returns 1 if saved set-group and saved set-user ID is available, -otherwise \-1. -.It Li _SC_VERSION -The version of ISO/IEC 9945 (POSIX 1003.1) with which the system -attempts to comply. -.It Li _SC_BC_BASE_MAX -The maximum ibase/obase values in the -.Xr bc 1 -utility. -.It Li _SC_BC_DIM_MAX -The maximum array size in the -.Xr bc 1 -utility. -.It Li _SC_BC_SCALE_MAX -The maximum scale value in the -.Xr bc 1 -utility. -.It Li _SC_BC_STRING_MAX -The maximum string length in the -.Xr bc 1 -utility. -.It Li _SC_COLL_WEIGHTS_MAX -The maximum number of weights that can be assigned to any entry of -the LC_COLLATE order keyword in the locale definition file. -.It Li _SC_EXPR_NEST_MAX -The maximum number of expressions that can be nested within -parenthesis by the -.Xr expr 1 -utility. -.It Li _SC_LINE_MAX -The maximum length in bytes of a text-processing utility's input -line. -.It Li _SC_RE_DUP_MAX -The maximum number of repeated occurrences of a regular expression -permitted when using interval notation. -.It Li _SC_2_VERSION -The version of POSIX 1003.2 with which the system attempts to comply. -.It Li _SC_2_C_BIND -Return 1 if the system's C-language development facilities support the -C-Language Bindings Option, otherwise \-1. -.It Li _SC_2_C_DEV -Return 1 if the system supports the C-Language Development Utilities Option, -otherwise \-1. -.It Li _SC_2_CHAR_TERM -Return 1 if the system supports at least one terminal type capable of -all operations described in POSIX 1003.2, otherwise \-1. -.It Li _SC_2_FORT_DEV -Return 1 if the system supports the FORTRAN Development Utilities Option, -otherwise \-1. -.It Li _SC_2_FORT_RUN -Return 1 if the system supports the FORTRAN Runtime Utilities Option, -otherwise \-1. -.It Li _SC_2_LOCALEDEF -Return 1 if the system supports the creation of locales, otherwise \-1. -.It Li _SC_2_SW_DEV -Return 1 if the system supports the Software Development Utilities Option, -otherwise \-1. -.It Li _SC_2_UPE -Return 1 if the system supports the User Portability Utilities Option, -otherwise \-1. -.El -.Sh RETURN VALUES -If the call to -.Fn sysconf -is not successful, \-1 is returned and -.Va errno -is set appropriately. -Otherwise, if the variable is associated with functionality that is not -supported, \-1 is returned and -.Va errno -is not modified. -Otherwise, the current variable value is returned. -.Sh ERRORS -The -.Fn sysconf -function may fail and set -.Va errno -for any of the errors specified for the library functions -.Xr sysctl 3 . -In addition, the following error may be reported: -.Bl -tag -width Er -.It Bq Er EINVAL -The value of the -.Fa name -argument is invalid. -.Sh SEE ALSO -.Xr sysctl 3 -.Sh BUGS -The value for _SC_STREAM_MAX is a minimum maximum, and required to be -the same as ANSI C's FOPEN_MAX, so the returned value is a ridiculously -small and misleading number. -.Sh STANDARDS -Except for the fact that values returned by -.Fn sysconf -may change over the lifetime of the calling process, -this function conforms to -.St -p1003.1-88 . -.Sh HISTORY -The -.Fn sysconf -function first appeared in -.Bx 4.4 . diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c deleted file mode 100644 index 2298bb1..0000000 --- a/lib/libc/gen/sysconf.c +++ /dev/null @@ -1,299 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Sean Eric Fagan of Cygnus Support. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)sysconf.c 8.2 (Berkeley) 3/20/94"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include - -#include -#include -#include - -/* - * sysconf -- - * get configurable system variables. - * - * XXX - * POSIX 1003.1 (ISO/IEC 9945-1, 4.8.1.3) states that the variable values - * not change during the lifetime of the calling process. This would seem - * to require that any change to system limits kill all running processes. - * A workaround might be to cache the values when they are first retrieved - * and then simply return the cached value on subsequent calls. This is - * less useful than returning up-to-date values, however. - */ -long -sysconf(name) - int name; -{ - struct rlimit rl; - size_t len; - int mib[2], value; - long defaultresult; - - len = sizeof(value); - defaultresult = -1; - - switch (name) { -/* 1003.1 */ - case _SC_ARG_MAX: - mib[0] = CTL_KERN; - mib[1] = KERN_ARGMAX; - break; - case _SC_CHILD_MAX: - return (getrlimit(RLIMIT_NPROC, &rl) ? -1 : rl.rlim_cur); - case _SC_CLK_TCK: - return (CLK_TCK); - case _SC_JOB_CONTROL: - mib[0] = CTL_KERN; - mib[1] = KERN_JOB_CONTROL; - goto yesno; - case _SC_NGROUPS_MAX: - mib[0] = CTL_KERN; - mib[1] = KERN_NGROUPS; - break; - case _SC_OPEN_MAX: - return (getrlimit(RLIMIT_NOFILE, &rl) ? -1 : rl.rlim_cur); - case _SC_STREAM_MAX: - mib[0] = CTL_USER; - mib[1] = USER_STREAM_MAX; - break; - case _SC_TZNAME_MAX: - mib[0] = CTL_USER; - mib[1] = USER_TZNAME_MAX; - break; - case _SC_SAVED_IDS: - mib[0] = CTL_KERN; - mib[1] = KERN_SAVED_IDS; - goto yesno; - case _SC_VERSION: - mib[0] = CTL_KERN; - mib[1] = KERN_POSIX1; - break; - -/* 1003.2 */ - case _SC_BC_BASE_MAX: - mib[0] = CTL_USER; - mib[1] = USER_BC_BASE_MAX; - break; - case _SC_BC_DIM_MAX: - mib[0] = CTL_USER; - mib[1] = USER_BC_DIM_MAX; - break; - case _SC_BC_SCALE_MAX: - mib[0] = CTL_USER; - mib[1] = USER_BC_SCALE_MAX; - break; - case _SC_BC_STRING_MAX: - mib[0] = CTL_USER; - mib[1] = USER_BC_STRING_MAX; - break; - case _SC_COLL_WEIGHTS_MAX: - mib[0] = CTL_USER; - mib[1] = USER_COLL_WEIGHTS_MAX; - break; - case _SC_EXPR_NEST_MAX: - mib[0] = CTL_USER; - mib[1] = USER_EXPR_NEST_MAX; - break; - case _SC_LINE_MAX: - mib[0] = CTL_USER; - mib[1] = USER_LINE_MAX; - break; - case _SC_RE_DUP_MAX: - mib[0] = CTL_USER; - mib[1] = USER_RE_DUP_MAX; - break; - case _SC_2_VERSION: - mib[0] = CTL_USER; - mib[1] = USER_POSIX2_VERSION; - break; - case _SC_2_C_BIND: - mib[0] = CTL_USER; - mib[1] = USER_POSIX2_C_BIND; - goto yesno; - case _SC_2_C_DEV: - mib[0] = CTL_USER; - mib[1] = USER_POSIX2_C_DEV; - goto yesno; - case _SC_2_CHAR_TERM: - mib[0] = CTL_USER; - mib[1] = USER_POSIX2_CHAR_TERM; - goto yesno; - case _SC_2_FORT_DEV: - mib[0] = CTL_USER; - mib[1] = USER_POSIX2_FORT_DEV; - goto yesno; - case _SC_2_FORT_RUN: - mib[0] = CTL_USER; - mib[1] = USER_POSIX2_FORT_RUN; - goto yesno; - case _SC_2_LOCALEDEF: - mib[0] = CTL_USER; - mib[1] = USER_POSIX2_LOCALEDEF; - goto yesno; - case _SC_2_SW_DEV: - mib[0] = CTL_USER; - mib[1] = USER_POSIX2_SW_DEV; - goto yesno; - case _SC_2_UPE: - mib[0] = CTL_USER; - mib[1] = USER_POSIX2_UPE; - goto yesno; - -#ifdef _P1003_1B_VISIBLE - /* POSIX.1B */ - - case _SC_ASYNCHRONOUS_IO: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_ASYNCHRONOUS_IO; - goto yesno; - case _SC_MAPPED_FILES: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_MAPPED_FILES; - goto yesno; - case _SC_MEMLOCK: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_MEMLOCK; - goto yesno; - case _SC_MEMLOCK_RANGE: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_MEMLOCK_RANGE; - goto yesno; - case _SC_MEMORY_PROTECTION: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_MEMORY_PROTECTION; - goto yesno; - case _SC_MESSAGE_PASSING: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_MESSAGE_PASSING; - goto yesno; - case _SC_PRIORITIZED_IO: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_PRIORITIZED_IO; - goto yesno; - case _SC_PRIORITY_SCHEDULING: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_PRIORITY_SCHEDULING; - goto yesno; - case _SC_REALTIME_SIGNALS: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_REALTIME_SIGNALS; - goto yesno; - case _SC_SEMAPHORES: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_SEMAPHORES; - goto yesno; - case _SC_FSYNC: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_FSYNC; - goto yesno; - case _SC_SHARED_MEMORY_OBJECTS: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_SHARED_MEMORY_OBJECTS; - goto yesno; - case _SC_SYNCHRONIZED_IO: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_SYNCHRONIZED_IO; - goto yesno; - case _SC_TIMERS: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_TIMERS; - goto yesno; - case _SC_AIO_LISTIO_MAX: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_AIO_LISTIO_MAX; - goto yesno; - case _SC_AIO_MAX: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_AIO_MAX; - goto yesno; - case _SC_AIO_PRIO_DELTA_MAX: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_AIO_PRIO_DELTA_MAX; - goto yesno; - case _SC_DELAYTIMER_MAX: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_DELAYTIMER_MAX; - goto yesno; - case _SC_MQ_OPEN_MAX: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_MQ_OPEN_MAX; - goto yesno; - case _SC_PAGESIZE: - defaultresult = getpagesize(); - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_PAGESIZE; - goto yesno; - case _SC_RTSIG_MAX: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_RTSIG_MAX; - goto yesno; - case _SC_SEM_NSEMS_MAX: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_SEM_NSEMS_MAX; - goto yesno; - case _SC_SEM_VALUE_MAX: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_SEM_VALUE_MAX; - goto yesno; - case _SC_SIGQUEUE_MAX: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_SIGQUEUE_MAX; - goto yesno; - case _SC_TIMER_MAX: - mib[0] = CTL_P1003_1B; - mib[1] = CTL_P1003_1B_TIMER_MAX; - goto yesno; -#endif /* _P1003_1B_VISIBLE */ - -yesno: if (sysctl(mib, 2, &value, &len, NULL, 0) == -1) - return (-1); - if (value == 0) - return (defaultresult); - return (value); - break; - default: - errno = EINVAL; - return (-1); - } - return (sysctl(mib, 2, &value, &len, NULL, 0) == -1 ? -1 : value); -} diff --git a/lib/libc/gen/sysctl.3 b/lib/libc/gen/sysctl.3 deleted file mode 100644 index bcf4285..0000000 --- a/lib/libc/gen/sysctl.3 +++ /dev/null @@ -1,768 +0,0 @@ -.\" Copyright (c) 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. -.\" -.\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95 -.\" $FreeBSD$ -.\" -.Dd May 9, 1995 -.Dt SYSCTL 3 -.Os -.Sh NAME -.Nm sysctl , -.Nm sysctlbyname -.Nd get or set system information -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Ft int -.Fn sysctl "int *name" "u_int namelen" "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen" -.Ft int -.Fn sysctlbyname "const char *name" "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen" -.Sh DESCRIPTION -The -.Fn sysctl -function retrieves system information and allows processes with -appropriate privileges to set system information. -The information available from -.Fn sysctl -consists of integers, strings, and tables. -Information may be retrieved and set from the command interface -using the -.Xr sysctl 8 -utility. -.Pp -Unless explicitly noted below, -.Fn sysctl -returns a consistent snapshot of the data requested. -Consistency is obtained by locking the destination -buffer into memory so that the data may be copied out without blocking. -Calls to -.Fn sysctl -are serialized to avoid deadlock. -.Pp -The state is described using a ``Management Information Base'' (MIB) -style name, listed in -.Fa name , -which is a -.Fa namelen -length array of integers. -.Pp -The -.Fn sysctlbyname -function accepts an ASCII representation of the name and internally -looks up the integer name vector. Apart from that, it behaves the same -as the standard -.Fn sysctl -function. -.Pp -The information is copied into the buffer specified by -.Fa oldp . -The size of the buffer is given by the location specified by -.Fa oldlenp -before the call, -and that location gives the amount of data copied after a successful call -and after a call that returns with the error code ENOMEM. -If the amount of data available is greater -than the size of the buffer supplied, -the call supplies as much data as fits in the buffer provided -and returns with the error code ENOMEM. -If the old value is not desired, -.Fa oldp -and -.Fa oldlenp -should be set to NULL. -.Pp -The size of the available data can be determined by calling -.Fn sysctl -with a NULL parameter for -.Fa oldp . -The size of the available data will be returned in the location pointed to by -.Fa oldlenp . -For some operations, the amount of space may change often. -For these operations, -the system attempts to round up so that the returned size is -large enough for a call to return the data shortly thereafter. -.Pp -To set a new value, -.Fa newp -is set to point to a buffer of length -.Fa newlen -from which the requested value is to be taken. -If a new value is not to be set, -.Fa newp -should be set to NULL and -.Fa newlen -set to 0. -.Pp -The top level names are defined with a CTL_ prefix in -.Pa , -and are as follows. -The next and subsequent levels down are found in the include files -listed here, and described in separate sections below. -.Pp -.Bl -column CTLXMACHDEPXXX "Next level namesXXXXXX" -offset indent -.It Sy Pa Name Next level names Description -.It CTL\_DEBUG sys/sysctl.h Debugging -.It CTL\_VFS sys/mount.h Filesystem -.It CTL\_HW sys/sysctl.h Generic CPU, I/O -.It CTL\_KERN sys/sysctl.h High kernel limits -.It CTL\_MACHDEP sys/sysctl.h Machine dependent -.It CTL\_NET sys/socket.h Networking -.It CTL\_USER sys/sysctl.h User-level -.It CTL\_VM vm/vm_param.h Virtual memory -.El -.Pp -For example, the following retrieves the maximum number of processes allowed -in the system: -.Pp -.Bd -literal -offset indent -compact -int mib[2], maxproc; -size_t len; - -mib[0] = CTL_KERN; -mib[1] = KERN_MAXPROC; -len = sizeof(maxproc); -sysctl(mib, 2, &maxproc, &len, NULL, 0); -.Ed -.Pp -To retrieve the standard search path for the system utilities: -.Pp -.Bd -literal -offset indent -compact -int mib[2]; -size_t len; -char *p; - -mib[0] = CTL_USER; -mib[1] = USER_CS_PATH; -sysctl(mib, 2, NULL, &len, NULL, 0); -p = malloc(len); -sysctl(mib, 2, p, &len, NULL, 0); -.Ed -.Sh CTL_DEBUG -The debugging variables vary from system to system. -A debugging variable may be added or deleted without need to recompile -.Fn sysctl -to know about it. -Each time it runs, -.Fn sysctl -gets the list of debugging variables from the kernel and -displays their current values. -The system defines twenty -.Ns ( Va struct ctldebug ) -variables named -.Nm debug0 -through -.Nm debug19 . -They are declared as separate variables so that they can be -individually initialized at the location of their associated variable. -The loader prevents multiple use of the same variable by issuing errors -if a variable is initialized in more than one place. -For example, to export the variable -.Nm dospecialcheck -as a debugging variable, the following declaration would be used: -.Bd -literal -offset indent -compact -int dospecialcheck = 1; -struct ctldebug debug5 = { "dospecialcheck", &dospecialcheck }; -.Ed -.Sh CTL_VFS -A distinguished second level name, VFS_GENERIC, -is used to get general information about all filesystems. -One of its third level identifiers is VFS_MAXTYPENUM -that gives the highest valid filesystem type number. -Its other third level identifier is VFS_CONF that -returns configuration information about the filesystem -type given as a fourth level identifier (see -.Xr getvfsbyname 3 -as an example of its use). -The remaining second level identifiers are the -filesystem type number returned by a -.Xr statfs 2 -call or from VFS_CONF. -The third level identifiers available for each filesystem -are given in the header file that defines the mount -argument structure for that filesystem. -.Sh CTL_HW -The string and integer information available for the CTL_HW level -is detailed below. -The changeable column shows whether a process with appropriate -privilege may change the value. -.Bl -column "Second level nameXXXXXX" integerXXX -offset indent -.It Sy Pa Second level name Type Changeable -.It HW\_MACHINE string no -.It HW\_MODEL string no -.It HW\_NCPU integer no -.It HW\_BYTEORDER integer no -.It HW\_PHYSMEM integer no -.It HW\_USERMEM integer no -.It HW\_PAGESIZE integer no -.It HW\_FLOATINGPOINT integer no -.It HW\_MACHINE\_ARCH string no -.\".It HW\_DISKNAMES integer no -.\".It HW\_DISKSTATS integer no -.El -.Pp -.Bl -tag -width "123456" -.It Li HW_MACHINE -The machine class. -.It Li HW_MODEL -The machine model -.It Li HW_NCPU -The number of cpus. -.ne 1i -.It Li HW_BYTEORDER -The byteorder (4,321, or 1,234). -.It Li HW_PHYSMEM -The bytes of physical memory. -.It Li HW_USERMEM -The bytes of non-kernel memory. -.It Li HW_PAGESIZE -The software page size. -.It Li HW_FLOATINGPOINT -Nonzero if the floating point support is in hardware. -.It Li HW_MACHINE_ARCH -The machine dependent architecture type. -.\".It Fa HW_DISKNAMES -.\".It Fa HW_DISKSTATS -.El -.Sh CTL_KERN -The string and integer information available for the CTL_KERN level -is detailed below. -The changeable column shows whether a process with appropriate -privilege may change the value. -The types of data currently available are process information, -system vnodes, the open file entries, routing table entries, -virtual memory statistics, load average history, and clock rate -information. -.Bl -column "KERNXMAXFILESPERPROCXXX" "struct clockrateXXX" -offset indent -.It Sy Pa Second level name Type Changeable -.It KERN\_ARGMAX integer no -.It KERN\_BOOTFILE string yes -.It KERN\_BOOTTIME struct timeval no -.It KERN\_CLOCKRATE struct clockinfo no -.It KERN\_FILE struct file no -.It KERN\_HOSTID integer yes -.It KERN\_HOSTNAME string yes -.It KERN\_JOB\_CONTROL integer no -.It KERN\_MAXFILES integer yes -.It KERN\_MAXFILESPERPROC integer yes -.It KERN\_MAXPROC integer no -.It KERN\_MAXPROCPERUID integer yes -.It KERN\_MAXVNODES integer yes -.It KERN\_NGROUPS integer no -.It KERN\_NISDOMAINNAME string yes -.It KERN\_OSRELDATE integer no -.It KERN\_OSRELEASE string no -.It KERN\_OSREV integer no -.It KERN\_OSTYPE string no -.It KERN\_POSIX1 integer no -.It KERN\_PROC struct proc no -.It KERN\_PROF node not applicable -.It KERN\_QUANTUM integer yes -.It KERN\_SAVED\_IDS integer no -.It KERN\_SECURELVL integer raise only -.It KERN\_UPDATEINTERVAL integer no -.It KERN\_VERSION string no -.It KERN\_VNODE struct vnode no -.El -.ne 1i -.Pp -.Bl -tag -width "123456" -.It Li KERN_ARGMAX -The maximum bytes of argument to -.Xr execve 2 . -.It Li KERN_BOOTFILE -The full pathname of the file from which the kernel was loaded. -.It Li KERN_BOOTTIME -A -.Va struct timeval -structure is returned. -This structure contains the time that the system was booted. -.It Li KERN_CLOCKRATE -A -.Va struct clockinfo -structure is returned. -This structure contains the clock, statistics clock and profiling clock -frequencies, the number of micro-seconds per hz tick and the skew rate. -.It Li KERN_FILE -Return the entire file table. -The returned data consists of a single -.Va struct filehead -followed by an array of -.Va struct file , -whose size depends on the current number of such objects in the system. -.It Li KERN_HOSTID -Get or set the host id. -.It Li KERN_HOSTNAME -Get or set the hostname. -.It Li KERN_JOB_CONTROL -Return 1 if job control is available on this system, otherwise 0. -.It Li KERN_MAXFILES -The maximum number of files that may be open in the system. -.It Li KERN_MAXFILESPERPROC -The maximum number of files that may be open for a single process. -This limit only applies to processes with an effective uid of nonzero -at the time of the open request. -Files that have already been opened are not affected if the limit -or the effective uid is changed. -.It Li KERN_MAXPROC -The maximum number of concurrent processes the system will allow. -.It Li KERN_MAXPROCPERUID -The maximum number of concurrent processes the system will allow -for a single effective uid. -This limit only applies to processes with an effective uid of nonzero -at the time of a fork request. -Processes that have already been started are not affected if the limit -is changed. -.It Li KERN_MAXVNODES -The maximum number of vnodes available on the system. -.It Li KERN_NGROUPS -The maximum number of supplemental groups. -.It Li KERN_NISDOMAINNAME -The name of the current YP/NIS domain. -.It Li KERN_OSRELDATE -The system release date in YYYYMM format -(January 1996 is encoded as 199601). -.It Li KERN_OSRELEASE -The system release string. -.It Li KERN_OSREV -The system revision string. -.It Li KERN_OSTYPE -The system type string. -.It Li KERN_POSIX1 -The version of ISO/IEC 9945 (POSIX 1003.1) with which the system -attempts to comply. -.It Li KERN_PROC -Return the entire process table, or a subset of it. -An array of -.Va struct kinfo_proc -structures is returned, -whose size depends on the current number of such objects in the system. -The third and fourth level names are as follows: -.Bl -column "Third level nameXXXXXX" "Fourth level is:XXXXXX" -offset indent -.It Pa Third level name Fourth level is: -.It KERN\_PROC\_ALL None -.It KERN\_PROC\_PID A process ID -.It KERN\_PROC\_PGRP A process group -.It KERN\_PROC\_TTY A tty device -.It KERN\_PROC\_UID A user ID -.It KERN\_PROC\_RUID A real user ID -.El -.It Li KERN_PROF -Return profiling information about the kernel. -If the kernel is not compiled for profiling, -attempts to retrieve any of the KERN_PROF values will -fail with EOPNOTSUPP. -The third level names for the string and integer profiling information -is detailed below. -The changeable column shows whether a process with appropriate -privilege may change the value. -.Bl -column "GPROFXGMONPARAMXXX" "struct gmonparamXXX" -offset indent -.It Sy Pa Third level name Type Changeable -.It GPROF\_STATE integer yes -.It GPROF\_COUNT u_short[\|] yes -.It GPROF\_FROMS u_short[\|] yes -.It GPROF\_TOS struct tostruct yes -.It GPROF\_GMONPARAM struct gmonparam no -.El -.Pp -The variables are as follows: -.Bl -tag -width "123456" -.It Li GPROF_STATE -Returns GMON_PROF_ON or GMON_PROF_OFF to show that profiling -is running or stopped. -.It Li GPROF_COUNT -Array of statistical program counter counts. -.It Li GPROF_FROMS -Array indexed by program counter of call-from points. -.It Li GPROF_TOS -Array of -.Va struct tostruct -describing destination of calls and their counts. -.It Li GPROF_GMONPARAM -Structure giving the sizes of the above arrays. -.El -.ne 1i -.It Li KERN_QUANTUM -The maximum period of time, in microseconds, for which a process is allowed -to run without being preempted if other processes are in the run queue. -.It Li KERN_SAVED_IDS -Returns 1 if saved set-group and saved set-user ID is available. -.It Li KERN_SECURELVL -The system security level. -This level may be raised by processes with appropriate privilege. -It may not be lowered. -.It Li KERN_VERSION -The system version string. -.It Li KERN_VNODE -Return the entire vnode table. -Note, the vnode table is not necessarily a consistent snapshot of -the system. -The returned data consists of an array whose size depends on the -current number of such objects in the system. -Each element of the array contains the kernel address of a vnode -.Va struct vnode * -followed by the vnode itself -.Va struct vnode . -.It Li KERN_UPDATEINTERVAL -The interval between -.Xr sync 2 -calls in the -.Xr update 4 -process. -.El -.Sh CTL_MACHDEP -The set of variables defined is architecture dependent. -The following variables are defined for the i386 architecture. -.Bl -column "CONSOLE_DEVICEXXX" "struct bootinfoXXX" -offset indent -.It Sy Pa Second level name Type Changeable -.It Li CPU_CONSDEV dev_t no -.It Li CPU_ADJKERNTZ int yes -.It Li CPU_DISRTCSET int yes -.It Li CPU_BOOTINFO struct bootinfo no -.It Li CPU_WALLCLOCK int yes -.El -.Sh CTL_NET -The string and integer information available for the CTL_NET level -is detailed below. -The changeable column shows whether a process with appropriate -privilege may change the value. -.Bl -column "Second level nameXXXXXX" "routing messagesXXX" -offset indent -.It Sy Pa Second level name Type Changeable -.It PF\_ROUTE routing messages no -.It PF\_INET IPv4 values yes -.It PF\_INET6 IPv6 values yes -.El -.Pp -.Bl -tag -width "123456" -.It Li PF_ROUTE -Return the entire routing table or a subset of it. -The data is returned as a sequence of routing messages (see -.Xr route 4 -for the header file, format and meaning). -The length of each message is contained in the message header. -.Pp -The third level name is a protocol number, which is currently always 0. -The fourth level name is an address family, which may be set to 0 to -select all address families. -The fifth and sixth level names are as follows: -.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent -.It Pa Fifth level name Sixth level is: -.It NET\_RT\_FLAGS rtflags -.It NET\_RT\_DUMP None -.It NET\_RT\_IFLIST None -.El -.It Li PF_INET -Get or set various global information about the IPv4 -.Pq Internet Protocol version 4 . -The third level name is the protocol. -The fourth level name is the variable name. -The currently defined protocols and names are: -.ne 1i -.Bl -column ProtocolXX VariableXX TypeXX ChangeableXX -.It Pa Protocol Variable Type Changeable -.It icmp bmcastecho integer yes -.It icmp maskrepl integer yes -.It ip forwarding integer yes -.It ip redirect integer yes -.It ip ttl integer yes -.It udp checksum integer yes -.El -.Pp -The variables are as follows: -.Bl -tag -width "123456" -.It Li icmp.bmcastecho -Returns 1 if an ICMP echo request to a broadcast or multicast address is -to be answered. -.It Li icmp.maskrepl -Returns 1 if ICMP network mask requests are to be answered. -.It Li ip.forwarding -Returns 1 when IP forwarding is enabled for the host, -meaning that the host is acting as a router. -.It Li ip.redirect -Returns 1 when ICMP redirects may be sent by the host. -This option is ignored unless the host is routing IP packets, -and should normally be enabled on all systems. -.It Li ip.ttl -The maximum time-to-live (hop count) value for an IP packet sourced by -the system. -This value applies to normal transport protocols, not to ICMP. -.It Li udp.checksum -Returns 1 when UDP checksums are being computed and checked. -Disabling UDP checksums is strongly discouraged. -.Pp -For variables net.inet.*.ipsec, please refer to -.Xr ipsec 4 . -.El -.It Li PF_INET6 -Get or set various global information about the IPv6 -.Pq Internet Protocol version 6 . -The third level name is the protocol. -The fourth level name is the variable name. -.Pp -For variables net.inet6.* please refer to -.Xr inet6 4 . -For variables net.inet6.*.ipsec6, please refer to -.Xr ipsec 4 . -.El -.Sh CTL_USER -The string and integer information available for the CTL_USER level -is detailed below. -The changeable column shows whether a process with appropriate -privilege may change the value. -.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" -offset indent -.It Sy Pa Second level name Type Changeable -.It USER\_BC\_BASE\_MAX integer no -.It USER\_BC\_DIM\_MAX integer no -.It USER\_BC\_SCALE\_MAX integer no -.It USER\_BC\_STRING\_MAX integer no -.It USER\_COLL\_WEIGHTS\_MAX integer no -.It USER\_CS\_PATH string no -.It USER\_EXPR\_NEST\_MAX integer no -.It USER\_LINE\_MAX integer no -.It USER\_POSIX2\_CHAR\_TERM integer no -.It USER\_POSIX2\_C\_BIND integer no -.It USER\_POSIX2\_C\_DEV integer no -.It USER\_POSIX2\_FORT\_DEV integer no -.It USER\_POSIX2\_FORT\_RUN integer no -.It USER\_POSIX2\_LOCALEDEF integer no -.It USER\_POSIX2\_SW\_DEV integer no -.It USER\_POSIX2\_UPE integer no -.It USER\_POSIX2\_VERSION integer no -.It USER\_RE\_DUP\_MAX integer no -.It USER\_STREAM\_MAX integer no -.It USER\_TZNAME\_MAX integer no -.El -.Bl -tag -width "123456" -.Pp -.It Li USER_BC_BASE_MAX -The maximum ibase/obase values in the -.Xr bc 1 -utility. -.It Li USER_BC_DIM_MAX -The maximum array size in the -.Xr bc 1 -utility. -.It Li USER_BC_SCALE_MAX -The maximum scale value in the -.Xr bc 1 -utility. -.It Li USER_BC_STRING_MAX -The maximum string length in the -.Xr bc 1 -utility. -.It Li USER_COLL_WEIGHTS_MAX -The maximum number of weights that can be assigned to any entry of -the LC_COLLATE order keyword in the locale definition file. -.It Li USER_CS_PATH -Return a value for the -.Ev PATH -environment variable that finds all the standard utilities. -.It Li USER_EXPR_NEST_MAX -The maximum number of expressions that can be nested within -parenthesis by the -.Xr expr 1 -utility. -.It Li USER_LINE_MAX -The maximum length in bytes of a text-processing utility's input -line. -.It Li USER_POSIX2_CHAR_TERM -Return 1 if the system supports at least one terminal type capable of -all operations described in POSIX 1003.2, otherwise 0. -.It Li USER_POSIX2_C_BIND -Return 1 if the system's C-language development facilities support the -C-Language Bindings Option, otherwise 0. -.It Li USER_POSIX2_C_DEV -Return 1 if the system supports the C-Language Development Utilities Option, -otherwise 0. -.It Li USER_POSIX2_FORT_DEV -Return 1 if the system supports the FORTRAN Development Utilities Option, -otherwise 0. -.It Li USER_POSIX2_FORT_RUN -Return 1 if the system supports the FORTRAN Runtime Utilities Option, -otherwise 0. -.It Li USER_POSIX2_LOCALEDEF -Return 1 if the system supports the creation of locales, otherwise 0. -.It Li USER_POSIX2_SW_DEV -Return 1 if the system supports the Software Development Utilities Option, -otherwise 0. -.It Li USER_POSIX2_UPE -Return 1 if the system supports the User Portability Utilities Option, -otherwise 0. -.It Li USER_POSIX2_VERSION -The version of POSIX 1003.2 with which the system attempts to comply. -.It Li USER_RE_DUP_MAX -The maximum number of repeated occurrences of a regular expression -permitted when using interval notation. -.ne 1i -.It Li USER_STREAM_MAX -The minimum maximum number of streams that a process may have open -at any one time. -.It Li USER_TZNAME_MAX -The minimum maximum number of types supported for the name of a -timezone. -.El -.Sh CTL_VM -The string and integer information available for the CTL_VM level -is detailed below. -The changeable column shows whether a process with appropriate -privilege may change the value. -.Bl -column "Second level nameXXXXXX" "struct loadavgXXX" -offset indent -.It Sy Pa Second level name Type Changeable -.It VM\_LOADAVG struct loadavg no -.It VM\_METER struct vmtotal no -.It VM\_PAGEOUT\_ALGORITHM integer yes -.It VM\_SWAPPING\_ENABLED integer maybe -.It VM\_V\_CACHE\_MAX integer yes -.It VM\_V\_CACHE\_MIN integer yes -.It VM\_V\_FREE\_MIN integer yes -.It VM\_V\_FREE\_RESERVED integer yes -.It VM\_V\_FREE\_TARGET integer yes -.It VM\_V\_INACTIVE\_TARGET integer yes -.It VM\_V\_PAGEOUT\_FREE\_MIN integer yes -.El -.Pp -.Bl -tag -width "123456" -.It Li VM_LOADAVG -Return the load average history. -The returned data consists of a -.Va struct loadavg . -.It Li VM_METER -Return the system wide virtual memory statistics. -The returned data consists of a -.Va struct vmtotal . -.It Li VM_PAGEOUT_ALGORITHM -0 if the statistics-based page management algorithm is in use -or 1 if the near-LRU algorithm is in use. -.It Li VM_SWAPPING_ENABLED -1 if process swapping is enabled or 0 if disabled. This variable is -permanently set to 0 if the kernel was built with swapping disabled. -.It Li VM_V_CACHE_MAX -Maximum desired size of the cache queue. -.It Li VM_V_CACHE_MIN -Minimum desired size of the cache queue. If the cache queue size -falls very far below this value, the pageout daemon is awakened. -.It Li VM_V_FREE_MIN -Minimum amount of memory (cache memory plus free memory) -required to be available before a process waiting on memory will be -awakened. -.It Li VM_V_FREE_RESERVED -Processes will awaken the pageout daemon and wait for memory if the -number of free and cached pages drops below this value. -.It Li VM_V_FREE_TARGET -The total amount of free memory (including cache memory) that the -pageout daemon tries to maintain. -.It Li VM_V_INACTIVE_TARGET -The desired number of inactive pages that the pageout daemon should -achieve when it runs. Inactive pages can be quickly inserted into -process address space when needed. -.It Li VM_V_PAGEOUT_FREE_MIN -If the amount of free and cache memory falls below this value, the -pageout daemon will enter "memory conserving mode" to avoid deadlock. -.El -.Sh RETURN VALUES -.Fn sysctl -and -.Fn sysctlbyname -return 0 when successful. -Otherwise \-1 is returned and -.Va errno -is set appropriately. -.Sh ERRORS -The following errors may be reported: -.Bl -tag -width Er -.It Bq Er EFAULT -The buffer -.Fa name , -.Fa oldp , -.Fa newp , -or length pointer -.Fa oldlenp -contains an invalid address. -.It Bq Er EINVAL -The -.Fa name -array is less than two or greater than CTL_MAXNAME. -.It Bq Er EINVAL -A non-null -.Fa newp -is given and its specified length in -.Fa newlen -is too large or too small. -.It Bq Er ENOMEM -The length pointed to by -.Fa oldlenp -is too short to hold the requested value. -.It Bq Er ENOTDIR -The -.Fa name -array specifies an intermediate rather than terminal name. -.It Bq Er EISDIR -The -.Fa name -array specifies a terminal name, but the actual name is not terminal. -.It Bq Er EOPNOTSUPP -The -.Fa name -array specifies a value that is unknown. -.It Bq Er EPERM -An attempt is made to set a read-only value. -.It Bq Er EPERM -A process without appropriate privilege attempts to set a value. -.El -.Sh FILES -.Bl -tag -width -compact -.It Pa -definitions for top level identifiers, second level kernel and hardware -identifiers, and user level identifiers -.It Pa -definitions for second level network identifiers -.It Pa -definitions for third level profiling identifiers -.It Pa -definitions for second level virtual memory identifiers -.It Pa -definitions for third level IPv4/IPv6 identifiers and -fourth level IPv4/v6 identifiers -.It Pa -definitions for fourth level ICMP identifiers -.It Pa -definitions for fourth level ICMPv6 identifiers -.It Pa -definitions for fourth level UDP identifiers -.El -.Sh SEE ALSO -.Xr sysconf 3 , -.Xr sysctl 8 -.Sh HISTORY -The -.Fn sysctl -function first appeared in -.Bx 4.4 . diff --git a/lib/libc/gen/sysctl.c b/lib/libc/gen/sysctl.c deleted file mode 100644 index 19709d5..0000000 --- a/lib/libc/gen/sysctl.c +++ /dev/null @@ -1,182 +0,0 @@ -/*- - * Copyright (c) 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)sysctl.c 8.2 (Berkeley) 1/4/94"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#include -#include -#include -#include -#include -#include - -int -sysctl(name, namelen, oldp, oldlenp, newp, newlen) - int *name; - u_int namelen; - void *oldp, *newp; - size_t *oldlenp, newlen; -{ - if (name[0] != CTL_USER) - return (__sysctl(name, namelen, oldp, oldlenp, newp, newlen)); - - if (newp != NULL) { - errno = EPERM; - return (-1); - } - if (namelen != 2) { - errno = EINVAL; - return (-1); - } - - switch (name[1]) { - case USER_CS_PATH: - if (oldp && *oldlenp < sizeof(_PATH_STDPATH)) { - errno = ENOMEM; - return -1; - } - *oldlenp = sizeof(_PATH_STDPATH); - if (oldp != NULL) - memmove(oldp, _PATH_STDPATH, sizeof(_PATH_STDPATH)); - return (0); - } - - if (oldp && *oldlenp < sizeof(int)) { - errno = ENOMEM; - return (-1); - } - *oldlenp = sizeof(int); - if (oldp == NULL) - return (0); - - switch (name[1]) { - case USER_BC_BASE_MAX: - *(int *)oldp = BC_BASE_MAX; - return (0); - case USER_BC_DIM_MAX: - *(int *)oldp = BC_DIM_MAX; - return (0); - case USER_BC_SCALE_MAX: - *(int *)oldp = BC_SCALE_MAX; - return (0); - case USER_BC_STRING_MAX: - *(int *)oldp = BC_STRING_MAX; - return (0); - case USER_COLL_WEIGHTS_MAX: - *(int *)oldp = COLL_WEIGHTS_MAX; - return (0); - case USER_EXPR_NEST_MAX: - *(int *)oldp = EXPR_NEST_MAX; - return (0); - case USER_LINE_MAX: - *(int *)oldp = LINE_MAX; - return (0); - case USER_RE_DUP_MAX: - *(int *)oldp = RE_DUP_MAX; - return (0); - case USER_POSIX2_VERSION: - *(int *)oldp = _POSIX2_VERSION; - return (0); - case USER_POSIX2_C_BIND: -#ifdef POSIX2_C_BIND - *(int *)oldp = 1; -#else - *(int *)oldp = 0; -#endif - return (0); - case USER_POSIX2_C_DEV: -#ifdef POSIX2_C_DEV - *(int *)oldp = 1; -#else - *(int *)oldp = 0; -#endif - return (0); - case USER_POSIX2_CHAR_TERM: -#ifdef POSIX2_CHAR_TERM - *(int *)oldp = 1; -#else - *(int *)oldp = 0; -#endif - return (0); - case USER_POSIX2_FORT_DEV: -#ifdef POSIX2_FORT_DEV - *(int *)oldp = 1; -#else - *(int *)oldp = 0; -#endif - return (0); - case USER_POSIX2_FORT_RUN: -#ifdef POSIX2_FORT_RUN - *(int *)oldp = 1; -#else - *(int *)oldp = 0; -#endif - return (0); - case USER_POSIX2_LOCALEDEF: -#ifdef POSIX2_LOCALEDEF - *(int *)oldp = 1; -#else - *(int *)oldp = 0; -#endif - return (0); - case USER_POSIX2_SW_DEV: -#ifdef POSIX2_SW_DEV - *(int *)oldp = 1; -#else - *(int *)oldp = 0; -#endif - return (0); - case USER_POSIX2_UPE: -#ifdef POSIX2_UPE - *(int *)oldp = 1; -#else - *(int *)oldp = 0; -#endif - return (0); - case USER_STREAM_MAX: - *(int *)oldp = FOPEN_MAX; - return (0); - case USER_TZNAME_MAX: - *(int *)oldp = NAME_MAX; - return (0); - default: - errno = EINVAL; - return (-1); - } - /* NOTREACHED */ -} diff --git a/lib/libc/gen/sysctlbyname.c b/lib/libc/gen/sysctlbyname.c deleted file mode 100644 index 3d19ca2..0000000 --- a/lib/libc/gen/sysctlbyname.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * wrote this file. As long as you retain this notice you - * can do whatever you want with this stuff. If we meet some day, and you think - * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp - * ---------------------------------------------------------------------------- - * - * $FreeBSD$ - * - */ -#include -#include -#include - -int -sysctlbyname(const char *name, void *oldp, size_t *oldlenp, void *newp, - size_t newlen) -{ - int name2oid_oid[2]; - int real_oid[CTL_MAXNAME+2]; - int error; - size_t oidlen; - - name2oid_oid[0] = 0; /* This is magic & undocumented! */ - name2oid_oid[1] = 3; - - oidlen = sizeof(real_oid); - error = sysctl(name2oid_oid, 2, real_oid, &oidlen, (void *)name, - strlen(name)); - if (error < 0) - return error; - oidlen /= sizeof (int); - error = sysctl(real_oid, oidlen, oldp, oldlenp, newp, newlen); - return (error); -} - diff --git a/lib/libc/gen/syslog.3 b/lib/libc/gen/syslog.3 deleted file mode 100644 index 550ce5b..0000000 --- a/lib/libc/gen/syslog.3 +++ /dev/null @@ -1,276 +0,0 @@ -.\" Copyright (c) 1985, 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. -.\" -.\" @(#)syslog.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt SYSLOG 3 -.Os BSD 4.2 -.Sh NAME -.Nm syslog , -.Nm vsyslog , -.Nm openlog , -.Nm closelog , -.Nm setlogmask -.Nd control system log -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Ft void -.Fn syslog "int priority" "const char *message" "..." -.Ft void -.Fn vsyslog "int priority" "const char *message" "va_list args" -.Ft void -.Fn openlog "const char *ident" "int logopt" "int facility" -.Ft void -.Fn closelog void -.Ft int -.Fn setlogmask "int maskpri" -.Sh DESCRIPTION -The -.Fn syslog -function -writes -.Fa message -to the system message logger. -The message is then written to the system console, log files, -logged-in users, or forwarded to other machines as appropriate. -(See -.Xr syslogd 8 . ) -.Pp -The message is identical to a -.Xr printf 3 -format string, except that -.Ql %m -is replaced by the current error -message. -(As denoted by the global variable -.Va errno ; -see -.Xr strerror 3 . ) -A trailing newline is added if none is present. -.Pp -The -.Fn vsyslog -function -is an alternate form in which the arguments have already been captured -using the variable-length argument facilities of -.Xr varargs 3 . -.Pp -The message is tagged with -.Fa priority . -Priorities are encoded as a -.Fa facility -and a -.Em level . -The facility describes the part of the system -generating the message. -The level is selected from the following -.Em ordered -(high to low) list: -.Bl -tag -width LOG_AUTHPRIV -.It Dv LOG_EMERG -A panic condition. -This is normally broadcast to all users. -.It Dv LOG_ALERT -A condition that should be corrected immediately, such as a corrupted -system database. -.It Dv LOG_CRIT -Critical conditions, e.g., hard device errors. -.It Dv LOG_ERR -Errors. -.It Dv LOG_WARNING -Warning messages. -.It Dv LOG_NOTICE -Conditions that are not error conditions, -but should possibly be handled specially. -.It Dv LOG_INFO -Informational messages. -.It Dv LOG_DEBUG -Messages that contain information -normally of use only when debugging a program. -.El -.Pp -The -.Fn openlog -function -provides for more specialized processing of the messages sent -by -.Fn syslog -and -.Fn vsyslog . -The parameter -.Fa ident -is a string that will be prepended to every message. -The -.Fa logopt -argument -is a bit field specifying logging options, which is formed by -.Tn OR Ns 'ing -one or more of the following values: -.Bl -tag -width LOG_AUTHPRIV -.It Dv LOG_CONS -If -.Fn syslog -cannot pass the message to -.Xr syslogd 8 -it will attempt to write the message to the console -.Pq Dq Pa /dev/console. -.It Dv LOG_NDELAY -Open the connection to -.Xr syslogd 8 -immediately. -Normally the open is delayed until the first message is logged. -Useful for programs that need to manage the order in which file -descriptors are allocated. -.It Dv LOG_PERROR -Write the message to standard error output as well to the system log. -.It Dv LOG_PID -Log the process id with each message: useful for identifying -instantiations of daemons. -.El -.Pp -The -.Fa facility -parameter encodes a default facility to be assigned to all messages -that do not have an explicit facility encoded: -.Bl -tag -width LOG_AUTHPRIV -.It Dv LOG_AUTH -The authorization system: -.Xr login 1 , -.Xr su 1 , -.Xr getty 8 , -etc. -.It Dv LOG_AUTHPRIV -The same as -.Dv LOG_AUTH , -but logged to a file readable only by -selected individuals. -.It Dv LOG_CRON -The cron daemon: -.Xr cron 8 . -.It Dv LOG_DAEMON -System daemons, such as -.Xr routed 8 , -that are not provided for explicitly by other facilities. -.It Dv LOG_FTP -The file transfer protocol daemons: -.Xr ftpd 8 , -.Xr tftpd 8 . -.It Dv LOG_KERN -Messages generated by the kernel. -These cannot be generated by any user processes. -.It Dv LOG_LPR -The line printer spooling system: -.Xr lpr 1 , -.Xr lpc 8 , -.Xr lpd 8 , -etc. -.It Dv LOG_MAIL -The mail system. -.It Dv LOG_NEWS -The network news system. -.It Dv LOG_SECURITY -Security subsystems, such as -.It Dv LOG_SYSLOG -Messages generated internally by -.Xr syslogd 8 . -.It Dv LOG_USER -Messages generated by random user processes. -This is the default facility identifier if none is specified. -.It Dv LOG_UUCP -The uucp system. -.Xr ipfw 4 . -.It Dv LOG_LOCAL0 -Reserved for local use. -Similarly for -.Dv LOG_LOCAL1 -through -.Dv LOG_LOCAL7 . -.El -.Pp -The -.Fn closelog -function -can be used to close the log file. -.Pp -The -.Fn setlogmask -function -sets the log priority mask to -.Fa maskpri -and returns the previous mask. -Calls to -.Fn syslog -with a priority not set in -.Fa maskpri -are rejected. -The mask for an individual priority -.Fa pri -is calculated by the macro -.Fn LOG_MASK pri ; -the mask for all priorities up to and including -.Fa toppri -is given by the macro -.Fn LOG_UPTO toppri ; . -The default allows all priorities to be logged. -.Sh RETURN VALUES -The routines -.Fn closelog , -.Fn openlog , -.Fn syslog -and -.Fn vsyslog -return no value. -.Pp -The routine -.Fn setlogmask -always returns the previous log mask level. -.Sh EXAMPLES -.Bd -literal -offset indent -compact -syslog(LOG_ALERT, "who: internal error 23"); - -openlog("ftpd", LOG_PID | LOG_NDELAY, LOG_FTP); - -setlogmask(LOG_UPTO(LOG_ERR)); - -syslog(LOG_INFO, "Connection from host %d", CallingHost); - -syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m"); -.Ed -.Sh SEE ALSO -.Xr logger 1 , -.Xr syslogd 8 -.Sh HISTORY -These -functions appeared in -.Bx 4.2 . diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c deleted file mode 100644 index 18d00d7..0000000 --- a/lib/libc/gen/syslog.c +++ /dev/null @@ -1,365 +0,0 @@ -/* - * Copyright (c) 1983, 1988, 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/* -static char sccsid[] = "@(#)syslog.c 8.5 (Berkeley) 4/29/95"; -*/ -static const char rcsid[] = - "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#if __STDC__ -#include -#else -#include -#endif - -static int LogFile = -1; /* fd for log */ -static int connected; /* have done connect */ -static int opened; /* have done openlog() */ -static int LogStat = 0; /* status bits, set by openlog() */ -static const char *LogTag = NULL; /* string to tag the entry with */ -static int LogFacility = LOG_USER; /* default facility code */ -static int LogMask = 0xff; /* mask of priorities to be logged */ -extern char *__progname; /* Program name, from crt0. */ - -static void disconnectlog __P((void)); /* disconnect from syslogd */ -static void connectlog __P((void)); /* (re)connect to syslogd */ - -/* - * Format of the magic cookie passed through the stdio hook - */ -struct bufcookie { - char *base; /* start of buffer */ - int left; -}; - -/* - * stdio write hook for writing to a static string buffer - * XXX: Maybe one day, dynamically allocate it so that the line length - * is `unlimited'. - */ -static -int writehook(cookie, buf, len) - void *cookie; /* really [struct bufcookie *] */ - char *buf; /* characters to copy */ - int len; /* length to copy */ -{ - struct bufcookie *h; /* private `handle' */ - - h = (struct bufcookie *)cookie; - if (len > h->left) { - /* clip in case of wraparound */ - len = h->left; - } - if (len > 0) { - (void)memcpy(h->base, buf, len); /* `write' it. */ - h->base += len; - h->left -= len; - } - return 0; -} - -/* - * syslog, vsyslog -- - * print message on log file; output is intended for syslogd(8). - */ -void -#if __STDC__ -syslog(int pri, const char *fmt, ...) -#else -syslog(pri, fmt, va_alist) - int pri; - char *fmt; - va_dcl -#endif -{ - va_list ap; - -#if __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - vsyslog(pri, fmt, ap); - va_end(ap); -} - -void -vsyslog(pri, fmt, ap) - int pri; - register const char *fmt; - va_list ap; -{ - register int cnt; - register char ch, *p; - time_t now; - int fd, saved_errno; - char *stdp, tbuf[2048], fmt_cpy[1024]; - FILE *fp, *fmt_fp; - struct bufcookie tbuf_cookie; - struct bufcookie fmt_cookie; - -#define INTERNALLOG LOG_ERR|LOG_CONS|LOG_PERROR|LOG_PID - /* Check for invalid bits. */ - if (pri & ~(LOG_PRIMASK|LOG_FACMASK)) { - syslog(INTERNALLOG, - "syslog: unknown facility/priority: %x", pri); - pri &= LOG_PRIMASK|LOG_FACMASK; - } - - /* Check priority against setlogmask values. */ - if (!(LOG_MASK(LOG_PRI(pri)) & LogMask)) - return; - - saved_errno = errno; - - /* Set default facility if none specified. */ - if ((pri & LOG_FACMASK) == 0) - pri |= LogFacility; - - /* Create the primary stdio hook */ - tbuf_cookie.base = tbuf; - tbuf_cookie.left = sizeof(tbuf); - fp = fwopen(&tbuf_cookie, writehook); - if (fp == NULL) - return; - - /* Build the message. */ - (void)time(&now); - (void)fprintf(fp, "<%d>", pri); - (void)fprintf(fp, "%.15s ", ctime(&now) + 4); - if (LogStat & LOG_PERROR) { - /* Transfer to string buffer */ - (void)fflush(fp); - stdp = tbuf + (sizeof(tbuf) - tbuf_cookie.left); - } - if (LogTag == NULL) - LogTag = __progname; - if (LogTag != NULL) - (void)fprintf(fp, "%s", LogTag); - if (LogStat & LOG_PID) - (void)fprintf(fp, "[%d]", getpid()); - if (LogTag != NULL) { - (void)fprintf(fp, ": "); - } - - /* Check to see if we can skip expanding the %m */ - if (strstr(fmt, "%m")) { - - /* Create the second stdio hook */ - fmt_cookie.base = fmt_cpy; - fmt_cookie.left = sizeof(fmt_cpy) - 1; - fmt_fp = fwopen(&fmt_cookie, writehook); - if (fmt_fp == NULL) { - fclose(fp); - return; - } - - /* Substitute error message for %m. */ - for ( ; (ch = *fmt); ++fmt) - if (ch == '%' && fmt[1] == 'm') { - ++fmt; - fputs(strerror(saved_errno), fmt_fp); - } else - fputc(ch, fmt_fp); - - /* Null terminate if room */ - fputc(0, fmt_fp); - fclose(fmt_fp); - - /* Guarantee null termination */ - fmt_cpy[sizeof(fmt_cpy) - 1] = '\0'; - - fmt = fmt_cpy; - } - - (void)vfprintf(fp, fmt, ap); - (void)fclose(fp); - - cnt = sizeof(tbuf) - tbuf_cookie.left; - - /* Output to stderr if requested. */ - if (LogStat & LOG_PERROR) { - struct iovec iov[2]; - register struct iovec *v = iov; - - v->iov_base = stdp; - v->iov_len = cnt - (stdp - tbuf); - ++v; - v->iov_base = "\n"; - v->iov_len = 1; - (void)writev(STDERR_FILENO, iov, 2); - } - - /* Get connected, output the message to the local logger. */ - if (!opened) - openlog(LogTag, LogStat | LOG_NDELAY, 0); - connectlog(); - if (send(LogFile, tbuf, cnt, 0) >= 0) - return; - - /* - * If the send() failed, the odds are syslogd was restarted. - * Make one (only) attempt to reconnect to /dev/log. - */ - disconnectlog(); - connectlog(); - if (send(LogFile, tbuf, cnt, 0) >= 0) - return; - - /* - * Output the message to the console; don't worry about blocking, - * if console blocks everything will. Make sure the error reported - * is the one from the syslogd failure. - */ - if (LogStat & LOG_CONS && - (fd = _open(_PATH_CONSOLE, O_WRONLY, 0)) >= 0) { - struct iovec iov[2]; - register struct iovec *v = iov; - - p = strchr(tbuf, '>') + 1; - v->iov_base = p; - v->iov_len = cnt - (p - tbuf); - ++v; - v->iov_base = "\r\n"; - v->iov_len = 2; - (void)writev(fd, iov, 2); - (void)_close(fd); - } -} -static void -disconnectlog() -{ - /* - * If the user closed the FD and opened another in the same slot, - * that's their problem. They should close it before calling on - * system services. - */ - if (LogFile != -1) { - _close(LogFile); - LogFile = -1; - } - connected = 0; /* retry connect */ -} - -static void -connectlog() -{ - struct sockaddr_un SyslogAddr; /* AF_UNIX address of local logger */ - - if (LogFile == -1) { - if ((LogFile = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) - return; - (void)_fcntl(LogFile, F_SETFD, 1); - } - if (LogFile != -1 && !connected) { - SyslogAddr.sun_len = sizeof(SyslogAddr); - SyslogAddr.sun_family = AF_UNIX; - (void)strncpy(SyslogAddr.sun_path, _PATH_LOG, - sizeof SyslogAddr.sun_path); - connected = connect(LogFile, (struct sockaddr *)&SyslogAddr, - sizeof(SyslogAddr)) != -1; - - if (!connected) { - /* - * Try the old "/dev/log" path, for backward - * compatibility. - */ - (void)strncpy(SyslogAddr.sun_path, _PATH_OLDLOG, - sizeof SyslogAddr.sun_path); - connected = connect(LogFile, - (struct sockaddr *)&SyslogAddr, - sizeof(SyslogAddr)) != -1; - } - - if (!connected) { - (void)_close(LogFile); - LogFile = -1; - } - } -} - -void -openlog(ident, logstat, logfac) - const char *ident; - int logstat, logfac; -{ - if (ident != NULL) - LogTag = ident; - LogStat = logstat; - if (logfac != 0 && (logfac &~ LOG_FACMASK) == 0) - LogFacility = logfac; - - if (LogStat & LOG_NDELAY) /* open immediately */ - connectlog(); - - opened = 1; /* ident and facility has been set */ -} - -void -closelog() -{ - (void)_close(LogFile); - LogFile = -1; - connected = 0; -} - -/* setlogmask -- set the log mask level */ -int -setlogmask(pmask) - int pmask; -{ - int omask; - - omask = LogMask; - if (pmask != 0) - LogMask = pmask; - return (omask); -} diff --git a/lib/libc/gen/tcgetpgrp.3 b/lib/libc/gen/tcgetpgrp.3 deleted file mode 100644 index 7a026b7..0000000 --- a/lib/libc/gen/tcgetpgrp.3 +++ /dev/null @@ -1,80 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)tcgetpgrp.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt TCGETPGRP 3 -.Os -.Sh NAME -.Nm tcgetpgrp -.Nd get foreground process group ID -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Ft pid_t -.Fn tcgetpgrp "int fd" -.Sh DESCRIPTION -The -.Fn tcgetpgrp -function returns the value of the process group ID of the foreground -process group associated with the terminal device. -If there is no foreground process group, -.Fn tcgetpgrp -returns an invalid process ID. -.Sh ERRORS -If an error occurs, -.Fn tcgetpgrp -returns -1 and the global variable -.Va errno -is set to indicate the error, as follows: -.Bl -tag -width Er -.It Bq Er EBADF -The -.Fa fd -argument is not a valid file descriptor. -.It Bq Er ENOTTY -The calling process does not have a controlling terminal or the -underlying terminal device represented by -.Fa fd -is not the controlling terminal. -.El -.Sh SEE ALSO -.Xr setpgid 2 , -.Xr setsid 2 , -.Xr tcsetpgrp 3 -.Sh STANDARDS -The -.Fn tcgetpgrp -function is expected to be compliant with the -.St -p1003.1-88 -specification. diff --git a/lib/libc/gen/tcsendbreak.3 b/lib/libc/gen/tcsendbreak.3 deleted file mode 100644 index 6b5f754..0000000 --- a/lib/libc/gen/tcsendbreak.3 +++ /dev/null @@ -1,155 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)tcsendbreak.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt TCSENDBREAK 3 -.Os -.Sh NAME -.Nm tcsendbreak , -.Nm tcdrain , -.Nm tcflush , -.Nm tcflow -.Nd line control functions -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn tcdrain "int fd" -.Ft int -.Fn tcflow "int fd" "int action" -.Ft int -.Fn tcflush "int fd" "int action" -.Ft int -.Fn tcsendbreak "int fd" "int len" -.Sh DESCRIPTION -The -.Fn tcdrain -function waits until all output written to the terminal referenced by -.Fa fd -has been transmitted to the terminal. -.Pp -The -.Fn tcflow -function suspends transmission of data to or the reception of data from -the terminal referenced by -.Fa fd -depending on the value of -.Fa action . -The value of -.Fa action -must be one of the following: -.Bl -tag -width "TCIOFF" -.It Fa TCOOFF -Suspend output. -.It Fa TCOON -Restart suspended output. -.It Fa TCIOFF -Transmit a STOP character, which is intended to cause the terminal to stop -transmitting data to the system. -(See the description of IXOFF in the -.Ql Input Modes -section of -.Xr termios 4 ). -.It Fa TCION -Transmit a START character, which is intended to cause the terminal to start -transmitting data to the system. -(See the description of IXOFF in the -.Ql Input Modes -section of -.Xr termios 4 ). -.El -.Pp -The -.Fn tcflush -function discards any data written to the terminal referenced by -.Fa fd -which has not been transmitted to the terminal, or any data received -from the terminal but not yet read, depending on the value of -.Fa action . -The value of -.Fa action -must be one of the following: -.Bl -tag -width "TCIOFLUSH" -.It Fa TCIFLUSH -Flush data received but not read. -.It Fa TCOFLUSH -Flush data written but not transmitted. -.It Fa TCIOFLUSH -Flush both data received but not read and data written but not transmitted. -.El -.Pp -The -.Fn tcsendbreak -function transmits a continuous stream of zero-valued bits for four-tenths -of a second to the terminal referenced by -.Fa fd . -The -.Fa len -parameter is ignored in this implementation. -.Sh RETURN VALUES -Upon successful completion, all of these functions return a value of zero. -.Sh ERRORS -If any error occurs, a value of -1 is returned and the global variable -.Va errno -is set to indicate the error, as follows: -.Bl -tag -width Er -.It Bq Er EBADF -The -.Fa fd -argument is not a valid file descriptor. -.It Bq Er EINVAL -The -.Fa action -argument is not a proper value. -.It Bq Er ENOTTY -The file associated with -.Fa fd -is not a terminal. -.It Bq Er EINTR -A signal interrupted the -.Fn tcdrain -function. -.El -.Sh SEE ALSO -.Xr tcsetattr 3 , -.Xr termios 4 -.Sh STANDARDS -The -.Fn tcsendbreak , -.Fn tcdrain , -.Fn tcflush -and -.Fn tcflow -functions are expected to be compliant with the -.St -p1003.1-88 -specification. diff --git a/lib/libc/gen/tcsetattr.3 b/lib/libc/gen/tcsetattr.3 deleted file mode 100644 index b5c6fd9..0000000 --- a/lib/libc/gen/tcsetattr.3 +++ /dev/null @@ -1,331 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)tcsetattr.3 8.3 (Berkeley) 1/2/94 -.\" $FreeBSD$ -.\" -.Dd January 2, 1994 -.Dt TCSETATTR 3 -.Os -.Sh NAME -.Nm cfgetispeed , -.Nm cfsetispeed , -.Nm cfgetospeed , -.Nm cfsetospeed , -.Nm cfsetspeed , -.Nm cfmakeraw , -.Nm tcgetattr , -.Nm tcsetattr -.Nd manipulating the termios structure -.Sh SYNOPSIS -.Fd #include -.Ft speed_t -.Fn cfgetispeed "const struct termios *t" -.Ft int -.Fn cfsetispeed "struct termios *t" "speed_t speed" -.Ft speed_t -.Fn cfgetospeed "const struct termios *t" -.Ft int -.Fn cfsetospeed "struct termios *t" "speed_t speed" -.Ft int -.Fn cfsetspeed "struct termios *t" "speed_t speed" -.Ft void -.Fn cfmakeraw "struct termios *t" -.Ft int -.Fn tcgetattr "int fd" "struct termios *t" -.Ft int -.Fn tcsetattr "int fd" "int action" "const struct termios *t" -.Sh DESCRIPTION -The -.Fn cfmakeraw , -.Fn tcgetattr -and -.Fn tcsetattr -functions are provided for getting and setting the termios structure. -.Pp -The -.Fn cfgetispeed , -.Fn cfsetispeed , -.Fn cfgetospeed , -.Fn cfsetospeed -and -.Fn cfsetspeed -functions are provided for getting and setting the baud rate values in -the termios structure. -The effects of the functions on the terminal as described below -do not become effective, nor are all errors detected, until the -.Fn tcsetattr -function is called. -Certain values for baud rates set in the termios structure and passed to -.Fn tcsetattr -have special meanings. -These are discussed in the portion of the manual page that describes the -.Fn tcsetattr -function. -.Sh GETTING AND SETTING THE BAUD RATE -The input and output baud rates are found in the termios structure. -The unsigned integer -.Li speed_t -is typdef'd in the include file -.Aq Pa termios.h . -The value of the integer corresponds directly to the baud rate being -represented, however, the following symbolic values are defined. -.Bd -literal -#define B0 0 -#define B50 50 -#define B75 75 -#define B110 110 -#define B134 134 -#define B150 150 -#define B200 200 -#define B300 300 -#define B600 600 -#define B1200 1200 -#define B1800 1800 -#define B2400 2400 -#define B4800 4800 -#define B9600 9600 -#define B19200 19200 -#define B38400 38400 -#ifndef _POSIX_SOURCE -#define EXTA 19200 -#define EXTB 38400 -#endif /*_POSIX_SOURCE */ -.Ed -.Pp -The -.Fn cfgetispeed -function returns the input baud rate in the termios structure referenced by -.Fa tp . -.Pp -The -.Fn cfsetispeed -function sets the input baud rate in the termios structure referenced by -.Fa tp -to -.Fa speed . -.Pp -The -.Fn cfgetospeed -function returns the output baud rate in the termios structure referenced by -.Fa tp . -.Pp -The -.Fn cfsetospeed -function sets the output baud rate in the termios structure referenced by -.Fa tp -to -.Fa speed . -.Pp -The -.Fn cfsetspeed -function sets both the input and output baud rate in the termios structure -referenced by -.Fa tp -to -.Fa speed . -.Pp -Upon successful completion, the functions -.Fn cfsetispeed , -.Fn cfsetospeed , -and -.Fn cfsetspeed -return a value of 0. -Otherwise, a value of -1 is returned and the global variable -.Va errno -is set to indicate the error. -.Sh GETTING AND SETTING THE TERMIOS STATE -This section describes the functions that are used to control the general -terminal interface. -Unless otherwise noted for a specific command, these functions are restricted -from use by background processes. -Attempts to perform these operations shall cause the process group to be sent -a SIGTTOU signal. -If the calling process is blocking or ignoring SIGTTOU signals, the process -is allowed to perform the operation and the SIGTTOU signal is not sent. -.Pp -In all the functions, although -.Fa fd -is an open file descriptor, the functions affect the underlying terminal -file, not just the open file description associated with the particular -file descriptor. -.Pp -The -.Fn cfmakeraw -function sets the flags stored in the termios structure to a state disabling -all input and output processing, giving a -.Dq raw I/O path. -It should be noted that there is no function to reverse this effect. -This is because there are a variety of processing options that could be -re-enabled and the correct method is for an application to snapshot the -current terminal state using the function -.Fn tcgetattr , -setting raw mode with -.Fn cfmakeraw -and the subsequent -.Fn tcsetattr , -and then using another -.Fn tcsetattr -with the saved state to revert to the previous terminal state. -.Pp -The -.Fn tcgetattr -function copies the parameters associated with the terminal referenced -by -.Fa fd -in the termios structure referenced by -.Fa tp . -This function is allowed from a background process, however, the terminal -attributes may be subsequently changed by a foreground process. -.Pp -The -.Fn tcsetattr -function sets the parameters associated with the terminal from the -termios structure referenced by -.Fa tp . -The -.Fa action -field is created by -.Em or Ns 'ing -the following values, as specified in the include file -.Aq Pa termios.h . -.Bl -tag -width "TCSADRAIN" -.It Fa TCSANOW -The change occurs immediately. -.It Fa TCSADRAIN -The change occurs after all output written to -.Fa fd -has been transmitted to the terminal. -This value of -.Fa action -should be used when changing parameters that affect output. -.It Fa TCSAFLUSH -The change occurs after all output written to -.Fa fd -has been transmitted to the terminal. -Additionally, any input that has been received but not read is discarded. -.It Fa TCSASOFT -If this value is -.Em or Ns 'ed -into the -.Fa action -value, the values of the -.Em c_cflag , -.Em c_ispeed , -and -.Em c_ospeed -fields are ignored. -.El -.Pp -The 0 baud rate is used to terminate the connection. -If 0 is specified as the output speed to the function -.Fn tcsetattr , -modem control will no longer be asserted on the terminal, disconnecting -the terminal. -.Pp -If zero is specified as the input speed to the function -.Fn tcsetattr , -the input baud rate will be set to the same value as that specified by -the output baud rate. -.Pp -If -.Fn tcsetattr -is unable to make any of the requested changes, it returns -1 and -sets errno. -Otherwise, it makes all of the requested changes it can. -If the specified input and output baud rates differ and are a combination -that is not supported, neither baud rate is changed. -.Pp -Upon successful completion, the functions -.Fn tcgetattr -and -.Fn tcsetattr -return a value of 0. -Otherwise, they -return -1 and the global variable -.Va errno -is set to indicate the error, as follows: -.Bl -tag -width Er -.It Bq Er EBADF -The -.Fa fd -argument to -.Fn tcgetattr -or -.Fn tcsetattr -was not a valid file descriptor. -.It Bq Er EINTR -The -.Fn tcsetattr -function was interrupted by a signal. -.It Bq Er EINVAL -The -.Fa action -argument to the -.Fn tcsetattr -function was not valid, or an attempt was made to change an attribute -represented in the termios structure to an unsupported value. -.It Bq Er ENOTTY -The file associated with the -.Fa fd -argument to -.Fn tcgetattr -or -.Fn tcsetattr -is not a terminal. -.El -.Sh SEE ALSO -.Xr tcsendbreak 3 , -.Xr termios 4 -.Sh STANDARDS -The -.Fn cfgetispeed , -.Fn cfsetispeed , -.Fn cfgetospeed , -.Fn cfsetospeed , -.Fn tcgetattr -and -.Fn tcsetattr -functions are expected to be compliant with the -.St -p1003.1-88 -specification. -The -.Fn cfmakeraw -and -.Fn cfsetspeed -functions, -as well as the -.Li TCSASOFT -option to the -.Fn tcsetattr -function are extensions to the -.St -p1003.1-88 -specification. diff --git a/lib/libc/gen/tcsetpgrp.3 b/lib/libc/gen/tcsetpgrp.3 deleted file mode 100644 index 3da2cd1..0000000 --- a/lib/libc/gen/tcsetpgrp.3 +++ /dev/null @@ -1,101 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)tcsetpgrp.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt TCSETPGRP 3 -.Os -.Sh NAME -.Nm tcsetpgrp -.Nd set foreground process group ID -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Ft int -.Fn tcsetpgrp "int fd" "pid_t pgrp_id" -.Sh DESCRIPTION -If the process has a controlling terminal, the -.Nm tcsetpgrp -function sets the foreground process group ID associated with the -terminal device to -.Fa pgrp_id . -The terminal device associated with -.Fa fd -must be the controlling terminal of the calling process and the -controlling terminal must be currently associated with the session -of the calling process. -The value of -.Fa pgrp_id -must be the same as the process group ID of a process in the same -session as the calling process. -.Pp -Upon successful completion, -.Nm tcsetpgrp -returns a value of zero. -.Sh ERRORS -If an error occurs, -.Nm tcsetpgrp -returns -1 and the global variable -.Va errno -is set to indicate the error, as follows: -.Bl -tag -width Er -.It Bq Er EBADF -The -.Fa fd -argument is not a valid file descriptor. -.It Bq Er EINVAL -An invalid value of -.Fa pgrp_id -was specified. -.It Bq Er ENOTTY -The calling process does not have a controlling terminal, or the file -represented by -.Fa fd -is not the controlling terminal, or the controlling terminal is no -longer associated with the session of the calling process. -.It Bq Er EPERM -The -.Fa pgrp_id -argument does not match the process group ID of a process in the same -session as the calling process. -.El -.Sh SEE ALSO -.Xr setpgid 2 , -.Xr setsid 2 , -.Xr tcgetpgrp 3 -.Sh STANDARDS -The -.Nm tcsetpgprp -function is expected to be compliant with the -.St -p1003.1-88 -specification. diff --git a/lib/libc/gen/telldir.c b/lib/libc/gen/telldir.c deleted file mode 100644 index ab23d9d..0000000 --- a/lib/libc/gen/telldir.c +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)telldir.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -/* - * The option SINGLEUSE may be defined to say that a telldir - * cookie may be used only once before it is freed. This option - * is used to avoid having memory usage grow without bound. - */ -#define SINGLEUSE - -/* - * 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 */ - const DIR* loc_dirp; /* directory which used this entry */ -}; - -#define NDIRHASH 32 /* Num of hash lists, must be a power of 2 */ -#define LOCHASH(i) ((i)&(NDIRHASH-1)) - -static long dd_loccnt; /* Index of entry for sequential readdir's */ -static struct ddloc *dd_hash[NDIRHASH]; /* Hash list heads for ddlocs */ - -/* - * return a pointer into a directory - */ -long -telldir(dirp) - const DIR *dirp; -{ - register int index; - register struct ddloc *lp; - - if ((lp = (struct ddloc *)malloc(sizeof(struct ddloc))) == NULL) - return (-1); - index = dd_loccnt++; - lp->loc_index = index; - lp->loc_seek = dirp->dd_seek; - lp->loc_loc = dirp->dd_loc; - lp->loc_dirp = dirp; - lp->loc_next = dd_hash[LOCHASH(index)]; - dd_hash[LOCHASH(index)] = lp; - return (index); -} - -/* - * seek to an entry in a directory. - * Only values returned by "telldir" should be passed to seekdir. - */ -void -_seekdir(dirp, loc) - register DIR *dirp; - long loc; -{ - register struct ddloc *lp; - register struct ddloc **prevlp; - struct dirent *dp; - - prevlp = &dd_hash[LOCHASH(loc)]; - lp = *prevlp; - while (lp != NULL) { - if (lp->loc_index == loc) - break; - prevlp = &lp->loc_next; - lp = lp->loc_next; - } - if (lp == NULL) - return; - if (lp->loc_loc == dirp->dd_loc && lp->loc_seek == dirp->dd_seek) - goto found; - (void) lseek(dirp->dd_fd, (off_t)lp->loc_seek, SEEK_SET); - dirp->dd_seek = lp->loc_seek; - dirp->dd_loc = 0; - while (dirp->dd_loc < lp->loc_loc) { - dp = readdir(dirp); - if (dp == NULL) - break; - } -found: -#ifdef SINGLEUSE - *prevlp = lp->loc_next; - free((caddr_t)lp); -#endif -} - -/* - * Reclaim memory for telldir cookies which weren't used. - */ -void -_reclaim_telldir(dirp) - register const DIR *dirp; -{ - register struct ddloc *lp; - register struct ddloc **prevlp; - int i; - - for (i = 0; i < NDIRHASH; i++) { - prevlp = &dd_hash[i]; - lp = *prevlp; - while (lp != NULL) { - if (lp->loc_dirp == dirp) { - *prevlp = lp->loc_next; - free((caddr_t)lp); - lp = *prevlp; - continue; - } - prevlp = &lp->loc_next; - lp = lp->loc_next; - } - } -} diff --git a/lib/libc/gen/termios.c b/lib/libc/gen/termios.c deleted file mode 100644 index f321876..0000000 --- a/lib/libc/gen/termios.c +++ /dev/null @@ -1,250 +0,0 @@ -/*- - * 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)termios.c 8.2 (Berkeley) 2/21/94"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -#include -#include -#include - -int -tcgetattr(fd, t) - int fd; - struct termios *t; -{ - - return (ioctl(fd, TIOCGETA, t)); -} - -int -tcsetattr(fd, opt, t) - int fd, opt; - const struct termios *t; -{ - struct termios localterm; - - if (opt & TCSASOFT) { - localterm = *t; - localterm.c_cflag |= CIGNORE; - t = &localterm; - } - switch (opt & ~TCSASOFT) { - case TCSANOW: - return (ioctl(fd, TIOCSETA, t)); - case TCSADRAIN: - return (ioctl(fd, TIOCSETAW, t)); - case TCSAFLUSH: - return (ioctl(fd, TIOCSETAF, t)); - default: - errno = EINVAL; - return (-1); - } -} - -int -#if __STDC__ -tcsetpgrp(int fd, pid_t pgrp) -#else -tcsetpgrp(fd, pgrp) - int fd; - pid_t pgrp; -#endif -{ - int s; - - s = pgrp; - return (ioctl(fd, TIOCSPGRP, &s)); -} - -pid_t -tcgetpgrp(fd) - int fd; -{ - int s; - - if (ioctl(fd, TIOCGPGRP, &s) < 0) - return ((pid_t)-1); - - return ((pid_t)s); -} - -speed_t -cfgetospeed(t) - const struct termios *t; -{ - - return (t->c_ospeed); -} - -speed_t -cfgetispeed(t) - const struct termios *t; -{ - - return (t->c_ispeed); -} - -int -cfsetospeed(t, speed) - struct termios *t; - speed_t speed; -{ - - t->c_ospeed = speed; - return (0); -} - -int -cfsetispeed(t, speed) - struct termios *t; - speed_t speed; -{ - - t->c_ispeed = speed; - return (0); -} - -int -cfsetspeed(t, speed) - struct termios *t; - speed_t speed; -{ - - t->c_ispeed = t->c_ospeed = speed; - return (0); -} - -/* - * Make a pre-existing termios structure into "raw" mode: character-at-a-time - * mode with no characters interpreted, 8-bit data path. - */ -void -cfmakeraw(t) - struct termios *t; -{ - - t->c_iflag &= ~(IMAXBEL|IXOFF|INPCK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON|IGNPAR); - t->c_iflag |= IGNBRK; - t->c_oflag &= ~OPOST; - t->c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|ICANON|ISIG|IEXTEN|NOFLSH|TOSTOP|PENDIN); - t->c_cflag &= ~(CSIZE|PARENB); - t->c_cflag |= CS8|CREAD; - t->c_cc[VMIN] = 1; - t->c_cc[VTIME] = 0; -} - -int -tcsendbreak(fd, len) - int fd, len; -{ - struct timeval sleepytime; - - sleepytime.tv_sec = 0; - sleepytime.tv_usec = 400000; - if (ioctl(fd, TIOCSBRK, 0) == -1) - return (-1); - (void)select(0, 0, 0, 0, &sleepytime); - if (ioctl(fd, TIOCCBRK, 0) == -1) - return (-1); - return (0); -} - -int -__tcdrain(fd) - int fd; -{ - return (ioctl(fd, TIOCDRAIN, 0)); -} - -#ifndef _THREAD_SAFE -__weak_reference(__tcdrain, tcdrain); -#endif - -int -tcflush(fd, which) - int fd, which; -{ - int com; - - switch (which) { - case TCIFLUSH: - com = FREAD; - break; - case TCOFLUSH: - com = FWRITE; - break; - case TCIOFLUSH: - com = FREAD | FWRITE; - break; - default: - errno = EINVAL; - return (-1); - } - return (ioctl(fd, TIOCFLUSH, &com)); -} - -int -tcflow(fd, action) - int fd, action; -{ - struct termios term; - u_char c; - - switch (action) { - case TCOOFF: - return (ioctl(fd, TIOCSTOP, 0)); - case TCOON: - return (ioctl(fd, TIOCSTART, 0)); - case TCION: - case TCIOFF: - if (tcgetattr(fd, &term) == -1) - return (-1); - c = term.c_cc[action == TCIOFF ? VSTOP : VSTART]; - if (c != _POSIX_VDISABLE && _write(fd, &c, sizeof(c)) == -1) - return (-1); - return (0); - default: - errno = EINVAL; - return (-1); - } - /* NOTREACHED */ -} diff --git a/lib/libc/gen/time.3 b/lib/libc/gen/time.3 deleted file mode 100644 index 71c1982..0000000 --- a/lib/libc/gen/time.3 +++ /dev/null @@ -1,86 +0,0 @@ -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (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.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt TIME 3 -.Os BSD 4 -.Sh NAME -.Nm time -.Nd get time of day -.Sh SYNOPSIS -.Fd #include -.Ft time_t -.Fn time "time_t *tloc" -.Sh DESCRIPTION -The -.Fn time -function -returns the value of time in seconds since 0 hours, 0 minutes, -0 seconds, January 1, 1970, Coordinated Universal Time. -.Pp -A copy of the time value may be saved to the area indicated by the -pointer -.Fa tloc . -If -.Fa tloc -is a NULL pointer, no value is stored. -.Pp -Upon successful completion, -.Fn time -returns the value of time. -Otherwise a value of -.Po -.Po Fa time_t Pc \-1 -.Pc -is returned and the global variable -.Va errno -is set to indicate the error. -.Sh ERRORS -The following error codes may be set in -.Va errno : -.Bl -tag -width [EFAULT] -.It Bq Er EFAULT -An argument address referenced invalid memory. -.Sh SEE ALSO -.Xr gettimeofday 2 , -.Xr ctime 3 -.Sh HISTORY -A -.Fn time -function appeared in -.At v6 . diff --git a/lib/libc/gen/time.c b/lib/libc/gen/time.c deleted file mode 100644 index 044d3a2..0000000 --- a/lib/libc/gen/time.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)time.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -time_t -time(t) - time_t *t; -{ - struct timeval tt; - - if (gettimeofday(&tt, (struct timezone *)0) < 0) - return(-1); - if (t) - *t = tt.tv_sec; - return(tt.tv_sec); -} diff --git a/lib/libc/gen/times.3 b/lib/libc/gen/times.3 deleted file mode 100644 index b971e2d..0000000 --- a/lib/libc/gen/times.3 +++ /dev/null @@ -1,138 +0,0 @@ -.\" Copyright (c) 1990, 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. -.\" -.\" @(#)times.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt TIMES 3 -.Os BSD 4 -.Sh NAME -.Nm times -.Nd process times -.Sh SYNOPSIS -.Fd #include -.Ft clock_t -.Fn times "struct tms *tp" -.Sh DESCRIPTION -.Bf -symbolic -This interface is obsoleted by getrusage(2) -and gettimeofday(3). -.Ef -.Pp -The -.Fn times -function returns the value of time in -.Dv CLK_TCK Ns 's -of a second since -0 hours, 0 minutes, 0 seconds, January 1, 1970, Coordinated Universal -Time. -.Pp -It also fills in the structure pointed to by -.Fa tp -with time-accounting information. -.Pp -The -.Fa tms -structure is defined as follows: -.Bd -literal -offset indent -typedef struct { - clock_t tms_utime; - clock_t tms_stime; - clock_t tms_cutime; - clock_t tms_cstime; -} -.Ed -.Pp -The elements of this structure are defined as follows: -.Bl -tag -width tms_cutime -.It Fa tms_utime -The -.Tn CPU -time charged for the execution of user instructions. -.It Fa tms_stime -The -.Tn CPU -time charged for execution by the system on behalf of -the process. -.It Fa tms_cutime -The sum of the -.Fa tms_utime s -and -.Fa tms_cutime s -of the child processes. -.It Fa tms_cstime -The sum of the -.Fa tms_stime Ns s -and -.Fa tms_cstime Ns s -of the child processes. -.El -.Pp -All times are in -.Dv CLK_TCK Ns 's -of a second. -.Pp -The times of a terminated child process are included in the -.Fa tms_cutime -and -.Fa tms_cstime -elements of the parent when one of the -.Xr wait 2 -functions returns the process ID of the terminated child to the parent. -If an error occurs, -.Fn times -returns the value -.Pq (clock_t)\-1 , -and sets errno to indicate the error. -.Sh ERRORS -The -.Fn times -function -may fail and set the global variable -.Va errno -for any of the errors specified for the library -routines -.Xr getrusage 2 -and -.Xr gettimeofday 2 . -.Sh SEE ALSO -.Xr time 1 , -.Xr getrusage 2 , -.Xr gettimeofday 2 , -.Xr wait 2 , -.Xr clocks 7 -.Sh STANDARDS -The -.Fn times -function -conforms to -.St -p1003.1-88 . diff --git a/lib/libc/gen/times.c b/lib/libc/gen/times.c deleted file mode 100644 index c145d0a..0000000 --- a/lib/libc/gen/times.c +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * Copyright (c) 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)times.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -/* - * Convert usec to clock ticks; could do (usec * CLK_TCK) / 1000000, - * but this would overflow if we switch to nanosec. - */ -#define CONVTCK(r) (r.tv_sec * CLK_TCK + r.tv_usec / (1000000 / CLK_TCK)) - -clock_t -times(tp) - register struct tms *tp; -{ - struct rusage ru; - struct timeval t; - - if (getrusage(RUSAGE_SELF, &ru) < 0) - return ((clock_t)-1); - tp->tms_utime = CONVTCK(ru.ru_utime); - tp->tms_stime = CONVTCK(ru.ru_stime); - if (getrusage(RUSAGE_CHILDREN, &ru) < 0) - return ((clock_t)-1); - tp->tms_cutime = CONVTCK(ru.ru_utime); - tp->tms_cstime = CONVTCK(ru.ru_stime); - if (gettimeofday(&t, (struct timezone *)0)) - return ((clock_t)-1); - return ((clock_t)(CONVTCK(t))); -} diff --git a/lib/libc/gen/timezone.3 b/lib/libc/gen/timezone.3 deleted file mode 100644 index 7468aa4..0000000 --- a/lib/libc/gen/timezone.3 +++ /dev/null @@ -1,68 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)timezone.3 8.2 (Berkeley) 4/19/94 -.\" $FreeBSD$ -.\" -.Dd April 19, 1994 -.Dt TIMEZONE 3 -.Os -.Sh NAME -.Nm timezone -.Nd return the timezone abbreviation -.Sh SYNOPSIS -.Ft char * -.Fn timezone "int zone" "int dst" -.Sh DESCRIPTION -.ft B -This interface is for compatibility only; it is impossible to reliably -map timezone's arguments to a time zone abbreviation. -See ctime(3). -.ft P -.Pp -The -.Fn timezone -function returns a pointer to a time zone abbreviation for the specified -.Ar zone -and -.Ar dst -values. -.Ar Zone -is the number of minutes west of GMT and -.Ar dst -is non-zero if daylight savings time is in effect. -.Sh SEE ALSO -.Xr ctime 3 -.Sh HISTORY -A -.Fn timezone -function appeared in -.At v7 . diff --git a/lib/libc/gen/timezone.c b/lib/libc/gen/timezone.c deleted file mode 100644 index 74086ef..0000000 --- a/lib/libc/gen/timezone.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 1987, 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)timezone.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#define TZ_MAX_CHARS 255 - -char *_tztab(); - -/* - * timezone -- - * The arguments are the number of minutes of time you are westward - * from Greenwich and whether DST is in effect. It returns a string - * giving the name of the local timezone. Should be replaced, in the - * application code, by a call to localtime. - */ - -static char czone[TZ_MAX_CHARS]; /* space for zone name */ - -char * -timezone(zone, dst) - int zone, - dst; -{ - register char *beg, - *end; - - if ( (beg = getenv("TZNAME")) ) { /* set in environment */ - if ( (end = index(beg, ',')) ) {/* "PST,PDT" */ - if (dst) - return(++end); - *end = '\0'; - (void)strncpy(czone,beg,sizeof(czone) - 1); - czone[sizeof(czone) - 1] = '\0'; - *end = ','; - return(czone); - } - return(beg); - } - return(_tztab(zone,dst)); /* default: table or created zone */ -} - -static struct zone { - int offset; - char *stdzone; - char *dlzone; -} zonetab[] = { - {-1*60, "MET", "MET DST"}, /* Middle European */ - {-2*60, "EET", "EET DST"}, /* Eastern European */ - {4*60, "AST", "ADT"}, /* Atlantic */ - {5*60, "EST", "EDT"}, /* Eastern */ - {6*60, "CST", "CDT"}, /* Central */ - {7*60, "MST", "MDT"}, /* Mountain */ - {8*60, "PST", "PDT"}, /* Pacific */ -#ifdef notdef - /* there's no way to distinguish this from WET */ - {0, "GMT", 0}, /* Greenwich */ -#endif - {0*60, "WET", "WET DST"}, /* Western European */ - {-10*60,"EST", "EST"}, /* Aust: Eastern */ - {-10*60+30,"CST", "CST"}, /* Aust: Central */ - {-8*60, "WST", 0}, /* Aust: Western */ - {-1} -}; - -/* - * _tztab -- - * check static tables or create a new zone name; broken out so that - * we can make a guess as to what the zone is if the standard tables - * aren't in place in /etc. DO NOT USE THIS ROUTINE OUTSIDE OF THE - * STANDARD LIBRARY. - */ -char * -_tztab(zone,dst) - register int zone; - int dst; -{ - register struct zone *zp; - register char sign; - - for (zp = zonetab; zp->offset != -1;++zp) /* static tables */ - if (zp->offset == zone) { - if (dst && zp->dlzone) - return(zp->dlzone); - if (!dst && zp->stdzone) - return(zp->stdzone); - } - - if (zone < 0) { /* create one */ - zone = -zone; - sign = '+'; - } - else - sign = '-'; - (void)snprintf(czone, sizeof(czone), - "GMT%c%d:%02d",sign,zone / 60,zone % 60); - return(czone); -} diff --git a/lib/libc/gen/ttyname.3 b/lib/libc/gen/ttyname.3 deleted file mode 100644 index 5e7bb4e..0000000 --- a/lib/libc/gen/ttyname.3 +++ /dev/null @@ -1,129 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)ttyname.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt TTYNAME 3 -.Os -.Sh NAME -.Nm ttyname , -.Nm isatty , -.Nm ttyslot -.Nd get name of associated terminal (tty) from file descriptor -.Sh SYNOPSIS -.Fd #include -.Ft char * -.Fn ttyname "int fd" -.Ft int -.Fn isatty "int fd" -.Ft int -.Fn ttyslot void -.Sh DESCRIPTION -These functions operate on the system file descriptors for terminal -type devices. -These descriptors are not related to the standard -.Tn I/O -.Dv FILE -typedef, but refer to the special device files found in -.Pa /dev -and named -.Pa /dev/tty Ns Em xx -and for which an entry exists -in the initialization file -.Pa /etc/ttys. -(See -.Xr ttys 5 . ) -.Pp -The -.Fn isatty -function -determines if the file descriptor -.Fa fd -refers to a valid -terminal type device. -.Pp -The -.Fn ttyname -function -gets the related device name of -a file descriptor for which -.Fn isatty -is true -.Pp -The -.Fn ttyslot -function -fetches the current process' control terminal number from the -.Xr ttys 5 -file entry. -.Sh RETURN VALUES -The -.Fn ttyname -function -returns the null terminated name if the device is found and -.Fn isatty -is true; otherwise -a -.Dv NULL -pointer is returned. -.Pp -The -.Fn ttyslot -function -returns the unit number of the device file if found; otherwise -the value zero is returned. -.Sh FILES -.Bl -tag -width /etc/ttys -compact -.It Pa /dev/\(** -.It Pa /etc/ttys -.El -.Sh SEE ALSO -.Xr ioctl 2 , -.Xr ttys 5 -.Sh HISTORY -A -.Fn isatty , -.Fn ttyname , -and -.Fn ttyslot -function -appeared in -.At v7 . -.Sh BUGS -The -.Fn ttyname -function leaves its result in an internal static object and returns -a pointer to that object. -Subsequent calls to -.Fn ttyname -will modify the same object. diff --git a/lib/libc/gen/ttyname.c b/lib/libc/gen/ttyname.c deleted file mode 100644 index cb01870..0000000 --- a/lib/libc/gen/ttyname.c +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright (c) 1988, 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)ttyname.c 8.2 (Berkeley) 1/27/94"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _THREAD_SAFE -#include -#include "pthread_private.h" -static struct pthread_mutex _ttyname_lockd = PTHREAD_MUTEX_STATIC_INITIALIZER; -static pthread_mutex_t ttyname_lock = &_ttyname_lockd; -static pthread_key_t ttyname_key; -static int ttyname_init = 0; - -char * -ttyname(int fd) -{ - char *ret; - - if (_FD_LOCK(fd, FD_READ, NULL) == 0) { - ret = __ttyname_basic(fd); - _FD_UNLOCK(fd, FD_READ); - } else { - ret = NULL; - } - - return (ret); -} - -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(fd)) - return (rval); - /* Must be a character device. */ - if (_thread_sys_fstat(fd, &sb) || !S_ISCHR(sb.st_mode)) - return (rval); - /* Must have enough room */ - if (len <= sizeof(_PATH_DEV)) - return (rval); - - if ((dp = opendir(_PATH_DEV)) != NULL) { - memcpy(buf, _PATH_DEV, sizeof(_PATH_DEV)); - for (rval = NULL; (dirp = readdir(dp)) != NULL;) { - if (dirp->d_fileno != sb.st_ino) - continue; - minlen = (len - (sizeof(_PATH_DEV) - 1)) < (dirp->d_namlen + 1) ? - (len - (sizeof(_PATH_DEV) - 1)) : (dirp->d_namlen + 1); - memcpy(buf + sizeof(_PATH_DEV) - 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_DEV) + MAXNAMLEN)) != NULL) { - if (pthread_setspecific(ttyname_key, buf) != 0) { - free(buf); - return (NULL); - } - } else { - return (NULL); - } - } - return (__ttyname_r_basic(fd, buf, sizeof(_PATH_DEV) + MAXNAMLEN)); -} - -char * -ttyname_r(int fd, char *buf, size_t len) -{ - char *ret; - - if (_FD_LOCK(fd, FD_READ, NULL) == 0) { - ret = __ttyname_r_basic(fd, buf, len); - _FD_UNLOCK(fd, FD_READ); - } else { - ret = NULL; - } - return (ret); -} -#else -static char buf[sizeof(_PATH_DEV) + MAXNAMLEN] = _PATH_DEV; -static char *oldttyname __P((int, struct stat *)); - -char * -ttyname(fd) - int fd; -{ - struct stat sb; - struct termios ttyb; - DB *db; - DBT data, key; - struct { - mode_t type; - dev_t dev; - } bkey; - - /* Must be a terminal. */ - if (tcgetattr(fd, &ttyb) < 0) - return (NULL); - /* Must be a character device. */ - if (fstat(fd, &sb) || !S_ISCHR(sb.st_mode)) - return (NULL); - - if ( (db = dbopen(_PATH_DEVDB, O_RDONLY, 0, DB_HASH, NULL)) ) { - memset(&bkey, 0, sizeof(bkey)); - bkey.type = S_IFCHR; - bkey.dev = sb.st_rdev; - key.data = &bkey; - key.size = sizeof(bkey); - if (!(db->get)(db, &key, &data, 0)) { - bcopy(data.data, - buf + sizeof(_PATH_DEV) - 1, data.size); - (void)(db->close)(db); - return (buf); - } - (void)(db->close)(db); - } - return (oldttyname(fd, &sb)); -} - -static char * -oldttyname(fd, sb) - int fd; - struct stat *sb; -{ - register struct dirent *dirp; - register DIR *dp; - struct stat dsb; - - if ((dp = opendir(_PATH_DEV)) == NULL) - return (NULL); - - while ( (dirp = readdir(dp)) ) { - if (dirp->d_fileno != sb->st_ino) - continue; - bcopy(dirp->d_name, buf + sizeof(_PATH_DEV) - 1, - dirp->d_namlen + 1); - if (stat(buf, &dsb) || sb->st_dev != dsb.st_dev || - sb->st_ino != dsb.st_ino) - continue; - (void)closedir(dp); - return (buf); - } - (void)closedir(dp); - return (NULL); -} -#endif diff --git a/lib/libc/gen/ttyslot.c b/lib/libc/gen/ttyslot.c deleted file mode 100644 index 2f72ebb..0000000 --- a/lib/libc/gen/ttyslot.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 1988, 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)ttyslot.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -int -ttyslot() -{ - register struct ttyent *ttyp; - register int slot; - register char *p; - int cnt; - char *name; - - setttyent(); - for (cnt = 0; cnt < 3; ++cnt) - if ( (name = ttyname(cnt)) ) { - if ( (p = rindex(name, '/')) ) - ++p; - else - p = name; - for (slot = 1; (ttyp = getttyent()); ++slot) - if (!strcmp(ttyp->ty_name, p)) { - endttyent(); - return(slot); - } - break; - } - endttyent(); - return(0); -} diff --git a/lib/libc/gen/tzset.3 b/lib/libc/gen/tzset.3 deleted file mode 100644 index 853a1da..0000000 --- a/lib/libc/gen/tzset.3 +++ /dev/null @@ -1,326 +0,0 @@ -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Arthur Olson. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)tzset.3 8.2 (Berkeley) 11/17/93 -.\" $FreeBSD$ -.\" -.Dd November 17, 1993 -.Dt TZSET 3 -.Os -.Sh NAME -.Nm tzset , -.Nm tzsetwall -.Nd initialize time conversion information -.Sh SYNOPSIS -.Fd #include -.Ft void -.Fn tzset void -.Ft void -.Fn tzsetwall void -.Sh DESCRIPTION -The -.Fn tzset -function -initializes time conversion information used by the library routine -.Xr localtime 3 . -The environment variable -.Ev TZ -specifies how this is done. -.Pp -If -.Ev TZ -does not appear in the environment, the best available approximation to -local wall clock time, as specified by the -.Xr tzfile 5 Ns -format -file -.Pa /etc/localtime -is used. -.Pp -If -.Ev TZ -appears in the environment but its value is a null string, Coordinated -Universal Time -.Pq Tn UTC -is used (without leap second correction). -.Pp -If -.Ev TZ -appears in the environment and its value begins with a colon -.Pq Ql \: , -the rest of its value is used as a pathname of a -.Xr tzfile 5 Ns -format -file from which to read the time conversion information. -If the first character of the pathname is a slash -.Pq Ql / -it is used as -an absolute pathname; otherwise, it is used as a pathname relative to -the system time conversion information directory. -.Pp -If its value does not begin with a colon, it is first used as the pathname -of a file (as described above) from which to read the time conversion -information. -If that file cannot be read, the value is then interpreted as a direct -specification (the format is described below) of the time conversion -information. -.Pp -If the -.Ev TZ -environment variable does not specify a -.Xr tzfile 5 Ns -format -file and cannot be interpreted as a direct specification, -.Tn UTC -is used. -.Pp -The -.Fn tzsetwall -function -sets things up so that -.Xr localtime -returns the best available approximation of local wall clock time. -.Sh SPECIFICATION FORMAT -When -.Ev TZ -is used directly as a specification of the time conversion information, -it must have the following syntax (spaces inserted for clarity): -.Bd -filled -offset indent -.Em std offset Bo -.Em dst Bo -.Em offset -.Bc -.Bo -.No , Em rule -.Bc -.Bc -.Ed -.Pp -Where: -.Bl -tag -width std_and_dst -offset indent -.It Em std No and Em dst -Three or more bytes that are the designation for the standard -.Pq Em std -or summer -.Pq Em dst -time zone. Only -.Em std -is required; if -.Em dst -is missing, then summer time does not apply in this locale. -Upper and lowercase letters are explicitly allowed. Any characters -except a leading colon -.Pq Ql \: , -digits, comma -.Pq Ql \&, , -minus -.Pq Ql \- , -plus -.Pq Ql + , -and -.Tn ASCII -.Dv NUL -are allowed. -.It Em offset -Indicates the value one must add to the local time to arrive at -Coordinated Universal Time. The -.Em offset -has the form: -.Bd -unfilled -offset indent -.Em hh Bo -.Pf \&: Em mm -.Bo -.Pf \&: Em ss -.Bc -.Bc -.Ed -.Pp -The minutes -.Pq Em mm -and seconds -.Pq Em ss -are optional. The hour -.Pq Em hh -is required and may be a single digit. The -.Em offset -following -.Em std -is required. If no -.Em offset -follows -.Em dst , -summer time is assumed to be one hour ahead of standard time. One or -more digits may be used; the value is always interpreted as a decimal -number. The hour must be between zero and 24, and the minutes (and -seconds) \(em if present \(em between zero and 59. If preceded by a -.Pq Ql \- -the time zone shall be east of the Prime Meridian; otherwise it shall be -west (which may be indicated by an optional preceding -.Pq Ql + ) . -.It Em rule -Indicates when to change to and back from summer time. The -.Em rule -has the form: -.Bd -filled -offset indent -.Em date/time,date/time -.Ed -.Pp -where the first -.Em date -describes when the change from standard to summer time occurs and the -second -.Em date -describes when the change back happens. Each -.Em time -field describes when, in current local time, the change to the other -time is made. -.Pp -The format of -.Em date -is one of the following: -.Bl -tag -width "M.m.n.d" -.It Sy J Em n -The Julian day -.Em n -(1 \*(Le -.Em n -\*(Le 365). -Leap days are not counted; that is, in all years \(em including leap -years \(em February 28 is day 59 and March 1 is day 60. It is -impossible to explicitly refer to the occasional February 29. -.It Em n -The zero-based Julian day -(0 \*(Le -.Em n -\*(Le 365 ) . -Leap days are counted, and it is possible to refer to February 29. -.It Sy M Em m.n.d -The -.Em d Ns 'th -day (0 \*(Le -.Em d -\*(Le 6 ) -of week -.Em n -of month -.Em m -of the year -(1 \*(Le -.Em n -\*(Le 5), -(1 \*(Le -.Em m -\*(Le 12), -where week 5 means -.Do -the last -.Em d -day in month -.Em m -.Dc -which may occur in either the fourth or the fifth week). Week 1 is the -first week in which the -.Em d Ns 'th -day occurs. Day zero is Sunday. -.Pp -The -.Em time -has the same format as -.Em offset -except that no leading sign -.Pq Ql \- -or -.Pq Ql + -is allowed. The default, if -.Em time -is not given, is -.Sy 02:00:00 . -.El -.Pp -If no -.Em rule -is present in the -.Ev TZ -specification, the rules specified -by the -.Xr tzfile 5 Ns -format -file -.Em posixrules -in the system time conversion information directory are used, with the -standard and summer time offsets from -.Tn UTC -replaced by those specified by -the -.Em offset -values in -.Ev TZ . -.El -.Pp -For compatibility with System V Release 3.1, a semicolon -.Pq Ql \; -may be used to separate the -.Em rule -from the rest of the specification. -.Sh FILES -.Bl -tag -width /usr/share/zoneinfo/posixrules -compact -.It Pa /etc/localtime -local time zone file -.It Pa /usr/share/zoneinfo -time zone directory -.It Pa /usr/share/zoneinfo/posixrules -rules for -.Tn POSIX Ns -style -.Tn TZ Ns 's -.It Pa /usr/share/zoneinfo/GMT for -.Tn UTC -leap seconds -.El -.Pp -If the file -.Pa /usr/share/zoneinfo/GMT -does not exist, -.Tn UTC -leap seconds are loaded from -.Pa /usr/share/zoneinfo/posixrules . -.Sh SEE ALSO -.Xr date 1 , -.Xr gettimeofday 2 , -.Xr ctime 3 , -.Xr getenv 3 , -.Xr time 3 , -.Xr tzfile 5 -.Sh HISTORY -The -.Fn tzset -and -.Fn tzsetwall -functions first appeared in -.Bx 4.4 . diff --git a/lib/libc/gen/ualarm.3 b/lib/libc/gen/ualarm.3 deleted file mode 100644 index bbf9457..0000000 --- a/lib/libc/gen/ualarm.3 +++ /dev/null @@ -1,99 +0,0 @@ -.\" Copyright (c) 1986, 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. -.\" -.\" From: @(#)ualarm.3 8.2 (Berkeley) 4/19/94 -.\" $FreeBSD$ -.\" -.Dd April 19, 1994 -.Dt UALARM 3 -.Os BSD 4.3 -.Sh NAME -.Nm ualarm -.Nd schedule signal after specified time -.Sh SYNOPSIS -.Fd #include -.Ft u_int -.Fn ualarm "u_int microseconds" "u_int interval" -.Sh DESCRIPTION -.Bf -symbolic -This is a simplified interface to setitimer(2). -.Ef -.Pp -The -.Fn ualarm -function -waits a count of -.Ar microseconds -before asserting the terminating signal -.Dv SIGALRM . -System activity or time used in processing the call may cause a slight -delay. -.Pp -If the -.Fa interval -argument is non-zero, the -.Dv SIGALRM -signal will be sent -to the process every -.Fa interval -microseconds after the timer expires (e.g. after -.Fa value -microseconds have passed). -.Pp -Due to -.Xr setitimer 2 -restriction the maximum number of -.Ar microseconds -and -.Ar interval -is limited to 100000000000000 -(in case this value fit in the unsigned integer). -.Sh RETURN VALUES -When the signal has successfully been caught, -.Fn ualarm -returns the amount of time left on the clock. -.Sh NOTES -.Pp -A microsecond is 0.000001 seconds. -.Sh SEE ALSO -.Xr getitimer 2 , -.Xr setitimer 2 , -.Xr sigpause 2 , -.Xr sigvec 2 , -.Xr alarm 3 , -.Xr signal 3 , -.Xr sleep 3 , -.Xr usleep 3 -.Sh HISTORY -The -.Fn ualarm -function appeared in -.Bx 4.3 . diff --git a/lib/libc/gen/ualarm.c b/lib/libc/gen/ualarm.c deleted file mode 100644 index ec49a2d..0000000 --- a/lib/libc/gen/ualarm.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 1985, 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)ualarm.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#define USPS 1000000 /* # of microseconds in a second */ - -/* - * Generate a SIGALRM signal in ``usecs'' microseconds. - * If ``reload'' is non-zero, keep generating SIGALRM - * every ``reload'' microseconds after the first signal. - */ -unsigned -ualarm(usecs, reload) - register unsigned usecs; - register unsigned reload; -{ - struct itimerval new, old; - - new.it_interval.tv_usec = reload % USPS; - new.it_interval.tv_sec = reload / USPS; - - new.it_value.tv_usec = usecs % USPS; - new.it_value.tv_sec = usecs / USPS; - - if (setitimer(ITIMER_REAL, &new, &old) == 0) - return (old.it_value.tv_sec * USPS + old.it_value.tv_usec); - /* else */ - return (-1); -} diff --git a/lib/libc/gen/uname.3 b/lib/libc/gen/uname.3 deleted file mode 100644 index 6a3aef6..0000000 --- a/lib/libc/gen/uname.3 +++ /dev/null @@ -1,94 +0,0 @@ -.\" Copyright (c) 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. -.\" -.\" @(#)uname.3 8.1 (Berkeley) 1/4/94 -.\" $FreeBSD$ -.\" -.Dd January 4, 1994 -.Dt UNAME 3 -.Os -.Sh NAME -.Nm uname -.Nd get system identification -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn uname "struct utsname *name" -.Sh DESCRIPTION -The -.Fn uname -function stores nul-terminated strings of information identifying -the current system into the structure referenced by -.Fa name . -.Pp -The -.Li utsname -structure is defined in the -.Li -header file, and contains the following members: -.Bl -tag -width nodenameXXXX -offset indent -.It sysname -Name of the operating system implementation. -.It nodename -Network name of this machine. -.It release -Release level of the operating system. -.It version -Version level of the operating system. -.It machine -Machine hardware platform. -.El -.Sh RETURN VALUES -If -.Fn uname -is successful, 0 is returned, otherwise, -1 is returned and -.Va errno -is set appropriately. -.Sh ERRORS -The -.Fn uname -function may fail and set -.Va errno -for any of the errors specified for the library functions -.Xr sysctl 3 . -.Sh SEE ALSO -.Xr uname 1 , -.Xr sysctl 3 -.Sh STANDARDS -The -.Fn uname -function conforms to -.St -p1003.1-88 . -.Sh HISTORY -The -.Fn uname -function first appeared in -.Bx 4.4 . diff --git a/lib/libc/gen/uname.c b/lib/libc/gen/uname.c deleted file mode 100644 index 944c2dc..0000000 --- a/lib/libc/gen/uname.c +++ /dev/null @@ -1,125 +0,0 @@ -/*- - * Copyright (c) 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char sccsid[] = "From: @(#)uname.c 8.1 (Berkeley) 1/4/94";*/ -static const char rcsid[] = - "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -int -uname(name) - struct utsname *name; -{ - int mib[2], rval; - size_t len; - char *p; - int oerrno; - - rval = 0; - - mib[0] = CTL_KERN; - mib[1] = KERN_OSTYPE; - len = sizeof(name->sysname); - oerrno = errno; - if (sysctl(mib, 2, &name->sysname, &len, NULL, 0) == -1) { - if(errno == ENOMEM) - errno = oerrno; - else - rval = -1; - } - name->sysname[sizeof(name->sysname) - 1] = '\0'; - - mib[0] = CTL_KERN; - mib[1] = KERN_HOSTNAME; - len = sizeof(name->nodename); - oerrno = errno; - if (sysctl(mib, 2, &name->nodename, &len, NULL, 0) == -1) { - if(errno == ENOMEM) - errno = oerrno; - else - rval = -1; - } - name->nodename[sizeof(name->nodename) - 1] = '\0'; - - mib[0] = CTL_KERN; - mib[1] = KERN_OSRELEASE; - len = sizeof(name->release); - oerrno = errno; - if (sysctl(mib, 2, &name->release, &len, NULL, 0) == -1) { - if(errno == ENOMEM) - errno = oerrno; - else - rval = -1; - } - name->release[sizeof(name->release) - 1] = '\0'; - - /* The version may have newlines in it, turn them into spaces. */ - mib[0] = CTL_KERN; - mib[1] = KERN_VERSION; - len = sizeof(name->version); - oerrno = errno; - if (sysctl(mib, 2, &name->version, &len, NULL, 0) == -1) { - if (errno == ENOMEM) - errno = oerrno; - else - rval = -1; - } - name->version[sizeof(name->version) - 1] = '\0'; - for (p = name->version; len--; ++p) { - if (*p == '\n' || *p == '\t') { - if (len > 1) - *p = ' '; - else - *p = '\0'; - } - } - - mib[0] = CTL_HW; - mib[1] = HW_MACHINE; - len = sizeof(name->machine); - oerrno = errno; - if (sysctl(mib, 2, &name->machine, &len, NULL, 0) == -1) { - if (errno == ENOMEM) - errno = oerrno; - else - rval = -1; - } - name->machine[sizeof(name->machine) - 1] = '\0'; - return (rval); -} diff --git a/lib/libc/gen/unvis.3 b/lib/libc/gen/unvis.3 deleted file mode 100644 index 16734d1..0000000 --- a/lib/libc/gen/unvis.3 +++ /dev/null @@ -1,164 +0,0 @@ -.\" Copyright (c) 1989, 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. -.\" -.\" @(#)unvis.3 8.2 (Berkeley) 12/11/93 -.\" $FreeBSD$ -.\" -.Dd December 11, 1993 -.Dt UNVIS 3 -.Os -.Sh NAME -.Nm unvis , -.Nm strunvis -.Nd decode a visual representation of characters -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn unvis "char *cp" "int c" "int *astate" "int flag" -.Ft int -.Fn strunvis "char *dst" "const char *src" -.Sh DESCRIPTION -The -.Fn unvis -and -.Fn strunvis -functions -are used to decode a visual representation of characters, as produced -by the -.Xr vis 3 -function, back into -the original form. Unvis is called with successive characters in -.Ar c -until a valid -sequence is recognized, at which time the decoded character is -available at the character pointed to by -.Ar cp . -Strunvis decodes the -characters pointed to by -.Ar src -into the buffer pointed to by -.Ar dst . -.Pp -The -.Fn strunvis -function -simply copies -.Ar src -to -.Ar dst , -decoding any escape sequences along the way, -and returns the number of characters placed into -.Ar dst , -or \-1 if an -invalid escape sequence was detected. The size of -.Ar dst -should be -equal to the size of -.Ar src -(that is, no expansion takes place during -decoding). -.Pp -The -.Fn unvis -function -implements a state machine that can be used to decode an arbitrary -stream of bytes. All state associated with the bytes being decoded -is stored outside the -.Fn unvis -function (that is, a pointer to the state is passed in), so -calls decoding different streams can be freely intermixed. To -start decoding a stream of bytes, first initialize an integer -to zero. Call -.Fn unvis -with each successive byte, along with a pointer -to this integer, and a pointer to a destination character. -The -.Fn unvis -function -has several return codes that must be handled properly. They are: -.Bl -tag -width UNVIS_VALIDPUSH -.It Li \&0 (zero) -Another character is necessary; nothing has been recognized yet. -.It Dv UNVIS_VALID -A valid character has been recognized and is available at the location -pointed to by cp. -.It Dv UNVIS_VALIDPUSH -A valid character has been recognized and is available at the location -pointed to by cp; however, the character currently passed in should -be passed in again. -.It Dv UNVIS_NOCHAR -A valid sequence was detected, but no character was produced. This -return code is necessary to indicate a logical break between characters. -.It Dv UNVIS_SYNBAD -An invalid escape sequence was detected, or the decoder is in an -unknown state. The decoder is placed into the starting state. -.El -.Pp -When all bytes in the stream have been processed, call -.Fn unvis -one more time with flag set to -.Dv UNVIS_END -to extract any remaining character (the character passed in is ignored). -.Pp -The following code fragment illustrates a proper use of -.Fn unvis . -.Bd -literal -offset indent -int state = 0; -char out; - -while ((ch = getchar()) != EOF) { -again: - switch(unvis(&out, ch, &state, 0)) { - case 0: - case UNVIS_NOCHAR: - break; - case UNVIS_VALID: - (void) putchar(out); - break; - case UNVIS_VALIDPUSH: - (void) putchar(out); - goto again; - case UNVIS_SYNBAD: - (void)fprintf(stderr, "bad sequence!\n"); - exit(1); - } -} -if (unvis(&out, (char)0, &state, UNVIS_END) == UNVIS_VALID) - (void) putchar(out); -.Ed -.Sh SEE ALSO -.Xr vis 1 -.Sh HISTORY -The -.Nm unvis -function -first appeared in -.Bx 4.4 . diff --git a/lib/libc/gen/unvis.c b/lib/libc/gen/unvis.c deleted file mode 100644 index 32405df..0000000 --- a/lib/libc/gen/unvis.c +++ /dev/null @@ -1,247 +0,0 @@ -/*- - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* - * decode driven by state machine - */ -#define S_GROUND 0 /* haven't seen escape char */ -#define S_START 1 /* start decoding special sequence */ -#define S_META 2 /* metachar started (M) */ -#define S_META1 3 /* metachar more, regular char (-) */ -#define S_CTRL 4 /* control char started (^) */ -#define S_OCTAL2 5 /* octal digit 2 */ -#define S_OCTAL3 6 /* octal digit 3 */ - -#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7') - -/* - * unvis - decode characters previously encoded by vis - */ -int -unvis(cp, c, astate, flag) - char *cp; - int c, *astate, flag; -{ - - if (flag & UNVIS_END) { - if (*astate == S_OCTAL2 || *astate == S_OCTAL3) { - *astate = S_GROUND; - return (UNVIS_VALID); - } - return (*astate == S_GROUND ? UNVIS_NOCHAR : UNVIS_SYNBAD); - } - - switch (*astate) { - - case S_GROUND: - *cp = 0; - if (c == '\\') { - *astate = S_START; - return (0); - } - *cp = c; - return (UNVIS_VALID); - - case S_START: - switch(c) { - case '\\': - *cp = c; - *astate = S_GROUND; - return (UNVIS_VALID); - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - *cp = (c - '0'); - *astate = S_OCTAL2; - return (0); - case 'M': - *cp = 0200; - *astate = S_META; - return (0); - case '^': - *astate = S_CTRL; - return (0); - case 'n': - *cp = '\n'; - *astate = S_GROUND; - return (UNVIS_VALID); - case 'r': - *cp = '\r'; - *astate = S_GROUND; - return (UNVIS_VALID); - case 'b': - *cp = '\b'; - *astate = S_GROUND; - return (UNVIS_VALID); - case 'a': - *cp = '\007'; - *astate = S_GROUND; - return (UNVIS_VALID); - case 'v': - *cp = '\v'; - *astate = S_GROUND; - return (UNVIS_VALID); - case 't': - *cp = '\t'; - *astate = S_GROUND; - return (UNVIS_VALID); - case 'f': - *cp = '\f'; - *astate = S_GROUND; - return (UNVIS_VALID); - case 's': - *cp = ' '; - *astate = S_GROUND; - return (UNVIS_VALID); - case 'E': - *cp = '\033'; - *astate = S_GROUND; - return (UNVIS_VALID); - case '\n': - /* - * hidden newline - */ - *astate = S_GROUND; - return (UNVIS_NOCHAR); - case '$': - /* - * hidden marker - */ - *astate = S_GROUND; - return (UNVIS_NOCHAR); - } - *astate = S_GROUND; - return (UNVIS_SYNBAD); - - case S_META: - if (c == '-') - *astate = S_META1; - else if (c == '^') - *astate = S_CTRL; - else { - *astate = S_GROUND; - return (UNVIS_SYNBAD); - } - return (0); - - case S_META1: - *astate = S_GROUND; - *cp |= c; - return (UNVIS_VALID); - - case S_CTRL: - if (c == '?') - *cp |= 0177; - else - *cp |= c & 037; - *astate = S_GROUND; - return (UNVIS_VALID); - - case S_OCTAL2: /* second possible octal digit */ - if (isoctal(c)) { - /* - * yes - and maybe a third - */ - *cp = (*cp << 3) + (c - '0'); - *astate = S_OCTAL3; - return (0); - } - /* - * no - done with current sequence, push back passed char - */ - *astate = S_GROUND; - return (UNVIS_VALIDPUSH); - - case S_OCTAL3: /* third possible octal digit */ - *astate = S_GROUND; - if (isoctal(c)) { - *cp = (*cp << 3) + (c - '0'); - return (UNVIS_VALID); - } - /* - * we were done, push back passed char - */ - return (UNVIS_VALIDPUSH); - - default: - /* - * decoder in unknown state - (probably uninitialized) - */ - *astate = S_GROUND; - return (UNVIS_SYNBAD); - } -} - -/* - * strunvis - decode src into dst - * - * Number of chars decoded into dst is returned, -1 on error. - * Dst is null terminated. - */ - -int -strunvis(dst, src) - register char *dst; - register const char *src; -{ - register char c; - char *start = dst; - int state = 0; - - while ( (c = *src++) ) { - again: - switch (unvis(dst, c, &state, 0)) { - case UNVIS_VALID: - dst++; - break; - case UNVIS_VALIDPUSH: - dst++; - goto again; - case 0: - case UNVIS_NOCHAR: - break; - default: - return (-1); - } - } - if (unvis(dst, c, &state, UNVIS_END) == UNVIS_VALID) - dst++; - *dst = '\0'; - return (dst - start); -} diff --git a/lib/libc/gen/usleep.3 b/lib/libc/gen/usleep.3 deleted file mode 100644 index 77d6259..0000000 --- a/lib/libc/gen/usleep.3 +++ /dev/null @@ -1,81 +0,0 @@ -.\" Copyright (c) 1986, 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. -.\" -.\" @(#)usleep.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd Feb 13, 1998 -.Dt USLEEP 3 -.Os BSD 4.3 -.Sh NAME -.Nm usleep -.Nd suspend process execution for an interval measured in microseconds -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn usleep "unsigned int microseconds" -.Sh DESCRIPTION -The -.Fn usleep -function suspends execution of the calling process until either -.Fa microseconds -microseconds have elapsed or a signal is delivered to the process and its -action is to invoke a signal-catching function or to terminate the -process. -System activity may lengthen the sleep by an indeterminate amount. -.Pp -This function is implemented using -.Xr nanosleep 2 -by pausing for -.Fa microseconds -microseconds or until a signal occurs. -Consequently, in this implementation, -sleeping has no effect on the state of process timers, -and there is no special handling for SIGALRM. -.Sh RETURN VALUES -.Rv -std usleep -.Sh ERRORS -The -.Fn usleep -function -will fail if: -.Bl -tag -width [EINTR] -.It Bq Er EINTR -A signal was delivered to the process and its -action was to invoke a signal-catching function. -.Sh SEE ALSO -.Xr nanosleep 2 , -.Xr sleep 3 -.Sh HISTORY -The -.Fn usleep -function appeared in -.Bx 4.3 . diff --git a/lib/libc/gen/usleep.c b/lib/libc/gen/usleep.c deleted file mode 100644 index 651edf9..0000000 --- a/lib/libc/gen/usleep.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)usleep.c 8.1 (Berkeley) 6/4/93"; -#endif -static char rcsid[] = - "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -int -usleep(useconds) - unsigned int useconds; -{ - struct timespec time_to_sleep; - - time_to_sleep.tv_nsec = (useconds % 1000000) * 1000; - time_to_sleep.tv_sec = useconds / 1000000; - return (_nanosleep(&time_to_sleep, NULL)); -} diff --git a/lib/libc/gen/utime.3 b/lib/libc/gen/utime.3 deleted file mode 100644 index b8d66fd..0000000 --- a/lib/libc/gen/utime.3 +++ /dev/null @@ -1,88 +0,0 @@ -.\" Copyright (c) 1980, 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. -.\" -.\" @(#)utime.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt UTIME 3 -.Os BSD 4 -.Sh NAME -.Nm utime -.Nd set file times -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Ft int -.Fn utime "const char *file" "const struct utimbuf *timep" -.Sh DESCRIPTION -.Bf -symbolic -This interface is obsoleted by utimes(2) . -.Ef -.Pp -The -.Fn utime -function sets the access and modification times of the named file from -the structures in the argument array -.Fa timep . -.Pp -If the times are specified (the -.Fa timep -argument is -.Pf non- Dv NULL ) -the caller must be the owner of the file or be the super-user. -.Pp -If the times are not specified (the -.Fa timep -argument is -.Dv NULL ) -the caller must be the owner of the file, have permission to write -the file, or be the super-user. -.Sh ERRORS -The -.Fn utime -function may fail and set -.Va errno -for any of the errors specified for the library function -.Xr utimes 2 . -.Sh SEE ALSO -.Xr stat 2 , -.Xr utimes 2 -.Sh HISTORY -A -.Fn utime -function appeared in -.At v7 . -.Sh STANDARDS -The -.Fn utime -function conforms to -.St -p1003.1-88 . diff --git a/lib/libc/gen/utime.c b/lib/libc/gen/utime.c deleted file mode 100644 index a561fd6..0000000 --- a/lib/libc/gen/utime.c +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * Copyright (c) 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)utime.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include - -int -utime(path, times) - const char *path; - const struct utimbuf *times; -{ - struct timeval tv[2], *tvp; - - if (times) { - tv[0].tv_sec = times->actime; - tv[1].tv_sec = times->modtime; - tv[0].tv_usec = tv[1].tv_usec = 0; - tvp = tv; - } else - tvp = NULL; - return (utimes(path, tvp)); -} diff --git a/lib/libc/gen/valloc.3 b/lib/libc/gen/valloc.3 deleted file mode 100644 index e97d1f3..0000000 --- a/lib/libc/gen/valloc.3 +++ /dev/null @@ -1,76 +0,0 @@ -.\" Copyright (c) 1980, 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. -.\" -.\" @(#)valloc.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt VALLOC 3 -.Os BSD 3 -.Sh NAME -.Nm valloc -.Nd aligned memory allocation function -.Sh SYNOPSIS -.Fd #include -.Ft void * -.Fn valloc "size_t size" -.Sh DESCRIPTION -.Bf -symbolic -Valloc is obsoleted by the current version of malloc(3), -which aligns page-sized and larger allocations. -.Ef -.Pp -The -.Fn valloc -function -allocates -.Fa size -bytes aligned on a page boundary. -It is implemented by calling -.Xr malloc 3 -with a slightly larger request, saving the true beginning of the block -allocated, and returning a properly aligned pointer. -.Sh RETURN VALUES -The -.Fn valloc -function returns -a pointer to the allocated space if successful; otherwise -a null pointer is returned -.Sh HISTORY -The -.Fn valloc -function appeared in -.Bx 3.0 . -.Sh BUGS -A -.Em vfree -function -has not been implemented. diff --git a/lib/libc/gen/valloc.c b/lib/libc/gen/valloc.c deleted file mode 100644 index 6035329..0000000 --- a/lib/libc/gen/valloc.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1980, 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)valloc.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -void * -valloc(i) - size_t i; -{ - long valsiz = getpagesize(), j; - void *cp = malloc(i + (valsiz-1)); - - j = ((long)cp + (valsiz-1)) &~ (valsiz-1); - return ((void *)j); -} diff --git a/lib/libc/gen/vis.3 b/lib/libc/gen/vis.3 deleted file mode 100644 index e8860b0..0000000 --- a/lib/libc/gen/vis.3 +++ /dev/null @@ -1,265 +0,0 @@ -.\" Copyright (c) 1989, 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. -.\" -.\" From: @(#)vis.3 8.1 (Berkeley) 6/9/93 -.\" $FreeBSD$ -.\" -.Dd July 25, 1996 -.Dt VIS 3 -.Os -.Sh NAME -.Nm vis -.Nd visually encode characters -.Sh SYNOPSIS -.Fd #include -.Ft char * -.Fn vis "char *dst" "int c" "int flag" "int nextc" -.Ft int -.Fn strvis "char *dst" "const char *src" "int flag" -.Ft int -.Fn strvisx "char *dst" "const char *src" "size_t len" "int flag" -.Sh DESCRIPTION -The -.Fn vis -function -copies into -.Fa dst -a string which represents the character -.Fa c . -If -.Fa c -needs no encoding, it is copied in unaltered. The string is -null terminated, and a pointer to the end of the string is -returned. The maximum length of any encoding is four -characters (not including the trailing -.Dv NUL ) ; -thus, when -encoding a set of characters into a buffer, the size of the buffer should -be four times the number of characters encoded, plus one for the trailing -.Dv NUL . -The flag parameter is used for altering the default range of -characters considered for encoding and for altering the visual -representation. -The additional character, -.Fa nextc , -is only used when selecting the -.Dv VIS_CSTYLE -encoding format (explained below). -.Pp -The -.Fn strvis -and -.Fn strvisx -functions copy into -.Fa dst -a visual representation of -the string -.Fa src . -The -.Fn strvis -function encodes characters from -.Fa src -up to the -first -.Dv NUL . -The -.Fn strvisx -function encodes exactly -.Fa len -characters from -.Fa src -(this -is useful for encoding a block of data that may contain -.Dv NUL Ns 's). -Both forms -.Dv NUL -terminate -.Fa dst . -The size of -.Fa dst -must be four times the number -of characters encoded from -.Fa src -(plus one for the -.Dv NUL ) . -Both -forms return the number of characters in dst (not including -the trailing -.Dv NUL ) . -.Pp -The encoding is a unique, invertible representation composed entirely of -graphic characters; it can be decoded back into the original form using -the -.Xr unvis 3 -or -.Xr strunvis 3 -functions. -.Pp -There are two parameters that can be controlled: the range of -characters that are encoded, and the type -of representation used. -By default, all non-graphic characters. -except space, tab, and newline are encoded. -(See -.Xr isgraph 3 . ) -The following flags -alter this: -.Bl -tag -width VIS_WHITEX -.It Dv VIS_SP -Also encode space. -.It Dv VIS_TAB -Also encode tab. -.It Dv VIS_NL -Also encode newline. -.It Dv VIS_WHITE -Synonym for -.Dv VIS_SP -\&| -.Dv VIS_TAB -\&| -.Dv VIS_NL . -.It Dv VIS_SAFE -Only encode "unsafe" characters. Unsafe means control -characters which may cause common terminals to perform -unexpected functions. Currently this form allows space, -tab, newline, backspace, bell, and return - in addition -to all graphic characters - unencoded. -.El -.Pp -There are three forms of encoding. -All forms use the backslash character -.Ql \e -to introduce a special -sequence; two backslashes are used to represent a real backslash. -These are the visual formats: -.Bl -tag -width VIS_CSTYLE -.It (default) -Use an -.Ql M -to represent meta characters (characters with the 8th -bit set), and use carat -.Ql ^ -to represent control characters see -.Pf ( Xr iscntrl 3 ) . -The following formats are used: -.Bl -tag -width xxxxx -.It Dv \e^C -Represents the control character -.Ql C . -Spans characters -.Ql \e000 -through -.Ql \e037 , -and -.Ql \e177 -(as -.Ql \e^? ) . -.It Dv \eM-C -Represents character -.Ql C -with the 8th bit set. -Spans characters -.Ql \e241 -through -.Ql \e376 . -.It Dv \eM^C -Represents control character -.Ql C -with the 8th bit set. -Spans characters -.Ql \e200 -through -.Ql \e237 , -and -.Ql \e377 -(as -.Ql \eM^? ) . -.It Dv \e040 -Represents -.Tn ASCII -space. -.It Dv \e240 -Represents Meta-space. -.El -.Pp -.It Dv VIS_CSTYLE -Use C-style backslash sequences to represent standard non-printable -characters. -The following sequences are used to represent the indicated characters: -.Bd -unfilled -offset indent -.Li \ea Tn - BEL No (007) -.Li \eb Tn - BS No (010) -.Li \ef Tn - NP No (014) -.Li \en Tn - NL No (012) -.Li \er Tn - CR No (015) -.Li \et Tn - HT No (011) -.Li \ev Tn - VT No (013) -.Li \e0 Tn - NUL No (000) -.Ed -.Pp -When using this format, the nextc parameter is looked at to determine -if a -.Dv NUL -character can be encoded as -.Ql \e0 -instead of -.Ql \e000 . -If -.Fa nextc -is an octal digit, the latter representation is used to -avoid ambiguity. -.It Dv VIS_OCTAL -Use a three digit octal sequence. The form is -.Ql \eddd -where -.Em d -represents an octal digit. -.El -.Pp -There is one additional flag, -.Dv VIS_NOSLASH , -which inhibits the -doubling of backslashes and the backslash before the default -format (that is, control characters are represented by -.Ql ^C -and -meta characters as -.Ql M-C ) . -With this flag set, the encoding is -ambiguous and non-invertible. -.Sh SEE ALSO -.Xr unvis 1 , -.Xr strunvis 3 , -.Xr unvis 3 -.Sh HISTORY -These functions first appeared in -.Bx 4.4 . - diff --git a/lib/libc/gen/vis.c b/lib/libc/gen/vis.c deleted file mode 100644 index 61aa836..0000000 --- a/lib/libc/gen/vis.c +++ /dev/null @@ -1,187 +0,0 @@ -/*- - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)vis.c 8.1 (Berkeley) 7/19/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7') - -/* - * vis - visually encode characters - */ -char * -vis(dst, c, flag, nextc) - register char *dst; - int c, nextc; - register int flag; -{ - c = (unsigned char)c; - if (isgraph(c) || - ((flag & VIS_SP) == 0 && c == ' ') || - ((flag & VIS_TAB) == 0 && c == '\t') || - ((flag & VIS_NL) == 0 && c == '\n') || - ((flag & VIS_SAFE) && (c == '\b' || c == '\007' || c == '\r'))) { - *dst++ = c; - if (c == '\\' && (flag & VIS_NOSLASH) == 0) - *dst++ = '\\'; - *dst = '\0'; - return (dst); - } - - if (flag & VIS_CSTYLE) { - switch(c) { - case '\n': - *dst++ = '\\'; - *dst++ = 'n'; - goto done; - case '\r': - *dst++ = '\\'; - *dst++ = 'r'; - goto done; - case '\b': - *dst++ = '\\'; - *dst++ = 'b'; - goto done; -#if __STDC__ - case '\a': -#else - case '\007': -#endif - *dst++ = '\\'; - *dst++ = 'a'; - goto done; - case '\v': - *dst++ = '\\'; - *dst++ = 'v'; - goto done; - case '\t': - *dst++ = '\\'; - *dst++ = 't'; - goto done; - case '\f': - *dst++ = '\\'; - *dst++ = 'f'; - goto done; - case ' ': - *dst++ = '\\'; - *dst++ = 's'; - goto done; - case '\0': - *dst++ = '\\'; - *dst++ = '0'; - if (isoctal(nextc)) { - *dst++ = '0'; - *dst++ = '0'; - } - goto done; - } - } - if (((c & 0177) == ' ') || (flag & VIS_OCTAL)) { - *dst++ = '\\'; - *dst++ = ((u_char)c >> 6 & 07) + '0'; - *dst++ = ((u_char)c >> 3 & 07) + '0'; - *dst++ = ((u_char)c & 07) + '0'; - goto done; - } - if ((flag & VIS_NOSLASH) == 0) - *dst++ = '\\'; - if (c & 0200) { - c &= 0177; - *dst++ = 'M'; - } - if (iscntrl(c)) { - *dst++ = '^'; - if (c == 0177) - *dst++ = '?'; - else - *dst++ = c + '@'; - } else { - *dst++ = '-'; - *dst++ = c; - } -done: - *dst = '\0'; - return (dst); -} - -/* - * strvis, strvisx - visually encode characters from src into dst - * - * Dst must be 4 times the size of src to account for possible - * expansion. The length of dst, not including the trailing NULL, - * is returned. - * - * Strvisx encodes exactly len bytes from src into dst. - * This is useful for encoding a block of data. - */ -int -strvis(dst, src, flag) - register char *dst; - register const char *src; - int flag; -{ - register char c; - char *start; - - for (start = dst; (c = *src); ) - dst = vis(dst, c, flag, *++src); - *dst = '\0'; - return (dst - start); -} - -int -strvisx(dst, src, len, flag) - register char *dst; - register const char *src; - register size_t len; - int flag; -{ - int c; - char *start; - - for (start = dst; len > 1; len--) { - c = *src; - dst = vis(dst, c, flag, *++src); - } - if (len) - dst = vis(dst, *src, flag, '\0'); - *dst = '\0'; - - return (dst - start); -} diff --git a/lib/libc/gen/wait.c b/lib/libc/gen/wait.c deleted file mode 100644 index 366e262..0000000 --- a/lib/libc/gen/wait.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 1988, 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)wait.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -pid_t -__wait(istat) - int *istat; -{ - return (wait4(WAIT_ANY, istat, 0, (struct rusage *)0)); -} - -#ifndef _THREAD_SAFE -__weak_reference(__wait, wait); -#endif diff --git a/lib/libc/gen/wait3.c b/lib/libc/gen/wait3.c deleted file mode 100644 index c8d8f9e..0000000 --- a/lib/libc/gen/wait3.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1988, 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)wait3.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -pid_t -wait3(istat, options, rup) - int *istat; - int options; - struct rusage *rup; -{ - return (wait4(WAIT_ANY, istat, options, rup)); -} diff --git a/lib/libc/gen/waitpid.c b/lib/libc/gen/waitpid.c deleted file mode 100644 index 350157a..0000000 --- a/lib/libc/gen/waitpid.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 1988, 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)waitpid.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -pid_t -#if __STDC__ -__waitpid(pid_t pid, int *istat, int options) -#else -__waitpid(pid, istat, options) - pid_t pid; - int *istat; - int options; -#endif -{ - return (wait4(pid, istat, options, (struct rusage *)0)); -} - -#ifndef _THREAD_SAFE -__weak_reference(__waitpid, waitpid); -#endif diff --git a/lib/libc/gmon/Makefile.inc b/lib/libc/gmon/Makefile.inc deleted file mode 100644 index 1b8a906..0000000 --- a/lib/libc/gmon/Makefile.inc +++ /dev/null @@ -1,17 +0,0 @@ -# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 -# $FreeBSD$ - -# gmon sources -.PATH: ${.CURDIR}/../libc/gmon - -SRCS+= gmon.c mcount.c - -.if ${LIB} == "c" -MAN3+= moncontrol.3 - -MLINKS+=moncontrol.3 monstartup.3 -.endif - -# mcount cannot be compiled with profiling -mcount.po: mcount.o - cp mcount.o mcount.po diff --git a/lib/libc/gmon/gmon.c b/lib/libc/gmon/gmon.c deleted file mode 100644 index 6bf3d5b..0000000 --- a/lib/libc/gmon/gmon.c +++ /dev/null @@ -1,263 +0,0 @@ -/*- - * Copyright (c) 1983, 1992, 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. - * - * $FreeBSD$ - */ - -#if !defined(lint) && defined(LIBC_SCCS) -static char sccsid[] = "@(#)gmon.c 8.1 (Berkeley) 6/4/93"; -#endif - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#if defined(__ELF__) && defined(i386) -extern char *minbrk asm (".minbrk"); -#else -extern char *minbrk asm ("minbrk"); -#endif - -extern char *__progname; - -struct gmonparam _gmonparam = { GMON_PROF_OFF }; - -static int s_scale; -/* see profil(2) where this is describe (incorrectly) */ -#define SCALE_1_TO_1 0x10000L - -#define ERR(s) _write(2, s, sizeof(s)) - -void moncontrol __P((int)); -static int hertz __P((void)); - -void -monstartup(lowpc, highpc) - u_long lowpc; - u_long highpc; -{ - register int o; - char *cp; - struct gmonparam *p = &_gmonparam; - - /* - * round lowpc and highpc to multiples of the density we're using - * so the rest of the scaling (here and in gprof) stays in ints. - */ - p->lowpc = ROUNDDOWN(lowpc, HISTFRACTION * sizeof(HISTCOUNTER)); - p->highpc = ROUNDUP(highpc, HISTFRACTION * sizeof(HISTCOUNTER)); - p->textsize = p->highpc - p->lowpc; - p->kcountsize = p->textsize / HISTFRACTION; - p->hashfraction = HASHFRACTION; - p->fromssize = p->textsize / HASHFRACTION; - p->tolimit = p->textsize * ARCDENSITY / 100; - if (p->tolimit < MINARCS) - p->tolimit = MINARCS; - else if (p->tolimit > MAXARCS) - p->tolimit = MAXARCS; - p->tossize = p->tolimit * sizeof(struct tostruct); - - cp = sbrk(p->kcountsize + p->fromssize + p->tossize); - if (cp == (char *)-1) { - ERR("monstartup: out of memory\n"); - return; - } -#ifdef notdef - bzero(cp, p->kcountsize + p->fromssize + p->tossize); -#endif - p->tos = (struct tostruct *)cp; - cp += p->tossize; - p->kcount = (u_short *)cp; - cp += p->kcountsize; - p->froms = (u_short *)cp; - - minbrk = sbrk(0); - p->tos[0].link = 0; - - o = p->highpc - p->lowpc; - if (p->kcountsize < o) { -#ifndef hp300 - s_scale = ((float)p->kcountsize / o ) * SCALE_1_TO_1; -#else /* avoid floating point */ - int quot = o / p->kcountsize; - - if (quot >= 0x10000) - s_scale = 1; - else if (quot >= 0x100) - s_scale = 0x10000 / quot; - else if (o >= 0x800000) - s_scale = 0x1000000 / (o / (p->kcountsize >> 8)); - else - s_scale = 0x1000000 / ((o << 8) / p->kcountsize); -#endif - } else - s_scale = SCALE_1_TO_1; - - moncontrol(1); -} - -void -_mcleanup() -{ - int fd; - int fromindex; - int endfrom; - u_long frompc; - int toindex; - struct rawarc rawarc; - struct gmonparam *p = &_gmonparam; - struct gmonhdr gmonhdr, *hdr; - struct clockinfo clockinfo; - char outname[128]; - int mib[2]; - size_t size; -#ifdef DEBUG - int log, len; - char buf[200]; -#endif - - if (p->state == GMON_PROF_ERROR) - ERR("_mcleanup: tos overflow\n"); - - size = sizeof(clockinfo); - mib[0] = CTL_KERN; - mib[1] = KERN_CLOCKRATE; - if (sysctl(mib, 2, &clockinfo, &size, NULL, 0) < 0) { - /* - * Best guess - */ - clockinfo.profhz = hertz(); - } else if (clockinfo.profhz == 0) { - if (clockinfo.hz != 0) - clockinfo.profhz = clockinfo.hz; - else - clockinfo.profhz = hertz(); - } - - moncontrol(0); - snprintf(outname,sizeof(outname),"%s.gmon",__progname); - fd = _open(outname, O_CREAT|O_TRUNC|O_WRONLY, 0666); - if (fd < 0) { - warnx("_mcleanup: %s - %s",outname,strerror(errno)); - return; - } -#ifdef DEBUG - log = _open("gmon.log", O_CREAT|O_TRUNC|O_WRONLY, 0664); - if (log < 0) { - perror("_mcleanup: gmon.log"); - return; - } - len = sprintf(buf, "[mcleanup1] kcount 0x%x ssiz %d\n", - p->kcount, p->kcountsize); - _write(log, buf, len); -#endif - hdr = (struct gmonhdr *)&gmonhdr; - hdr->lpc = p->lowpc; - hdr->hpc = p->highpc; - hdr->ncnt = p->kcountsize + sizeof(gmonhdr); - hdr->version = GMONVERSION; - hdr->profrate = clockinfo.profhz; - _write(fd, (char *)hdr, sizeof *hdr); - _write(fd, p->kcount, p->kcountsize); - endfrom = p->fromssize / sizeof(*p->froms); - for (fromindex = 0; fromindex < endfrom; fromindex++) { - if (p->froms[fromindex] == 0) - continue; - - frompc = p->lowpc; - frompc += fromindex * p->hashfraction * sizeof(*p->froms); - for (toindex = p->froms[fromindex]; toindex != 0; - toindex = p->tos[toindex].link) { -#ifdef DEBUG - len = sprintf(buf, - "[mcleanup2] frompc 0x%x selfpc 0x%x count %d\n" , - frompc, p->tos[toindex].selfpc, - p->tos[toindex].count); - _write(log, buf, len); -#endif - rawarc.raw_frompc = frompc; - rawarc.raw_selfpc = p->tos[toindex].selfpc; - rawarc.raw_count = p->tos[toindex].count; - _write(fd, &rawarc, sizeof rawarc); - } - } - _close(fd); -} - -/* - * Control profiling - * profiling is what mcount checks to see if - * all the data structures are ready. - */ -void -moncontrol(mode) - int mode; -{ - struct gmonparam *p = &_gmonparam; - - if (mode) { - /* start */ - profil((char *)p->kcount, p->kcountsize, p->lowpc, s_scale); - p->state = GMON_PROF_ON; - } else { - /* stop */ - profil((char *)0, 0, 0, 0); - p->state = GMON_PROF_OFF; - } -} - -/* - * discover the tick frequency of the machine - * if something goes wrong, we return 0, an impossible hertz. - */ -static int -hertz() -{ - struct itimerval tim; - - tim.it_interval.tv_sec = 0; - tim.it_interval.tv_usec = 1; - tim.it_value.tv_sec = 0; - tim.it_value.tv_usec = 0; - setitimer(ITIMER_REAL, &tim, 0); - setitimer(ITIMER_REAL, 0, &tim); - if (tim.it_interval.tv_usec < 2) - return(0); - return (1000000 / tim.it_interval.tv_usec); -} diff --git a/lib/libc/gmon/mcount.c b/lib/libc/gmon/mcount.c deleted file mode 100644 index caf0c14..0000000 --- a/lib/libc/gmon/mcount.c +++ /dev/null @@ -1,325 +0,0 @@ -/*- - * Copyright (c) 1983, 1992, 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. - */ - -#if !defined(lint) && !defined(_KERNEL) && defined(LIBC_SCCS) -#if 0 -static char sccsid[] = "@(#)mcount.c 8.1 (Berkeley) 6/4/93"; -#endif -static const char rcsid[] = - "$FreeBSD$"; -#endif - -#include -#include -#ifdef _KERNEL -#include -#include -#include -#include -void bintr __P((void)); -void btrap __P((void)); -void eintr __P((void)); -void user __P((void)); -#endif - -/* - * mcount is called on entry to each function compiled with the profiling - * switch set. _mcount(), which is declared in a machine-dependent way - * with _MCOUNT_DECL, does the actual work and is either inlined into a - * C routine or called by an assembly stub. In any case, this magic is - * taken care of by the MCOUNT definition in . - * - * _mcount updates data structures that represent traversals of the - * program's call graph edges. frompc and selfpc are the return - * address and function address that represents the given call graph edge. - * - * Note: the original BSD code used the same variable (frompcindex) for - * both frompcindex and frompc. Any reasonable, modern compiler will - * perform this optimization. - */ -_MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */ - register uintfptr_t frompc, selfpc; -{ -#ifdef GUPROF - u_int delta; -#endif - register fptrdiff_t frompci; - register u_short *frompcindex; - register struct tostruct *top, *prevtop; - register struct gmonparam *p; - register long toindex; -#ifdef _KERNEL - MCOUNT_DECL(s) -#endif - - p = &_gmonparam; -#ifndef GUPROF /* XXX */ - /* - * check that we are profiling - * and that we aren't recursively invoked. - */ - if (p->state != GMON_PROF_ON) - return; -#endif -#ifdef _KERNEL - MCOUNT_ENTER(s); -#else - p->state = GMON_PROF_BUSY; -#endif - frompci = frompc - p->lowpc; - -#ifdef _KERNEL - /* - * When we are called from an exception handler, frompci may be - * for a user address. Convert such frompci's to the index of - * user() to merge all user counts. - */ - if (frompci >= p->textsize) { - if (frompci + p->lowpc - >= (uintfptr_t)(VM_MAXUSER_ADDRESS + UPAGES * PAGE_SIZE)) - goto done; - frompci = (uintfptr_t)user - p->lowpc; - if (frompci >= p->textsize) - goto done; - } -#endif - -#ifdef GUPROF - if (p->state != GMON_PROF_HIRES) - goto skip_guprof_stuff; - /* - * Look at the clock and add the count of clock cycles since the - * clock was last looked at to a counter for frompc. This - * solidifies the count for the function containing frompc and - * effectively starts another clock for the current function. - * The count for the new clock will be solidified when another - * function call is made or the function returns. - * - * We use the usual sampling counters since they can be located - * efficiently. 4-byte counters are usually necessary. - * - * There are many complications for subtracting the profiling - * overheads from the counts for normal functions and adding - * them to the counts for mcount(), mexitcount() and cputime(). - * We attempt to handle fractional cycles, but the overheads - * are usually underestimated because they are calibrated for - * a simpler than usual setup. - */ - delta = cputime() - p->mcount_overhead; - p->cputime_overhead_resid += p->cputime_overhead_frac; - p->mcount_overhead_resid += p->mcount_overhead_frac; - if ((int)delta < 0) - *p->mcount_count += delta + p->mcount_overhead - - p->cputime_overhead; - else if (delta != 0) { - if (p->cputime_overhead_resid >= CALIB_SCALE) { - p->cputime_overhead_resid -= CALIB_SCALE; - ++*p->cputime_count; - --delta; - } - if (delta != 0) { - if (p->mcount_overhead_resid >= CALIB_SCALE) { - p->mcount_overhead_resid -= CALIB_SCALE; - ++*p->mcount_count; - --delta; - } - KCOUNT(p, frompci) += delta; - } - *p->mcount_count += p->mcount_overhead_sub; - } - *p->cputime_count += p->cputime_overhead; -skip_guprof_stuff: -#endif /* GUPROF */ - -#ifdef _KERNEL - /* - * When we are called from an exception handler, frompc is faked - * to be for where the exception occurred. We've just solidified - * the count for there. Now convert frompci to the index of btrap() - * for trap handlers and bintr() for interrupt handlers to make - * exceptions appear in the call graph as calls from btrap() and - * bintr() instead of calls from all over. - */ - if ((uintfptr_t)selfpc >= (uintfptr_t)btrap - && (uintfptr_t)selfpc < (uintfptr_t)eintr) { - if ((uintfptr_t)selfpc >= (uintfptr_t)bintr) - frompci = (uintfptr_t)bintr - p->lowpc; - else - frompci = (uintfptr_t)btrap - p->lowpc; - } -#endif - - /* - * check that frompc is a reasonable pc value. - * for example: signal catchers get called from the stack, - * not from text space. too bad. - */ - if (frompci >= p->textsize) - goto done; - - frompcindex = &p->froms[frompci / (p->hashfraction * sizeof(*p->froms))]; - toindex = *frompcindex; - if (toindex == 0) { - /* - * first time traversing this arc - */ - toindex = ++p->tos[0].link; - if (toindex >= p->tolimit) - /* halt further profiling */ - goto overflow; - - *frompcindex = toindex; - top = &p->tos[toindex]; - top->selfpc = selfpc; - top->count = 1; - top->link = 0; - goto done; - } - top = &p->tos[toindex]; - if (top->selfpc == selfpc) { - /* - * arc at front of chain; usual case. - */ - top->count++; - goto done; - } - /* - * have to go looking down chain for it. - * top points to what we are looking at, - * prevtop points to previous top. - * we know it is not at the head of the chain. - */ - for (; /* goto done */; ) { - if (top->link == 0) { - /* - * top is end of the chain and none of the chain - * had top->selfpc == selfpc. - * so we allocate a new tostruct - * and link it to the head of the chain. - */ - toindex = ++p->tos[0].link; - if (toindex >= p->tolimit) - goto overflow; - - top = &p->tos[toindex]; - top->selfpc = selfpc; - top->count = 1; - top->link = *frompcindex; - *frompcindex = toindex; - goto done; - } - /* - * otherwise, check the next arc on the chain. - */ - prevtop = top; - top = &p->tos[top->link]; - if (top->selfpc == selfpc) { - /* - * there it is. - * increment its count - * move it to the head of the chain. - */ - top->count++; - toindex = prevtop->link; - prevtop->link = top->link; - top->link = *frompcindex; - *frompcindex = toindex; - goto done; - } - - } -done: -#ifdef _KERNEL - MCOUNT_EXIT(s); -#else - p->state = GMON_PROF_ON; -#endif - return; -overflow: - p->state = GMON_PROF_ERROR; -#ifdef _KERNEL - MCOUNT_EXIT(s); -#endif - return; -} - -/* - * Actual definition of mcount function. Defined in , - * which is included by . - */ -MCOUNT - -#ifdef GUPROF -void -mexitcount(selfpc) - uintfptr_t selfpc; -{ - struct gmonparam *p; - uintfptr_t selfpcdiff; - - p = &_gmonparam; - selfpcdiff = selfpc - (uintfptr_t)p->lowpc; - if (selfpcdiff < p->textsize) { - u_int delta; - - /* - * Solidify the count for the current function. - */ - delta = cputime() - p->mexitcount_overhead; - p->cputime_overhead_resid += p->cputime_overhead_frac; - p->mexitcount_overhead_resid += p->mexitcount_overhead_frac; - if ((int)delta < 0) - *p->mexitcount_count += delta + p->mexitcount_overhead - - p->cputime_overhead; - else if (delta != 0) { - if (p->cputime_overhead_resid >= CALIB_SCALE) { - p->cputime_overhead_resid -= CALIB_SCALE; - ++*p->cputime_count; - --delta; - } - if (delta != 0) { - if (p->mexitcount_overhead_resid - >= CALIB_SCALE) { - p->mexitcount_overhead_resid - -= CALIB_SCALE; - ++*p->mexitcount_count; - --delta; - } - KCOUNT(p, selfpcdiff) += delta; - } - *p->mexitcount_count += p->mexitcount_overhead_sub; - } - *p->cputime_count += p->cputime_overhead; - } -} -#endif /* GUPROF */ diff --git a/lib/libc/gmon/moncontrol.3 b/lib/libc/gmon/moncontrol.3 deleted file mode 100644 index f608f8f..0000000 --- a/lib/libc/gmon/moncontrol.3 +++ /dev/null @@ -1,106 +0,0 @@ -.\" Copyright (c) 1980, 1991, 1992, 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. -.\" -.\" @(#)moncontrol.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt MONCONTROL 3 -.Os BSD 4 -.Sh NAME -.Nm moncontrol , -.Nm monstartup -.Nd control execution profile -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn moncontrol "int mode" -.Ft int -.Fn monstartup "u_long *lowpc" "u_long *highpc" -.Sh DESCRIPTION -An executable program compiled using the -.Fl pg -option to -.Xr cc 1 -automatically includes calls to collect statistics for the -.Xr gprof 1 -call-graph execution profiler. -In typical operation, profiling begins at program startup -and ends when the program calls exit. -When the program exits, the profiling data are written to the file -.Em progname.gmon , -where progname is the name of the program, then -.Xr gprof 1 -can be used to examine the results. -.Pp -.Fn moncontrol -selectively controls profiling within a program. -When the program starts, profiling begins. -To stop the collection of histogram ticks and call counts use -.Fn moncontrol 0 ; -to resume the collection of histogram ticks and call counts use -.Fn moncontrol 1 . -This feature allows the cost of particular operations to be measured. -Note that an output file will be produced on program exit -regardless of the state of -.Fn moncontrol . -.Pp -Programs that are not loaded with -.Fl pg -may selectively collect profiling statistics by calling -.Fn monstartup -with the range of addresses to be profiled. -.Fa lowpc -and -.Fa highpc -specify the address range that is to be sampled; -the lowest address sampled is that of -.Fa lowpc -and the highest is just below -.Fa highpc . -Only functions in that range that have been compiled with the -.Fl pg -option to -.Xr cc 1 -will appear in the call graph part of the output; -however, all functions in that address range will -have their execution time measured. -Profiling begins on return from -.Fn monstartup . -.Sh FILES -.Bl -tag -width Pa -compact -.It Pa progname.gmon execution data file -.El -.Sh SEE ALSO -.Xr cc 1 , -.Xr gprof 1 , -.Xr profil 2 , -.Xr clocks 7 diff --git a/lib/libc/i386/DEFS.h b/lib/libc/i386/DEFS.h deleted file mode 100644 index edf08ea..0000000 --- a/lib/libc/i386/DEFS.h +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)DEFS.h 5.1 (Berkeley) 4/23/90 - * - * $FreeBSD$ - */ - -#include diff --git a/lib/libc/i386/SYS.h b/lib/libc/i386/SYS.h deleted file mode 100644 index cadbecb..0000000 --- a/lib/libc/i386/SYS.h +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)SYS.h 5.5 (Berkeley) 5/7/91 - * - * $FreeBSD$ - */ - -#include -#include "DEFS.h" - -#define SYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \ - ENTRY(__CONCAT(_,x)); \ - .weak CNAME(x); \ - .set CNAME(x),CNAME(__CONCAT(_,x)); \ - lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b - -#define RSYSCALL(x) SYSCALL(x); ret - -#define PSEUDO(x,y) ENTRY(__CONCAT(_,x)); \ - .weak CNAME(x); \ - .set CNAME(x),CNAME(__CONCAT(_,x)); \ - lea __CONCAT(SYS_,y), %eax; KERNCALL; ret - -/* gas messes up offset -- although we don't currently need it, do for BCS */ -#define LCALL(x,y) .byte 0x9a ; .long y; .word x - -/* - * Design note: - * - * The macros PSYSCALL() and PRSYSCALL() are intended for use where a - * syscall needs to be renamed in the threaded library. When building - * a normal library, they default to the traditional SYSCALL() and - * RSYSCALL(). This avoids the need to #ifdef _THREAD_SAFE everywhere - * that the renamed function needs to be called. - */ -#ifdef _THREAD_SAFE -/* - * For the thread_safe versions, we prepend _thread_sys_ to the function - * name so that the 'C' wrapper can go around the real name. - */ -#define PSYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \ - ENTRY(__CONCAT(_thread_sys_,x)); \ - lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b -#define PRSYSCALL(x) PSYSCALL(x); ret -#define PPSEUDO(x,y) ENTRY(__CONCAT(_thread_sys_,x)); \ - lea __CONCAT(SYS_,y), %eax; KERNCALL; ret -#else -/* - * The non-threaded library defaults to traditional syscalls where - * the function name matches the syscall name. - */ -#define PSYSCALL(x) SYSCALL(x) -#define PRSYSCALL(x) RSYSCALL(x) -#define PPSEUDO(x,y) PSEUDO(x,y) -#endif - -#ifdef __ELF__ -#define KERNCALL int $0x80 /* Faster */ -#else -#define KERNCALL LCALL(7,0) /* The old way */ -#endif diff --git a/lib/libc/i386/gen/Makefile.inc b/lib/libc/i386/gen/Makefile.inc deleted file mode 100644 index f2506fd..0000000 --- a/lib/libc/i386/gen/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 -# $FreeBSD$ - -SRCS+= _setjmp.S alloca.S fabs.S frexp.c infinity.c isinf.c ldexp.c modf.S \ - setjmp.S sigsetjmp.S diff --git a/lib/libc/i386/gen/_setjmp.S b/lib/libc/i386/gen/_setjmp.S deleted file mode 100644 index 9c66308..0000000 --- a/lib/libc/i386/gen/_setjmp.S +++ /dev/null @@ -1,89 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS 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 environment 'a'. - * The previous signal state is NOT restored. - */ - -#include "DEFS.h" - -ENTRY(_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) - fnstcw 24(%eax) - xorl %eax,%eax - ret - -#ifdef _THREAD_SAFE -ENTRY(___longjmp) -#else -ALTENTRY(___longjmp) -ENTRY(_longjmp) -#endif - 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 - fninit - fldcw 24(%edx) - testl %eax,%eax - jnz 1f - incl %eax -1: movl %ecx,0(%esp) - ret diff --git a/lib/libc/i386/gen/alloca.S b/lib/libc/i386/gen/alloca.S deleted file mode 100644 index 4aa0e32..0000000 --- a/lib/libc/i386/gen/alloca.S +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -/* like alloc, but automatic automatic free in return */ - -#include "DEFS.h" - -ENTRY(alloca) - popl %edx /* pop return addr */ - popl %eax /* pop amount to allocate */ - movl %esp,%ecx - addl $3,%eax /* round up to next word */ - andl $0xfffffffc,%eax - subl %eax,%esp - movl %esp,%eax /* base of newly allocated space */ - pushl 8(%ecx) /* copy possible saved registers */ - pushl 4(%ecx) - pushl 0(%ecx) - pushl %eax /* dummy to pop at callsite */ - jmp %edx /* "return" */ diff --git a/lib/libc/i386/gen/fabs.S b/lib/libc/i386/gen/fabs.S deleted file mode 100644 index 578cf7c..0000000 --- a/lib/libc/i386/gen/fabs.S +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -ENTRY(fabs) - fldl 4(%esp) - fabs - ret diff --git a/lib/libc/i386/gen/frexp.c b/lib/libc/i386/gen/frexp.c deleted file mode 100644 index 4834f17..0000000 --- a/lib/libc/i386/gen/frexp.c +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) -static const char rcsid[] = "$FreeBSD$"; -#endif /* LIBC_RCS and not lint */ - -#include -#include - -double -frexp(value, eptr) - double value; - int *eptr; -{ - union { - double v; - struct { - u_int u_mant2 : 32; - u_int u_mant1 : 20; - u_int u_exp : 11; - u_int u_sign : 1; - } s; - } u; - - if (value) { - u.v = value; - *eptr = u.s.u_exp - 1022; - u.s.u_exp = 1022; - return(u.v); - } else { - *eptr = 0; - return((double)0); - } -} diff --git a/lib/libc/i386/gen/infinity.c b/lib/libc/i386/gen/infinity.c deleted file mode 100644 index ac92d46..0000000 --- a/lib/libc/i386/gen/infinity.c +++ /dev/null @@ -1,9 +0,0 @@ -/* - * infinity.c - * $FreeBSD$ - */ - -#include - -/* bytes for +Infinity on a 387 */ -char __infinity[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }; diff --git a/lib/libc/i386/gen/isinf.c b/lib/libc/i386/gen/isinf.c deleted file mode 100644 index b2b63a8..0000000 --- a/lib/libc/i386/gen/isinf.c +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) -static const char rcsid[] = "$FreeBSD$"; -#endif /* LIBC_RCS and not lint */ - -#include - -int -isnan(d) - double d; -{ - register struct IEEEdp { - u_int manl : 32; - u_int manh : 20; - u_int exp : 11; - u_int sign : 1; - } *p = (struct IEEEdp *)&d; - - return(p->exp == 2047 && (p->manh || p->manl)); -} - -int -isinf(d) - double d; -{ - register struct IEEEdp { - u_int manl : 32; - u_int manh : 20; - u_int exp : 11; - u_int sign : 1; - } *p = (struct IEEEdp *)&d; - - return(p->exp == 2047 && !p->manh && !p->manl); -} diff --git a/lib/libc/i386/gen/ldexp.c b/lib/libc/i386/gen/ldexp.c deleted file mode 100644 index e7e58f0..0000000 --- a/lib/libc/i386/gen/ldexp.c +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Sean Eric Fagan. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) -static const char rcsid[] = "$FreeBSD$"; -#endif /* LIBC_RCS and not lint */ - -/* - * ldexp(value, exp): return value * (2 ** exp). - * - * Written by Sean Eric Fagan (sef@kithrup.COM) - * Sun Mar 11 20:27:09 PST 1990 - */ - -/* - * We do the conversion in C to let gcc optimize it away, if possible. - * The "fxch ; fstp" stuff is because value is still on the stack - * (stupid 8087!). - */ -double -ldexp (double value, int exp) -{ - double temp, texp, temp2; - texp = exp; -#ifdef __GNUC__ -#if __GNUC__ >= 2 - asm ("fscale " - : "=u" (temp2), "=t" (temp) - : "0" (texp), "1" (value)); -#else - asm ("fscale ; fxch %%st(1) ; fstp%L1 %1 " - : "=f" (temp), "=0" (temp2) - : "0" (texp), "f" (value)); -#endif -#else -error unknown asm -#endif - return (temp); -} diff --git a/lib/libc/i386/gen/modf.S b/lib/libc/i386/gen/modf.S deleted file mode 100644 index 751ec1c..0000000 --- a/lib/libc/i386/gen/modf.S +++ /dev/null @@ -1,79 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Sean Eric Fagan. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -/* - * modf(value, iptr): return fractional part of value, and stores the - * integral part into iptr (a pointer to double). - * - * Written by Sean Eric Fagan (sef@kithrup.COM) - * Sun Mar 11 20:27:30 PST 1990 - */ - -/* With CHOP mode on, frndint behaves as TRUNC does. Useful. */ - -#include "DEFS.h" - -ENTRY(modf) - pushl %ebp - movl %esp,%ebp - subl $16,%esp - fnstcw -12(%ebp) - movw -12(%ebp),%dx - orw $3072,%dx - movw %dx,-16(%ebp) - fldcw -16(%ebp) - fldl 8(%ebp) - frndint - fstpl -8(%ebp) - fldcw -12(%ebp) - movl 16(%ebp),%eax - movl -8(%ebp),%edx - movl -4(%ebp),%ecx - movl %edx,(%eax) - movl %ecx,4(%eax) - fldl 8(%ebp) - fsubl -8(%ebp) - jmp L1 -L1: - leave - ret diff --git a/lib/libc/i386/gen/setjmp.S b/lib/libc/i386/gen/setjmp.S deleted file mode 100644 index 39e9c21..0000000 --- a/lib/libc/i386/gen/setjmp.S +++ /dev/null @@ -1,116 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS 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 environment 'a'. - * The previous signal state is restored. - */ - -#include "DEFS.h" -#include "SYS.h" - -ENTRY(setjmp) - movl 4(%esp),%ecx - PIC_PROLOGUE - leal 28(%ecx), %eax - pushl %eax /* (sigset_t*)oset */ - pushl $0 /* (sigset_t*)set */ - pushl $1 /* SIG_BLOCK */ -#ifdef _THREAD_SAFE - call PIC_PLT(CNAME(_thread_sys_sigprocmask)) -#else - call PIC_PLT(CNAME(sigprocmask)) -#endif - addl $12,%esp - PIC_EPILOGUE - movl 4(%esp),%ecx - movl 0(%esp),%edx - movl %edx, 0(%ecx) - movl %ebx, 4(%ecx) - movl %esp, 8(%ecx) - movl %ebp,12(%ecx) - movl %esi,16(%ecx) - movl %edi,20(%ecx) - fnstcw 24(%ecx) - xorl %eax,%eax - ret - -#ifdef _THREAD_SAFE -ENTRY(__longjmp) -#else -ALTENTRY(__longjmp) -ENTRY(longjmp) -#endif - movl 4(%esp),%edx - PIC_PROLOGUE - pushl $0 /* (sigset_t*)oset */ - leal 28(%edx), %eax - pushl %eax /* (sigset_t*)set */ - pushl $3 /* SIG_SETMASK */ -#ifdef _THREAD_SAFE - call PIC_PLT(CNAME(_thread_sys_sigprocmask)) -#else - call PIC_PLT(CNAME(sigprocmask)) -#endif - addl $12,%esp - PIC_EPILOGUE - 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 - fninit - fldcw 24(%edx) - testl %eax,%eax - jnz 1f - incl %eax -1: movl %ecx,0(%esp) - ret diff --git a/lib/libc/i386/gen/sigsetjmp.S b/lib/libc/i386/gen/sigsetjmp.S deleted file mode 100644 index 13c0dc7..0000000 --- a/lib/libc/i386/gen/sigsetjmp.S +++ /dev/null @@ -1,127 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" -#include "SYS.h" - -/*- - * TODO: - * Rename sigsetjmp to __sigsetjmp and siglongjmp to __siglongjmp, - * remove the other *jmp functions and define everything in terms - * of the renamed functions. This requires compiler support for - * the renamed functions (introduced in gcc-2.5.3; previous versions - * only supported *jmp with 0 or 1 leading underscores). - * - * Use sigprocmask() instead of sigblock() and sigsetmask(), and - * check for and handle errors. - * - * Restore _all_ the registers and the signal mask atomically. Can - * use sigreturn() if sigreturn() works. - */ - -ENTRY(sigsetjmp) - movl 8(%esp),%eax - movl 4(%esp),%ecx - movl %eax,44(%ecx) - testl %eax,%eax - jz 2f - PIC_PROLOGUE - leal 28(%ecx), %eax - pushl %eax /* (sigset_t*)oset */ - pushl $0 /* (sigset_t*)set */ - pushl $1 /* SIG_BLOCK */ -#ifdef _THREAD_SAFE - call PIC_PLT(CNAME(_thread_sys_sigprocmask)) -#else - call PIC_PLT(CNAME(sigprocmask)) -#endif - addl $12,%esp - PIC_EPILOGUE - movl 4(%esp),%ecx -2: movl 0(%esp),%edx - movl %edx, 0(%ecx) - movl %ebx, 4(%ecx) - movl %esp, 8(%ecx) - movl %ebp,12(%ecx) - movl %esi,16(%ecx) - movl %edi,20(%ecx) - fnstcw 24(%ecx) - xorl %eax,%eax - ret - -#ifdef _THREAD_SAFE -ENTRY(__siglongjmp) -#else -ALTENTRY(__siglongjmp) -ENTRY(siglongjmp) -#endif - movl 4(%esp),%edx - cmpl $0,44(%edx) - jz 2f - PIC_PROLOGUE - pushl $0 /* (sigset_t*)oset */ - leal 28(%edx), %eax - pushl %eax /* (sigset_t*)set */ - pushl $3 /* SIG_SETMASK */ -#ifdef _THREAD_SAFE - call PIC_PLT(CNAME(_thread_sys_sigprocmask)) -#else - call PIC_PLT(CNAME(sigprocmask)) -#endif - addl $12,%esp - PIC_EPILOGUE - movl 4(%esp),%edx -2: 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 - fninit - fldcw 24(%edx) - testl %eax,%eax - jnz 1f - incl %eax -1: movl %ecx,0(%esp) - ret diff --git a/lib/libc/i386/net/Makefile.inc b/lib/libc/i386/net/Makefile.inc deleted file mode 100644 index 96e559b..0000000 --- a/lib/libc/i386/net/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 -# $FreeBSD$ - -SRCS+= htonl.S htons.S ntohl.S ntohs.S diff --git a/lib/libc/i386/net/htonl.S b/lib/libc/i386/net/htonl.S deleted file mode 100644 index 48f1ca8..0000000 --- a/lib/libc/i386/net/htonl.S +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -/* netorder = htonl(hostorder) */ - -#include "DEFS.h" - -ENTRY(htonl) - movl 4(%esp),%eax - xchgb %al,%ah - roll $16,%eax - xchgb %al,%ah - ret diff --git a/lib/libc/i386/net/htons.S b/lib/libc/i386/net/htons.S deleted file mode 100644 index 68f2b5a..0000000 --- a/lib/libc/i386/net/htons.S +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -/* netorder = htons(hostorder) */ - -#include "DEFS.h" - -ENTRY(htons) - movzwl 4(%esp),%eax - xchgb %al,%ah - ret diff --git a/lib/libc/i386/net/ntohl.S b/lib/libc/i386/net/ntohl.S deleted file mode 100644 index 7be9dee..0000000 --- a/lib/libc/i386/net/ntohl.S +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -/* hostorder = ntohl(netorder) */ - -#include "DEFS.h" - -ENTRY(ntohl) - movl 4(%esp),%eax - xchgb %al,%ah - roll $16,%eax - xchgb %al,%ah - ret diff --git a/lib/libc/i386/net/ntohs.S b/lib/libc/i386/net/ntohs.S deleted file mode 100644 index 0f1d228..0000000 --- a/lib/libc/i386/net/ntohs.S +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -/* hostorder = ntohs(netorder) */ - -#include "DEFS.h" - -ENTRY(ntohs) - movzwl 4(%esp),%eax - xchgb %al,%ah - ret diff --git a/lib/libc/i386/stdlib/Makefile.inc b/lib/libc/i386/stdlib/Makefile.inc deleted file mode 100644 index 0a6a6a8..0000000 --- a/lib/libc/i386/stdlib/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 -# $FreeBSD$ - -MDSRCS+=abs.S div.S labs.S ldiv.S diff --git a/lib/libc/i386/stdlib/abs.S b/lib/libc/i386/stdlib/abs.S deleted file mode 100644 index e4812d8..0000000 --- a/lib/libc/i386/stdlib/abs.S +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -ENTRY(abs) - movl 4(%esp),%eax - testl %eax,%eax - jns 1f - negl %eax -1: ret diff --git a/lib/libc/i386/stdlib/div.S b/lib/libc/i386/stdlib/div.S deleted file mode 100644 index a9ff515..0000000 --- a/lib/libc/i386/stdlib/div.S +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -ENTRY(div) - movl 4(%esp),%eax - movl 8(%esp),%ecx - cdq - idiv %ecx - movl %eax,4(%esp) - movl %edx,8(%esp) - ret diff --git a/lib/libc/i386/stdlib/labs.S b/lib/libc/i386/stdlib/labs.S deleted file mode 100644 index 6fa8149..0000000 --- a/lib/libc/i386/stdlib/labs.S +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -ENTRY(labs) - movl 4(%esp),%eax - testl %eax,%eax - jns 1f - negl %eax -1: ret diff --git a/lib/libc/i386/stdlib/ldiv.S b/lib/libc/i386/stdlib/ldiv.S deleted file mode 100644 index c9546c3..0000000 --- a/lib/libc/i386/stdlib/ldiv.S +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -ENTRY(ldiv) - movl 4(%esp),%eax - movl 8(%esp),%ecx - cdq - idiv %ecx - movl %eax,4(%esp) - movl %edx,8(%esp) - ret diff --git a/lib/libc/i386/string/Makefile.inc b/lib/libc/i386/string/Makefile.inc deleted file mode 100644 index 1b2de19..0000000 --- a/lib/libc/i386/string/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 -# $FreeBSD$ - -MDSRCS+=bcmp.S bcopy.S bzero.S ffs.S index.S memchr.S memcmp.S memcpy.S \ - memmove.S memset.S rindex.S strcat.S strchr.S strcmp.S strcpy.S \ - strlen.S strncmp.S strrchr.S swab.S diff --git a/lib/libc/i386/string/bcmp.S b/lib/libc/i386/string/bcmp.S deleted file mode 100644 index 3c0bd02..0000000 --- a/lib/libc/i386/string/bcmp.S +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * bcmp (void *b1, void *b2, size_t len) - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(bcmp) - pushl %edi - pushl %esi - movl 12(%esp),%edi - movl 16(%esp),%esi - xorl %eax,%eax /* clear return value */ - cld /* set compare direction forward */ - - movl 20(%esp),%ecx /* compare by words */ - shrl $2,%ecx - repe - cmpsl - jne L1 - - movl 20(%esp),%ecx /* compare remainder by bytes */ - andl $3,%ecx - repe - cmpsb - je L2 - -L1: incl %eax -L2: popl %esi - popl %edi - ret diff --git a/lib/libc/i386/string/bcopy.S b/lib/libc/i386/string/bcopy.S deleted file mode 100644 index d2a571e..0000000 --- a/lib/libc/i386/string/bcopy.S +++ /dev/null @@ -1,103 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from locore.s. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 - - RCSID("$NetBSD: bcopy.S,v 1.6 1996/11/12 00:50:06 jtc Exp $") - - /* - * (ov)bcopy (src,dst,cnt) - * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800 - */ - -#ifdef MEMCOPY -ENTRY(memcpy) -#else -#ifdef MEMMOVE -ENTRY(memmove) -#else -ENTRY(bcopy) -#endif -#endif - pushl %esi - pushl %edi -#if defined(MEMCOPY) || defined(MEMMOVE) - movl 12(%esp),%edi - movl 16(%esp),%esi -#else - movl 12(%esp),%esi - movl 16(%esp),%edi -#endif - movl 20(%esp),%ecx - movl %edi,%eax - subl %esi,%eax - cmpl %ecx,%eax /* overlapping? */ - jb 1f - cld /* nope, copy forwards. */ - shrl $2,%ecx /* copy by words */ - rep - movsl - movl 20(%esp),%ecx - andl $3,%ecx /* any bytes left? */ - rep - movsb -#if defined(MEMCOPY) || defined(MEMMOVE) - movl 12(%esp),%eax -#endif - popl %edi - popl %esi - ret -1: - addl %ecx,%edi /* copy backwards. */ - addl %ecx,%esi - std - andl $3,%ecx /* any fractional bytes? */ - decl %edi - decl %esi - rep - movsb - movl 20(%esp),%ecx /* copy remainder by words */ - shrl $2,%ecx - subl $3,%esi - subl $3,%edi - rep - movsl -#if defined(MEMCOPY) || defined(MEMMOVE) - movl 12(%esp),%eax -#endif - popl %edi - popl %esi - cld - ret diff --git a/lib/libc/i386/string/bzero.S b/lib/libc/i386/string/bzero.S deleted file mode 100644 index 7f95f71..0000000 --- a/lib/libc/i386/string/bzero.S +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * bzero (void *b, size_t len) - * write len zero bytes to the string b. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(bzero) - pushl %edi - pushl %ebx - movl 12(%esp),%edi - movl 16(%esp),%ecx - - cld /* set fill direction forward */ - xorl %eax,%eax /* set fill data to 0 */ - - /* - * if the string is too short, it's really not worth the overhead - * of aligning to word boundries, etc. So we jump to a plain - * unaligned set. - */ - cmpl $0x0f,%ecx - jle L1 - - movl %edi,%edx /* compute misalignment */ - negl %edx - andl $3,%edx - movl %ecx,%ebx - subl %edx,%ebx - - movl %edx,%ecx /* zero until word aligned */ - rep - stosb - - movl %ebx,%ecx /* zero by words */ - shrl $2,%ecx - rep - stosl - - movl %ebx,%ecx - andl $3,%ecx /* zero remainder by bytes */ -L1: rep - stosb - - popl %ebx - popl %edi - ret diff --git a/lib/libc/i386/string/ffs.S b/lib/libc/i386/string/ffs.S deleted file mode 100644 index ae4be79..0000000 --- a/lib/libc/i386/string/ffs.S +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * ffs(value) - * finds the first bit set in value and returns the index of - * that bit. Bits are numbered starting from 1, starting at the - * rightmost bit. A return value of 0 means that the argument - * was zero. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(ffs) - bsfl 4(%esp),%eax - jz L1 /* ZF is set if all bits are 0 */ - incl %eax /* bits numbered from 1, not 0 */ - ret - - .align 2 -L1: xorl %eax,%eax /* clear result */ - ret diff --git a/lib/libc/i386/string/index.S b/lib/libc/i386/string/index.S deleted file mode 100644 index d63a646..0000000 --- a/lib/libc/i386/string/index.S +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * index(s, c) - * return a pointer to the first occurance of the character c in - * string s, or NULL if c does not occur in the string. - * - * %edx - pointer iterating through string - * %eax - pointer to first occurance of 'c' - * %cl - character we're comparing against - * %bl - character at %edx - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(index) - pushl %ebx - movl 8(%esp),%eax - movb 12(%esp),%cl - .align 2,0x90 -L1: - movb (%eax),%bl - cmpb %bl,%cl /* found char??? */ - je L2 - incl %eax - testb %bl,%bl /* null terminator??? */ - jne L1 - xorl %eax,%eax -L2: - popl %ebx - ret diff --git a/lib/libc/i386/string/memchr.S b/lib/libc/i386/string/memchr.S deleted file mode 100644 index 9604f59..0000000 --- a/lib/libc/i386/string/memchr.S +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * memchr (b, c, len) - * locates the first occurance of c in string b. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(memchr) - pushl %edi - movl 8(%esp),%edi /* string address */ - movl 12(%esp),%eax /* set character to search for */ - movl 16(%esp),%ecx /* set length of search */ - testl %esp,%esp /* clear Z flag, for len == 0 */ - cld /* set search forward */ - repne /* search! */ - scasb - jnz L1 /* scan failed, return null */ - leal -1(%edi),%eax /* adjust result of scan */ - popl %edi - ret - .align 2,0x90 -L1: xorl %eax,%eax - popl %edi - ret diff --git a/lib/libc/i386/string/memcmp.S b/lib/libc/i386/string/memcmp.S deleted file mode 100644 index e4fd4a7..0000000 --- a/lib/libc/i386/string/memcmp.S +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * memcmp (void *b1, void *b2, size_t len) - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(memcmp) - pushl %edi - pushl %esi - movl 12(%esp),%edi - movl 16(%esp),%esi - cld /* set compare direction forward */ - - movl 20(%esp),%ecx /* compare by words */ - shrl $2,%ecx - repe - cmpsl - jne L5 /* do we match so far? */ - - movl 20(%esp),%ecx /* compare remainder by bytes */ - andl $3,%ecx - repe - cmpsb - jne L6 /* do we match? */ - - xorl %eax,%eax /* we match, return zero */ - popl %esi - popl %edi - ret - -L5: movl $4,%ecx /* We know that one of the next */ - subl %ecx,%edi /* four pairs of bytes do not */ - subl %ecx,%esi /* match. */ - repe - cmpsb -L6: movzbl -1(%edi),%eax /* Perform unsigned comparison */ - movzbl -1(%esi),%edx - subl %edx,%eax - popl %esi - popl %edi - ret diff --git a/lib/libc/i386/string/memcpy.S b/lib/libc/i386/string/memcpy.S deleted file mode 100644 index 1617c71..0000000 --- a/lib/libc/i386/string/memcpy.S +++ /dev/null @@ -1,2 +0,0 @@ -#define MEMCOPY -#include "bcopy.S" diff --git a/lib/libc/i386/string/memmove.S b/lib/libc/i386/string/memmove.S deleted file mode 100644 index f5a94ed..0000000 --- a/lib/libc/i386/string/memmove.S +++ /dev/null @@ -1,2 +0,0 @@ -#define MEMMOVE -#include "bcopy.S" diff --git a/lib/libc/i386/string/memset.S b/lib/libc/i386/string/memset.S deleted file mode 100644 index bb9e268..0000000 --- a/lib/libc/i386/string/memset.S +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * memset(void *b, int c, size_t len) - * write len bytes of value c (converted to an unsigned char) to - * the string b. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(memset) - pushl %edi - pushl %ebx - movl 12(%esp),%edi - movzbl 16(%esp),%eax /* unsigned char, zero extend */ - movl 20(%esp),%ecx - pushl %edi /* push address of buffer */ - - cld /* set fill direction forward */ - - /* - * if the string is too short, it's really not worth the overhead - * of aligning to word boundries, etc. So we jump to a plain - * unaligned set. - */ - cmpl $0x0f,%ecx - jle L1 - - movb %al,%ah /* copy char to all bytes in word */ - movl %eax,%edx - sall $16,%eax - orl %edx,%eax - - movl %edi,%edx /* compute misalignment */ - negl %edx - andl $3,%edx - movl %ecx,%ebx - subl %edx,%ebx - - movl %edx,%ecx /* set until word aligned */ - rep - stosb - - movl %ebx,%ecx - shrl $2,%ecx /* set by words */ - rep - stosl - - movl %ebx,%ecx /* set remainder by bytes */ - andl $3,%ecx -L1: rep - stosb - - popl %eax /* pop address of buffer */ - popl %ebx - popl %edi - ret diff --git a/lib/libc/i386/string/rindex.S b/lib/libc/i386/string/rindex.S deleted file mode 100644 index dd15865..0000000 --- a/lib/libc/i386/string/rindex.S +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * rindex(s, c) - * return a pointer to the last occurance of the character c in - * string s, or NULL if c does not occur in the string. - * - * %edx - pointer iterating through string - * %eax - pointer to last occurance of 'c' - * %cl - character we're comparing against - * %bl - character at %edx - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(rindex) - pushl %ebx - movl 8(%esp),%edx - movb 12(%esp),%cl - xorl %eax,%eax /* init pointer to null */ - .align 2,0x90 -L1: - movb (%edx),%bl - cmpb %bl,%cl - jne L2 - movl %edx,%eax -L2: - incl %edx - testb %bl,%bl /* null terminator??? */ - jne L1 - popl %ebx - ret diff --git a/lib/libc/i386/string/strcat.S b/lib/libc/i386/string/strcat.S deleted file mode 100644 index ceda010..0000000 --- a/lib/libc/i386/string/strcat.S +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * strcat(s, append) - * append a copy of the null-terminated string "append" to the end - * of the null-terminated string s, then add a terminating `\0'. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -/* - * I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cashe. - */ - -ENTRY(strcat) - pushl %edi /* save edi */ - movl 8(%esp),%edi /* dst address */ - movl 12(%esp),%edx /* src address */ - pushl %edi /* push destination address */ - - cld /* set search forward */ - xorl %eax,%eax /* set search for null terminator */ - movl $-1,%ecx /* set search for lots of characters */ - repne /* search! */ - scasb - - leal -1(%edi),%ecx /* correct dst address */ - - .align 2,0x90 -L1: movb (%edx),%al /* unroll loop, but not too much */ - movb %al,(%ecx) - testb %al,%al - je L2 - movb 1(%edx),%al - movb %al,1(%ecx) - testb %al,%al - je L2 - movb 2(%edx),%al - movb %al,2(%ecx) - testb %al,%al - je L2 - movb 3(%edx),%al - movb %al,3(%ecx) - testb %al,%al - je L2 - movb 4(%edx),%al - movb %al,4(%ecx) - testb %al,%al - je L2 - movb 5(%edx),%al - movb %al,5(%ecx) - testb %al,%al - je L2 - movb 6(%edx),%al - movb %al,6(%ecx) - testb %al,%al - je L2 - movb 7(%edx),%al - movb %al,7(%ecx) - addl $8,%edx - addl $8,%ecx - testb %al,%al - jne L1 -L2: popl %eax /* pop destination address */ - popl %edi /* restore edi */ - ret diff --git a/lib/libc/i386/string/strchr.S b/lib/libc/i386/string/strchr.S deleted file mode 100644 index 16fa724..0000000 --- a/lib/libc/i386/string/strchr.S +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * strchr(s, c) - * return a pointer to the first occurance of the character c in - * string s, or NULL if c does not occur in the string. - * - * %edx - pointer iterating through string - * %eax - pointer to first occurance of 'c' - * %cl - character we're comparing against - * %bl - character at %edx - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(strchr) - pushl %ebx - movl 8(%esp),%eax - movb 12(%esp),%cl - .align 2,0x90 -L1: - movb (%eax),%bl - cmpb %bl,%cl /* found char??? */ - je L2 - incl %eax - testb %bl,%bl /* null terminator??? */ - jne L1 - xorl %eax,%eax -L2: - popl %ebx - ret diff --git a/lib/libc/i386/string/strcmp.S b/lib/libc/i386/string/strcmp.S deleted file mode 100644 index 28a3f2f..0000000 --- a/lib/libc/i386/string/strcmp.S +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * strcmp(s1, s2) - * return an integer greater than, equal to, or less than 0, - * according as string s1 is greater than, equal to, or less - * than the string s2. - * - * %eax - pointer to s1 - * %edx - pointer to s2 - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -/* - * I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cashe. - */ - -ENTRY(strcmp) - movl 0x04(%esp),%eax - movl 0x08(%esp),%edx - jmp L2 /* Jump into the loop! */ - - .align 2,0x90 -L1: incl %eax - incl %edx -L2: movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - je L1 - .align 2, 0x90 -L3: movzbl (%eax),%eax /* unsigned comparison */ - movzbl (%edx),%edx - subl %edx,%eax - ret diff --git a/lib/libc/i386/string/strcpy.S b/lib/libc/i386/string/strcpy.S deleted file mode 100644 index 5a30414..0000000 --- a/lib/libc/i386/string/strcpy.S +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * strcpy (dst, src) - * copy the string src to dst. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -/* - * I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cashe. - */ - -ENTRY(strcpy) - movl 4(%esp),%ecx /* dst address */ - movl 8(%esp),%edx /* src address */ - pushl %ecx /* push dst address */ - - .align 2,0x90 -L1: movb (%edx),%al /* unroll loop, but not too much */ - movb %al,(%ecx) - testb %al,%al - je L2 - movb 1(%edx),%al - movb %al,1(%ecx) - testb %al,%al - je L2 - movb 2(%edx),%al - movb %al,2(%ecx) - testb %al,%al - je L2 - movb 3(%edx),%al - movb %al,3(%ecx) - testb %al,%al - je L2 - movb 4(%edx),%al - movb %al,4(%ecx) - testb %al,%al - je L2 - movb 5(%edx),%al - movb %al,5(%ecx) - testb %al,%al - je L2 - movb 6(%edx),%al - movb %al,6(%ecx) - testb %al,%al - je L2 - movb 7(%edx),%al - movb %al,7(%ecx) - addl $8,%edx - addl $8,%ecx - testb %al,%al - jne L1 -L2: popl %eax /* pop dst address */ - ret diff --git a/lib/libc/i386/string/strlen.S b/lib/libc/i386/string/strlen.S deleted file mode 100644 index eedc969..0000000 --- a/lib/libc/i386/string/strlen.S +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * strlen (s) - * compute the length of the string s. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(strlen) - pushl %edi - movl 8(%esp),%edi /* string address */ - cld /* set search forward */ - xorl %eax,%eax /* set search for null terminator */ - movl $-1,%ecx /* set search for lots of characters */ - repne /* search! */ - scasb - notl %ecx /* get length by taking complement */ - leal -1(%ecx),%eax /* and subtracting one */ - popl %edi - ret diff --git a/lib/libc/i386/string/strncmp.S b/lib/libc/i386/string/strncmp.S deleted file mode 100644 index 0efc6ac..0000000 --- a/lib/libc/i386/string/strncmp.S +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 1993,94 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * strncmp(s1, s2, n) - * return an integer greater than, equal to, or less than 0, - * according as the first n characters of string s1 is greater - * than, equal to, or less than the string s2. - * - * %eax - pointer to s1 - * %ecx - pointer to s2 - * %edx - length - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -/* - * I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cache. - * - * TODO: change all the jz's back to je for consistency. - */ - -ENTRY(strncmp) - pushl %ebx - movl 8(%esp),%eax - movl 12(%esp),%ecx - movl 16(%esp),%edx - testl %edx,%edx - jmp L2 /* Jump into the loop! */ - - .align 2,0x90 -L1: incl %eax - incl %ecx - decl %edx -L2: jz L4 /* strings are equal */ - movb (%eax),%bl - testb %bl,%bl - jz L3 - cmpb %bl,(%ecx) - jne L3 - -/* - * XXX it might be best to move the next 4 instructions to the end of the - * unrolled part of the loop. The unrolled part would then be - * movb n(%eax),%bl; testb %bl, %bl; je L3; cmpb n(%ecx); jne L3 - * or maybe better - * movb n(%eax),%bl; cmpb n(%ecx); jne L3; testb %bl,%bl; je return_0 - * for n = 0, 1, ..., 8. The end of the loop would be - * L1: addl $8,%eax; addl $8,%ecx; subl $8,%edx; cmpl $8,%edx; jae Lx - * where residual counts of 0 to 7 are handled at Lx. However, this would - * be slower for short strings. Cache effects are probably not so - * important because we are only handling a byte at a time. - */ - incl %eax - incl %ecx - decl %edx - jz L4 - movb (%eax),%bl - testb %bl,%bl - jz L3 - cmpb %bl,(%ecx) - jne L3 - - incl %eax - incl %ecx - decl %edx - jz L4 - movb (%eax),%bl - testb %bl,%bl - jz L3 - cmpb %bl,(%ecx) - jne L3 - - incl %eax - incl %ecx - decl %edx - jz L4 - movb (%eax),%bl - testb %bl,%bl - jz L3 - cmpb %bl,(%ecx) - jne L3 - - incl %eax - incl %ecx - decl %edx - jz L4 - movb (%eax),%bl - testb %bl,%bl - jz L3 - cmpb %bl,(%ecx) - jne L3 - - incl %eax - incl %ecx - decl %edx - jz L4 - movb (%eax),%bl - testb %bl,%bl - jz L3 - cmpb %bl,(%ecx) - jne L3 - - incl %eax - incl %ecx - decl %edx - jz L4 - movb (%eax),%bl - testb %bl,%bl - jz L3 - cmpb %bl,(%ecx) - jne L3 - - incl %eax - incl %ecx - decl %edx - jz L4 - movb (%eax),%bl - testb %bl,%bl - jz L3 - cmpb %bl,(%ecx) - je L1 - - .align 2,0x90 -L3: movzbl (%eax),%eax /* unsigned comparison */ - movzbl (%ecx),%ecx - subl %ecx,%eax - popl %ebx - ret - .align 2,0x90 -L4: xorl %eax,%eax - popl %ebx - ret diff --git a/lib/libc/i386/string/strrchr.S b/lib/libc/i386/string/strrchr.S deleted file mode 100644 index d62039f..0000000 --- a/lib/libc/i386/string/strrchr.S +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * strrchr(s, c) - * return a pointer to the last occurance of the character c in - * string s, or NULL if c does not occur in the string. - * - * %edx - pointer iterating through string - * %eax - pointer to last occurance of 'c' - * %cl - character we're comparing against - * %bl - character at %edx - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(strrchr) - pushl %ebx - movl 8(%esp),%edx - movb 12(%esp),%cl - xorl %eax,%eax /* init pointer to null */ - .align 2,0x90 -L1: - movb (%edx),%bl - cmpb %bl,%cl - jne L2 - movl %edx,%eax -L2: - incl %edx - testb %bl,%bl /* null terminator??? */ - jne L1 - popl %ebx - ret diff --git a/lib/libc/i386/string/swab.S b/lib/libc/i386/string/swab.S deleted file mode 100644 index 80578af..0000000 --- a/lib/libc/i386/string/swab.S +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 1993,94 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif - -#include "DEFS.h" - -/* - * void - * swab (const void *src, void *dst, size_t len) - * copy len bytes from src to dst, swapping adjacent bytes - * - * On the i486, this code is negligibly faster than the code generated - * by gcc at about half the size. If my i386 databook is correct, it - * should be considerably faster than the gcc code on a i386. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(swab) - pushl %esi - pushl %edi - movl 12(%esp),%esi - movl 16(%esp),%edi - movl 20(%esp),%ecx - - cld # set direction forward - - shrl $1,%ecx - testl $7,%ecx # copy first group of 1 to 7 words - jz L2 # while swaping alternate bytes. - .align 2,0x90 -L1: lodsw - rorw $8,%ax - stosw - decl %ecx - testl $7,%ecx - jnz L1 - -L2: shrl $3,%ecx # copy remainder 8 words at a time - jz L4 # while swapping alternate bytes. - .align 2,0x90 -L3: lodsw - rorw $8,%ax - stosw - lodsw - rorw $8,%ax - stosw - lodsw - rorw $8,%ax - stosw - lodsw - rorw $8,%ax - stosw - lodsw - rorw $8,%ax - stosw - lodsw - rorw $8,%ax - stosw - lodsw - rorw $8,%ax - stosw - lodsw - rorw $8,%ax - stosw - decl %ecx - jnz L3 - -L4: popl %edi - popl %esi - ret diff --git a/lib/libc/i386/sys/Makefile.inc b/lib/libc/i386/sys/Makefile.inc deleted file mode 100644 index c1c3d2d..0000000 --- a/lib/libc/i386/sys/Makefile.inc +++ /dev/null @@ -1,28 +0,0 @@ -# from: Makefile.inc,v 1.1 1993/09/03 19:04:23 jtc Exp -# $FreeBSD$ - -SRCS+= i386_get_ioperm.c i386_get_ldt.c i386_set_ioperm.c i386_set_ldt.c \ - i386_vm86.c - -MDASM= Ovfork.S brk.S cerror.S exect.S fork.S pipe.S ptrace.S reboot.S \ - rfork.S sbrk.S setlogin.S sigreturn.S syscall.S - -# Don't generate default code for these syscalls: -NOASM= __semctl.o break.o exit.o ftruncate.o getdomainname.o getlogin.o \ - lseek.o mlockall.o mmap.o msgctl.o msgget.o msgrcv.o msgsnd.o \ - munlockall.o openbsd_poll.o pread.o pwrite.o semconfig.o semget.o \ - semop.o setdomainname.o shmat.o shmctl.o shmdt.o shmget.o sstk.o \ - thr_sleep.o thr_wakeup.o truncate.o uname.o vfork.o yield.o - -PSEUDO= _getlogin.o - -# Pseudo syscalls that are renamed as _thread_sys_{pseudo} when -# building libc_r. -PSEUDOR= _exit.o - -.if ${LIB} == "c" -MAN2+= i386_get_ioperm.2 i386_get_ldt.2 i386_vm86.2 - -MLINKS+=i386_get_ioperm.2 i386_set_ioperm.2 -MLINKS+=i386_get_ldt.2 i386_set_ldt.2 -.endif diff --git a/lib/libc/i386/sys/Ovfork.S b/lib/libc/i386/sys/Ovfork.S deleted file mode 100644 index 30d7fd1..0000000 --- a/lib/libc/i386/sys/Ovfork.S +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "DEFS.h" -#include "SYS.h" - -/* - * pid = vfork(); - * - * %edx == 0 in parent process, %edx == 1 in child process. - * %eax == pid of child in parent, %eax == pid of parent in child. - * - */ - -#ifdef _THREAD_SAFE -ENTRY(_thread_sys_vfork) -#else -ENTRY(vfork) -#endif - popl %ecx /* my rta into ecx */ - lea SYS_vfork,%eax - KERNCALL - jb 2f - cmpl $0,%edx /* parent process? */ - je 1f /* yes */ - movl $0,%eax -1: - jmp %ecx -2: - pushl %ecx - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) diff --git a/lib/libc/i386/sys/brk.S b/lib/libc/i386/sys/brk.S deleted file mode 100644 index 5726675..0000000 --- a/lib/libc/i386/sys/brk.S +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - - .globl HIDENAME(curbrk) - .globl HIDENAME(minbrk) -ENTRY(_brk) - jmp ok - -ENTRY(brk) -#ifdef PIC - movl 4(%esp),%eax - PIC_PROLOGUE - movl PIC_GOT(HIDENAME(curbrk)),%edx # set up GOT addressing - movl PIC_GOT(HIDENAME(minbrk)),%ecx # - PIC_EPILOGUE - cmpl %eax,(%ecx) - jbe ok - movl (%ecx),%eax - movl %eax,4(%esp) -ok: - lea SYS_break,%eax - KERNCALL - jb err - movl 4(%esp),%eax - movl %eax,(%edx) - movl $0,%eax - ret -err: - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) - -#else - - movl 4(%esp),%eax - cmpl %eax,HIDENAME(minbrk) - jbe ok - movl HIDENAME(minbrk),%eax - movl %eax,4(%esp) -ok: - lea SYS_break,%eax - KERNCALL - jb err - movl 4(%esp),%eax - movl %eax,HIDENAME(curbrk) - movl $0,%eax - ret -err: - jmp HIDENAME(cerror) -#endif diff --git a/lib/libc/i386/sys/cerror.S b/lib/libc/i386/sys/cerror.S deleted file mode 100644 index 31c3622..0000000 --- a/lib/libc/i386/sys/cerror.S +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - - .globl HIDENAME(cerror) - - /* - * The __error() function is thread aware. For non-threaded - * programs and the initial threaded in threaded programs, - * it returns a pointer to the global errno variable. - */ - .globl CNAME(__error) - .type CNAME(__error),@function -HIDENAME(cerror): - pushl %eax -#ifdef PIC - /* The caller must execute the PIC prologue before jumping to cerror. */ - call PIC_PLT(CNAME(__error)) - popl %ecx - PIC_EPILOGUE -#else - call CNAME(__error) - popl %ecx -#endif - movl %ecx,(%eax) - movl $-1,%eax - movl $-1,%edx - ret - diff --git a/lib/libc/i386/sys/exect.S b/lib/libc/i386/sys/exect.S deleted file mode 100644 index 9f90060..0000000 --- a/lib/libc/i386/sys/exect.S +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" -#include - -ENTRY(exect) - lea SYS_execve,%eax - pushf - popl %edx - orl $ PSL_T,%edx - pushl %edx - popf - KERNCALL - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) /* exect(file, argv, env); */ diff --git a/lib/libc/i386/sys/fork.S b/lib/libc/i386/sys/fork.S deleted file mode 100644 index 6c3cde8..0000000 --- a/lib/libc/i386/sys/fork.S +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - -PSYSCALL(fork) - cmpl $0,%edx /* parent, since %edx == 0 in parent, 1 in child */ - je 1f - movl $0,%eax -1: - ret /* pid = fork(); */ diff --git a/lib/libc/i386/sys/i386_get_ioperm.2 b/lib/libc/i386/sys/i386_get_ioperm.2 deleted file mode 100644 index 2d326b8..0000000 --- a/lib/libc/i386/sys/i386_get_ioperm.2 +++ /dev/null @@ -1,84 +0,0 @@ -.\" Copyright (c) 1998 Jonathan Lemon -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd July 27, 1998 -.Os -.Dt I386_GET_IOPERM 2 -.Sh NAME -.Nm i386_get_ioperm , -.Nm i386_set_ioperm -.Nd manage per-process access to the i386 I/O port space -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn i386_get_ioperm "unsigned int start" "unsigned int *length" "int *enable" -.Ft int -.Fn i386_set_ioperm "unsigned int start" "unsigned int length" "int enable" -.Sh DESCRIPTION -.Fn i386_get_ioperm -will return the permission for the process' I/O port space in the -.Fa *enable -argument. The port range starts at -.Fa start -and the number of contiguous entries will be returned in -.Fa *length . -.Pp -.Fn i386_set_ioperm -will set access to a range of I/O ports described by the -.Fa start -and -.Fa length -arguments to the state specified by the -.Fa enable -argument. -.Sh RETURN VALUES -Upon successful completion, -.Fn i386_get_ioperm -and -.Fn i386_set_ioperm -return the value of 0. -Otherwise, a value of -1 is returned and the global -variable -.Va errno -is set to indicate the error. -.Sh ERRORS -.Fn i386_get_ioperm -and -.Fn i386_set_ioperm -will fail if: -.Bl -tag -width [EINVAL] -.It Bq Er EINVAL -An invalid range was specified by the -.Fa start -or -.Fa length -arguments. -.It Bq Er EPERM -The caller of i386_set_ioperm was not the superuser. -.El -.Sh AUTHORS -This man page was written by -.An Jonathan Lemon . diff --git a/lib/libc/i386/sys/i386_get_ioperm.c b/lib/libc/i386/sys/i386_get_ioperm.c deleted file mode 100644 index 319ce57..0000000 --- a/lib/libc/i386/sys/i386_get_ioperm.c +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1998 Jonathan Lemon - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) -static const char rcsid[] = "$FreeBSD$"; -#endif /* LIBC_RCS and not lint */ - -#include - -int -i386_get_ioperm(unsigned int start, unsigned int *length, int *enable) -{ - struct i386_ioperm_args p; - int error; - - p.start = start; - p.length = *length; - p.enable = *enable; - - error = sysarch(I386_GET_IOPERM, (char *)&p); - - *length = p.length; - *enable = p.enable; - - return (error); -} diff --git a/lib/libc/i386/sys/i386_get_ldt.2 b/lib/libc/i386/sys/i386_get_ldt.2 deleted file mode 100644 index fce57b6..0000000 --- a/lib/libc/i386/sys/i386_get_ldt.2 +++ /dev/null @@ -1,98 +0,0 @@ -.\" Copyright (c) 1980, 1991 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: @(#)fork.2 6.5 (Berkeley) 3/10/91 -.\" $FreeBSD$ -.\" -.Dd September 20, 1993 -.Dt I386_GET_LDT 2 -.Os FreeBSD -.Sh NAME -.Nm i386_get_ldt , -.Nm i386_set_ldt -.Nd manage i386 per-process Local Descriptor Table entries -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Ft int -.Fn i386_get_ldt "int start_sel" "union descriptor *descs" "int num_sels" -.Ft int -.Fn i386_set_ldt "int start_sel" "union descriptor *descs" "int num_sels" -.Sh DESCRIPTION -.Fn i386_get_ldt -will return the list of i386 descriptors that the process has in its -LDT. -.Fn i386_set_ldt -will set a list of i386 descriptors for the current process in its -LDT. -Both routines accept a starting selector number -.Fa start_sel -, an array of memory that -will contain the descriptors to be set or returned -.Fa descs -, and the number of entries to set or return -.Fa num_sels . -.Pp -The argument -.Fa descs -can be either segment_descriptor or gate_descriptor and are defined in -.Fd . -These structures are defined by the architecture -as disjoint bit-fields, so care must be taken in constructing them. -.Sh RETURN VALUES -Upon successful completion, -.Fn i386_get_ldt -returns the number of descriptors currently in the LDT. -.Fn i386_set_ldt -returns the first selector set. -Otherwise, a value of -1 is returned and the global -variable -.Va errno -is set to indicate the error. -.Sh ERRORS -.Fn i386_get_ldt -and -.Fn i386_set_ldt -will fail if: -.Bl -tag -width [EINVAL] -.It Bq Er EINVAL -An inappropriate parameter was used for -.Fa start_sel -or -.Fa num_sels . -.It Bq Er EACCES -The caller attempted to use a descriptor that would -circumvent protection or cause a failure. -.El -.Sh REFERENCES -i386 Microprocessor Programmer's Reference Manual, Intel -.Sh WARNING -You can really hose your process using this. diff --git a/lib/libc/i386/sys/i386_get_ldt.c b/lib/libc/i386/sys/i386_get_ldt.c deleted file mode 100644 index e2e6bd4..0000000 --- a/lib/libc/i386/sys/i386_get_ldt.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 1993 John Brezak - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) -static const char rcsid[] = "$FreeBSD$"; -#endif /* LIBC_RCS and not lint */ - -#include -#include -#include - -int -i386_get_ldt(int start, union descriptor *descs, int num) -{ - struct i386_ldt_args p; - - p.start = start; - p.descs = descs; - p.num = num; - - return sysarch(I386_GET_LDT, (char *)&p); -} diff --git a/lib/libc/i386/sys/i386_set_ioperm.c b/lib/libc/i386/sys/i386_set_ioperm.c deleted file mode 100644 index 1eca62b..0000000 --- a/lib/libc/i386/sys/i386_set_ioperm.c +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * Copyright (c) 1998 Jonathan Lemon - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) -static const char rcsid[] = "$FreeBSD$"; -#endif /* LIBC_RCS and not lint */ - -#include - -int -i386_set_ioperm(unsigned int start, unsigned int length, int enable) -{ - struct i386_ioperm_args p; - - p.start = start; - p.length = length; - p.enable = enable; - - return (sysarch(I386_SET_IOPERM, (char *)&p)); -} diff --git a/lib/libc/i386/sys/i386_set_ldt.c b/lib/libc/i386/sys/i386_set_ldt.c deleted file mode 100644 index 97fc318..0000000 --- a/lib/libc/i386/sys/i386_set_ldt.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 1993 John Brezak - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) -static const char rcsid[] = "$FreeBSD$"; -#endif /* LIBC_RCS and not lint */ - -#include -#include -#include - -int -i386_set_ldt(int start, union descriptor *descs, int num) -{ - struct i386_ldt_args p; - - p.start = start; - p.descs = descs; - p.num = num; - - return sysarch(I386_SET_LDT, (char *)&p); -} diff --git a/lib/libc/i386/sys/i386_vm86.2 b/lib/libc/i386/sys/i386_vm86.2 deleted file mode 100644 index 4dc0d52..0000000 --- a/lib/libc/i386/sys/i386_vm86.2 +++ /dev/null @@ -1,96 +0,0 @@ -.\" Copyright (c) 1998 Jonathan Lemon -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd July 27, 1998 -.Os -.Dt I386_VM86 2 -.Sh NAME -.Nm i386_vm86 -.Nd control vm86-related functions -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Fd #include -.Ft int -.Fn i386_vm86 "int function" "void *data" -.Sh DESCRIPTION -.Fn i386_vm86 -is used to call various vm86 related functions. -.Fa function -can be one of the following values: -.Bl -tag -offset indent -width VM86_SET_VME -.It Dv VM86_INIT -This will initialize the kernel's vm86 parameter area for the -process, and permit the process to make vm86 calls. -.Fa data -points to the following structure: -.Bd -literal -struct vm86_init_args { - int debug; - int cpu_type; - u_char int_map[32]; -}; -.Ed -.Pp -.Fa debug -is used to turn on debugging code. -.Fa cpu_type -controls the type of CPU being emulated, and is currently unimplemented. -.Fa int_map -is a bitmap which determines whether vm86 interrupts should be handled -in vm86 mode, or reflected back to the process. If the -.Em Nth -bit is set, the interrupt will be reflected to the process, otherwise -it will be dispatched by the vm86 interrupt table. -.\" .It Dv VM86_SET_VME -.\" .It Dv VM86_GET_VME -.\" .It Dv VM86_INTCALL -.El -.Pp -vm86 mode is entered by calling -.Xr sigreturn 2 -with the correct machine context for vm86, and with the -.Em PSL_VM -bit set. Control returns to the process upon delivery of a signal. -.Sh RETURN VALUES -Upon successful completion, -.Fn i386_vm86 -will return the value of 0. -Otherwise, a value of -1 is returned and the global -variable -.Va errno -is set to indicate the error. -.Sh ERRORS -.Fn i386_vm86 -will fail if: -.Bl -tag -width [ENOMEM] -.It Bq Er EINVAL -The kernel does not have vm86 support, or an invalid function was specified. -.It Bq Er ENOMEM -There is not enough memory to initialize the kernel data structures. -.Sh AUTHORS -This man page was written by -.An Jonathan Lemon . diff --git a/lib/libc/i386/sys/i386_vm86.c b/lib/libc/i386/sys/i386_vm86.c deleted file mode 100644 index 3e2c842..0000000 --- a/lib/libc/i386/sys/i386_vm86.c +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * Copyright (c) 1998 Jonathan Lemon - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) -static const char rcsid[] = "$FreeBSD$"; -#endif /* LIBC_RCS and not lint */ - -#include - -int -i386_vm86(int fcn, void *data) -{ - struct i386_vm86_args p; - - p.sub_op = fcn; - p.sub_args = (char *)data; - - return (sysarch(I386_VM86, (void *)&p)); -} diff --git a/lib/libc/i386/sys/pipe.S b/lib/libc/i386/sys/pipe.S deleted file mode 100644 index 1684611..0000000 --- a/lib/libc/i386/sys/pipe.S +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - -PSYSCALL(pipe) - movl 4(%esp),%ecx - movl %eax,(%ecx) - movl %edx,4(%ecx) - movl $0,%eax - ret diff --git a/lib/libc/i386/sys/ptrace.S b/lib/libc/i386/sys/ptrace.S deleted file mode 100644 index 7f5e149..0000000 --- a/lib/libc/i386/sys/ptrace.S +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - -ENTRY(ptrace) - xorl %eax,%eax -#ifdef PIC - PIC_PROLOGUE - movl PIC_GOT(CNAME(errno)),%edx - movl %eax,(%edx) - PIC_EPILOGUE -#else - movl %eax,CNAME(errno) -#endif - lea SYS_ptrace,%eax - KERNCALL - jb err - ret -err: - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) diff --git a/lib/libc/i386/sys/reboot.S b/lib/libc/i386/sys/reboot.S deleted file mode 100644 index 4e39068..0000000 --- a/lib/libc/i386/sys/reboot.S +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - -SYSCALL(reboot) - iret diff --git a/lib/libc/i386/sys/rfork.S b/lib/libc/i386/sys/rfork.S deleted file mode 100644 index b3e20e4..0000000 --- a/lib/libc/i386/sys/rfork.S +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - -PSYSCALL(rfork) - cmpl $0,%edx /* parent, since %edx == 0 in parent, 1 in child */ - je 1f - movl $0,%eax -1: - ret /* pid = rfork(); */ diff --git a/lib/libc/i386/sys/sbrk.S b/lib/libc/i386/sys/sbrk.S deleted file mode 100644 index f7aae35..0000000 --- a/lib/libc/i386/sys/sbrk.S +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - - .globl CNAME(end) - .globl HIDENAME(minbrk) - .globl HIDENAME(curbrk) - - .data -HIDENAME(minbrk): .long CNAME(end) -HIDENAME(curbrk): .long CNAME(end) - .text - -ENTRY(sbrk) -#ifdef PIC - movl 4(%esp),%ecx - PIC_PROLOGUE - movl PIC_GOT(HIDENAME(curbrk)),%edx - movl (%edx),%eax - PIC_EPILOGUE - testl %ecx,%ecx - jz back - addl %eax,4(%esp) - lea SYS_break,%eax - KERNCALL - jb err - PIC_PROLOGUE - movl PIC_GOT(HIDENAME(curbrk)),%edx - movl (%edx),%eax - addl %ecx,(%edx) - PIC_EPILOGUE -back: - ret -err: - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) - -#else /* !PIC */ - - movl 4(%esp),%ecx - movl HIDENAME(curbrk),%eax - testl %ecx,%ecx - jz back - addl %eax,4(%esp) - lea SYS_break,%eax - KERNCALL - jb err - movl HIDENAME(curbrk),%eax - addl %ecx,HIDENAME(curbrk) -back: - ret -err: - jmp HIDENAME(cerror) -#endif /* PIC */ diff --git a/lib/libc/i386/sys/setlogin.S b/lib/libc/i386/sys/setlogin.S deleted file mode 100644 index a4d74b0..0000000 --- a/lib/libc/i386/sys/setlogin.S +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 1991 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* LIBC_RCS and not lint */ - -#include "SYS.h" - -.globl CNAME(_logname_valid) /* in getlogin() */ - -SYSCALL(setlogin) -#ifdef PIC - PIC_PROLOGUE - pushl %eax - movl PIC_GOT(CNAME(_logname_valid)),%eax - movl $0,(%eax) - popl %eax - PIC_EPILOGUE -#else - movl $0,CNAME(_logname_valid) -#endif - ret /* setlogin(name) */ diff --git a/lib/libc/i386/sys/sigreturn.S b/lib/libc/i386/sys/sigreturn.S deleted file mode 100644 index 7405c34..0000000 --- a/lib/libc/i386/sys/sigreturn.S +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - -/* - * NOTE: If the profiling ENTRY() code ever changes any registers, they - * must be saved. On FreeBSD, this is not the case. - */ - -PSYSCALL(sigreturn) - ret diff --git a/lib/libc/i386/sys/syscall.S b/lib/libc/i386/sys/syscall.S deleted file mode 100644 index b5516f0..0000000 --- a/lib/libc/i386/sys/syscall.S +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * 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. - * - * $FreeBSD$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - -ENTRY(syscall) - pop %ecx /* rta */ - pop %eax /* syscall number */ - push %ecx - KERNCALL - push %ecx /* need to push a word to keep stack frame intact - upon return; the word must be the return address. */ - jb 1f - ret -1: - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h deleted file mode 100644 index 1e20bc7..0000000 --- a/lib/libc/include/libc_private.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 1998 John Birrell . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - * - * Private definitions for libc, libc_r and libpthread. - * - */ - -#ifndef _LIBC_PRIVATE_H_ -#define _LIBC_PRIVATE_H_ - -/* - * This global flag is non-zero when a process has created one - * or more threads. It is used to avoid calling locking functions - * when they are not required. - */ -extern int __isthreaded; - -/* - * File lock contention is difficult to diagnose without knowing - * where locks were set. Allow a debug library to be built which - * records the source file and line number of each lock call. - */ -#ifdef _FLOCK_DEBUG -#define _FLOCKFILE(x) _flockfile_debug(x, __FILE__, __LINE__) -#else -#define _FLOCKFILE(x) flockfile(x) -#endif - -/* - * Macros for locking and unlocking FILEs. These test if the - * process is threaded to avoid locking when not required. - */ -#define FLOCKFILE(fp) if (__isthreaded) _FLOCKFILE(fp) -#define FUNLOCKFILE(fp) if (__isthreaded) funlockfile(fp) - -#endif /* _LIBC_PRIVATE_H_ */ diff --git a/lib/libc/include/spinlock.h b/lib/libc/include/spinlock.h deleted file mode 100644 index d81615d..0000000 --- a/lib/libc/include/spinlock.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 1998 John Birrell . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - * - * Lock definitions used in both libc and libpthread. - * - */ - -#ifndef _SPINLOCK_H_ -#define _SPINLOCK_H_ -#include -#include - -/* - * Lock structure with room for debugging information. - */ -typedef struct { - volatile long access_lock; - volatile long lock_owner; - volatile char *fname; - volatile int lineno; -} spinlock_t; - -#define _SPINLOCK_INITIALIZER { 0, 0, 0, 0 } - -#define _SPINUNLOCK(_lck) (_lck)->access_lock = 0 -#ifdef _LOCK_DEBUG -#define _SPINLOCK(_lck) _spinlock_debug(_lck, __FILE__, __LINE__) -#else -#define _SPINLOCK(_lck) _spinlock(_lck) -#endif - -/* - * Thread function prototype definitions: - */ -__BEGIN_DECLS -long _atomic_lock __P((volatile long *)); -void _spinlock __P((spinlock_t *)); -void _spinlock_debug __P((spinlock_t *, char *, int)); -__END_DECLS - -#endif /* _SPINLOCK_H_ */ diff --git a/lib/libc/locale/Makefile.inc b/lib/libc/locale/Makefile.inc deleted file mode 100644 index fb3cb39..0000000 --- a/lib/libc/locale/Makefile.inc +++ /dev/null @@ -1,26 +0,0 @@ -# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 -# $FreeBSD$ - -# locale sources -.PATH: ${.CURDIR}/../libc/${MACHINE_ARCH}/locale ${.CURDIR}/../libc/locale - -SRCS+= ansi.c big5.c collate.c collcmp.c euc.c frune.c isctype.c \ - lconv.c localeconv.c mbrune.c mskanji.c nomacros.c none.c rune.c \ - runetype.c setinvalidrune.c setlocale.c setrunelocale.c table.c \ - tolower.c toupper.c utf2.c - -.if ${LIB} == "c" -MAN3+= ctype.3 isalnum.3 isalpha.3 isascii.3 isblank.3 iscntrl.3 \ - isdigit.3 isgraph.3 islower.3 isprint.3 ispunct.3 isspace.3 \ - isupper.3 isxdigit.3 mbrune.3 multibyte.3 rune.3 setlocale.3 \ - toascii.3 tolower.3 toupper.3 -MAN4+= euc.4 utf2.4 - -MLINKS+=mbrune.3 mbmb.3 mbrune.3 mbrrune.3 -MLINKS+=multibyte.3 mblen.3 multibyte.3 mbstowcs.3 multibyte.3 mbtowc.3 \ - multibyte.3 wcstombs.3 multibyte.3 wctomb.3 -MLINKS+=rune.3 fgetrune.3 rune.3 fputrune.3 rune.3 fungetrune.3 \ - rune.3 setinvalidrune.3 rune.3 setrunelocale.3 rune.3 sgetrune.3 \ - rune.3 sputrune.3 -MLINKS+=setlocale.3 localeconv.3 -.endif diff --git a/lib/libc/locale/ansi.c b/lib/libc/locale/ansi.c deleted file mode 100644 index c0871fe..0000000 --- a/lib/libc/locale/ansi.c +++ /dev/null @@ -1,151 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)ansi.c 8.1 (Berkeley) 6/27/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -int -mblen(s, n) - const char *s; - size_t n; -{ - char const *e; - - if (s == 0 || *s == 0) - return (0); /* No support for state dependent encodings. */ - - if (sgetrune(s, n, &e) == _INVALID_RUNE) - return (s - e); - return (e - s); -} - -int -mbtowc(pwc, s, n) - wchar_t *pwc; - const char *s; - size_t n; -{ - char const *e; - rune_t r; - - if (s == 0 || *s == 0) - return (0); /* No support for state dependent encodings. */ - - if ((r = sgetrune(s, n, &e)) == _INVALID_RUNE) - return (s - e); - if (pwc) - *pwc = r; - return (e - s); -} - -int -wctomb(s, wchar) - char *s; - wchar_t wchar; -{ - char *e; - - if (s == 0) - return (0); /* No support for state dependent encodings. */ - - if (wchar == 0) { - *s = 0; - return (1); - } - - sputrune(wchar, s, MB_CUR_MAX, &e); - return (e ? e - s : -1); -} - -size_t -mbstowcs(pwcs, s, n) - wchar_t *pwcs; - const char *s; - size_t n; -{ - char const *e; - int cnt = 0; - - if (!pwcs || !s) - return (-1); - - while (n-- > 0) { - *pwcs = sgetrune(s, MB_LEN_MAX, &e); - if (*pwcs == _INVALID_RUNE) - return (-1); - if (*pwcs++ == 0) - break; - s = e; - ++cnt; - } - return (cnt); -} - -size_t -wcstombs(s, pwcs, n) - char *s; - const wchar_t *pwcs; - size_t n; -{ - char *e; - int cnt, nb; - - if (!pwcs || !s || n > INT_MAX) - return (-1); - - nb = n; - cnt = 0; - while (nb > 0) { - if (*pwcs == 0) { - *s = 0; - break; - } - if (!sputrune(*pwcs++, s, nb, &e)) - return (-1); /* encoding error */ - if (!e) /* too long */ - return (cnt); - cnt += e - s; - nb -= e - s; - s = e; - } - return (cnt); -} diff --git a/lib/libc/locale/big5.c b/lib/libc/locale/big5.c deleted file mode 100644 index 9294f0c..0000000 --- a/lib/libc/locale/big5.c +++ /dev/null @@ -1,120 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifdef XPG4 -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)big5.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include - -rune_t _BIG5_sgetrune __P((const char *, size_t, char const **)); -int _BIG5_sputrune __P((rune_t, char *, size_t, char **)); - -int -_BIG5_init(rl) - _RuneLocale *rl; -{ - rl->sgetrune = _BIG5_sgetrune; - rl->sputrune = _BIG5_sputrune; - _CurrentRuneLocale = rl; - __mb_cur_max = 2; - return (0); -} - -static inline int -_big5_check(c) - u_int c; -{ - c &= 0xff; - return ((c >= 0xa1 && c <= 0xfe) ? 2 : 1); -} - -rune_t -_BIG5_sgetrune(string, n, result) - const char *string; - size_t n; - char const **result; -{ - rune_t rune = 0; - int len; - - if (n < 1 || (len = _big5_check(*string)) > n) { - if (result) - *result = string; - return (_INVALID_RUNE); - } - while (--len >= 0) - rune = (rune << 8) | ((u_int)(*string++) & 0xff); - if (result) - *result = string; - return rune; -} - -int -_BIG5_sputrune(c, string, n, result) - rune_t c; - char *string, **result; - size_t n; -{ - if (c & 0x8000) { - if (n >= 2) { - string[0] = (c >> 8) & 0xff; - string[1] = c & 0xff; - if (result) - *result = string + 2; - return (2); - } - } - else { - if (n >= 1) { - *string = c & 0xff; - if (result) - *result = string + 1; - return (1); - } - } - if (result) - *result = string; - return (0); - -} -#endif /* XPG4 */ diff --git a/lib/libc/locale/collate.c b/lib/libc/locale/collate.c deleted file mode 100644 index 373019c..0000000 --- a/lib/libc/locale/collate.c +++ /dev/null @@ -1,211 +0,0 @@ -/*- - * Copyright (c) 1995 Alex Tatmanjants - * at Electronni Visti IA, Kiev, Ukraine. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include -#include -#include -#include -#include -#include -#include -#include "collate.h" -#include "setlocale.h" - -int __collate_load_error = 1; -int __collate_substitute_nontrivial; -char __collate_version[STR_LEN]; -u_char __collate_substitute_table[UCHAR_MAX + 1][STR_LEN]; -struct __collate_st_char_pri __collate_char_pri_table[UCHAR_MAX + 1]; -struct __collate_st_chain_pri __collate_chain_pri_table[TABLE_SIZE]; - -#define FREAD(a, b, c, d) \ - do { \ - if(fread(a, b, c, d) != c) { \ - fclose(d); \ - return -1; \ - } \ - } while(0) - -void __collate_err(int ex, const char *f) __dead2; - -int -__collate_load_tables(encoding) - char *encoding; -{ - char buf[PATH_MAX]; - FILE *fp; - int i, save_load_error; - - save_load_error = __collate_load_error; - __collate_load_error = 1; - if (!encoding) { - __collate_load_error = save_load_error; - return -1; - } - if (!strcmp(encoding, "C") || !strcmp(encoding, "POSIX")) - return 0; - if (!_PathLocale) { - __collate_load_error = save_load_error; - return -1; - } - /* Range checking not needed, encoding has fixed size */ - (void) strcpy(buf, _PathLocale); - (void) strcat(buf, "/"); - (void) strcat(buf, encoding); - (void) strcat(buf, "/LC_COLLATE"); - if ((fp = fopen(buf, "r")) == NULL) { - __collate_load_error = save_load_error; - return -1; - } - FREAD(__collate_version, sizeof(__collate_version), 1, fp); - if (strcmp(__collate_version, COLLATE_VERSION) != 0) { - fclose(fp); - return -1; - } - FREAD(__collate_substitute_table, sizeof(__collate_substitute_table), - 1, fp); - FREAD(__collate_char_pri_table, sizeof(__collate_char_pri_table), 1, - fp); - FREAD(__collate_chain_pri_table, sizeof(__collate_chain_pri_table), 1, - fp); - fclose(fp); - __collate_load_error = 0; - - __collate_substitute_nontrivial = 0; - for (i = 0; i < UCHAR_MAX + 1; i++) { - if (__collate_substitute_table[i][0] != i || - __collate_substitute_table[i][1] != 0) { - __collate_substitute_nontrivial = 1; - break; - } - } - - return 0; -} - -u_char * -__collate_substitute(s) - const u_char *s; -{ - int dest_len, len, nlen; - int delta = strlen(s); - u_char *dest_str = NULL; - - if(s == NULL || *s == '\0') - return __collate_strdup(""); - delta += delta / 8; - dest_str = malloc(dest_len = delta); - if(dest_str == NULL) - __collate_err(EX_OSERR, __FUNCTION__); - len = 0; - while(*s) { - nlen = len + strlen(__collate_substitute_table[*s]); - if (dest_len <= nlen) { - dest_str = reallocf(dest_str, dest_len = nlen + delta); - if(dest_str == NULL) - __collate_err(EX_OSERR, __FUNCTION__); - } - strcpy(dest_str + len, __collate_substitute_table[*s++]); - len = nlen; - } - return dest_str; -} - -void -__collate_lookup(t, len, prim, sec) - const u_char *t; - int *len, *prim, *sec; -{ - struct __collate_st_chain_pri *p2; - - *len = 1; - *prim = *sec = 0; - for(p2 = __collate_chain_pri_table; p2->str[0]; p2++) { - if(strncmp(t, p2->str, strlen(p2->str)) == 0) { - *len = strlen(p2->str); - *prim = p2->prim; - *sec = p2->sec; - return; - } - } - *prim = __collate_char_pri_table[*t].prim; - *sec = __collate_char_pri_table[*t].sec; -} - -u_char * -__collate_strdup(s) - u_char *s; -{ - u_char *t = strdup(s); - - if (t == NULL) - __collate_err(EX_OSERR, __FUNCTION__); - return t; -} - -void -__collate_err(int ex, const char *f) -{ - extern char *__progname; /* Program name, from crt0. */ - const char *s; - int serrno = errno; - - s = __progname; - _write(STDERR_FILENO, s, strlen(s)); - _write(STDERR_FILENO, ": ", 2); - s = f; - _write(STDERR_FILENO, s, strlen(s)); - _write(STDERR_FILENO, ": ", 2); - s = strerror(serrno); - _write(STDERR_FILENO, s, strlen(s)); - _write(STDERR_FILENO, "\n", 1); - exit(ex); -} - -#ifdef COLLATE_DEBUG -void -__collate_print_tables() -{ - int i; - struct __collate_st_chain_pri *p2; - - printf("Substitute table:\n"); - for (i = 0; i < UCHAR_MAX + 1; i++) - if (i != *__collate_substitute_table[i]) - printf("\t'%c' --> \"%s\"\n", i, - __collate_substitute_table[i]); - printf("Chain priority table:\n"); - for (p2 = __collate_chain_pri_table; p2->str[0]; p2++) - printf("\t\"%s\" : %d %d\n\n", p2->str, p2->prim, p2->sec); - printf("Char priority table:\n"); - for (i = 0; i < UCHAR_MAX + 1; i++) - printf("\t'%c' : %d %d\n", i, __collate_char_pri_table[i].prim, - __collate_char_pri_table[i].sec); -} -#endif diff --git a/lib/libc/locale/collate.h b/lib/libc/locale/collate.h deleted file mode 100644 index ae6317c..0000000 --- a/lib/libc/locale/collate.h +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * Copyright (c) 1995 Alex Tatmanjants - * at Electronni Visti IA, Kiev, Ukraine. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef COLLATE_H_INCLUDED -#define COLLATE_H_INCLUDED - -#include -#include -#include - -#define STR_LEN 10 -#define TABLE_SIZE 100 -#define COLLATE_VERSION "1.0\n" - -struct __collate_st_char_pri { - int prim, sec; -}; -struct __collate_st_chain_pri { - u_char str[STR_LEN]; - int prim, sec; -}; - -extern int __collate_load_error; -extern int __collate_substitute_nontrivial; -extern char __collate_version[STR_LEN]; -extern u_char __collate_substitute_table[UCHAR_MAX + 1][STR_LEN]; -extern struct __collate_st_char_pri __collate_char_pri_table[UCHAR_MAX + 1]; -extern struct __collate_st_chain_pri __collate_chain_pri_table[TABLE_SIZE]; - -__BEGIN_DECLS -u_char *__collate_strdup __P((u_char *)); -u_char *__collate_substitute __P((const u_char *)); -int __collate_load_tables __P((char *)); -void __collate_lookup __P((const u_char *, int *, int *, int *)); -int __collate_range_cmp __P((int, int)); -#ifdef COLLATE_DEBUG -void __collate_print_tables __P((void)); -#endif -__END_DECLS - -#endif /* not COLLATE_H_INCLUDED */ diff --git a/lib/libc/locale/collcmp.c b/lib/libc/locale/collcmp.c deleted file mode 100644 index ae783d0..0000000 --- a/lib/libc/locale/collcmp.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 1996 by Andrey A. Chernov, Moscow, Russia. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#define ASCII_COMPATIBLE_COLLATE /* see usr.bin/colldef/data */ - -#include -#include "collate.h" -#ifndef ASCII_COMPATIBLE_COLLATE -#include -#endif - -/* - * Compare two characters converting collate information - * into ASCII-compatible range, it allows to handle - * "[a-z]"-type ranges with national characters. - */ - -int __collate_range_cmp (c1, c2) - int c1, c2; -{ - static char s1[2], s2[2]; - int ret; -#ifndef ASCII_COMPATIBLE_COLLATE - int as1, as2, al1, al2; -#endif - - c1 &= UCHAR_MAX; - c2 &= UCHAR_MAX; - if (c1 == c2) - return (0); - -#ifndef ASCII_COMPATIBLE_COLLATE - as1 = isascii(c1); - as2 = isascii(c2); - al1 = isalpha(c1); - al2 = isalpha(c2); - - if (as1 || as2 || al1 || al2) { - if ((as1 && as2) || (!al1 && !al2)) - return (c1 - c2); - if (al1 && !al2) { - if (isupper(c1)) - return ('A' - c2); - else - return ('a' - c2); - } else if (al2 && !al1) { - if (isupper(c2)) - return (c1 - 'A'); - else - return (c1 - 'a'); - } - } -#endif - s1[0] = c1; - s2[0] = c2; - if ((ret = strcoll(s1, s2)) != 0) - return (ret); - return (c1 - c2); -} diff --git a/lib/libc/locale/ctype.3 b/lib/libc/locale/ctype.3 deleted file mode 100644 index ba7143b..0000000 --- a/lib/libc/locale/ctype.3 +++ /dev/null @@ -1,145 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)ctype.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt CTYPE 3 -.Os -.Sh NAME -.Nm isalnum , -.Nm isalpha , -.Nm isascii , -.Nm isblank , -.Nm iscntrl , -.Nm isdigit , -.Nm isgraph , -.Nm ishexnumber , -.Nm isideogram , -.Nm islower , -.Nm isnumber , -.Nm isphonogram , -.Nm isprint , -.Nm ispunct , -.Nm isrune , -.Nm isspace , -.Nm isspecial , -.Nm isupper , -.Nm isxdigit , -.Nm toascii , -.Nm tolower , -.Nm toupper -.Nd character classification macros -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn isalnum "int c" -.Ft int -.Fn isalpha "int c" -.Ft int -.Fn isascii "int c" -.Ft int -.Fn iscntrl "int c" -.Ft int -.Fn isdigit "int c" -.Ft int -.Fn isgraph "int c" -.Ft int -.Fn ishexnumber "int c" -.Ft int -.Fn isideogram "int c" -.Ft int -.Fn islower "int c" -.Ft int -.Fn isnumber "int c" -.Ft int -.Fn isphonogram "int c" -.Ft int -.Fn isspecial "int c" -.Ft int -.Fn isprint "int c" -.Ft int -.Fn ispunct "int c" -.Ft int -.Fn isrune "int c" -.Ft int -.Fn isspace "int c" -.Ft int -.Fn isupper "int c" -.Ft int -.Fn isxdigit "int c" -.Ft int -.Fn toascii "int c" -.Ft int -.Fn tolower "int c" -.Ft int -.Fn toupper "int c" -.Sh DESCRIPTION -The above functions perform character tests and conversions on the integer -.Ar c . -They are available as macros, defined in the include file -.Aq Pa ctype.h , -or as true functions in the C library. -See the specific manual pages for more information. -.Sh SEE ALSO -.Xr isalnum 3 , -.Xr isalpha 3 , -.Xr isascii 3 , -.Xr isblank 3 , -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr isgraph 3 , -.Xr islower 3 , -.Xr isprint 3 , -.Xr ispunct 3 , -.Xr isspace 3 , -.Xr isupper 3 , -.Xr isxdigit 3 , -.Xr toascii 3 , -.Xr tolower 3 , -.Xr toupper 3 , -.Xr ascii 7 -.Sh STANDARDS -These functions, except for -.Fn digittoint , -.Fn isascii , -.Fn isblank , -.Fn ishexnumber , -.Fn isideogram , -.Fn isnumber , -.Fn isphonogram , -.Fn isrune , -.Fn isspecial -and -.Fn toascii , -conform to -.St -ansiC . diff --git a/lib/libc/locale/euc.4 b/lib/libc/locale/euc.4 deleted file mode 100644 index ce319ba..0000000 --- a/lib/libc/locale/euc.4 +++ /dev/null @@ -1,242 +0,0 @@ -.\" Copyright (c) 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Paul Borman at Krystal Technologies. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)euc.4 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt EUC 4 -.Os -.Sh NAME -.Nm euc -.Nd EUC encoding of runes -.Sh SYNOPSIS -.Nm ENCODING -.Qq EUC -.Pp -.Nm VARIABLE -.Ar len1 -.Ar mask1 -.Ar len2 -.Ar mask2 -.Ar len3 -.Ar mask3 -.Ar len4 -.Ar mask4 -.Ar mask -.Sh DESCRIPTION -The -.Nm EUC -encoding is provided for compatibility with -.Ux -based systems. -See -.Xr mklocale 1 -for a complete description of the -.Ev LC_CTYPE -source file format. -.Pp -.Nm EUC -implements a system of 4 multibyte codesets. -A multibyte character in the first codeset consists of -.Ar len1 -bytes starting with a byte in the range of 0x00 to 0x7f. -To allow use of ASCII, -.Ar len1 -is always 1. -A multibyte character in the second codeset consists of -.Ar len2 -bytes starting with a byte in the range of 0x80-0xff excluding 0x8e and 0x8f. -A multibyte character in the third codeset consists of -.Ar len3 -bytes starting with the byte 0x8e. -A multibyte character in the fourth codeset consists of -.Ar len4 -bytes starting with the byte 0x8f. -.Pp -The -.Ev rune_t -encoding of -.Nm EUC -multibyte characters is dependent on the -.Ar len -and -.Ar mask -arguments. -First, the bytes are moved into a -.Ev rune_t -as follows: -.Bd -literal -byte0 << ((\fIlen\fPN-1) * 8) | byte1 << ((\fIlen\fPN-2) * 8) | ... | byte\fIlen\fPN-1 -.Ed -.Pp -The result is then ANDed with -.Ar ~mask -and ORed with -.Ar maskN . -Codesets 2 and 3 are special in that the leading byte (0x8e or 0x8f) is -first removed and the -.Ar lenN -argument is reduced by 1. -.Pp -For example, the Japanese locale has the following -.Ev VARIABLE -line: -.Bd -literal -VARIABLE 1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080 -.Ed -.Pp -Codeset 1 consists of the values 0x0000 - 0x007f. -.Pp -Codeset 2 consists of the values who have the bits 0x8080 set. -.Pp -Codeset 3 consists of the values 0x0080 - 0x00ff. -.Pp -Codeset 4 consists of the values 0x8000 - 0xff7f excluding the values -which have the 0x0080 bit set. -.Pp -Notice that the global -.Ar mask -is set to 0x8080, this implies that from those 2 bits the codeset can -be determined. -.Sh "EXAMPLE - Japanese Locale" -This is a complete example of an -.Ev LC_CTYPE -source file for the Japanese locale -.Bd -literal -/* - * Japanese LOCALE_CTYPE definitions using EUC of JIS character sets - */ - -ENCODING "EUC" - -/* JIS JIS JIS */ -/* X201 X208 X201 */ -/* 00-7f 84-fe */ - -VARIABLE 1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080 - -/* - * Code Set 1 - */ -ALPHA 'A' - 'Z' 'a' - 'z' -CONTROL 0x00 - 0x1f 0x7f -DIGIT '0' - '9' -GRAPH 0x21 - 0x7e -LOWER 'a' - 'z' -PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e -SPACE 0x09 - 0x0d 0x20 -UPPER 'A' - 'Z' -XDIGIT 'a' - 'f' 'A' - 'F' -BLANK ' ' '\t' -PRINT 0x20 - 0x7e - -MAPLOWER < 'A' - 'Z' : 'a' > < 'a' - 'z' : 'a' > -MAPUPPER < 'A' - 'Z' : 'A' > < 'a' - 'z' : 'A' > -TODIGIT < '0' - '9' : 0 > -TODIGIT < 'A' - 'F' : 10 > < 'a' - 'f' : 10 > - -/* - * Code Set 2 - */ - -SPACE 0xa1a1 -PHONOGRAM 0xa1bc -SPECIAL 0xa1a2 - 0xa1fe -PUNCT 0xa1a2 - 0xa1f8 /* A few too many in here... */ - -SPECIAL 0xa2a1 - 0xa2ae 0xa2ba - 0xa2c1 0xa2ca - 0xa2d0 0xa2dc - 0xa2ea -SPECIAL 0xa2f2 - 0xa2f9 0xa2fe - -DIGIT 0xa3b0 - 0xa3b9 -UPPER 0xa3c1 - 0xa3da /* Romaji */ -LOWER 0xa3e1 - 0xa3fa /* Romaji */ -MAPLOWER < 0xa3c1 - 0xa3da : 0xa3e1 > /* English */ -MAPLOWER < 0xa3e1 - 0xa3fa : 0xa3e1 > /* English */ -MAPUPPER < 0xa3c1 - 0xa3da : 0xa3c1 > -MAPUPPER < 0xa3e1 - 0xa3fa : 0xa3c1 > - -XDIGIT 0xa3c1 - 0xa3c6 0xa3e1 - 0xa3e6 - -TODIGIT < 0xa3b0 - 0xa3b9 : 0 > -TODIGIT < 0xa3c1 - 0xa3c6 : 10 > < 0xa3e1 - 0xa3e6 : 10 > - -PHONOGRAM 0xa4a1 - 0xa4f3 -PHONOGRAM 0xa5a1 - 0xa5f6 - -UPPER 0xa6a1 - 0xa6b8 /* Greek */ -LOWER 0xa6c1 - 0xa6d8 /* Greek */ -MAPLOWER < 0xa6a1 - 0xa6b8 : 0xa6c1 > < 0xa6c1 - 0xa6d8 : 0xa6c1 > -MAPUPPER < 0xa6a1 - 0xa6b8 : 0xa6a1 > < 0xa6c1 - 0xa6d8 : 0xa6a1 > - -UPPER 0xa7a1 - 0xa7c1 /* Cyrillic */ -LOWER 0xa7d1 - 0xa7f1 /* Cyrillic */ -MAPLOWER < 0xa7a1 - 0xa7c1 : 0xa7d1 > < 0xa7d1 - 0xa7f1 : 0xa7d1 > -MAPUPPER < 0xa7a1 - 0xa7c1 : 0xa7a1 > < 0xa7d1 - 0xa7f1 : 0xa7a1 > - -SPECIAL 0xa8a1 - 0xa8c0 - -IDEOGRAM 0xb0a1 - 0xb0fe 0xb1a1 - 0xb1fe 0xb2a1 - 0xb2fe -IDEOGRAM 0xb3a1 - 0xb3fe 0xb4a1 - 0xb4fe 0xb5a1 - 0xb5fe -IDEOGRAM 0xb6a1 - 0xb6fe 0xb7a1 - 0xb7fe 0xb8a1 - 0xb8fe -IDEOGRAM 0xb9a1 - 0xb9fe 0xbaa1 - 0xbafe 0xbba1 - 0xbbfe -IDEOGRAM 0xbca1 - 0xbcfe 0xbda1 - 0xbdfe 0xbea1 - 0xbefe -IDEOGRAM 0xbfa1 - 0xbffe 0xc0a1 - 0xc0fe 0xc1a1 - 0xc1fe -IDEOGRAM 0xc2a1 - 0xc2fe 0xc3a1 - 0xc3fe 0xc4a1 - 0xc4fe -IDEOGRAM 0xc5a1 - 0xc5fe 0xc6a1 - 0xc6fe 0xc7a1 - 0xc7fe -IDEOGRAM 0xc8a1 - 0xc8fe 0xc9a1 - 0xc9fe 0xcaa1 - 0xcafe -IDEOGRAM 0xcba1 - 0xcbfe 0xcca1 - 0xccfe 0xcda1 - 0xcdfe -IDEOGRAM 0xcea1 - 0xcefe 0xcfa1 - 0xcfd3 0xd0a1 - 0xd0fe -IDEOGRAM 0xd1a1 - 0xd1fe 0xd2a1 - 0xd2fe 0xd3a1 - 0xd3fe -IDEOGRAM 0xd4a1 - 0xd4fe 0xd5a1 - 0xd5fe 0xd6a1 - 0xd6fe -IDEOGRAM 0xd7a1 - 0xd7fe 0xd8a1 - 0xd8fe 0xd9a1 - 0xd9fe -IDEOGRAM 0xdaa1 - 0xdafe 0xdba1 - 0xdbfe 0xdca1 - 0xdcfe -IDEOGRAM 0xdda1 - 0xddfe 0xdea1 - 0xdefe 0xdfa1 - 0xdffe -IDEOGRAM 0xe0a1 - 0xe0fe 0xe1a1 - 0xe1fe 0xe2a1 - 0xe2fe -IDEOGRAM 0xe3a1 - 0xe3fe 0xe4a1 - 0xe4fe 0xe5a1 - 0xe5fe -IDEOGRAM 0xe6a1 - 0xe6fe 0xe7a1 - 0xe7fe 0xe8a1 - 0xe8fe -IDEOGRAM 0xe9a1 - 0xe9fe 0xeaa1 - 0xeafe 0xeba1 - 0xebfe -IDEOGRAM 0xeca1 - 0xecfe 0xeda1 - 0xedfe 0xeea1 - 0xeefe -IDEOGRAM 0xefa1 - 0xeffe 0xf0a1 - 0xf0fe 0xf1a1 - 0xf1fe -IDEOGRAM 0xf2a1 - 0xf2fe 0xf3a1 - 0xf3fe 0xf4a1 - 0xf4a4 -/* - * This is for Code Set 3, half-width kana - */ -SPECIAL 0xa1 - 0xdf -PHONOGRAM 0xa1 - 0xdf -CONTROL 0x84 - 0x97 0x9b - 0x9f 0xe0 - 0xfe -.Ed -.Sh "SEE ALSO" -.Xr mklocale 1 , -.Xr setlocale 3 diff --git a/lib/libc/locale/euc.5 b/lib/libc/locale/euc.5 deleted file mode 100644 index ce319ba..0000000 --- a/lib/libc/locale/euc.5 +++ /dev/null @@ -1,242 +0,0 @@ -.\" Copyright (c) 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Paul Borman at Krystal Technologies. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)euc.4 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt EUC 4 -.Os -.Sh NAME -.Nm euc -.Nd EUC encoding of runes -.Sh SYNOPSIS -.Nm ENCODING -.Qq EUC -.Pp -.Nm VARIABLE -.Ar len1 -.Ar mask1 -.Ar len2 -.Ar mask2 -.Ar len3 -.Ar mask3 -.Ar len4 -.Ar mask4 -.Ar mask -.Sh DESCRIPTION -The -.Nm EUC -encoding is provided for compatibility with -.Ux -based systems. -See -.Xr mklocale 1 -for a complete description of the -.Ev LC_CTYPE -source file format. -.Pp -.Nm EUC -implements a system of 4 multibyte codesets. -A multibyte character in the first codeset consists of -.Ar len1 -bytes starting with a byte in the range of 0x00 to 0x7f. -To allow use of ASCII, -.Ar len1 -is always 1. -A multibyte character in the second codeset consists of -.Ar len2 -bytes starting with a byte in the range of 0x80-0xff excluding 0x8e and 0x8f. -A multibyte character in the third codeset consists of -.Ar len3 -bytes starting with the byte 0x8e. -A multibyte character in the fourth codeset consists of -.Ar len4 -bytes starting with the byte 0x8f. -.Pp -The -.Ev rune_t -encoding of -.Nm EUC -multibyte characters is dependent on the -.Ar len -and -.Ar mask -arguments. -First, the bytes are moved into a -.Ev rune_t -as follows: -.Bd -literal -byte0 << ((\fIlen\fPN-1) * 8) | byte1 << ((\fIlen\fPN-2) * 8) | ... | byte\fIlen\fPN-1 -.Ed -.Pp -The result is then ANDed with -.Ar ~mask -and ORed with -.Ar maskN . -Codesets 2 and 3 are special in that the leading byte (0x8e or 0x8f) is -first removed and the -.Ar lenN -argument is reduced by 1. -.Pp -For example, the Japanese locale has the following -.Ev VARIABLE -line: -.Bd -literal -VARIABLE 1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080 -.Ed -.Pp -Codeset 1 consists of the values 0x0000 - 0x007f. -.Pp -Codeset 2 consists of the values who have the bits 0x8080 set. -.Pp -Codeset 3 consists of the values 0x0080 - 0x00ff. -.Pp -Codeset 4 consists of the values 0x8000 - 0xff7f excluding the values -which have the 0x0080 bit set. -.Pp -Notice that the global -.Ar mask -is set to 0x8080, this implies that from those 2 bits the codeset can -be determined. -.Sh "EXAMPLE - Japanese Locale" -This is a complete example of an -.Ev LC_CTYPE -source file for the Japanese locale -.Bd -literal -/* - * Japanese LOCALE_CTYPE definitions using EUC of JIS character sets - */ - -ENCODING "EUC" - -/* JIS JIS JIS */ -/* X201 X208 X201 */ -/* 00-7f 84-fe */ - -VARIABLE 1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080 - -/* - * Code Set 1 - */ -ALPHA 'A' - 'Z' 'a' - 'z' -CONTROL 0x00 - 0x1f 0x7f -DIGIT '0' - '9' -GRAPH 0x21 - 0x7e -LOWER 'a' - 'z' -PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e -SPACE 0x09 - 0x0d 0x20 -UPPER 'A' - 'Z' -XDIGIT 'a' - 'f' 'A' - 'F' -BLANK ' ' '\t' -PRINT 0x20 - 0x7e - -MAPLOWER < 'A' - 'Z' : 'a' > < 'a' - 'z' : 'a' > -MAPUPPER < 'A' - 'Z' : 'A' > < 'a' - 'z' : 'A' > -TODIGIT < '0' - '9' : 0 > -TODIGIT < 'A' - 'F' : 10 > < 'a' - 'f' : 10 > - -/* - * Code Set 2 - */ - -SPACE 0xa1a1 -PHONOGRAM 0xa1bc -SPECIAL 0xa1a2 - 0xa1fe -PUNCT 0xa1a2 - 0xa1f8 /* A few too many in here... */ - -SPECIAL 0xa2a1 - 0xa2ae 0xa2ba - 0xa2c1 0xa2ca - 0xa2d0 0xa2dc - 0xa2ea -SPECIAL 0xa2f2 - 0xa2f9 0xa2fe - -DIGIT 0xa3b0 - 0xa3b9 -UPPER 0xa3c1 - 0xa3da /* Romaji */ -LOWER 0xa3e1 - 0xa3fa /* Romaji */ -MAPLOWER < 0xa3c1 - 0xa3da : 0xa3e1 > /* English */ -MAPLOWER < 0xa3e1 - 0xa3fa : 0xa3e1 > /* English */ -MAPUPPER < 0xa3c1 - 0xa3da : 0xa3c1 > -MAPUPPER < 0xa3e1 - 0xa3fa : 0xa3c1 > - -XDIGIT 0xa3c1 - 0xa3c6 0xa3e1 - 0xa3e6 - -TODIGIT < 0xa3b0 - 0xa3b9 : 0 > -TODIGIT < 0xa3c1 - 0xa3c6 : 10 > < 0xa3e1 - 0xa3e6 : 10 > - -PHONOGRAM 0xa4a1 - 0xa4f3 -PHONOGRAM 0xa5a1 - 0xa5f6 - -UPPER 0xa6a1 - 0xa6b8 /* Greek */ -LOWER 0xa6c1 - 0xa6d8 /* Greek */ -MAPLOWER < 0xa6a1 - 0xa6b8 : 0xa6c1 > < 0xa6c1 - 0xa6d8 : 0xa6c1 > -MAPUPPER < 0xa6a1 - 0xa6b8 : 0xa6a1 > < 0xa6c1 - 0xa6d8 : 0xa6a1 > - -UPPER 0xa7a1 - 0xa7c1 /* Cyrillic */ -LOWER 0xa7d1 - 0xa7f1 /* Cyrillic */ -MAPLOWER < 0xa7a1 - 0xa7c1 : 0xa7d1 > < 0xa7d1 - 0xa7f1 : 0xa7d1 > -MAPUPPER < 0xa7a1 - 0xa7c1 : 0xa7a1 > < 0xa7d1 - 0xa7f1 : 0xa7a1 > - -SPECIAL 0xa8a1 - 0xa8c0 - -IDEOGRAM 0xb0a1 - 0xb0fe 0xb1a1 - 0xb1fe 0xb2a1 - 0xb2fe -IDEOGRAM 0xb3a1 - 0xb3fe 0xb4a1 - 0xb4fe 0xb5a1 - 0xb5fe -IDEOGRAM 0xb6a1 - 0xb6fe 0xb7a1 - 0xb7fe 0xb8a1 - 0xb8fe -IDEOGRAM 0xb9a1 - 0xb9fe 0xbaa1 - 0xbafe 0xbba1 - 0xbbfe -IDEOGRAM 0xbca1 - 0xbcfe 0xbda1 - 0xbdfe 0xbea1 - 0xbefe -IDEOGRAM 0xbfa1 - 0xbffe 0xc0a1 - 0xc0fe 0xc1a1 - 0xc1fe -IDEOGRAM 0xc2a1 - 0xc2fe 0xc3a1 - 0xc3fe 0xc4a1 - 0xc4fe -IDEOGRAM 0xc5a1 - 0xc5fe 0xc6a1 - 0xc6fe 0xc7a1 - 0xc7fe -IDEOGRAM 0xc8a1 - 0xc8fe 0xc9a1 - 0xc9fe 0xcaa1 - 0xcafe -IDEOGRAM 0xcba1 - 0xcbfe 0xcca1 - 0xccfe 0xcda1 - 0xcdfe -IDEOGRAM 0xcea1 - 0xcefe 0xcfa1 - 0xcfd3 0xd0a1 - 0xd0fe -IDEOGRAM 0xd1a1 - 0xd1fe 0xd2a1 - 0xd2fe 0xd3a1 - 0xd3fe -IDEOGRAM 0xd4a1 - 0xd4fe 0xd5a1 - 0xd5fe 0xd6a1 - 0xd6fe -IDEOGRAM 0xd7a1 - 0xd7fe 0xd8a1 - 0xd8fe 0xd9a1 - 0xd9fe -IDEOGRAM 0xdaa1 - 0xdafe 0xdba1 - 0xdbfe 0xdca1 - 0xdcfe -IDEOGRAM 0xdda1 - 0xddfe 0xdea1 - 0xdefe 0xdfa1 - 0xdffe -IDEOGRAM 0xe0a1 - 0xe0fe 0xe1a1 - 0xe1fe 0xe2a1 - 0xe2fe -IDEOGRAM 0xe3a1 - 0xe3fe 0xe4a1 - 0xe4fe 0xe5a1 - 0xe5fe -IDEOGRAM 0xe6a1 - 0xe6fe 0xe7a1 - 0xe7fe 0xe8a1 - 0xe8fe -IDEOGRAM 0xe9a1 - 0xe9fe 0xeaa1 - 0xeafe 0xeba1 - 0xebfe -IDEOGRAM 0xeca1 - 0xecfe 0xeda1 - 0xedfe 0xeea1 - 0xeefe -IDEOGRAM 0xefa1 - 0xeffe 0xf0a1 - 0xf0fe 0xf1a1 - 0xf1fe -IDEOGRAM 0xf2a1 - 0xf2fe 0xf3a1 - 0xf3fe 0xf4a1 - 0xf4a4 -/* - * This is for Code Set 3, half-width kana - */ -SPECIAL 0xa1 - 0xdf -PHONOGRAM 0xa1 - 0xdf -CONTROL 0x84 - 0x97 0x9b - 0x9f 0xe0 - 0xfe -.Ed -.Sh "SEE ALSO" -.Xr mklocale 1 , -.Xr setlocale 3 diff --git a/lib/libc/locale/euc.c b/lib/libc/locale/euc.c deleted file mode 100644 index ea5cdb4..0000000 --- a/lib/libc/locale/euc.c +++ /dev/null @@ -1,223 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifdef XPG4 -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)euc.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include -#include -#include - -rune_t _EUC_sgetrune __P((const char *, size_t, char const **)); -int _EUC_sputrune __P((rune_t, char *, size_t, char **)); - -typedef struct { - int count[4]; - rune_t bits[4]; - rune_t mask; -} _EucInfo; - -int -_EUC_init(rl) - _RuneLocale *rl; -{ - _EucInfo *ei; - int x; - char *v, *e; - - rl->sgetrune = _EUC_sgetrune; - rl->sputrune = _EUC_sputrune; - - if (!rl->variable) { - free(rl); - return (EFTYPE); - } - v = (char *) rl->variable; - - while (*v == ' ' || *v == '\t') - ++v; - - if ((ei = malloc(sizeof(_EucInfo))) == NULL) { - free(rl); - return (ENOMEM); - } - for (x = 0; x < 4; ++x) { - ei->count[x] = (int) strtol(v, &e, 0); - if (v == e || !(v = e)) { - free(rl); - free(ei); - return (EFTYPE); - } - while (*v == ' ' || *v == '\t') - ++v; - ei->bits[x] = (int) strtol(v, &e, 0); - if (v == e || !(v = e)) { - free(rl); - free(ei); - return (EFTYPE); - } - while (*v == ' ' || *v == '\t') - ++v; - } - ei->mask = (int)strtol(v, &e, 0); - if (v == e || !(v = e)) { - free(rl); - free(ei); - return (EFTYPE); - } - if (sizeof(_EucInfo) <= rl->variable_len) { - memcpy(rl->variable, ei, sizeof(_EucInfo)); - free(ei); - } else { - rl->variable = &ei; - } - rl->variable_len = sizeof(_EucInfo); - _CurrentRuneLocale = rl; - __mb_cur_max = 3; - return (0); -} - -#define CEI ((_EucInfo *)(_CurrentRuneLocale->variable)) - -#define _SS2 0x008e -#define _SS3 0x008f - -static inline int -_euc_set(c) - u_int c; -{ - c &= 0xff; - - return ((c & 0x80) ? c == _SS3 ? 3 : c == _SS2 ? 2 : 1 : 0); -} -rune_t -_EUC_sgetrune(string, n, result) - const char *string; - size_t n; - char const **result; -{ - rune_t rune = 0; - int len, set; - - if (n < 1 || (len = CEI->count[set = _euc_set(*string)]) > n) { - if (result) - *result = string; - return (_INVALID_RUNE); - } - switch (set) { - case 3: - case 2: - --len; - ++string; - /* FALLTHROUGH */ - case 1: - case 0: - while (len-- > 0) - rune = (rune << 8) | ((u_int)(*string++) & 0xff); - break; - } - if (result) - *result = string; - return ((rune & ~CEI->mask) | CEI->bits[set]); -} - -int -_EUC_sputrune(c, string, n, result) - rune_t c; - char *string, **result; - size_t n; -{ - rune_t m = c & CEI->mask; - rune_t nm = c & ~m; - int i, len; - - if (m == CEI->bits[1]) { -CodeSet1: - /* Codeset 1: The first byte must have 0x80 in it. */ - i = len = CEI->count[1]; - if (n >= len) { - if (result) - *result = string + len; - while (i-- > 0) - *string++ = (nm >> (i << 3)) | 0x80; - } else - if (result) - *result = (char *) 0; - } else { - if (m == CEI->bits[0]) { - i = len = CEI->count[0]; - if (n < len) { - if (result) - *result = NULL; - return (len); - } - } else - if (m == CEI->bits[2]) { - i = len = CEI->count[2]; - if (n < len) { - if (result) - *result = NULL; - return (len); - } - *string++ = _SS2; - --i; - } else - if (m == CEI->bits[3]) { - i = len = CEI->count[3]; - if (n < len) { - if (result) - *result = NULL; - return (len); - } - *string++ = _SS3; - --i; - } else - goto CodeSet1; /* Bletch */ - while (i-- > 0) - *string++ = (nm >> (i << 3)) & 0xff; - if (result) - *result = string; - } - return (len); -} -#endif /* XPG4 */ diff --git a/lib/libc/locale/frune.c b/lib/libc/locale/frune.c deleted file mode 100644 index 443d3ba..0000000 --- a/lib/libc/locale/frune.c +++ /dev/null @@ -1,103 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)frune.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -long -fgetrune(fp) - FILE *fp; -{ - rune_t r; - int c, len; - char buf[MB_LEN_MAX]; - char const *result; - - len = 0; - do { - if ((c = getc(fp)) == EOF) { - if (len) - break; - return (EOF); - } - buf[len++] = c; - - if ((r = sgetrune(buf, len, &result)) != _INVALID_RUNE) - return (r); - } while (result == buf && len < MB_LEN_MAX); - - while (--len > 0) - ungetc(buf[len], fp); - return (_INVALID_RUNE); -} - -int -fungetrune(r, fp) - rune_t r; - FILE* fp; -{ - int len; - char buf[MB_LEN_MAX]; - - len = sputrune(r, buf, MB_LEN_MAX, 0); - while (len-- > 0) - if (ungetc(buf[len], fp) == EOF) - return (EOF); - return (0); -} - -int -fputrune(r, fp) - rune_t r; - FILE *fp; -{ - int i, len; - char buf[MB_LEN_MAX]; - - len = sputrune(r, buf, MB_LEN_MAX, 0); - - for (i = 0; i < len; ++i) - if (putc(buf[i], fp) == EOF) - return (EOF); - - return (0); -} diff --git a/lib/libc/locale/isalnum.3 b/lib/libc/locale/isalnum.3 deleted file mode 100644 index b548c58..0000000 --- a/lib/libc/locale/isalnum.3 +++ /dev/null @@ -1,91 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)isalnum.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt ISALNUM 3 -.Os -.Sh NAME -.Nm isalnum -.Nd alphanumeric character test -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn isalnum "int c" -.Sh DESCRIPTION -The -.Fn isalnum -function tests for any character for which -.Xr isalpha 3 -or -.Xr isdigit 3 -is true. -For 8-bit wide locales the value of the argument is -representable as an unsigned char or the value of EOF. -In the ASCII character set, this includes the following characters -(with their numeric values shown in octal): -.Pp -.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ -.It \&060\ ``0'' \t061\ ``1'' \t062\ ``2'' \t063\ ``3'' \t064\ ``4'' -.It \&065\ ``5'' \t066\ ``6'' \t067\ ``7'' \t070\ ``8'' \t071\ ``9'' -.It \&101\ ``A'' \t102\ ``B'' \t103\ ``C'' \t104\ ``D'' \t105\ ``E'' -.It \&106\ ``F'' \t107\ ``G'' \t110\ ``H'' \t111\ ``I'' \t112\ ``J'' -.It \&113\ ``K'' \t114\ ``L'' \t115\ ``M'' \t116\ ``N'' \t117\ ``O'' -.It \&120\ ``P'' \t121\ ``Q'' \t122\ ``R'' \t123\ ``S'' \t124\ ``T'' -.It \&125\ ``U'' \t126\ ``V'' \t127\ ``W'' \t130\ ``X'' \t131\ ``Y'' -.It \&132\ ``Z'' \t141\ ``a'' \t142\ ``b'' \t143\ ``c'' \t144\ ``d'' -.It \&145\ ``e'' \t146\ ``f'' \t147\ ``g'' \t150\ ``h'' \t151\ ``i'' -.It \&152\ ``j'' \t153\ ``k'' \t154\ ``l'' \t155\ ``m'' \t156\ ``n'' -.It \&157\ ``o'' \t160\ ``p'' \t161\ ``q'' \t162\ ``r'' \t163\ ``s'' -.It \&164\ ``t'' \t165\ ``u'' \t166\ ``v'' \t167\ ``w'' \t170\ ``x'' -.It \&171\ ``y'' \t172\ ``z'' -.El -.Sh RETURN VALUES -The -.Fn isalnum -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr isalpha 3 , -.Xr isdigit 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn isalnum -function conforms to -.St -ansiC . diff --git a/lib/libc/locale/isalpha.3 b/lib/libc/locale/isalpha.3 deleted file mode 100644 index 4bfed34..0000000 --- a/lib/libc/locale/isalpha.3 +++ /dev/null @@ -1,89 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)isalpha.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt ISALPHA 3 -.Os -.Sh NAME -.Nm isalpha -.Nd alphabetic character test -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn isalpha "int c" -.Sh DESCRIPTION -The -.Fn isalpha -function tests for any character for which -.Xr isupper 3 -or -.Xr islower 3 -is true. -For 8-bit wide locales the value of the argument is -representable as an unsigned char or the value of EOF. -In the ASCII character set, this includes the following characters -(with their numeric values shown in octal): -.Pp -.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ -.It \&101\ ``A'' \t102\ ``B'' \t103\ ``C'' \t104\ ``D'' \t105\ ``E'' -.It \&106\ ``F'' \t107\ ``G'' \t110\ ``H'' \t111\ ``I'' \t112\ ``J'' -.It \&113\ ``K'' \t114\ ``L'' \t115\ ``M'' \t116\ ``N'' \t117\ ``O'' -.It \&120\ ``P'' \t121\ ``Q'' \t122\ ``R'' \t123\ ``S'' \t124\ ``T'' -.It \&125\ ``U'' \t126\ ``V'' \t127\ ``W'' \t130\ ``X'' \t131\ ``Y'' -.It \&132\ ``Z'' \t141\ ``a'' \t142\ ``b'' \t143\ ``c'' \t144\ ``d'' -.It \&145\ ``e'' \t146\ ``f'' \t147\ ``g'' \t150\ ``h'' \t151\ ``i'' -.It \&152\ ``j'' \t153\ ``k'' \t154\ ``l'' \t155\ ``m'' \t156\ ``n'' -.It \&157\ ``o'' \t160\ ``p'' \t161\ ``q'' \t162\ ``r'' \t163\ ``s'' -.It \&164\ ``t'' \t165\ ``u'' \t166\ ``v'' \t167\ ``w'' \t170\ ``x'' -.It \&171\ ``y'' \t172\ ``z'' -.El -.Sh RETURN VALUES -The -.Fn isalpha -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr islower 3 , -.Xr isupper 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn isalpha -function conforms to -.St -ansiC . diff --git a/lib/libc/locale/isascii.3 b/lib/libc/locale/isascii.3 deleted file mode 100644 index b37f89b..0000000 --- a/lib/libc/locale/isascii.3 +++ /dev/null @@ -1,59 +0,0 @@ -.\" Copyright (c) 1989, 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. -.\" -.\" @(#)isascii.3 8.2 (Berkeley) 12/11/93 -.\" $FreeBSD$ -.\" -.Dd December 11, 1993 -.Dt ISASCII 3 -.Os -.Sh NAME -.Nm isascii -.Nd test for ASCII character -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn isascii "int c" -.Sh DESCRIPTION -The -.Fn isascii -function tests for an -.Tn ASCII -character, which is any character -between 0 and octal 0177 inclusive. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn isascii -function conforms to -.St -ansiC . diff --git a/lib/libc/locale/isblank.3 b/lib/libc/locale/isblank.3 deleted file mode 100644 index 545cbe6..0000000 --- a/lib/libc/locale/isblank.3 +++ /dev/null @@ -1,58 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)isblank.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt ISBLANK 3 -.Os -.Sh NAME -.Nm isblank -.Nd space or tab character test -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn isblank "int c" -.Sh DESCRIPTION -The -.Fn isblank -function tests for a space or tab character. -For 8-bit wide locales the value of the argument is -representable as an unsigned char or the value of EOF. -.Sh RETURN VALUES -The -.Fn isblank -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr ascii 7 diff --git a/lib/libc/locale/iscntrl.3 b/lib/libc/locale/iscntrl.3 deleted file mode 100644 index 4289e4c..0000000 --- a/lib/libc/locale/iscntrl.3 +++ /dev/null @@ -1,79 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)iscntrl.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt ISCNTRL 3 -.Os -.Sh NAME -.Nm iscntrl -.Nd control character test -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn iscntrl "int c" -.Sh DESCRIPTION -The -.Fn iscntrl -function tests for any control character. -For 8-bit wide locales the value of the argument is -representable as an unsigned char or the value of EOF. -In the ASCII character set, this includes the following characters -(with their numeric values shown in octal): -.Pp -.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ -.It \&000\ nul \t001\ soh \t002\ stx \t003\ etx \t004\ eot -.It \&005\ enq \t006\ ack \t007\ bel \t010\ bs \t011\ ht -.It \&012\ nl \t013\ vt \t014\ np \t015\ cr \t016\ so -.It \&017\ si \t020\ dle \t021\ dc1 \t022\ dc2 \t023\ dc3 -.It \&024\ dc4 \t025\ nak \t026\ syn \t027\ etb \t030\ can -.It \&031\ em \t032\ sub \t033\ esc \t034\ fs \t035\ gs -.It \&036\ rs \t037\ us \t177\ del -.El -.Sh RETURN VALUES -The -.Fn iscntrl -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn iscntrl -function conforms to -.St -ansiC . diff --git a/lib/libc/locale/isctype.c b/lib/libc/locale/isctype.c deleted file mode 100644 index 98e70e4..0000000 --- a/lib/libc/locale/isctype.c +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)isctype.c 8.3 (Berkeley) 2/24/94"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#undef digittoint -int -digittoint(c) - int c; -{ - return (__maskrune((c), 0xFF)); -} - -#undef isalnum -int -isalnum(c) - int c; -{ - return (__istype((c), _CTYPE_A|_CTYPE_D)); -} - -#undef isalpha -int -isalpha(c) - int c; -{ - return (__istype((c), _CTYPE_A)); -} - -#undef isascii -int -isascii(c) - int c; -{ - return (((c) & ~0x7F) == 0); -} - -#undef isblank -int -isblank(c) - int c; -{ - return (__istype((c), _CTYPE_B)); -} - -#undef iscntrl -int -iscntrl(c) - int c; -{ - return (__istype((c), _CTYPE_C)); -} - -#undef isdigit -int -isdigit(c) - int c; -{ - return (__isctype((c), _CTYPE_D)); -} - -#undef isgraph -int -isgraph(c) - int c; -{ - return (__istype((c), _CTYPE_G)); -} - -#undef ishexnumber -int -ishexnumber(c) - int c; -{ - return (__istype((c), _CTYPE_X)); -} - -#undef isideogram -int -isideogram(c) - int c; -{ - return (__istype((c), _CTYPE_I)); -} - -#undef islower -int -islower(c) - int c; -{ - return (__istype((c), _CTYPE_L)); -} - -#undef isnumber -int -isnumber(c) - int c; -{ - return (__istype((c), _CTYPE_D)); -} - -#undef isphonogram -int -isphonogram(c) - int c; -{ - return (__istype((c), _CTYPE_Q)); -} - -#undef isprint -int -isprint(c) - int c; -{ - return (__istype((c), _CTYPE_R)); -} - -#undef ispunct -int -ispunct(c) - int c; -{ - return (__istype((c), _CTYPE_P)); -} - -#undef isrune -int -isrune(c) - int c; -{ - return (__istype((c), 0xFFFFFF00L)); -} - -#undef isspace -int -isspace(c) - int c; -{ - return (__istype((c), _CTYPE_S)); -} - -#undef isspecial -int -isspecial(c) - int c; -{ - return (__istype((c), _CTYPE_T)); -} - -#undef isupper -int -isupper(c) - int c; -{ - return (__istype((c), _CTYPE_U)); -} - -#undef isxdigit -int -isxdigit(c) - int c; -{ - return (__isctype((c), _CTYPE_X)); -} - -#undef toascii -int -toascii(c) - int c; -{ - return ((c) & 0x7F); -} - -#undef tolower -int -tolower(c) - int c; -{ - return (__tolower(c)); -} - -#undef toupper -int -toupper(c) - int c; -{ - return (__toupper(c)); -} - diff --git a/lib/libc/locale/isdigit.3 b/lib/libc/locale/isdigit.3 deleted file mode 100644 index 24c3e78..0000000 --- a/lib/libc/locale/isdigit.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)isdigit.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt ISDIGIT 3 -.Os -.Sh NAME -.Nm isdigit -.Nd decimal-digit character test -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn isdigit "int c" -.Sh DESCRIPTION -The -.Fn isdigit -function tests for any decimal-digit character. -For 8-bit wide locales the value of the argument is -representable as an unsigned char or the value of EOF. -In the ASCII character set, this includes the following characters -(with their numeric values shown in octal): -.Pp -.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ -.It \&060\ ``0'' \t061\ ``1'' \t062\ ``2'' \t063\ ``3'' \t064\ ``4'' -.It \&065\ ``5'' \t066\ ``6'' \t067\ ``7'' \t070\ ``8'' \t071\ ``9'' -.El -.Sh RETURN VALUES -The -.Fn isdigit -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn isdigit -function conforms to -.St -ansiC . diff --git a/lib/libc/locale/isgraph.3 b/lib/libc/locale/isgraph.3 deleted file mode 100644 index 5327398..0000000 --- a/lib/libc/locale/isgraph.3 +++ /dev/null @@ -1,91 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)isgraph.3 8.2 (Berkeley) 12/11/93 -.\" $FreeBSD$ -.\" -.Dd December 11, 1993 -.Dt ISGRAPH 3 -.Os -.Sh NAME -.Nm isgraph -.Nd printing character test (space character exclusive) -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn isgraph "int c" -.Sh DESCRIPTION -The -.Fn isgraph -function tests for any printing character except space. -For 8-bit wide locales the value of the argument is -representable as an unsigned char or the value of EOF. -In the ASCII character set, this includes the following characters -(with their numeric values shown in octal): -.Pp -.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ -.It \&041\ ``!'' \t042\ ``"'' \t043\ ``#'' \t044\ ``$'' \t045\ ``%'' -.It \&046\ ``&'' \t047\ ``''' \t050\ ``('' \t051\ ``)'' \t052\ ``*'' -.It \&053\ ``+'' \t054\ ``,'' \t055\ ``-'' \t056\ ``.'' \t057\ ``/'' -.It \&060\ ``0'' \t061\ ``1'' \t062\ ``2'' \t063\ ``3'' \t064\ ``4'' -.It \&065\ ``5'' \t066\ ``6'' \t067\ ``7'' \t070\ ``8'' \t071\ ``9'' -.It \&072\ ``:'' \t073\ ``;'' \t074\ ``<'' \t075\ ``='' \t076\ ``>'' -.It \&077\ ``?'' \t100\ ``@'' \t101\ ``A'' \t102\ ``B'' \t103\ ``C'' -.It \&104\ ``D'' \t105\ ``E'' \t106\ ``F'' \t107\ ``G'' \t110\ ``H'' -.It \&111\ ``I'' \t112\ ``J'' \t113\ ``K'' \t114\ ``L'' \t115\ ``M'' -.It \&116\ ``N'' \t117\ ``O'' \t120\ ``P'' \t121\ ``Q'' \t122\ ``R'' -.It \&123\ ``S'' \t124\ ``T'' \t125\ ``U'' \t126\ ``V'' \t127\ ``W'' -.It \&130\ ``X'' \t131\ ``Y'' \t132\ ``Z'' \t133\ ``['' \t134\ ``\e\|'' -.It \&135\ ``]'' \t136\ ``^'' \t137\ ``_'' \t140\ ```'' \t141\ ``a'' -.It \&142\ ``b'' \t143\ ``c'' \t144\ ``d'' \t145\ ``e'' \t146\ ``f'' -.It \&147\ ``g'' \t150\ ``h'' \t151\ ``i'' \t152\ ``j'' \t153\ ``k'' -.It \&154\ ``l'' \t155\ ``m'' \t156\ ``n'' \t157\ ``o'' \t160\ ``p'' -.It \&161\ ``q'' \t162\ ``r'' \t163\ ``s'' \t164\ ``t'' \t165\ ``u'' -.It \&166\ ``v'' \t167\ ``w'' \t170\ ``x'' \t171\ ``y'' \t172\ ``z'' -.It \&173\ ``{'' \t174\ ``|'' \t175\ ``}'' \t176\ ``~'' -.El -.Sh RETURN VALUES -The -.Fn isgraph -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn isgraph -function conforms to -.St -ansiC . diff --git a/lib/libc/locale/islower.3 b/lib/libc/locale/islower.3 deleted file mode 100644 index 37e3022..0000000 --- a/lib/libc/locale/islower.3 +++ /dev/null @@ -1,79 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)islower.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt ISLOWER 3 -.Os -.Sh NAME -.Nm islower -.Nd lower-case character test -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn islower "int c" -.Sh DESCRIPTION -The -.Fn islower -function tests for any lower-case letters. -For 8-bit wide locales the value of the argument is -representable as an unsigned char or the value of EOF. -In the ASCII character set, this includes the following characters -(with their numeric values shown in octal): -.Pp -.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ -.It \&141\ ``a'' \t142\ ``b'' \t143\ ``c'' \t144\ ``d'' \t145\ ``e'' -.It \&146\ ``f'' \t147\ ``g'' \t150\ ``h'' \t151\ ``i'' \t152\ ``j'' -.It \&153\ ``k'' \t154\ ``l'' \t155\ ``m'' \t156\ ``n'' \t157\ ``o'' -.It \&160\ ``p'' \t161\ ``q'' \t162\ ``r'' \t163\ ``s'' \t164\ ``t'' -.It \&165\ ``u'' \t166\ ``v'' \t167\ ``w'' \t170\ ``x'' \t171\ ``y'' -.It \&172\ ``z'' -.El -.Sh RETURN VALUES -The -.Fn islower -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr tolower 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn islower -function conforms to -.St -ansiC . diff --git a/lib/libc/locale/isprint.3 b/lib/libc/locale/isprint.3 deleted file mode 100644 index 6af2257..0000000 --- a/lib/libc/locale/isprint.3 +++ /dev/null @@ -1,91 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)isprint.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt ISPRINT 3 -.Os -.Sh NAME -.Nm isprint -.Nd printing character test (space character inclusive) -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn isprint "int c" -.Sh DESCRIPTION -The -.Fn isprint -function tests for any printing character including space (' '). -For 8-bit wide locales the value of the argument is -representable as an unsigned char or the value of EOF. -In the ASCII character set, this includes the following characters -(with their numeric values shown in octal): -.Pp -.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ -.It \&040\ sp \t041\ ``!'' \t042\ ``"'' \t043\ ``#'' \t044\ ``$'' -.It \&045\ ``%'' \t046\ ``&'' \t047\ ``''' \t050\ ``('' \t051\ ``)'' -.It \&052\ ``*'' \t053\ ``+'' \t054\ ``,'' \t055\ ``-'' \t056\ ``.'' -.It \&057\ ``/'' \t060\ ``0'' \t061\ ``1'' \t062\ ``2'' \t063\ ``3'' -.It \&064\ ``4'' \t065\ ``5'' \t066\ ``6'' \t067\ ``7'' \t070\ ``8'' -.It \&071\ ``9'' \t072\ ``:'' \t073\ ``;'' \t074\ ``<'' \t075\ ``='' -.It \&076\ ``>'' \t077\ ``?'' \t100\ ``@'' \t101\ ``A'' \t102\ ``B'' -.It \&103\ ``C'' \t104\ ``D'' \t105\ ``E'' \t106\ ``F'' \t107\ ``G'' -.It \&110\ ``H'' \t111\ ``I'' \t112\ ``J'' \t113\ ``K'' \t114\ ``L'' -.It \&115\ ``M'' \t116\ ``N'' \t117\ ``O'' \t120\ ``P'' \t121\ ``Q'' -.It \&122\ ``R'' \t123\ ``S'' \t124\ ``T'' \t125\ ``U'' \t126\ ``V'' -.It \&127\ ``W'' \t130\ ``X'' \t131\ ``Y'' \t132\ ``Z'' \t133\ ``['' -.It \&134\ ``\e\|'' \t135\ ``]'' \t136\ ``^'' \t137\ ``_'' \t140\ ```'' -.It \&141\ ``a'' \t142\ ``b'' \t143\ ``c'' \t144\ ``d'' \t145\ ``e'' -.It \&146\ ``f'' \t147\ ``g'' \t150\ ``h'' \t151\ ``i'' \t152\ ``j'' -.It \&153\ ``k'' \t154\ ``l'' \t155\ ``m'' \t156\ ``n'' \t157\ ``o'' -.It \&160\ ``p'' \t161\ ``q'' \t162\ ``r'' \t163\ ``s'' \t164\ ``t'' -.It \&165\ ``u'' \t166\ ``v'' \t167\ ``w'' \t170\ ``x'' \t171\ ``y'' -.It \&172\ ``z'' \t173\ ``{'' \t174\ ``|'' \t175\ ``}'' \t176\ ``~'' -.El -.Sh RETURN VALUES -The -.Fn isprint -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn isprint -function conforms to -.St -ansiC . diff --git a/lib/libc/locale/ispunct.3 b/lib/libc/locale/ispunct.3 deleted file mode 100644 index 5d8bf72..0000000 --- a/lib/libc/locale/ispunct.3 +++ /dev/null @@ -1,82 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)ispunct.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt ISPUNCT 3 -.Os -.Sh NAME -.Nm ispunct -.Nd punctuation character test -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn ispunct "int c" -.Sh DESCRIPTION -The -.Fn ispunct -function tests for any printing character except for space (' ') or a -character for which -.Xr isalnum 3 -is true. -For 8-bit wide locales the value of the argument is -representable as an unsigned char or the value of EOF. -In the ASCII character set, this includes the following characters -(with their numeric values shown in octal): -.Pp -.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ -.It \&041\ ``!'' \t042\ ``"'' \t043\ ``#'' \t044\ ``$'' \t045\ ``%'' -.It \&046\ ``&'' \t047\ ``''' \t050\ ``('' \t051\ ``)'' \t052\ ``*'' -.It \&053\ ``+'' \t054\ ``,'' \t055\ ``-'' \t056\ ``.'' \t057\ ``/'' -.It \&072\ ``:'' \t073\ ``;'' \t074\ ``<'' \t075\ ``='' \t076\ ``>'' -.It \&077\ ``?'' \t100\ ``@'' \t133\ ``['' \t134\ ``\e\|'' \t135\ ``]'' -.It \&136\ ``^'' \t137\ ``_'' \t140\ ```'' \t173\ ``{'' \t174\ ``|'' -.It \&175\ ``}'' \t176\ ``~'' -.El -.Sh RETURN VALUES -The -.Fn ispunct -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn ispunct -function conforms to -.St -ansiC . diff --git a/lib/libc/locale/isspace.3 b/lib/libc/locale/isspace.3 deleted file mode 100644 index d1e8795..0000000 --- a/lib/libc/locale/isspace.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)isspace.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt ISSPACE 3 -.Os -.Sh NAME -.Nm isspace -.Nd white-space character test -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn isspace "int c" -.Sh DESCRIPTION -The -.Fn isspace -function tests for the standard white-space characters. -For 8-bit wide locales the value of the argument is -representable as an unsigned char or the value of EOF. -In the ASCII character set, this includes the following characters -(with their numeric values shown in octal): -.Pp -.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ -.It \&011\ ht \t012\ nl \t013\ vt \t014\ np \t015\ cr -.It \&040\ sp -.El -.Sh RETURN VALUES -The -.Fn isspace -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn isspace -function conforms to -.St -ansiC . diff --git a/lib/libc/locale/isupper.3 b/lib/libc/locale/isupper.3 deleted file mode 100644 index b060345..0000000 --- a/lib/libc/locale/isupper.3 +++ /dev/null @@ -1,79 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)isupper.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt ISUPPER 3 -.Os -.Sh NAME -.Nm isupper -.Nd upper-case character test -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn isupper "int c" -.Sh DESCRIPTION -The -.Fn isupper -function tests for any upper-case letter. -For 8-bit wide locales the value of the argument is -representable as an unsigned char or the value of EOF. -In the ASCII character set, this includes the following characters -(with their numeric values shown in octal): -.Pp -.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ -.It \&101\ ``A'' \t102\ ``B'' \t103\ ``C'' \t104\ ``D'' \t105\ ``E'' -.It \&106\ ``F'' \t107\ ``G'' \t110\ ``H'' \t111\ ``I'' \t112\ ``J'' -.It \&113\ ``K'' \t114\ ``L'' \t115\ ``M'' \t116\ ``N'' \t117\ ``O'' -.It \&120\ ``P'' \t121\ ``Q'' \t122\ ``R'' \t123\ ``S'' \t124\ ``T'' -.It \&125\ ``U'' \t126\ ``V'' \t127\ ``W'' \t130\ ``X'' \t131\ ``Y'' -.It \&132\ ``Z'' -.El -.Sh RETURN VALUES -The -.Fn isupper -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr toupper 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn isupper -function conforms to -.St -ansiC . diff --git a/lib/libc/locale/isxdigit.3 b/lib/libc/locale/isxdigit.3 deleted file mode 100644 index fc0dae9..0000000 --- a/lib/libc/locale/isxdigit.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)isxdigit.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt ISXDIGIT 3 -.Os -.Sh NAME -.Nm isxdigit -.Nd hexadecimal-digit character test -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn isxdigit "int c" -.Sh DESCRIPTION -The -.Fn isxdigit -function tests for any hexadecimal-digit character. -For 8-bit wide locales the value of the argument is -representable as an unsigned char or the value of EOF. -In the ASCII character set, this includes the following characters -(with their numeric values shown in octal): -.Pp -.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ -.It \&060\ ``0'' \t061\ ``1'' \t062\ ``2'' \t063\ ``3'' \t064\ ``4'' -.It \&065\ ``5'' \t066\ ``6'' \t067\ ``7'' \t070\ ``8'' \t071\ ``9'' -.It \&101\ ``A'' \t102\ ``B'' \t103\ ``C'' \t104\ ``D'' \t105\ ``E'' -.It \&106\ ``F'' \t141\ ``a'' \t142\ ``b'' \t143\ ``c'' \t144\ ``d'' -.It \&145\ ``e'' \t146\ ``f'' -.El -.Sh RETURN VALUES -The -.Fn isxdigit -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn isxdigit -function conforms to -.St -ansiC . diff --git a/lib/libc/locale/lconv.c b/lib/libc/locale/lconv.c deleted file mode 100644 index f1212b0a..0000000 --- a/lib/libc/locale/lconv.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)lconv.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -static char empty[] = ""; - -/* - * Default (C) locale conversion. - */ -static struct lconv C_lconv = { - ".", /* decimal_point */ - empty, /* thousands_sep */ - empty, /* grouping */ - empty, /* int_curr_symbol */ - empty, /* currency_symbol */ - empty, /* mon_decimal_point */ - empty, /* mon_thousands_sep */ - empty, /* mon_grouping */ - empty, /* positive_sign */ - empty, /* negative_sign */ - CHAR_MAX, /* int_frac_digits */ - CHAR_MAX, /* frac_digits */ - CHAR_MAX, /* p_cs_precedes */ - CHAR_MAX, /* p_sep_by_space */ - CHAR_MAX, /* n_cs_precedes */ - CHAR_MAX, /* n_sep_by_space */ - CHAR_MAX, /* p_sign_posn */ - CHAR_MAX, /* n_sign_posn */ -}; - -/* - * Current locale conversion. - */ -struct lconv *__lconv = &C_lconv; diff --git a/lib/libc/locale/localeconv.c b/lib/libc/locale/localeconv.c deleted file mode 100644 index f3172af..0000000 --- a/lib/libc/locale/localeconv.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)localeconv.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -/* - * Return the current locale conversion. - */ -struct lconv * -localeconv() -{ - extern struct lconv *__lconv; - - return (__lconv); -} diff --git a/lib/libc/locale/mbrune.3 b/lib/libc/locale/mbrune.3 deleted file mode 100644 index 5c9d53b..0000000 --- a/lib/libc/locale/mbrune.3 +++ /dev/null @@ -1,158 +0,0 @@ -.\" Copyright (c) 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Paul Borman at Krystal Technologies. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)mbrune.3 8.2 (Berkeley) 4/19/94 -.\" $FreeBSD$ -.\" -.Dd April 19, 1994 -.Dt MBRUNE 3 -.Os -.Sh NAME -.Nm mbrune , -.Nm mbrrune , -.Nm mbmb -.Nd multibyte rune support for C -.Sh SYNOPSIS -.Fd #include -.Ft char * -.Fn mbrune "const char *string" "rune_t rune" -.Ft char * -.Fn mbrrune "const char *string" "rune_t rune" -.Ft char * -.Fn mbmb "const char *string" "char *pattern" -.Sh DESCRIPTION -These routines provide the corresponding functionality of -.Fn strchr , -.Fn strrchr -and -.Fn strstr -for multibyte strings. -.Pp -The -.Fn mbrune -function locates the first occurrence of -.Fn rune -in the string pointed to by -.Ar string . -The terminating -.Dv NUL -character is considered part of the string. -If -.Fa rune -is -.Ql \e0 , -.Fn mbrune -locates the terminating -.Ql \e0 . -.Pp -The -.Fn mbrrune -function -locates the last occurrence of -.Fa rune -in the string -.Fa string . -If -.Fa rune -is -.Ql \e0 , -.Fn mbrune -locates the terminating -.Ql \e0 . -.Pp -The -.Fn mbmb -function locates the first occurrence of the null-terminated string -.Fa pattern -in the null-terminated string -.Fa string. -If -.Fa pattern -is the empty string, -.Fn mbmb -returns -.Fa string ; -if -.Fa pattern -occurs nowhere in -.Fa string , -.Fn mbmb -returns -.Dv NULL ; -otherwise -.Fn mbmb -returns a pointer to the first character of the first occurrence of -.Fa pattern . -.Sh RETURN VALUES -The function -.Fn mbrune -returns a pointer to the located character, or -.Dv NULL -if the character does not appear in the string. -.Pp -The -.Fn mbrrune -function -returns a pointer to the character, or -.Dv NULL -if the character does not appear in the string. -.Pp -The -.Fn mbmb -function -returns a pointer to the -.Fa pattern , -or -.Dv NULL -if the -.Fa pattern -does not appear in the string. -.Sh "SEE ALSO -.Xr mbrune 3 , -.Xr rune 3 , -.Xr setlocale 3 , -.Xr euc 4 , -.Xr utf2 4 -.Sh HISTORY -The -.Fn mbrune , -.Fn mbrrune , -and -.Fn mbmb -functions -first appeared in Plan 9 from Bell Labs as -.Fn utfrune , -.Fn utfrrune , -and -.Fn utfutf . diff --git a/lib/libc/locale/mbrune.c b/lib/libc/locale/mbrune.c deleted file mode 100644 index 92efe83..0000000 --- a/lib/libc/locale/mbrune.c +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)mbrune.c 8.1 (Berkeley) 6/27/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -char * -mbrune(string, c) - const char *string; - rune_t c; -{ - char const *result; - rune_t r; - - while ((r = sgetrune(string, MB_LEN_MAX, &result))) { - if (r == c) - return ((char *)string); - string = result == string ? string + 1 : result; - } - - return (c == *string ? (char *)string : NULL); -} - -char * -mbrrune(string, c) - const char *string; - rune_t c; -{ - const char *last = 0; - char const *result; - rune_t r; - - while ((r = sgetrune(string, MB_LEN_MAX, &result))) { - if (r == c) - last = string; - string = result == string ? string + 1 : result; - } - return (c == *string ? (char *)string : (char *)last); -} - -char * -mbmb(string, pattern) - const char *string; - char *pattern; -{ - rune_t first, r; - size_t plen, slen; - char const *result; - - plen = strlen(pattern); - slen = strlen(string); - if (plen > slen) - return (0); - - first = sgetrune(pattern, plen, &result); - if (result == string) - return (0); - - while (slen >= plen && (r = sgetrune(string, slen, &result))) { - if (r == first) { - if (strncmp(string, pattern, slen) == 0) - return ((char *) string); - } - if (result == string) { - --slen; - ++string; - } else { - slen -= result - string; - string = result; - } - } - return (0); -} diff --git a/lib/libc/locale/mskanji.c b/lib/libc/locale/mskanji.c deleted file mode 100644 index bce27fe..0000000 --- a/lib/libc/locale/mskanji.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * ja_JP.SJIS locale table for BSD4.4/rune - * version 1.0 - * (C) Sin'ichiro MIYATANI / Phase One, Inc - * May 12, 1995 - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Phase One, Inc. - * 4. The name of Phase One, Inc. may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifdef XPG4 -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)mskanji.c 1.0 (Phase One) 5/5/95"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include -#include - -rune_t _MSKanji_sgetrune __P((const char *, size_t, char const **)); -int _MSKanji_sputrune __P((rune_t, char *, size_t, char **)); - -int -_MSKanji_init(rl) - _RuneLocale *rl; -{ - rl->sgetrune = _MSKanji_sgetrune; - rl->sputrune = _MSKanji_sputrune; - - _CurrentRuneLocale = rl; - __mb_cur_max = 2; - return (0); -} - -rune_t -_MSKanji_sgetrune(string, n, result) - const char *string; - size_t n; - char const **result; -{ - rune_t rune = 0; - - if (n < 1 ) { - rune = _INVALID_RUNE; - } else { - rune = *( string++ ) & 0xff; - if ( ( rune > 0x80 && rune < 0xa0 ) - || ( rune >= 0xe0 && rune < 0xfa ) ) { - if ( n < 2 ) { - rune = (rune_t)_INVALID_RUNE; - --string; - } else { - rune = ( rune << 8 ) | ( *( string++ ) & 0xff ); - } - } - } - if (result) *result = string; - return rune; -} - -int -_MSKanji_sputrune(c, string, n, result) - rune_t c; - char *string, **result; - size_t n; -{ - int len, i; - - len = ( c > 0x100 ) ? 2 : 1; - if ( n < len ) { - if ( result ) *result = (char *) 0; - } else { - if ( result ) *result = string + len; - for ( i = len; i-- > 0; ) { - *( string++ ) = c >> ( i << 3 ); - } - } - return len; -} -#endif /* XPG4 */ diff --git a/lib/libc/locale/multibyte.3 b/lib/libc/locale/multibyte.3 deleted file mode 100644 index fd0c19f..0000000 --- a/lib/libc/locale/multibyte.3 +++ /dev/null @@ -1,242 +0,0 @@ -.\" Copyright (c) 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Donn Seeley of BSDI. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)multibyte.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt MULTIBYTE 3 -.Os -.Sh NAME -.Nm mblen , -.Nm mbstowcs , -.Nm mbtowc , -.Nm wcstombs , -.Nm wctomb -.Nd multibyte character support for C -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn mblen "const char *mbchar" "size_t nbytes" -.Ft size_t -.Fn mbstowcs "wchar_t *wcstring" "const char *mbstring" "size_t nwchars" -.Ft int -.Fn mbtowc "wchar_t *wcharp" "const char *mbchar" "size_t nbytes" -.Ft size_t -.Fn wcstombs "char *mbstring" "const wchar_t *wcstring" "size_t nbytes" -.Ft int -.Fn wctomb "char *mbchar" "wchar_t wchar" -.Sh DESCRIPTION -The basic elements of some written natural languages such as Chinese -cannot be represented uniquely with single C -.Va char Ns s . -The C standard supports two different ways of dealing with -extended natural language encodings, -.Em wide -characters and -.Em multibyte -characters. -Wide characters are an internal representation -which allows each basic element to map -to a single object of type -.Va wchar_t . -Multibyte characters are used for input and output -and code each basic element as a sequence of C -.Va char Ns s . -Individual basic elements may map into one or more -.Pq up to Dv MB_CHAR_MAX -bytes in a multibyte character. -.Pp -The current locale -.Pq Xr setlocale 3 -governs the interpretation of wide and multibyte characters. -The locale category -.Dv LC_CTYPE -specifically controls this interpretation. -The -.Va wchar_t -type is wide enough to hold the largest value -in the wide character representations for all locales. -.Pp -Multibyte strings may contain -.Sq shift -indicators to switch to and from -particular modes within the given representation. -If explicit bytes are used to signal shifting, -these are not recognized as separate characters -but are lumped with a neighboring character. -There is always a distinguished -.Sq initial -shift state. -The -.Fn mbstowcs -and -.Fn wcstombs -functions assume that multibyte strings are interpreted -starting from the initial shift state. -The -.Fn mblen , -.Fn mbtowc -and -.Fn wctomb -functions maintain static shift state internally. -A call with a null -.Fa mbchar -pointer returns nonzero if the current locale requires shift states, -zero otherwise; -if shift states are required, the shift state is reset to the initial state. -The internal shift states are undefined after a call to -.Fn setlocale -with the -.Dv LC_CTYPE -or -.Dv LC_ALL -categories. -.Pp -For convenience in processing, -the wide character with value 0 -.Pq the null wide character -is recognized as the wide character string terminator, -and the character with value 0 -.Pq the null byte -is recognized as the multibyte character string terminator. -Null bytes are not permitted within multibyte characters. -.Pp -The -.Fn mblen -function computes the length in bytes -of a multibyte character -.Fa mbchar . -Up to -.Fa nbytes -bytes are examined. -.Pp -The -.Fn mbtowc -function converts a multibyte character -.Fa mbchar -into a wide character and stores the result -in the object pointed to by -.Fa wcharp. -Up to -.Fa nbytes -bytes are examined. -.Pp -The -.Fn wctomb -function converts a wide character -.Fa wchar -into a multibyte character and stores -the result in -.Fa mbchar . -The object pointed to by -.Fa mbchar -must be large enough to accommodate the multibyte character. -.Pp -The -.Fn mbstowcs -function converts a multibyte character string -.Fa mbstring -into a wide character string -.Fa wcstring . -No more than -.Fa nwchars -wide characters are stored. -A terminating null wide character is appended if there is room. -.Pp -The -.Fn wcstombs -function converts a wide character string -.Fa wcstring -into a multibyte character string -.Fa mbstring . -Up to -.Fa nbytes -bytes are stored in -.Fa mbstring . -Partial multibyte characters at the end of the string are not stored. -The multibyte character string is null terminated if there is room. -.Sh "RETURN VALUES -If multibyte characters are not supported in the current locale, -all of these functions will return \-1 if characters can be processed, -otherwise 0. -.Pp -If -.Fa mbchar -is -.Dv NULL , -the -.Fn mblen , -.Fn mbtowc -and -.Fn wctomb -functions return nonzero if shift states are supported, -zero otherwise. -If -.Fa mbchar -is valid, -then these functions return -the number of bytes processed in -.Fa mbchar , -or \-1 if no multibyte character -could be recognized or converted. -.Pp -The -.Fn mbstowcs -function returns the number of wide characters converted, -not counting any terminating null wide character. -The -.Fn wcstombs -function returns the number of bytes converted, -not counting any terminating null byte. -If any invalid multibyte characters are encountered, -both functions return \-1. -.Sh "SEE ALSO -.Xr mbrune 3 , -.Xr rune 3 , -.Xr setlocale 3 , -.Xr euc 4 , -.Xr utf2 4 -.Sh STANDARDS -The -.Fn mblen , -.Fn mbstowcs , -.Fn mbtowc , -.Fn wcstombs -and -.Fn wctomb -functions conform to -.St -ansiC . -.Sh BUGS -The current implementation does not support shift states. diff --git a/lib/libc/locale/nomacros.c b/lib/libc/locale/nomacros.c deleted file mode 100644 index 45c0db7..0000000 --- a/lib/libc/locale/nomacros.c +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Tell to generate extern versions of all its inline - * functions. The extern versions get called if the system doesn't - * support inlines or the user defines _DONT_USE_CTYPE_INLINE_ - * before including . - */ -#define _EXTERNALIZE_CTYPE_INLINES_ - -#include diff --git a/lib/libc/locale/none.c b/lib/libc/locale/none.c deleted file mode 100644 index 41f70ae..0000000 --- a/lib/libc/locale/none.c +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)none.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include - -rune_t _none_sgetrune __P((const char *, size_t, char const **)); -int _none_sputrune __P((rune_t, char *, size_t, char **)); - -int -_none_init(rl) - _RuneLocale *rl; -{ - rl->sgetrune = _none_sgetrune; - rl->sputrune = _none_sputrune; - _CurrentRuneLocale = rl; - __mb_cur_max = 1; - return(0); -} - -rune_t -_none_sgetrune(string, n, result) - const char *string; - size_t n; - char const **result; -{ - if (n < 1) { - if (result) - *result = string; - return(_INVALID_RUNE); - } - if (result) - *result = string + 1; - return(*string & 0xff); -} - -int -_none_sputrune(c, string, n, result) - rune_t c; - char *string, **result; - size_t n; -{ - if (n >= 1) { - if (string) - *string = c; - if (result) - *result = string + 1; - } else if (result) - *result = (char *)0; - return(1); -} diff --git a/lib/libc/locale/rune.3 b/lib/libc/locale/rune.3 deleted file mode 100644 index a479e33..0000000 --- a/lib/libc/locale/rune.3 +++ /dev/null @@ -1,272 +0,0 @@ -.\" Copyright (c) 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Paul Borman at Krystal Technologies. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)rune.3 8.2 (Berkeley) 12/11/93 -.\" $FreeBSD$ -.\" -.Dd December 11, 1993 -.Dt RUNE 3 -.Os -.Sh NAME -.Nm setrunelocale , -.Nm setinvalidrune , -.Nm sgetrune , -.Nm sputrune -.Nd rune support for C -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Ft int -.Fn setrunelocale "char *locale" -.Ft void -.Fn setinvalidrune "rune_t rune" -.Ft rune_t -.Fn sgetrune "const char *string" "size_t n" "char const **result" -.Ft int -.Fn sputrune "rune_t rune" "char *string" "size_t n" "char **result" -.Pp -.Fd #include -.Ft long -.Fn fgetrune "FILE *stream" -.Ft int -.Fn fungetrune "rune_t rune" "FILE *stream" -.Ft int -.Fn fputrune "rune_t rune" "FILE *stream" -.Sh DESCRIPTION -The -.Fn setrunelocale -controls the type of encoding used to represent runes as multibyte strings -as well as the properties of the runes as defined in -.Aq Pa ctype.h . -The -.Fa locale -argument indicates which locale to load. -If the locale is successfully loaded, -.Dv 0 -is returned, otherwise an errno value is returned to indicate the -type of error. -.Pp -The -.Fn setinvalidrune -function sets the value of the global value -.Ev _INVALID_RUNE -to be -.Fa rune . -.Pp -The -.Fn sgetrune -function tries to read a single multibyte character from -.Fa string , -which is at most -.Fa n -bytes long. -If -.Fn sgetrune -is successful, the rune is returned. -If -.Fa result -is not -.Dv NULL , -.Fa *result -will point to the first byte which was not converted in -.Fa string . -If the first -.Fa n -bytes of -.Fa string -do not describe a full multibyte character, -.Ev _INVALID_RUNE -is returned and -.Fa *result -will point to -.Fa string . -If there is an encoding error at the start of -.Fa string , -.Ev _INVALID_RUNE -is returned and -.Fa *result -will point to the second character of -.Fa string . -.Pp -the -.Fn sputrune -function tries to encode -.Fa rune -as a multibyte string and store it at -.Fa string , -but no more than -.Fa n -bytes will be stored. -If -.Fa result -is not -.Dv NULL , -.Fa *result -will be set to point to the first byte in string following the new -multibyte character. -If -.Fa string -is -.Dv NULL , -.Fa *result -will point to -.Dv "(char *)0 +" -.Fa x , -where -.Fa x -is the number of bytes that would be needed to store the multibyte value. -If the multibyte character would consist of more than -.Fa n -bytes and -.Fa result -is not -.Dv NULL , -.Fa *result -will be set to -.Dv NULL. -In all cases, -.Fn sputrune -will return the number of bytes which would be needed to store -.Fa rune -as a multibyte character. -.Pp -The -.Fn fgetrune -function operates the same as -.Fn sgetrune -with the exception that it attempts to read enough bytes from -.Fa stream -to decode a single rune. It returns either -.Ev EOF -on end of file, -.Ev _INVALID_RUNE -on an encoding error, or the rune decoded if all went well. -.Pp -The -.Fn fungetrune -function pushes the multibyte encoding, as provided by -.Fn sputrune , -of -.Fa rune -onto -.Fa stream -such that the next -.Fn fgetrune -call will return -.Fa rune . -It returns -.Ev EOF -if it fails and -.Dv 0 -on success. -.Pp -The -.Fn fputrune -function writes the multibyte encoding of -.Fa rune , -as provided by -.Fn sputrune , -onto -.Fa stream . -It returns -.Ev EOF -on failure and -.Dv 0 -on success. -.Sh RETURN VALUES -The -.Fn setrunelocale -function returns one of the following values: -.Bl -tag -width WWWWWWWW -.It Dv 0 -.Fn setrunelocale -was successful. -.It Ev EFAULT -.Fa locale -was -.Dv NULL . -.It Ev ENOENT -The locale could not be found. -.It Ev EFTYPE -The file found was not a valid file. -.It Ev EINVAL -The encoding indicated by the locale was unknown. -.El -.Pp -The -.Fn sgetrune -function either returns the rune read or -.Ev _INVALID_RUNE . -The -.Fn sputrune -function returns the number of bytes needed to store -.Fa rune -as a multibyte string. -.Sh FILES -.Bl -tag -width /usr/share/locale/locale/LC_CTYPE -compact -.It Pa $PATH_LOCALE/ Ns Em locale Ns /LC_CTYPE -.It Pa /usr/share/locale/ Ns Em locale Ns /LC_CTYPE -binary LC_CTYPE file for the locale -.Em locale . -.El -.Sh "SEE ALSO -.Xr mbrune 3 , -.Xr setlocale 3 , -.Xr euc 4 , -.Xr utf2 4 -.Sh NOTE -The ANSI C type -.Ev wchar_t -is the same as -.Ev rune_t . -.Ev Rune_t -was chosen to accent the purposeful choice of not basing the -system with the ANSI C -primitives, which were, shall we say, less aesthetic. -.Sh HISTORY -These functions first appeared in -.Bx 4.4 . -.Pp -The -.Fn setrunelocale -function and the other non-ANSI rune functions were inspired by -.Nm Plan 9 from Bell Labs -as a much more sane alternative to the ANSI multibyte and -wide character support. -.\"They were conceived at the San Diego 1993 Summer USENIX conference by -.\"Paul Borman of Krystal Technologies, Keith Bostic of CSRG and Andrew Hume -.\"of Bell Labs. -.Pp -All of the ANSI multibyte and wide character -support functions are built using the rune functions. diff --git a/lib/libc/locale/rune.c b/lib/libc/locale/rune.c deleted file mode 100644 index bc4d07c..0000000 --- a/lib/libc/locale/rune.c +++ /dev/null @@ -1,173 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)rune.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include - -_RuneLocale * -_Read_RuneMagi(fp) - FILE *fp; -{ - char *data; - void *lastp; - _RuneLocale *rl; - _RuneEntry *rr; - struct stat sb; - int x; - - if (fstat(fileno(fp), &sb) < 0) - return(0); - - if (sb.st_size < sizeof(_RuneLocale)) - return(0); - - if ((data = malloc(sb.st_size)) == NULL) - return(0); - - rewind(fp); /* Someone might have read the magic number once already */ - - if (fread(data, sb.st_size, 1, fp) != 1) { - free(data); - return(0); - } - - rl = (_RuneLocale *)data; - lastp = data + sb.st_size; - - rl->variable = rl + 1; - - if (memcmp(rl->magic, _RUNE_MAGIC_1, sizeof(rl->magic))) { - free(data); - return(0); - } - - rl->invalid_rune = ntohl(rl->invalid_rune); - rl->variable_len = ntohl(rl->variable_len); - rl->runetype_ext.nranges = ntohl(rl->runetype_ext.nranges); - rl->maplower_ext.nranges = ntohl(rl->maplower_ext.nranges); - rl->mapupper_ext.nranges = ntohl(rl->mapupper_ext.nranges); - - for (x = 0; x < _CACHED_RUNES; ++x) { - rl->runetype[x] = ntohl(rl->runetype[x]); - rl->maplower[x] = ntohl(rl->maplower[x]); - rl->mapupper[x] = ntohl(rl->mapupper[x]); - } - - rl->runetype_ext.ranges = (_RuneEntry *)rl->variable; - rl->variable = rl->runetype_ext.ranges + rl->runetype_ext.nranges; - if (rl->variable > lastp) { - free(data); - return(0); - } - - rl->maplower_ext.ranges = (_RuneEntry *)rl->variable; - rl->variable = rl->maplower_ext.ranges + rl->maplower_ext.nranges; - if (rl->variable > lastp) { - free(data); - return(0); - } - - rl->mapupper_ext.ranges = (_RuneEntry *)rl->variable; - rl->variable = rl->mapupper_ext.ranges + rl->mapupper_ext.nranges; - if (rl->variable > lastp) { - free(data); - return(0); - } - - for (x = 0; x < rl->runetype_ext.nranges; ++x) { - rr = rl->runetype_ext.ranges; - - rr[x].min = ntohl(rr[x].min); - rr[x].max = ntohl(rr[x].max); - if ((rr[x].map = ntohl(rr[x].map)) == 0) { - int len = rr[x].max - rr[x].min + 1; - rr[x].types = rl->variable; - rl->variable = rr[x].types + len; - if (rl->variable > lastp) { - free(data); - return(0); - } - while (len-- > 0) - rr[x].types[len] = ntohl(rr[x].types[len]); - } else - rr[x].types = 0; - } - - for (x = 0; x < rl->maplower_ext.nranges; ++x) { - rr = rl->maplower_ext.ranges; - - rr[x].min = ntohl(rr[x].min); - rr[x].max = ntohl(rr[x].max); - rr[x].map = ntohl(rr[x].map); - } - - for (x = 0; x < rl->mapupper_ext.nranges; ++x) { - rr = rl->mapupper_ext.ranges; - - rr[x].min = ntohl(rr[x].min); - rr[x].max = ntohl(rr[x].max); - rr[x].map = ntohl(rr[x].map); - } - if (((char *)rl->variable) + rl->variable_len > (char *)lastp) { - free(data); - return(0); - } - - /* - * Go out and zero pointers that should be zero. - */ - if (!rl->variable_len) - rl->variable = 0; - - if (!rl->runetype_ext.nranges) - rl->runetype_ext.ranges = 0; - - if (!rl->maplower_ext.nranges) - rl->maplower_ext.ranges = 0; - - if (!rl->mapupper_ext.nranges) - rl->mapupper_ext.ranges = 0; - - return(rl); -} diff --git a/lib/libc/locale/runetype.c b/lib/libc/locale/runetype.c deleted file mode 100644 index 282f806..0000000 --- a/lib/libc/locale/runetype.c +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 -#include - -unsigned long -___runetype(c) - _BSD_CT_RUNE_T_ c; -{ -#ifdef XPG4 - int x; - _RuneRange *rr = &_CurrentRuneLocale->runetype_ext; - _RuneEntry *re = rr->ranges; - - if (c < 0 || c == EOF) - return(0L); - - for (x = 0; x < rr->nranges; ++x, ++re) { - if (c < re->min) - return(0L); - if (c <= re->max) { - if (re->types) - return(re->types[c - re->min]); - else - return(re->map); - } - } -#endif - return(0L); -} diff --git a/lib/libc/locale/setinvalidrune.c b/lib/libc/locale/setinvalidrune.c deleted file mode 100644 index 45a2a47..0000000 --- a/lib/libc/locale/setinvalidrune.c +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 - -void -setinvalidrune(ir) - rune_t ir; -{ - _INVALID_RUNE = ir; -} diff --git a/lib/libc/locale/setlocale.3 b/lib/libc/locale/setlocale.3 deleted file mode 100644 index 4750034..0000000 --- a/lib/libc/locale/setlocale.3 +++ /dev/null @@ -1,336 +0,0 @@ -.\" Copyright (c) 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Donn Seeley at BSDI. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)setlocale.3 8.1 (Berkeley) 6/9/93 -.\" $FreeBSD$ -.\" -.Dd June 9, 1993 -.Dt SETLOCALE 3 -.Os -.Sh NAME -.Nm setlocale , -.Nm localeconv -.Nd natural language formatting for C -.Sh SYNOPSIS -.Fd #include -.Ft char * -.Fn setlocale "int category" "const char *locale" -.Ft struct lconv * -.Fn localeconv "void" -.Sh DESCRIPTION -The -.Fn setlocale -function sets the C library's notion -of natural language formatting style -for particular sets of routines. -Each such style is called a -.Sq locale -and is invoked using an appropriate name passed as a C string. -The -.Fn localeconv -routine returns the current locale's parameters -for formatting numbers. -.Pp -The -.Fn setlocale -function recognizes several categories of routines. -These are the categories and the sets of routines they select: -.Pp -.Bl -tag -width LC_MONETARY -.It Dv LC_ALL -Set the entire locale generically. -.It Dv LC_COLLATE -Set a locale for string collation routines. -This controls alphabetic ordering in -.Fn strcoll -and -.Fn strxfrm . -.It Dv LC_CTYPE -Set a locale for the -.Xr ctype 3 , -.Xr mbrune 3 , -.Xr multibyte 3 -and -.Xr rune 3 -functions. -This controls recognition of upper and lower case, -alphabetic or non-alphabetic characters, -and so on. The real work is done by the -.Fn setrunelocale -function. -.It Dv LC_MESSAGES -Set a locale for message catalogs, see -.Xr catopen 3 -function. -.It Dv LC_MONETARY -Set a locale for formatting monetary values; -this affects the -.Fn localeconv -function. -.It Dv LC_NUMERIC -Set a locale for formatting numbers. -This controls the formatting of decimal points -in input and output of floating point numbers -in functions such as -.Fn printf -and -.Fn scanf , -as well as values returned by -.Fn localeconv . -.It Dv LC_TIME -Set a locale for formatting dates and times using the -.Fn strftime -function. -.El -.Pp -Only three locales are defined by default, -the empty string -.Li "\&""\|"" -which denotes the native environment, and the -.Li "\&""C"" -and -.Li "\&""POSIX"" -locales, which denote the C language environment. -A -.Fa locale -argument of -.Dv NULL -causes -.Fn setlocale -to return the current locale. -By default, C programs start in the -.Li "\&""C"" -locale. -The only function in the library that sets the locale is -.Fn setlocale ; -the locale is never changed as a side effect of some other routine. -.Pp -The -.Fn localeconv -function returns a pointer to a structure -which provides parameters for formatting numbers, -especially currency values: -.Bd -literal -offset indent -struct lconv { - char *decimal_point; - char *thousands_sep; - char *grouping; - char *int_curr_symbol; - char *currency_symbol; - char *mon_decimal_point; - char *mon_thousands_sep; - char *mon_grouping; - char *positive_sign; - char *negative_sign; - char int_frac_digits; - char frac_digits; - char p_cs_precedes; - char p_sep_by_space; - char n_cs_precedes; - char n_sep_by_space; - char p_sign_posn; - char n_sign_posn; -}; -.Ed -.Pp -The individual fields have the following meanings: -.Pp -.Bl -tag -width mon_decimal_point -.It Fa decimal_point -The decimal point character, except for currency values. -.It Fa thousands_sep -The separator between groups of digits -before the decimal point, except for currency values. -.It Fa grouping -The sizes of the groups of digits, except for currency values. -This is a pointer to a vector of integers, each of size -.Va char , -representing group size from low order digit groups -to high order (right to left). -The list may be terminated with 0 or -.Dv CHAR_MAX . -If the list is terminated with 0, -the last group size before the 0 is repeated to account for all the digits. -If the list is terminated with -.Dv CHAR_MAX , -no more grouping is performed. -.It Fa int_curr_symbol -The standardized international currency symbol. -.It Fa currency_symbol -The local currency symbol. -.It Fa mon_decimal_point -The decimal point character for currency values. -.It Fa mon_thousands_sep -The separator for digit groups in currency values. -.It Fa mon_grouping -Like -.Fa grouping -but for currency values. -.It Fa positive_sign -The character used to denote nonnegative currency values, -usually the empty string. -.It Fa negative_sign -The character used to denote negative currency values, -usually a minus sign. -.It Fa int_frac_digits -The number of digits after the decimal point -in an international-style currency value. -.It Fa frac_digits -The number of digits after the decimal point -in the local style for currency values. -.It Fa p_cs_precedes -1 if the currency symbol precedes the currency value -for nonnegative values, 0 if it follows. -.It Fa p_sep_by_space -1 if a space is inserted between the currency symbol -and the currency value for nonnegative values, 0 otherwise. -.It Fa n_cs_precedes -Like -.Fa p_cs_precedes -but for negative values. -.It Fa n_sep_by_space -Like -.Fa p_sep_by_space -but for negative values. -.It Fa p_sign_posn -The location of the -.Fa positive_sign -with respect to a nonnegative quantity and the -.Fa currency_symbol , -coded as follows: -.Bl -tag -width 3n -compact -.It Li 0 -Parentheses around the entire string. -.It Li 1 -Before the string. -.It Li 2 -After the string. -.It Li 3 -Just before -.Fa currency_symbol . -.It Li 4 -Just after -.Fa currency_symbol . -.El -.It Fa n_sign_posn -Like -.Fa p_sign_posn -but for negative currency values. -.El -.Pp -Unless mentioned above, -an empty string as a value for a field -indicates a zero length result or -a value that is not in the current locale. -A -.Dv CHAR_MAX -result similarly denotes an unavailable value. -.Sh "RETURN VALUES -The -.Fn setlocale -function returns -.Dv NULL -and fails to change the locale -if the given combination of -.Fa category -and -.Fa locale -makes no sense. -The -.Fn localeconv -function returns a pointer to a static object -which may be altered by later calls to -.Fn setlocale -or -.Fn localeconv . -.Sh FILES -.Bl -tag -width /usr/share/locale/locale/category -compact -.It Pa $PATH_LOCALE/ Ns Em locale/category -.It Pa /usr/share/locale/ Ns Em locale/category -locale file for the locale -.Em locale -and the category -.Em category . -.El -.Sh "SEE ALSO -.Xr colldef 1 , -.Xr mklocale 1 , -.Xr catopen 3 , -.Xr ctype 3 , -.Xr mbrune 3 , -.Xr multibyte 3 , -.Xr rune 3 , -.Xr strcoll 3 , -.Xr strxfrm 3 , -.Xr euc 4 , -.Xr utf2 4 -.Sh STANDARDS -The -.Fn setlocale -and -.Fn localeconv -functions conform to -.St -ansiC . -.Sh HISTORY -The -.Fn setlocale -and -.Fn localeconv -functions first appeared in -.Bx 4.4 . -.Sh BUGS -The current implementation supports only the -.Li "\&""C"" -and -.Li "\&""POSIX"" -locales for all but the -.Dv LC_COLLATE , -.Dv LC_CTYPE , -and -.Dv LC_TIME -categories. -.Pp -In spite of the gnarly currency support in -.Fn localeconv , -the standards don't include any functions -for generalized currency formatting. -.Pp -Use of -.Dv LC_MONETARY -could lead to misleading results until we have a real time currency -conversion function. -.Dv LC_NUMERIC -and -.Dv LC_TIME -are personal choices and should not be wrapped up with the other categories. diff --git a/lib/libc/locale/setlocale.c b/lib/libc/locale/setlocale.c deleted file mode 100644 index 179be54..0000000 --- a/lib/libc/locale/setlocale.c +++ /dev/null @@ -1,321 +0,0 @@ -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifdef LIBC_RCS -static const char rcsid[] = - "$FreeBSD$"; -#endif - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)setlocale.c 8.1 (Berkeley) 7/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "collate.h" -#include "setlocale.h" - -/* - * Category names for getenv() - */ -static char *categories[_LC_LAST] = { - "LC_ALL", - "LC_COLLATE", - "LC_CTYPE", - "LC_MONETARY", - "LC_NUMERIC", - "LC_TIME", - "LC_MESSAGES", -}; - -/* - * Current locales for each category - */ -static char current_categories[_LC_LAST][ENCODING_LEN + 1] = { - "C", - "C", - "C", - "C", - "C", - "C", - "C", -}; - -/* - * The locales we are going to try and load - */ -static char new_categories[_LC_LAST][ENCODING_LEN + 1]; -static char saved_categories[_LC_LAST][ENCODING_LEN + 1]; - -static char current_locale_string[_LC_LAST * (ENCODING_LEN + 1/*"/"*/ + 1)]; - -static char *currentlocale __P((void)); -static char *loadlocale __P((int)); -static int stub_load_locale __P((const char *)); - -extern int __time_load_locale __P((const char *)); /* strftime.c */ - -#ifdef XPG4 -extern int _xpg4_setrunelocale __P((char *)); -#endif - -char * -setlocale(category, locale) - int category; - const char *locale; -{ - int i, j, len; - char *env, *r; - - if (category < LC_ALL || category >= _LC_LAST) - return (NULL); - - if (!locale) - return (category != LC_ALL ? - current_categories[category] : currentlocale()); - - /* - * Default to the current locale for everything. - */ - for (i = 1; i < _LC_LAST; ++i) - (void)strcpy(new_categories[i], current_categories[i]); - - /* - * Now go fill up new_categories from the locale argument - */ - if (!*locale) { - env = getenv(categories[category]); - - if (category != LC_ALL && (!env || !*env)) - env = getenv(categories[LC_ALL]); - - if (!env || !*env) - env = getenv("LANG"); - - if (!env || !*env) - env = "C"; - - (void) strncpy(new_categories[category], env, ENCODING_LEN); - new_categories[category][ENCODING_LEN] = '\0'; - if (category == LC_ALL) { - for (i = 1; i < _LC_LAST; ++i) { - if (!(env = getenv(categories[i])) || !*env) - env = new_categories[LC_ALL]; - (void)strncpy(new_categories[i], env, ENCODING_LEN); - new_categories[i][ENCODING_LEN] = '\0'; - } - } - } else if (category != LC_ALL) { - (void)strncpy(new_categories[category], locale, ENCODING_LEN); - new_categories[category][ENCODING_LEN] = '\0'; - } else { - if ((r = strchr(locale, '/')) == NULL) { - for (i = 1; i < _LC_LAST; ++i) { - (void)strncpy(new_categories[i], locale, ENCODING_LEN); - new_categories[i][ENCODING_LEN] = '\0'; - } - } else { - for (i = 1; r[1] == '/'; ++r); - if (!r[1]) - return (NULL); /* Hmm, just slashes... */ - do { - len = r - locale > ENCODING_LEN ? ENCODING_LEN : r - locale; - (void)strncpy(new_categories[i], locale, len); - new_categories[i][len] = '\0'; - i++; - locale = r; - while (*locale == '/') - ++locale; - while (*++r && *r != '/'); - } while (*locale); - while (i < _LC_LAST) { - (void)strcpy(new_categories[i], - new_categories[i-1]); - i++; - } - } - } - - if (category) - return (loadlocale(category)); - - for (i = 1; i < _LC_LAST; ++i) { - (void)strcpy(saved_categories[i], current_categories[i]); - if (loadlocale(i) == NULL) { - for (j = 1; j < i; j++) { - (void)strcpy(new_categories[j], - saved_categories[j]); - /* XXX can fail too */ - (void)loadlocale(j); - } - return (NULL); - } - } - return (currentlocale()); -} - -static char * -currentlocale() -{ - int i; - - (void)strcpy(current_locale_string, current_categories[1]); - - for (i = 2; i < _LC_LAST; ++i) - if (strcmp(current_categories[1], current_categories[i])) { - for (i = 2; i < _LC_LAST; ++i) { - (void) strcat(current_locale_string, "/"); - (void) strcat(current_locale_string, current_categories[i]); - } - break; - } - return (current_locale_string); -} - -static char * -loadlocale(category) - int category; -{ - char *ret; - char *new = new_categories[category]; - char *old = current_categories[category]; - - if (_PathLocale == NULL) { - char *p = getenv("PATH_LOCALE"); - - if (p != NULL -#ifndef __NETBSD_SYSCALLS - && !issetugid() -#endif - ) { - if (strlen(p) + 1/*"/"*/ + ENCODING_LEN + - 1/*"/"*/ + CATEGORY_LEN >= PATH_MAX) - return (NULL); - _PathLocale = strdup(p); - if (_PathLocale == NULL) - return (NULL); - } else - _PathLocale = _PATH_LOCALE; - } - - if (strcmp(new, old) == 0) - return (old); - - if (category == LC_CTYPE) { -#ifdef XPG4 - ret = _xpg4_setrunelocale(new) ? NULL : new; -#else - ret = setrunelocale(new) ? NULL : new; -#endif - if (!ret) { -#ifdef XPG4 - (void)_xpg4_setrunelocale(old); -#else - (void)setrunelocale(old); -#endif - } else - (void)strcpy(old, new); - return (ret); - } - - if (category == LC_COLLATE) { - ret = (__collate_load_tables(new) < 0) ? NULL : new; - if (!ret) - (void)__collate_load_tables(old); - else - (void)strcpy(old, new); - return (ret); - } - - if (category == LC_TIME) { - ret = (__time_load_locale(new) < 0) ? NULL : new; - if (!ret) - (void)__time_load_locale(old); - else - (void)strcpy(old, new); - return (ret); - } - - if (category == LC_MONETARY || - category == LC_MESSAGES || - category == LC_NUMERIC) { - ret = stub_load_locale(new) ? NULL : new; - if (!ret) - (void)stub_load_locale(old); - else - (void)strcpy(old, new); - return (ret); - } - - /* Just in case...*/ - return (NULL); -} - -static int -stub_load_locale(encoding) -const char *encoding; -{ - char name[PATH_MAX]; - struct stat st; - - if (!encoding) - return(1); - /* - * The "C" and "POSIX" locale are always here. - */ - if (!strcmp(encoding, "C") || !strcmp(encoding, "POSIX")) - return(0); - if (!_PathLocale) - return(1); - /* Range checking not needed, encoding has fixed size */ - strcpy(name, _PathLocale); - strcat(name, "/"); - strcat(name, encoding); -#if 0 - /* - * Some day we will actually look at this file. - */ -#endif - return (stat(name, &st) != 0 || !S_ISDIR(st.st_mode)); -} diff --git a/lib/libc/locale/setlocale.h b/lib/libc/locale/setlocale.h deleted file mode 100644 index f3b2a22..0000000 --- a/lib/libc/locale/setlocale.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef _SETLOCALE_H -#define _SETLOCALE_H -/* - * Copyright (C) 1997 by Andrey A. Chernov, Moscow, Russia. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#define ENCODING_LEN 31 -#define CATEGORY_LEN 11 - -extern char *_PathLocale; - -#endif /* SETLOCALE_H */ diff --git a/lib/libc/locale/setrunelocale.c b/lib/libc/locale/setrunelocale.c deleted file mode 100644 index 8cfddab..0000000 --- a/lib/libc/locale/setrunelocale.c +++ /dev/null @@ -1,140 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 -#include -#include -#include -#include -#include -#include -#include "setlocale.h" - -extern int _none_init __P((_RuneLocale *)); -#ifdef XPG4 -extern int _UTF2_init __P((_RuneLocale *)); -extern int _EUC_init __P((_RuneLocale *)); -extern int _BIG5_init __P((_RuneLocale *)); -extern int _MSKanji_init __P((_RuneLocale *)); -extern int _xpg4_setrunelocale __P((char *)); -#endif -extern _RuneLocale *_Read_RuneMagi __P((FILE *)); - -#ifdef XPG4 -int -setrunelocale(encoding) - char *encoding; -{ - return _xpg4_setrunelocale(encoding); -} -#endif - -int -#ifndef XPG4 -setrunelocale(encoding) -#else -_xpg4_setrunelocale(encoding) -#endif - char *encoding; -{ - FILE *fp; - char name[PATH_MAX]; - _RuneLocale *rl; - - if (!encoding || strlen(encoding) > ENCODING_LEN) - return(EFAULT); - - /* - * The "C" and "POSIX" locale are always here. - */ - if (!strcmp(encoding, "C") || !strcmp(encoding, "POSIX")) { - _CurrentRuneLocale = &_DefaultRuneLocale; - return(0); - } - - if (_PathLocale == NULL) { - char *p = getenv("PATH_LOCALE"); - - if (p != NULL -#ifndef __NETBSD_SYSCALLS - && !issetugid() -#endif - ) { - if (strlen(p) + 1/*"/"*/ + ENCODING_LEN + - 1/*"/"*/ + CATEGORY_LEN >= PATH_MAX) - return(EFAULT); - _PathLocale = strdup(p); - if (_PathLocale == NULL) - return (errno); - } else - _PathLocale = _PATH_LOCALE; - } - /* Range checking not needed, encoding length already checked above */ - (void) strcpy(name, _PathLocale); - (void) strcat(name, "/"); - (void) strcat(name, encoding); - (void) strcat(name, "/LC_CTYPE"); - - if ((fp = fopen(name, "r")) == NULL) - return(ENOENT); - - if ((rl = _Read_RuneMagi(fp)) == 0) { - fclose(fp); - return(EFTYPE); - } - fclose(fp); - -#ifdef XPG4 - if (!rl->encoding[0] || !strcmp(rl->encoding, "UTF2")) - return(_UTF2_init(rl)); -#else - if (!rl->encoding[0]) - return(EINVAL); -#endif - else if (!strcmp(rl->encoding, "NONE")) - return(_none_init(rl)); -#ifdef XPG4 - else if (!strcmp(rl->encoding, "EUC")) - return(_EUC_init(rl)); - else if (!strcmp(rl->encoding, "BIG5")) - return(_BIG5_init(rl)); - else if (!strcmp(rl->encoding, "MSKanji")) - return(_MSKanji_init(rl)); -#endif - else - return(EINVAL); -} - diff --git a/lib/libc/locale/table.c b/lib/libc/locale/table.c deleted file mode 100644 index 2fe979c..0000000 --- a/lib/libc/locale/table.c +++ /dev/null @@ -1,258 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 6/27/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -extern rune_t _none_sgetrune __P((const char *, size_t, char const **)); -extern int _none_sputrune __P((rune_t, char *, size_t, char **)); -extern int _none_init __P((char *, char **)); - -_RuneLocale _DefaultRuneLocale = { - _RUNE_MAGIC_1, - "none", - _none_sgetrune, - _none_sputrune, - 0xFFFD, - - { /*00*/ _CTYPE_C, - _CTYPE_C, - _CTYPE_C, - _CTYPE_C, - _CTYPE_C, - _CTYPE_C, - _CTYPE_C, - _CTYPE_C, - /*08*/ _CTYPE_C, - _CTYPE_C|_CTYPE_S|_CTYPE_B, - _CTYPE_C|_CTYPE_S, - _CTYPE_C|_CTYPE_S, - _CTYPE_C|_CTYPE_S, - _CTYPE_C|_CTYPE_S, - _CTYPE_C, - _CTYPE_C, - /*10*/ _CTYPE_C, - _CTYPE_C, - _CTYPE_C, - _CTYPE_C, - _CTYPE_C, - _CTYPE_C, - _CTYPE_C, - _CTYPE_C, - /*18*/ _CTYPE_C, - _CTYPE_C, - _CTYPE_C, - _CTYPE_C, - _CTYPE_C, - _CTYPE_C, - _CTYPE_C, - _CTYPE_C, - /*20*/ _CTYPE_S|_CTYPE_B|_CTYPE_R, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - /*28*/ _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - /*30*/ _CTYPE_D|_CTYPE_R|_CTYPE_G|_CTYPE_X|0, - _CTYPE_D|_CTYPE_R|_CTYPE_G|_CTYPE_X|1, - _CTYPE_D|_CTYPE_R|_CTYPE_G|_CTYPE_X|2, - _CTYPE_D|_CTYPE_R|_CTYPE_G|_CTYPE_X|3, - _CTYPE_D|_CTYPE_R|_CTYPE_G|_CTYPE_X|4, - _CTYPE_D|_CTYPE_R|_CTYPE_G|_CTYPE_X|5, - _CTYPE_D|_CTYPE_R|_CTYPE_G|_CTYPE_X|6, - _CTYPE_D|_CTYPE_R|_CTYPE_G|_CTYPE_X|7, - /*38*/ _CTYPE_D|_CTYPE_R|_CTYPE_G|_CTYPE_X|8, - _CTYPE_D|_CTYPE_R|_CTYPE_G|_CTYPE_X|9, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - /*40*/ _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_U|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|10, - _CTYPE_U|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|11, - _CTYPE_U|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|12, - _CTYPE_U|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|13, - _CTYPE_U|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|14, - _CTYPE_U|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|15, - _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, - /*48*/ _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, - /*50*/ _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, - /*58*/ _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - /*60*/ _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_L|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|10, - _CTYPE_L|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|11, - _CTYPE_L|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|12, - _CTYPE_L|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|13, - _CTYPE_L|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|14, - _CTYPE_L|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|15, - _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, - /*68*/ _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, - /*70*/ _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, - /*78*/ _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_P|_CTYPE_R|_CTYPE_G, - _CTYPE_C, - }, - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 'a', 'b', 'c', 'd', 'e', 'f', 'g', - 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', - 'x', 'y', 'z', 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 'a', 'b', 'c', 'd', 'e', 'f', 'g', - 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', - 'x', 'y', 'z', 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, - 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, - 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, - 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, - }, - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 'A', 'B', 'C', 'D', 'E', 'F', 'G', - 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', - 'X', 'Y', 'Z', 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 'A', 'B', 'C', 'D', 'E', 'F', 'G', - 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', - 'X', 'Y', 'Z', 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, - 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, - 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, - 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, - }, -}; - -_RuneLocale *_CurrentRuneLocale = &_DefaultRuneLocale; - -int __mb_cur_max = 1; - -char *_PathLocale; diff --git a/lib/libc/locale/toascii.3 b/lib/libc/locale/toascii.3 deleted file mode 100644 index 6fc26f97..0000000 --- a/lib/libc/locale/toascii.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" Copyright (c) 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. -.\" -.\" @(#)toascii.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt TOASCII 3 -.Os -.Sh NAME -.Nm toascii -.Nd convert a byte to 7-bit ASCII -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn toascii "int c" -.Sh DESCRIPTION -The -.Fn toascii -function strips all but the low 7 bits from a letter, -including parity or other marker bits. -.Sh RETURN VALUES -The -.Fn toascii -function always returns a valid ASCII character. -.Sh SEE ALSO -.Xr isalnum 3 , -.Xr isalpha 3 , -.Xr isascii 3 , -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr isgraph 3 , -.Xr islower 3 , -.Xr isprint 3 , -.Xr ispunct 3 , -.Xr isspace 3 , -.Xr isupper 3 , -.Xr isxdigit 3 , -.Xr stdio 3 , -.Xr tolower 3 , -.Xr toupper 3 , -.Xr ascii 7 diff --git a/lib/libc/locale/tolower.3 b/lib/libc/locale/tolower.3 deleted file mode 100644 index dfb7c25..0000000 --- a/lib/libc/locale/tolower.3 +++ /dev/null @@ -1,91 +0,0 @@ -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)tolower.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt TOLOWER 3 -.Os -.Sh NAME -.Nm tolower -.Nd upper case to lower case letter conversion -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn tolower "int c" -.Sh DESCRIPTION -The -.Fn tolower -function converts an upper-case letter to the corresponding lower-case -letter. -For 8-bit wide locales the value of the argument is -representable as an unsigned char or the value of EOF. -.Sh RETURN VALUES -If the argument is an upper-case letter, the -.Fn tolower -function returns the corresponding lower-case letter if there is -one; otherwise the argument is returned unchanged. -.\" In the -.\" .Em ``C'' -.\" locale, -.\" .Fn tolower -.\" maps only the characters for which -.\" .Xr isupper -.\" is true to the corresponding characters for which -.\" .Xr islower -.\" is true. -.Sh SEE ALSO -.Xr isalnum 3 , -.Xr isalpha 3 , -.Xr isascii 3 , -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr isgraph 3 , -.Xr islower 3 , -.Xr isprint 3 , -.Xr ispunct 3 , -.Xr isspace 3 , -.Xr isupper 3 , -.Xr isxdigit 3 , -.Xr stdio 3 , -.Xr toascii 3 , -.Xr toupper 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn tolower -function conforms to -.St -ansiC . diff --git a/lib/libc/locale/tolower.c b/lib/libc/locale/tolower.c deleted file mode 100644 index 65d5175..0000000 --- a/lib/libc/locale/tolower.c +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 -#include - -_BSD_CT_RUNE_T_ -___tolower(c) - _BSD_CT_RUNE_T_ c; -{ -#ifdef XPG4 - int x; - _RuneRange *rr = &_CurrentRuneLocale->maplower_ext; - _RuneEntry *re = rr->ranges; - - if (c < 0 || c == EOF) - return(c); - - for (x = 0; x < rr->nranges; ++x, ++re) { - if (c < re->min) - return(c); - if (c <= re->max) - return(re->map + c - re->min); - } -#endif - return(c); -} diff --git a/lib/libc/locale/toupper.3 b/lib/libc/locale/toupper.3 deleted file mode 100644 index 28bc027..0000000 --- a/lib/libc/locale/toupper.3 +++ /dev/null @@ -1,91 +0,0 @@ -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)toupper.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt TOUPPER 3 -.Os -.Sh NAME -.Nm toupper -.Nd lower case to upper case letter conversion -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn toupper "int c" -.Sh DESCRIPTION -The -.Fn toupper -function converts a lower-case letter to the corresponding -upper-case letter. -For 8-bit wide locales the value of the argument is -representable as an unsigned char or the value of EOF. -.SH RETURN VALUES -If the argument is a lower-case letter, the -.Fn toupper -function returns the corresponding upper-case letter if there is -one; otherwise the argument is returned unchanged. -.\" In the -.\" .Em ``C'' -.\" locale, -.\" .Fn toupper -.\" maps only the characters for which -.\" .Xr islower -.\" is true to the corresponding characters for which -.\" .Xr isupper -.\" is true. -.Sh SEE ALSO -.Xr isalnum 3 , -.Xr isalpha 3 , -.Xr isascii 3 , -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr isgraph 3 , -.Xr islower 3 , -.Xr isprint 3 , -.Xr ispunct 3 , -.Xr isspace 3 , -.Xr isupper 3 , -.Xr isxdigit 3 , -.Xr stdio 3 , -.Xr toascii 3 , -.Xr tolower 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn toupper -function conforms to -.St -ansiC . diff --git a/lib/libc/locale/toupper.c b/lib/libc/locale/toupper.c deleted file mode 100644 index d2e4480..0000000 --- a/lib/libc/locale/toupper.c +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 -#include - -_BSD_CT_RUNE_T_ -___toupper(c) - _BSD_CT_RUNE_T_ c; -{ -#ifdef XPG4 - int x; - _RuneRange *rr = &_CurrentRuneLocale->mapupper_ext; - _RuneEntry *re = rr->ranges; - - if (c < 0 || c == EOF) - return(c); - - for (x = 0; x < rr->nranges; ++x, ++re) { - if (c < re->min) - return(c); - if (c <= re->max) - return(re->map + c - re->min); - } -#endif - return(c); -} diff --git a/lib/libc/locale/utf2.4 b/lib/libc/locale/utf2.4 deleted file mode 100644 index 3734dba..0000000 --- a/lib/libc/locale/utf2.4 +++ /dev/null @@ -1,88 +0,0 @@ -.\" Copyright (c) 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Paul Borman at Krystal Technologies. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)utf2.4 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt UTF2 4 -.Os -.Sh NAME -.Nm utf2 -.Nd "Universal character set Transformation Format encoding of runes -.Sh SYNOPSIS -.Nm ENCODING -.Qq UTF2 -.Sh DESCRIPTION -The -.Nm UTF2 -encoding is based on a proposed X-Open multibyte -\s-1FSS-UCS-TF\s+1 (File System Safe Universal Character Set Transformation Format) encoding as used in -.Nm Plan 9 from Bell Labs. -Although it is capable of representing more than 16 bits, -the current implementation is limited to 16 bits as defined by the -Unicode Standard. -.Pp -.Nm UTF2 -representation is backwards compatible with ASCII, so 0x00-0x7f refer to the -ASCII character set. The multibyte encoding of runes between 0x0080 and 0xffff -consist entirely of bytes whose high order bit is set. The actual -encoding is represented by the following table: -.Bd -literal -[0x0000 - 0x007f] [00000000.0bbbbbbb] -> 0bbbbbbb -[0x0080 - 0x07ff] [00000bbb.bbbbbbbb] -> 110bbbbb, 10bbbbbb -[0x0800 - 0xffff] [bbbbbbbb.bbbbbbbb] -> 1110bbbb, 10bbbbbb, 10bbbbbb -.Ed -.Pp -If more than a single representation of a value exists (for example, -0x00; 0xC0 0x80; 0xE0 0x80 0x80) the shortest representation is always -used (but the longer ones will be correctly decoded). -.Pp -The final three encodings provided by X-Open: -.Bd -literal -[00000000.000bbbbb.bbbbbbbb.bbbbbbbb] -> - 11110bbb, 10bbbbbb, 10bbbbbb, 10bbbbbb - -[000000bb.bbbbbbbb.bbbbbbbb.bbbbbbbb] -> - 111110bb, 10bbbbbb, 10bbbbbb, 10bbbbbb, 10bbbbbb - -[0bbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb] -> - 1111110b, 10bbbbbb, 10bbbbbb, 10bbbbbb, 10bbbbbb, 10bbbbbb -.Ed -.Pp -which provides for the entire proposed ISO-10646 31 bit standard are currently -not implemented. -.Sh "SEE ALSO" -.Xr mklocale 1 , -.Xr setlocale 3 diff --git a/lib/libc/locale/utf2.5 b/lib/libc/locale/utf2.5 deleted file mode 100644 index 3734dba..0000000 --- a/lib/libc/locale/utf2.5 +++ /dev/null @@ -1,88 +0,0 @@ -.\" Copyright (c) 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Paul Borman at Krystal Technologies. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)utf2.4 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt UTF2 4 -.Os -.Sh NAME -.Nm utf2 -.Nd "Universal character set Transformation Format encoding of runes -.Sh SYNOPSIS -.Nm ENCODING -.Qq UTF2 -.Sh DESCRIPTION -The -.Nm UTF2 -encoding is based on a proposed X-Open multibyte -\s-1FSS-UCS-TF\s+1 (File System Safe Universal Character Set Transformation Format) encoding as used in -.Nm Plan 9 from Bell Labs. -Although it is capable of representing more than 16 bits, -the current implementation is limited to 16 bits as defined by the -Unicode Standard. -.Pp -.Nm UTF2 -representation is backwards compatible with ASCII, so 0x00-0x7f refer to the -ASCII character set. The multibyte encoding of runes between 0x0080 and 0xffff -consist entirely of bytes whose high order bit is set. The actual -encoding is represented by the following table: -.Bd -literal -[0x0000 - 0x007f] [00000000.0bbbbbbb] -> 0bbbbbbb -[0x0080 - 0x07ff] [00000bbb.bbbbbbbb] -> 110bbbbb, 10bbbbbb -[0x0800 - 0xffff] [bbbbbbbb.bbbbbbbb] -> 1110bbbb, 10bbbbbb, 10bbbbbb -.Ed -.Pp -If more than a single representation of a value exists (for example, -0x00; 0xC0 0x80; 0xE0 0x80 0x80) the shortest representation is always -used (but the longer ones will be correctly decoded). -.Pp -The final three encodings provided by X-Open: -.Bd -literal -[00000000.000bbbbb.bbbbbbbb.bbbbbbbb] -> - 11110bbb, 10bbbbbb, 10bbbbbb, 10bbbbbb - -[000000bb.bbbbbbbb.bbbbbbbb.bbbbbbbb] -> - 111110bb, 10bbbbbb, 10bbbbbb, 10bbbbbb, 10bbbbbb - -[0bbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb] -> - 1111110b, 10bbbbbb, 10bbbbbb, 10bbbbbb, 10bbbbbb, 10bbbbbb -.Ed -.Pp -which provides for the entire proposed ISO-10646 31 bit standard are currently -not implemented. -.Sh "SEE ALSO" -.Xr mklocale 1 , -.Xr setlocale 3 diff --git a/lib/libc/locale/utf2.c b/lib/libc/locale/utf2.c deleted file mode 100644 index 52b4cad..0000000 --- a/lib/libc/locale/utf2.c +++ /dev/null @@ -1,150 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifdef XPG4 -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)utf2.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include - -rune_t _UTF2_sgetrune __P((const char *, size_t, char const **)); -int _UTF2_sputrune __P((rune_t, char *, size_t, char **)); - -static int _utf_count[16] = { - 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 2, 2, 3, 0, -}; - -int -_UTF2_init(rl) - _RuneLocale *rl; -{ - rl->sgetrune = _UTF2_sgetrune; - rl->sputrune = _UTF2_sputrune; - _CurrentRuneLocale = rl; - __mb_cur_max = 3; - return (0); -} - -rune_t -_UTF2_sgetrune(string, n, result) - const char *string; - size_t n; - char const **result; -{ - int c; - - if (n < 1 || (c = _utf_count[(*string >> 4) & 0xf]) > n) { - if (result) - *result = string; - return (_INVALID_RUNE); - } - switch (c) { - case 1: - if (result) - *result = string + 1; - return (*string & 0xff); - case 2: - if ((string[1] & 0xC0) != 0x80) - goto encoding_error; - if (result) - *result = string + 2; - return (((string[0] & 0x1F) << 6) | (string[1] & 0x3F)); - case 3: - if ((string[1] & 0xC0) != 0x80 || (string[2] & 0xC0) != 0x80) - goto encoding_error; - if (result) - *result = string + 3; - return (((string[0] & 0x1F) << 12) | ((string[1] & 0x3F) << 6) - | (string[2] & 0x3F)); - default: -encoding_error: if (result) - *result = string + 1; - return (_INVALID_RUNE); - } -} - -int -_UTF2_sputrune(c, string, n, result) - rune_t c; - char *string, **result; - size_t n; -{ - if (c & 0xF800) { - if (n >= 3) { - if (string) { - string[0] = 0xE0 | ((c >> 12) & 0x0F); - string[1] = 0x80 | ((c >> 6) & 0x3F); - string[2] = 0x80 | ((c) & 0x3F); - } - if (result) - *result = string + 3; - } else - if (result) - *result = NULL; - - return (3); - } else - if (c & 0x0780) { - if (n >= 2) { - if (string) { - string[0] = 0xC0 | ((c >> 6) & 0x1F); - string[1] = 0x80 | ((c) & 0x3F); - } - if (result) - *result = string + 2; - } else - if (result) - *result = NULL; - return (2); - } else { - if (n >= 1) { - if (string) - string[0] = c; - if (result) - *result = string + 1; - } else - if (result) - *result = NULL; - return (1); - } -} -#endif /* XPG4 */ diff --git a/lib/libc/mips/:errfix b/lib/libc/mips/:errfix deleted file mode 100644 index 528c927..0000000 --- a/lib/libc/mips/:errfix +++ /dev/null @@ -1,5 +0,0 @@ -?sys_nerr? -.-4,.+1m1 -.+1,$g/\.data/s//\.text/ -w -q diff --git a/lib/libc/mips/Makefile.inc b/lib/libc/mips/Makefile.inc deleted file mode 100644 index c64d01b..0000000 --- a/lib/libc/mips/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.1.1.1 1995/10/18 08:41:33 deraadt Exp $ - -KMINCLUDES= -KMSRCS= diff --git a/lib/libc/mips/SYS.h b/lib/libc/mips/SYS.h deleted file mode 100644 index ccce710..0000000 --- a/lib/libc/mips/SYS.h +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $OpenBSD: SYS.h,v 1.3 1996/07/30 20:27:48 pefo Exp $ - */ - -#include -#include - -#ifdef __STDC__ -#define RSYSCALL(x) \ - LEAF(x); \ - li v0,SYS_ ## x; \ - syscall; \ - bne a3,zero,err; \ - j ra; \ - err: la t9, cerror; \ - jr t9; \ - END(x); -#define PSEUDO(x,y) \ - LEAF(x); \ - li v0,SYS_ ## y; \ - syscall; \ - bne a3,zero,err; \ - j ra; \ - err: la t9, cerror; \ - jr t9; \ - END(x); -#else -#define RSYSCALL(x) \ - LEAF(x); \ - li v0,SYS_/**/x; \ - syscall; \ - bne a3,zero,err; \ - j ra; \ - err: la t9, cerror; \ - jr t9; \ - END(x); -#define PSEUDO(x,y) \ - LEAF(x); \ - li v0,SYS_/**/y; \ - syscall; \ - bne a3,zero,err; \ - j ra; \ - err: la t9, cerror; \ - jr t9; \ - END(x); -#endif diff --git a/lib/libc/mips/gen/Makefile.inc b/lib/libc/mips/gen/Makefile.inc deleted file mode 100644 index 6c358a9..0000000 --- a/lib/libc/mips/gen/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.4 1995/12/15 01:12:36 jonathan Exp $ - -SRCS+= _setjmp.S fabs.S frexp.c infinity.c isinf.S ldexp.S modf.S -SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ - fpsetround.c fpsetsticky.c -SRCS+= setjmp.S sigsetjmp.S diff --git a/lib/libc/mips/gen/_setjmp.S b/lib/libc/mips/gen/_setjmp.S deleted file mode 100644 index 0e7b886..0000000 --- a/lib/libc/mips/gen/_setjmp.S +++ /dev/null @@ -1,132 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 -#include - -#if defined(LIBC_SCCS) - .text - .asciz "$OpenBSD: _setjmp.S,v 1.5 1996/08/19 08:15:51 tholo Exp $" -#endif /* LIBC_SCCS */ - -/* - * 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. - */ - -LEAF(_setjmp) - .set noreorder - li v0, 0xACEDBADE # sigcontext magic number - sw ra, (2 * 4)(a0) # sc_pc = return address - sw v0, (3 * 4)(a0) # saved in sc_regs[0] - sw s0, ((S0 + 3) * 4)(a0) - sw s1, ((S1 + 3) * 4)(a0) - sw s2, ((S2 + 3) * 4)(a0) - sw s3, ((S3 + 3) * 4)(a0) - sw s4, ((S4 + 3) * 4)(a0) - sw s5, ((S5 + 3) * 4)(a0) - sw s6, ((S6 + 3) * 4)(a0) - sw s7, ((S7 + 3) * 4)(a0) - sw sp, ((SP + 3) * 4)(a0) - sw s8, ((S8 + 3) * 4)(a0) - cfc1 v0, $31 # too bad cant check if FP used - swc1 $f20, ((20 + 38) * 4)(a0) - swc1 $f21, ((21 + 38) * 4)(a0) - swc1 $f22, ((22 + 38) * 4)(a0) - swc1 $f23, ((23 + 38) * 4)(a0) - swc1 $f24, ((24 + 38) * 4)(a0) - swc1 $f25, ((25 + 38) * 4)(a0) - swc1 $f26, ((26 + 38) * 4)(a0) - swc1 $f27, ((27 + 38) * 4)(a0) - swc1 $f28, ((28 + 38) * 4)(a0) - swc1 $f29, ((29 + 38) * 4)(a0) - swc1 $f30, ((30 + 38) * 4)(a0) - swc1 $f31, ((31 + 38) * 4)(a0) - sw v0, ((32 + 38) * 4)(a0) - j ra - move v0, zero -END(_setjmp) - -LEAF(_longjmp) -#ifdef ABICALLS - subu sp, sp, 32 - .cprestore 16 -#endif - .set noreorder - lw v0, (3 * 4)(a0) # get magic number - lw ra, (2 * 4)(a0) - bne v0, 0xACEDBADE, botch # jump if error - - addu sp, sp, 32 # does not matter, sanity - lw s0, ((S0 + 3) * 4)(a0) - lw s1, ((S1 + 3) * 4)(a0) - lw s2, ((S2 + 3) * 4)(a0) - lw s3, ((S3 + 3) * 4)(a0) - lw s4, ((S4 + 3) * 4)(a0) - lw s5, ((S5 + 3) * 4)(a0) - lw s6, ((S6 + 3) * 4)(a0) - lw s7, ((S7 + 3) * 4)(a0) - lw v0, ((32 + 38) * 4)(a0) # get fpu status - lw sp, ((SP + 3) * 4)(a0) - lw s8, ((S8 + 3) * 4)(a0) - ctc1 v0, $31 - lwc1 $f20, ((20 + 38) * 4)(a0) - lwc1 $f21, ((21 + 38) * 4)(a0) - lwc1 $f22, ((22 + 38) * 4)(a0) - lwc1 $f23, ((23 + 38) * 4)(a0) - lwc1 $f24, ((24 + 38) * 4)(a0) - lwc1 $f25, ((25 + 38) * 4)(a0) - lwc1 $f26, ((26 + 38) * 4)(a0) - lwc1 $f27, ((27 + 38) * 4)(a0) - lwc1 $f28, ((28 + 38) * 4)(a0) - lwc1 $f29, ((29 + 38) * 4)(a0) - lwc1 $f30, ((30 + 38) * 4)(a0) - lwc1 $f31, ((31 + 38) * 4)(a0) - - j ra - move v0, a1 -botch: - jal _C_LABEL(longjmperror) - nop - jal _C_LABEL(abort) - nop -END(_longjmp) diff --git a/lib/libc/mips/gen/fabs.S b/lib/libc/mips/gen/fabs.S deleted file mode 100644 index 5306870..0000000 --- a/lib/libc/mips/gen/fabs.S +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 - -#if defined(LIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* LIBC_SCCS */ - -/* - * fabs(x) - * double x; - * - * Return absolute value of x. - */ -LEAF(fabs) - .set noreorder - j ra - abs.d $f0, $f12 # compute absolute value of x -END(fabs) diff --git a/lib/libc/mips/gen/flt_rounds.c b/lib/libc/mips/gen/flt_rounds.c deleted file mode 100644 index 289ed7c..0000000 --- a/lib/libc/mips/gen/flt_rounds.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Written by J.T. Conklin, Apr 11, 1995 - * Public domain. - */ - -#include -#include - -#if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: flt_rounds.c,v 1.3 1997/08/01 21:36:28 deraadt Exp $"; -#endif /* LIBC_SCCS and not lint */ - -static const int map[] = { - 1, /* round to nearest */ - 0, /* round to zero */ - 2, /* round to positive infinity */ - 3 /* round to negative infinity */ -}; - -int -__flt_rounds() -{ - int x; - - __asm__("cfc1 %0,$31" : "=r" (x)); - return map[x & 0x03]; -} diff --git a/lib/libc/mips/gen/fpgetmask.c b/lib/libc/mips/gen/fpgetmask.c deleted file mode 100644 index 8c1a53e..0000000 --- a/lib/libc/mips/gen/fpgetmask.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Written by J.T. Conklin, Apr 11, 1995 - * Public domain. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include - -fp_except -fpgetmask() -{ - int x; - - __asm__("cfc1 %0,$31" : "=r" (x)); - return (x >> 7) & 0x1f; -} diff --git a/lib/libc/mips/gen/fpgetround.c b/lib/libc/mips/gen/fpgetround.c deleted file mode 100644 index 565f7c8..0000000 --- a/lib/libc/mips/gen/fpgetround.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Written by J.T. Conklin, Apr 11, 1995 - * Public domain. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include - -fp_rnd -fpgetround() -{ - int x; - - __asm__("cfc1 %0,$31" : "=r" (x)); - return x & 0x03; -} diff --git a/lib/libc/mips/gen/fpgetsticky.c b/lib/libc/mips/gen/fpgetsticky.c deleted file mode 100644 index f7057ff..0000000 --- a/lib/libc/mips/gen/fpgetsticky.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Written by J.T. Conklin, Apr 11, 1995 - * Public domain. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include - -fp_except -fpgetsticky() -{ - int x; - - __asm__("cfc1 %0,$31" : "=r" (x)); - return (x >> 2) & 0x1f; -} diff --git a/lib/libc/mips/gen/fpsetmask.c b/lib/libc/mips/gen/fpsetmask.c deleted file mode 100644 index c57f52f..0000000 --- a/lib/libc/mips/gen/fpsetmask.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Written by J.T. Conklin, Apr 11, 1995 - * Public domain. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include - -fp_except -fpsetmask(mask) - fp_except mask; -{ - fp_except old; - fp_except new; - - __asm__("cfc1 %0,$31" : "=r" (old)); - - new = old; - new &= ~(0x1f << 7); - new |= ((mask & 0x1f) << 7); - - __asm__("ctc1 %0,$31" : : "r" (new)); - - return (old >> 7) & 0x1f; -} diff --git a/lib/libc/mips/gen/fpsetround.c b/lib/libc/mips/gen/fpsetround.c deleted file mode 100644 index 9516d34..0000000 --- a/lib/libc/mips/gen/fpsetround.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Written by J.T. Conklin, Apr 11, 1995 - * Public domain. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include - -fp_rnd -fpsetround(rnd_dir) - fp_rnd rnd_dir; -{ - fp_rnd old; - fp_rnd new; - - __asm__("cfc1 %0,$31" : "=r" (old)); - - new = old; - new &= ~0x03; - new |= (rnd_dir & 0x03); - - __asm__("ctc1 %0,$31" : : "r" (new)); - - return old & 0x03; -} diff --git a/lib/libc/mips/gen/fpsetsticky.c b/lib/libc/mips/gen/fpsetsticky.c deleted file mode 100644 index 493c3a0..0000000 --- a/lib/libc/mips/gen/fpsetsticky.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Written by J.T. Conklin, Apr 11, 1995 - * Public domain. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include - -fp_except -fpsetsticky(sticky) - fp_except sticky; -{ - fp_except old; - fp_except new; - - __asm__("cfc1 %0,$31" : "=r" (old)); - - new = old; - new &= ~(0x1f << 2); - new |= ((sticky & 0x1f) << 2); - - __asm__("ctc1 %0,$31" : : "r" (new)); - - return (old >> 2) & 0x1f; -} diff --git a/lib/libc/mips/gen/frexp.c b/lib/libc/mips/gen/frexp.c deleted file mode 100644 index 181e1dc..0000000 --- a/lib/libc/mips/gen/frexp.c +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: frexp.c,v 1.3 1997/07/23 20:55:24 kstailey Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -double -frexp(value, eptr) - double value; - int *eptr; -{ - union { - double v; - struct { -#if BYTE_ORDER == LITTLE_ENDIAN - u_int u_mant2 : 32; - u_int u_mant1 : 20; - u_int u_exp : 11; - u_int u_sign : 1; -#else - u_int u_sign : 1; - u_int u_exp : 11; - u_int u_mant1 : 20; - u_int u_mant2 : 32; -#endif - } s; - } u; - - if (value) { - u.v = value; - *eptr = u.s.u_exp - 1022; - u.s.u_exp = 1022; - return(u.v); - } else { - *eptr = 0; - return((double)0); - } -} diff --git a/lib/libc/mips/gen/infinity.c b/lib/libc/mips/gen/infinity.c deleted file mode 100644 index 7a0b131..0000000 --- a/lib/libc/mips/gen/infinity.c +++ /dev/null @@ -1,15 +0,0 @@ -/* infinity.c */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: infinity.c,v 1.2 1996/08/19 08:16:01 tholo Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* bytes for +Infinity on a MIPS */ -#if BYTE_ORDER == BIG_ENDIAN -char __infinity[] = { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 }; -#else -char __infinity[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }; -#endif diff --git a/lib/libc/mips/gen/isinf.S b/lib/libc/mips/gen/isinf.S deleted file mode 100644 index e872cd7..0000000 --- a/lib/libc/mips/gen/isinf.S +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 - -#if defined(LIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* LIBC_SCCS */ - -#define DEXP_INF 0x7ff - -/* - * isnan(x) - * double x; - * - * Return true if x is a NAN. - */ -LEAF(isnan) - .set noreorder - mfc1 v1, $f13 # get MSW of x - mfc1 t3, $f12 # get LSW of x - sll t1, v1, 1 # get x exponent - srl t1, t1, 32 - 11 - bne t1, DEXP_INF, 2f # is it a finite number? - sll t2, v1, 32 - 20 # get x fraction - bne t3, zero, 1f # is it a NAN? - nop - beq t2, zero, 2f # its infinity - nop -1: - j ra - li v0, 1 # x is a NAN -2: - j ra - move v0, zero # x is NOT a NAN -END(isnan) - -/* - * isinf(x) - * double x; - * - * Return true if x is infinity. - */ -LEAF(isinf) - .set noreorder - mfc1 v1, $f13 # get MSW of x - mfc1 t3, $f12 # get LSW of x - sll t1, v1, 1 # get x exponent - srl t1, t1, 32 - 11 - bne t1, DEXP_INF, 1f # is it a finite number? - sll t2, v1, 32 - 20 # get x fraction - bne t3, zero, 1f # is it a NAN? - nop - bne t2, zero, 1f # is it a NAN? - nop - j ra - li v0, 1 # x is infinity -1: - j ra - move v0, zero # x is NOT infinity -END(isinf) diff --git a/lib/libc/mips/gen/ldexp.S b/lib/libc/mips/gen/ldexp.S deleted file mode 100644 index 5aa6131..0000000 --- a/lib/libc/mips/gen/ldexp.S +++ /dev/null @@ -1,217 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 - -#if defined(LIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* LIBC_SCCS */ - -#define DEXP_INF 0x7ff -#define DEXP_BIAS 1023 -#define DEXP_MIN -1022 -#define DEXP_MAX 1023 -#define DFRAC_BITS 52 -#define DIMPL_ONE 0x00100000 -#define DLEAD_ZEROS 31 - 20 -#define STICKYBIT 1 -#define GUARDBIT 0x80000000 -#define DSIGNAL_NAN 0x00040000 -#define DQUIET_NAN0 0x0007ffff -#define DQUIET_NAN1 0xffffffff - -/* - * double ldexp(x, N) - * double x; int N; - * - * Return x * (2**N), for integer values N. - */ -LEAF(ldexp) - .set reorder - mfc1 v1, $f13 # get MSW of x - mfc1 t3, $f12 # get LSW of x - sll t1, v1, 1 # get x exponent - srl t1, t1, 32 - 11 - beq t1, DEXP_INF, 9f # is it a NAN or infinity? - beq t1, zero, 1f # zero or denormalized number? - addu t1, t1, a2 # scale exponent - sll v0, a2, 20 # position N for addition - bge t1, DEXP_INF, 8f # overflow? - addu v0, v0, v1 # multiply by (2**N) - ble t1, zero, 4f # underflow? - mtc1 v0, $f1 # save MSW of result - mtc1 t3, $f0 # save LSW of result - j ra -1: - sll t2, v1, 32 - 20 # get x fraction - srl t2, t2, 32 - 20 - srl t0, v1, 31 # get x sign - bne t2, zero, 1f - beq t3, zero, 9f # result is zero -1: -/* - * Find out how many leading zero bits are in t2,t3 and put in t9. - */ - move v0, t2 - move t9, zero - bne t2, zero, 1f - move v0, t3 - addu t9, 32 -1: - srl t4, v0, 16 - bne t4, zero, 1f - addu t9, 16 - sll v0, 16 -1: - srl t4, v0, 24 - bne t4, zero, 1f - addu t9, 8 - sll v0, 8 -1: - srl t4, v0, 28 - bne t4, zero, 1f - addu t9, 4 - sll v0, 4 -1: - srl t4, v0, 30 - bne t4, zero, 1f - addu t9, 2 - sll v0, 2 -1: - srl t4, v0, 31 - bne t4, zero, 1f - addu t9, 1 -/* - * Now shift t2,t3 the correct number of bits. - */ -1: - subu t9, t9, DLEAD_ZEROS # dont count normal leading zeros - li t1, DEXP_MIN + DEXP_BIAS - subu t1, t1, t9 # adjust exponent - addu t1, t1, a2 # scale exponent - li v0, 32 - blt t9, v0, 1f - subu t9, t9, v0 # shift fraction left >= 32 bits - sll t2, t3, t9 - move t3, zero - b 2f -1: - subu v0, v0, t9 # shift fraction left < 32 bits - sll t2, t2, t9 - srl t4, t3, v0 - or t2, t2, t4 - sll t3, t3, t9 -2: - bge t1, DEXP_INF, 8f # overflow? - ble t1, zero, 4f # underflow? - sll t2, t2, 32 - 20 # clear implied one bit - srl t2, t2, 32 - 20 -3: - sll t1, t1, 31 - 11 # reposition exponent - sll t0, t0, 31 # reposition sign - or t0, t0, t1 # put result back together - or t0, t0, t2 - mtc1 t0, $f1 # save MSW of result - mtc1 t3, $f0 # save LSW of result - j ra -4: - li v0, 0x80000000 - ble t1, -52, 7f # is result too small for denorm? - sll t2, v1, 31 - 20 # clear exponent, extract fraction - or t2, t2, v0 # set implied one bit - blt t1, -30, 2f # will all bits in t3 be shifted out? - srl t2, t2, 31 - 20 # shift fraction back to normal position - subu t1, t1, 1 - sll t4, t2, t1 # shift right t2,t3 based on exponent - srl t8, t3, t1 # save bits shifted out - negu t1 - srl t3, t3, t1 - or t3, t3, t4 - srl t2, t2, t1 - bge t8, zero, 1f # does result need to be rounded? - addu t3, t3, 1 # round result - sltu t4, t3, 1 - sll t8, t8, 1 - addu t2, t2, t4 - bne t8, zero, 1f # round result to nearest - and t3, t3, ~1 -1: - mtc1 t3, $f0 # save denormalized result (LSW) - mtc1 t2, $f1 # save denormalized result (MSW) - bge v1, zero, 1f # should result be negative? - neg.d $f0, $f0 # negate result -1: - j ra -2: - mtc1 zero, $f1 # exponent and upper fraction - addu t1, t1, 20 # compute amount to shift right by - sll t8, t2, t1 # save bits shifted out - negu t1 - srl t3, t2, t1 - bge t8, zero, 1f # does result need to be rounded? - addu t3, t3, 1 # round result - sltu t4, t3, 1 - sll t8, t8, 1 - mtc1 t4, $f1 # exponent and upper fraction - bne t8, zero, 1f # round result to nearest - and t3, t3, ~1 -1: - mtc1 t3, $f0 - bge v1, zero, 1f # is result negative? - neg.d $f0, $f0 # negate result -1: - j ra -7: - mtc1 zero, $f0 # result is zero - mtc1 zero, $f1 - beq t0, zero, 1f # is result positive? - neg.d $f0, $f0 # negate result -1: - j ra -8: - li t1, 0x7ff00000 # result is infinity (MSW) - mtc1 t1, $f1 - mtc1 zero, $f0 # result is infinity (LSW) - bge v1, zero, 1f # should result be negative infinity? - neg.d $f0, $f0 # result is negative infinity -1: - add.d $f0, $f0 # cause overflow faults if enabled - j ra -9: - mov.d $f0, $f12 # yes, result is just x - j ra -END(ldexp) diff --git a/lib/libc/mips/gen/modf.S b/lib/libc/mips/gen/modf.S deleted file mode 100644 index 057feaa..0000000 --- a/lib/libc/mips/gen/modf.S +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * Copyright (c) 1991, 1993, 1995 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 - -#if defined(LIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* LIBC_SCCS */ - -/* - * double modf(val, iptr) - * double val, *iptr; - * returns: xxx and n (in *iptr) where val == n.xxx - */ -LEAF(modf) - .set reorder - cfc1 t0, $31 # get the control register - li.d $f2, 4503599627370496e0 # f2 <- 2^52 - - or t1, t0, 0x3 # set rounding mode to round to zero - xor t1, t1, 0x2 # (i.e., 01) - ctc1 t1, $31 - - mov.d $f0, $f12 # f0 <- f12 - abs.d $f4, $f12 # f4 <- |f12| - c.olt.d $f4, $f2 # f4 ? < f2 - bc1f 1f # leave f0 alone if Nan, infinity - # or >=2^52 - c.eq.d $f12,$f4 # was f12 positive ? - add.d $f4,$f2,$f4 # round off to integer - bc1f 2f # No -> will have to negate result - sub.d $f0,$f4,$f2 # Remove fudge factor - j 1f # integer fraction got -2: - sub.d $f0,$f2,$f4 # Remove fudge factor and negate -1: - ctc1 t0, $31 # restore old rounding mode - s.d $f0, 0(a2) # save the integer part - sub.d $f0, $f12, $f0 # subtract val - integer part - j ra -END(modf) diff --git a/lib/libc/mips/gen/setjmp.S b/lib/libc/mips/gen/setjmp.S deleted file mode 100644 index 0abfed8..0000000 --- a/lib/libc/mips/gen/setjmp.S +++ /dev/null @@ -1,128 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 -#include -#include - -#if defined(LIBC_SCCS) - .text - .asciz "$OpenBSD: setjmp.S,v 1.6 1997/07/23 20:55:25 kstailey Exp $" -#endif /* LIBC_SCCS */ - -/* - * 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, - * and a struct sigcontext, see - */ - -#define SETJMP_FRAME_SIZE (STAND_FRAME_SIZE + 12) - -NON_LEAF(setjmp, SETJMP_FRAME_SIZE, ra) - .mask 0x80000000, (STAND_RA_OFFSET - STAND_FRAME_SIZE) - subu sp, sp, SETJMP_FRAME_SIZE # allocate stack frame -#ifdef ABICALLS - .cprestore 16 -#endif - .set reorder - sw ra, STAND_RA_OFFSET(sp) # save state - sw a0, SETJMP_FRAME_SIZE(sp) - move a0, zero # get current signal mask - jal _C_LABEL(sigblock) - lw v1, SETJMP_FRAME_SIZE(sp) # v1 = jmpbuf - sw v0, (1 * 4)(v1) # save sc_mask = sigblock(0) - move a0, zero - addu a1, sp, STAND_FRAME_SIZE # pointer to struct sigaltstack - jal _C_LABEL(sigaltstack) - lw a0, SETJMP_FRAME_SIZE(sp) # restore jmpbuf - lw v1, STAND_FRAME_SIZE+8(sp) # get old ss_onstack - and v1, v1, 1 # extract onstack flag - sw v1, 0(a0) # save it in sc_onstack - lw ra, STAND_RA_OFFSET(sp) - addu sp, sp, SETJMP_FRAME_SIZE - blt v0, zero, botch # check for sigstack() error - sw ra, (2 * 4)(a0) # sc_pc = return address - li v0, 0xACEDBADE # sigcontext magic number - sw v0, ((ZERO + 3) * 4)(a0) # saved in sc_regs[0] - sw s0, ((S0 + 3) * 4)(a0) - sw s1, ((S1 + 3) * 4)(a0) - sw s2, ((S2 + 3) * 4)(a0) - sw s3, ((S3 + 3) * 4)(a0) - sw s4, ((S4 + 3) * 4)(a0) - sw s5, ((S5 + 3) * 4)(a0) - sw s6, ((S6 + 3) * 4)(a0) - sw s7, ((S7 + 3) * 4)(a0) - sw gp, ((GP + 3) * 4)(a0) - sw sp, ((SP + 3) * 4)(a0) - sw s8, ((S8 + 3) * 4)(a0) - li v0, 1 # be nice if we could tell - sw v0, (37 * 4)(a0) # sc_fpused = 1 - cfc1 v0, $31 - swc1 $f20, ((20 + 38) * 4)(a0) - swc1 $f21, ((21 + 38) * 4)(a0) - swc1 $f22, ((22 + 38) * 4)(a0) - swc1 $f23, ((23 + 38) * 4)(a0) - swc1 $f24, ((24 + 38) * 4)(a0) - swc1 $f25, ((25 + 38) * 4)(a0) - swc1 $f26, ((26 + 38) * 4)(a0) - swc1 $f27, ((27 + 38) * 4)(a0) - swc1 $f28, ((28 + 38) * 4)(a0) - swc1 $f29, ((29 + 38) * 4)(a0) - swc1 $f30, ((30 + 38) * 4)(a0) - swc1 $f31, ((31 + 38) * 4)(a0) - sw v0, ((32 + 38) * 4)(a0) - move v0, zero - j ra -END(setjmp) - -LEAF(longjmp) -#ifdef ABICALLS - subu sp, sp, 32 - .cprestore 16 -#endif - .set reorder - sw a1, ((V0 + 3) * 4)(a0) # save return value in sc_regs[V0] - li v0, SYS_sigreturn - syscall -botch: - jal _C_LABEL(longjmperror) - jal _C_LABEL(abort) -END(longjmp) diff --git a/lib/libc/mips/gen/sigsetjmp.S b/lib/libc/mips/gen/sigsetjmp.S deleted file mode 100644 index 4a7d414..0000000 --- a/lib/libc/mips/gen/sigsetjmp.S +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * Copyright (c) 1991, 1993, 1995, - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Havard Eidnes. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 -#include -#include -#include - -#if defined(LIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* LIBC_SCCS */ - -/* - * C library -- sigsetjmp, siglongjmp - * - * siglongjmp(a,v) - * will generate a "return(v)" from - * the last call to - * sigsetjmp(a, savemask) - * by restoring registers from the stack, - * and dependent on savemask restores the - * signal mask. - */ - -LEAF(sigsetjmp) - .set reorder - sw a1, (_JBLEN*4)(a0) # save "savemask" - bne a1, 0x0, 1f # do saving of signal mask? - la t9, _setjmp - jr t9 - -1: la t9, setjmp - jr t9 -END(sigsetjmp) - -LEAF(siglongjmp) - .set reorder - lw t0, (_JBLEN * 4)(a0) # get "savemask" - bne t0, 0x0, 1f # restore signal mask? - la t9, _longjmp - jr t9 -1: la t9, longjmp - jr t9 -END(siglongjmp) diff --git a/lib/libc/mips/net/Makefile.inc b/lib/libc/mips/net/Makefile.inc deleted file mode 100644 index 1518429..0000000 --- a/lib/libc/mips/net/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.1 1995/02/25 14:59:01 cgd Exp $ - -SRCS+= htonl.S htons.S -LSRCS+= htonl.c htons.c diff --git a/lib/libc/mips/net/htonl.S b/lib/libc/mips/net/htonl.S deleted file mode 100644 index 3ec9a96..0000000 --- a/lib/libc/mips/net/htonl.S +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 - -#if defined(LIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* LIBC_SCCS */ - -/* - * netorder = htonl(hostorder) - * hostorder = ntohl(netorder) - */ -ALEAF(ntohl) -NLEAF(htonl) # a0 = 0x11223344, return 0x44332211 - .set reorder -#ifdef MIPSEL - srl v1, a0, 24 # v1 = 0x00000011 - sll v0, a0, 24 # v0 = 0x44000000 - or v0, v0, v1 - and v1, a0, 0xff00 - sll v1, v1, 8 # v1 = 0x00330000 - or v0, v0, v1 - srl v1, a0, 8 - and v1, v1, 0xff00 # v1 = 0x00002200 - or v0, v0, v1 -#else -#ifdef MIPSEB - move v0, a0 -#else - ERROR -#endif -#endif - j ra -END(htonl) diff --git a/lib/libc/mips/net/htons.S b/lib/libc/mips/net/htons.S deleted file mode 100644 index be056d2..0000000 --- a/lib/libc/mips/net/htons.S +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 - -#if defined(LIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* LIBC_SCCS */ - -/* - * netorder = htons(hostorder) - * hostorder = ntohs(netorder) - */ -ALEAF(ntohs) -NLEAF(htons) - .set reorder -#ifdef MIPSEL - srl v0, a0, 8 - and v0, v0, 0xff - sll v1, a0, 8 - and v1, v1, 0xff00 - or v0, v0, v1 -#else -#ifdef MIPSEB - move v0, a0 -#else - ERROR -#endif -#endif - j ra -END(htons) diff --git a/lib/libc/mips/stdlib/Makefile.inc b/lib/libc/mips/stdlib/Makefile.inc deleted file mode 100644 index e69de29..0000000 diff --git a/lib/libc/mips/string/Makefile.inc b/lib/libc/mips/string/Makefile.inc deleted file mode 100644 index a60e550..0000000 --- a/lib/libc/mips/string/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.1 1995/03/20 14:45:47 mycroft Exp $ - -SRCS+= bcmp.S bcopy.S bzero.S ffs.S index.S memchr.c memcmp.c memset.c \ - rindex.S strcat.c strcmp.S strcpy.c strcspn.c strlen.S \ - strncat.c strncmp.c strncpy.c strpbrk.c strsep.c \ - strspn.c strstr.c swab.c -LSRCS+= bcmp.c bcopy.c bzero.c ffs.c index.c rindex.c strcmp.c strlen.c diff --git a/lib/libc/mips/string/bcmp.S b/lib/libc/mips/string/bcmp.S deleted file mode 100644 index 7d3a96e..0000000 --- a/lib/libc/mips/string/bcmp.S +++ /dev/null @@ -1,120 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 - -#if defined(LIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* LIBC_SCCS */ - -/* bcmp(s1, s2, n) */ - -LEAF(bcmp) - .set noreorder - blt a2, 16, small # is it worth any trouble? - xor v0, a0, a1 # compare low two bits of addresses - and v0, v0, 3 - subu a3, zero, a1 # compute # bytes to word align address - bne v0, zero, unaligned # not possible to align addresses - and a3, a3, 3 - - beq a3, zero, 1f - subu a2, a2, a3 # subtract from remaining count - move v0, v1 # init v0,v1 so unmodified bytes match - LWHI v0, 0(a0) # read 1, 2, or 3 bytes - LWHI v1, 0(a1) - addu a1, a1, a3 - bne v0, v1, nomatch - addu a0, a0, a3 -1: - and a3, a2, ~3 # compute number of whole words left - subu a2, a2, a3 # which has to be >= (16-3) & ~3 - addu a3, a3, a0 # compute ending address -2: - lw v0, 0(a0) # compare words - lw v1, 0(a1) - addu a0, a0, 4 - bne v0, v1, nomatch - addu a1, a1, 4 - bne a0, a3, 2b - nop - b small # finish remainder - nop -unaligned: - beq a3, zero, 2f - subu a2, a2, a3 # subtract from remaining count - addu a3, a3, a0 # compute ending address -1: - lbu v0, 0(a0) # compare bytes until a1 word aligned - lbu v1, 0(a1) - addu a0, a0, 1 - bne v0, v1, nomatch - addu a1, a1, 1 - bne a0, a3, 1b - nop -2: - and a3, a2, ~3 # compute number of whole words left - subu a2, a2, a3 # which has to be >= (16-3) & ~3 - addu a3, a3, a0 # compute ending address -3: - LWHI v0, 0(a0) # compare words a0 unaligned, a1 aligned - LWLO v0, 3(a0) - lw v1, 0(a1) - addu a0, a0, 4 - bne v0, v1, nomatch - addu a1, a1, 4 - bne a0, a3, 3b - nop -small: - ble a2, zero, match - addu a3, a2, a0 # compute ending address -1: - lbu v0, 0(a0) - lbu v1, 0(a1) - addu a0, a0, 1 - bne v0, v1, nomatch - addu a1, a1, 1 - bne a0, a3, 1b - nop -match: - j ra - move v0, zero -nomatch: - j ra - li v0, 1 - .set reorder -END(bcmp) diff --git a/lib/libc/mips/string/bcopy.S b/lib/libc/mips/string/bcopy.S deleted file mode 100644 index 3f64af5..0000000 --- a/lib/libc/mips/string/bcopy.S +++ /dev/null @@ -1,127 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 - -#if defined(LIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* LIBC_SCCS */ - -/* bcopy(s1, s2, n) */ - - -LEAF(bcopy) - .set noreorder - addu t0, a0, a2 # t0 = end of s1 region - sltu t1, a1, t0 - sltu t2, a0, a1 - and t1, t1, t2 # t1 = true if from < to < (from+len) - beq t1, zero, forward # non overlapping, do forward copy - slt t2, a2, 12 # check for small copy - - ble a2, zero, 2f - addu t1, a1, a2 # t1 = end of to region -1: - lb v0, -1(t0) # copy bytes backwards, - subu t0, t0, 1 # doesnt happen often so do slow way - subu t1, t1, 1 - bne t0, a0, 1b - sb v0, 0(t1) -2: - j ra - nop -forward: - bne t2, zero, smallcpy # do a small bcopy - xor v0, a0, a1 # compare low two bits of addresses - and v0, v0, 3 - subu a3, zero, a1 # compute # bytes to word align address - beq v0, zero, aligned # addresses can be word aligned - and a3, a3, 3 - - beq a3, zero, 1f - subu a2, a2, a3 # subtract from remaining count - LWHI v0, 0(a0) # get next 4 bytes (unaligned) - LWLO v0, 3(a0) - addu a0, a0, a3 - SWHI v0, 0(a1) # store 1, 2, or 3 bytes to align a1 - addu a1, a1, a3 -1: - and v0, a2, 3 # compute number of words left - subu a3, a2, v0 - move a2, v0 - addu a3, a3, a0 # compute ending address -2: - LWHI v0, 0(a0) # copy words a0 unaligned, a1 aligned - LWLO v0, 3(a0) - addu a0, a0, 4 - addu a1, a1, 4 - bne a0, a3, 2b - sw v0, -4(a1) - b smallcpy - nop -aligned: - beq a3, zero, 1f - subu a2, a2, a3 # subtract from remaining count - LWHI v0, 0(a0) # copy 1, 2, or 3 bytes to align - addu a0, a0, a3 - SWHI v0, 0(a1) - addu a1, a1, a3 -1: - and v0, a2, 3 # compute number of whole words left - subu a3, a2, v0 - move a2, v0 - addu a3, a3, a0 # compute ending address -2: - lw v0, 0(a0) # copy words - addu a0, a0, 4 - addu a1, a1, 4 - bne a0, a3, 2b - sw v0, -4(a1) -smallcpy: - ble a2, zero, 2f - addu a3, a2, a0 # compute ending address -1: - lbu v0, 0(a0) # copy bytes - addu a0, a0, 1 - addu a1, a1, 1 - bne a0, a3, 1b - sb v0, -1(a1) -2: - j ra - nop - .set reorder -END(bcopy) diff --git a/lib/libc/mips/string/bzero.S b/lib/libc/mips/string/bzero.S deleted file mode 100644 index cb5d258..0000000 --- a/lib/libc/mips/string/bzero.S +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 - -#if defined(LIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* LIBC_SCCS */ - -/* bzero(s1, n) */ - -LEAF(bzero) - .set noreorder - blt a1, 12, smallclr # small amount to clear? - subu a3, zero, a0 # compute # bytes to word align address - and a3, a3, 3 - beq a3, zero, 1f # skip if word aligned - subu a1, a1, a3 # subtract from remaining count - SWHI zero, 0(a0) # clear 1, 2, or 3 bytes to align - addu a0, a0, a3 -1: - and v0, a1, 3 # compute number of words left - subu a3, a1, v0 - move a1, v0 - addu a3, a3, a0 # compute ending address -2: - addu a0, a0, 4 # clear words - bne a0, a3, 2b # unrolling loop doesnt help - sw zero, -4(a0) # since we are limited by memory speed -smallclr: - ble a1, zero, 2f - addu a3, a1, a0 # compute ending address -1: - addu a0, a0, 1 # clear bytes - bne a0, a3, 1b - sb zero, -1(a0) -2: - j ra - nop -END(bzero) diff --git a/lib/libc/mips/string/ffs.S b/lib/libc/mips/string/ffs.S deleted file mode 100644 index 7392ad8..0000000 --- a/lib/libc/mips/string/ffs.S +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 - -#if defined(LIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* LIBC_SCCS */ - -/* bit = ffs(value) */ - -LEAF(ffs) - .set reorder - move v0, zero - beq a0, zero, done -1: - and v1, a0, 1 # bit set? - addu v0, v0, 1 - srl a0, a0, 1 - beq v1, zero, 1b # no, continue -done: - j ra -END(ffs) diff --git a/lib/libc/mips/string/index.S b/lib/libc/mips/string/index.S deleted file mode 100644 index c3bbe57..0000000 --- a/lib/libc/mips/string/index.S +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 - -#if defined(LIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* LIBC_SCCS */ - -LEAF(index) - .set reorder - lbu a2, 0(a0) # get a byte - addu a0, a0, 1 - beq a2, a1, fnd - bne a2, zero, _C_LABEL(index) -notfnd: - move v0, zero - j ra -fnd: - subu v0, a0, 1 - j ra -END(index) diff --git a/lib/libc/mips/string/rindex.S b/lib/libc/mips/string/rindex.S deleted file mode 100644 index 4e7dee4..0000000 --- a/lib/libc/mips/string/rindex.S +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 - -#if defined(LIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* LIBC_SCCS */ - -LEAF(rindex) - .set reorder - move v0, zero # default if not found -1: - lbu a3, 0(a0) # get a byte - addu a0, a0, 1 - bne a3, a1, 2f - subu v0, a0, 1 # save address of last match -2: - bne a3, zero, 1b # continue if not end - j ra -END(rindex) diff --git a/lib/libc/mips/string/strcmp.S b/lib/libc/mips/string/strcmp.S deleted file mode 100644 index bd6922e2..0000000 --- a/lib/libc/mips/string/strcmp.S +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 - -#if defined(LIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* LIBC_SCCS */ - -/* - * NOTE: this version assumes unsigned chars in order to be "8 bit clean". - */ -LEAF(strcmp) - .set reorder -1: - lbu t0, 0(a0) # get two bytes and compare them - lbu t1, 0(a1) - beq t0, zero, LessOrEq # end of first string? - bne t0, t1, NotEq - lbu t0, 1(a0) # unroll loop - lbu t1, 1(a1) - add a0, a0, 2 - beq t0, zero, LessOrEq # end of first string? - add a1, a1, 2 - beq t0, t1, 1b -NotEq: - subu v0, t0, t1 - j ra -LessOrEq: - subu v0, zero, t1 - j ra -END(strcmp) diff --git a/lib/libc/mips/string/strlen.S b/lib/libc/mips/string/strlen.S deleted file mode 100644 index 4f0569a..0000000 --- a/lib/libc/mips/string/strlen.S +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 - -#if defined(LIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* LIBC_SCCS */ - -LEAF(strlen) - .set reorder - addu v1, a0, 1 -1: - lb v0, 0(a0) # get byte from string - addu a0, a0, 1 # increment pointer - bne v0, zero, 1b # continue if not end - subu v0, a0, v1 # compute length - 1 for '\0' char - j ra -END(strlen) diff --git a/lib/libc/mips/sys/Makefile.inc b/lib/libc/mips/sys/Makefile.inc deleted file mode 100644 index e69de29..0000000 diff --git a/lib/libc/mips/sys/Ovfork.S b/lib/libc/mips/sys/Ovfork.S deleted file mode 100644 index fa95c3a..0000000 --- a/lib/libc/mips/sys/Ovfork.S +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 "SYS.h" - -#if defined(SYSLIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* SYSLIBC_SCCS */ - -/* - * pid = vfork(); - * - * v1 == 0 in parent process, v1 == 1 in child process. - * v0 == pid of child in parent, v0 == pid of parent in child. - */ - -LEAF(vfork) - .set reorder - li v0, SYS_vfork # system call number for vfork - syscall - beq a3, zero, 1f # jump if no errors - la t9, cerror - jr t9 -1: - beq v1, zero, 2f # parent process ? - move v0, zero # return zero in child -2: - j ra -END(vfork) diff --git a/lib/libc/mips/sys/brk.S b/lib/libc/mips/sys/brk.S deleted file mode 100644 index 483be25..0000000 --- a/lib/libc/mips/sys/brk.S +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 "SYS.h" - -#if defined(SYSLIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* SYSLIBC_SCCS */ - - .globl minbrk - .globl curbrk - - .data -minbrk: .word _C_LABEL(end) - .text - -LEAF(brk) - .set reorder - lw v0, minbrk - bltu a0, v0, 1f - la t9, _brk - jr t9 -1: - move a0, v0 # dont allow break < minbrk - li v0, SYS_break - syscall - bne a3, zero, 2f - sw a0, curbrk - move v0, zero - j ra -2: - la t9, _C_LABEL(cerror) - jr t9 -END(brk) - -LEAF(_brk) - .set reorder - li v0, SYS_break - syscall - bne a3, zero, 1f - sw a0, curbrk - move v0, zero - j ra -1: - la t9, _C_LABEL(cerror) - jr t9 -END(brk) diff --git a/lib/libc/mips/sys/cerror.S b/lib/libc/mips/sys/cerror.S deleted file mode 100644 index 8dd3aff..0000000 --- a/lib/libc/mips/sys/cerror.S +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 "SYS.h" - -#if defined(SYSLIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* SYSLIBC_SCCS */ - - .globl _C_LABEL(errno) -LEAF(cerror) - .set noreorder - sw v0, _C_LABEL(errno) - li v0, -1 - j ra - li v1, -1 -END(cerror) diff --git a/lib/libc/mips/sys/exect.S b/lib/libc/mips/sys/exect.S deleted file mode 100644 index 581f21f..0000000 --- a/lib/libc/mips/sys/exect.S +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 "SYS.h" - -#if defined(SYSLIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* SYSLIBC_SCCS */ - -LEAF(exect) - .set reorder - li v0, SYS_execve - syscall - bne a3, zero, 1f - j ra -1: - la t9, _C_LABEL(cerror) - jr t9 -END(exect) diff --git a/lib/libc/mips/sys/fork.S b/lib/libc/mips/sys/fork.S deleted file mode 100644 index c454056..0000000 --- a/lib/libc/mips/sys/fork.S +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 "SYS.h" - -#if defined(SYSLIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* SYSLIBC_SCCS */ - -LEAF(fork) - .set reorder - li v0, SYS_fork # pid = fork() - syscall - bne a3, zero, 2f - beq v1, zero, 1f # v1 == 0 in parent, 1 in child - move v0, zero -1: - j ra -2: - la t9, _C_LABEL(cerror) - jr t9 -END(fork) diff --git a/lib/libc/mips/sys/pipe.S b/lib/libc/mips/sys/pipe.S deleted file mode 100644 index 2bed812..0000000 --- a/lib/libc/mips/sys/pipe.S +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 "SYS.h" - -#if defined(SYSLIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* SYSLIBC_SCCS */ - -LEAF(pipe) - .set reorder - li v0, SYS_pipe # pipe(fildes) int fildes[2]; - syscall - bne a3, zero, 1f - sw v0, 0(a0) # store the two file descriptors - sw v1, 4(a0) - move v0, zero - j ra -1: - la t9, _C_LABEL(cerror) - jr t9 -END(pipe) diff --git a/lib/libc/mips/sys/ptrace.S b/lib/libc/mips/sys/ptrace.S deleted file mode 100644 index fe73ee0..0000000 --- a/lib/libc/mips/sys/ptrace.S +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 "SYS.h" - -#if defined(SYSLIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* SYSLIBC_SCCS */ - -LEAF(ptrace) - .set reorder - sw zero, _C_LABEL(errno) - li v0, SYS_ptrace - syscall - bne a3, zero, 1f - j ra -1: - la t9, _C_LABEL(cerror) - jr t9 -END(ptrace) diff --git a/lib/libc/mips/sys/sbrk.S b/lib/libc/mips/sys/sbrk.S deleted file mode 100644 index 8946be1..0000000 --- a/lib/libc/mips/sys/sbrk.S +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 "SYS.h" - -#if defined(SYSLIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* SYSLIBC_SCCS */ - - .globl curbrk - - .data -curbrk: .word _C_LABEL(end) - .text - -LEAF(sbrk) - .set reorder - lw v1, curbrk - li v0, SYS_break - addu a0, a0, v1 # compute current break - syscall - - bne a3, zero, 1f - move v0, v1 # return old val of curbrk from above - sw a0, curbrk # save current val of curbrk from above - j ra -1: - la t9, _C_LABEL(cerror) - jr t9 -END(sbrk) diff --git a/lib/libc/mips/sys/setlogin.S b/lib/libc/mips/sys/setlogin.S deleted file mode 100644 index c148c3e..0000000 --- a/lib/libc/mips/sys/setlogin.S +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 "SYS.h" - -#if defined(SYSLIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* SYSLIBC_SCCS */ - -LEAF(setlogin) - .set reorder - li v0, SYS_setlogin # setlogin(name) - syscall - - bne a3, zero, 1f - sw zero, _C_LABEL(__logname_valid) # in getlogin() - j ra -1: - la t9, _C_LABEL(cerror) - jr t9 -END(setlogin) diff --git a/lib/libc/mips/sys/sigpending.S b/lib/libc/mips/sys/sigpending.S deleted file mode 100644 index 9982086..0000000 --- a/lib/libc/mips/sys/sigpending.S +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 "SYS.h" - -#if defined(SYSLIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* SYSLIBC_SCCS */ - -LEAF(sigpending) - .set reorder - li v0, SYS_sigpending # setlogin(name) - syscall - bne a3, zero, 1f - sw v0, 0(a0) - move v0, zero - j ra -1: - la t9, _C_LABEL(cerror) - jr t9 -END(sigpending) diff --git a/lib/libc/mips/sys/sigprocmask.S b/lib/libc/mips/sys/sigprocmask.S deleted file mode 100644 index ee30fd4..0000000 --- a/lib/libc/mips/sys/sigprocmask.S +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 "SYS.h" - -#if defined(SYSLIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* SYSLIBC_SCCS */ - -LEAF(sigprocmask) # sigprocmask(how, new, old) sigset_t *new, *old; - .set reorder - bne a1, zero, gotptr # if new sigset pointer not null - li a0, 1 # how = SIG_BLOCK - b doit # mask = zero -gotptr: - lw a1, 0(a1) # indirect to new mask arg -doit: - li v0, SYS_sigprocmask - syscall - bne a3, zero, err - beq a2, zero, out # test if old mask requested - sw v0, 0(a2) # store old mask -out: - move v0, zero - j ra -err: - la t9, _C_LABEL(cerror) - jr t9 -END(sigprocmask) diff --git a/lib/libc/mips/sys/sigreturn.S b/lib/libc/mips/sys/sigreturn.S deleted file mode 100644 index 4c20042..0000000 --- a/lib/libc/mips/sys/sigreturn.S +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 "SYS.h" - -#if defined(SYSLIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* SYSLIBC_SCCS */ - -/* - * We must preserve the state of the registers as the user has set them up. - */ - -RSYSCALL(sigreturn) diff --git a/lib/libc/mips/sys/sigsuspend.S b/lib/libc/mips/sys/sigsuspend.S deleted file mode 100644 index 2394e2b..0000000 --- a/lib/libc/mips/sys/sigsuspend.S +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 "SYS.h" - -#if defined(SYSLIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* SYSLIBC_SCCS */ - -LEAF(sigsuspend) - .set reorder - lw a0, 0(a0) # indirect to mask arg - li v0, SYS_sigsuspend - syscall - bne a3, zero, 1f - move v0, zero # should not happen - j ra -1: - la t9, _C_LABEL(cerror) - jr t9 -END(sigsuspend) diff --git a/lib/libc/mips/sys/syscall.S b/lib/libc/mips/sys/syscall.S deleted file mode 100644 index d471155..0000000 --- a/lib/libc/mips/sys/syscall.S +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 "SYS.h" - -#if defined(SYSLIBC_SCCS) - .text - .asciz "$OpenBSD$" -#endif /* SYSLIBC_SCCS */ - -#define SYS_syscall 0 - - -RSYSCALL(syscall) diff --git a/lib/libc/mipseb/Makefile.inc b/lib/libc/mipseb/Makefile.inc deleted file mode 100644 index 656b6dd..0000000 --- a/lib/libc/mipseb/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -.include "${.CURDIR}/../libc/mips/Makefile.inc" diff --git a/lib/libc/mipseb/SYS.h b/lib/libc/mipseb/SYS.h deleted file mode 100644 index ccce710..0000000 --- a/lib/libc/mipseb/SYS.h +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $OpenBSD: SYS.h,v 1.3 1996/07/30 20:27:48 pefo Exp $ - */ - -#include -#include - -#ifdef __STDC__ -#define RSYSCALL(x) \ - LEAF(x); \ - li v0,SYS_ ## x; \ - syscall; \ - bne a3,zero,err; \ - j ra; \ - err: la t9, cerror; \ - jr t9; \ - END(x); -#define PSEUDO(x,y) \ - LEAF(x); \ - li v0,SYS_ ## y; \ - syscall; \ - bne a3,zero,err; \ - j ra; \ - err: la t9, cerror; \ - jr t9; \ - END(x); -#else -#define RSYSCALL(x) \ - LEAF(x); \ - li v0,SYS_/**/x; \ - syscall; \ - bne a3,zero,err; \ - j ra; \ - err: la t9, cerror; \ - jr t9; \ - END(x); -#define PSEUDO(x,y) \ - LEAF(x); \ - li v0,SYS_/**/y; \ - syscall; \ - bne a3,zero,err; \ - j ra; \ - err: la t9, cerror; \ - jr t9; \ - END(x); -#endif diff --git a/lib/libc/mipseb/gen/Makefile.inc b/lib/libc/mipseb/gen/Makefile.inc deleted file mode 100644 index 157d1a4..0000000 --- a/lib/libc/mipseb/gen/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -.include "${.CURDIR}/../libc/mips/gen/Makefile.inc" diff --git a/lib/libc/mipseb/net/Makefile.inc b/lib/libc/mipseb/net/Makefile.inc deleted file mode 100644 index 6d330b0..0000000 --- a/lib/libc/mipseb/net/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -.include "${.CURDIR}/../libc/mips/net/Makefile.inc" diff --git a/lib/libc/mipseb/stdlib/Makefile.inc b/lib/libc/mipseb/stdlib/Makefile.inc deleted file mode 100644 index 9a9462b..0000000 --- a/lib/libc/mipseb/stdlib/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -.include "${.CURDIR}/../libc/mips/stdlib/Makefile.inc" diff --git a/lib/libc/mipseb/string/Makefile.inc b/lib/libc/mipseb/string/Makefile.inc deleted file mode 100644 index 302acfd..0000000 --- a/lib/libc/mipseb/string/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -.include "${.CURDIR}/../libc/mips/string/Makefile.inc" diff --git a/lib/libc/mipseb/sys/Makefile.inc b/lib/libc/mipseb/sys/Makefile.inc deleted file mode 100644 index 1fe51f5..0000000 --- a/lib/libc/mipseb/sys/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -.include "${.CURDIR}/../libc/mips/sys/Makefile.inc" diff --git a/lib/libc/mipsel/Makefile.inc b/lib/libc/mipsel/Makefile.inc deleted file mode 100644 index 656b6dd..0000000 --- a/lib/libc/mipsel/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -.include "${.CURDIR}/../libc/mips/Makefile.inc" diff --git a/lib/libc/mipsel/SYS.h b/lib/libc/mipsel/SYS.h deleted file mode 100644 index ccce710..0000000 --- a/lib/libc/mipsel/SYS.h +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $OpenBSD: SYS.h,v 1.3 1996/07/30 20:27:48 pefo Exp $ - */ - -#include -#include - -#ifdef __STDC__ -#define RSYSCALL(x) \ - LEAF(x); \ - li v0,SYS_ ## x; \ - syscall; \ - bne a3,zero,err; \ - j ra; \ - err: la t9, cerror; \ - jr t9; \ - END(x); -#define PSEUDO(x,y) \ - LEAF(x); \ - li v0,SYS_ ## y; \ - syscall; \ - bne a3,zero,err; \ - j ra; \ - err: la t9, cerror; \ - jr t9; \ - END(x); -#else -#define RSYSCALL(x) \ - LEAF(x); \ - li v0,SYS_/**/x; \ - syscall; \ - bne a3,zero,err; \ - j ra; \ - err: la t9, cerror; \ - jr t9; \ - END(x); -#define PSEUDO(x,y) \ - LEAF(x); \ - li v0,SYS_/**/y; \ - syscall; \ - bne a3,zero,err; \ - j ra; \ - err: la t9, cerror; \ - jr t9; \ - END(x); -#endif diff --git a/lib/libc/mipsel/gen/Makefile.inc b/lib/libc/mipsel/gen/Makefile.inc deleted file mode 100644 index 157d1a4..0000000 --- a/lib/libc/mipsel/gen/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -.include "${.CURDIR}/../libc/mips/gen/Makefile.inc" diff --git a/lib/libc/mipsel/net/Makefile.inc b/lib/libc/mipsel/net/Makefile.inc deleted file mode 100644 index 6d330b0..0000000 --- a/lib/libc/mipsel/net/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -.include "${.CURDIR}/../libc/mips/net/Makefile.inc" diff --git a/lib/libc/mipsel/stdlib/Makefile.inc b/lib/libc/mipsel/stdlib/Makefile.inc deleted file mode 100644 index 9a9462b..0000000 --- a/lib/libc/mipsel/stdlib/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -.include "${.CURDIR}/../libc/mips/stdlib/Makefile.inc" diff --git a/lib/libc/mipsel/string/Makefile.inc b/lib/libc/mipsel/string/Makefile.inc deleted file mode 100644 index 302acfd..0000000 --- a/lib/libc/mipsel/string/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -.include "${.CURDIR}/../libc/mips/string/Makefile.inc" diff --git a/lib/libc/mipsel/sys/Makefile.inc b/lib/libc/mipsel/sys/Makefile.inc deleted file mode 100644 index 1fe51f5..0000000 --- a/lib/libc/mipsel/sys/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -.include "${.CURDIR}/../libc/mips/sys/Makefile.inc" diff --git a/lib/libc/net/Makefile.inc b/lib/libc/net/Makefile.inc deleted file mode 100644 index 22c4010..0000000 --- a/lib/libc/net/Makefile.inc +++ /dev/null @@ -1,82 +0,0 @@ -# from @(#)Makefile.inc 8.2 (Berkeley) 9/5/93 -# $FreeBSD$ - -# machine-independent net sources -.PATH: ${.CURDIR}/../libc/${MACHINE_ARCH}/net ${.CURDIR}/../libc/net - -SRCS+= addr2ascii.c ascii2addr.c base64.c ether_addr.c getaddrinfo.c \ - gethostbydns.c gethostbyht.c gethostbynis.c gethostnamadr.c \ - getnameinfo.c \ - getnetbydns.c getnetbyht.c getnetbynis.c getnetnamadr.c \ - getproto.c getprotoent.c getprotoname.c getservbyname.c \ - getservbyport.c getservent.c herror.c inet_addr.c ifname.c \ - inet_lnaof.c \ - inet_makeaddr.c inet_net_ntop.c inet_net_pton.c inet_neta.c \ - inet_netof.c inet_network.c inet_ntoa.c inet_ntop.c \ - inet_pton.c ip6opt.c linkaddr.c map_v4v6.c name6.c ns_addr.c \ - ns_name.c ns_netint.c \ - ns_ntoa.c ns_parse.c ns_print.c ns_ttl.c nsap_addr.c \ - rcmd.c recv.c res_comp.c res_data.c res_debug.c \ - res_init.c res_mkquery.c res_mkupdate.c res_query.c res_send.c \ - res_update.c rthdr.c send.c vars.c -# not supported: iso_addr.c - -CFLAGS+=-DINET6 - -# machine-dependent net sources -.include "${.CURDIR}/../libc/${MACHINE_ARCH}/net/Makefile.inc" - -.if ${LIB} == "c" -MAN3+= addr2ascii.3 byteorder.3 ethers.3 getaddrinfo.3 gethostbyname.3 \ - getipnodebyname.3 \ - getnameinfo.3 getnetent.3 getprotoent.3 getservent.3 if_indextoname.3 \ - inet.3 inet6_option_space.3 inet6_rthdr_space.3 linkaddr.3 \ - rcmd.3 resolver.3 -# not installed: iso_addr.3 ns.3 - -MLINKS+=addr2ascii.3 ascii2addr.3 -MLINKS+=byteorder.3 htonl.3 byteorder.3 htons.3 byteorder.3 ntohl.3 \ - byteorder.3 ntohs.3 -MLINKS+=ethers.3 ether_aton.3 ethers.3 ether_hostton.3 ethers.3 ether_line.3 \ - ethers.3 ether_ntoa.3 ethers.3 ether_ntohost.3 -MLINKS+=getaddrinfo.3 freeaddrinfo.3 getaddrinfo.3 gai_strerror.3 -MLINKS+=gethostbyname.3 endhostent.3 gethostbyname.3 gethostbyaddr.3 \ - gethostbyname.3 gethostbyname2.3 gethostbyname.3 gethostent.3 \ - gethostbyname.3 herror.3 gethostbyname.3 hstrerror.3 \ - gethostbyname.3 sethostent.3 -MLINKS+=getipnodebyname.3 getipnodebyaddr.3 getipnodebyname.3 freehostent.3 -MLINKS+=getnetent.3 endnetent.3 getnetent.3 getnetbyaddr.3 \ - getnetent.3 getnetbyname.3 getnetent.3 setnetent.3 -MLINKS+=getprotoent.3 endprotoent.3 getprotoent.3 getprotobyname.3 \ - getprotoent.3 getprotobynumber.3 getprotoent.3 setprotoent.3 -MLINKS+=getservent.3 endservent.3 getservent.3 getservbyname.3 \ - getservent.3 getservbyport.3 getservent.3 setservent.3 -MLINKS+=if_indextoname.3 if_nametoindex.3 if_indextoname.3 if_nameindex.3 \ - if_indextoname.3 if_freenameindex.3 -MLINKS+=inet.3 addr.3 inet.3 inet_addr.3 inet.3 inet_aton.3 \ - inet.3 inet_lnaof.3 inet.3 inet_makeaddr.3 inet.3 inet_netof.3 \ - inet.3 inet_network.3 inet.3 inet_ntoa.3 \ - inet.3 inet_ntop.3 inet.3 inet_pton.3 \ - inet.3 network.3 inet.3 ntoa.3 -MLINKS+=inet6_option_space.3 inet6_option_alloc.3 \ - inet6_option_space.3 inet6_option_append.3 \ - inet6_option_space.3 inet6_option_find.3 \ - inet6_option_space.3 inet6_option_init.3 \ - inet6_option_space.3 inet6_option_next.3 \ - inet6_rthdr_space.3 inet6_rthdr_add.3 \ - inet6_rthdr_space.3 inet6_rthdr_getaddr.3 \ - inet6_rthdr_space.3 inet6_rthdr_getflags.3 \ - inet6_rthdr_space.3 inet6_rthdr_init.3 \ - inet6_rthdr_space.3 inet6_rthdr_lasthop.3 \ - inet6_rthdr_space.3 inet6_rthdr_reverse.3 \ - inet6_rthdr_space.3 inet6_rthdr_segments.3 -MLINKS+=linkaddr.3 link_addr.3 linkaddr.3 link_ntoa.3 -#MLINKS+=ns.3 ns_addr.3 ns.3 ns_ntoa.3 -MLINKS+=rcmd.3 iruserok.3 rcmd.3 iruserok_sa.3 \ - rcmd.3 rcmd_af.3 \ - rcmd.3 rresvport.3 rcmd.3 rresvport_af.3 \ - rcmd.3 ruserok.3 -MLINKS+=resolver.3 dn_comp.3 resolver.3 dn_expand.3 resolver.3 res_init.3 \ - resolver.3 res_mkquery.3 resolver.3 res_query.3 \ - resolver.3 res_search.3 resolver.3 res_send.3 -.endif diff --git a/lib/libc/net/addr2ascii.3 b/lib/libc/net/addr2ascii.3 deleted file mode 100644 index b5ec167..0000000 --- a/lib/libc/net/addr2ascii.3 +++ /dev/null @@ -1,217 +0,0 @@ -.\" -.\" Copyright 1996 Massachusetts Institute of Technology -.\" -.\" Permission to use, copy, modify, and distribute this software and -.\" its documentation for any purpose and without fee is hereby -.\" granted, provided that both the above copyright notice and this -.\" permission notice appear in all copies, that both the above -.\" copyright notice and this permission notice appear in all -.\" supporting documentation, and that the name of M.I.T. not be used -.\" in advertising or publicity pertaining to distribution of the -.\" software without specific, written prior permission. M.I.T. makes -.\" no representations about the suitability of this software for any -.\" purpose. It is provided "as is" without express or implied -.\" warranty. -.\" -.\" THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS -.\" ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, -.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT -.\" SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -.\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $ANA: addr2ascii.3,v 1.1 1996/06/13 18:41:46 wollman Exp $ -.\" $FreeBSD$ -.\" -.Dd June 13, 1996 -.Dt ADDR2ASCII 3 -.Os -.Sh NAME -.Nm addr2ascii , -.Nm ascii2addr -.Nd Generic address formatting routines -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Fd #include -.Ft "char *" -.Fn addr2ascii "int af" "const void *addrp" "int len" "char *buf" -.Ft int -.Fn ascii2addr "int af" "const char *ascii" "void *result" -.Sh DESCRIPTION -The routines -.Fn addr2ascii -and -.Fn ascii2addr -are used to convert network addresses between binary form and a -printable form appropriate to the address family. Both functions take -an -.Fa af -argument, specifying the address family to be used in the conversion -process. -(Currently, only the -.Dv AF_INET -and -.Dv AF_LINK -address families are supported.) -.Pp -The -.Fn addr2ascii -function -is used to convert binary, network-format addresses into printable -form. In addition to -.Fa af , -there are three other arguments. The -.Fa addrp -argument is a pointer to the network address to be converted. -The -.Fa len -argument is the length of the address. The -.Fa buf -argument is an optional pointer to a caller-allocated buffer to hold -the result; if a null pointer is passed, -.Fn addr2ascii -uses a statically-allocated buffer. -.Pp -The -.Fn ascii2addr -function performs the inverse operation to -.Fn addr2ascii . -In addition to -.Fa af , -it takes two parameters, -.Fa ascii -and -.Fa result . -The -.Fa ascii -parameter is a pointer to the string which is to be converted into -binary. The -.Fa result -parameter is a pointer to an appropriate network address structure for -the specified family. -.Pp -The following gives the appropriate structure to use for binary -addresses in the specified family: -.Pp -.Bl -tag -width AF_INETxxxx -compact -.It Dv AF_INET -.Li struct in_addr -.Pq in Aq Pa netinet/in.h -.It Dv AF_LINK -.Li struct sockaddr_dl -.Pq in Aq Pa net/if_dl.h -.\" .It Dv AF_INET6 -.\" .Li struct in6_addr -.\" .Pq in Aq Pa netinet6/in6.h -.El -.Sh RETURN VALUES -The -.Fn addr2ascii -function returns the address of the buffer it was passed, or a static -buffer if the a null pointer was passed; on failure, it returns a null -pointer. -The -.Fn ascii2addr -function returns the length of the binary address in bytes, or -1 on -failure. -.Sh EXAMPLES -The -.Xr inet 3 -functions -.Fn inet_ntoa -and -.Fn inet_aton -could be implemented thusly: -.Bd -literal -offset indent -#include -#include -#include -#include - -char * -inet_ntoa(struct in_addr addr) -{ - return addr2ascii(AF_INET, &addr, sizeof addr, 0); -} - -int -inet_aton(const char *ascii, struct in_addr *addr) -{ - return (ascii2addr(AF_INET, ascii, addr) - == sizeof(*addr)); -} -.Ed -.Pp -In actuality, this cannot be done because -.Fn addr2ascii -and -.Fn ascii2addr -are implemented in terms of the -.Xr inet 3 -functions, rather than the other way around. -.Sh ERRORS -When a failure is returned, -.Li errno -is set to one of the following values: -.Bl -tag -width [EPROTONOSUPPORT] -.It Bq Er ENAMETOOLONG -The -.Fn addr2ascii -routine was passed a -.Fa len -parameter which was inappropriate for the address family given by -.Fa af . -.It Bq Er EPROTONOSUPPORT -Either routine was passed an -.Fa af -parameter other than -.Dv AF_INET -or -.Dv AF_LINK . -.It Bq Er EINVAL -The string passed to -.Fn ascii2addr -was improperly formatted for address family -.Fa af . -.El -.Sh SEE ALSO -.Xr inet 3 , -.Xr linkaddr 3 , -.Xr inet 4 -.Sh HISTORY -An interface close to this one was originally suggested by Craig -Partridge. This particular interface originally appeared in the -.Tn INRIA -.Tn IPv6 -implementation. -.Sh AUTHORS -Code and documentation by -.An Garrett A. Wollman , -MIT Laboratory for Computer Science. -.Sh BUGS -The original implementations supported IPv6. This support should -eventually be resurrected. The -.Tn NRL -implementation also included support for the -.Dv AF_ISO -and -.Dv AF_NS -address families. -.Pp -The genericity of this interface is somewhat questionable. A truly -generic interface would provide a means for determining the length of -the buffer to be used so that it could be dynamically allocated, and -would always require a -.Dq Li "struct sockaddr" -to hold the binary address. Unfortunately, this is incompatible with existing -practice. This limitation means that a routine for printing network -addresses from arbitrary address families must still have internal -knowledge of the maximum buffer length needed and the appropriate part -of the address to use as the binary address. diff --git a/lib/libc/net/addr2ascii.c b/lib/libc/net/addr2ascii.c deleted file mode 100644 index 5bee3ea..0000000 --- a/lib/libc/net/addr2ascii.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 1996 Massachusetts Institute of Technology - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby - * granted, provided that both the above copyright notice and this - * permission notice appear in all copies, that both the above - * copyright notice and this permission notice appear in all - * supporting documentation, and that the name of M.I.T. not be used - * in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. M.I.T. makes - * no representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied - * warranty. - * - * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS - * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT - * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $ANA: addr2ascii.c,v 1.1 1996/06/13 18:41:46 wollman Exp $ - */ - -#include -#include - -#include -#include - -#include -#include -#include - -/*- - * Convert a network address from binary to printable numeric format. - * This API is copied from INRIA's IPv6 implementation, but it is a - * bit bogus in two ways: - * - * 1) There is no value in passing both an address family and - * an address length; either one should imply the other, - * or we should be passing sockaddrs instead. - * 2) There should by contrast be /added/ a length for the buffer - * that we pass in, so that programmers are spared the need to - * manually calculate (read: ``guess'') the maximum length. - * - * Flash: the API is also the same in the NRL implementation, and seems to - * be some sort of standard, so we appear to be stuck with both the bad - * naming and the poor choice of arguments. - */ -char * -addr2ascii(af, addrp, len, buf) - int af; - const void *addrp; - int len; /* should be size_t XXX */ - char *buf; /* XXX should pass length of buffer */ -{ - static char staticbuf[64]; /* 64 for AF_LINK > 16 for AF_INET */ - - if (!buf) - buf = staticbuf; - - switch(af) { - case AF_INET: - if (len != sizeof(struct in_addr)) { - errno = ENAMETOOLONG; - return 0; - } - strcpy(buf, inet_ntoa(*(const struct in_addr *)addrp)); - break; - - case AF_LINK: - if (len != sizeof(struct sockaddr_dl)) { - errno = ENAMETOOLONG; - return 0; - } - strcpy(buf, link_ntoa((const struct sockaddr_dl *)addrp)); - break; - - default: - errno = EPROTONOSUPPORT; - return 0; - } - return buf; -} diff --git a/lib/libc/net/ascii2addr.c b/lib/libc/net/ascii2addr.c deleted file mode 100644 index 0b5bab4..0000000 --- a/lib/libc/net/ascii2addr.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 1996 Massachusetts Institute of Technology - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby - * granted, provided that both the above copyright notice and this - * permission notice appear in all copies, that both the above - * copyright notice and this permission notice appear in all - * supporting documentation, and that the name of M.I.T. not be used - * in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. M.I.T. makes - * no representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied - * warranty. - * - * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS - * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT - * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $ANA: ascii2addr.c,v 1.2 1996/06/13 18:46:02 wollman Exp $ - */ - -#include -#include - -#include -#include - -#include -#include -#include - -int -ascii2addr(af, ascii, result) - int af; - const char *ascii; - void *result; -{ - struct in_addr *ina; - char strbuf[4*sizeof("123")]; /* long enough for V4 only */ - - switch(af) { - case AF_INET: - ina = result; - strbuf[0] = '\0'; - strncat(strbuf, ascii, (sizeof strbuf)-1); - if (inet_aton(strbuf, ina)) - return sizeof(struct in_addr); - errno = EINVAL; - break; - - case AF_LINK: - link_addr(ascii, result); - /* oops... no way to detect failure */ - return sizeof(struct sockaddr_dl); - - default: - errno = EPROTONOSUPPORT; - break; - } - - return -1; -} diff --git a/lib/libc/net/base64.c b/lib/libc/net/base64.c deleted file mode 100644 index 1301b6a..0000000 --- a/lib/libc/net/base64.c +++ /dev/null @@ -1,316 +0,0 @@ -/* - * Copyright (c) 1996, 1998 by Internet Software Consortium. - * - * 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. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM 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. - */ - -/* - * Portions Copyright (c) 1995 by International Business Machines, Inc. - * - * International Business Machines, Inc. (hereinafter called IBM) grants - * permission under its copyrights to use, copy, modify, and distribute this - * Software with or without fee, provided that the above copyright notice and - * all paragraphs of this notice appear in all copies, and that the name of IBM - * not be used in connection with the marketing of any product incorporating - * the Software or modifications thereof, without specific, written prior - * permission. - * - * To the extent it has a right to do so, IBM grants an immunity from suit - * under its patents, if any, for the use, sale or manufacture of products to - * the extent that such products are used for performing Domain Name System - * dynamic updates in TCP/IP networks by means of the Software. No immunity is - * granted for any product per se or for any other function of any product. - * - * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, - * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN - * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. - */ - -#if !defined(LINT) && !defined(CODECENTER) -static char rcsid[] = "$FreeBSD$"; -#endif /* not lint */ - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#define Assert(Cond) if (!(Cond)) abort() - -static const char Base64[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -static const char Pad64 = '='; - -/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt) - The following encoding technique is taken from RFC 1521 by Borenstein - and Freed. It is reproduced here in a slightly edited form for - convenience. - - A 65-character subset of US-ASCII is used, enabling 6 bits to be - represented per printable character. (The extra 65th character, "=", - is used to signify a special processing function.) - - The encoding process represents 24-bit groups of input bits as output - strings of 4 encoded characters. Proceeding from left to right, a - 24-bit input group is formed by concatenating 3 8-bit input groups. - These 24 bits are then treated as 4 concatenated 6-bit groups, each - of which is translated into a single digit in the base64 alphabet. - - Each 6-bit group is used as an index into an array of 64 printable - characters. The character referenced by the index is placed in the - output string. - - Table 1: The Base64 Alphabet - - Value Encoding Value Encoding Value Encoding Value Encoding - 0 A 17 R 34 i 51 z - 1 B 18 S 35 j 52 0 - 2 C 19 T 36 k 53 1 - 3 D 20 U 37 l 54 2 - 4 E 21 V 38 m 55 3 - 5 F 22 W 39 n 56 4 - 6 G 23 X 40 o 57 5 - 7 H 24 Y 41 p 58 6 - 8 I 25 Z 42 q 59 7 - 9 J 26 a 43 r 60 8 - 10 K 27 b 44 s 61 9 - 11 L 28 c 45 t 62 + - 12 M 29 d 46 u 63 / - 13 N 30 e 47 v - 14 O 31 f 48 w (pad) = - 15 P 32 g 49 x - 16 Q 33 h 50 y - - Special processing is performed if fewer than 24 bits are available - at the end of the data being encoded. A full encoding quantum is - always completed at the end of a quantity. When fewer than 24 input - bits are available in an input group, zero bits are added (on the - right) to form an integral number of 6-bit groups. Padding at the - end of the data is performed using the '=' character. - - Since all base64 input is an integral number of octets, only the - ------------------------------------------------- - following cases can arise: - - (1) the final quantum of encoding input is an integral - multiple of 24 bits; here, the final unit of encoded - output will be an integral multiple of 4 characters - with no "=" padding, - (2) the final quantum of encoding input is exactly 8 bits; - here, the final unit of encoded output will be two - characters followed by two "=" padding characters, or - (3) the final quantum of encoding input is exactly 16 bits; - here, the final unit of encoded output will be three - characters followed by one "=" padding character. - */ - -int -b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize) { - size_t datalength = 0; - u_char input[3]; - u_char output[4]; - size_t i; - - while (2 < srclength) { - input[0] = *src++; - input[1] = *src++; - input[2] = *src++; - srclength -= 3; - - output[0] = input[0] >> 2; - output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); - output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); - output[3] = input[2] & 0x3f; - Assert(output[0] < 64); - Assert(output[1] < 64); - Assert(output[2] < 64); - Assert(output[3] < 64); - - if (datalength + 4 > targsize) - return (-1); - target[datalength++] = Base64[output[0]]; - target[datalength++] = Base64[output[1]]; - target[datalength++] = Base64[output[2]]; - target[datalength++] = Base64[output[3]]; - } - - /* Now we worry about padding. */ - if (0 != srclength) { - /* Get what's left. */ - input[0] = input[1] = input[2] = '\0'; - for (i = 0; i < srclength; i++) - input[i] = *src++; - - output[0] = input[0] >> 2; - output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); - output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); - Assert(output[0] < 64); - Assert(output[1] < 64); - Assert(output[2] < 64); - - if (datalength + 4 > targsize) - return (-1); - target[datalength++] = Base64[output[0]]; - target[datalength++] = Base64[output[1]]; - if (srclength == 1) - target[datalength++] = Pad64; - else - target[datalength++] = Base64[output[2]]; - target[datalength++] = Pad64; - } - if (datalength >= targsize) - return (-1); - target[datalength] = '\0'; /* Returned value doesn't count \0. */ - return (datalength); -} - -/* skips all whitespace anywhere. - converts characters, four at a time, starting at (or after) - src from base - 64 numbers into three 8 bit bytes in the target area. - it returns the number of data bytes stored at the target, or -1 on error. - */ - -int -b64_pton(src, target, targsize) - char const *src; - u_char *target; - size_t targsize; -{ - int tarindex, state, ch; - char *pos; - - state = 0; - tarindex = 0; - - while ((ch = *src++) != '\0') { - if (isspace((unsigned char)ch)) /* Skip whitespace anywhere. */ - continue; - - if (ch == Pad64) - break; - - pos = strchr(Base64, ch); - if (pos == 0) /* A non-base64 character. */ - return (-1); - - switch (state) { - case 0: - if (target) { - if ((size_t)tarindex >= targsize) - return (-1); - target[tarindex] = (pos - Base64) << 2; - } - state = 1; - break; - case 1: - if (target) { - if ((size_t)tarindex + 1 >= targsize) - return (-1); - target[tarindex] |= (pos - Base64) >> 4; - target[tarindex+1] = ((pos - Base64) & 0x0f) - << 4 ; - } - tarindex++; - state = 2; - break; - case 2: - if (target) { - if ((size_t)tarindex + 1 >= targsize) - return (-1); - target[tarindex] |= (pos - Base64) >> 2; - target[tarindex+1] = ((pos - Base64) & 0x03) - << 6; - } - tarindex++; - state = 3; - break; - case 3: - if (target) { - if ((size_t)tarindex >= targsize) - return (-1); - target[tarindex] |= (pos - Base64); - } - tarindex++; - state = 0; - break; - default: - abort(); - } - } - - /* - * We are done decoding Base-64 chars. Let's see if we ended - * on a byte boundary, and/or with erroneous trailing characters. - */ - - if (ch == Pad64) { /* We got a pad char. */ - ch = *src++; /* Skip it, get next. */ - switch (state) { - case 0: /* Invalid = in first position */ - case 1: /* Invalid = in second position */ - return (-1); - - case 2: /* Valid, means one byte of info */ - /* Skip any number of spaces. */ - for ((void)NULL; ch != '\0'; ch = *src++) - if (!isspace((unsigned char)ch)) - break; - /* Make sure there is another trailing = sign. */ - if (ch != Pad64) - return (-1); - ch = *src++; /* Skip the = */ - /* Fall through to "single trailing =" case. */ - /* FALLTHROUGH */ - - case 3: /* Valid, means two bytes of info */ - /* - * We know this char is an =. Is there anything but - * whitespace after it? - */ - for ((void)NULL; ch != '\0'; ch = *src++) - if (!isspace((unsigned char)ch)) - return (-1); - - /* - * Now make sure for cases 2 and 3 that the "extra" - * bits that slopped past the last full byte were - * zeros. If we don't check them, they become a - * subliminal channel. - */ - if (target && target[tarindex] != 0) - return (-1); - } - } else { - /* - * We ended by seeing the end of the string. Make sure we - * have no partial bytes lying around. - */ - if (state != 0) - return (-1); - } - - return (tarindex); -} diff --git a/lib/libc/net/byteorder.3 b/lib/libc/net/byteorder.3 deleted file mode 100644 index 3c55d21c..0000000 --- a/lib/libc/net/byteorder.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" Copyright (c) 1983, 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. -.\" -.\" @(#)byteorder.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt BYTEORDER 3 -.Os BSD 4.2 -.Sh NAME -.Nm htonl , -.Nm htons , -.Nm ntohl , -.Nm ntohs -.Nd convert values between host and network byte order -.Sh SYNOPSIS -.Fd #include -.Ft u_long -.Fn htonl "u_long hostlong" -.Ft u_short -.Fn htons "u_short hostshort" -.Ft u_long -.Fn ntohl "u_long netlong" -.Ft u_short -.Fn ntohs "u_short netshort" -.Sh DESCRIPTION -These routines convert 16 and 32 bit quantities between network -byte order and host byte order. -On machines which have a byte order which is the same as the network -order, routines are defined as null macros. -.Pp -These routines are most often used in conjunction with Internet -addresses and ports as returned by -.Xr gethostbyname 3 -and -.Xr getservent 3 . -.Sh SEE ALSO -.Xr gethostbyname 3 , -.Xr getservent 3 -.Sh HISTORY -The -.Nm byteorder -functions appeared in -.Bx 4.2 . -.Sh BUGS -On the -.Tn VAX -bytes are handled backwards from most everyone else in -the world. This is not expected to be fixed in the near future. diff --git a/lib/libc/net/ether_addr.c b/lib/libc/net/ether_addr.c deleted file mode 100644 index 89aa7b5..0000000 --- a/lib/libc/net/ether_addr.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (c) 1995 - * Bill Paul . All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Bill Paul. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * ethernet address conversion and lookup routines - * - * Written by Bill Paul - * Center for Telecommunications Research - * Columbia University, New York City - * - * $FreeBSD$ - */ - - -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef YP -#include -#include -#include -#endif - -#ifndef _PATH_ETHERS -#define _PATH_ETHERS "/etc/ethers" -#endif - -/* - * Parse a string of text containing an ethernet address and hostname - * and separate it into its component parts. - */ -int ether_line(l, e, hostname) - char *l; - struct ether_addr *e; - char *hostname; -{ - int i, o[6]; - - i = sscanf(l, "%x:%x:%x:%x:%x:%x %s", &o[0], &o[1], &o[2], - &o[3], &o[4], &o[5], - hostname); - if (i != 7) - return (i); - - for (i=0; i<6; i++) - e->octet[i] = o[i]; - return (0); -} - -/* - * Convert an ASCII representation of an ethernet address to - * binary form. - */ -struct ether_addr *ether_aton(a) - char *a; -{ - int i; - static struct ether_addr o; - unsigned int o0, o1, o2, o3, o4, o5; - - i = sscanf(a, "%x:%x:%x:%x:%x:%x", &o0, &o1, &o2, &o3, &o4, &o5); - - if (i != 6) - return (NULL); - - o.octet[0]=o0; - o.octet[1]=o1; - o.octet[2]=o2; - o.octet[3]=o3; - o.octet[4]=o4; - o.octet[5]=o5; - - return ((struct ether_addr *)&o); -} - -/* - * Convert a binary representation of an ethernet address to - * an ASCII string. - */ -char *ether_ntoa(n) - struct ether_addr *n; -{ - int i; - static char a[18]; - - i = sprintf(a,"%x:%x:%x:%x:%x:%x",n->octet[0],n->octet[1],n->octet[2], - n->octet[3],n->octet[4],n->octet[5]); - if (i < 11) - return (NULL); - return ((char *)&a); -} - -/* - * Map an ethernet address to a hostname. Use either /etc/ethers or - * NIS/YP. - */ - -int ether_ntohost(hostname, e) - char *hostname; - struct ether_addr *e; -{ - FILE *fp; - char buf[BUFSIZ + 2]; - struct ether_addr local_ether; - char local_host[MAXHOSTNAMELEN]; -#ifdef YP - char *result; - int resultlen; - char *ether_a; - char *yp_domain; -#endif - if ((fp = fopen(_PATH_ETHERS, "r")) == NULL) - return (1); - - while (fgets(buf,BUFSIZ,fp)) { - if (buf[0] == '#') - continue; -#ifdef YP - if (buf[0] == '+') { - if (yp_get_default_domain(&yp_domain)) - continue; - ether_a = ether_ntoa(e); - if (yp_match(yp_domain, "ethers.byaddr", ether_a, - strlen(ether_a), &result, &resultlen)) { - continue; - } - strncpy(buf, result, resultlen); - buf[resultlen] = '\0'; - free(result); - } -#endif - if (!ether_line(buf, &local_ether, local_host)) { - if (!bcmp((char *)&local_ether.octet[0], - (char *)&e->octet[0], 6)) { - /* We have a match */ - strcpy(hostname, local_host); - fclose(fp); - return(0); - } - } - } - fclose(fp); - return (1); -} - -/* - * Map a hostname to an ethernet address using /etc/ethers or - * NIS/YP. - */ -int ether_hostton(hostname, e) - char *hostname; - struct ether_addr *e; -{ - FILE *fp; - char buf[BUFSIZ + 2]; - struct ether_addr local_ether; - char local_host[MAXHOSTNAMELEN]; -#ifdef YP - char *result; - int resultlen; - char *yp_domain; -#endif - if ((fp = fopen(_PATH_ETHERS, "r")) == NULL) - return (1); - - while (fgets(buf,BUFSIZ,fp)) { - if (buf[0] == '#') - continue; -#ifdef YP - if (buf[0] == '+') { - if (yp_get_default_domain(&yp_domain)) - continue; - if (yp_match(yp_domain, "ethers.byname", hostname, - strlen(hostname), &result, &resultlen)) { - continue; - } - strncpy(buf, result, resultlen); - buf[resultlen] = '\0'; - free(result); - } -#endif - if (!ether_line(buf, &local_ether, local_host)) { - if (!strcmp(hostname, local_host)) { - /* We have a match */ - bcopy((char *)&local_ether.octet[0], - (char *)&e->octet[0], 6); - fclose(fp); - return(0); - } - } - } - fclose(fp); - return (1); -} diff --git a/lib/libc/net/ethers.3 b/lib/libc/net/ethers.3 deleted file mode 100644 index 72b7488..0000000 --- a/lib/libc/net/ethers.3 +++ /dev/null @@ -1,196 +0,0 @@ -.\" Copyright (c) 1995 -.\" Bill Paul . All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by Bill Paul. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd April 12, 1995 -.Dt ETHERS 3 -.Os FreeBSD 2.1 -.Sh NAME -.Nm ethers , -.Nm ether_line , -.Nm ether_aton , -.Nm ether_ntoa , -.Nm ether_ntohost , -.Nm ether_hostton -.Nd Ethernet address conversion and lookup routines -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Fd #include -.Ft int -.Fn ether_line "char *l" "struct ether_addr *e" "char *hostname" -.Ft struct ether_addr * -.Fn ether_aton "char *a" -.Ft char * -.Fn ether_ntoa "struct ether_addr *n" -.Ft int -.Fn ether_ntohost "char *hostname" "struct ether_addr *e" -.Ft int -.Fn ether_hostton "char *hostname" "struct ether_addr *e" -.Sh DESCRIPTION -These functions operate on ethernet addresses using an -.Ar ether_addr -structure, which is defined in the header file -.Aq Pa netinet/if_ether.h : -.Bd -literal -offset indent -/* - * The number of bytes in an ethernet (MAC) address. - */ -#define ETHER_ADDR_LEN 6 - -/* - * Structure of a 48-bit Ethernet address. - */ -struct ether_addr { - u_char octet[ETHER_ADDR_LEN]; -}; -.Ed -.Pp -The function -.Fn ether_line -scans -.Ar l , -an -.Tn ASCII -string in -.Xr ethers 5 -format and sets -.Ar e -to the ethernet address specified in the string and -.Ar h -to the hostname. -This function is used to parse lines from -.Pa /etc/ethers -into their component parts. -.Pp -The -.Fn ether_aton -function converts an -.Tn ASCII -representation of an ethernet address into an -.Ar ether_addr -structure. -Likewise, -.Fn ether_ntoa -converts an ethernet address specified as an -.Ar ether_addr -structure into an -.Tn ASCII -string. -.Pp -The -.Fn ether_ntohost -and -.Fn ether_hostton -functions map ethernet addresses to their corresponding hostnames -as specified in the -.Pa /etc/ethers -database. -.Fn ether_ntohost -converts from ethernet address to hostname, and -.Fn ether_hostton -converts from hostname to ethernet address. -.Sh RETURN VALUES -.Fn ether_line -returns zero on success and non-zero if it was unable to parse -any part of the supplied line -.Ar l . -It returns the extracted ethernet address in the supplied -.Ar ether_addr -structure -.Ar e -and the hostname in the supplied string -.Ar h . -.Pp -On success, -.Fn ether_ntoa -returns a pointer to a string containing an -.Tn ASCII -representation of an ethernet address. -If it is unable to convert -the supplied -.Ar ether_addr -structure, it returns a -.Dv NULL -pointer. -Likewise, -.Fn ether_aton -returns a pointer to an -.Ar ether_addr -structure on success and a -.Dv NULL -pointer on failure. -.Pp -The -.Fn ether_ntohost -and -.Fn ether_hostton -functions both return zero on success or non-zero if they were -unable to find a match in the -.Pa /etc/ethers -database. -.Sh NOTES -The user must insure that the hostname strings passed to the -.Fn ether_line , -.Fn ether_ntohost -and -.Fn ether_hostton -functions are large enough to contain the returned hostnames. -.Sh NIS INTERACTION -If the -.Pa /etc/ethers -contains a line with a single + in it, the -.Fn ether_ntohost -and -.Fn ether_hostton -functions will attempt to consult the NIS -.Pa ethers.byname -and -.Pa ethers.byaddr -maps in addition to the data in the -.Pa /etc/ethers -file. -.Sh SEE ALSO -.Xr yp 4 , -.Xr ethers 5 -.Sh BUGS -.Pp -The -.Fn ether_aton -and -.Fn ether_ntoa -functions returns values that are stored in static memory areas -which may be overwritten the next time they are called. -.Sh HISTORY -This particular implementation of the -.Nm ethers -library functions were written for and first appeared in -.Fx 2.1 . diff --git a/lib/libc/net/getaddrinfo.3 b/lib/libc/net/getaddrinfo.3 deleted file mode 100644 index 754a796..0000000 --- a/lib/libc/net/getaddrinfo.3 +++ /dev/null @@ -1,408 +0,0 @@ -.\" Copyright (c) 1983, 1987, 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. -.\" -.\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95 -.\" $Id: getaddrinfo.3,v 1.3 1999/10/07 08:22:04 jinmei Exp $ -.\" $FreeBSD$ -.\" -.Dd May 25, 1995 -.Dt GETADDRINFO 3 -.Os KAME -.\" -.Sh NAME -.Nm getaddrinfo -.Nm freeaddrinfo , -.Nm gai_strerror -.Nd nodename-to-address translation in protocol-independent manner -.\" -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Fd #include -.Ft int -.Fn getaddrinfo "const char *nodename" "const char *servname" "const struct addrinfo *hints" "struct addrinfo **res" -.Ft void -.Fn freeaddrinfo "struct addrinfo *ai" -.Ft "char *" -.Fn gai_strerror "int ecode" -.\" -.Sh DESCRIPTION -The -.Fn getaddrinfo -function is defined for protocol-independent nodename-to-address translation. -It performs functionality of -.Xr gethostbyname 3 -and -.Xr getservbyname 3 , -in more sophisticated manner. -.Pp -The addrinfo structure is defined as a result of including the -.Li -header: -.Bd -literal -offset -struct addrinfo { * - int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */ - int ai_family; /* PF_xxx */ - int ai_socktype; /* SOCK_xxx */ - int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ - size_t ai_addrlen; /* length of ai_addr */ - char *ai_canonname; /* canonical name for nodename */ - struct sockaddr *ai_addr; /* binary address */ - struct addrinfo *ai_next; /* next structure in linked list */ -}; -.Ed -.Pp -The -.Fa nodename -and -.Fa servname -arguments are pointers to null-terminated strings or -.Dv NULL . -One or both of these two arguments must be a -.Pf non Dv -NULL -pointer. -In the normal client scenario, both the -.Fa nodename -and -.Fa servname -are specified. -In the normal server scenario, only the -.Fa servname -is specified. -A -.Pf non Dv -NULL -.Fa nodename -string can be either a node name or a numeric host address string -.Po -i.e., a dotted-decimal IPv4 address or an IPv6 hex address -.Pc . -A -.Pf non Dv -NULL -.Fa servname -string can be either a service name or a decimal port number. -.Pp -The caller can optionally pass an -.Li addrinfo -structure, pointed to by the third argument, -to provide hints concerning the type of socket that the caller supports. -In this -.Fa hints -structure all members other than -.Fa ai_flags , -.Fa ai_family , -.Fa ai_socktype , -and -.Fa ai_protocol -must be zero or a -.Dv NULL -pointer. -A value of -.Dv PF_UNSPEC -for -.Fa ai_family -means the caller will accept any protocol family. -A value of 0 for -.Fa ai_socktype -means the caller will accept any socket type. -A value of 0 for -.Fa ai_protocol -means the caller will accept any protocol. -For example, if the caller handles only TCP and not UDP, then the -.Fa ai_socktype -member of the hints structure should be set to -.Dv SOCK_STREAM -when -.Fn getaddrinfo -is called. -If the caller handles only IPv4 and not IPv6, then the -.Fa ai_family -member of the -.Fa hints -structure should be set to -.Dv PF_INET -when -.Fn getaddrinfo -is called. -If the third argument to -.Fn getaddrinfo -is a -.Dv NULL -pointer, this is the same as if the caller had filled in an -.Li addrinfo -structure initialized to zero with -.Fa ai_family -set to PF_UNSPEC. -.Pp -Upon successful return a pointer to a linked list of one or more -.Li addrinfo -structures is returned through the final argument. -The caller can process each -.Li addrinfo -structure in this list by following the -.Fa ai_next -pointer, until a -.Dv NULL -pointer is encountered. -In each returned -.Li addrinfo -structure the three members -.Fa ai_family , -.Fa ai_socktype , -and -.Fa ai_protocol -are the corresponding arguments for a call to the -.Fn socket -function. -In each -.Li addrinfo -structure the -.Fa ai_addr -member points to a filled-in socket address structure whose length is -specified by the -.Fa ai_addrlen -member. -.Pp -If the -.Dv AI_PASSIVE -bit is set in the -.Fa ai_flags -member of the -.Fa hints -structure, then the caller plans to use the returned socket address -structure in a call to -.Fn bind . -In this case, if the -.Fa nodename -argument is a -.Dv NULL -pointer, then the IP address portion of the socket -address structure will be set to -.Dv INADDR_ANY -for an IPv4 address or -.Dv IN6ADDR_ANY_INIT -for an IPv6 address. -.Pp -If the -.Dv AI_PASSIVE -bit is not set in the -.Fa ai_flags -member of the -.Fa hints -structure, then the returned socket address structure will be ready for a -call to -.Fn connect -.Pq for a connection-oriented protocol -or either -.Fn connect , -.Fn sendto , or -.Fn sendmsg -.Pq for a connectionless protocol . -In this case, if the -.Fa nodename -argument is a -.Dv NULL -pointer, then the IP address portion of the -socket address structure will be set to the loopback address. -.Pp -If the -.Dv AI_CANONNAME -bit is set in the -.Fa ai_flags -member of the -.Fa hints -structure, then upon successful return the -.Fa ai_canonname -member of the first -.Li addrinfo -structure in the linked list will point to a null-terminated string -containing the canonical name of the specified -.Fa nodename . -.Pp -If the -.Dv AI_NUMERICHOST -bit is set in the -.Fa ai_flags -member of the -.Fa hints -structure, then a -.Pf non Dv -NULL -.Fa nodename -string must be a numeric host address string. -Otherwise an error of -.Dv EAI_NONAME -is returned. -This flag prevents any type of name resolution service (e.g., the DNS) -from being called. -.Pp -All of the information returned by -.Fn getaddrinfo -is dynamically allocated: -the -.Li addrinfo -structures, and the socket address structures and canonical node name -strings pointed to by the addrinfo structures. -To return this information to the system the function -.Fn freeaddrinfo -is called. -The -.Fa addrinfo -structure pointed to by the -.Fa ai argument -is freed, along with any dynamic storage pointed to by the structure. -This operation is repeated until a -.Dv NULL -.Fa ai_next -pointer is encountered. -.Pp -To aid applications in printing error messages based on the -.Dv EAI_xxx -codes returned by -.Fn getaddrinfo , -.Fn gai_strerror -is defined. -The argument is one of the -.Dv EAI_xxx -values defined earlier and the return value points to a string describing -the error. -If the argument is not one of the -.Dv EAI_xxx -values, the function still returns a pointer to a string whose contents -indicate an unknown error. -.\" -.Sh EXTENSION -The implementation allows experimental numeric IPv6 address notation with -scope identifier. -By appending atmark and scope identifier to addresses, you can fill -.Li sin6_scope_id -field for addresses. -This would make management of scoped address easier, -and allows cut-and-paste input of scoped address. -.Pp -At this moment the code supports only link-local addresses with the format. -Scope identifier is hardcoded to name of hardware interface associated -with the link. -.Po -such as -.Li ne0 -.Pc . -Example would be like -.Dq Li fe80::1@ne0 , -which means -.Do -.Li fe80::1 -on the link associated with -.Li ne0 -interface -.Dc . -.Pp -The implementation is still very experimental and non-standard. -The current implementation assumes one-by-one relationship between -interface and link, which is not necessarily true from the specification. -.\" -.Sh FILES -.Bl -tag -width /etc/resolv.conf -compact -.It Pa /etc/hosts -.It Pa /etc/host.conf -.It Pa /etc/resolv.conf -.El -.\" -.Sh DIAGNOSTICS -Error return status from -.Fn getaddrinfo -is zero on success and non-zero on errors. -Non-zero error codes are defined in -.Li , -and as follows: -.Pp -.Bl -tag -width EAI_ADDRFAMILY -compact -.It Dv EAI_ADDRFAMILY -address family for nodename not supported -.It Dv EAI_AGAIN -temporary failure in name resolution -.It Dv EAI_BADFLAGS -invalid value for ai_flags -.It Dv EAI_FAIL -non-recoverable failure in name resolution -.It Dv EAI_FAMILY -ai_family not supported -.It Dv EAI_MEMORY -memory allocation failure -.It Dv EAI_NODATA -no address associated with nodename -.It Dv EAI_NONAME -nodename nor servname provided, or not known -.It Dv EAI_SERVICE -servname not supported for ai_socktype -.It Dv EAI_SOCKTYPE -ai_socktype not supported -.It Dv EAI_SYSTEM -system error returned in errno -.El -.Pp -If called with proper argument, -.Fn gai_strerror -returns a pointer to a string describing the given error code. -If the argument is not one of the -.Dv EAI_xxx -values, the function still returns a pointer to a string whose contents -indicate an unknown error. -.\" -.Sh SEE ALSO -.Xr getnameinfo 3 , -.Xr gethostbyname 3 , -.Xr getservbyname 3 , -.Xr hosts 5 , -.Xr services 5 , -.Xr hostname 7 , -.Xr named 8 . -.Pp -.Rs -.%A R. Gilligan -.%A S. Thomson -.%A J. Bound -.%A W. Stevens -.%T Basic Socket Interface Extensions for IPv6 -.%R RFC2553 -.%D March 1999 -.Re -.\" -.Sh HISTORY -The implementation first appeared in WIDE Hydrangea IPv6 protocol stack kit. -.\" -.Sh STANDARDS -The -.Fn getaddrinfo -function is defined IEEE POSIX 1003.1g draft specification, -and documented in ``Basic Socket Interface Extensions for IPv6'' -.Pq RFC2533 . -.\" -.Sh BUGS -The text was shamelessly copied from RFC2553. diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c deleted file mode 100644 index a1f2726..0000000 --- a/lib/libc/net/getaddrinfo.c +++ /dev/null @@ -1,927 +0,0 @@ -/* - * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -/* - * "#ifdef FAITH" part is local hack for supporting IPv4-v6 translator. - * - * Issues to be discussed: - * - Thread safe-ness must be checked. - * - Return values. There are nonstandard return values defined and used - * in the source code. This is because RFC2553 is silent about which error - * code must be returned for which situation. - * Note: - * - We use getipnodebyname() just for thread-safeness. There's no intent - * to let it do PF_UNSPEC (actually we never pass PF_UNSPEC to - * getipnodebyname(). - * - The code filters out AFs that are not supported by the kernel, - * when globbing NULL hostname (to loopback, or wildcard). Is it the right - * thing to do? What is the relationship with post-RFC2553 AI_ADDRCONFIG - * in ai_flags? - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(__KAME__) && defined(INET6) -# define FAITH -#endif - -#define SUCCESS 0 -#define ANY 0 -#define YES 1 -#define NO 0 - -static const char in_addrany[] = { 0, 0, 0, 0 }; -static const char in6_addrany[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; -static const char in_loopback[] = { 127, 0, 0, 1 }; -static const char in6_loopback[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 -}; - -static const struct afd { - int a_af; - int a_addrlen; - int a_socklen; - int a_off; - const char *a_addrany; - const char *a_loopback; - int a_scoped; -} afdl [] = { -#ifdef INET6 -#define N_INET6 0 - {PF_INET6, sizeof(struct in6_addr), - sizeof(struct sockaddr_in6), - offsetof(struct sockaddr_in6, sin6_addr), - in6_addrany, in6_loopback, 1}, -#define N_INET 1 -#else -#define N_INET 0 -#endif - {PF_INET, sizeof(struct in_addr), - sizeof(struct sockaddr_in), - offsetof(struct sockaddr_in, sin_addr), - in_addrany, in_loopback, 0}, - {0, 0, 0, 0, NULL, NULL, 0}, -}; - -struct explore { - int e_af; - int e_socktype; - int e_protocol; - const char *e_protostr; - int e_wild; -#define WILD_AF(ex) ((ex)->e_wild & 0x01) -#define WILD_SOCKTYPE(ex) ((ex)->e_wild & 0x02) -#define WILD_PROTOCOL(ex) ((ex)->e_wild & 0x04) -}; - -static const struct explore explore[] = { -#ifdef INET6 - { PF_INET6, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 }, - { PF_INET6, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 }, - { PF_INET6, SOCK_RAW, ANY, NULL, 0x05 }, -#endif - { PF_INET, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 }, - { PF_INET, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 }, - { PF_INET, SOCK_RAW, ANY, NULL, 0x05 }, - { -1, 0, 0, NULL, 0 }, -}; - -#ifdef INET6 -#define PTON_MAX 16 -#else -#define PTON_MAX 4 -#endif - - -static int str_isnumber __P((const char *)); -static int explore_fqdn __P((const struct addrinfo *, const char *, - const char *, struct addrinfo **)); -static int explore_null __P((const struct addrinfo *, const char *, - const char *, struct addrinfo **)); -static int explore_numeric __P((const struct addrinfo *, const char *, - const char *, struct addrinfo **)); -static int explore_numeric_scope __P((const struct addrinfo *, const char *, - const char *, struct addrinfo **)); -static int get_canonname __P((const struct addrinfo *, - struct addrinfo *, const char *)); -static struct addrinfo *get_ai __P((const struct addrinfo *, - const struct afd *, const char *)); -static int get_portmatch __P((const struct addrinfo *, const char *)); -static int get_port __P((struct addrinfo *, const char *, int)); -static const struct afd *find_afd __P((int)); - -static char *ai_errlist[] = { - "Success", - "Address family for hostname not supported", /* EAI_ADDRFAMILY */ - "Temporary failure in name resolution", /* EAI_AGAIN */ - "Invalid value for ai_flags", /* EAI_BADFLAGS */ - "Non-recoverable failure in name resolution", /* EAI_FAIL */ - "ai_family not supported", /* EAI_FAMILY */ - "Memory allocation failure", /* EAI_MEMORY */ - "No address associated with hostname", /* EAI_NODATA */ - "hostname nor servname provided, or not known", /* EAI_NONAME */ - "servname not supported for ai_socktype", /* EAI_SERVICE */ - "ai_socktype not supported", /* EAI_SOCKTYPE */ - "System error returned in errno", /* EAI_SYSTEM */ - "Invalid value for hints", /* EAI_BADHINTS */ - "Resolved protocol is unknown", /* EAI_PROTOCOL */ - "Argument res is NULL", /* EAI_RESNULL */ - "Unknown error", /* EAI_MAX */ -}; - -/* XXX macros that make external reference is BAD. */ - -#define GET_AI(ai, afd, addr) \ -do { \ - /* external reference: pai, error, and label free */ \ - (ai) = get_ai(pai, (afd), (addr)); \ - if ((ai) == NULL) { \ - error = EAI_MEMORY; \ - goto free; \ - } \ -} while (0) - -#define GET_PORT(ai, serv) \ -do { \ - /* external reference: error and label free */ \ - error = get_port((ai), (serv), 0); \ - if (error != 0) \ - goto free; \ -} while (0) - -#define GET_CANONNAME(ai, str) \ -do { \ - /* external reference: pai, error and label free */ \ - error = get_canonname(pai, (ai), (str)); \ - if (error != 0) \ - goto free; \ -} while (0) - -#define ERR(err) \ -do { \ - /* external reference: error, and label bad */ \ - error = (err); \ - goto bad; \ -} while (0) - -#define MATCH_FAMILY(x, y, w) \ - ((x) == (y) || ((w) && ((x) == PF_UNSPEC || (y) == PF_UNSPEC))) -#define MATCH(x, y, w) \ - ((x) == (y) || ((w) && ((x) == ANY || (y) == ANY))) - -char * -gai_strerror(ecode) - int ecode; -{ - if (ecode < 0 || ecode > EAI_MAX) - ecode = EAI_MAX; - return ai_errlist[ecode]; -} - -void -freeaddrinfo(ai) - struct addrinfo *ai; -{ - struct addrinfo *next; - - do { - next = ai->ai_next; - if (ai->ai_canonname) - free(ai->ai_canonname); - /* no need to free(ai->ai_addr) */ - free(ai); - } while ((ai = next) != NULL); -} - -static int -str_isnumber(p) - const char *p; -{ - char *q = (char *)p; - while (*q) { - if (! isdigit(*q)) - return NO; - q++; - } - return YES; -} - -int -getaddrinfo(hostname, servname, hints, res) - const char *hostname, *servname; - const struct addrinfo *hints; - struct addrinfo **res; -{ - struct addrinfo sentinel; - struct addrinfo *cur; - int error = 0; - struct addrinfo ai; - struct addrinfo ai0; - struct addrinfo *pai; - const struct afd *afd; - const struct explore *ex; - - sentinel.ai_next = NULL; - cur = &sentinel; - pai = &ai; - pai->ai_flags = 0; - pai->ai_family = PF_UNSPEC; - pai->ai_socktype = ANY; - pai->ai_protocol = ANY; - pai->ai_addrlen = 0; - pai->ai_canonname = NULL; - pai->ai_addr = NULL; - pai->ai_next = NULL; - - if (hostname == NULL && servname == NULL) - return EAI_NONAME; - if (res == NULL) - return EAI_RESNULL; /* xxx */ - if (hints) { - /* error check for hints */ - if (hints->ai_addrlen || hints->ai_canonname || - hints->ai_addr || hints->ai_next) - ERR(EAI_BADHINTS); /* xxx */ - if (hints->ai_flags & ~AI_MASK) - ERR(EAI_BADFLAGS); - switch (hints->ai_family) { - case PF_UNSPEC: - case PF_INET: -#ifdef INET6 - case PF_INET6: -#endif - break; - default: - ERR(EAI_FAMILY); - } - memcpy(pai, hints, sizeof(*pai)); - - /* - * if both socktype/protocol are specified, check if they - * are meaningful combination. - */ - if (pai->ai_socktype != ANY && pai->ai_protocol != ANY) { - int matched = 0; - - for (ex = explore; ex->e_af >= 0; ex++) { - if (pai->ai_family != ex->e_af) - continue; - if (ex->e_socktype == ANY) - continue; - if (ex->e_protocol == ANY) - continue; - if (pai->ai_socktype == ex->e_socktype - && pai->ai_protocol == ex->e_protocol) - matched = 1; - else - continue; - if (matched == 0) - ERR(EAI_BADHINTS); - } - } - } - - /* backup original pai contents */ - ai0 = *pai; - - /* - * special cases check for inet and inet6 sockets. - * (1) servname is disallowed for raw sockets. - * (2) numeric servname is disallowed if socktype/protocol is left - * unspecified. - */ - if (MATCH_FAMILY(pai->ai_family, PF_INET, 1) -#ifdef INET6 - || MATCH_FAMILY(pai->ai_family, PF_INET6, 1) -#endif - ) { - *pai = ai0; - - if (pai->ai_family == PF_UNSPEC) -#ifdef INET6 - pai->ai_family = PF_INET6; -#else - pai->ai_family = PF_INET; -#endif - error = get_portmatch(pai, servname); - if (error) - ERR(error); - } - - /* NULL hostname, or numeric hostname */ - for (ex = explore; ex->e_af >= 0; ex++) { - *pai = ai0; - - if (!MATCH_FAMILY(pai->ai_family, ex->e_af, WILD_AF(ex))) - continue; - if (!MATCH(pai->ai_socktype, ex->e_socktype, WILD_SOCKTYPE(ex))) - continue; - if (!MATCH(pai->ai_protocol, ex->e_protocol, WILD_PROTOCOL(ex))) - continue; - - if (pai->ai_family == PF_UNSPEC) - pai->ai_family = ex->e_af; - if (pai->ai_socktype == ANY && ex->e_socktype != ANY) - pai->ai_socktype = ex->e_socktype; - if (pai->ai_protocol == ANY && ex->e_protocol != ANY) - pai->ai_protocol = ex->e_protocol; - - if (hostname == NULL) - error = explore_null(pai, hostname, servname, &cur->ai_next); - else - error = explore_numeric_scope(pai, hostname, servname, &cur->ai_next); - - if (error) - goto free; - - while (cur && cur->ai_next) - cur = cur->ai_next; - } - - /* - * XXX - * If numreic representation of AF1 can be interpreted as FQDN - * representation of AF2, we need to think again about the code below. - */ - if (sentinel.ai_next) - goto good; - - if (pai->ai_flags & AI_NUMERICHOST) - ERR(EAI_NONAME); - if (hostname == NULL) - ERR(EAI_NONAME); - - /* - * hostname as alphabetical name. - * we would like to prefer AF_INET6 than AF_INET, so we'll make a - * outer loop by AFs. - */ - for (afd = afdl; afd->a_af; afd++) { - *pai = ai0; - - if (!MATCH_FAMILY(pai->ai_family, afd->a_af, 1)) - continue; - - for (ex = explore; ex->e_af >= 0; ex++) { - *pai = ai0; - - if (pai->ai_family == PF_UNSPEC) - pai->ai_family = afd->a_af; - - if (!MATCH_FAMILY(pai->ai_family, ex->e_af, - WILD_AF(ex))) - continue; - if (!MATCH(pai->ai_socktype, ex->e_socktype, - WILD_SOCKTYPE(ex))) { - continue; - } - if (!MATCH(pai->ai_protocol, ex->e_protocol, - WILD_PROTOCOL(ex))) { - continue; - } - - if (pai->ai_family == PF_UNSPEC) - pai->ai_family = ex->e_af; - if (pai->ai_socktype == ANY && ex->e_socktype != ANY) - pai->ai_socktype = ex->e_socktype; - if (pai->ai_protocol == ANY && ex->e_protocol != ANY) - pai->ai_protocol = ex->e_protocol; - - error = explore_fqdn(pai, hostname, servname, - &cur->ai_next); - - while (cur && cur->ai_next) - cur = cur->ai_next; - } - } - - /* XXX: if any addrinfo found, SUCCESS return even if (error != 0) */ - if (sentinel.ai_next) { - good: - *res = sentinel.ai_next; - return SUCCESS; - } - /* else, failed */ - free: - bad: - if (error == 0) - error = EAI_FAIL; - if (sentinel.ai_next) - freeaddrinfo(sentinel.ai_next); - *res = NULL; - return error; -} - -/* - * FQDN hostname, DNS lookup - */ -static int -explore_fqdn(pai, hostname, servname, res) - const struct addrinfo *pai; - const char *hostname; - const char *servname; - struct addrinfo **res; -{ - struct hostent *hp; - int h_error; - int af; - char *ap; - struct addrinfo sentinel, *cur; - int i; - const struct afd *afd; - int error; - - *res = NULL; - sentinel.ai_next = NULL; - cur = &sentinel; - - /* - * if the servname does not match socktype/protocol, ignore it. - */ - if (get_portmatch(pai, servname) != 0) - return 0; - - afd = find_afd(pai->ai_family); - if (afd == NULL) - return 0; - - hp = getipnodebyname(hostname, pai->ai_family, AI_ADDRCONFIG, - &h_error); - if (hp == NULL) { - switch (h_error) { - case HOST_NOT_FOUND: - case NO_DATA: - error = EAI_NODATA; - break; - case TRY_AGAIN: - error = EAI_AGAIN; - break; - case NO_RECOVERY: - case NETDB_INTERNAL: - default: - error = EAI_FAIL; - break; - } - } else if ((hp->h_name == NULL) || (hp->h_name[0] == 0) - || (hp->h_addr_list[0] == NULL)) { - freehostent(hp); - hp = NULL; - error = EAI_FAIL; - } - - if (hp == NULL) - goto free; - - for (i = 0; hp->h_addr_list[i] != NULL; i++) { - af = hp->h_addrtype; - ap = hp->h_addr_list[i]; - - if (af != pai->ai_family) - continue; - - GET_AI(cur->ai_next, afd, ap); - GET_PORT(cur->ai_next, servname); - if ((pai->ai_flags & AI_CANONNAME) != 0) { - /* - * RFC2553 says that ai_canonname will be set only for - * the first element. we do it for all the elements, - * just for convenience. - */ - GET_CANONNAME(cur->ai_next, hp->h_name); - } - - while (cur && cur->ai_next) - cur = cur->ai_next; - } - - *res = sentinel.ai_next; - return 0; - -free: - if (hp) - freehostent(hp); - if (sentinel.ai_next) - freeaddrinfo(sentinel.ai_next); - return error; -} - -/* - * hostname == NULL. - * passive socket -> anyaddr (0.0.0.0 or ::) - * non-passive socket -> localhost (127.0.0.1 or ::1) - */ -static int -explore_null(pai, hostname, servname, res) - const struct addrinfo *pai; - const char *hostname; - const char *servname; - struct addrinfo **res; -{ - int s; - const struct afd *afd; - struct addrinfo *cur; - struct addrinfo sentinel; - int error; - - *res = NULL; - sentinel.ai_next = NULL; - cur = &sentinel; - - /* - * filter out AFs that are not supported by the kernel - * XXX errno? - */ - s = socket(pai->ai_family, SOCK_DGRAM, 0); - if (s < 0) - return 0; - _close(s); - afd = find_afd(pai->ai_family); - if (afd == NULL) - return 0; - - GET_AI(cur->ai_next, afd, - (pai->ai_flags & AI_PASSIVE) ? afd->a_addrany : afd->a_loopback - ); - /* xxx meaningless? - * GET_CANONNAME(cur->ai_next, "anyaddr"); - * or - * GET_CANONNAME(cur->ai_next, "localhost"); - */ - /* if the servname does not match socktype/protocol, ignored */ - GET_PORT(cur->ai_next, servname); - - *res = sentinel.ai_next; - return 0; - -free: - if (sentinel.ai_next) - freeaddrinfo(sentinel.ai_next); - return error; -} - -/* - * numeric hostname - */ -static int -explore_numeric(pai, hostname, servname, res) - const struct addrinfo *pai; - const char *hostname; - const char *servname; - struct addrinfo **res; -{ - const struct afd *afd; - struct addrinfo *cur; - struct addrinfo sentinel; - int error; - char pton[PTON_MAX]; - int flags; - - *res = NULL; - sentinel.ai_next = NULL; - cur = &sentinel; - - /* - * if the servname does not match socktype/protocol, ignore it. - */ - if (get_portmatch(pai, servname) != 0) - return 0; - - afd = find_afd(pai->ai_family); - if (afd == NULL) - return 0; - flags = pai->ai_flags; - - if ((afd->a_af == AF_INET - ? inet_aton(hostname, (struct in_addr *)pton) - : inet_pton(afd->a_af, hostname, pton)) == 1) { - if (pai->ai_family == afd->a_af || - pai->ai_family == PF_UNSPEC /*?*/) { - GET_AI(cur->ai_next, afd, pton); - GET_PORT(cur->ai_next, servname); - while (cur && cur->ai_next) - cur = cur->ai_next; - } else - ERR(EAI_FAMILY); /*xxx*/ - } - - *res = sentinel.ai_next; - return 0; - -free: -bad: - if (sentinel.ai_next) - freeaddrinfo(sentinel.ai_next); - return error; -} - -/* - * numeric hostname with scope - */ -static int -explore_numeric_scope(pai, hostname, servname, res) - const struct addrinfo *pai; - const char *hostname; - const char *servname; - struct addrinfo **res; -{ -#ifndef SCOPE_DELIMITER - return explore_numeric(pai, hostname, servname, res); -#else - const struct afd *afd; - struct addrinfo *cur; - int error; - char *cp, *hostname2 = NULL; - int scope; -#ifdef INET6 - struct sockaddr_in6 *sin6; -#endif - - /* - * if the servname does not match socktype/protocol, ignore it. - */ - if (get_portmatch(pai, servname) != 0) - return 0; - - afd = find_afd(pai->ai_family); - if (afd == NULL) - return 0; - if (!afd->a_scoped) - return explore_numeric(pai, hostname, servname, res); - - cp = strchr(hostname, SCOPE_DELIMITER); - if (cp == NULL) - return explore_numeric(pai, hostname, servname, res); - - /* - * Handle special case of - */ - hostname2 = strdup(hostname); - if (hostname2 == NULL) - return EAI_MEMORY; - /* terminate at the delimiter */ - hostname2[cp - hostname] = '\0'; - - cp++; - switch (pai->ai_family) { -#ifdef INET6 - case AF_INET6: - scope = if_nametoindex(cp); - if (scope == 0) { - error = EAI_SYSTEM; - goto free; - } - break; -#endif - } - - error = explore_numeric(pai, hostname2, servname, res); - if (error == 0) { - for (cur = *res; cur; cur = cur->ai_next) { -#ifdef INET6 - if (cur->ai_family != AF_INET6) - continue; - sin6 = (struct sockaddr_in6 *)cur->ai_addr; - if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) || - IN6_IS_ADDR_MC_LINKLOCAL(&sin6->sin6_addr)) - sin6->sin6_scope_id = scope; -#endif - } - } - -#ifdef INET6 -free: -#endif - free(hostname2); - - return error; -#endif -} - -static int -get_canonname(pai, ai, str) - const struct addrinfo *pai; - struct addrinfo *ai; - const char *str; -{ - if ((pai->ai_flags & AI_CANONNAME) != 0) { - ai->ai_canonname = (char *)malloc(strlen(str) + 1); - if (ai->ai_canonname == NULL) - return EAI_MEMORY; - strcpy(ai->ai_canonname, str); - } - return 0; -} - -static struct addrinfo * -get_ai(pai, afd, addr) - const struct addrinfo *pai; - const struct afd *afd; - const char *addr; -{ - char *p; - struct addrinfo *ai; -#ifdef FAITH - struct in6_addr faith_prefix; - char *fp_str; - int translate = 0; -#endif - -#ifdef FAITH - /* - * Transfrom an IPv4 addr into a special IPv6 addr format for - * IPv6->IPv4 translation gateway. (only TCP is supported now) - * - * +-----------------------------------+------------+ - * | faith prefix part (12 bytes) | embedded | - * | | IPv4 addr part (4 bytes) - * +-----------------------------------+------------+ - * - * faith prefix part is specified as ascii IPv6 addr format - * in environmental variable GAI. - * For FAITH to work correctly, routing to faith prefix must be - * setup toward a machine where a FAITH daemon operates. - * Also, the machine must enable some mechanizm - * (e.g. faith interface hack) to divert those packet with - * faith prefixed destination addr to user-land FAITH daemon. - */ - fp_str = getenv("GAI"); - if (fp_str && inet_pton(AF_INET6, fp_str, &faith_prefix) == 1 && - afd->a_af == AF_INET && pai->ai_socktype == SOCK_STREAM) { - u_int32_t v4a; - u_int8_t v4a_top; - - memcpy(&v4a, addr, sizeof v4a); - v4a_top = v4a >> IN_CLASSA_NSHIFT; - if (!IN_MULTICAST(v4a) && !IN_EXPERIMENTAL(v4a) && - v4a_top != 0 && v4a != IN_LOOPBACKNET) { - afd = &afdl[N_INET6]; - memcpy(&faith_prefix.s6_addr[12], addr, - sizeof(struct in_addr)); - translate = 1; - } - } -#endif - - ai = (struct addrinfo *)malloc(sizeof(struct addrinfo) - + (afd->a_socklen)); - if (ai == NULL) - return NULL; - - memcpy(ai, pai, sizeof(struct addrinfo)); - ai->ai_addr = (struct sockaddr *)(ai + 1); - memset(ai->ai_addr, 0, afd->a_socklen); - ai->ai_addr->sa_len = afd->a_socklen; - ai->ai_addrlen = afd->a_socklen; - ai->ai_addr->sa_family = ai->ai_family = afd->a_af; - p = (char *)(ai->ai_addr); -#ifdef FAITH - if (translate == 1) - memcpy(p + afd->a_off, &faith_prefix, afd->a_addrlen); - else -#endif - memcpy(p + afd->a_off, addr, afd->a_addrlen); - - return ai; -} - -static int -get_portmatch(ai, servname) - const struct addrinfo *ai; - const char *servname; -{ - /* get_port does not touch first argument. when matchonly == 1. */ - return get_port((struct addrinfo *)ai, servname, 1); -} - -static int -get_port(ai, servname, matchonly) - struct addrinfo *ai; - const char *servname; - int matchonly; -{ - const char *proto; - struct servent *sp; - int port; - int allownumeric; - - if (servname == NULL) - return 0; - if (ai->ai_family != AF_INET -#ifdef INET6 - && ai->ai_family != AF_INET6 -#endif - ) - return 0; - - switch (ai->ai_socktype) { - case SOCK_RAW: - return EAI_SERVICE; - case SOCK_DGRAM: - case SOCK_STREAM: - allownumeric = 1; - break; - case ANY: - allownumeric = 0; - break; - default: - return EAI_SOCKTYPE; - } - - if (str_isnumber(servname)) { - if (!allownumeric) - return EAI_SERVICE; - port = htons(atoi(servname)); - if (port < 0 || port > 65535) - return EAI_SERVICE; - } else { - switch (ai->ai_socktype) { - case SOCK_DGRAM: - proto = "udp"; - break; - case SOCK_STREAM: - proto = "tcp"; - break; - default: - proto = NULL; - break; - } - - if ((sp = getservbyname(servname, proto)) == NULL) - return EAI_SERVICE; - port = sp->s_port; - } - - if (!matchonly) { - switch (ai->ai_family) { - case AF_INET: - ((struct sockaddr_in *)ai->ai_addr)->sin_port = port; - break; -#ifdef INET6 - case AF_INET6: - ((struct sockaddr_in6 *)ai->ai_addr)->sin6_port = port; - break; -#endif - } - } - - return 0; -} - -static const struct afd * -find_afd(af) - int af; -{ - const struct afd *afd; - - if (af == PF_UNSPEC) - return NULL; - for (afd = afdl; afd->a_af; afd++) { - if (afd->a_af == af) - return afd; - } - return NULL; -} diff --git a/lib/libc/net/gethostbydns.c b/lib/libc/net/gethostbydns.c deleted file mode 100644 index a5a3e7b..0000000 --- a/lib/libc/net/gethostbydns.c +++ /dev/null @@ -1,778 +0,0 @@ -/* - * ++Copyright++ 1985, 1988, 1993 - * - - * Copyright (c) 1985, 1988, 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. - * - - * --Copyright-- - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93"; -static char fromrcsid[] = "From: Id: gethnamaddr.c,v 8.23 1998/04/07 04:59:46 vixie Exp $"; -static char rcsid[] = "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "res_config.h" - -#define SPRINTF(x) ((size_t)sprintf x) - -#define MAXALIASES 35 -#define MAXADDRS 35 - -static const char AskedForGot[] = - "gethostby*.gethostanswer: asked for \"%s\", got \"%s\""; - -static char *h_addr_ptrs[MAXADDRS + 1]; - -static struct hostent host; -static char *host_aliases[MAXALIASES]; -static char hostbuf[8*1024]; -static u_char host_addr[16]; /* IPv4 or IPv6 */ - -#ifdef RESOLVSORT -static void addrsort __P((char **, int)); -#endif - -#if PACKETSZ > 1024 -#define MAXPACKET PACKETSZ -#else -#define MAXPACKET 1024 -#endif - -typedef union { - HEADER hdr; - u_char buf[MAXPACKET]; -} querybuf; - -typedef union { - int32_t al; - char ac; -} align; - -extern int h_errno; -int _dns_ttl_; - -#ifdef DEBUG -static void -dprintf(msg, num) - char *msg; - int num; -{ - if (_res.options & RES_DEBUG) { - int save = errno; - - printf(msg, num); - errno = save; - } -} -#else -# define dprintf(msg, num) /*nada*/ -#endif - -#define BOUNDED_INCR(x) \ - do { \ - cp += x; \ - if (cp > eom) { \ - h_errno = NO_RECOVERY; \ - return (NULL); \ - } \ - } while (0) - -#define BOUNDS_CHECK(ptr, count) \ - do { \ - if ((ptr) + (count) > eom) { \ - h_errno = NO_RECOVERY; \ - return (NULL); \ - } \ - } while (0) - -static struct hostent * -gethostanswer(answer, anslen, qname, qtype) - const querybuf *answer; - int anslen; - const char *qname; - int qtype; -{ - register const HEADER *hp; - register const u_char *cp; - register int n; - const u_char *eom, *erdata; - char *bp, **ap, **hap; - int type, class, buflen, ancount, qdcount; - int haveanswer, had_error; - int toobig = 0; - char tbuf[MAXDNAME]; - const char *tname; - int (*name_ok) __P((const char *)); - - tname = qname; - host.h_name = NULL; - eom = answer->buf + anslen; - switch (qtype) { - case T_A: - case T_AAAA: - name_ok = res_hnok; - break; - case T_PTR: - name_ok = res_dnok; - break; - default: - h_errno = NO_RECOVERY; - return (NULL); /* XXX should be abort(); */ - } - /* - * find first satisfactory answer - */ - hp = &answer->hdr; - ancount = ntohs(hp->ancount); - qdcount = ntohs(hp->qdcount); - bp = hostbuf; - buflen = sizeof hostbuf; - cp = answer->buf; - BOUNDED_INCR(HFIXEDSZ); - if (qdcount != 1) { - h_errno = NO_RECOVERY; - return (NULL); - } - n = dn_expand(answer->buf, eom, cp, bp, buflen); - if ((n < 0) || !(*name_ok)(bp)) { - h_errno = NO_RECOVERY; - return (NULL); - } - BOUNDED_INCR(n + QFIXEDSZ); - if (qtype == T_A || qtype == T_AAAA) { - /* res_send() has already verified that the query name is the - * same as the one we sent; this just gets the expanded name - * (i.e., with the succeeding search-domain tacked on). - */ - n = strlen(bp) + 1; /* for the \0 */ - if (n >= MAXHOSTNAMELEN) { - h_errno = NO_RECOVERY; - return (NULL); - } - host.h_name = bp; - bp += n; - buflen -= n; - /* The qname can be abbreviated, but h_name is now absolute. */ - qname = host.h_name; - } - ap = host_aliases; - *ap = NULL; - host.h_aliases = host_aliases; - hap = h_addr_ptrs; - *hap = NULL; - host.h_addr_list = h_addr_ptrs; - haveanswer = 0; - had_error = 0; - _dns_ttl_ = -1; - while (ancount-- > 0 && cp < eom && !had_error) { - n = dn_expand(answer->buf, eom, cp, bp, buflen); - if ((n < 0) || !(*name_ok)(bp)) { - had_error++; - continue; - } - cp += n; /* name */ - BOUNDS_CHECK(cp, 3 * INT16SZ + INT32SZ); - type = _getshort(cp); - cp += INT16SZ; /* type */ - class = _getshort(cp); - cp += INT16SZ; /* class */ - if (qtype == T_A && type == T_A) - _dns_ttl_ = _getlong(cp); - cp += INT32SZ; /* TTL */ - n = _getshort(cp); - cp += INT16SZ; /* len */ - BOUNDS_CHECK(cp, n); - erdata = cp + n; - if (class != C_IN) { - /* XXX - debug? syslog? */ - cp += n; - continue; /* XXX - had_error++ ? */ - } - if ((qtype == T_A || qtype == T_AAAA) && type == T_CNAME) { - if (ap >= &host_aliases[MAXALIASES-1]) - continue; - n = dn_expand(answer->buf, eom, cp, tbuf, sizeof tbuf); - if ((n < 0) || !(*name_ok)(tbuf)) { - had_error++; - continue; - } - cp += n; - if (cp != erdata) { - h_errno = NO_RECOVERY; - return (NULL); - } - /* Store alias. */ - *ap++ = bp; - n = strlen(bp) + 1; /* for the \0 */ - if (n >= MAXHOSTNAMELEN) { - had_error++; - continue; - } - bp += n; - buflen -= n; - /* Get canonical name. */ - n = strlen(tbuf) + 1; /* for the \0 */ - if (n > buflen || n >= MAXHOSTNAMELEN) { - had_error++; - continue; - } - strcpy(bp, tbuf); - host.h_name = bp; - bp += n; - buflen -= n; - continue; - } - if (qtype == T_PTR && type == T_CNAME) { - n = dn_expand(answer->buf, eom, cp, tbuf, sizeof tbuf); - if (n < 0 || !res_dnok(tbuf)) { - had_error++; - continue; - } - cp += n; - if (cp != erdata) { - h_errno = NO_RECOVERY; - return (NULL); - } - /* Get canonical name. */ - n = strlen(tbuf) + 1; /* for the \0 */ - if (n > buflen || n >= MAXHOSTNAMELEN) { - had_error++; - continue; - } - strcpy(bp, tbuf); - tname = bp; - bp += n; - buflen -= n; - continue; - } - if (type != qtype) { - if (type != T_SIG) - syslog(LOG_NOTICE|LOG_AUTH, - "gethostby*.gethostanswer: asked for \"%s %s %s\", got type \"%s\"", - qname, p_class(C_IN), p_type(qtype), - p_type(type)); - cp += n; - continue; /* XXX - had_error++ ? */ - } - switch (type) { - case T_PTR: - if (strcasecmp(tname, bp) != 0) { - syslog(LOG_NOTICE|LOG_AUTH, - AskedForGot, qname, bp); - cp += n; - continue; /* XXX - had_error++ ? */ - } - n = dn_expand(answer->buf, eom, cp, bp, buflen); - if ((n < 0) || !res_hnok(bp)) { - had_error++; - break; - } -#if MULTI_PTRS_ARE_ALIASES - cp += n; - if (cp != erdata) { - h_errno = NO_RECOVERY; - return (NULL); - } - if (!haveanswer) - host.h_name = bp; - else if (ap < &host_aliases[MAXALIASES-1]) - *ap++ = bp; - else - n = -1; - if (n != -1) { - n = strlen(bp) + 1; /* for the \0 */ - if (n >= MAXHOSTNAMELEN) { - had_error++; - break; - } - bp += n; - buflen -= n; - } - break; -#else - host.h_name = bp; - if (_res.options & RES_USE_INET6) { - n = strlen(bp) + 1; /* for the \0 */ - if (n >= MAXHOSTNAMELEN) { - had_error++; - break; - } - bp += n; - buflen -= n; - _map_v4v6_hostent(&host, &bp, &buflen); - } - h_errno = NETDB_SUCCESS; - return (&host); -#endif - case T_A: - case T_AAAA: - if (strcasecmp(host.h_name, bp) != 0) { - syslog(LOG_NOTICE|LOG_AUTH, - AskedForGot, host.h_name, bp); - cp += n; - continue; /* XXX - had_error++ ? */ - } - if (n != host.h_length) { - cp += n; - continue; - } - if (!haveanswer) { - register int nn; - - host.h_name = bp; - nn = strlen(bp) + 1; /* for the \0 */ - bp += nn; - buflen -= nn; - } - - bp += sizeof(align) - ((u_long)bp % sizeof(align)); - - if (bp + n >= &hostbuf[sizeof hostbuf]) { - dprintf("size (%d) too big\n", n); - had_error++; - continue; - } - if (hap >= &h_addr_ptrs[MAXADDRS-1]) { - if (!toobig++) - dprintf("Too many addresses (%d)\n", - MAXADDRS); - cp += n; - continue; - } - bcopy(cp, *hap++ = bp, n); - bp += n; - buflen -= n; - cp += n; - if (cp != erdata) { - h_errno = NO_RECOVERY; - return (NULL); - } - break; - default: - dprintf("Impossible condition (type=%d)\n", type); - h_errno = NO_RECOVERY; - return (NULL); - /* BIND has abort() here, too risky on bad data */ - } - if (!had_error) - haveanswer++; - } - if (haveanswer) { - *ap = NULL; - *hap = NULL; -# if defined(RESOLVSORT) - /* - * Note: we sort even if host can take only one address - * in its return structures - should give it the "best" - * address in that case, not some random one - */ - if (_res.nsort && haveanswer > 1 && qtype == T_A) - addrsort(h_addr_ptrs, haveanswer); -# endif /*RESOLVSORT*/ - if (!host.h_name) { - n = strlen(qname) + 1; /* for the \0 */ - if (n > buflen || n >= MAXHOSTNAMELEN) - goto no_recovery; - strcpy(bp, qname); - host.h_name = bp; - bp += n; - buflen -= n; - } - if (_res.options & RES_USE_INET6) - _map_v4v6_hostent(&host, &bp, &buflen); - h_errno = NETDB_SUCCESS; - return (&host); - } - no_recovery: - h_errno = NO_RECOVERY; - return (NULL); -} - -struct hostent * -__dns_getanswer(answer, anslen, qname, qtype) - const char *answer; - int anslen; - const char *qname; - int qtype; -{ - switch(qtype) { - case T_AAAA: - host.h_addrtype = AF_INET6; - host.h_length = IN6ADDRSZ; - break; - case T_A: - default: - host.h_addrtype = AF_INET; - host.h_length = INADDRSZ; - break; - } - - return(gethostanswer((const querybuf *)answer, anslen, qname, qtype)); -} - -struct hostent * -_gethostbydnsname(name, af) - const char *name; - int af; -{ - querybuf buf; - register const char *cp; - char *bp; - int n, size, type, len; - - if ((_res.options & RES_INIT) == 0 && res_init() == -1) { - h_errno = NETDB_INTERNAL; - return (NULL); - } - - switch (af) { - case AF_INET: - size = INADDRSZ; - type = T_A; - break; - case AF_INET6: - size = IN6ADDRSZ; - type = T_AAAA; - break; - default: - h_errno = NETDB_INTERNAL; - errno = EAFNOSUPPORT; - return (NULL); - } - - host.h_addrtype = af; - host.h_length = size; - - /* - * if there aren't any dots, it could be a user-level alias. - * this is also done in res_query() since we are not the only - * function that looks up host names. - */ - if (!strchr(name, '.') && (cp = __hostalias(name))) - name = cp; - - /* - * disallow names consisting only of digits/dots, unless - * they end in a dot. - */ - if (isdigit((unsigned char)name[0])) - for (cp = name;; ++cp) { - if (!*cp) { - if (*--cp == '.') - break; - /* - * All-numeric, no dot at the end. - * Fake up a hostent as if we'd actually - * done a lookup. - */ - if (inet_pton(af, name, host_addr) <= 0) { - h_errno = HOST_NOT_FOUND; - return (NULL); - } - strncpy(hostbuf, name, MAXDNAME); - hostbuf[MAXDNAME] = '\0'; - bp = hostbuf + MAXDNAME; - len = sizeof hostbuf - MAXDNAME; - host.h_name = hostbuf; - host.h_aliases = host_aliases; - host_aliases[0] = NULL; - h_addr_ptrs[0] = (char *)host_addr; - h_addr_ptrs[1] = NULL; - host.h_addr_list = h_addr_ptrs; - if (_res.options & RES_USE_INET6) - _map_v4v6_hostent(&host, &bp, &len); - h_errno = NETDB_SUCCESS; - return (&host); - } - if (!isdigit((unsigned char)*cp) && *cp != '.') - break; - } - if ((isxdigit((unsigned char)name[0]) && strchr(name, ':') != NULL) || - name[0] == ':') - for (cp = name;; ++cp) { - if (!*cp) { - if (*--cp == '.') - break; - /* - * All-IPv6-legal, no dot at the end. - * Fake up a hostent as if we'd actually - * done a lookup. - */ - if (inet_pton(af, name, host_addr) <= 0) { - h_errno = HOST_NOT_FOUND; - return (NULL); - } - strncpy(hostbuf, name, MAXDNAME); - hostbuf[MAXDNAME] = '\0'; - bp = hostbuf + MAXDNAME; - len = sizeof hostbuf - MAXDNAME; - host.h_name = hostbuf; - host.h_aliases = host_aliases; - host_aliases[0] = NULL; - h_addr_ptrs[0] = (char *)host_addr; - h_addr_ptrs[1] = NULL; - host.h_addr_list = h_addr_ptrs; - h_errno = NETDB_SUCCESS; - return (&host); - } - if (!isxdigit((unsigned char)*cp) && *cp != ':' && *cp != '.') - break; - } - - if ((n = res_search(name, C_IN, type, buf.buf, sizeof(buf))) < 0) { - dprintf("res_search failed (%d)\n", n); - return (NULL); - } - return (gethostanswer(&buf, n, name, type)); -} - -struct hostent * -_gethostbydnsaddr(addr, len, af) - const char *addr; /* XXX should have been def'd as u_char! */ - int len, af; -{ - const u_char *uaddr = (const u_char *)addr; - static const u_char mapped[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0xff,0xff }; - static const u_char tunnelled[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0,0 }; - int n, size; - querybuf buf; - register struct hostent *hp; - char qbuf[MAXDNAME+1], *qp; -#ifdef SUNSECURITY - register struct hostent *rhp; - char **haddr; - u_long old_options; - char hname2[MAXDNAME+1]; -#endif /*SUNSECURITY*/ - - if ((_res.options & RES_INIT) == 0 && res_init() == -1) { - h_errno = NETDB_INTERNAL; - return (NULL); - } - if (af == AF_INET6 && len == IN6ADDRSZ && - (!bcmp(uaddr, mapped, sizeof mapped) || - !bcmp(uaddr, tunnelled, sizeof tunnelled))) { - /* Unmap. */ - addr += sizeof mapped; - uaddr += sizeof mapped; - af = AF_INET; - len = INADDRSZ; - } - switch (af) { - case AF_INET: - size = INADDRSZ; - break; - case AF_INET6: - size = IN6ADDRSZ; - break; - default: - errno = EAFNOSUPPORT; - h_errno = NETDB_INTERNAL; - return (NULL); - } - if (size != len) { - errno = EINVAL; - h_errno = NETDB_INTERNAL; - return (NULL); - } - switch (af) { - case AF_INET: - (void) sprintf(qbuf, "%u.%u.%u.%u.in-addr.arpa", - (uaddr[3] & 0xff), - (uaddr[2] & 0xff), - (uaddr[1] & 0xff), - (uaddr[0] & 0xff)); - break; - case AF_INET6: - qp = qbuf; - for (n = IN6ADDRSZ - 1; n >= 0; n--) { - qp += SPRINTF((qp, "%x.%x.", - uaddr[n] & 0xf, - (uaddr[n] >> 4) & 0xf)); - } - strcpy(qp, "ip6.int"); - break; - default: - abort(); - } - n = res_query(qbuf, C_IN, T_PTR, (u_char *)buf.buf, sizeof buf.buf); - if (n < 0) { - dprintf("res_query failed (%d)\n", n); - return (NULL); - } - if (n > sizeof buf.buf) { - dprintf("static buffer is too small (%d)\n", n); - return (NULL); - } - if (!(hp = gethostanswer(&buf, n, qbuf, T_PTR))) - return (NULL); /* h_errno was set by gethostanswer() */ -#ifdef SUNSECURITY - if (af == AF_INET) { - /* - * turn off search as the name should be absolute, - * 'localhost' should be matched by defnames - */ - strncpy(hname2, hp->h_name, MAXDNAME); - hname2[MAXDNAME] = '\0'; - old_options = _res.options; - _res.options &= ~RES_DNSRCH; - _res.options |= RES_DEFNAMES; - if (!(rhp = gethostbyname(hname2))) { - syslog(LOG_NOTICE|LOG_AUTH, - "gethostbyaddr: No A record for %s (verifying [%s])", - hname2, inet_ntoa(*((struct in_addr *)addr))); - _res.options = old_options; - h_errno = HOST_NOT_FOUND; - return (NULL); - } - _res.options = old_options; - for (haddr = rhp->h_addr_list; *haddr; haddr++) - if (!memcmp(*haddr, addr, INADDRSZ)) - break; - if (!*haddr) { - syslog(LOG_NOTICE|LOG_AUTH, - "gethostbyaddr: A record of %s != PTR record [%s]", - hname2, inet_ntoa(*((struct in_addr *)addr))); - h_errno = HOST_NOT_FOUND; - return (NULL); - } - } -#endif /*SUNSECURITY*/ - hp->h_addrtype = af; - hp->h_length = len; - bcopy(addr, host_addr, len); - h_addr_ptrs[0] = (char *)host_addr; - h_addr_ptrs[1] = NULL; - if (af == AF_INET && (_res.options & RES_USE_INET6)) { - _map_v4v6_address((char*)host_addr, (char*)host_addr); - hp->h_addrtype = AF_INET6; - hp->h_length = IN6ADDRSZ; - } - h_errno = NETDB_SUCCESS; - return (hp); -} - -#ifdef RESOLVSORT -static void -addrsort(ap, num) - char **ap; - int num; -{ - int i, j; - char **p; - short aval[MAXADDRS]; - int needsort = 0; - - p = ap; - for (i = 0; i < num; i++, p++) { - for (j = 0 ; (unsigned)j < _res.nsort; j++) - if (_res.sort_list[j].addr.s_addr == - (((struct in_addr *)(*p))->s_addr & _res.sort_list[j].mask)) - break; - aval[i] = j; - if (needsort == 0 && i > 0 && j < aval[i-1]) - needsort = i; - } - if (!needsort) - return; - - while (needsort < num) { - for (j = needsort - 1; j >= 0; j--) { - if (aval[j] > aval[j+1]) { - char *hp; - - i = aval[j]; - aval[j] = aval[j+1]; - aval[j+1] = i; - - hp = ap[j]; - ap[j] = ap[j+1]; - ap[j+1] = hp; - - } else - break; - } - needsort++; - } -} -#endif -void -_sethostdnsent(stayopen) - int stayopen; -{ - if ((_res.options & RES_INIT) == 0 && res_init() == -1) - return; - if (stayopen) - _res.options |= RES_STAYOPEN | RES_USEVC; -} - -void -_endhostdnsent() -{ - _res.options &= ~(RES_STAYOPEN | RES_USEVC); - res_close(); -} diff --git a/lib/libc/net/gethostbyht.c b/lib/libc/net/gethostbyht.c deleted file mode 100644 index cd5f0f4..0000000 --- a/lib/libc/net/gethostbyht.c +++ /dev/null @@ -1,202 +0,0 @@ -/*- - * Copyright (c) 1985, 1988, 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. - * - - * --Copyright-- - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93"; -static char rcsid[] = "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* XXX */ -#include /* XXX */ - -#define MAXALIASES 35 - -static struct hostent host; -static char *host_aliases[MAXALIASES]; -static char hostbuf[BUFSIZ+1]; -static FILE *hostf = NULL; -static u_int32_t host_addr[4]; /* IPv4 or IPv6 */ -static char *h_addr_ptrs[2]; -static int stayopen = 0; - -void -_sethosthtent(f) - int f; -{ - if (!hostf) - hostf = fopen(_PATH_HOSTS, "r" ); - else - rewind(hostf); - stayopen = f; -} - -void -_endhosthtent() -{ - if (hostf && !stayopen) { - (void) fclose(hostf); - hostf = NULL; - } -} - -struct hostent * -gethostent() -{ - char *p; - register char *cp, **q; - int af, len; - - if (!hostf && !(hostf = fopen(_PATH_HOSTS, "r" ))) { - h_errno = NETDB_INTERNAL; - return (NULL); - } - again: - if (!(p = fgets(hostbuf, sizeof hostbuf, hostf))) { - h_errno = HOST_NOT_FOUND; - return (NULL); - } - if (*p == '#') - goto again; - if (!(cp = strpbrk(p, "#\n"))) - goto again; - *cp = '\0'; - if (!(cp = strpbrk(p, " \t"))) - goto again; - *cp++ = '\0'; - if (inet_pton(AF_INET6, p, host_addr) > 0) { - af = AF_INET6; - len = IN6ADDRSZ; - } else if (inet_pton(AF_INET, p, host_addr) > 0) { - if (_res.options & RES_USE_INET6) { - _map_v4v6_address((char*)host_addr, (char*)host_addr); - af = AF_INET6; - len = IN6ADDRSZ; - } else { - af = AF_INET; - len = INADDRSZ; - } - } else { - goto again; - } - h_addr_ptrs[0] = (char *)host_addr; - h_addr_ptrs[1] = NULL; - host.h_addr_list = h_addr_ptrs; - host.h_length = len; - host.h_addrtype = af; - while (*cp == ' ' || *cp == '\t') - cp++; - host.h_name = cp; - q = host.h_aliases = host_aliases; - if ((cp = strpbrk(cp, " \t")) != NULL) - *cp++ = '\0'; - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (q < &host_aliases[MAXALIASES - 1]) - *q++ = cp; - if ((cp = strpbrk(cp, " \t")) != NULL) - *cp++ = '\0'; - } - *q = NULL; - h_errno = NETDB_SUCCESS; - return (&host); -} - -struct hostent * -_gethostbyhtname(name, af) - const char *name; - int af; -{ - register struct hostent *p; - register char **cp; - - sethostent(0); - while ((p = gethostent()) != NULL) { - if (p->h_addrtype != af) - continue; - if (strcasecmp(p->h_name, name) == 0) - break; - for (cp = p->h_aliases; *cp != 0; cp++) - if (strcasecmp(*cp, name) == 0) - goto found; - } -found: - endhostent(); - return (p); -} - -struct hostent * -_gethostbyhtaddr(addr, len, af) - const char *addr; - int len, af; -{ - register struct hostent *p; - - sethostent(0); - while ((p = gethostent()) != NULL) - if (p->h_addrtype == af && !bcmp(p->h_addr, addr, len)) - break; - endhostent(); - return (p); -} diff --git a/lib/libc/net/gethostbyname.3 b/lib/libc/net/gethostbyname.3 deleted file mode 100644 index 1b48c4a..0000000 --- a/lib/libc/net/gethostbyname.3 +++ /dev/null @@ -1,305 +0,0 @@ -.\" Copyright (c) 1983, 1987, 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. -.\" -.\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95 -.\" $FreeBSD$ -.\" -.Dd May 25, 1995 -.Dt GETHOSTBYNAME 3 -.Os BSD 4.2 -.Sh NAME -.Nm gethostbyname , -.Nm gethostbyname2 , -.Nm gethostbyaddr , -.Nm gethostent , -.Nm sethostent , -.Nm endhostent , -.Nm herror , -.Nm hstrerror -.Nd get network host entry -.Sh SYNOPSIS -.Fd #include -.Vt extern int h_errno; -.Ft struct hostent * -.Fn gethostbyname "const char *name" -.Ft struct hostent * -.Fn gethostbyname2 "const char *name" "int af" -.Ft struct hostent * -.Fn gethostbyaddr "const char *addr" "int len" "int type" -.Ft struct hostent * -.Fn gethostent void -.Ft void -.Fn sethostent "int stayopen" -.Ft void -.Fn endhostent void -.Ft void -.Fn herror "const char *string" -.Ft const char * -.Fn hstrerror "int err" -.Sh DESCRIPTION -The -.Fn gethostbyname , -.Fn gethostbyname2 -and -.Fn gethostbyaddr -functions -each return a pointer to an object with the -following structure describing an internet host -referenced by name or by address, respectively. -This structure contains either the information obtained from the name server, -.Xr named 8 , -or broken-out fields from a line in -.Pa /etc/hosts . -If the local name server is not running these routines do a lookup in -.Pa /etc/hosts . -.Bd -literal -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 compatibility */ -.Ed -.Pp -The members of this structure are: -.Bl -tag -width h_addr_list -.It Fa h_name -Official name of the host. -.It Fa h_aliases -A NULL-terminated array of alternate names for the host. -.It Fa h_addrtype -The type of address being returned; usually -.Dv AF_INET . -.It Fa h_length -The length, in bytes, of the address. -.It Fa h_addr_list -A NULL-terminated array of network addresses for the host. -Host addresses are returned in network byte order. -.It Fa h_addr -The first address in -.Fa h_addr_list ; -this is for backward compatibility. -.El -.Pp -When using the nameserver, -.Fn gethostbyname -and -.Fn gethostbyname2 -will search for the named host in the current domain and its parents -unless the name ends in a dot. -If the name contains no dot, and if the environment variable -.Dq Ev HOSTALIASES -contains the name of an alias file, the alias file will first be searched -for an alias matching the input name. -See -.Xr hostname 7 -for the domain search procedure and the alias file format. -.Pp -The -.Fn gethostbyname2 -function is an evolution of -.Fn gethostbyname -which is intended to allow lookups in address families other than -.Dv AF_INET , -for example -.Dv AF_INET6 . -Currently the -.Fa af -argument must be specified as -.Dv AF_INET -else the function will return -.Dv NULL -after having set -.Va h_errno -to -.Dv NETDB_INTERNAL -.Pp -The -.Fn sethostent -function -may be used to request the use of a connected -.Tn TCP -socket for queries. -If the -.Fa stayopen -flag is non-zero, -this sets the option to send all queries to the name server using -.Tn TCP -and to retain the connection after each call to -.Fn gethostbyname , -.Fn gethostbyname2 -or -.Fn gethostbyaddr . -Otherwise, queries are performed using -.Tn UDP -datagrams. -.Pp -The -.Fn endhostent -function -closes the -.Tn TCP -connection. -.Pp -The -.Fn herror -function writes a message to the diagnostic output consisting of the -string parameter -.Fa s , -the constant string ": ", and a message corresponding to the value of -.Va h_errno . -.Pp -The -.Fn hstrerror -function returns a string which is the message text corresponding to the -value of the -.Fa err -parameter. -.Sh FILES -.Bl -tag -width /etc/resolv.conf -compact -.It Pa /etc/hosts -.It Pa /etc/host.conf -.It Pa /etc/resolv.conf -.El -.Sh DIAGNOSTICS -Error return status from -.Fn gethostbyname , -.Fn gethostbyname2 -and -.Fn gethostbyaddr -is indicated by return of a null pointer. -The external integer -.Va h_errno -may then be checked to see whether this is a temporary failure -or an invalid or unknown host. -The routine -.Fn herror -can be used to print an error message describing the failure. -If its argument -.Fa string -is -.Pf non Dv -NULL , -it is printed, followed by a colon and a space. -The error message is printed with a trailing newline. -.Pp -The variable -.Va h_errno -can have the following values: -.Bl -tag -width HOST_NOT_FOUND -.It Dv HOST_NOT_FOUND -No such host is known. -.It Dv TRY_AGAIN -This is usually a temporary error -and means that the local server did not receive -a response from an authoritative server. -A retry at some later time may succeed. -.It Dv NO_RECOVERY -Some unexpected server failure was encountered. -This is a non-recoverable error. -.It Dv NO_DATA -The requested name is valid but does not have an IP address; -this is not a temporary error. -This means that the name is known to the name server but there is no address -associated with this name. -Another type of request to the name server using this domain name -will result in an answer; -for example, a mail-forwarder may be registered for this domain. -.El -.Sh SEE ALSO -.Xr resolver 3 , -.Xr hosts 5 , -.Xr hostname 7 , -.Xr named 8 -.Sh CAVEAT -The -.Fn gethostent -function -is defined, and -.Fn sethostent -and -.Fn endhostent -are redefined, -when -.Xr libc 3 -is built to use only the routines to lookup in -.Pa /etc/hosts -and not the name server. -.Pp -The -.Fn gethostent -function -reads the next line of -.Pa /etc/hosts , -opening the file if necessary. -.Pp -The -.Fn sethostent -function -opens and/or rewinds the file -.Pa /etc/hosts . -If the -.Fa stayopen -argument is non-zero, -the file will not be closed after each call to -.Fn gethostbyname , -.Fn gethostbyname2 -or -.Fn gethostbyaddr . -.Pp -The -.Fn endhostent -function -closes the file. -.Sh HISTORY -The -.Fn herror -function appeared in -.Bx 4.3 . -The -.Fn endhostent , -.Fn gethostbyaddr , -.Fn gethostbyname , -.Fn gethostent , -and -.Fn sethostent -functions appeared in -.Bx 4.2 . -The -.Fn gethostbyname2 -function first appeared in bind-4.9.4. -.Sh BUGS -These functions use static data storage; -if the data is needed for future use, it should be -copied before any subsequent calls overwrite it. -Only the Internet -address format is currently understood. diff --git a/lib/libc/net/gethostbynis.c b/lib/libc/net/gethostbynis.c deleted file mode 100644 index 82e0b3d..0000000 --- a/lib/libc/net/gethostbynis.c +++ /dev/null @@ -1,145 +0,0 @@ -/*- - * Copyright (c) 1994, Garrett Wollman - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)$FreeBSD$"; -static char rcsid[] = "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef YP -#include -#include -#include -#endif - -#define MAXALIASES 35 -#define MAXADDRS 35 - -#ifdef YP -static char *host_aliases[MAXALIASES]; -static char hostaddr[MAXADDRS]; -static char *host_addrs[2]; -#endif /* YP */ - -static struct hostent * -_gethostbynis(name, map, af) - const char *name; - char *map; - int af; -{ -#ifdef YP - register char *cp, **q; - char *result; - int resultlen,size; - static struct hostent h; - static char *domain = (char *)NULL; - static char ypbuf[YPMAXRECORD + 2]; - - switch(af) { - case AF_INET: - size = NS_INADDRSZ; - break; - default: - case AF_INET6: - size = NS_IN6ADDRSZ; - errno = EAFNOSUPPORT; - return NULL; - } - - if (domain == (char *)NULL) - if (yp_get_default_domain (&domain)) - return ((struct hostent *)NULL); - - if (yp_match(domain, map, name, strlen(name), &result, &resultlen)) - return ((struct hostent *)NULL); - - /* avoid potential memory leak */ - bcopy((char *)result, (char *)&ypbuf, resultlen); - ypbuf[resultlen] = '\0'; - free(result); - result = (char *)&ypbuf; - - if ((cp = index(result, '\n'))) - *cp = '\0'; - - cp = strpbrk(result, " \t"); - *cp++ = '\0'; - h.h_addr_list = host_addrs; - h.h_addr = hostaddr; - *((u_long *)h.h_addr) = inet_addr(result); - h.h_length = size; - h.h_addrtype = AF_INET; - while (*cp == ' ' || *cp == '\t') - cp++; - h.h_name = cp; - q = h.h_aliases = host_aliases; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (q < &host_aliases[MAXALIASES - 1]) - *q++ = cp; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - } - *q = NULL; - return (&h); -#else - return (NULL); -#endif /* YP */ -} - -struct hostent * -_gethostbynisname(name, af) - const char *name; - int af; -{ - return _gethostbynis(name, "hosts.byname", af); -} - -struct hostent * -_gethostbynisaddr(addr, len, af) - const char *addr; - int len; - int af; -{ - return _gethostbynis(inet_ntoa(*(struct in_addr *)addr),"hosts.byaddr", af); -} diff --git a/lib/libc/net/gethostnamadr.c b/lib/libc/net/gethostnamadr.c deleted file mode 100644 index 010e4db..0000000 --- a/lib/libc/net/gethostnamadr.c +++ /dev/null @@ -1,224 +0,0 @@ -/*- - * Copyright (c) 1994, Garrett Wollman - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)$FreeBSD$"; -static char rcsid[] = "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* XXX hack for _res */ -#include /* XXX hack for _res */ - -#define _PATH_HOSTCONF "/etc/host.conf" - -enum service_type { - SERVICE_NONE = 0, - SERVICE_BIND, - SERVICE_HOSTS, - SERVICE_NIS }; -#define SERVICE_MAX SERVICE_NIS - -static struct { - const char *name; - enum service_type type; -} service_names[] = { - { "hosts", SERVICE_HOSTS }, - { "/etc/hosts", SERVICE_HOSTS }, - { "hosttable", SERVICE_HOSTS }, - { "htable", SERVICE_HOSTS }, - { "bind", SERVICE_BIND }, - { "dns", SERVICE_BIND }, - { "domain", SERVICE_BIND }, - { "yp", SERVICE_NIS }, - { "yellowpages", SERVICE_NIS }, - { "nis", SERVICE_NIS }, - { 0, SERVICE_NONE } -}; - -static enum service_type service_order[SERVICE_MAX + 1]; -static int service_done = 0; - -static enum service_type -get_service_name(const char *name) { - int i; - for(i = 0; service_names[i].type != SERVICE_NONE; i++) { - if(!strcasecmp(name, service_names[i].name)) { - return service_names[i].type; - } - } - return SERVICE_NONE; -} - -static void -init_services() -{ - char *cp, *p, buf[BUFSIZ]; - register int cc = 0; - FILE *fd; - - if ((fd = (FILE *)fopen(_PATH_HOSTCONF, "r")) == NULL) { - /* make some assumptions */ - service_order[0] = SERVICE_BIND; - service_order[1] = SERVICE_HOSTS; - service_order[2] = SERVICE_NONE; - } else { - while (fgets(buf, BUFSIZ, fd) != NULL && cc < SERVICE_MAX) { - if(buf[0] == '#') - continue; - - p = buf; - while ((cp = strsep(&p, "\n \t,:;")) != NULL && *cp == '\0') - ; - if (cp == NULL) - continue; - do { - if (isalpha((unsigned char)cp[0])) { - service_order[cc] = get_service_name(cp); - if(service_order[cc] != SERVICE_NONE) - cc++; - } - while ((cp = strsep(&p, "\n \t,:;")) != NULL && *cp == '\0') - ; - } while(cp != NULL && cc < SERVICE_MAX); - } - service_order[cc] = SERVICE_NONE; - fclose(fd); - } - service_done = 1; -} - -struct hostent * -gethostbyname(const char *name) -{ - struct hostent *hp; - - if (_res.options & RES_USE_INET6) { /* XXX */ - hp = gethostbyname2(name, AF_INET6); /* XXX */ - if (hp) /* XXX */ - return (hp); /* XXX */ - } /* XXX */ - return (gethostbyname2(name, AF_INET)); -} - -struct hostent * -gethostbyname2(const char *name, int type) -{ - struct hostent *hp = 0; - int nserv = 0; - - if (!service_done) - init_services(); - - while (!hp) { - switch (service_order[nserv]) { - case SERVICE_NONE: - return NULL; - case SERVICE_HOSTS: - hp = _gethostbyhtname(name, type); - break; - case SERVICE_BIND: - hp = _gethostbydnsname(name, type); - break; - case SERVICE_NIS: - hp = _gethostbynisname(name, type); - break; - } - nserv++; - } - return hp; -} - -struct hostent * -gethostbyaddr(const char *addr, int len, int type) -{ - struct hostent *hp = 0; - int nserv = 0; - - if (!service_done) - init_services(); - - while (!hp) { - switch (service_order[nserv]) { - case SERVICE_NONE: - return 0; - case SERVICE_HOSTS: - hp = _gethostbyhtaddr(addr, len, type); - break; - case SERVICE_BIND: - hp = _gethostbydnsaddr(addr, len, type); - break; - case SERVICE_NIS: - hp = _gethostbynisaddr(addr, len, type); - break; - } - nserv++; - } - return hp; -} - -#ifdef _THREAD_SAFE -struct hostent_data; - -/* - * Temporary function (not thread safe) - */ -int gethostbyaddr_r(const char *addr, int len, int type, - struct hostent *result, struct hostent_data *buffer) -{ - struct hostent *hp; - int ret; - if ((hp = gethostbyaddr(addr, len, type)) == NULL) { - ret = -1; - } else { - memcpy(result, hp, sizeof(struct hostent)); - ret = 0; - } - return(ret); -} -#endif - -void -sethostent(stayopen) - int stayopen; -{ - _sethosthtent(stayopen); - _sethostdnsent(stayopen); -} - -void -endhostent() -{ - _endhosthtent(); - _endhostdnsent(); -} diff --git a/lib/libc/net/getipnodebyname.3 b/lib/libc/net/getipnodebyname.3 deleted file mode 100644 index d5a881a..0000000 --- a/lib/libc/net/getipnodebyname.3 +++ /dev/null @@ -1,447 +0,0 @@ -.\" Copyright (c) 1983, 1987, 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. -.\" -.\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95 -.\" $Id: getipnodebyname.3,v 1.2 1999/09/13 16:04:51 itojun Exp $ -.\ $FreeBSD$ -.\" -.Dd May 25, 1995 -.Dt GETIPNODEBYNAME 3 -.Os KAME -.\" -.Sh NAME -.Nm getipnodebyname , -.Nm getipnodebyaddr , -.Nm freehostent -.Nd nodename-to-address and address-to-nodename translation -.\" -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Fd #include -.Ft "struct hostent *" -.Fn getipnodebyname "const char *name" "int af" "int flags" "int *error_num" -.Ft "struct hostent *" -.Fn getipnodebyaddr "const void *src" "size_t len" "int af" "int *error_num" -.Ft void -.Fn freehostent "struct hostent *ptr" -.\" -.Sh DESCRIPTION -.Fn getipnodebyname -and -.Fn getipnodebyaddr -functions are very similar to -.Xr gethostbyname 3 , -.Xr gethostbyname2 3 -and -.Xr gethostbyaddr 3 . -The functions cover all the functionalities provided by the older ones, -and provide better interface to programmers. -The functions require additional arguments, -.Ar af , -and -.Ar flags , -for specifying address family and operation mode. -The additional arguments allow programmer to get address for a nodename, -for specific address family -.Po -such as -.Dv AF_INET -or -.Dv AF_INET6 -.Pc . -The functions also require an additional pointer argument, -.Ar error_num -to return the appropriate error code, -to support thread safe error code returns. -.Pp -The type and usage of the return value, -.Li "struct hostent" -is described in -.Xr gethostbyname 3 . -.Pp -For -.Fn getipnodebyname , -the -.Ar name -argument can be either a node name or a numeric address -string -.Po -i.e., a dotted-decimal IPv4 address or an IPv6 hex address -.Pc . -The -.Ar af -argument specifies the address family, either -.Dv AF_INET -or -.Dv AF_INET6 . -The -.Ar flags -argument specifies the types of addresses that are searched for, -and the types of addresses that are returned. -We note that a special flags value of -.Dv AI_DEFAULT -.Pq defined below -should handle most applications. -That is, porting simple applications to use IPv6 replaces the call -.Bd -literal -offset - hptr = gethostbyname(name); -.Ed -.Pp -with -.Bd -literal -offset - hptr = getipnodebyname(name, AF_INET6, AI_DEFAULT, &error_num); -.Ed -.Pp -Applications desiring finer control over the types of addresses -searched for and returned, can specify other combinations of the -.Ar flags -argument. -.Pp -A -.Ar flags -of -.Li 0 -implies a strict interpretation of the -.Ar af -argument: -.Bl -bullet -.It -If -.Ar flags -is 0 and -.Ar af -is -.Dv AF_INET , -then the caller wants only IPv4 addresses. -A query is made for -.Li A -records. -If successful, the IPv4 addresses are returned and the -.Li h_length -member of the -.Li hostent -structure will be 4, else the function returns a -.Dv NULL -pointer. -.It -If -.Ar flags -is 0 and if -.Ar af -is -.Li AF_INET6 , -then the caller wants only IPv6 addresses. -A query is made for -.Li AAAA -records. -If successful, the IPv6 addresses are returned and the -.Li h_length -member of the -.Li hostent -structure will be 16, else the function returns a -.Dv NULL -pointer. -.El -.Pp -Other constants can be logically-ORed into the -.Ar flags -argument, to modify the behavior of the function. -.Bl -bullet -.It -If the -.Dv AI_V4MAPPED -flag is specified along with an -.Ar af -of -.Dv AF_INET6 , -then the caller will accept IPv4-mapped IPv6 addresses. -That is, if no -.Li AAAA -records are found then a query is made for -.Li A -records and any found are returned as IPv4-mapped IPv6 addresses -.Po -.Li h_length -will be 16 -.Pc . -The -.Dv AI_V4MAPPED -flag is ignored unless -.Ar af -equals -.Dv AF_INET6 . -.It -The -.Dv AI_V4MAPPED_CFG -flag is exact same as the -.Dv AI_V4MAPPED -flag only if the kernel supports IPv4-mapped IPv6 address. -.It -If the -.Dv AI_ALL -flag is used in conjunction with the -.Dv AI_V4MAPPED -flag, and only used with the IPv6 address family. -When -.Dv AI_ALL -is logically or'd with -.Dv AI_V4MAPPED -flag then the caller wants all addresses: IPv6 and IPv4-mapped IPv6. -A query is first made for -.Li AAAA -records and if successful, the -IPv6 addresses are returned. Another query is then made for -.Li A -records and any found are returned as IPv4-mapped IPv6 addresses. -.Li h_length -will be 16. Only if both queries fail does the function -return a -.Dv NULL -pointer. This flag is ignored unless af equals -AF_INET6. If both -.Dv AI_ALL -and -.Dv AI_V4MAPPED -are specified, -.Dv AI_ALL -takes precedence. -.It -The -.Dv AI_ADDRCONFIG -flag specifies that a query for -.Li AAAA -records -should occur only if the node has at least one IPv6 source -address configured and a query for -.Li A -records should occur only if the node has at least one IPv4 source address -configured. -.Pp -For example, if the node has no IPv6 source addresses configured, -and -.Ar af -equals AF_INET6, and the node name being looked up has both -.Li AAAA -and -.Li A -records, then: -(a) if only -.Dv AI_ADDRCONFIG -is -specified, the function returns a -.Dv NULL -pointer; -(b) if -.Dv AI_ADDRCONFIG -| -.Dv AI_V4MAPPED -is specified, the -.Li A -records are returned as IPv4-mapped IPv6 addresses; -.El -.Pp -The special flags value of -.Dv AI_DEFAULT -is defined as -.Bd -literal -offset - #define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG) -.Ed -.Pp -We noted that the -.Fn getipnodebyname -function must allow the -.Ar name -argument to be either a node name or a literal address string -.Po -i.e., a dotted-decimal IPv4 address or an IPv6 hex address -.Pc . -This saves applications from having to call -.Xr inet_pton 3 -to handle literal address strings. -When the -.Ar name -argument is a literal address string, -the -.Ar flags -argument is always ignored. -.Pp -There are four scenarios based on the type of literal address string -and the value of the -.Ar af -argument. -The two simple cases are when -.Ar name -is a dotted-decimal IPv4 address and -.Ar af -equals -.Dv AF_INET , -or when -.Ar name -is an IPv6 hex address and -.Ar af -equals -.Dv AF_INET6 . -The members of the -returned hostent structure are: -.Li h_name -points to a copy of the -.Ar name -argument, -.Li h_aliases -is a -.Dv NULL -pointer, -.Li h_addrtype -is a copy of the -.Ar af -argument, -.Li h_length -is either 4 -.Po -for -.Dv AF_INET -.Pc -or 16 -.Po -for -.Dv AF_INET6 -.Pc , -.Li h_addr_list[0] -is a pointer to the 4-byte or 16-byte binary address, -and -.Li h_addr_list[1] -is a -.Dv NULL -pointer. -.Pp -When -.Ar name -is a dotted-decimal IPv4 address and -.Ar af -equals -.Dv AF_INET6 , -and -.Dv AI_V4MAPPED -is specified, -an IPv4-mapped IPv6 address is returned: -.Li h_name -points to an IPv6 hex address containing the IPv4-mapped IPv6 address, -.Li h_aliases -is a -.Dv NULL -pointer, -.Li h_addrtype -is -.Dv AF_INET6 , -.Li h_length -is 16, -.Li h_addr_list[0] -is a pointer to the 16-byte binary address, and -.Li h_addr_list[1] -is a -.Dv NULL -pointer. -.Pp -It is an error when -.Ar name -is an IPv6 hex address and -.Ar af -equals -.Dv AF_INET . -The function's return value is a -.Dv NULL -pointer and the value pointed to by -.Ar error_num -equals -.Dv HOST_NOT_FOUND . -.Pp -.Fn getipnodebyaddr -takes almost the same argument as -.Xr gethostbyaddr 3 , -but adds a pointer to return an error number. -Additionally it takes care of IPv4-mapped IPv6 addresses, -and IPv4-compatible IPv6 addresses. -.Pp -.Fn getipnodebyname -and -.Fn getipnodebyaddr -dynamically allocate the structure to be returned to the caller. -.Fn freehostent -reclaims memory region allocated and returned by -.Fn getipnodebyname -or -.Fn getipnodebyaddr . -.\" -.Sh FILES -.Bl -tag -width /etc/resolv.conf -compact -.It Pa /etc/hosts -.It Pa /etc/host.conf -.It Pa /etc/resolv.conf -.El -.\" -.Sh DIAGNOSTICS -.Nm getipnodebyname -and -.Nm getipnodebyaddr -returns -.Dv NULL -on errors. -The integer values pointed to by -.Ar error_num -may then be checked to see whether this is a temporary failure -or an invalid or unknown host. -The meanings of each error code are described in -.Xr gethostbyname 3 . -.\" -.Sh SEE ALSO -.Xr gethostbyname 3 , -.Xr gethostbyaddr 3 , -.Xr hosts 5 , -.Xr services 5 , -.Xr hostname 7 , -.Xr named 8 -.Pp -R. Gilligan, S. Thomson, J. Bound, and W. Stevens, -``Basic Socket Interface Extensions for IPv6,'' RFC2553, March 1999. -.\" -.Sh HISTORY -The implementation first appeared in KAME advanced networking kit. -.\" -.Sh STANDARDS -.Fn getipnodebyname -and -.Fn getipnodebyaddr -are documented in ``Basic Socket Interface Extensions for IPv6'' -.Pq RFC2553 . -.\" -.Sh BUGS -The text was shamelessly copied from RFC2553. diff --git a/lib/libc/net/getnameinfo.3 b/lib/libc/net/getnameinfo.3 deleted file mode 100644 index 732af8e..0000000 --- a/lib/libc/net/getnameinfo.3 +++ /dev/null @@ -1,232 +0,0 @@ -.\" Copyright (c) 1983, 1987, 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. -.\" -.\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95 -.\" $Id: getnameinfo.3,v 1.2 1999/10/07 04:46:27 itojun Exp $ -.\" $FreeBSD$ -.\" -.Dd May 25, 1995 -.Dt GETNAMEINFO 3 -.Os KAME -.\" -.Sh NAME -.Nm getnameinfo -.Nd address-to-nodename translation in protocol-independent manner -.\" -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Fd #include -.Ft int -.Fn getnameinfo "const struct sockaddr *sa" "socklen_t salen" "char *host" "size_t hostlen" "char *serv" "size_t servlen" "int flags" -.\" -.Sh DESCRIPTION -The -.Fn getnameinfo -function is defined for protocol-independent address-to-nodename translation. -Its functionality is a reverse conversion of -.Xr getaddrinfo 3 , -and implements similar functionality with -.Xr gethostbyaddr 3 and -.Xr getservbyport 3 -in more sophisticated manner. -.Pp -This function looks up an IP address and port number provided by the -caller in the DNS and system-specific database, and returns text -strings for both in buffers provided by the caller. -The function indicates successful completion by a zero return value; -a non-zero return value indicates failure. -.Pp -The first argument, -.Fa sa , -points to either a -.Fa sockaddr_in -structure (for IPv4) or a -.Fa sockaddr_in6 -structure (for IPv6) that holds the IP address and port number. -The -.Fa salen -argument gives the length of the -.Fa sockaddr_in -or -.Fa sockaddr_in6 -structure. -.Pp -The function returns the nodename associated with the IP address in -the buffer pointed to by the -.Fa host -argument. -The caller provides the size of this buffer via the -.Fa hostlen -argument. -The service name associated with the port number is returned in the buffer -pointed to by -.Fa serv , -and the -.Fa servlen -argument gives the length of this buffer. -The caller specifies not to return either string by providing a zero -value for the -.Fa hostlen -or -.Fa servlen -arguments. -Otherwise, the caller must provide buffers large enough to hold the -nodename and the service name, including the terminating null characters. -.Pp -Unfortunately most systems do not provide constants that specify the -maximum size of either a fully-qualified domain name or a service name. -Therefore to aid the application in allocating buffers for these two -returned strings the following constants are defined in -.Li : -.Bd -literal -offset -#define NI_MAXHOST 1025 -#define NI_MAXSERV 32 -.Ed -.Pp -The first value is actually defined as the constant -.Dv MAXDNAME -in recent versions of BIND's -.Li -header -.Po -older versions of BIND define this constant to be 256 -.Pc -and the second is a guess based on the services listed in the current -Assigned Numbers RFC. -.Pp -The final argument is a -.Fa flag -that changes the default actions of this function. -By default the fully-qualified domain name (FQDN) for the host is -looked up in the DNS and returned. -If the flag bit -.Dv NI_NOFQDN -is set, only the nodename portion of the FQDN is returned for local hosts. -.Pp -If the -.Fa flag -bit -.Dv NI_NUMERICHOST -is set, or if the host's name cannot be located in the DNS, -the numeric form of the host's address is returned instead of its name -.Po -e.g., by calling -.Fn inet_ntop -instead of -.Fn getnodebyaddr -.Pc . -If the -.Fa flag -bit -.Dv NI_NAMEREQD -is set, an error is returned if the host's name cannot be located in the DNS. -.Pp -If the flag bit -.Dv NI_NUMERICSERV -is set, the numeric form of the service address is returned -.Pq e.g., its port number -instead of its name. -The two -.Dv NI_NUMERICxxx -flags are required to support the -.Li "-n" -flag that many commands provide. -.Pp -A fifth flag bit, -.Dv NI_DGRAM , -specifies that the service is a datagram service, and causes -.Fn getservbyport -to be called with a second argument of "udp" instead of its default of "tcp". -This is required for the few ports (512-514) -that have different services for UDP and TCP. -.Pp -These -.Dv NI_xxx -flags are defined in -.Li . -.\" -.Sh EXTENSION -The implementation allows experimental numeric IPv6 address notation with -scope identifier. -IPv6 link-local address will appear as string like -.Dq Li fe80::1@ne0 , -if -.Dv NI_WITHSCOPEID -bit is enabled in -.Ar flags -argument. -Refer to -.Xr getaddrinfo 3 -for the notation. -.\" -.Sh FILES -.Bl -tag -width /etc/resolv.conf -compact -.It Pa /etc/hosts -.It Pa /etc/host.conf -.It Pa /etc/resolv.conf -.El -.\" -.Sh DIAGNOSTICS -The function indicates successful completion by a zero return value; -a non-zero return value indicates failure. -.\" -.Sh SEE ALSO -.Xr getaddrinfo 3 , -.Xr gethostbyaddr 3 , -.Xr getservbyport 3 , -.Xr hosts 5 , -.Xr services 5 , -.Xr hostname 7 , -.Xr named 8 -.Pp -.Rs -.%A R. Gilligan -.%A S. Thomson -.%A J. Bound -.%A W. Stevens -.%T Basic Socket Interface Extensions for IPv6 -.%R RFC2553 -.%D March 1999 -.Re -.\" -.Sh HISTORY -The implementation first appeared in WIDE Hydrangea IPv6 protocol stack kit. -.\" -.Sh STANDARDS -The -.Fn getaddrinfo -function is defined IEEE POSIX 1003.1g draft specification, -and documented in ``Basic Socket Interface Extensions for IPv6'' -.Pq RFC2533 . -.\" -.Sh BUGS -The text was shamelessly copied from RFC2553. diff --git a/lib/libc/net/getnameinfo.c b/lib/libc/net/getnameinfo.c deleted file mode 100644 index 5edcffb..0000000 --- a/lib/libc/net/getnameinfo.c +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -/* - * Issues to be discussed: - * - Thread safe-ness must be checked - * - Return values. There seems to be no standard for return value (RFC2553) - * but INRIA implementation returns EAI_xxx defined for getaddrinfo(). - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define SUCCESS 0 -#define ANY 0 -#define YES 1 -#define NO 0 - -static struct afd { - int a_af; - int a_addrlen; - int a_socklen; - int a_off; -} afdl [] = { -#ifdef INET6 - {PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6), - offsetof(struct sockaddr_in6, sin6_addr)}, -#endif - {PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in), - offsetof(struct sockaddr_in, sin_addr)}, - {0, 0, 0}, -}; - -struct sockinet { - u_char si_len; - u_char si_family; - u_short si_port; -}; - -#define ENI_NOSOCKET 0 -#define ENI_NOSERVHOST 1 -#define ENI_NOHOSTNAME 2 -#define ENI_MEMORY 3 -#define ENI_SYSTEM 4 -#define ENI_FAMILY 5 -#define ENI_SALEN 6 - -int -getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) - const struct sockaddr *sa; - size_t salen; - char *host; - size_t hostlen; - char *serv; - size_t servlen; - int flags; -{ - struct afd *afd; - struct servent *sp; - struct hostent *hp; - u_short port; - int family, i; - char *addr, *p; - u_long v4a; - int h_error; - char numserv[512]; - char numaddr[512]; - int noserv = 0; - - if (sa == NULL) - return ENI_NOSOCKET; - - if (sa->sa_len != salen) - return ENI_SALEN; - - family = sa->sa_family; - for (i = 0; afdl[i].a_af; i++) - if (afdl[i].a_af == family) { - afd = &afdl[i]; - goto found; - } - return ENI_FAMILY; - - found: - if (salen != afd->a_socklen) - return ENI_SALEN; - - port = ((struct sockinet *)sa)->si_port; /* network byte order */ - addr = (char *)sa + afd->a_off; - - if (serv == NULL || servlen == 0) { - noserv = 1; - } else { - if (flags & NI_NUMERICSERV) - sp = NULL; - else { - sp = getservbyport(port, - (flags & NI_DGRAM) ? "udp" : "tcp"); - } - if (sp) { - if (strlen(sp->s_name) > servlen) - return ENI_MEMORY; - strcpy(serv, sp->s_name); - } else { - snprintf(numserv, sizeof(numserv), "%d", ntohs(port)); - if (strlen(numserv) > servlen) - return ENI_MEMORY; - strcpy(serv, numserv); - } - } - - switch (sa->sa_family) { - case AF_INET: - v4a = ntohl(((struct sockaddr_in *)sa)->sin_addr.s_addr); - if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a)) - flags |= NI_NUMERICHOST; - v4a >>= IN_CLASSA_NSHIFT; - if (v4a == 0) - flags |= NI_NUMERICHOST; - break; -#ifdef INET6 - case AF_INET6: - { - struct sockaddr_in6 *sin6; - sin6 = (struct sockaddr_in6 *)sa; - if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) || - IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) - flags |= NI_NUMERICHOST; - } - break; -#endif - } - if (host == NULL || hostlen == 0) { - if (noserv == 1) - return ENI_NOSERVHOST; - } else if (flags & NI_NUMERICHOST) { - /* NUMERICHOST and NAMEREQD conflicts with each other */ - if (flags & NI_NAMEREQD) - return ENI_NOHOSTNAME; - if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr)) - == NULL) - return ENI_SYSTEM; - if (strlen(numaddr) > hostlen) - return ENI_MEMORY; - strcpy(host, numaddr); -#ifdef INET6 - if (afd->a_af == AF_INET6 && - (IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)addr) || - IN6_IS_ADDR_MULTICAST((struct in6_addr *)addr)) && - ((struct sockaddr_in6 *)sa)->sin6_scope_id) { - if (flags & NI_WITHSCOPEID) { - char *ep = strchr(host, '\0'); - unsigned int ifindex = - ((struct sockaddr_in6 *)sa)->sin6_scope_id; - char ifname[IF_NAMESIZE * 2 /* for safety */]; - int scopelen, numaddrlen; - - if ((if_indextoname(ifindex, ifname)) == NULL) - return ENI_SYSTEM; - scopelen = strlen(ifname); - numaddrlen = strlen(host); - if (numaddrlen + 1 /* SCOPE_DELIMITER */ - + scopelen > hostlen) - return ENI_MEMORY; - /* - * Construct - */ - memcpy(host + numaddrlen + 1, ifname, scopelen); - host[numaddrlen] = SCOPE_DELIMITER; - host[numaddrlen + 1 + scopelen] = '\0'; - } - } -#endif /* INET6 */ - } else { - hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error); - if (hp) { - if (flags & NI_NOFQDN) { - p = strchr(hp->h_name, '.'); - if (p) *p = '\0'; - } - if (strlen(hp->h_name) > hostlen) { - freehostent(hp); - return ENI_MEMORY; - } - strcpy(host, hp->h_name); - freehostent(hp); - } else { - if (flags & NI_NAMEREQD) - return ENI_NOHOSTNAME; - if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr)) - == NULL) - return ENI_NOHOSTNAME; - if (strlen(numaddr) > hostlen) - return ENI_MEMORY; - strcpy(host, numaddr); - } - } - return SUCCESS; -} diff --git a/lib/libc/net/getnetbydns.c b/lib/libc/net/getnetbydns.c deleted file mode 100644 index 65d9d2d..0000000 --- a/lib/libc/net/getnetbydns.c +++ /dev/null @@ -1,313 +0,0 @@ -/*- - * Copyright (c) 1985, 1988, 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. - * - - * --Copyright-- - */ -/* Portions Copyright (c) 1993 Carlos Leandro and Rui Salgueiro - * Dep. Matematica Universidade de Coimbra, Portugal, Europe - * - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93"; -static char rcsid[] = "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "res_config.h" - -extern int h_errno; - -#define BYADDR 0 -#define BYNAME 1 -#define MAXALIASES 35 - -#if PACKETSZ > 1024 -#define MAXPACKET PACKETSZ -#else -#define MAXPACKET 1024 -#endif - -typedef union { - HEADER hdr; - u_char buf[MAXPACKET]; -} querybuf; - -typedef union { - long al; - char ac; -} align; - -static struct netent * -getnetanswer(answer, anslen, net_i) - querybuf *answer; - int anslen; - int net_i; -{ - - register HEADER *hp; - register u_char *cp; - register int n; - u_char *eom; - int type, class, buflen, ancount, qdcount, haveanswer, i, nchar; - char aux1[MAXHOSTNAMELEN], aux2[MAXHOSTNAMELEN], ans[MAXHOSTNAMELEN]; - char *in, *st, *pauxt, *bp, **ap; - char *paux1 = &aux1[0], *paux2 = &aux2[0], flag = 0; -static struct netent net_entry; -static char *net_aliases[MAXALIASES], netbuf[PACKETSZ]; - - /* - * find first satisfactory answer - * - * answer --> +------------+ ( MESSAGE ) - * | Header | - * +------------+ - * | Question | the question for the name server - * +------------+ - * | Answer | RRs answering the question - * +------------+ - * | Authority | RRs pointing toward an authority - * | Additional | RRs holding additional information - * +------------+ - */ - eom = answer->buf + anslen; - hp = &answer->hdr; - ancount = ntohs(hp->ancount); /* #/records in the answer section */ - qdcount = ntohs(hp->qdcount); /* #/entries in the question section */ - bp = netbuf; - buflen = sizeof(netbuf); - cp = answer->buf + HFIXEDSZ; - if (!qdcount) { - if (hp->aa) - h_errno = HOST_NOT_FOUND; - else - h_errno = TRY_AGAIN; - return (NULL); - } - while (qdcount-- > 0) - cp += __dn_skipname(cp, eom) + QFIXEDSZ; - ap = net_aliases; - *ap = NULL; - net_entry.n_aliases = net_aliases; - haveanswer = 0; - while (--ancount >= 0 && cp < eom) { - n = dn_expand(answer->buf, eom, cp, bp, buflen); - if ((n < 0) || !res_dnok(bp)) - break; - cp += n; - ans[0] = '\0'; - (void)strncpy(&ans[0], bp, sizeof(ans) - 1); - ans[sizeof(ans) - 1] = '\0'; - GETSHORT(type, cp); - GETSHORT(class, cp); - cp += INT32SZ; /* TTL */ - GETSHORT(n, cp); - if (class == C_IN && type == T_PTR) { - n = dn_expand(answer->buf, eom, cp, bp, buflen); - if ((n < 0) || !res_hnok(bp)) { - cp += n; - return (NULL); - } - cp += n; - *ap++ = bp; - bp += strlen(bp) + 1; - net_entry.n_addrtype = - (class == C_IN) ? AF_INET : AF_UNSPEC; - haveanswer++; - } - } - if (haveanswer) { - *ap = NULL; - switch (net_i) { - case BYADDR: - net_entry.n_name = *net_entry.n_aliases; - net_entry.n_net = 0L; - break; - case BYNAME: - in = *net_entry.n_aliases; - net_entry.n_name = &ans[0]; - aux2[0] = '\0'; - for (i = 0; i < 4; i++) { - for (st = in, nchar = 0; - *st != '.'; - st++, nchar++) - ; - if (nchar != 1 || *in != '0' || flag) { - flag = 1; - (void)strncpy(paux1, - (i==0) ? in : in-1, - (i==0) ?nchar : nchar+1); - paux1[(i==0) ? nchar : nchar+1] = '\0'; - pauxt = paux2; - paux2 = strcat(paux1, paux2); - paux1 = pauxt; - } - in = ++st; - } - net_entry.n_net = inet_network(paux2); - break; - } - net_entry.n_aliases++; - return (&net_entry); - } - h_errno = TRY_AGAIN; - return (NULL); -} - -struct netent * -_getnetbydnsaddr(net, net_type) - register unsigned long net; - register int net_type; -{ - unsigned int netbr[4]; - int nn, anslen; - querybuf buf; - char qbuf[MAXDNAME]; - unsigned long net2; - struct netent *net_entry; - - if (net_type != AF_INET) - return (NULL); - - for (nn = 4, net2 = net; net2; net2 >>= 8) - netbr[--nn] = net2 & 0xff; - switch (nn) { - case 3: /* Class A */ - sprintf(qbuf, "0.0.0.%u.in-addr.arpa", netbr[3]); - break; - case 2: /* Class B */ - sprintf(qbuf, "0.0.%u.%u.in-addr.arpa", netbr[3], netbr[2]); - break; - case 1: /* Class C */ - sprintf(qbuf, "0.%u.%u.%u.in-addr.arpa", netbr[3], netbr[2], - netbr[1]); - break; - case 0: /* Class D - E */ - sprintf(qbuf, "%u.%u.%u.%u.in-addr.arpa", netbr[3], netbr[2], - netbr[1], netbr[0]); - break; - } - anslen = res_query(qbuf, C_IN, T_PTR, (u_char *)&buf, sizeof(buf)); - if (anslen < 0) { -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf("res_query failed\n"); -#endif - return (NULL); - } - net_entry = getnetanswer(&buf, anslen, BYADDR); - if (net_entry) { - unsigned u_net = net; /* maybe net should be unsigned ? */ - - /* Strip trailing zeros */ - while ((u_net & 0xff) == 0 && u_net != 0) - u_net >>= 8; - net_entry->n_net = u_net; - return (net_entry); - } - return (NULL); -} - -struct netent * -_getnetbydnsname(net) - register const char *net; -{ - int anslen; - querybuf buf; - char qbuf[MAXDNAME]; - - if ((_res.options & RES_INIT) == 0 && res_init() == -1) { - h_errno = NETDB_INTERNAL; - return (NULL); - } - strncpy(qbuf, net, sizeof(qbuf) - 1); - qbuf[sizeof(qbuf) - 1] = '\0'; - anslen = res_search(qbuf, C_IN, T_PTR, (u_char *)&buf, sizeof(buf)); - if (anslen < 0) { -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf("res_query failed\n"); -#endif - return (NULL); - } - return getnetanswer(&buf, anslen, BYNAME); -} - -void -_setnetdnsent(stayopen) - int stayopen; -{ - if (stayopen) - _res.options |= RES_STAYOPEN | RES_USEVC; -} - -void -_endnetdnsent() -{ - _res.options &= ~(RES_STAYOPEN | RES_USEVC); - res_close(); -} diff --git a/lib/libc/net/getnetbyht.c b/lib/libc/net/getnetbyht.c deleted file mode 100644 index ab164b1..0000000 --- a/lib/libc/net/getnetbyht.c +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* Portions Copyright (c) 1993 Carlos Leandro and Rui Salgueiro - * Dep. Matematica Universidade de Coimbra, Portugal, Europe - * - * 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. - * - * from getnetent.c 1.1 (Coimbra) 93/06/02 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getnetent.c 8.1 (Berkeley) 6/4/93"; -static char orig_rcsid[] = "From: Id: getnetent.c,v 8.4 1997/06/01 20:34:37 vixie Exp"; -static chat rcsid[] = "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define MAXALIASES 35 - -static FILE *netf; -static char line[BUFSIZ+1]; -static struct netent net; -static char *net_aliases[MAXALIASES]; -static int _net_stayopen; - -void -_setnethtent(f) - int f; -{ - - if (netf == NULL) - netf = fopen(_PATH_NETWORKS, "r" ); - else - rewind(netf); - _net_stayopen |= f; -} - -void -_endnethtent() -{ - - if (netf) { - fclose(netf); - netf = NULL; - } - _net_stayopen = 0; -} - -struct netent * -getnetent() -{ - char *p; - register char *cp, **q; - - if (netf == NULL && (netf = fopen(_PATH_NETWORKS, "r" )) == NULL) - return (NULL); -again: - p = fgets(line, sizeof line, netf); - if (p == NULL) - return (NULL); - if (*p == '#') - goto again; - cp = strpbrk(p, "#\n"); - if (cp == NULL) - goto again; - *cp = '\0'; - net.n_name = p; - cp = strpbrk(p, " \t"); - if (cp == NULL) - goto again; - *cp++ = '\0'; - while (*cp == ' ' || *cp == '\t') - cp++; - p = strpbrk(cp, " \t"); - if (p != NULL) - *p++ = '\0'; - net.n_net = inet_network(cp); - net.n_addrtype = AF_INET; - q = net.n_aliases = net_aliases; - if (p != NULL) - cp = p; - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (q < &net_aliases[MAXALIASES - 1]) - *q++ = cp; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - } - *q = NULL; - return (&net); -} - -struct netent * -_getnetbyhtname(name) - register const char *name; -{ - register struct netent *p; - register char **cp; - - setnetent(_net_stayopen); - while ( (p = getnetent()) ) { - if (strcasecmp(p->n_name, name) == 0) - break; - for (cp = p->n_aliases; *cp != 0; cp++) - if (strcasecmp(*cp, name) == 0) - goto found; - } -found: - if (!_net_stayopen) - endnetent(); - return (p); -} - -struct netent * -_getnetbyhtaddr(net, type) - register unsigned long net; - register int type; -{ - register struct netent *p; - - setnetent(_net_stayopen); - while ( (p = getnetent()) ) - if (p->n_addrtype == type && p->n_net == net) - break; - if (!_net_stayopen) - endnetent(); - return (p); -} diff --git a/lib/libc/net/getnetbynis.c b/lib/libc/net/getnetbynis.c deleted file mode 100644 index 0ab7073..0000000 --- a/lib/libc/net/getnetbynis.c +++ /dev/null @@ -1,177 +0,0 @@ -/*- - * Copyright (c) 1994, Garrett Wollman - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)$FreeBSD$"; -static char rcsid[] = "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef YP -#include -#include -#include -#endif - -#define MAXALIASES 35 -#define MAXADDRS 35 - -#ifdef YP -static char *host_aliases[MAXALIASES]; -#endif /* YP */ - -static struct netent * -_getnetbynis(name, map, af) - const char *name; - char *map; - int af; -{ -#ifdef YP - register char *cp, **q; - static char *result; - int resultlen; - static struct netent h; - static char *domain = (char *)NULL; - static char ypbuf[YPMAXRECORD + 2]; - - switch(af) { - case AF_INET: - break; - default: - case AF_INET6: - errno = EAFNOSUPPORT; - return NULL; - } - - if (domain == (char *)NULL) - if (yp_get_default_domain (&domain)) - return (NULL); - - if (yp_match(domain, map, name, strlen(name), &result, &resultlen)) - return (NULL); - - bcopy((char *)result, (char *)&ypbuf, resultlen); - ypbuf[resultlen] = '\0'; - free(result); - result = (char *)&ypbuf; - - if ((cp = index(result, '\n'))) - *cp = '\0'; - - cp = strpbrk(result, " \t"); - *cp++ = '\0'; - h.n_name = result; - - while (*cp == ' ' || *cp == '\t') - cp++; - - h.n_net = inet_network(cp); - h.n_addrtype = AF_INET; - - q = h.n_aliases = host_aliases; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (q < &host_aliases[MAXALIASES - 1]) - *q++ = cp; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - } - *q = NULL; - return (&h); -#else - return (NULL); -#endif -} - -struct netent * -_getnetbynisname(name) - const char *name; -{ - return _getnetbynis(name, "networks.byname", AF_INET); -} - -struct netent * -_getnetbynisaddr(addr, af) - unsigned long addr; - int af; -{ - char *str, *cp; - unsigned long net2; - int nn; - unsigned int netbr[4]; - char buf[MAXDNAME]; - - if (af != AF_INET) { - errno = EAFNOSUPPORT; - return (NULL); - } - - for (nn = 4, net2 = addr; net2; net2 >>= 8) { - netbr[--nn] = net2 & 0xff; - } - - switch (nn) { - case 3: /* Class A */ - sprintf(buf, "%u", netbr[3]); - break; - case 2: /* Class B */ - sprintf(buf, "%u.%u", netbr[2], netbr[3]); - break; - case 1: /* Class C */ - sprintf(buf, "%u.%u.%u", netbr[1], netbr[2], netbr[3]); - break; - case 0: /* Class D - E */ - sprintf(buf, "%u.%u.%u.%u", netbr[0], netbr[1], - netbr[2], netbr[3]); - break; - } - - str = (char *)&buf; - cp = str + (strlen(str) - 2); - - while(!strcmp(cp, ".0")) { - *cp = '\0'; - cp = str + (strlen(str) - 2); - } - - return _getnetbynis(str, "networks.byaddr", af); -} diff --git a/lib/libc/net/getnetent.3 b/lib/libc/net/getnetent.3 deleted file mode 100644 index 1bf3664..0000000 --- a/lib/libc/net/getnetent.3 +++ /dev/null @@ -1,160 +0,0 @@ -.\" Copyright (c) 1983, 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. -.\" -.\" @(#)getnetent.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt GETNETENT 3 -.Os BSD 4.2 -.Sh NAME -.Nm getnetent , -.Nm getnetbyaddr , -.Nm getnetbyname , -.Nm setnetent , -.Nm endnetent -.Nd get network entry -.Sh SYNOPSIS -.Fd #include -.Ft struct netent * -.Fn getnetent void -.Ft struct netent * -.Fn getnetbyname "const char *name" -.Ft struct netent * -.Fn getnetbyaddr "unsigned long net" "int type" -.Ft void -.Fn setnetent "int stayopen" -.Ft void -.Fn endnetent void -.Sh DESCRIPTION -The -.Fn getnetent , -.Fn getnetbyname , -and -.Fn getnetbyaddr -functions -each return a pointer to an object with the -following structure -containing the broken-out -fields of a line in the network data base, -.Pa /etc/networks . -.Bd -literal -offset indent -struct netent { - char *n_name; /* official name of net */ - char **n_aliases; /* alias list */ - int n_addrtype; /* net number type */ - unsigned long n_net; /* net number */ -}; -.Ed -.Pp -The members of this structure are: -.Bl -tag -width n_addrtype -.It Fa n_name -The official name of the network. -.It Fa n_aliases -A zero terminated list of alternate names for the network. -.It Fa n_addrtype -The type of the network number returned; currently only AF_INET. -.It Fa n_net -The network number. Network numbers are returned in machine byte -order. -.El -.Pp -The -.Fn getnetent -function -reads the next line of the file, opening the file if necessary. -.Pp -The -.Fn setnetent -function -opens and rewinds the file. If the -.Fa stayopen -flag is non-zero, -the net data base will not be closed after each call to -.Fn getnetbyname -or -.Fn getnetbyaddr . -.Pp -The -.Fn endnetent -function -closes the file. -.Pp -The -.Fn getnetbyname -function -and -.Fn getnetbyaddr -sequentially search from the beginning -of the file until a matching -net name or -net address and type is found, -or until -.Dv EOF -is encountered. -The -.Fa type -must be -.Dv AF_INET . -Network numbers are supplied in host order. -.Sh FILES -.Bl -tag -width /etc/networks -compact -.It Pa /etc/networks -.El -.Sh DIAGNOSTICS -Null pointer -(0) returned on -.Dv EOF -or error. -.Sh SEE ALSO -.Xr networks 5 -.Pp -.%T RFC 1101 -.Sh HISTORY -The -.Fn getnetent , -.Fn getnetbyaddr , -.Fn getnetbyname , -.Fn setnetent , -and -.Fn endnetent -functions appeared in -.Bx 4.2 . -.Sh BUGS -The data space used by -these functions is static; if future use requires the data, it should be -copied before any subsequent calls to these functions overwrite it. -Only Internet network -numbers are currently understood. -Expecting network numbers to fit -in no more than 32 bits is probably -naive. diff --git a/lib/libc/net/getnetnamadr.c b/lib/libc/net/getnetnamadr.c deleted file mode 100644 index cb5871b..0000000 --- a/lib/libc/net/getnetnamadr.c +++ /dev/null @@ -1,190 +0,0 @@ -/*- - * Copyright (c) 1994, Garrett Wollman - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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 rcsid[] = "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef _PATH_NETCONF -#define _PATH_NETCONF "/etc/host.conf" -#endif - -enum service_type { - SERVICE_NONE = 0, - SERVICE_BIND, - SERVICE_TABLE, - SERVICE_NIS }; -#define SERVICE_MAX SERVICE_NIS - -static struct { - const char *name; - enum service_type type; -} service_names[] = { - { "hosts", SERVICE_TABLE }, - { "/etc/hosts", SERVICE_TABLE }, - { "hosttable", SERVICE_TABLE }, - { "htable", SERVICE_TABLE }, - { "bind", SERVICE_BIND }, - { "dns", SERVICE_BIND }, - { "domain", SERVICE_BIND }, - { "yp", SERVICE_NIS }, - { "yellowpages", SERVICE_NIS }, - { "nis", SERVICE_NIS }, - { 0, SERVICE_NONE } -}; - -static enum service_type service_order[SERVICE_MAX + 1]; -static int service_done = 0; - -static enum service_type -get_service_name(const char *name) { - int i; - for(i = 0; service_names[i].type != SERVICE_NONE; i++) { - if(!strcasecmp(name, service_names[i].name)) { - return service_names[i].type; - } - } - return SERVICE_NONE; -} - -static void -init_services() -{ - char *cp, *p, buf[BUFSIZ]; - register int cc = 0; - FILE *fd; - - if ((fd = (FILE *)fopen(_PATH_NETCONF, "r")) == NULL) { - /* make some assumptions */ - service_order[0] = SERVICE_TABLE; - service_order[1] = SERVICE_NONE; - } else { - while (fgets(buf, BUFSIZ, fd) != NULL && cc < SERVICE_MAX) { - if(buf[0] == '#') - continue; - - p = buf; - while ((cp = strsep(&p, "\n \t,:;")) != NULL && *cp == '\0') - ; - if (cp == NULL) - continue; - do { - if (isalpha((unsigned char)cp[0])) { - service_order[cc] = get_service_name(cp); - if(service_order[cc] != SERVICE_NONE) - cc++; - } - while ((cp = strsep(&p, "\n \t,:;")) != NULL && *cp == '\0') - ; - } while(cp != NULL && cc < SERVICE_MAX); - } - service_order[cc] = SERVICE_NONE; - fclose(fd); - } - service_done = 1; -} - -struct netent * -getnetbyname(const char *name) -{ - struct netent *hp = 0; - int nserv = 0; - - if (!service_done) - init_services(); - - while (!hp) { - switch (service_order[nserv]) { - case SERVICE_NONE: - return NULL; - case SERVICE_TABLE: - hp = _getnetbyhtname(name); - break; - case SERVICE_BIND: - hp = _getnetbydnsname(name); - break; - case SERVICE_NIS: - hp = _getnetbynisname(name); - break; - } - nserv++; - } - return hp; -} - -struct netent * -getnetbyaddr(addr, af) - u_long addr; - int af; -{ - struct netent *hp = 0; - int nserv = 0; - - if (!service_done) - init_services(); - - while (!hp) { - switch (service_order[nserv]) { - case SERVICE_NONE: - return 0; - case SERVICE_TABLE: - hp = _getnetbyhtaddr(addr, af); - break; - case SERVICE_BIND: - hp = _getnetbydnsaddr(addr, af); - break; - case SERVICE_NIS: - hp = _getnetbynisaddr(addr, af); - break; - } - nserv++; - } - return hp; -} - -void -setnetent(stayopen) - int stayopen; -{ - _setnethtent(stayopen); - _setnetdnsent(stayopen); -} - -void -endnetent() -{ - _endnethtent(); - _endnetdnsent(); -} diff --git a/lib/libc/net/getproto.c b/lib/libc/net/getproto.c deleted file mode 100644 index 46f46d3..0000000 --- a/lib/libc/net/getproto.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getproto.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -extern int _proto_stayopen; - -struct protoent * -getprotobynumber(proto) - register int proto; -{ - register struct protoent *p; - - setprotoent(_proto_stayopen); - while ( (p = getprotoent()) ) - if (p->p_proto == proto) - break; - if (!_proto_stayopen) - endprotoent(); - return (p); -} diff --git a/lib/libc/net/getprotoent.3 b/lib/libc/net/getprotoent.3 deleted file mode 100644 index fad937e..0000000 --- a/lib/libc/net/getprotoent.3 +++ /dev/null @@ -1,147 +0,0 @@ -.\" Copyright (c) 1983, 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. -.\" -.\" @(#)getprotoent.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt GETPROTOENT 3 -.Os BSD 4.2 -.Sh NAME -.Nm getprotoent , -.Nm getprotobynumber , -.Nm getprotobyname , -.Nm setprotoent , -.Nm endprotoent -.Nd get protocol entry -.Sh SYNOPSIS -.Fd #include -.Ft struct protoent * -.Fn getprotoent void -.Ft struct protoent * -.Fn getprotobyname "const char *name" -.Ft struct protoent * -.Fn getprotobynumber "int proto" -.Ft void -.Fn setprotoent "int stayopen" -.Ft void -.Fn endprotoent void -.Sh DESCRIPTION -The -.Fn getprotoent , -.Fn getprotobyname , -and -.Fn getprotobynumber -functions -each return a pointer to an object with the -following structure -containing the broken-out -fields of a line in the network protocol data base, -.Pa /etc/protocols . -.Bd -literal -offset indent -.Pp -struct protoent { - char *p_name; /* official name of protocol */ - char **p_aliases; /* alias list */ - int p_proto; /* protocol number */ -}; -.Ed -.Pp -The members of this structure are: -.Bl -tag -width p_aliases -.It Fa p_name -The official name of the protocol. -.It Fa p_aliases -A zero terminated list of alternate names for the protocol. -.It Fa p_proto -The protocol number. -.El -.Pp -The -.Fn getprotoent -function -reads the next line of the file, opening the file if necessary. -.Pp -The -.Fn setprotoent -function -opens and rewinds the file. If the -.Fa stayopen -flag is non-zero, -the net data base will not be closed after each call to -.Fn getprotobyname -or -.Fn getprotobynumber . -.Pp -The -.Fn endprotoent -function -closes the file. -.Pp -The -.Fn getprotobyname -function -and -.Fn getprotobynumber -sequentially search from the beginning -of the file until a matching -protocol name or -protocol number is found, -or until -.Dv EOF -is encountered. -.Sh RETURN VALUES -Null pointer -(0) returned on -.Dv EOF -or error. -.Sh FILES -.Bl -tag -width /etc/protocols -compact -.It Pa /etc/protocols -.El -.Sh SEE ALSO -.Xr protocols 5 -.Sh HISTORY -The -.Fn getprotoent , -.Fn getprotobynumber , -.Fn getprotobyname , -.Fn setprotoent , -and -.Fn endprotoent -functions appeared in -.Bx 4.2 . -.Sh BUGS -These functions use a static data space; -if the data is needed for future use, it should be -copied before any subsequent calls overwrite it. -Only the Internet -protocols are currently understood. diff --git a/lib/libc/net/getprotoent.c b/lib/libc/net/getprotoent.c deleted file mode 100644 index c10ae33..0000000 --- a/lib/libc/net/getprotoent.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getprotoent.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include - -#define MAXALIASES 35 - -static FILE *protof = NULL; -static char line[BUFSIZ+1]; -static struct protoent proto; -static char *proto_aliases[MAXALIASES]; -int _proto_stayopen; - -void -setprotoent(f) - int f; -{ - if (protof == NULL) - protof = fopen(_PATH_PROTOCOLS, "r" ); - else - rewind(protof); - _proto_stayopen |= f; -} - -void -endprotoent() -{ - if (protof) { - fclose(protof); - protof = NULL; - } - _proto_stayopen = 0; -} - -struct protoent * -getprotoent() -{ - char *p; - register char *cp, **q; - - if (protof == NULL && (protof = fopen(_PATH_PROTOCOLS, "r" )) == NULL) - return (NULL); -again: - if ((p = fgets(line, BUFSIZ, protof)) == NULL) - return (NULL); - if (*p == '#') - goto again; - cp = strpbrk(p, "#\n"); - if (cp == NULL) - goto again; - *cp = '\0'; - proto.p_name = p; - cp = strpbrk(p, " \t"); - if (cp == NULL) - goto again; - *cp++ = '\0'; - while (*cp == ' ' || *cp == '\t') - cp++; - p = strpbrk(cp, " \t"); - if (p != NULL) - *p++ = '\0'; - proto.p_proto = atoi(cp); - q = proto.p_aliases = proto_aliases; - if (p != NULL) { - cp = p; - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (q < &proto_aliases[MAXALIASES - 1]) - *q++ = cp; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - } - } - *q = NULL; - return (&proto); -} diff --git a/lib/libc/net/getprotoname.c b/lib/libc/net/getprotoname.c deleted file mode 100644 index 0832acf..0000000 --- a/lib/libc/net/getprotoname.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getprotoname.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -extern int _proto_stayopen; - -struct protoent * -getprotobyname(name) - register const char *name; -{ - register struct protoent *p; - register char **cp; - - setprotoent(_proto_stayopen); - while ( (p = getprotoent()) ) { - if (strcmp(p->p_name, name) == 0) - break; - for (cp = p->p_aliases; *cp != 0; cp++) - if (strcmp(*cp, name) == 0) - goto found; - } -found: - if (!_proto_stayopen) - endprotoent(); - return (p); -} diff --git a/lib/libc/net/getservbyname.c b/lib/libc/net/getservbyname.c deleted file mode 100644 index 124f5ac..0000000 --- a/lib/libc/net/getservbyname.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getservbyname.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -extern int _serv_stayopen; - -struct servent * -getservbyname(name, proto) - const char *name, *proto; -{ - register struct servent *p; - register char **cp; - -#ifdef YP - extern char *___getservbyname_yp; - extern char *___getservbyproto_yp; - - ___getservbyname_yp = (char *)name; - ___getservbyproto_yp = (char *)proto; -#endif - - setservent(_serv_stayopen); - while ( (p = getservent()) ) { - if (strcmp(name, p->s_name) == 0) - goto gotname; - for (cp = p->s_aliases; *cp; cp++) - if (strcmp(name, *cp) == 0) - goto gotname; - continue; -gotname: - if (proto == 0 || strcmp(p->s_proto, proto) == 0) - break; - } - if (!_serv_stayopen) - endservent(); - -#ifdef YP - ___getservbyname_yp = NULL; - ___getservbyproto_yp = NULL; -#endif - - return (p); -} diff --git a/lib/libc/net/getservbyport.c b/lib/libc/net/getservbyport.c deleted file mode 100644 index ef9a2e8..0000000 --- a/lib/libc/net/getservbyport.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getservbyport.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -extern int _serv_stayopen; - -struct servent * -getservbyport(port, proto) - int port; - const char *proto; -{ - register struct servent *p; - -#ifdef YP - extern int ___getservbyport_yp; - extern char *___getservbyproto_yp; - - ___getservbyport_yp = port; - ___getservbyproto_yp = (char *)proto; -#endif - - setservent(_serv_stayopen); - while ( (p = getservent()) ) { - if (p->s_port != port) - continue; - if (proto == 0 || strcmp(p->s_proto, proto) == 0) - break; - } - if (!_serv_stayopen) - endservent(); - -#ifdef YP - ___getservbyport_yp = 0; - ___getservbyproto_yp = NULL; -#endif - - return (p); -} diff --git a/lib/libc/net/getservent.3 b/lib/libc/net/getservent.3 deleted file mode 100644 index eac2361..0000000 --- a/lib/libc/net/getservent.3 +++ /dev/null @@ -1,157 +0,0 @@ -.\" Copyright (c) 1983, 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. -.\" -.\" From: @(#)getservent.3 8.3 (Berkeley) 1/12/94 -.\" $FreeBSD$ -.\" -.Dd July 9, 1995 -.Dt GETSERVENT 3 -.Os BSD 4.2 -.Sh NAME -.Nm getservent , -.Nm getservbyport , -.Nm getservbyname , -.Nm setservent , -.Nm endservent -.Nd get service entry -.Sh SYNOPSIS -.Fd #include -.Ft struct servent * -.Fn getservent -.Ft struct servent * -.Fn getservbyname "const char *name" "const char *proto" -.Ft struct servent * -.Fn getservbyport "int port" "const char *proto" -.Ft void -.Fn setservent "int stayopen" -.Ft void -.Fn endservent void -.Sh DESCRIPTION -The -.Fn getservent , -.Fn getservbyname , -and -.Fn getservbyport -functions -each return a pointer to an object with the -following structure -containing the broken-out -fields of a line in the network services data base, -.Pa /etc/services . -.Bd -literal -offset indent -struct servent { - char *s_name; /* official name of service */ - char **s_aliases; /* alias list */ - int s_port; /* port service resides at */ - char *s_proto; /* protocol to use */ -}; -.Ed -.Pp -The members of this structure are: -.Bl -tag -width s_aliases -.It Fa s_name -The official name of the service. -.It Fa s_aliases -A zero terminated list of alternate names for the service. -.It Fa s_port -The port number at which the service resides. -Port numbers are returned in network byte order. -.It Fa s_proto -The name of the protocol to use when contacting the -service. -.El -.Pp -The -.Fn getservent -function -reads the next line of the file, opening the file if necessary. -.Pp -The -.Fn setservent -function -opens and rewinds the file. If the -.Fa stayopen -flag is non-zero, -the net data base will not be closed after each call to -.Fn getservbyname -or -.Fn getservbyport . -.Pp -The -.Fn endservent -function -closes the file. -.Pp -The -.Fn getservbyname -and -.Fn getservbyport -functions -sequentially search from the beginning -of the file until a matching -protocol name or -port number (which must be specified in -network byte order) is found, -or until -.Dv EOF -is encountered. -If a protocol name is also supplied (non- -.Dv NULL ) , -searches must also match the protocol. -.ne 1i -.Sh FILES -.Bl -tag -width /etc/services -compact -.It Pa /etc/services -.El -.Sh DIAGNOSTICS -Null pointer -(0) returned on -.Dv EOF -or error. -.Sh SEE ALSO -.Xr getprotoent 3 , -.Xr services 5 -.Sh HISTORY -The -.Fn getservent , -.Fn getservbyport , -.Fn getservbyname , -.Fn setservent , -and -.Fn endservent -functions appeared in -.Bx 4.2 . -.Sh BUGS -These functions use static data storage; -if the data is needed for future use, it should be -copied before any subsequent calls overwrite it. -Expecting port numbers to fit in a 32 bit -quantity is probably naive. diff --git a/lib/libc/net/getservent.c b/lib/libc/net/getservent.c deleted file mode 100644 index cd4449f..0000000 --- a/lib/libc/net/getservent.c +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getservent.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#ifdef YP -#include -#include -#include -static int serv_stepping_yp = 0; -extern int _yp_check __P(( char ** )); -#endif - - -#define MAXALIASES 35 - -static FILE *servf = NULL; -static char line[BUFSIZ+1]; -static struct servent serv; -static char *serv_aliases[MAXALIASES]; -int _serv_stayopen; - -#ifdef YP -char *___getservbyname_yp = NULL; -char *___getservbyproto_yp = NULL; -int ___getservbyport_yp = 0; -static char *yp_domain = NULL; - -static int -_getservbyport_yp(line) - char *line; -{ - char *result; - int resultlen; - char buf[YPMAXRECORD + 2]; - int rv; - - snprintf(buf, sizeof(buf), "%d/%s", ntohs(___getservbyport_yp), - ___getservbyproto_yp); - - ___getservbyport_yp = 0; - ___getservbyproto_yp = NULL; - - if(!yp_domain) { - if(yp_get_default_domain(&yp_domain)) - return (0); - } - - /* - * We have to be a little flexible here. Ideally you're supposed - * to have both a services.byname and a services.byport map, but - * some systems have only services.byname. FreeBSD cheats a little - * by putting the services.byport information in the same map as - * services.byname so that either case will work. We allow for both - * possibilities here: if there is no services.byport map, we try - * services.byname instead. - */ - if ((rv = yp_match(yp_domain, "services.byport", buf, strlen(buf), - &result, &resultlen))) { - if (rv == YPERR_MAP) { - if (yp_match(yp_domain, "services.byname", buf, - strlen(buf), &result, &resultlen)) - return(0); - } else - return(0); - } - - /* getservent() expects lines terminated with \n -- make it happy */ - snprintf(line, BUFSIZ, "%.*s\n", resultlen, result); - - free(result); - return(1); -} - -static int -_getservbyname_yp(line) - char *line; -{ - char *result; - int resultlen; - char buf[YPMAXRECORD + 2]; - - if(!yp_domain) { - if(yp_get_default_domain(&yp_domain)) - return (0); - } - - snprintf(buf, sizeof(buf), "%s/%s", ___getservbyname_yp, - ___getservbyproto_yp); - - ___getservbyname_yp = 0; - ___getservbyproto_yp = NULL; - - if (yp_match(yp_domain, "services.byname", buf, strlen(buf), - &result, &resultlen)) { - return(0); - } - - /* getservent() expects lines terminated with \n -- make it happy */ - snprintf(line, BUFSIZ, "%.*s\n", resultlen, result); - - free(result); - return(1); -} - -static int -_getservent_yp(line) - char *line; -{ - static char *key = NULL; - static int keylen; - char *lastkey, *result; - int resultlen; - int rv; - - if(!yp_domain) { - if(yp_get_default_domain(&yp_domain)) - return (0); - } - - if (!serv_stepping_yp) { - if (key) - free(key); - if ((rv = yp_first(yp_domain, "services.byname", &key, &keylen, - &result, &resultlen))) { - serv_stepping_yp = 0; - return(0); - } - serv_stepping_yp = 1; - } else { - lastkey = key; - rv = yp_next(yp_domain, "services.byname", key, keylen, &key, - &keylen, &result, &resultlen); - free(lastkey); - if (rv) { - serv_stepping_yp = 0; - return (0); - } - } - - /* getservent() expects lines terminated with \n -- make it happy */ - snprintf(line, BUFSIZ, "%.*s\n", resultlen, result); - - free(result); - - return(1); -} -#endif - -void -setservent(f) - int f; -{ - if (servf == NULL) - servf = fopen(_PATH_SERVICES, "r" ); - else - rewind(servf); - _serv_stayopen |= f; -} - -void -endservent() -{ - if (servf) { - fclose(servf); - servf = NULL; - } - _serv_stayopen = 0; -} - -struct servent * -getservent() -{ - char *p; - register char *cp, **q; - -#ifdef YP - if (serv_stepping_yp && _getservent_yp(line)) { - p = (char *)&line; - goto unpack; - } -tryagain: -#endif - if (servf == NULL && (servf = fopen(_PATH_SERVICES, "r" )) == NULL) - return (NULL); -again: - if ((p = fgets(line, BUFSIZ, servf)) == NULL) - return (NULL); -#ifdef YP - if (*p == '+' && _yp_check(NULL)) { - if (___getservbyname_yp != NULL) { - if (!_getservbyname_yp(line)) - goto tryagain; - } - else if (___getservbyport_yp != 0) { - if (!_getservbyport_yp(line)) - goto tryagain; - } - else if (!_getservent_yp(line)) - goto tryagain; - } -unpack: -#endif - if (*p == '#') - goto again; - cp = strpbrk(p, "#\n"); - if (cp == NULL) - goto again; - *cp = '\0'; - serv.s_name = p; - p = strpbrk(p, " \t"); - if (p == NULL) - goto again; - *p++ = '\0'; - while (*p == ' ' || *p == '\t') - p++; - cp = strpbrk(p, ",/"); - if (cp == NULL) - goto again; - *cp++ = '\0'; - serv.s_port = htons((u_short)atoi(p)); - serv.s_proto = cp; - q = serv.s_aliases = serv_aliases; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (q < &serv_aliases[MAXALIASES - 1]) - *q++ = cp; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - } - *q = NULL; - return (&serv); -} diff --git a/lib/libc/net/herror.c b/lib/libc/net/herror.c deleted file mode 100644 index 0ab7448..0000000 --- a/lib/libc/net/herror.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 1987, 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) 1996 by Internet Software Consortium. - * - * 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. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM 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[] = "@(#)herror.c 8.1 (Berkeley) 6/4/93"; -static char rcsid[] = "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include - -const char *h_errlist[] = { - "Resolver Error 0 (no error)", - "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] }; - -int h_errno; - -/* - * 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; - - 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 = (char *)hstrerror(h_errno); - v->iov_len = strlen(v->iov_base); - v++; - v->iov_base = "\n"; - v->iov_len = 1; - writev(STDERR_FILENO, iov, (v - iov) + 1); -} - -const char * -hstrerror(err) - int err; -{ - if (err < 0) - return ("Resolver internal error"); - else if (err < h_nerr) - return (h_errlist[err]); - return ("Unknown resolver error"); -} diff --git a/lib/libc/net/if_indextoname.3 b/lib/libc/net/if_indextoname.3 deleted file mode 100644 index 0906ee0..0000000 --- a/lib/libc/net/if_indextoname.3 +++ /dev/null @@ -1,144 +0,0 @@ -.\" Copyright (c) 1983, 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. -.\" -.\" From: @(#)rcmd.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd May 21, 1998 -.Dt IF_NAMETOINDEX 3 -.Os KAME -.Sh NAME -.Nm if_nametoindex , -.Nm if_indextoname , -.Nm if_nameindex , -.Nm if_freenameindex -.Nd convert interface index to name, and vice versa -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Fd #include -.Ft "unsigned int" -.Fn if_nametoindex "const char *ifname" -.Ft "char *" -.Fn if_indextoname "unsigned int ifindex" "char *ifname" -.Ft "struct if_nameindex *" -.Fn if_nameindex "void" -.Ft "void" -.Fn if_freenameindex "struct if_nameindex *ptr" -.Sh DESCRIPTION -The functions map interface index to readable interface name -.Po -such as -.Li ``lo0'' -.Pc -, and vice versa. -.Pp -.Fn if_nametoindex -converts readable interface name to interface index -.Pp positive integer value . -If the specified interface does not exist, 0 will be returned. -.Pp -.Fn if_indextoname -converts interface index to readable interface name. -The -.Fa ifname -argument must point to a buffer of at least -.Dv IF_NAMESIZE -bytes into which the interface name corresponding to the specified index is -returned. -.Po -.Dv IF_NAMESIZE -is also defined in -.Li -and its value includes a terminating null byte at the end of the -interface name. -.Pc -This pointer is also the return value of the function. -If there is no interface corresponding to the specified index, -.Dv NULL -is returned. -.Pp -.Fn if_nameindex -returns an array of -.Fa if_nameindex -structures. -.Fa if_nametoindex -is also defined in -.Li , -and is as follows: -.Bd -literal -offset -struct if_nameindex { - unsigned int if_index; /* 1, 2, ... */ - char *if_name; /* null terminated name: "le0", ... */ -}; -.Ed -.Pp -The end of the array of structures is indicated by a structure with -an -.Fa if_index -of 0 and an -.Fa if_name -of -.Dv NULL . -The function returns a -.Dv NULL -pointer upon an error. -The memory used for this array of structures along with the interface -names pointed to by the -.Fa if_name -members is obtained dynamically. -This memory is freed by the -.Fn if_freenameindex -function. -.Pp -.Fn if_freenameindex -takes a pointer that was returned by -.Fn if_nameindex -as argument -.Pq Fa ptr , -and it reclaims the region allocated. -.Sh DIAGNOSTICS -.Fn if_nametoindex -returns 0 on error, positive integer on success. -.Fn if_indextoname -and -.Fn if_nameindex -return -.Dv NULL -on errors. -.Sh SEE ALSO -R. Gilligan, S. Thomson, J. Bound, and W. Stevens, -``Basic Socket Interface Extensions for IPv6,'' RFC2553, March 1999. -.Sh HISTORY -The implementation first appeared in WIDE Hydrangea IPv6 protocol stack kit. -.Sh STANDARDS -These functions are defined in ``Basic Socket Interface Extensions for IPv6'' -.Pq RFC2533 . diff --git a/lib/libc/net/ifname.c b/lib/libc/net/ifname.c deleted file mode 100644 index 3d3916a..0000000 --- a/lib/libc/net/ifname.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ -/* - * TODO: - * - prototype defs into arpa/inet.h, not net/if.h (bsd-api-new-02) - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#define ROUNDUP(a) \ - ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) -#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len)) - -unsigned int -if_nametoindex(ifname) - const char *ifname; -{ - struct if_nameindex *iff = if_nameindex(), *ifx; - int ret; - - if (iff == NULL) return 0; - ifx = iff; - while (ifx->if_name != NULL) { - if (strcmp(ifx->if_name, ifname) == 0) { - ret = ifx->if_index; - if_freenameindex(iff); - return ret; - } - ifx++; - } - if_freenameindex(iff); - errno = ENXIO; - return 0; -} - -char * -if_indextoname(ifindex, ifname) - unsigned int ifindex; - char *ifname; /* at least IF_NAMESIZE */ -{ - struct if_nameindex *iff = if_nameindex(), *ifx; - char *cp, *dp; - - if (iff == NULL) return NULL; - ifx = iff; - while (ifx->if_index != 0) { - if (ifx->if_index == ifindex) { - cp = ifname; - dp = ifx->if_name; - while ((*cp++ = *dp++)) ; - if_freenameindex(iff); - return (ifname); - } - ifx++; - } - if_freenameindex(iff); - errno = ENXIO; - return NULL; -} - -struct if_nameindex * -if_nameindex() -{ - size_t needed; - int mib[6], i, ifn = 0, off = 0, hlen; - char *buf = NULL, *lim, *next, *cp, *ifbuf = NULL; - struct rt_msghdr *rtm; - struct if_msghdr *ifm; - struct sockaddr *sa; - struct sockaddr_dl *sdl; - struct if_nameindex *ret = NULL; - static int ifxs = 64; /* initial upper limit */ - struct _ifx { - int if_index; - int if_off; - } *ifx = NULL; - - mib[0] = CTL_NET; - mib[1] = PF_ROUTE; - mib[2] = 0; /* protocol */ - mib[3] = 0; /* wildcard address family */ - mib[4] = NET_RT_IFLIST; - mib[5] = 0; /* no flags */ - if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) - return NULL; - if ((buf = malloc(needed)) == NULL) { - errno = ENOMEM; - goto end; - } - /* XXX: we may have allocated too much than necessary */ - if ((ifbuf = malloc(needed)) == NULL) { - errno = ENOMEM; - goto end; - } - if ((ifx = (struct _ifx *)malloc(sizeof(*ifx) * ifxs)) == NULL) { - errno = ENOMEM; - goto end; - } - if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) { - /* sysctl has set errno */ - goto end; - } - lim = buf + needed; - for (next = buf; next < lim; next += rtm->rtm_msglen) { - rtm = (struct rt_msghdr *)next; - if (rtm->rtm_version != RTM_VERSION) { - errno = EPROTONOSUPPORT; - goto end; - } - switch (rtm->rtm_type) { - case RTM_IFINFO: - ifm = (struct if_msghdr *)rtm; - ifx[ifn].if_index = ifm->ifm_index; - ifx[ifn].if_off = off; - cp = (char *)(ifm + 1); - for (i = 1; i; i <<= 1) { - if (i & ifm->ifm_addrs) { - sa = (struct sockaddr *)cp; - if (i == RTA_IFP && - sa->sa_family == AF_LINK) { - sdl = (struct sockaddr_dl *)sa; - memcpy(ifbuf + off, - sdl->sdl_data, - sdl->sdl_nlen); - off += sdl->sdl_nlen; - *(ifbuf + off) = '\0'; - off++; - } - ADVANCE(cp, sa); - } - } - if (++ifn == ifxs) { - /* we need more memory */ - struct _ifx *newifx; - - ifxs *= 2; - if ((newifx = (struct _ifx *)malloc(sizeof(*newifx) * ifxs)) == NULL) { - errno = ENOMEM; - goto end; - } - - /* copy and free old data */ - memcpy(newifx, ifx, (sizeof(*ifx) * ifxs) / 2); - free(ifx); - ifx = newifx; - } - } - } - hlen = sizeof(struct if_nameindex) * (ifn + 1); - if ((cp = (char *)malloc(hlen + off)) == NULL) { - errno = ENOMEM; - goto end; - } - bcopy(ifbuf, cp + hlen, off); - ret = (struct if_nameindex *)cp; - for (i = 0; i < ifn; i++) { - ret[i].if_index = ifx[i].if_index; - ret[i].if_name = cp + hlen + ifx[i].if_off; - } - ret[ifn].if_index = 0; - ret[ifn].if_name = NULL; - - end: - if (buf) free(buf); - if (ifbuf) free(ifbuf); - if (ifx) free(ifx); - - return ret; -} - -void if_freenameindex(ptr) - struct if_nameindex *ptr; -{ - free(ptr); -} diff --git a/lib/libc/net/inet.3 b/lib/libc/net/inet.3 deleted file mode 100644 index f9941fc..0000000 --- a/lib/libc/net/inet.3 +++ /dev/null @@ -1,267 +0,0 @@ -.\" Copyright (c) 1983, 1990, 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. -.\" -.\" From: @(#)inet.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 17, 1996 -.Dt INET 3 -.Os BSD 4.2 -.Sh NAME -.Nm inet_aton , -.Nm inet_addr , -.Nm inet_network , -.Nm inet_ntoa , -.Nm inet_ntop , -.Nm inet_pton , -.Nm inet_makeaddr , -.Nm inet_lnaof , -.Nm inet_netof -.Nd Internet address manipulation routines -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Fd #include -.Fd #include -.Ft int -.Fn inet_aton "const char *cp" "struct in_addr *pin" -.Ft unsigned long -.Fn inet_addr "const char *cp" -.Ft unsigned long -.Fn inet_network "const char *cp" -.Ft char * -.Fn inet_ntoa "struct in_addr in" -.Ft const char * -.Fn inet_ntop "int af" "const void *src" "char *dst" "size_t size" -.Ft int -.Fn inet_pton "int af" "const char *src" "void *dst" -.Ft struct in_addr -.Fn inet_makeaddr "unsigned long net" "unsigned long lna" -.Ft unsigned long -.Fn inet_lnaof "struct in_addr in" -.Ft unsigned long -.Fn inet_netof "struct in_addr in" -.Sh DESCRIPTION -The routines -.Fn inet_aton , -.Fn inet_addr -and -.Fn inet_network -interpret character strings representing -numbers expressed in the Internet standard -.Ql \&. -notation. -.Pp -The -.Fn inet_pton -function converts a presentation format address (that is, printable form -as held in a character string) to network format (usually a -.Ft struct in_addr -or some other internal binary representation, in network byte order). -It returns 1 if the address was valid for the specified address family, or -0 if the address wasn't parseable in the specified address family, or -1 -if some system error occurred (in which case -.Va errno -will have been set). -This function is presently valid for -.Dv AF_INET -and -.Dv AF_INET6 . -.Pp -The -.Fn inet_aton -routine interprets the specified character string as an Internet address, -placing the address into the structure provided. -It returns 1 if the string was successfully interpreted, -or 0 if the string is invalid. -The -.Fn inet_addr -and -.Fn inet_network -functions return numbers suitable for use -as Internet addresses and Internet network -numbers, respectively. -.Pp -The function -.Fn inet_ntop -converts an address from network format (usually a -.Ft struct in_addr -or some other binary form, in network byte order) to presentation format -(suitable for external display purposes). -It returns NULL if a system error occurs (in which case, -.Va errno -will have been set), or it returns a pointer to the destination string. -This function is presently valid for -.Dv AF_INET -and -.Dv AF_INET6 . -.Pp -The routine -.Fn inet_ntoa -takes an Internet address and returns an -.Tn ASCII -string representing the address in -.Ql \&. -notation. The routine -.Fn inet_makeaddr -takes an Internet network number and a local -network address and constructs an Internet address -from it. The routines -.Fn inet_netof -and -.Fn inet_lnaof -break apart Internet host addresses, returning -the network number and local network address part, -respectively. -.Pp -All Internet addresses are returned in network -order (bytes ordered from left to right). -All network numbers and local address parts are -returned as machine format integer values. -.Sh INTERNET ADDRESSES -Values specified using the -.Ql \&. -notation take one -of the following forms: -.Bd -literal -offset indent -a.b.c.d -a.b.c -a.b -a -.Ed -.Pp -When four parts are specified, each is interpreted -as a byte of data and assigned, from left to right, -to the four bytes of an Internet address. Note -that when an Internet address is viewed as a 32-bit -integer quantity on the -.Tn VAX -the bytes referred to -above appear as -.Dq Li d.c.b.a . -That is, -.Tn VAX -bytes are -ordered from right to left. -.Pp -When a three part address is specified, the last -part is interpreted as a 16-bit quantity and placed -in the right-most two bytes of the network address. -This makes the three part address format convenient -for specifying Class B network addresses as -.Dq Li 128.net.host . -.Pp -When a two part address is supplied, the last part -is interpreted as a 24-bit quantity and placed in -the right most three bytes of the network address. -This makes the two part address format convenient -for specifying Class A network addresses as -.Dq Li net.host . -.Pp -When only one part is given, the value is stored -directly in the network address without any byte -rearrangement. -.Pp -All numbers supplied as -.Dq parts -in a -.Ql \&. -notation -may be decimal, octal, or hexadecimal, as specified -in the C language (i.e., a leading 0x or 0X implies -hexadecimal; otherwise, a leading 0 implies octal; -otherwise, the number is interpreted as decimal). -.Pp -The -.Fn inet_aton -and -.Fn inet_ntoa -functions are semi-deprecated in favor of the -.Xr addr2ascii 3 -family. However, since those functions are not yet widely implemented, -portable programs cannot rely on their presence and will continue -to use the -.Xr inet 3 -functions for some time. -.Sh DIAGNOSTICS -The constant -.Dv INADDR_NONE -is returned by -.Fn inet_addr -and -.Fn inet_network -for malformed requests. -.Sh SEE ALSO -.Xr addr2ascii 3 , -.Xr gethostbyname 3 , -.Xr getnetent 3 , -.Xr hosts 5 , -.Xr networks 5 -.Rs -.%R RFC -.%N 2373 -.%D July 1998 -.%T "IP Version 6 Addressing Architecture" -.Re -.Sh STANDARDS -The -.Nm inet_ntop -and -.Nm inet_pton -functions conform to -.St -xns5.2d2.0 . -Note that -.Nm inet_pton -does not accept 1-, 2-, or 3-part dotted addresses; all four parts -must be specified. -This is a narrower input set than that accepted by -.Nm inet_aton . -.Sh HISTORY -These -functions appeared in -.Bx 4.2 . -.Sh BUGS -The value -.Dv INADDR_NONE -(0xffffffff) is a valid broadcast address, but -.Fn inet_addr -cannot return that value without indicating failure. -The newer -.Fn inet_aton -function does not share this problem. -The problem of host byte ordering versus network byte ordering is -confusing. -The string returned by -.Fn inet_ntoa -resides in a static memory area. -.Pp -Inet_addr should return a -.Fa struct in_addr . diff --git a/lib/libc/net/inet6_option_space.3 b/lib/libc/net/inet6_option_space.3 deleted file mode 100644 index 6fd71b6..0000000 --- a/lib/libc/net/inet6_option_space.3 +++ /dev/null @@ -1,451 +0,0 @@ -.\" Copyright (c) 1983, 1987, 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. -.\" -.\" $Id: inet6_option_space.3,v 1.4 2000/02/05 10:32:24 jinmei Exp $ -.\" $FreeBSD$ -.\" -.Dd December 10, 1999 -.Dt INET6_OPTION_SPACE 3 -.Os KAME -.\" -.Sh NAME -.Nm inet6_option_space , -.Nm inet6_option_init , -.Nm inet6_option_append , -.Nm inet6_option_alloc , -.Nm inet6_option_next , -.Nm inet6_option_find -.Nd IPv6 Hop-by-Hop and Destination Options manipulation -.\" -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Ft "int" -.Fn inet6_option_space "int nbytes" -.Ft "int" -.Fn inet6_option_init "void *bp" "struct cmsghdr **cmsgp" "int type" -.Ft "int" -.Fn inet6_option_append "struct cmsghdr *cmsg" "const u_int8_t *typep" "int multx" "int plusy" -.Ft "u_int8_t *" -.Fn inet6_option_alloc "struct cmsghdr *cmsg" "int datalen" "int multx" "int plusy" -.Ft "int" -.Fn inet6_option_next "const struct cmsghdr *cmsg" "u_int8_t **tptrp" -.Ft "int" -.Fn inet6_option_find "const struct cmsghdr *cmsg" "u_int8_t **tptrp" "int type" -.\" -.Sh DESCRIPTION -.\" -Building and parsing the Hop-by-Hop and Destination options is -complicated due to alignment constranints, padding and -ancillary data manipulation. -RFC2292 defines a set of functions to help the application. -The function prototypes for -these functions are all in the -.Aq Li netinet/in.h -header. -.\" -.Ss inet6_option_space -.Fn inet6_option_space -returns the number of bytes required to hold an option when it is stored as -ancillary data, including the -.Li cmsghdr -structure at the beginning, -and any padding at the end -.Po -to make its size a multiple of 8 bytes -.Pc . -The argument is the size of the structure defining the option, -which must include any pad bytes at the beginning -.Po -the value -.Li y -in the alignment term -.Dq Li xn + y -.Pc , -the type byte, the length byte, and the option data. -.Pp -Note: If multiple options are stored in a single ancillary data -object, which is the recommended technique, this function -overestimates the amount of space required by the size of -.Li N-1 -.Li cmsghdr -structures, -where -.Li N -is the number of options to be stored in the object. -This is of little consequence, since it is assumed that most -Hop-by-Hop option headers and Destination option headers carry only -one option -.Pq appendix B of [RFC-2460] . -.\" -.Ss inet6_option_init -.Fn inet6_option_init -is called once per ancillary data object that will -contain either Hop-by-Hop or Destination options. -It returns -.Li 0 -on success or -.Li -1 -on an error. -.Pp -.Fa bp -is a pointer to previously allocated space that will contain the -ancillary data object. -It must be large enough to contain all the -individual options to be added by later calls to -.Fn inet6_option_append -and -.Fn inet6_option_alloc . -.Pp -.Fa cmsgp -is a pointer to a pointer to a -.Li cmsghdr -structure. -.Fa *cmsgp -is initialized by this function to point to the -.Li cmsghdr -structure constructed by this function in the buffer pointed to by -.Fa bp . -.Pp -.Fa type -is either -.Dv IPV6_HOPOPTS -or -.Dv IPV6_DSTOPTS . -This -.Fa type -is stored in the -.Li cmsg_type -member of the -.Li cmsghdr -structure pointed to by -.Fa *cmsgp . -.\" -.Ss inet6_option_append -This function appends a Hop-by-Hop option or a Destination option -into an ancillary data object that has been initialized by -.Fn inet6_option_init . -This function returns -.Li 0 -if it succeeds or -.Li -1 -on an error. -.Pp -.Fa cmsg -is a pointer to the -.Li cmsghdr -structure that must have been -initialized by -.Fn inet6_option_init . -.Pp -.Fa typep -is a pointer to the 8-bit option type. -It is assumed that this -field is immediately followed by the 8-bit option data length field, -which is then followed immediately by the option data. -The caller -initializes these three fields -.Pq the type-length-value, or TLV -before calling this function. -.Pp -The option type must have a value from -.Li 2 -to -.Li 255 , inclusive. -.Po -.Li 0 -and -.Li 1 -are reserved for the -.Li Pad1 -and -.Li PadN -options, respectively. -.Pc -.Pp -The option data length must have a value between -.Li 0 -and -.Li 255 , -inclusive, and is the length of the option data that follows. -.Pp -.Fa multx -is the value -.Li x -in the alignment term -.Dq Li xn + y . -It must have a value of -.Li 1 , -.Li 2 , -.Li 4 , -or -.Li 8 . -.Pp -.Fa plusy -is the value -.Li y -in the alignment term -.Dq Li xn + y . -It must have a value between -.Li 0 -and -.Li 7 , -inclusive. -.\" -.Ss inet6_option_alloc -This function appends a Hop-by-Hop option or a Destination option -into an ancillary data object that has been initialized by -.Fn inet6_option_init . -This function returns a pointer to the 8-bit -option type field that starts the option on success, or -.Dv NULL -on an error. -.Pp -The difference between this function and -.Fn inet6_option_append -is that the latter copies the contents of a previously built option into -the ancillary data object while the current function returns a -pointer to the space in the data object where the option's TLV must -then be built by the caller. -.Pp -.Fa cmsg -is a pointer to the -.Li cmsghdr -structure that must have been -initialized by -.Fn inet6_option_init . -.Pp -.Fa datalen -is the value of the option data length byte for this option. -This value is required as an argument to allow the function to -determine if padding must be appended at the end of the option. -.Po -The -.Fn inet6_option_append -function does not need a data length argument -since the option data length must already be stored by the caller. -.Pc -.Pp -.Fa multx -is the value -.Li x -in the alignment term -.Dq Li xn + y . -It must have a value of -.Li 1 , -.Li 2 , -.Li 4 , -or -.Li 8 . -.Pp -.Fa plusy -is the value -.Li y -in the alignment term -.Dq Li xn + y . -It must have a value between -.Li 0 -and -.Li 7 , -inclusive. -.\" -.Ss inet6_option_next -This function processes the next Hop-by-Hop option or Destination -option in an ancillary data object. -If another option remains to be -processed, the return value of the function is -.Li 0 -and -.Fa *tptrp -points to -the 8-bit option type field -.Po -which is followed by the 8-bit option -data length, followed by the option data -.Pc . -If no more options remain -to be processed, the return value is -.Li -1 -and -.Fa *tptrp -is -.Dv NULL . -If an error occurs, the return value is -.Li -1 -and -.Fa *tptrp -is not -.Dv NULL . -.Pp -.Fa cmsg -is a pointer to -.Li cmsghdr -structure of which -.Li cmsg_level -equals -.Dv IPPROTO_IPV6 -and -.Li cmsg_type -equals either -.Dv IPV6_HOPOPTS -or -.Dv IPV6_DSTOPTS . -.Pp -.Fa tptrp -is a pointer to a pointer to an 8-bit byte and -.Fa *tptrp -is used -by the function to remember its place in the ancillary data object -each time the function is called. -The first time this function is -called for a given ancillary data object, -.Fa *tptrp -must be set to -.Dv NULL . -.Pp -Each time this function returns success, -.Fa *tptrp -points to the 8-bit -option type field for the next option to be processed. -.\" -.Ss inet6_option_find -This function is similar to the previously described -.Fn inet6_option_next -function, except this function lets the caller -specify the option type to be searched for, instead of always -returning the next option in the ancillary data object. -.Fa cmsg -is a -pointer to -.Li cmsghdr -structure of which -.Li cmsg_level -equals -.Dv IPPROTO_IPV6 -and -.Li cmsg_type -equals either -.Dv IPV6_HOPOPTS -or -.Dv IPV6_DSTOPTS . -.Pp -.Fa tptrp -is a pointer to a pointer to an 8-bit byte and -.Fa *tptrp -is used -by the function to remember its place in the ancillary data object -each time the function is called. -The first time this function is -called for a given ancillary data object, -.Fa *tptrp -must be set to -.Dv NULL . -.Pa -This function starts searching for an option of the specified type -beginning after the value of -.Fa *tptrp . -If an option of the specified -type is located, this function returns -.Li 0 -and -.Fa *tptrp -points to the 8- -bit option type field for the option of the specified type. -If an -option of the specified type is not located, the return value is -.Li -1 -and -.Fa *tptrp -is -.Dv NULL . -If an error occurs, the return value is -.Li -1 -and -.Fa *tptrp -is not -.Dv NULL . -.\" -.Sh DIAGNOSTICS -.Fn inet6_option_init -and -.Fn inet6_option_append -return -.Li 0 -on success or -.Li -1 -on an error. -.Pp -.Fn inet6_option_alloc -returns -.Dv NULL on an error. -.Pp -On errors, -.Fn inet6_option_next -and -.Fn inet6_option_find -return -.Li -1 -setting -.Fa *tptrp -to non -.Dv NULL -value. -.\" -.Sh EXAMPLES -RFC2292 gives comprehensive examples in chapter 6. -.\" -.Sh SEE ALSO -.Rs -.%A W. Stevens -.%A M. Thomas -.%T "Advanced Sockets API for IPv6" -.%N RFC2292 -.%D February 1998 -.Re -.Rs -.%A S. Deering -.%A R. Hinden -.%T "Internet Protocol, Version 6 (IPv6) Specification" -.%N RFC2460 -.%D December 1998 -.Re -.\" -.Sh HISTORY -The implementation first appeared in KAME advanced networking kit. -.\" -.Sh STANDARDS -The functions -are documented in -.Dq Advanced Sockets API for IPv6 -.Pq RFC2292 . -.\" -.Sh BUGS -The text was shamelessly copied from RFC2292. diff --git a/lib/libc/net/inet6_rthdr_space.3 b/lib/libc/net/inet6_rthdr_space.3 deleted file mode 100644 index 5f0845e..0000000 --- a/lib/libc/net/inet6_rthdr_space.3 +++ /dev/null @@ -1,327 +0,0 @@ -.\" Copyright (c) 1983, 1987, 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. -.\" -.\" $Id: inet6_rthdr_space.3,v 1.5 2000/02/05 13:19:07 jinmei Exp $ -.\" $FreeBSD$ -.\" -.Dd December 10, 1999 -.Dt INET6_OPTION_SPACE 3 -.Os KAME -.\" -.Sh NAME -.Nm inet6_rthdr_space , -.Nm inet6_rthdr_init , -.Nm inet6_rthdr_add , -.Nm inet6_rthdr_lasthop , -.Nm inet6_rthdr_reversoe , -.Nm inet6_rthdr_segments , -.Nm inet6_rthdr_getaddr , -.Nm inet6_rthdr_getflags -.Nd IPv6 Routing Header Options manipulation -.\" -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Ft size_t -.Fn inet6_rthdr_space "int type" "int segments" -.Ft "struct cmsghdr *" -.Fn inet6_rthdr_init "void *bp" "int type" -.Ft int -.Fn inet6_rthdr_add "struct cmsghdr *cmsg" "const struct in6_addr *addr" "unsigned int flags" -.Ft int -.Fn inet6_rthdr_lasthop "struct cmsghdr *cmsg" "unsigned int flags" -.Ft int -.Fn inet6_rthdr_reverse "const struct cmsghdr *in" "struct cmsghdr *out" -.Ft int -.Fn inet6_rthdr_segments "const struct cmsghdr *cmsg" -.Ft "struct in6_addr *" -.Fn inet6_rthdr_getaddr "struct cmsghdr *cmsg" "int index" -.Ft int -.Fn inet6_rthdr_getflags "const struct cmsghdr *cmsg" "int index" -.\" -.Sh DESCRIPTION -RFC2292 IPv6 advanced API defines eight -functions that the application calls to build and examine a Routing -header. Four functions build a Routing header: -.Bl -hang -.It Fn inet6_rthdr_space -return #bytes required for ancillary data -.It Fn inet6_rthdr_init -initialize ancillary data for Routing header -.It Fn inet6_rthdr_add -add IPv6 address & flags to Routing header -.It Fn inet6_rthdr_lasthop -specify the flags for the final hop -.El -.Pp -Four functions deal with a returned Routing header: -.Bl -hang -.It Fn inet6_rthdr_reverse -reverse a Routing header -.It Fn inet6_rthdr_segments -return #segments in a Routing header -.It Fn inet6_rthdr_getaddr -fetch one address from a Routing header -.It Fn inet6_rthdr_getflags -fetch one flag from a Routing header -.El -.Pp -The function prototypes for these functions are all in the -.Aq Li netinet/in.h -header. -.\" -.Ss inet6_rthdr_space -This function returns the number of bytes required to hold a Routing -header of the specified -.Fa type -containing the specified number of -.Fa segments -.Pq addresses . -For an IPv6 Type 0 Routing header, the number -of segments must be between 1 and 23, inclusive. The return value -includes the size of the cmsghdr structure that precedes the Routing -header, and any required padding. -.Pp -If the return value is 0, then either the type of the Routing header -is not supported by this implementation or the number of segments is -invalid for this type of Routing header. -.Pp -Note: This function returns the size but does not allocate the space -required for the ancillary data. -This allows an application to -allocate a larger buffer, if other ancillary data objects are -desired, since all the ancillary data objects must be specified to -.Xr sendmsg 2 -as a single -.Li msg_control -buffer. -.\" -.Ss inet6_rthdr_init -This function initializes the buffer pointed to by -.Fa bp -to contain a -.Li cmsghdr -structure followed by a Routing header of the specified -.Fa type . -The -.Li cmsg_len -member of the -.Li cmsghdr -structure is initialized to the -size of the structure plus the amount of space required by the -Routing header. -The -.Li cmsg_level -and -.Li cmsg_type -members are also initialized as required. -.Pp -The caller must allocate the buffer and its size can be determined by -calling -.Fn inet6_rthdr_space . -.Pp -Upon success the return value is the pointer to the -.Li cmsghdr -structure, and this is then used as the first argument to the next -two functions. -Upon an error the return value is -.Dv NULL . -.\" -.Ss inet6_rthdr_add -This function adds the address pointed to by -.Fa addr -to the end of the -Routing header being constructed and sets the type of this hop to the -value of -.Fa flags . -For an IPv6 Type 0 Routing header, -.Fa flags -must be -either -.Dv IPV6_RTHDR_LOOSE -or -.Dv IPV6_RTHDR_STRICT . -.Pp -If successful, the -.Li cmsg_len -member of the -.Li cmsghdr -structure is -updated to account for the new address in the Routing header and the -return value of the function is 0. -Upon an error the return value of -the function is -1. -.\" -.Ss inet6_rthdr_lasthop -This function specifies the Strict/Loose flag for the final hop of a -Routing header. -For an IPv6 Type 0 Routing header, -.Fa flags -must be either -.Dv IPV6_RTHDR_LOOSE -or -.Dv IPV6_RTHDR_STRICT . -.Pp -The return value of the function is 0 upon success, or -1 upon an error. -.Pp -Notice that a Routing header specifying -.Li N -intermediate nodes requires -.Li N+1 -Strict/Loose flags. -This requires -.Li N -calls to -.Fn inet6_rthdr_add -followed by one call to -.Fn inet6_rthdr_lasthop . -.\" -.Ss inet6_rthdr_reverse -This function is not yet implemented. -When implemented, this should behave as follows. -.Pp -This function takes a Routing header that was received as ancillary -data -.Po -pointed to by the first argument, -.Fa in -.Pc -and writes a new Routing -header that sends datagrams along the reverse of that route. -Both -arguments are allowed to point to the same buffer -.Pq that is, the reversal can occur in place . -.Pp -The return value of the function is 0 on success, or -1 upon an -error. -.\" -.Ss inet6_rthdr_segments -This function returns the number of segments -.Pq addresses -contained in -the Routing header described by -.Fa cmsg . -On success the return value is -between 1 and 23, inclusive. -The return value of the function is -1 upon an error. -.\" -.Ss inet6_rthdr_getaddr -This function returns a pointer to the IPv6 address specified by -.Fa index -.Po -which must have a value between 1 and the value returned by -.Fn inet6_rthdr_segments -.Pc -in the Routing header described by -.Fa cmsg . -An -application should first call -.Fn inet6_rthdr_segments -to obtain the number of segments in the Routing header. -.Pp -Upon an error the return value of the function is -.Dv NULL . -.\" -.Ss inet6_rthdr_getflags -This function returns the flags value specified by -.Fa index -.Po -which must -have a value between 0 and the value returned by -.Fn inet6_rthdr_segments -.Pc -in the Routing header described by -.Fa cmsg . -For an IPv6 Type 0 Routing header the return value will be either -.Dv IPV6_RTHDR_LOOSE -or -.Dv IPV6_RTHDR_STRICT . -.Pp -Upon an error the return value of the function is -1. -.Pp -Note: Addresses are indexed starting at 1, and flags starting at 0, -to maintain consistency with the terminology and figures in RFC2460. -.\" -.Sh DIAGNOSTICS -.Fn inet6_rthdr_space -returns 0 on errors. -.Pp -.Fn inet6_rthdr_add , -.Fn inet6_rthdr_lasthop -and -.Fn inet6_rthdr_reverse -return 0 on success, and returns -1 on error. -.Pp -.Fn inet6_rthdr_init -and -.Fn inet6_rthdr_getaddr -return -.Dv NULL -on error. -.Pp -.Fn inet6_rthdr_segments -and -.Fn inet6_rthdr_getflags -return -1 on error. -.\" -.Sh EXAMPLES -RFC2292 gives comprehensive examples in chapter 8. -.\" -.Sh SEE ALSO -.Rs -.%A W. Stevens -.%A M. Thomas -.%T "Advanced Sockets API for IPv6" -.%N RFC2292 -.%D February 1998 -.Re -.Rs -.%A S. Deering -.%A R. Hinden -.%T "Internet Protocol, Version 6 (IPv6) Specification" -.%N RFC2460 -.%D December 1998 -.Re -.\" -.Sh HISTORY -The implementation first appeared in KAME advanced networking kit. -.\" -.Sh STANDARDS -The functions -are documented in -.Dq Advanced Sockets API for IPv6 -.Pq RFC2292 . -.\" -.Sh BUGS -The text was shamelessly copied from RFC2292. -.Pp -.Fn inet6_rthdr_reverse -is not implemented yet. diff --git a/lib/libc/net/inet_addr.c b/lib/libc/net/inet_addr.c deleted file mode 100644 index 312c39b..0000000 --- a/lib/libc/net/inet_addr.c +++ /dev/null @@ -1,197 +0,0 @@ -/* - * ++Copyright++ 1983, 1990, 1993 - * - - * Copyright (c) 1983, 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. - * - - * --Copyright-- - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93"; -static char rcsid[] = "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include - -#include -#include -#include -#include - -/* - * ASCII internet address interpretation routine. - * The value returned is in network order. - */ -u_long /* XXX should be struct in_addr :( */ -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. - */ -int -inet_aton(cp, addr) - register const char *cp; - struct in_addr *addr; -{ - u_long parts[4]; - u_long val; - char *c; - char *endptr; - int gotend, n; - - c = (char *)cp; - n = 0; - /* - * Run through the string, grabbing numbers until - * the end of the string, or some error - */ - gotend = 0; - while (!gotend) { - errno = 0; - val = strtoul(c, &endptr, 0); - - if (errno == ERANGE) /* Fail completely if it overflowed. */ - return (0); - - /* - * If the whole string is invalid, endptr will equal - * c.. this way we can make sure someone hasn't - * gone '.12' or something which would get past - * the next check. - */ - if (endptr == c) - return (0); - parts[n] = val; - c = endptr; - - /* Check the next character past the previous number's end */ - switch (*c) { - case '.' : - /* Make sure we only do 3 dots .. */ - if (n == 3) /* Whoops. Quit. */ - return (0); - n++; - c++; - break; - - case '\0': - gotend = 1; - break; - - default: - if (isspace((unsigned char)*c)) { - gotend = 1; - break; - } else - return (0); /* Invalid character, so fail */ - } - - } - - /* - * Concoct the address according to - * the number of parts specified. - */ - - switch (n) { - case 0: /* a -- 32 bits */ - /* - * Nothing is necessary here. Overflow checking was - * already done in strtoul(). - */ - break; - case 1: /* a.b -- 8.24 bits */ - if (val > 0xffffff || parts[0] > 0xff) - return (0); - val |= parts[0] << 24; - break; - - case 2: /* a.b.c -- 8.8.16 bits */ - if (val > 0xffff || parts[0] > 0xff || parts[1] > 0xff) - return (0); - val |= (parts[0] << 24) | (parts[1] << 16); - break; - - case 3: /* a.b.c.d -- 8.8.8.8 bits */ - if (val > 0xff || parts[0] > 0xff || parts[1] > 0xff || - parts[2] > 0xff) - return (0); - val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); - break; - } - - if (addr != NULL) - addr->s_addr = htonl(val); - return (1); -} - -/* - * Weak aliases for applications that use certain private entry points, - * and fail to include . - */ -#undef inet_addr -__weak_reference(__inet_addr, inet_addr); -#undef inet_aton -__weak_reference(__inet_aton, inet_aton); diff --git a/lib/libc/net/inet_lnaof.c b/lib/libc/net/inet_lnaof.c deleted file mode 100644 index 99024d9..0000000 --- a/lib/libc/net/inet_lnaof.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)inet_lnaof.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -/* - * Return the local network address portion of an - * internet address; handles class a/b/c network - * number formats. - */ -u_long -inet_lnaof(in) - struct in_addr in; -{ - register u_long 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); -} - -/* - * Weak aliases for applications that use certain private entry points, - * and fail to include . - */ -#undef inet_lnaof -__weak_reference(__inet_lnaof, inet_lnaof); diff --git a/lib/libc/net/inet_makeaddr.c b/lib/libc/net/inet_makeaddr.c deleted file mode 100644 index 8af7770..0000000 --- a/lib/libc/net/inet_makeaddr.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)inet_makeaddr.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -/* - * Formulate an Internet address from network + host. Used in - * building addresses stored in the ifnet structure. - */ -struct in_addr -inet_makeaddr(net, host) - u_long net, host; -{ - u_long 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); -} - -/* - * Weak aliases for applications that use certain private entry points, - * and fail to include . - */ -#undef inet_makeaddr -__weak_reference(__inet_makeaddr, inet_makeaddr); diff --git a/lib/libc/net/inet_net_ntop.c b/lib/libc/net/inet_net_ntop.c deleted file mode 100644 index 4b30cb6..0000000 --- a/lib/libc/net/inet_net_ntop.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 1996 by Internet Software Consortium. - * - * 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. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM 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 const char orig_rcsid[] = "From Id: inet_net_ntop.c,v 8.2 1996/08/08 06:54:44 vixie Exp"; -static const char rcsid[] = "$FreeBSD$"; -#endif - -#include -#include -#include -#include - -#include -#include -#include -#include - -#ifdef SPRINTF_CHAR -# define SPRINTF(x) strlen(sprintf/**/x) -#else -# define SPRINTF(x) ((size_t)sprintf x) -#endif - -static char * inet_net_ntop_ipv4 __P((const u_char *src, int bits, - char *dst, size_t size)); - -/* - * char * - * inet_net_ntop(af, src, bits, dst, size) - * convert network number from network to presentation format. - * generates CIDR style result always. - * return: - * pointer to dst, or NULL if an error occurred (check errno). - * author: - * Paul Vixie (ISC), July 1996 - */ -char * -inet_net_ntop(af, src, bits, dst, size) - int af; - const void *src; - int bits; - char *dst; - size_t size; -{ - switch (af) { - case AF_INET: - return (inet_net_ntop_ipv4(src, bits, dst, size)); - default: - errno = EAFNOSUPPORT; - return (NULL); - } -} - -/* - * static char * - * inet_net_ntop_ipv4(src, bits, dst, size) - * convert IPv4 network number from network to presentation format. - * generates CIDR style result always. - * return: - * pointer to dst, or NULL if an error occurred (check errno). - * note: - * network byte order assumed. this means 192.5.5.240/28 has - * 0x11110000 in its fourth octet. - * author: - * Paul Vixie (ISC), July 1996 - */ -static char * -inet_net_ntop_ipv4(src, bits, dst, size) - const u_char *src; - int bits; - char *dst; - size_t size; -{ - char *odst = dst; - char *t; - u_int m; - int b; - - if (bits < 0 || bits > 32) { - errno = EINVAL; - return (NULL); - } - if (bits == 0) { - if (size < sizeof "0") - goto emsgsize; - *dst++ = '0'; - *dst = '\0'; - } - - /* Format whole octets. */ - for (b = bits / 8; b > 0; b--) { - if (size < sizeof "255.") - goto emsgsize; - t = dst; - dst += SPRINTF((dst, "%u", *src++)); - if (b > 1) { - *dst++ = '.'; - *dst = '\0'; - } - size -= (size_t)(dst - t); - } - - /* Format partial octet. */ - b = bits % 8; - if (b > 0) { - if (size < sizeof ".255") - goto emsgsize; - t = dst; - if (dst != odst) - *dst++ = '.'; - m = ((1 << b) - 1) << (8 - b); - dst += SPRINTF((dst, "%u", *src & m)); - size -= (size_t)(dst - t); - } - - /* Format CIDR /width. */ - if (size < sizeof "/32") - goto emsgsize; - dst += SPRINTF((dst, "/%u", bits)); - return (odst); - - emsgsize: - errno = EMSGSIZE; - return (NULL); -} - -/* - * Weak aliases for applications that use certain private entry points, - * and fail to include . - */ -#undef inet_net_ntop -__weak_reference(__inet_net_ntop, inet_net_ntop); diff --git a/lib/libc/net/inet_net_pton.c b/lib/libc/net/inet_net_pton.c deleted file mode 100644 index 04a45d4..0000000 --- a/lib/libc/net/inet_net_pton.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright (c) 1996 by Internet Software Consortium. - * - * 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. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM 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 const char orig_rcsid[] = "From Id: inet_net_pton.c,v 1.8 1996/11/21 10:28:12 vixie Exp $"; -static const char rcsid[] = "$FreeBSD$"; -#endif - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#ifdef SPRINTF_CHAR -# define SPRINTF(x) strlen(sprintf/**/x) -#else -# define SPRINTF(x) ((size_t)sprintf x) -#endif - -static int inet_net_pton_ipv4 __P((const char *src, u_char *dst, - size_t size)); - -/* - * static int - * inet_net_pton(af, src, dst, size) - * convert network number from presentation to network format. - * accepts hex octets, hex strings, decimal octets, and /CIDR. - * "size" is in bytes and describes "dst". - * return: - * number of bits, either imputed classfully or specified with /CIDR, - * or -1 if some failure occurred (check errno). ENOENT means it was - * not a valid network specification. - * author: - * Paul Vixie (ISC), June 1996 - */ -int -inet_net_pton(af, src, dst, size) - int af; - const char *src; - void *dst; - size_t size; -{ - switch (af) { - case AF_INET: - return (inet_net_pton_ipv4(src, dst, size)); - default: - errno = EAFNOSUPPORT; - return (-1); - } -} - -/* - * static int - * inet_net_pton_ipv4(src, dst, size) - * convert IPv4 network number from presentation to network format. - * accepts hex octets, hex strings, decimal octets, and /CIDR. - * "size" is in bytes and describes "dst". - * return: - * number of bits, either imputed classfully or specified with /CIDR, - * or -1 if some failure occurred (check errno). ENOENT means it was - * not an IPv4 network specification. - * note: - * network byte order assumed. this means 192.5.5.240/28 has - * 0x11110000 in its fourth octet. - * author: - * Paul Vixie (ISC), June 1996 - */ -static int -inet_net_pton_ipv4(src, dst, size) - const char *src; - u_char *dst; - size_t size; -{ - static const char - xdigits[] = "0123456789abcdef", - digits[] = "0123456789"; - int n, ch, tmp, dirty, bits; - const u_char *odst = dst; - - ch = *src++; - if (ch == '0' && (src[0] == 'x' || src[0] == 'X') - && isascii(src[1]) && isxdigit(src[1])) { - /* Hexadecimal: Eat nybble string. */ - if (size <= 0) - goto emsgsize; - *dst = 0, dirty = 0; - src++; /* skip x or X. */ - while ((ch = *src++) != '\0' && - isascii(ch) && isxdigit(ch)) { - if (isupper(ch)) - ch = tolower(ch); - n = strchr(xdigits, ch) - xdigits; - assert(n >= 0 && n <= 15); - *dst |= n; - if (!dirty++) - *dst <<= 4; - else if (size-- > 0) - *++dst = 0, dirty = 0; - else - goto emsgsize; - } - if (dirty) - size--; - } else if (isascii(ch) && isdigit(ch)) { - /* Decimal: eat dotted digit string. */ - for (;;) { - tmp = 0; - do { - n = strchr(digits, ch) - digits; - assert(n >= 0 && n <= 9); - tmp *= 10; - tmp += n; - if (tmp > 255) - goto enoent; - } while ((ch = *src++) != '\0' && - isascii(ch) && isdigit(ch)); - if (size-- <= 0) - goto emsgsize; - *dst++ = (u_char) tmp; - if (ch == '\0' || ch == '/') - break; - if (ch != '.') - goto enoent; - ch = *src++; - if (!isascii(ch) || !isdigit(ch)) - goto enoent; - } - } else - goto enoent; - - bits = -1; - if (ch == '/' && isascii(src[0]) && isdigit(src[0]) && dst > odst) { - /* CIDR width specifier. Nothing can follow it. */ - ch = *src++; /* Skip over the /. */ - bits = 0; - do { - n = strchr(digits, ch) - digits; - assert(n >= 0 && n <= 9); - bits *= 10; - bits += n; - } while ((ch = *src++) != '\0' && isascii(ch) && isdigit(ch)); - if (ch != '\0') - goto enoent; - if (bits > 32) - goto emsgsize; - } - - /* Firey death and destruction unless we prefetched EOS. */ - if (ch != '\0') - goto enoent; - - /* If nothing was written to the destination, we found no address. */ - if (dst == odst) - goto enoent; - /* If no CIDR spec was given, infer width from net class. */ - if (bits == -1) { - if (*odst >= 240) /* Class E */ - bits = 32; - else if (*odst >= 224) /* Class D */ - bits = 4; - else if (*odst >= 192) /* Class C */ - bits = 24; - else if (*odst >= 128) /* Class B */ - bits = 16; - else /* Class A */ - bits = 8; - /* If imputed mask is narrower than specified octets, widen. */ - if (bits >= 8 && bits < ((dst - odst) * 8)) - bits = (dst - odst) * 8; - } - /* Extend network to cover the actual mask. */ - while (bits > ((dst - odst) * 8)) { - if (size-- <= 0) - goto emsgsize; - *dst++ = '\0'; - } - return (bits); - - enoent: - errno = ENOENT; - return (-1); - - emsgsize: - errno = EMSGSIZE; - return (-1); -} - -/* - * Weak aliases for applications that use certain private entry points, - * and fail to include . - */ -#undef inet_net_pton -__weak_reference(__inet_net_pton, inet_net_pton); diff --git a/lib/libc/net/inet_neta.c b/lib/libc/net/inet_neta.c deleted file mode 100644 index 2b8a84c..0000000 --- a/lib/libc/net/inet_neta.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 1996 by Internet Software Consortium. - * - * 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. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM 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 const char orig_rcsid[] = "From Id: inet_neta.c,v 8.2 1996/08/08 06:54:44 vixie Exp"; -static const char rcsid[] = "$FreeBSD$"; -#endif - -#include -#include -#include -#include - -#include -#include -#include - -#ifdef SPRINTF_CHAR -# define SPRINTF(x) strlen(sprintf/**/x) -#else -# define SPRINTF(x) ((size_t)sprintf x) -#endif - -/* - * char * - * inet_neta(src, dst, size) - * format a u_long network number into presentation format. - * return: - * pointer to dst, or NULL if an error occurred (check errno). - * note: - * format of ``src'' is as for inet_network(). - * author: - * Paul Vixie (ISC), July 1996 - */ -char * -inet_neta(src, dst, size) - u_long src; - char *dst; - size_t size; -{ - char *odst = dst; - char *tp; - - while (src & 0xffffffff) { - u_char b = (src & 0xff000000) >> 24; - - src <<= 8; - if (b) { - if (size < sizeof "255.") - goto emsgsize; - tp = dst; - dst += SPRINTF((dst, "%u", b)); - if (src != 0L) { - *dst++ = '.'; - *dst = '\0'; - } - size -= (size_t)(dst - tp); - } - } - if (dst == odst) { - if (size < sizeof "0.0.0.0") - goto emsgsize; - strcpy(dst, "0.0.0.0"); - } - return (odst); - - emsgsize: - errno = EMSGSIZE; - return (NULL); -} - -/* - * Weak aliases for applications that use certain private entry points, - * and fail to include . - */ -#undef inet_neta -__weak_reference(__inet_neta, inet_neta); diff --git a/lib/libc/net/inet_netof.c b/lib/libc/net/inet_netof.c deleted file mode 100644 index 37063f7..0000000 --- a/lib/libc/net/inet_netof.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)inet_netof.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -/* - * Return the network number from an internet - * address; handles class a/b/c network #'s. - */ -u_long -inet_netof(in) - struct in_addr in; -{ - register u_long 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); -} - -/* - * Weak aliases for applications that use certain private entry points, - * and fail to include . - */ -#undef inet_netof -__weak_reference(__inet_netof, inet_netof); diff --git a/lib/libc/net/inet_network.c b/lib/libc/net/inet_network.c deleted file mode 100644 index e44257a..0000000 --- a/lib/libc/net/inet_network.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)inet_network.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -/* - * Internet network address interpretation routine. - * The library routines call this routine to interpret - * network numbers. - */ -u_long -inet_network(cp) - register const char *cp; -{ - register u_long val, base, n, i; - register char c; - u_long parts[4], *pp = parts; - -again: - val = 0; base = 10; - if (*cp == '0') - base = 8, cp++; - if (*cp == 'x' || *cp == 'X') - base = 16, cp++; - while ((c = *cp) != 0) { - if (isdigit((unsigned char)c)) { - val = (val * base) + (c - '0'); - cp++; - continue; - } - if (base == 16 && isxdigit((unsigned char)c)) { - val = (val << 4) + (c + 10 - (islower((unsigned char)c) ? 'a' : 'A')); - cp++; - continue; - } - break; - } - if (*cp == '.') { - if (pp >= parts + 3) - return (INADDR_NONE); - *pp++ = val, cp++; - goto again; - } - if (*cp && !isspace((unsigned char)*cp)) - return (INADDR_NONE); - *pp++ = val; - n = pp - parts; - for (val = 0, i = 0; i < n; i++) { - val <<= 8; - val |= parts[i] & 0xff; - } - return (val); -} - -/* - * Weak aliases for applications that use certain private entry points, - * and fail to include . - */ -#undef inet_network -__weak_reference(__inet_network, inet_network); diff --git a/lib/libc/net/inet_ntoa.c b/lib/libc/net/inet_ntoa.c deleted file mode 100644 index c210545..0000000 --- a/lib/libc/net/inet_ntoa.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)inet_ntoa.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include - -/* - * Convert network-format internet address - * to base 256 d.d.d.d representation. - */ -char * -inet_ntoa(in) - struct in_addr in; -{ - static char ret[18]; - - strcpy(ret, "[inet_ntoa error]"); - (void) inet_ntop(AF_INET, &in, ret, sizeof ret); - return (ret); -} - -/* - * Weak aliases for applications that use certain private entry points, - * and fail to include . - */ -#undef inet_ntoa -__weak_reference(__inet_ntoa, inet_ntoa); diff --git a/lib/libc/net/inet_ntop.c b/lib/libc/net/inet_ntop.c deleted file mode 100644 index 0b9449b..0000000 --- a/lib/libc/net/inet_ntop.c +++ /dev/null @@ -1,198 +0,0 @@ -/* Copyright (c) 1996 by Internet Software Consortium. - * - * 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. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM 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 rcsid[] = "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define SPRINTF(x) ((size_t)sprintf x) - -/* - * WARNING: Don't even consider trying to compile this on a system where - * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. - */ - -static const char *inet_ntop4 __P((const u_char *src, char *dst, size_t size)); -static const char *inet_ntop6 __P((const u_char *src, char *dst, size_t size)); - -/* char * - * inet_ntop(af, src, dst, size) - * convert a network format address to presentation format. - * return: - * pointer to presentation format address (`dst'), or NULL (see errno). - * author: - * Paul Vixie, 1996. - */ -const char * -inet_ntop(af, src, dst, size) - int af; - const void *src; - char *dst; - size_t size; -{ - switch (af) { - case AF_INET: - return (inet_ntop4(src, dst, size)); - case AF_INET6: - return (inet_ntop6(src, dst, size)); - default: - errno = EAFNOSUPPORT; - return (NULL); - } - /* NOTREACHED */ -} - -/* const char * - * inet_ntop4(src, dst, size) - * format an IPv4 address, more or less like inet_ntoa() - * return: - * `dst' (as a const) - * notes: - * (1) uses no statics - * (2) takes a u_char* not an in_addr as input - * author: - * Paul Vixie, 1996. - */ -static const char * -inet_ntop4(src, dst, size) - const u_char *src; - char *dst; - size_t size; -{ - static const char fmt[] = "%u.%u.%u.%u"; - char tmp[sizeof "255.255.255.255"]; - - if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) > size) { - errno = ENOSPC; - return (NULL); - } - strcpy(dst, tmp); - return (dst); -} - -/* const char * - * inet_ntop6(src, dst, size) - * convert IPv6 binary address into presentation (printable) format - * author: - * Paul Vixie, 1996. - */ -static const char * -inet_ntop6(src, dst, size) - const u_char *src; - char *dst; - size_t size; -{ - /* - * Note that int32_t and int16_t need only be "at least" large enough - * to contain a value of the specified size. On some systems, like - * Crays, there is no such thing as an integer variable with 16 bits. - * Keep this in mind if you think this function should have been coded - * to use pointer overlays. All the world's not a VAX. - */ - char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp; - struct { int base, len; } best, cur; - u_int words[NS_IN6ADDRSZ / NS_INT16SZ]; - int i; - - /* - * Preprocess: - * Copy the input (bytewise) array into a wordwise array. - * Find the longest run of 0x00's in src[] for :: shorthanding. - */ - memset(words, '\0', sizeof words); - for (i = 0; i < NS_IN6ADDRSZ; i++) - words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3)); - best.base = -1; - cur.base = -1; - for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { - if (words[i] == 0) { - if (cur.base == -1) - cur.base = i, cur.len = 1; - else - cur.len++; - } else { - if (cur.base != -1) { - if (best.base == -1 || cur.len > best.len) - best = cur; - cur.base = -1; - } - } - } - if (cur.base != -1) { - if (best.base == -1 || cur.len > best.len) - best = cur; - } - if (best.base != -1 && best.len < 2) - best.base = -1; - - /* - * Format the result. - */ - tp = tmp; - for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { - /* Are we inside the best run of 0x00's? */ - if (best.base != -1 && i >= best.base && - i < (best.base + best.len)) { - if (i == best.base) - *tp++ = ':'; - continue; - } - /* Are we following an initial run of 0x00s or any real hex? */ - if (i != 0) - *tp++ = ':'; - /* Is this address an encapsulated IPv4? */ - if (i == 6 && best.base == 0 && - (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) { - if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp))) - return (NULL); - tp += strlen(tp); - break; - } - tp += SPRINTF((tp, "%x", words[i])); - } - /* Was it a trailing run of 0x00's? */ - if (best.base != -1 && (best.base + best.len) == - (NS_IN6ADDRSZ / NS_INT16SZ)) - *tp++ = ':'; - *tp++ = '\0'; - - /* - * Check for overflow, copy, and we're done. - */ - if ((size_t)(tp - tmp) > size) { - errno = ENOSPC; - return (NULL); - } - strcpy(dst, tmp); - return (dst); -} - -/* - * Weak aliases for applications that use certain private entry points, - * and fail to include . - */ -#undef inet_ntop -__weak_reference(__inet_ntop, inet_ntop); diff --git a/lib/libc/net/inet_pton.c b/lib/libc/net/inet_pton.c deleted file mode 100644 index 488ac7f..0000000 --- a/lib/libc/net/inet_pton.c +++ /dev/null @@ -1,221 +0,0 @@ -/* Copyright (c) 1996 by Internet Software Consortium. - * - * 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. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM 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 rcsid[] = "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * WARNING: Don't even consider trying to compile this on a system where - * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. - */ - -static int inet_pton4 __P((const char *src, u_char *dst)); -static int inet_pton6 __P((const char *src, u_char *dst)); - -/* int - * inet_pton(af, src, dst) - * convert from presentation format (which usually means ASCII printable) - * to network format (which is usually some kind of binary format). - * return: - * 1 if the address was valid for the specified address family - * 0 if the address wasn't valid (`dst' is untouched in this case) - * -1 if some other error occurred (`dst' is untouched in this case, too) - * author: - * Paul Vixie, 1996. - */ -int -inet_pton(af, src, dst) - int af; - const char *src; - void *dst; -{ - switch (af) { - case AF_INET: - return (inet_pton4(src, dst)); - case AF_INET6: - return (inet_pton6(src, dst)); - default: - errno = EAFNOSUPPORT; - return (-1); - } - /* NOTREACHED */ -} - -/* int - * inet_pton4(src, dst) - * like inet_aton() but without all the hexadecimal and shorthand. - * return: - * 1 if `src' is a valid dotted quad, else 0. - * notice: - * does not touch `dst' unless it's returning 1. - * author: - * Paul Vixie, 1996. - */ -static int -inet_pton4(src, dst) - const char *src; - u_char *dst; -{ - static const char digits[] = "0123456789"; - int saw_digit, octets, ch; - u_char tmp[NS_INADDRSZ], *tp; - - saw_digit = 0; - octets = 0; - *(tp = tmp) = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - if ((pch = strchr(digits, ch)) != NULL) { - u_int new = *tp * 10 + (pch - digits); - - if (new > 255) - return (0); - *tp = new; - if (! saw_digit) { - if (++octets > 4) - return (0); - saw_digit = 1; - } - } else if (ch == '.' && saw_digit) { - if (octets == 4) - return (0); - *++tp = 0; - saw_digit = 0; - } else - return (0); - } - if (octets < 4) - return (0); - - memcpy(dst, tmp, NS_INADDRSZ); - return (1); -} - -/* int - * inet_pton6(src, dst) - * convert presentation level address to network order binary form. - * return: - * 1 if `src' is a valid [RFC1884 2.2] address, else 0. - * notice: - * (1) does not touch `dst' unless it's returning 1. - * (2) :: in a full address is silently ignored. - * credit: - * inspired by Mark Andrews. - * author: - * Paul Vixie, 1996. - */ -static int -inet_pton6(src, dst) - const char *src; - u_char *dst; -{ - static const char xdigits_l[] = "0123456789abcdef", - xdigits_u[] = "0123456789ABCDEF"; - u_char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp; - const char *xdigits, *curtok; - int ch, saw_xdigit; - u_int val; - - memset((tp = tmp), '\0', NS_IN6ADDRSZ); - endp = tp + NS_IN6ADDRSZ; - colonp = NULL; - /* Leading :: requires some special handling. */ - if (*src == ':') - if (*++src != ':') - return (0); - curtok = src; - saw_xdigit = 0; - val = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) - pch = strchr((xdigits = xdigits_u), ch); - if (pch != NULL) { - val <<= 4; - val |= (pch - xdigits); - if (val > 0xffff) - return (0); - saw_xdigit = 1; - continue; - } - if (ch == ':') { - curtok = src; - if (!saw_xdigit) { - if (colonp) - return (0); - colonp = tp; - continue; - } - if (tp + NS_INT16SZ > endp) - return (0); - *tp++ = (u_char) (val >> 8) & 0xff; - *tp++ = (u_char) val & 0xff; - saw_xdigit = 0; - val = 0; - continue; - } - if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) && - inet_pton4(curtok, tp) > 0) { - tp += NS_INADDRSZ; - saw_xdigit = 0; - break; /* '\0' was seen by inet_pton4(). */ - } - return (0); - } - if (saw_xdigit) { - if (tp + NS_INT16SZ > endp) - return (0); - *tp++ = (u_char) (val >> 8) & 0xff; - *tp++ = (u_char) val & 0xff; - } - if (colonp != NULL) { - /* - * Since some memmove()'s erroneously fail to handle - * overlapping regions, we'll do the shift by hand. - */ - const int n = tp - colonp; - int i; - - for (i = 1; i <= n; i++) { - endp[- i] = colonp[n - i]; - colonp[n - i] = 0; - } - tp = endp; - } - if (tp != endp) - return (0); - memcpy(dst, tmp, NS_IN6ADDRSZ); - return (1); -} - -/* - * Weak aliases for applications that use certain private entry points, - * and fail to include . - */ -#undef inet_pton -__weak_reference(__inet_pton, inet_pton); diff --git a/lib/libc/net/ip6opt.c b/lib/libc/net/ip6opt.c deleted file mode 100644 index f9291b9..0000000 --- a/lib/libc/net/ip6opt.c +++ /dev/null @@ -1,386 +0,0 @@ -/* - * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include -#include -#include - -#include -#include - -#include -#include - -static int ip6optlen(u_int8_t *opt, u_int8_t *lim); -static void inet6_insert_padopt(u_char *p, int len); - -/* - * This function returns the number of bytes required to hold an option - * when it is stored as ancillary data, including the cmsghdr structure - * at the beginning, and any padding at the end (to make its size a - * multiple of 8 bytes). The argument is the size of the structure - * defining the option, which must include any pad bytes at the - * beginning (the value y in the alignment term "xn + y"), the type - * byte, the length byte, and the option data. - */ -int -inet6_option_space(nbytes) - int nbytes; -{ - nbytes += 2; /* we need space for nxt-hdr and length fields */ - return(CMSG_SPACE((nbytes + 7) & ~7)); -} - -/* - * This function is called once per ancillary data object that will - * contain either Hop-by-Hop or Destination options. It returns 0 on - * success or -1 on an error. - */ -int -inet6_option_init(bp, cmsgp, type) - void *bp; - struct cmsghdr **cmsgp; - int type; -{ - register struct cmsghdr *ch = (struct cmsghdr *)bp; - - /* argument validation */ - if (type != IPV6_HOPOPTS && type != IPV6_DSTOPTS) - return(-1); - - ch->cmsg_level = IPPROTO_IPV6; - ch->cmsg_type = type; - ch->cmsg_len = CMSG_LEN(0); - - *cmsgp = ch; - return(0); -} - -/* - * This function appends a Hop-by-Hop option or a Destination option - * into an ancillary data object that has been initialized by - * inet6_option_init(). This function returns 0 if it succeeds or -1 on - * an error. - * multx is the value x in the alignment term "xn + y" described - * earlier. It must have a value of 1, 2, 4, or 8. - * plusy is the value y in the alignment term "xn + y" described - * earlier. It must have a value between 0 and 7, inclusive. - */ -int -inet6_option_append(cmsg, typep, multx, plusy) - struct cmsghdr *cmsg; - const u_int8_t *typep; - int multx; - int plusy; -{ - int padlen, optlen, off; - register u_char *bp = (u_char *)cmsg + cmsg->cmsg_len; - struct ip6_ext *eh = (struct ip6_ext *)CMSG_DATA(cmsg); - - /* argument validation */ - if (multx != 1 && multx != 2 && multx != 4 && multx != 8) - return(-1); - if (plusy < 0 || plusy > 7) - return(-1); - if (typep[0] > 255) - return(-1); - - /* - * If this is the first option, allocate space for the - * first 2 bytes(for next header and length fields) of - * the option header. - */ - if (bp == (u_char *)eh) { - bp += 2; - cmsg->cmsg_len += 2; - } - - /* calculate pad length before the option. */ - off = bp - (u_char *)eh; - padlen = (((off % multx) + (multx - 1)) & ~(multx - 1)) - - (off % multx); - padlen += plusy; - /* insert padding */ - inet6_insert_padopt(bp, padlen); - cmsg->cmsg_len += padlen; - bp += padlen; - - /* copy the option */ - if (typep[0] == IP6OPT_PAD1) - optlen = 1; - else - optlen = typep[1] + 2; - memcpy(bp, typep, optlen); - bp += optlen; - cmsg->cmsg_len += optlen; - - /* calculate pad length after the option and insert the padding */ - off = bp - (u_char *)eh; - padlen = ((off + 7) & ~7) - off; - inet6_insert_padopt(bp, padlen); - bp += padlen; - cmsg->cmsg_len += padlen; - - /* update the length field of the ip6 option header */ - eh->ip6e_len = ((bp - (u_char *)eh) >> 3) - 1; - - return(0); -} - -/* - * This function appends a Hop-by-Hop option or a Destination option - * into an ancillary data object that has been initialized by - * inet6_option_init(). This function returns a pointer to the 8-bit - * option type field that starts the option on success, or NULL on an - * error. - * The difference between this function and inet6_option_append() is - * that the latter copies the contents of a previously built option into - * the ancillary data object while the current function returns a - * pointer to the space in the data object where the option's TLV must - * then be built by the caller. - * - */ -u_int8_t * -inet6_option_alloc(cmsg, datalen, multx, plusy) - struct cmsghdr *cmsg; - int datalen; - int multx; - int plusy; -{ - int padlen, off; - register u_int8_t *bp = (u_char *)cmsg + cmsg->cmsg_len; - u_int8_t *retval; - struct ip6_ext *eh = (struct ip6_ext *)CMSG_DATA(cmsg); - - /* argument validation */ - if (multx != 1 && multx != 2 && multx != 4 && multx != 8) - return(NULL); - if (plusy < 0 || plusy > 7) - return(NULL); - - /* - * If this is the first option, allocate space for the - * first 2 bytes(for next header and length fields) of - * the option header. - */ - if (bp == (u_char *)eh) { - bp += 2; - cmsg->cmsg_len += 2; - } - - /* calculate pad length before the option. */ - off = bp - (u_char *)eh; - padlen = (((off % multx) + (multx - 1)) & ~(multx - 1)) - - (off % multx); - padlen += plusy; - /* insert padding */ - inet6_insert_padopt(bp, padlen); - cmsg->cmsg_len += padlen; - bp += padlen; - - /* keep space to store specified length of data */ - retval = bp; - bp += datalen; - cmsg->cmsg_len += datalen; - - /* calculate pad length after the option and insert the padding */ - off = bp - (u_char *)eh; - padlen = ((off + 7) & ~7) - off; - inet6_insert_padopt(bp, padlen); - bp += padlen; - cmsg->cmsg_len += padlen; - - /* update the length field of the ip6 option header */ - eh->ip6e_len = ((bp - (u_char *)eh) >> 3) - 1; - - return(retval); -} - -/* - * This function processes the next Hop-by-Hop option or Destination - * option in an ancillary data object. If another option remains to be - * processed, the return value of the function is 0 and *tptrp points to - * the 8-bit option type field (which is followed by the 8-bit option - * data length, followed by the option data). If no more options remain - * to be processed, the return value is -1 and *tptrp is NULL. If an - * error occurs, the return value is -1 and *tptrp is not NULL. - * (RFC 2292, 6.3.5) - */ -int -inet6_option_next(cmsg, tptrp) - const struct cmsghdr *cmsg; - u_int8_t **tptrp; -{ - struct ip6_ext *ip6e; - int hdrlen, optlen; - u_int8_t *lim; - - if (cmsg->cmsg_level != IPPROTO_IPV6 || - (cmsg->cmsg_type != IPV6_HOPOPTS && - cmsg->cmsg_type != IPV6_DSTOPTS)) - return(-1); - - /* message length validation */ - if (cmsg->cmsg_len < CMSG_SPACE(sizeof(struct ip6_ext))) - return(-1); - ip6e = (struct ip6_ext *)CMSG_DATA(cmsg); - hdrlen = (ip6e->ip6e_len + 1) << 3; - if (cmsg->cmsg_len < CMSG_SPACE(hdrlen)) - return(-1); - - /* - * If the caller does not specify the starting point, - * simply return the 1st option. - * Otherwise, search the option list for the next option. - */ - lim = (u_int8_t *)ip6e + hdrlen; - if (*tptrp == NULL) - *tptrp = (u_int8_t *)(ip6e + 1); - else { - if ((optlen = ip6optlen(*tptrp, lim)) == 0) - return(-1); - - *tptrp = *tptrp + optlen; - } - if (*tptrp >= lim) { /* there is no option */ - *tptrp = NULL; - return(-1); - } - /* - * Finally, checks if the next option is safely stored in the - * cmsg data. - */ - if (ip6optlen(*tptrp, lim) == 0) - return(-1); - else - return(0); -} - -/* - * This function is similar to the inet6_option_next() function, - * except this function lets the caller specify the option type to be - * searched for, instead of always returning the next option in the - * ancillary data object. - * Note: RFC 2292 says the type of tptrp is u_int8_t *, but we think - * it's a typo. The variable should be type of u_int8_t **. - */ -int -inet6_option_find(cmsg, tptrp, type) - const struct cmsghdr *cmsg; - u_int8_t **tptrp; - int type; -{ - struct ip6_ext *ip6e; - int hdrlen, optlen; - u_int8_t *optp, *lim; - - if (cmsg->cmsg_level != IPPROTO_IPV6 || - (cmsg->cmsg_type != IPV6_HOPOPTS && - cmsg->cmsg_type != IPV6_DSTOPTS)) - return(-1); - - /* message length validation */ - if (cmsg->cmsg_len < CMSG_SPACE(sizeof(struct ip6_ext))) - return(-1); - ip6e = (struct ip6_ext *)CMSG_DATA(cmsg); - hdrlen = (ip6e->ip6e_len + 1) << 3; - if (cmsg->cmsg_len < CMSG_SPACE(hdrlen)) - return(-1); - - /* - * If the caller does not specify the starting point, - * search from the beginning of the option list. - * Otherwise, search from *the next option* of the specified point. - */ - lim = (u_int8_t *)ip6e + hdrlen; - if (*tptrp == NULL) - *tptrp = (u_int8_t *)(ip6e + 1); - else { - if ((optlen = ip6optlen(*tptrp, lim)) == 0) - return(-1); - - *tptrp = *tptrp + optlen; - } - for (optp = *tptrp; optp < lim; optp += optlen) { - if (*optp == type) { - *tptrp = optp; - return(0); - } - if ((optlen = ip6optlen(optp, lim)) == 0) - return(-1); - } - - /* search failed */ - *tptrp = NULL; - return(-1); -} - -/* - * Calculate the length of a given IPv6 option. Also checks - * if the option is safely stored in user's buffer according to the - * calculated length and the limitation of the buffer. - */ -static int -ip6optlen(opt, lim) - u_int8_t *opt, *lim; -{ - int optlen; - - if (*opt == IP6OPT_PAD1) - optlen = 1; - else { - /* is there enough space to store type and len? */ - if (opt + 2 > lim) - return(0); - optlen = *(opt + 1) + 2; - } - if (opt + optlen <= lim) - return(optlen); - - return(0); -} - -static void -inet6_insert_padopt(u_char *p, int len) -{ - switch(len) { - case 0: - return; - case 1: - p[0] = IP6OPT_PAD1; - return; - default: - p[0] = IP6OPT_PADN; - p[1] = len - 2; - memset(&p[2], 0, len - 2); - return; - } -} diff --git a/lib/libc/net/iso_addr.3 b/lib/libc/net/iso_addr.3 deleted file mode 100644 index ad49778..0000000 --- a/lib/libc/net/iso_addr.3 +++ /dev/null @@ -1,111 +0,0 @@ -.\" Copyright (c) 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. -.\" -.\" @(#)iso_addr.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt ISO_ADDR 3 -.Os -.Sh NAME -.Nm iso_addr , -.Nm iso_ntoa -.Nd "elementary network address conversion routines for Open System Interconnection -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Ft struct iso_addr * -.Fn iso_addr "char *cp" -.Ft char * -.Fn iso_ntoa "struct iso_addr *isoa" -.Sh DESCRIPTION -The routine -.Fn iso_addr -interprets character strings representing -.Tn OSI -addresses, returning binary information suitable -for use in system calls. -The routine -.Fn iso_ntoa -takes -.Tn OSI -addresses and returns -.Tn ASCII -strings representing NSAPs (network service -access points) in a -notation inverse to that accepted by -.Fn iso_addr . -.Pp -Unfortunately, no universal standard exists for representing -.Tn OSI -network addresses. -.Pp -The format employed by -.Fn iso_addr -is a sequence of hexadecimal -.Dq digits -(optionally separated by periods), -of the form: -.Bd -filled -offset indent -.. -.Ed -.Pp -Each pair of hexadecimal digits represents a byte -with the leading digit indicating the higher-ordered bits. -A period following an even number of bytes has no -effect (but may be used to increase legibility). -A period following an odd number of bytes has the -effect of causing the byte of address being translated -to have its higher order bits filled with zeros. -.Sh RETURN VALUES -.Fn iso_ntoa -always returns a null terminated string. -.Fn iso_addr -always returns a pointer to a struct iso_addr. -(See -.Sx BUGS . ) -.Sh SEE ALSO -.Xr iso 4 -.Sh HISTORY -The -.Fn iso_addr -and -.Fn iso_ntoa -functions appeared in -.Bx 4.3 Reno . -.Sh BUGS -The returned values -reside in a static memory area. -.Pp -The function -.Fn iso_addr -should diagnose improperly formed input, and there should be an unambiguous -way to recognize this. diff --git a/lib/libc/net/iso_addr.c b/lib/libc/net/iso_addr.c deleted file mode 100644 index 8829497..0000000 --- a/lib/libc/net/iso_addr.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)iso_addr.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -/* States*/ -#define VIRGIN 0 -#define GOTONE 1 -#define GOTTWO 2 -/* Inputs */ -#define DIGIT (4*0) -#define END (4*1) -#define DELIM (4*2) - -struct iso_addr * -iso_addr(addr) - register const char *addr; -{ - static struct iso_addr out_addr; - register char *cp = out_addr.isoa_genaddr; - char *cplim = cp + sizeof(out_addr.isoa_genaddr); - register int byte = 0, state = VIRGIN, new; - - bzero((char *)&out_addr, sizeof(out_addr)); - do { - if ((*addr >= '0') && (*addr <= '9')) { - new = *addr - '0'; - } else if ((*addr >= 'a') && (*addr <= 'f')) { - new = *addr - 'a' + 10; - } else if ((*addr >= 'A') && (*addr <= 'F')) { - new = *addr - 'A' + 10; - } else if (*addr == 0) - state |= END; - else - state |= DELIM; - addr++; - switch (state /* | INPUT */) { - case GOTTWO | DIGIT: - *cp++ = byte; /*FALLTHROUGH*/ - case VIRGIN | DIGIT: - state = GOTONE; byte = new; continue; - case GOTONE | DIGIT: - state = GOTTWO; byte = new + (byte << 4); continue; - default: /* | DELIM */ - state = VIRGIN; *cp++ = byte; byte = 0; continue; - case GOTONE | END: - case GOTTWO | END: - *cp++ = byte; /* FALLTHROUGH */ - case VIRGIN | END: - break; - } - break; - } while (cp < cplim); - out_addr.isoa_len = cp - out_addr.isoa_genaddr; - return (&out_addr); -} - -static char hexlist[] = "0123456789abcdef"; - -char * -iso_ntoa(isoa) - const struct iso_addr *isoa; -{ - static char tmpbuf[sizeof(isoa->isoa_genaddr)*3]; - const u_char *binary; - char *cp; - int i; - - binary = isoa->isoa_genaddr; - cp = tmpbuf; - - for (i = 0; i < isoa->isoa_len; i++) { - *cp++ = hexlist[*binary >> 4]; - *cp++ = hexlist[*binary++ & 0xf]; - - if ((((i % 2) == 0) && ((i + 1) < isoa->isoa_len))) - *cp++ = '.'; - } - *cp = '\0'; - return tmpbuf; -} diff --git a/lib/libc/net/linkaddr.3 b/lib/libc/net/linkaddr.3 deleted file mode 100644 index 543e040..0000000 --- a/lib/libc/net/linkaddr.3 +++ /dev/null @@ -1,138 +0,0 @@ -.\" Copyright (c) 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Donn Seeley at BSDI. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (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: @(#)linkaddr.3 8.1 (Berkeley) 7/28/93 -.\" $FreeBSD$ -.\" -.Dd June 17, 1996 -.Dt LINK_ADDR 3 -.Os BSD 4.4 -.Sh NAME -.Nm link_addr , -.Nm link_ntoa -.Nd elementary address specification routines for link level access -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Fd #include -.Ft void -.Fn link_addr "const char *addr" "struct sockaddr_dl *sdl" -.Ft char * -.Fn link_ntoa "const struct sockaddr_dl *sdl" -.Sh DESCRIPTION -The routine -.Fn link_addr -interprets character strings representing -link-level addresses, returning binary information suitable -for use in system calls. -The routine -.Fn link_ntoa -takes -a link-level -address and returns an -.Tn ASCII -string representing some of the information present, -including the link level address itself, and the interface name -or number, if present. -This facility is experimental and is -still subject to change. -.Pp -For -.Fn link_addr , -the string -.Fa addr -may contain -an optional network interface identifier of the form -.Dq "name unit-number" , -suitable for the first argument to -.Xr ifconfig 8 , -followed in all cases by a colon and -an interface address in the form of -groups of hexadecimal digits -separated by periods. -Each group represents a byte of address; -address bytes are filled left to right from -low order bytes through high order bytes. -.Pp -.\" A regular expression may make this format clearer: -.\" .Bd -literal -offset indent -.\" ([a-z]+[0-9]+:)?[0-9a-f]+(\e.[0-9a-f]+)* -.\" .Ed -.\" .Pp -Thus -.Li le0:8.0.9.13.d.30 -represents an ethernet address -to be transmitted on the first Lance ethernet interface. -.Pp -The direct use of these functions is deprecated in favor of the -.Xr addr2ascii 3 -interface; however, portable programs cannot rely on the latter as it is -not yet widely implemented. -.Sh RETURN VALUES -.Fn link_ntoa -always returns a null terminated string. -.Fn link_addr -has no return value. -(See -.Sx BUGS . ) -.Sh SEE ALSO -.Xr addr2ascii 3 -.\" .Xr iso 4 -.Sh HISTORY -The -.Fn link_addr -and -.Fn link_ntoa -functions appeared in -.Bx 4.3 Reno . -.Sh BUGS -The returned values for link_ntoa -reside in a static memory area. -.Pp -The function -.Fn link_addr -should diagnose improperly formed input, and there should be an unambiguous -way to recognize this. -.Pp -If the -.Va sdl_len -field of the link socket address -.Fa sdl -is 0, -.Fn link_ntoa -will not insert a colon before the interface address bytes. -If this translated address is given to -.Fn link_addr -without inserting an initial colon, -the latter will not interpret it correctly. diff --git a/lib/libc/net/linkaddr.c b/lib/libc/net/linkaddr.c deleted file mode 100644 index 68eed3d..0000000 --- a/lib/libc/net/linkaddr.c +++ /dev/null @@ -1,158 +0,0 @@ -/*- - * Copyright (c) 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)linkaddr.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -/* States*/ -#define NAMING 0 -#define GOTONE 1 -#define GOTTWO 2 -#define RESET 3 -/* Inputs */ -#define DIGIT (4*0) -#define END (4*1) -#define DELIM (4*2) -#define LETTER (4*3) - -void -link_addr(addr, sdl) - register const char *addr; - register struct sockaddr_dl *sdl; -{ - register char *cp = sdl->sdl_data; - char *cplim = sdl->sdl_len + (char *)sdl; - register int byte = 0, state = NAMING, new; - - bzero((char *)&sdl->sdl_family, sdl->sdl_len - 1); - sdl->sdl_family = AF_LINK; - do { - state &= ~LETTER; - if ((*addr >= '0') && (*addr <= '9')) { - new = *addr - '0'; - } else if ((*addr >= 'a') && (*addr <= 'f')) { - new = *addr - 'a' + 10; - } else if ((*addr >= 'A') && (*addr <= 'F')) { - new = *addr - 'A' + 10; - } else if (*addr == 0) { - state |= END; - } else if (state == NAMING && - (((*addr >= 'A') && (*addr <= 'Z')) || - ((*addr >= 'a') && (*addr <= 'z')))) - state |= LETTER; - else - state |= DELIM; - addr++; - switch (state /* | INPUT */) { - case NAMING | DIGIT: - case NAMING | LETTER: - *cp++ = addr[-1]; - continue; - case NAMING | DELIM: - state = RESET; - sdl->sdl_nlen = cp - sdl->sdl_data; - continue; - case GOTTWO | DIGIT: - *cp++ = byte; - /* FALLTHROUGH */ - case RESET | DIGIT: - state = GOTONE; - byte = new; - continue; - case GOTONE | DIGIT: - state = GOTTWO; - byte = new + (byte << 4); - continue; - default: /* | DELIM */ - state = RESET; - *cp++ = byte; - byte = 0; - continue; - case GOTONE | END: - case GOTTWO | END: - *cp++ = byte; - /* FALLTHROUGH */ - case RESET | END: - break; - } - break; - } while (cp < cplim); - sdl->sdl_alen = cp - LLADDR(sdl); - new = cp - (char *)sdl; - if (new > sizeof(*sdl)) - sdl->sdl_len = new; - return; -} - -static char hexlist[] = "0123456789abcdef"; - -char * -link_ntoa(sdl) - register const struct sockaddr_dl *sdl; -{ - static char obuf[64]; - register char *out = obuf; - register int i; - register u_char *in = (u_char *)LLADDR(sdl); - u_char *inlim = in + sdl->sdl_alen; - int firsttime = 1; - - if (sdl->sdl_nlen) { - bcopy(sdl->sdl_data, obuf, sdl->sdl_nlen); - out += sdl->sdl_nlen; - if (sdl->sdl_alen) - *out++ = ':'; - } - while (in < inlim) { - if (firsttime) - firsttime = 0; - else - *out++ = '.'; - i = *in++; - if (i > 0xf) { - out[1] = hexlist[i & 0xf]; - i >>= 4; - out[0] = hexlist[i]; - out += 2; - } else - *out++ = hexlist[i]; - } - *out = 0; - return (obuf); -} diff --git a/lib/libc/net/map_v4v6.c b/lib/libc/net/map_v4v6.c deleted file mode 100644 index ca5e553..0000000 --- a/lib/libc/net/map_v4v6.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - * ++Copyright++ 1985, 1988, 1993 - * - - * Copyright (c) 1985, 1988, 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. - * - - * --Copyright-- - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93"; -static char rcsid[] = "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -typedef union { - int32_t al; - char ac; -} align; - -void -_map_v4v6_address(src, dst) - const char *src; - char *dst; -{ - u_char *p = (u_char *)dst; - char tmp[INADDRSZ]; - int i; - - /* Stash a temporary copy so our caller can update in place. */ - bcopy(src, tmp, INADDRSZ); - /* Mark this ipv6 addr as a mapped ipv4. */ - for (i = 0; i < 10; i++) - *p++ = 0x00; - *p++ = 0xff; - *p++ = 0xff; - /* Retrieve the saved copy and we're done. */ - bcopy(tmp, (void*)p, INADDRSZ); -} - -void -_map_v4v6_hostent(hp, bpp, lenp) - struct hostent *hp; - char **bpp; - int *lenp; -{ - char **ap; - - if (hp->h_addrtype != AF_INET || hp->h_length != INADDRSZ) - return; - hp->h_addrtype = AF_INET6; - hp->h_length = IN6ADDRSZ; - for (ap = hp->h_addr_list; *ap; ap++) { - int i = sizeof(align) - ((u_long)*bpp % sizeof(align)); - - if (*lenp < (i + IN6ADDRSZ)) { - /* Out of memory. Truncate address list here. XXX */ - *ap = NULL; - return; - } - *bpp += i; - *lenp -= i; - _map_v4v6_address(*ap, *bpp); - *ap = *bpp; - *bpp += IN6ADDRSZ; - *lenp -= IN6ADDRSZ; - } -} diff --git a/lib/libc/net/name6.c b/lib/libc/net/name6.c deleted file mode 100644 index e87f40f..0000000 --- a/lib/libc/net/name6.c +++ /dev/null @@ -1,1305 +0,0 @@ -/* - * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ -/* $Id: name6.c,v 1.9 1999/10/29 03:04:26 itojun Exp $ */ -/* - * Atsushi Onoe - */ - -/* - * TODO for thread safe - * use mutex for _hostconf, _hostconf_init. - * rewrite resolvers to be thread safe - */ - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#ifndef _PATH_HOSTS -#define _PATH_HOSTS "/etc/hosts" -#endif - -#ifndef MAXALIASES -#define MAXALIASES 10 -#endif -#ifndef MAXADDRS -#define MAXADDRS 20 -#endif -#ifndef MAXDNAME -#define MAXDNAME 1025 -#endif - -#ifdef INET6 -#define ADDRLEN(af) ((af) == AF_INET6 ? sizeof(struct in6_addr) : \ - sizeof(struct in_addr)) -#else -#define ADDRLEN(af) sizeof(struct in_addr) -#endif - -#define MAPADDR(ab, ina) \ -do { \ - memcpy(&(ab)->map_inaddr, ina, sizeof(struct in_addr)); \ - memset((ab)->map_zero, 0, sizeof((ab)->map_zero)); \ - memset((ab)->map_one, 0xff, sizeof((ab)->map_one)); \ -} while (0) -#define MAPADDRENABLED(flags) \ - (((flags) & AI_V4MAPPED) || \ - (((flags) & AI_V4MAPPED_CFG) && _mapped_addr_enabled())) - -union inx_addr { - struct in_addr in_addr; -#ifdef INET6 - struct in6_addr in6_addr; -#endif - struct { - u_char mau_zero[10]; - u_char mau_one[2]; - struct in_addr mau_inaddr; - } map_addr_un; -#define map_zero map_addr_un.mau_zero -#define map_one map_addr_un.mau_one -#define map_inaddr map_addr_un.mau_inaddr -}; - -static struct hostent *_hpcopy(struct hostent *hp, int *errp); -static struct hostent *_hpaddr(int af, const char *name, void *addr, int *errp); -static struct hostent *_hpmerge(struct hostent *hp1, struct hostent *hp2, int *errp); -#ifdef INET6 -static struct hostent *_hpmapv6(struct hostent *hp, int *errp); -#endif -static struct hostent *_hpsort(struct hostent *hp); -static struct hostent *_ghbyname(const char *name, int af, int flags, int *errp); -static char *_hgetword(char **pp); -static int _mapped_addr_enabled(void); - -static FILE *_files_open(int *errp); -static struct hostent *_files_ghbyname(const char *name, int af, int *errp); -static struct hostent *_files_ghbyaddr(const void *addr, int addrlen, int af, int *errp); -static void _files_shent(int stayopen); -static void _files_ehent(void); -static struct hostent *_nis_ghbyname(const char *name, int af, int *errp); -static struct hostent *_nis_ghbyaddr(const void *addr, int addrlen, int af, int *errp); -static struct hostent *_dns_ghbyname(const char *name, int af, int *errp); -static struct hostent *_dns_ghbyaddr(const void *addr, int addrlen, int af, int *errp); -static void _dns_shent(int stayopen); -static void _dns_ehent(void); -#ifdef ICMPNL -static struct hostent *_icmp_ghbyaddr(const void *addr, int addrlen, int af, int *errp); -#endif /* ICMPNL */ - -/* - * Select order host function. - */ -#define MAXHOSTCONF 4 - -#ifndef HOSTCONF -# define HOSTCONF "/etc/host.conf" -#endif /* !HOSTCONF */ - -struct _hostconf { - struct hostent *(*byname)(const char *name, int af, int *errp); - struct hostent *(*byaddr)(const void *addr, int addrlen, int af, int *errp); -}; - -/* default order */ -static struct _hostconf _hostconf[MAXHOSTCONF] = { - { _dns_ghbyname, _dns_ghbyaddr }, - { _files_ghbyname, _files_ghbyaddr }, -#ifdef ICMPNL - { NULL, _icmp_ghbyaddr }, -#endif /* ICMPNL */ -}; - -static int _hostconf_init_done; -static void _hostconf_init(void); - -/* - * Initialize hostconf structure. - */ - -static void -_hostconf_init(void) -{ - FILE *fp; - int n; - char *p, *line; - char buf[BUFSIZ]; - - _hostconf_init_done = 1; - n = 0; - p = HOSTCONF; - if ((fp = fopen(p, "r")) == NULL) - return; - while (n < MAXHOSTCONF && fgets(buf, sizeof(buf), fp)) { - line = buf; - if ((p = _hgetword(&line)) == NULL) - continue; - do { - if (strcmp(p, "hosts") == 0 - || strcmp(p, "local") == 0 - || strcmp(p, "file") == 0 - || strcmp(p, "files") == 0) { - _hostconf[n].byname = _files_ghbyname; - _hostconf[n].byaddr = _files_ghbyaddr; - n++; - } - else if (strcmp(p, "dns") == 0 - || strcmp(p, "bind") == 0) { - _hostconf[n].byname = _dns_ghbyname; - _hostconf[n].byaddr = _dns_ghbyaddr; - n++; - } - else if (strcmp(p, "nis") == 0) { - _hostconf[n].byname = _nis_ghbyname; - _hostconf[n].byaddr = _nis_ghbyaddr; - n++; - } -#ifdef ICMPNL - else if (strcmp(p, "icmp") == 0) { - _hostconf[n].byname = NULL; - _hostconf[n].byaddr = _icmp_ghbyaddr; - n++; - } -#endif /* ICMPNL */ - } while ((p = _hgetword(&line)) != NULL); - } - fclose(fp); - if (n < 0) { - /* no keyword found. do not change default configuration */ - return; - } - for (; n < MAXHOSTCONF; n++) { - _hostconf[n].byname = NULL; - _hostconf[n].byaddr = NULL; - } -} - -/* - * Check if kernel supports mapped address. - * implementation dependent - */ -#ifdef __KAME__ -#include -#endif /* __KAME__ */ - -static int -_mapped_addr_enabled(void) -{ - /* implementation dependent check */ -#if defined(__KAME__) && defined(IPV6CTL_MAPPED_ADDR) - int mib[4]; - size_t len; - int val; - - mib[0] = CTL_NET; - mib[1] = PF_INET6; - mib[2] = IPPROTO_IPV6; - mib[3] = IPV6CTL_MAPPED_ADDR; - len = sizeof(val); - if (sysctl(mib, 4, &val, &len, 0, 0) == 0 && val != 0) - return 1; -#endif /* __KAME__ && IPV6CTL_MAPPED_ADDR */ - return 0; -} - -/* - * Functions defined in RFC2553 - * getipnodebyname, getipnodebyadr, freehostent - */ - -static struct hostent * -_ghbyname(const char *name, int af, int flags, int *errp) -{ - struct hostent *hp; - int i; - - if (flags & AI_ADDRCONFIG) { - int s; - - if ((s = socket(af, SOCK_DGRAM, 0)) < 0) - return NULL; - /* - * TODO: - * Note that implementation dependent test for address - * configuration should be done everytime called - * (or apropriate interval), - * because addresses will be dynamically assigned or deleted. - */ - _close(s); - } - - for (i = 0; i < MAXHOSTCONF; i++) { - if (_hostconf[i].byname - && (hp = (*_hostconf[i].byname)(name, af, errp)) - != NULL) - return hp; - } - - return NULL; -} - -struct hostent * -getipnodebyname(const char *name, int af, int flags, int *errp) -{ - struct hostent *hp; - union inx_addr addrbuf; - - if (af != AF_INET -#ifdef INET6 - && af != AF_INET6 -#endif - ) - { - *errp = NO_RECOVERY; - return NULL; - } - -#ifdef INET6 - /* special case for literal address */ - if (inet_pton(AF_INET6, name, &addrbuf) == 1) { - if (af != AF_INET6) { - *errp = HOST_NOT_FOUND; - return NULL; - } - return _hpaddr(af, name, &addrbuf, errp); - } -#endif - if (inet_aton(name, (struct in_addr *)&addrbuf) == 1) { - if (af != AF_INET) { - if (MAPADDRENABLED(flags)) { - MAPADDR(&addrbuf, &addrbuf.in_addr); - } else { - *errp = HOST_NOT_FOUND; - return NULL; - } - } - return _hpaddr(af, name, &addrbuf, errp); - } - - if (!_hostconf_init_done) - _hostconf_init(); - - *errp = HOST_NOT_FOUND; - hp = _ghbyname(name, af, flags, errp); - -#ifdef INET6 - if (af == AF_INET6 - && ((flags & AI_ALL) || hp == NULL) - && (MAPADDRENABLED(flags))) { - struct hostent *hp2 = _ghbyname(name, AF_INET, flags, errp); - if (hp == NULL) - hp = _hpmapv6(hp2, errp); - else { - if (hp2 && strcmp(hp->h_name, hp2->h_name) != 0) { - freehostent(hp2); - hp2 = NULL; - } - hp = _hpmerge(hp, hp2, errp); - } - } -#endif - return _hpsort(hp); -} - -struct hostent * -getipnodebyaddr(const void *src, size_t len, int af, int *errp) -{ - struct hostent *hp; - int i; -#ifdef INET6 - struct in6_addr addrbuf; -#else - struct in_addr addrbuf; -#endif - - *errp = HOST_NOT_FOUND; - - switch (af) { - case AF_INET: - if (len != sizeof(struct in_addr)) { - *errp = NO_RECOVERY; - return NULL; - } - if ((long)src & ~(sizeof(struct in_addr) - 1)) { - memcpy(&addrbuf, src, len); - src = &addrbuf; - } - if (((struct in_addr *)src)->s_addr == 0) - return NULL; - break; -#ifdef INET6 - case AF_INET6: - if (len != sizeof(struct in6_addr)) { - *errp = NO_RECOVERY; - return NULL; - } - if ((long)src & ~(sizeof(struct in6_addr) / 2 - 1)) { /*XXX*/ - memcpy(&addrbuf, src, len); - src = &addrbuf; - } - if (IN6_IS_ADDR_UNSPECIFIED((struct in6_addr *)src)) - return NULL; - if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)src) - || IN6_IS_ADDR_V4COMPAT((struct in6_addr *)src)) { - src = (char *)src + - (sizeof(struct in6_addr) - sizeof(struct in_addr)); - af = AF_INET; - len = sizeof(struct in_addr); - } - break; -#endif - default: - *errp = NO_RECOVERY; - return NULL; - } - - if (!_hostconf_init_done) - _hostconf_init(); - for (i = 0; i < MAXHOSTCONF; i++) { - if (_hostconf[i].byaddr - && (hp = (*_hostconf[i].byaddr)(src, len, af, errp)) != NULL) - return hp; - } - - return NULL; -} - -void -freehostent(struct hostent *ptr) -{ - free(ptr); -} - -#if 0 - -/* XXX: should be deprecated */ -struct hostent * -getnodebyname(const char *name, int af, int flags) -{ - return getipnodebyname(name, af, flags, &h_errno); -} - -#ifdef __warn_references -__warn_references(getnodebyname, - "warning: getnodebyname() deprecated, " - "should use getaddrinfo() or getipnodebyname()"); -#endif - -struct hostent * -getnodebyaddr(const void *src, size_t len, int af) -{ - return getipnodebyaddr(src, len, af, &h_errno); -} - -#ifdef __warn_references -__warn_references(getnodebyaddr, - "warning: getnodebyaddr() deprecated, " - "should use getnameinfo() or getipnodebyaddr()"); -#endif - -#endif - -/* - * Private utility functions - */ - -/* - * _hpcopy: allocate and copy hostent structure - */ -static struct hostent * -_hpcopy(struct hostent *hp, int *errp) -{ - struct hostent *nhp; - char *cp, **pp; - int size, addrsize; - int nalias = 0, naddr = 0; - int al_off; - int i; - - if (hp == NULL) - return hp; - - /* count size to be allocated */ - size = sizeof(struct hostent); - if (hp->h_name != NULL && *hp->h_name != '\0') - size += strlen(hp->h_name) + 1; - if ((pp = hp->h_aliases) != NULL) { - for (i = 0; *pp != NULL; i++, pp++) { - if (**pp != '\0') { - size += strlen(*pp) + 1; - nalias++; - } - } - } - /* adjust alignment */ - size = ALIGN(size); - al_off = size; - size += sizeof(char *) * (nalias + 1); - addrsize = ALIGN(hp->h_length); - if ((pp = hp->h_addr_list) != NULL) { - while (*pp++ != NULL) - naddr++; - } - size += addrsize * naddr; - size += sizeof(char *) * (naddr + 1); - - /* copy */ - if ((nhp = (struct hostent *)malloc(size)) == NULL) { - *errp = TRY_AGAIN; - return NULL; - } - cp = (char *)&nhp[1]; - if (hp->h_name != NULL && *hp->h_name != '\0') { - nhp->h_name = cp; - strcpy(cp, hp->h_name); - cp += strlen(cp) + 1; - } else - nhp->h_name = NULL; - nhp->h_aliases = (char **)((char *)nhp + al_off); - if ((pp = hp->h_aliases) != NULL) { - for (i = 0; *pp != NULL; pp++) { - if (**pp != '\0') { - nhp->h_aliases[i++] = cp; - strcpy(cp, *pp); - cp += strlen(cp) + 1; - } - } - } - nhp->h_aliases[nalias] = NULL; - cp = (char *)&nhp->h_aliases[nalias + 1]; - nhp->h_addrtype = hp->h_addrtype; - nhp->h_length = hp->h_length; - nhp->h_addr_list = (char **)cp; - if ((pp = hp->h_addr_list) != NULL) { - cp = (char *)&nhp->h_addr_list[naddr + 1]; - for (i = 0; *pp != NULL; pp++) { - nhp->h_addr_list[i++] = cp; - memcpy(cp, *pp, hp->h_length); - cp += addrsize; - } - } - nhp->h_addr_list[naddr] = NULL; - return nhp; -} - -/* - * _hpaddr: construct hostent structure with one address - */ -static struct hostent * -_hpaddr(int af, const char *name, void *addr, int *errp) -{ - struct hostent *hp, hpbuf; - char *addrs[2]; - - hp = &hpbuf; - hp->h_name = (char *)name; - hp->h_aliases = NULL; - hp->h_addrtype = af; - hp->h_length = ADDRLEN(af); - hp->h_addr_list = addrs; - addrs[0] = (char *)addr; - addrs[1] = NULL; - return _hpcopy(hp, errp); -} - -/* - * _hpmerge: merge 2 hostent structure, arguments will be freed - */ -static struct hostent * -_hpmerge(struct hostent *hp1, struct hostent *hp2, int *errp) -{ - int i, j; - int naddr, nalias; - char **pp; - struct hostent *hp, hpbuf; - char *aliases[MAXALIASES + 1], *addrs[MAXADDRS + 1]; - union inx_addr addrbuf[MAXADDRS]; - - if (hp1 == NULL) - return hp2; - if (hp2 == NULL) - return hp1; - -#define HP(i) (i == 1 ? hp1 : hp2) - hp = &hpbuf; - hp->h_name = (hp1->h_name != NULL ? hp1->h_name : hp2->h_name); - hp->h_aliases = aliases; - nalias = 0; - for (i = 1; i <= 2; i++) { - if ((pp = HP(i)->h_aliases) == NULL) - continue; - for (; nalias < MAXALIASES && *pp != NULL; pp++) { - /* check duplicates */ - for (j = 0; j < nalias; j++) - if (strcasecmp(*pp, aliases[j]) == 0) - break; - if (j == nalias) - aliases[nalias++] = *pp; - } - } - aliases[nalias] = NULL; -#ifdef INET6 - if (hp1->h_length != hp2->h_length) { - hp->h_addrtype = AF_INET6; - hp->h_length = sizeof(struct in6_addr); - } else { -#endif - hp->h_addrtype = hp1->h_addrtype; - hp->h_length = hp1->h_length; -#ifdef INET6 - } -#endif - hp->h_addr_list = addrs; - naddr = 0; - for (i = 1; i <= 2; i++) { - if ((pp = HP(i)->h_addr_list) == NULL) - continue; - if (HP(i)->h_length == hp->h_length) { - while (naddr < MAXADDRS && *pp != NULL) - addrs[naddr++] = *pp++; - } else { - /* copy IPv4 addr as mapped IPv6 addr */ - while (naddr < MAXADDRS && *pp != NULL) { - MAPADDR(&addrbuf[naddr], *pp++); - addrs[naddr] = (char *)&addrbuf[naddr]; - naddr++; - } - } - } - addrs[naddr] = NULL; - hp = _hpcopy(hp, errp); - freehostent(hp1); - freehostent(hp2); - return hp; -} - -/* - * _hpmapv6: convert IPv4 hostent into IPv4-mapped IPv6 addresses - */ -#ifdef INET6 -static struct hostent * -_hpmapv6(struct hostent *hp, int *errp) -{ - struct hostent *hp6; - - if (hp == NULL) - return NULL; - if (hp->h_addrtype == AF_INET6) - return hp; - - /* make dummy hostent to convert IPv6 address */ - if ((hp6 = (struct hostent *)malloc(sizeof(struct hostent))) == NULL) { - *errp = TRY_AGAIN; - return NULL; - } - hp6->h_name = NULL; - hp6->h_aliases = NULL; - hp6->h_addrtype = AF_INET6; - hp6->h_length = sizeof(struct in6_addr); - hp6->h_addr_list = NULL; - return _hpmerge(hp6, hp, errp); -} -#endif - -/* - * _hpsort: sort address by sortlist - */ -static struct hostent * -_hpsort(struct hostent *hp) -{ - int i, j, n; - u_char *ap, *sp, *mp, **pp; - char t; - char order[MAXADDRS]; - int nsort = _res.nsort; - - if (hp == NULL || hp->h_addr_list[1] == NULL || nsort == 0) - return hp; - for (i = 0; (ap = (u_char *)hp->h_addr_list[i]); i++) { - for (j = 0; j < nsort; j++) { -#ifdef INET6 - if (_res_ext.sort_list[j].af != hp->h_addrtype) - continue; - sp = (u_char *)&_res_ext.sort_list[j].addr; - mp = (u_char *)&_res_ext.sort_list[j].mask; -#else - sp = (u_char *)&_res.sort_list[j].addr; - mp = (u_char *)&_res.sort_list[j].mask; -#endif - for (n = 0; n < hp->h_length; n++) { - if ((ap[n] & mp[n]) != sp[n]) - break; - } - if (n == hp->h_length) - break; - } - order[i] = j; - } - n = i; - pp = (u_char **)hp->h_addr_list; - for (i = 0; i < n - 1; i++) { - for (j = i + 1; j < n; j++) { - if (order[i] > order[j]) { - ap = pp[i]; - pp[i] = pp[j]; - pp[j] = ap; - t = order[i]; - order[i] = order[j]; - order[j] = t; - } - } - } - return hp; -} - -static char * -_hgetword(char **pp) -{ - char c, *p, *ret; - const char *sp; - static const char sep[] = "# \t\n"; - - ret = NULL; - for (p = *pp; (c = *p) != '\0'; p++) { - for (sp = sep; *sp != '\0'; sp++) { - if (c == *sp) - break; - } - if (c == '#') - p[1] = '\0'; /* ignore rest of line */ - if (ret == NULL) { - if (*sp == '\0') - ret = p; - } else { - if (*sp != '\0') { - *p++ = '\0'; - break; - } - } - } - *pp = p; - if (ret == NULL || *ret == '\0') - return NULL; - return ret; -} - -/* - * FILES (/etc/hosts) - */ - -static FILE * -_files_open(int *errp) -{ - FILE *fp; - fp = fopen(_PATH_HOSTS, "r"); - if (fp == NULL) - *errp = NO_RECOVERY; - return fp; -} - -static struct hostent * -_files_ghbyname(const char *name, int af, int *errp) -{ - int match, nalias; - char *p, *line, *addrstr, *cname; - FILE *fp; - struct hostent *rethp, *hp, hpbuf; - char *aliases[MAXALIASES + 1], *addrs[2]; - union inx_addr addrbuf; - char buf[BUFSIZ]; - - if ((fp = _files_open(errp)) == NULL) - return NULL; - rethp = hp = NULL; - - while (fgets(buf, sizeof(buf), fp)) { - line = buf; - if ((addrstr = _hgetword(&line)) == NULL - || (cname = _hgetword(&line)) == NULL) - continue; - match = (strcasecmp(cname, name) == 0); - nalias = 0; - while ((p = _hgetword(&line)) != NULL) { - if (!match) - match = (strcasecmp(p, name) == 0); - if (nalias < MAXALIASES) - aliases[nalias++] = p; - } - if (!match) - continue; - if ((af == AF_INET - ? inet_aton(addrstr, (struct in_addr *)&addrbuf) - : inet_pton(af, addrstr, &addrbuf)) != 1) { - *errp = NO_DATA; /* name found */ - continue; - } - hp = &hpbuf; - hp->h_name = cname; - hp->h_aliases = aliases; - aliases[nalias] = NULL; - hp->h_addrtype = af; - hp->h_length = ADDRLEN(af); - hp->h_addr_list = addrs; - addrs[0] = (char *)&addrbuf; - addrs[1] = NULL; - hp = _hpcopy(hp, errp); - rethp = _hpmerge(rethp, hp, errp); - } - fclose(fp); - return rethp; -} - -static struct hostent * -_files_ghbyaddr(const void *addr, int addrlen, int af, int *errp) -{ - int nalias; - char *p, *line; - FILE *fp; - struct hostent *hp, hpbuf; - char *aliases[MAXALIASES + 1], *addrs[2]; - union inx_addr addrbuf; - char buf[BUFSIZ]; - - if ((fp = _files_open(errp)) == NULL) - return NULL; - hp = NULL; - while (fgets(buf, sizeof(buf), fp)) { - line = buf; - if ((p = _hgetword(&line)) == NULL - || (af == AF_INET - ? inet_aton(p, (struct in_addr *)&addrbuf) - : inet_pton(af, p, &addrbuf)) != 1 - || memcmp(addr, &addrbuf, addrlen) != 0 - || (p = _hgetword(&line)) == NULL) - continue; - hp = &hpbuf; - hp->h_name = p; - hp->h_aliases = aliases; - nalias = 0; - while ((p = _hgetword(&line)) != NULL) { - if (nalias < MAXALIASES) - aliases[nalias++] = p; - } - aliases[nalias] = NULL; - hp->h_addrtype = af; - hp->h_length = addrlen; - hp->h_addr_list = addrs; - addrs[0] = (char *)&addrbuf; - addrs[1] = NULL; - hp = _hpcopy(hp, errp); - break; - } - fclose(fp); - return hp; -} - -/* - * NIS - * - * XXX actually a hack, these are INET4 specific. - */ -static struct hostent * -_nis_ghbyname(const char *name, int af, int *errp) -{ - struct hostent *hp = NULL; - - if (af == AF_INET) { - hp = _gethostbynisname(name, af); - if (hp != NULL) - hp = _hpcopy(hp, errp); - } - return (hp); - -} - -static struct hostent * -_nis_ghbyaddr(const void *addr, int addrlen, int af, int *errp) -{ - struct hostent *hp = NULL; - - if (af == AF_INET) { - hp = _gethostbynisaddr(addr, addrlen, af); - if (hp != NULL) - hp = _hpcopy(hp, errp); - } - return (hp); -} - -#ifdef DEBUG -#define DNS_ASSERT(X) if (!(X)) { fprintf(stderr, "ASSFAIL: %s %d: %s\n", __FILE__, __LINE__, #X); goto badanswer; } -#else -#define DNS_ASSERT(X) if (!(X)) { goto badanswer; } -#endif - -static struct hostent * -_dns_ghbyname(const char *name, int af, int *errp) -{ - int n; - u_char answer[BUFSIZ]; - char tbuf[MAXDNAME+1]; - HEADER *hp; - u_char *cp, *eom; - int qtype; - int type, class, ancount, qdcount; - u_long ttl; - char hostbuf[BUFSIZ]; - char *bp; - char *alist[MAXALIASES]; - char *hlist[MAXADDRS]; - struct hostent hbuf; - int buflen; - int na, nh; - - if ((_res.options & RES_INIT) == 0) { - if (res_init() < 0) { - *errp = h_errno; - return NULL; - } - } - hbuf.h_aliases = alist; - hbuf.h_addrtype = af; - hbuf.h_length = ADDRLEN(af); - hbuf.h_addr_list = hlist; - na = nh = 0; - -#ifdef INET6 - qtype = (af == AF_INET6 ? T_AAAA : T_A); -#else - qtype = T_A; -#endif - n = res_search(name, C_IN, qtype, answer, sizeof(answer)); - if (n < 0) { - *errp = h_errno; - return NULL; - } - hp = (HEADER *)answer; - eom = answer + n; - ancount = ntohs(hp->ancount); - qdcount = ntohs(hp->qdcount); - DNS_ASSERT(qdcount == 1); - cp = answer + sizeof(HEADER); - bp = hostbuf; - buflen = sizeof(hostbuf); - - n = dn_expand(answer, eom, cp, bp, buflen); - DNS_ASSERT(n >= 0); - cp += n + QFIXEDSZ; - hbuf.h_name = bp; - n = strlen(bp) + 1; - bp += n; - buflen -= n; - while (ancount-- > 0 && cp < eom) { - n = dn_expand(answer, eom, cp, bp, buflen); - DNS_ASSERT(n >= 0); - cp += n; /* name */ - type = _getshort(cp); - cp += 2; /* type */ - class = _getshort(cp); - cp += 2; /* class */ - ttl = _getlong(cp); - cp += 4; /* ttl */ - n = _getshort(cp); - cp += 2; /* len */ - DNS_ASSERT(class == C_IN); - switch (type) { - case T_CNAME: - if (na >= MAXALIASES-1) { - cp += n; - break; - } - n = dn_expand(answer, eom, cp, tbuf, sizeof(tbuf)); - DNS_ASSERT(n >= 0); - cp += n; - /* alias */ - alist[na++] = bp; - n = strlen(bp) + 1; - bp += n; - buflen -= n; - /* canon */ - n = strlen(tbuf) + 1; - DNS_ASSERT(n < buflen); - strcpy(bp, tbuf); - hbuf.h_name = bp; - bp += n; - buflen -= n; - break; - case T_A: -#ifdef INET6 - case T_AAAA: -#endif - DNS_ASSERT(type == qtype); - bp = (char *)ALIGN(bp); - DNS_ASSERT(n == hbuf.h_length); - DNS_ASSERT(n < buflen); - if (nh < MAXADDRS-1) { - hlist[nh++] = bp; - memcpy(bp, cp, n); - bp += n; - buflen -= n; - } - cp += n; - break; - default: - DNS_ASSERT(0); - cp += n; - break; - } - } - if (nh == 0) { - badanswer: - *errp = NO_RECOVERY; - return NULL; - } - alist[na] = NULL; - hlist[nh] = NULL; - return _hpcopy(&hbuf, errp); -} - -static struct hostent * -_dns_ghbyaddr(const void *addr, int addrlen, int af, int *errp) -{ - int n; - u_char answer[BUFSIZ]; - HEADER *hp; - u_char c, *cp, *eom; - int type, class, ancount, qdcount; - u_long ttl; - char hostbuf[BUFSIZ]; - char *bp; - char *alist[MAXALIASES]; - char *hlist[2]; - struct hostent hbuf; - int buflen; - int na; -#ifdef INET6 - static const char hex[] = "0123456789abcdef"; -#endif - -#ifdef INET6 - /* XXX */ - if (af == AF_INET6 && IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)addr)) - return NULL; -#endif - - if ((_res.options & RES_INIT) == 0) { - if (res_init() < 0) { - *errp = h_errno; - return NULL; - } - } - hbuf.h_name = NULL; - hbuf.h_aliases = alist; - hbuf.h_addrtype = af; - hbuf.h_length = addrlen; - hbuf.h_addr_list = hlist; - hlist[0] = (char *)addr; - hlist[1] = NULL; - na = 0; - - n = 0; - bp = hostbuf; - cp = (u_char *)addr+addrlen-1; - switch (af) { -#ifdef INET6 - case AF_INET6: - for (; n < addrlen; n++, cp--) { - c = *cp; - *bp++ = hex[c & 0xf]; - *bp++ = '.'; - *bp++ = hex[c >> 4]; - *bp++ = '.'; - } - strcpy(bp, "ip6.int"); - break; -#endif - default: - for (; n < addrlen; n++, cp--) { - c = *cp; - if (c >= 100) - *bp++ = '0' + c / 100; - if (c >= 10) - *bp++ = '0' + (c % 100) / 10; - *bp++ = '0' + c % 10; - *bp++ = '.'; - } - strcpy(bp, "in-addr.arpa"); - break; - } - - n = res_query(hostbuf, C_IN, T_PTR, answer, sizeof(answer)); - if (n < 0) { - *errp = h_errno; - return NULL; - } - hp = (HEADER *)answer; - eom = answer + n; - ancount = ntohs(hp->ancount); - qdcount = ntohs(hp->qdcount); - DNS_ASSERT(qdcount == 1); - cp = answer + sizeof(HEADER); - bp = hostbuf; - buflen = sizeof(hostbuf); - - n = dn_expand(answer, eom, cp, bp, buflen); - DNS_ASSERT(n >= 0); - cp += n + QFIXEDSZ; - while (ancount-- > 0 && cp < eom) { - n = dn_expand(answer, eom, cp, bp, buflen); - DNS_ASSERT(n >= 0); - cp += n; /* name */ - type = _getshort(cp); - cp += 2; /* type */ - class = _getshort(cp); - cp += 2; /* class */ - ttl = _getlong(cp); - cp += 4; /* ttl */ - n = _getshort(cp); - cp += 2; /* len */ - DNS_ASSERT(class == C_IN); - switch (type) { - case T_PTR: - n = dn_expand(answer, eom, cp, bp, buflen); - DNS_ASSERT(n >= 0); - cp += n; - if (na >= MAXALIASES-1) - break; - if (hbuf.h_name == NULL) - hbuf.h_name = bp; - else - alist[na++] = bp; - n = strlen(bp) + 1; - bp += n; - buflen -= n; - break; - case T_CNAME: - cp += n; - break; - default: - badanswer: - *errp = NO_RECOVERY; - return NULL; - } - } - if (hbuf.h_name == NULL) { - *errp = h_errno; - return NULL; - } - alist[na] = NULL; - return _hpcopy(&hbuf, errp); -} - -#ifdef ICMPNL - -/* - * experimental: - * draft-ietf-ipngwg-icmp-namelookups-02.txt - * ifindex is assumed to be encoded in addr. - */ -#include -#include -#include - -struct _icmp_host_cache { - struct _icmp_host_cache *hc_next; - int hc_ifindex; - struct in6_addr hc_addr; - char *hc_name; -}; - -static char * -_icmp_fqdn_query(const struct in6_addr *addr, int ifindex) -{ - int s; - struct icmp6_filter filter; - struct msghdr msg; - struct cmsghdr *cmsg; - struct in6_pktinfo *pkt; - char cbuf[256]; - char buf[1024]; - int cc; - struct icmp6_fqdn_query *fq; - struct icmp6_fqdn_reply *fr; - struct _icmp_host_cache *hc; - struct sockaddr_in6 sin6; - struct iovec iov; - fd_set s_fds, fds; - struct timeval tout; - int len; - char *name; - static int pid; - static struct _icmp_host_cache *hc_head; - - for (hc = hc_head; hc; hc = hc->hc_next) { - if (hc->hc_ifindex == ifindex - && IN6_ARE_ADDR_EQUAL(&hc->hc_addr, addr)) - return hc->hc_name; - } - - if (pid == 0) - pid = getpid(); - - ICMP6_FILTER_SETBLOCKALL(&filter); - ICMP6_FILTER_SETPASS(ICMP6_FQDN_REPLY, &filter); - - FD_ZERO(&s_fds); - tout.tv_sec = 0; - tout.tv_usec = 200000; /*XXX: 200ms*/ - - fq = (struct icmp6_fqdn_query *)buf; - fq->icmp6_fqdn_type = ICMP6_FQDN_QUERY; - fq->icmp6_fqdn_code = 0; - fq->icmp6_fqdn_cksum = 0; - fq->icmp6_fqdn_id = (u_short)pid; - fq->icmp6_fqdn_unused = 0; - fq->icmp6_fqdn_cookie[0] = 0; - fq->icmp6_fqdn_cookie[1] = 0; - - memset(&sin6, 0, sizeof(sin6)); - sin6.sin6_family = AF_INET6; - sin6.sin6_addr = *addr; - - memset(&msg, 0, sizeof(msg)); - msg.msg_name = (caddr_t)&sin6; - msg.msg_namelen = sizeof(sin6); - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - msg.msg_control = NULL; - msg.msg_controllen = 0; - iov.iov_base = (caddr_t)buf; - iov.iov_len = sizeof(struct icmp6_fqdn_query); - - if (ifindex) { - msg.msg_control = cbuf; - msg.msg_controllen = sizeof(cbuf); - cmsg = CMSG_FIRSTHDR(&msg); - cmsg->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo)); - cmsg->cmsg_level = IPPROTO_IPV6; - cmsg->cmsg_type = IPV6_PKTINFO; - pkt = (struct in6_pktinfo *)&cmsg[1]; - memset(&pkt->ipi6_addr, 0, sizeof(struct in6_addr)); - pkt->ipi6_ifindex = ifindex; - cmsg = CMSG_NXTHDR(&msg, cmsg); - msg.msg_controllen = (char *)cmsg - cbuf; - } - - if ((s = socket(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) < 0) - return NULL; - (void)setsockopt(s, IPPROTO_ICMPV6, ICMP6_FILTER, - (char *)&filter, sizeof(filter)); - cc = sendmsg(s, &msg, 0); - if (cc < 0) { - _close(s); - return NULL; - } - FD_SET(s, &s_fds); - for (;;) { - fds = s_fds; - if (select(s + 1, &fds, NULL, NULL, &tout) <= 0) { - _close(s); - return NULL; - } - len = sizeof(sin6); - cc = recvfrom(s, buf, sizeof(buf), 0, - (struct sockaddr *)&sin6, &len); - if (cc <= 0) { - _close(s); - return NULL; - } - if (cc < sizeof(struct ip6_hdr) + sizeof(struct icmp6_hdr)) - continue; - if (!IN6_ARE_ADDR_EQUAL(addr, &sin6.sin6_addr)) - continue; - fr = (struct icmp6_fqdn_reply *)(buf + sizeof(struct ip6_hdr)); - if (fr->icmp6_fqdn_type == ICMP6_FQDN_REPLY) - break; - } - _close(s); - if (fr->icmp6_fqdn_cookie[1] != 0) { - /* rfc1788 type */ - name = buf + sizeof(struct ip6_hdr) + sizeof(struct icmp6_hdr) + 4; - len = (buf + cc) - name; - } else { - len = fr->icmp6_fqdn_namelen; - name = fr->icmp6_fqdn_name; - } - if (len <= 0) - return NULL; - name[len] = 0; - - if ((hc = (struct _icmp_host_cache *)malloc(sizeof(*hc))) == NULL) - return NULL; - /* XXX: limit number of cached entries */ - hc->hc_ifindex = ifindex; - hc->hc_addr = *addr; - hc->hc_name = strdup(name); - hc->hc_next = hc_head; - hc_head = hc; - return hc->hc_name; -} - -static struct hostent * -_icmp_ghbyaddr(const void *addr, int addrlen, int af, int *errp) -{ - char *hname; - int ifindex; - struct in6_addr addr6; - - if (af != AF_INET6) { - /* - * Note: rfc1788 defines Who Are You for IPv4, - * but no one implements it. - */ - return NULL; - } - - memcpy(&addr6, addr, addrlen); - ifindex = (addr6.s6_addr[2] << 8) | addr6.s6_addr[3]; - addr6.s6_addr[2] = addr6.s6_addr[3] = 0; - - if (!IN6_IS_ADDR_LINKLOCAL(&addr6)) - return NULL; /*XXX*/ - - if ((hname = _icmp_fqdn_query(&addr6, ifindex)) == NULL) - return NULL; - return _hpaddr(af, hname, &addr6, errp); -} -#endif /* ICMPNL */ diff --git a/lib/libc/net/ns.3 b/lib/libc/net/ns.3 deleted file mode 100644 index 6e697f9..0000000 --- a/lib/libc/net/ns.3 +++ /dev/null @@ -1,131 +0,0 @@ -.\" Copyright (c) 1986, 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. -.\" -.\" @(#)ns.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt NS 3 -.Os BSD 4.3 -.Sh NAME -.Nm ns_addr , -.Nm ns_ntoa -.Nd Xerox -.Tn NS Ns (tm) -address conversion routines -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Ft struct ns_addr -.Fn ns_addr "char *cp" -.Ft char * -.Fn ns_ntoa "struct ns_addr ns" -.Sh DESCRIPTION -The routine -.Fn ns_addr -interprets character strings representing -.Tn XNS -addresses, returning binary information suitable -for use in system calls. -The routine -.Fn ns_ntoa -takes -.Tn XNS -addresses and returns -.Tn ASCII -strings representing the address in a -notation in common use in the Xerox Development Environment: -.Bd -filled -offset indent -.. -.Ed -.Pp -Trailing zero fields are suppressed, and each number is printed in hexadecimal, -in a format suitable for input to -.Fn ns_addr . -Any fields lacking super-decimal digits will have a -trailing -.Ql H -appended. -.Pp -Unfortunately, no universal standard exists for representing -.Tn XNS -addresses. -An effort has been made to insure that -.Fn ns_addr -be compatible with most formats in common use. -It will first separate an address into 1 to 3 fields using a single delimiter -chosen from -period -.Ql \&. , -colon -.Ql \&: -or pound-sign -.Ql \&# . -Each field is then examined for byte separators (colon or period). -If there are byte separators, each subfield separated is taken to be -a small hexadecimal number, and the entirety is taken as a network-byte-ordered -quantity to be zero extended in the high-network-order bytes. -Next, the field is inspected for hyphens, in which case -the field is assumed to be a number in decimal notation -with hyphens separating the millenia. -Next, the field is assumed to be a number: -It is interpreted -as hexadecimal if there is a leading -.Ql 0x -(as in C), -a trailing -.Ql H -(as in Mesa), or there are any super-decimal digits present. -It is interpreted as octal is there is a leading -.Ql 0 -and there are no super-octal digits. -Otherwise, it is converted as a decimal number. -.Sh RETURN VALUES -None. (See -.Sx BUGS . ) -.Sh SEE ALSO -.Xr hosts 5 , -.Xr networks 5 -.Sh HISTORY -The -.Fn ns_addr -and -.Fn ns_toa -functions appeared in -.Bx 4.3 . -.Sh BUGS -The string returned by -.Fn ns_ntoa -resides in a static memory area. -The function -.Fn ns_addr -should diagnose improperly formed input, and there should be an unambiguous -way to recognize this. diff --git a/lib/libc/net/ns_addr.c b/lib/libc/net/ns_addr.c deleted file mode 100644 index 3446e08..0000000 --- a/lib/libc/net/ns_addr.c +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (c) 1986, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * J.Q. Johnson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (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[] = "@(#)ns_addr.c 8.1 (Berkeley) 6/7/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -static struct ns_addr addr, zero_addr; - -static void Field(), cvtbase(); - -struct ns_addr -ns_addr(name) - const char *name; -{ - char separator; - char *hostname, *socketname, *cp; - char buf[50]; - - (void)strncpy(buf, name, sizeof(buf) - 1); - buf[sizeof(buf) - 1] = '\0'; - - /* - * First, figure out what he intends as a field separtor. - * Despite the way this routine is written, the prefered - * form 2-272.AA001234H.01777, i.e. XDE standard. - * Great efforts are made to insure backward compatability. - */ - if ((hostname = strchr(buf, '#')) != NULL) - separator = '#'; - else { - hostname = strchr(buf, '.'); - if ((cp = strchr(buf, ':')) && - ((hostname && cp < hostname) || (hostname == 0))) { - hostname = cp; - separator = ':'; - } else - separator = '.'; - } - if (hostname) - *hostname++ = 0; - - addr = zero_addr; - Field(buf, addr.x_net.c_net, 4); - if (hostname == 0) - return (addr); /* No separator means net only */ - - socketname = strchr(hostname, separator); - if (socketname) { - *socketname++ = 0; - Field(socketname, (u_char *)&addr.x_port, 2); - } - - Field(hostname, addr.x_host.c_host, 6); - - return (addr); -} - -static void -Field(buf, out, len) - char *buf; - u_char *out; - int len; -{ - register char *bp = buf; - int i, ibase, base16 = 0, base10 = 0, clen = 0; - int hb[6], *hp; - char *fmt; - - /* - * first try 2-273#2-852-151-014#socket - */ - if ((*buf != '-') && - (1 < (i = sscanf(buf, "%d-%d-%d-%d-%d", - &hb[0], &hb[1], &hb[2], &hb[3], &hb[4])))) { - cvtbase(1000L, 256, hb, i, out, len); - return; - } - /* - * try form 8E1#0.0.AA.0.5E.E6#socket - */ - if (1 < (i = sscanf(buf,"%x.%x.%x.%x.%x.%x", - &hb[0], &hb[1], &hb[2], &hb[3], &hb[4], &hb[5]))) { - cvtbase(256L, 256, hb, i, out, len); - return; - } - /* - * try form 8E1#0:0:AA:0:5E:E6#socket - */ - if (1 < (i = sscanf(buf,"%x:%x:%x:%x:%x:%x", - &hb[0], &hb[1], &hb[2], &hb[3], &hb[4], &hb[5]))) { - cvtbase(256L, 256, hb, i, out, len); - return; - } - /* - * This is REALLY stretching it but there was a - * comma notation separting shorts -- definitely non standard - */ - if (1 < (i = sscanf(buf,"%x,%x,%x", - &hb[0], &hb[1], &hb[2]))) { - hb[0] = htons(hb[0]); hb[1] = htons(hb[1]); - hb[2] = htons(hb[2]); - cvtbase(65536L, 256, hb, i, out, len); - return; - } - - /* Need to decide if base 10, 16 or 8 */ - while (*bp) switch (*bp++) { - - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '-': - break; - - case '8': case '9': - base10 = 1; - break; - - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - base16 = 1; - break; - - case 'x': case 'X': - *--bp = '0'; - base16 = 1; - break; - - case 'h': case 'H': - base16 = 1; - /* fall into */ - - default: - *--bp = 0; /* Ends Loop */ - } - if (base16) { - fmt = "%3x"; - ibase = 4096; - } else if (base10 == 0 && *buf == '0') { - fmt = "%3o"; - ibase = 512; - } else { - fmt = "%3d"; - ibase = 1000; - } - - for (bp = buf; *bp++; ) clen++; - if (clen == 0) clen++; - if (clen > 18) clen = 18; - i = ((clen - 1) / 3) + 1; - bp = clen + buf - 3; - hp = hb + i - 1; - - while (hp > hb) { - (void)sscanf(bp, fmt, hp); - bp[0] = 0; - hp--; - bp -= 3; - } - (void)sscanf(buf, fmt, hp); - cvtbase((long)ibase, 256, hb, i, out, len); -} - -static void -cvtbase(oldbase,newbase,input,inlen,result,reslen) - long oldbase; - int newbase; - int input[]; - int inlen; - unsigned char result[]; - int reslen; -{ - int d, e; - long sum; - - e = 1; - while (e > 0 && reslen > 0) { - d = 0; e = 0; sum = 0; - /* long division: input=input/newbase */ - while (d < inlen) { - sum = sum*oldbase + (long) input[d]; - e += (sum > 0); - input[d++] = sum / newbase; - sum %= newbase; - } - result[--reslen] = sum; /* accumulate remainder */ - } - for (d=0; d < reslen; d++) - result[d] = 0; -} diff --git a/lib/libc/net/ns_name.c b/lib/libc/net/ns_name.c deleted file mode 100644 index cbaf7bd..0000000 --- a/lib/libc/net/ns_name.c +++ /dev/null @@ -1,593 +0,0 @@ -/* - * Copyright (c) 1996 by Internet Software Consortium. - * - * 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. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM 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. - */ - -#ifndef lint -static char rcsid[] = "$FreeBSD$"; -#endif - -#include - -#include -#include - -#include -#include -#include - -/* Data. */ - -static char digits[] = "0123456789"; - -/* Forward. */ - -static int special(int); -static int printable(int); -static int dn_find(const u_char *, const u_char *, - const u_char * const *, - const u_char * const *); - -/* Public. */ - -/* - * ns_name_ntop(src, dst, dstsiz) - * Convert an encoded domain name to printable ascii as per RFC1035. - * return: - * Number of bytes written to buffer, or -1 (with errno set) - * notes: - * The root is returned as "." - * All other domains are returned in non absolute form - */ -int -ns_name_ntop(const u_char *src, char *dst, size_t dstsiz) { - const u_char *cp; - char *dn, *eom; - u_char c; - u_int n; - - cp = src; - dn = dst; - eom = dst + dstsiz; - - while ((n = *cp++) != 0) { - if ((n & NS_CMPRSFLGS) != 0) { - /* Some kind of compression pointer. */ - errno = EMSGSIZE; - return (-1); - } - if (dn != dst) { - if (dn >= eom) { - errno = EMSGSIZE; - return (-1); - } - *dn++ = '.'; - } - if (dn + n >= eom) { - errno = EMSGSIZE; - return (-1); - } - for ((void)NULL; n > 0; n--) { - c = *cp++; - if (special(c)) { - if (dn + 1 >= eom) { - errno = EMSGSIZE; - return (-1); - } - *dn++ = '\\'; - *dn++ = (char)c; - } else if (!printable(c)) { - if (dn + 3 >= eom) { - errno = EMSGSIZE; - return (-1); - } - *dn++ = '\\'; - *dn++ = digits[c / 100]; - *dn++ = digits[(c % 100) / 10]; - *dn++ = digits[c % 10]; - } else { - if (dn >= eom) { - errno = EMSGSIZE; - return (-1); - } - *dn++ = (char)c; - } - } - } - if (dn == dst) { - if (dn >= eom) { - errno = EMSGSIZE; - return (-1); - } - *dn++ = '.'; - } - if (dn >= eom) { - errno = EMSGSIZE; - return (-1); - } - *dn++ = '\0'; - return (dn - dst); -} - -/* - * ns_name_pton(src, dst, dstsiz) - * Convert a ascii string into an encoded domain name as per RFC1035. - * return: - * -1 if it fails - * 1 if string was fully qualified - * 0 is string was not fully qualified - * notes: - * Enforces label and domain length limits. - */ - -int -ns_name_pton(const char *src, u_char *dst, size_t dstsiz) { - u_char *label, *bp, *eom; - int c, n, escaped; - char *cp; - - escaped = 0; - bp = dst; - eom = dst + dstsiz; - label = bp++; - - while ((c = *src++) != 0) { - if (escaped) { - if ((cp = strchr(digits, c)) != NULL) { - n = (cp - digits) * 100; - if ((c = *src++) == 0 || - (cp = strchr(digits, c)) == NULL) { - errno = EMSGSIZE; - return (-1); - } - n += (cp - digits) * 10; - if ((c = *src++) == 0 || - (cp = strchr(digits, c)) == NULL) { - errno = EMSGSIZE; - return (-1); - } - n += (cp - digits); - if (n > 255) { - errno = EMSGSIZE; - return (-1); - } - c = n; - } - escaped = 0; - } else if (c == '\\') { - escaped = 1; - continue; - } else if (c == '.') { - c = (bp - label - 1); - if ((c & NS_CMPRSFLGS) != 0) { /* Label too big. */ - errno = EMSGSIZE; - return (-1); - } - if (label >= eom) { - errno = EMSGSIZE; - return (-1); - } - *label = c; - /* Fully qualified ? */ - if (*src == '\0') { - if (c != 0) { - if (bp >= eom) { - errno = EMSGSIZE; - return (-1); - } - *bp++ = '\0'; - } - if ((bp - dst) > MAXCDNAME) { - errno = EMSGSIZE; - return (-1); - } - return (1); - } - if (c == 0) { - errno = EMSGSIZE; - return (-1); - } - label = bp++; - continue; - } - if (bp >= eom) { - errno = EMSGSIZE; - return (-1); - } - *bp++ = (u_char)c; - } - c = (bp - label - 1); - if ((c & NS_CMPRSFLGS) != 0) { /* Label too big. */ - errno = EMSGSIZE; - return (-1); - } - if (label >= eom) { - errno = EMSGSIZE; - return (-1); - } - *label = c; - if (c != 0) { - if (bp >= eom) { - errno = EMSGSIZE; - return (-1); - } - *bp++ = 0; - } - if ((bp - dst) > MAXCDNAME) { /* src too big */ - errno = EMSGSIZE; - return (-1); - } - return (0); -} - -/* - * ns_name_unpack(msg, eom, src, dst, dstsiz) - * Unpack a domain name from a message, source may be compressed. - * return: - * -1 if it fails, or consumed octets if it succeeds. - */ -int -ns_name_unpack(const u_char *msg, const u_char *eom, const u_char *src, - u_char *dst, size_t dstsiz) -{ - const u_char *srcp, *dstlim; - u_char *dstp; - int n, c, len, checked; - - len = -1; - checked = 0; - dstp = dst; - srcp = src; - dstlim = dst + dstsiz; - if (srcp < msg || srcp >= eom) { - errno = EMSGSIZE; - return (-1); - } - /* Fetch next label in domain name. */ - while ((n = *srcp++) != 0) { - /* Check for indirection. */ - switch (n & NS_CMPRSFLGS) { - case 0: - /* Limit checks. */ - if (dstp + n + 1 >= dstlim || srcp + n >= eom) { - errno = EMSGSIZE; - return (-1); - } - checked += n + 1; - *dstp++ = n; - memcpy(dstp, srcp, n); - dstp += n; - srcp += n; - break; - - case NS_CMPRSFLGS: - if (srcp >= eom) { - errno = EMSGSIZE; - return (-1); - } - if (len < 0) - len = srcp - src + 1; - srcp = msg + (((n & 0x3f) << 8) | (*srcp & 0xff)); - if (srcp < msg || srcp >= eom) { /* Out of range. */ - errno = EMSGSIZE; - 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 >= eom - msg) { - errno = EMSGSIZE; - return (-1); - } - break; - - default: - errno = EMSGSIZE; - return (-1); /* flag error */ - } - } - *dstp = '\0'; - if (len < 0) - len = srcp - src; - return (len); -} - -/* - * ns_name_pack(src, dst, dstsiz, dnptrs, lastdnptr) - * Pack domain name 'domain' into 'comp_dn'. - * return: - * Size of the compressed name, or -1. - * notes: - * 'dnptrs' is an array of pointers to previous compressed names. - * dnptrs[0] is a pointer to the beginning of the message. The array - * ends with NULL. - * 'lastdnptr' is a pointer to the end of the array pointed to - * by 'dnptrs'. - * Side effects: - * The list of pointers in dnptrs is updated 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. - */ -int -ns_name_pack(const u_char *src, u_char *dst, int dstsiz, - const u_char **dnptrs, const u_char **lastdnptr) -{ - u_char *dstp; - const u_char **cpp, **lpp, *eob, *msg; - const u_char *srcp; - int n, l; - - srcp = src; - dstp = dst; - eob = dstp + dstsiz; - lpp = cpp = NULL; - if (dnptrs != NULL) { - if ((msg = *dnptrs++) != NULL) { - for (cpp = dnptrs; *cpp != NULL; cpp++) - (void)NULL; - lpp = cpp; /* end of list to search */ - } - } else - msg = NULL; - - /* make sure the domain we are about to add is legal */ - l = 0; - do { - n = *srcp; - if ((n & NS_CMPRSFLGS) != 0) { - errno = EMSGSIZE; - return (-1); - } - l += n + 1; - if (l > MAXCDNAME) { - errno = EMSGSIZE; - return (-1); - } - srcp += n + 1; - } while (n != 0); - - srcp = src; - do { - /* Look to see if we can use pointers. */ - n = *srcp; - if (n != 0 && msg != NULL) { - l = dn_find(srcp, msg, (const u_char * const *)dnptrs, - (const u_char * const *)lpp); - if (l >= 0) { - if (dstp + 1 >= eob) { - errno = EMSGSIZE; - return (-1); - } - *dstp++ = (l >> 8) | NS_CMPRSFLGS; - *dstp++ = l % 256; - return (dstp - dst); - } - /* Not found, save it. */ - if (lastdnptr != NULL && cpp < lastdnptr - 1 && - (dstp - msg) < 0x4000) { - *cpp++ = dstp; - *cpp = NULL; - } - } - /* copy label to buffer */ - if (n & NS_CMPRSFLGS) { /* Should not happen. */ - errno = EMSGSIZE; - return (-1); - } - if (dstp + 1 + n >= eob) { - errno = EMSGSIZE; - return (-1); - } - memcpy(dstp, srcp, n + 1); - srcp += n + 1; - dstp += n + 1; - } while (n != 0); - - if (dstp > eob) { - if (msg != NULL) - *lpp = NULL; - errno = EMSGSIZE; - return (-1); - } - return (dstp - dst); -} - -/* - * ns_name_uncompress(msg, eom, src, dst, dstsiz) - * Expand compressed domain name to presentation format. - * return: - * Number of bytes read out of `src', or -1 (with errno set). - * note: - * Root domain returns as "." not "". - */ -int -ns_name_uncompress(const u_char *msg, const u_char *eom, const u_char *src, - char *dst, size_t dstsiz) -{ - u_char tmp[NS_MAXCDNAME]; - int n; - - if ((n = ns_name_unpack(msg, eom, src, tmp, sizeof tmp)) == -1) - return (-1); - if (ns_name_ntop(tmp, dst, dstsiz) == -1) - return (-1); - return (n); -} - -/* - * ns_name_compress(src, dst, dstsiz, dnptrs, lastdnptr) - * Compress a domain name into wire format, using compression pointers. - * return: - * Number of bytes consumed in `dst' or -1 (with errno set). - * notes: - * 'dnptrs' is an array 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 - * array 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. - */ -int -ns_name_compress(const char *src, u_char *dst, size_t dstsiz, - const u_char **dnptrs, const u_char **lastdnptr) -{ - u_char tmp[NS_MAXCDNAME]; - - if (ns_name_pton(src, tmp, sizeof tmp) == -1) - return (-1); - return (ns_name_pack(tmp, dst, dstsiz, dnptrs, lastdnptr)); -} - -/* - * ns_name_skip(ptrptr, eom) - * Advance *ptrptr to skip over the compressed name it points at. - * return: - * 0 on success, -1 (with errno set) on failure. - */ -int -ns_name_skip(const u_char **ptrptr, const u_char *eom) { - const u_char *cp; - u_int n; - - cp = *ptrptr; - while (cp < eom && (n = *cp++) != 0) { - /* Check for indirection. */ - switch (n & NS_CMPRSFLGS) { - case 0: /* normal case, n == len */ - cp += n; - continue; - case NS_CMPRSFLGS: /* indirection */ - cp++; - break; - default: /* illegal type */ - errno = EMSGSIZE; - return (-1); - } - break; - } - if (cp > eom) { - errno = EMSGSIZE; - return (-1); - } - *ptrptr = cp; - return (0); -} - -/* Private. */ - -/* - * special(ch) - * Thinking in noninternationalized USASCII (per the DNS spec), - * is this characted special ("in need of quoting") ? - * return: - * boolean. - */ -static int -special(int ch) { - switch (ch) { - case 0x22: /* '"' */ - case 0x2E: /* '.' */ - case 0x3B: /* ';' */ - case 0x5C: /* '\\' */ - /* Special modifiers in zone files. */ - case 0x40: /* '@' */ - case 0x24: /* '$' */ - return (1); - default: - return (0); - } -} - -/* - * printable(ch) - * Thinking in noninternationalized USASCII (per the DNS spec), - * is this character visible and not a space when printed ? - * return: - * boolean. - */ -static int -printable(int ch) { - return (ch > 0x20 && ch < 0x7f); -} - -/* - * Thinking in noninternationalized USASCII (per the DNS spec), - * convert this character to lower case if it's upper case. - */ -static int -mklower(int ch) { - if (ch >= 0x41 && ch <= 0x5A) - return (ch + 0x20); - return (ch); -} - -/* - * dn_find(domain, msg, dnptrs, lastdnptr) - * Search for the counted-label name in an array of compressed names. - * return: - * offset from msg if found, or -1. - * notes: - * dnptrs is the pointer to the first name on the list, - * not the pointer to the start of the message. - */ -static int -dn_find(const u_char *domain, const u_char *msg, - const u_char * const *dnptrs, - const u_char * const *lastdnptr) -{ - const u_char *dn, *cp, *sp; - const u_char * const *cpp; - u_int n; - - for (cpp = dnptrs; cpp < lastdnptr; cpp++) { - dn = domain; - sp = cp = *cpp; - while ((n = *cp++) != 0) { - /* - * check for indirection - */ - switch (n & NS_CMPRSFLGS) { - case 0: /* normal case, n == len */ - if (n != *dn++) - goto next; - for ((void)NULL; n > 0; n--) - if (mklower(*dn++) != mklower(*cp++)) - goto next; - /* Is next root for both ? */ - if (*dn == '\0' && *cp == '\0') - return (sp - msg); - if (*dn) - continue; - goto next; - - case NS_CMPRSFLGS: /* indirection */ - cp = msg + (((n & 0x3f) << 8) | *cp); - break; - - default: /* illegal type */ - errno = EMSGSIZE; - return (-1); - } - } - next: ; - } - errno = ENOENT; - return (-1); -} diff --git a/lib/libc/net/ns_netint.c b/lib/libc/net/ns_netint.c deleted file mode 100644 index 5e25b49..0000000 --- a/lib/libc/net/ns_netint.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 1996 by Internet Software Consortium. - * - * 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. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM 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. - */ - -#ifndef lint -static char rcsid[] = "$FreeBSD$"; -#endif - -/* Import. */ - -#include -#include - -#include -#include - -u_int -ns_get16(const u_char *src) { - u_int dst; - - NS_GET16(dst, src); - return (dst); -} - -u_long -ns_get32(const u_char *src) { - u_long dst; - - NS_GET32(dst, src); - return (dst); -} - -void -ns_put16(u_int src, u_char *dst) { - NS_PUT16(src, dst); -} - -void -ns_put32(u_long src, u_char *dst) { - NS_PUT32(src, dst); -} diff --git a/lib/libc/net/ns_ntoa.c b/lib/libc/net/ns_ntoa.c deleted file mode 100644 index de5f305..0000000 --- a/lib/libc/net/ns_ntoa.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)ns_ntoa.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -char * -ns_ntoa(addr) - struct ns_addr addr; -{ - static char obuf[40]; - union { union ns_net net_e; u_long long_e; } net; - u_short port = htons(addr.x_port); - register char *cp; - char *cp2; - register u_char *up = addr.x_host.c_host; - u_char *uplim = up + 6; - static char *spectHex(); - - net.net_e = addr.x_net; - sprintf(obuf, "%lx", (u_long)ntohl(net.long_e)); - cp = spectHex(obuf); - cp2 = cp + 1; - while (*up==0 && up < uplim) up++; - if (up == uplim) { - if (port) { - sprintf(cp, ".0"); - cp += 2; - } - } else { - sprintf(cp, ".%x", *up++); - while (up < uplim) { - while (*cp) cp++; - sprintf(cp, "%02x", *up++); - } - cp = spectHex(cp2); - } - if (port) { - sprintf(cp, ".%x", port); - spectHex(cp + 1); - } - return (obuf); -} - -static char * -spectHex(p0) - char *p0; -{ - int ok = 0; - int nonzero = 0; - register char *p = p0; - for (; *p; p++) switch (*p) { - - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - *p += ('A' - 'a'); - /* fall into . . . */ - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - ok = 1; - case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - nonzero = 1; - } - if (nonzero && !ok) { *p++ = 'H'; *p = 0; } - return (p); -} diff --git a/lib/libc/net/ns_parse.c b/lib/libc/net/ns_parse.c deleted file mode 100644 index d3653b1..0000000 --- a/lib/libc/net/ns_parse.c +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (c) 1996 by Internet Software Consortium. - * - * 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. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM 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. - */ - -#ifndef lint -static char rcsid[] = "$FreeBSD$"; -#endif - -#include - -#include -#include - -#include -#include -#include - -/* These need to be in the same order as the nres.h:ns_flag enum. */ -struct _ns_flagdata _ns_flagdata[16] = { - { 0x8000, 15 }, /* qr. */ - { 0x7800, 11 }, /* opcode. */ - { 0x0400, 10 }, /* aa. */ - { 0x0200, 9 }, /* tc. */ - { 0x0100, 8 }, /* rd. */ - { 0x0080, 7 }, /* ra. */ - { 0x0040, 6 }, /* z. */ - { 0x0020, 5 }, /* ad. */ - { 0x0010, 4 }, /* cd. */ - { 0x000f, 0 }, /* rcode. */ - { 0x0000, 0 }, /* expansion (1/6). */ - { 0x0000, 0 }, /* expansion (2/6). */ - { 0x0000, 0 }, /* expansion (3/6). */ - { 0x0000, 0 }, /* expansion (4/6). */ - { 0x0000, 0 }, /* expansion (5/6). */ - { 0x0000, 0 }, /* expansion (6/6). */ -}; - -static int -skiprr(const u_char *ptr, const u_char *eom, ns_sect section, int count) { - const u_char *optr = ptr; - - for ((void)NULL; count > 0; count--) { - int b, rdlength; - - b = dn_skipname(ptr, eom); - if (b < 0) - goto emsgsize; - ptr += b/*Name*/ + NS_INT16SZ/*Type*/ + NS_INT16SZ/*Class*/; - if (section != ns_s_qd) { - if (ptr + NS_INT32SZ > eom) - goto emsgsize; - ptr += NS_INT32SZ/*TTL*/; - if (ptr + NS_INT16SZ > eom) - goto emsgsize; - NS_GET16(rdlength, ptr); - ptr += rdlength/*RData*/; - } - } - if (ptr > eom) - goto emsgsize; - return (ptr - optr); - emsgsize: - errno = EMSGSIZE; - return (-1); -} - -int -ns_initparse(const u_char *msg, int msglen, ns_msg *handle) { - const u_char *eom = msg + msglen; - int i; - - memset(handle, 0x5e, sizeof *handle); - handle->_msg = msg; - handle->_eom = eom; - if (msg + NS_INT16SZ > eom) - goto emsgsize; - NS_GET16(handle->_id, msg); - if (msg + NS_INT16SZ > eom) - goto emsgsize; - NS_GET16(handle->_flags, msg); - for (i = 0; i < ns_s_max; i++) { - if (msg + NS_INT16SZ > eom) - goto emsgsize; - NS_GET16(handle->_counts[i], msg); - } - for (i = 0; i < ns_s_max; i++) - if (handle->_counts[i] == 0) - handle->_sections[i] = NULL; - else { - int b = skiprr(msg, eom, (ns_sect)i, - handle->_counts[i]); - - if (b < 0) - return (-1); - handle->_sections[i] = msg; - msg += b; - } - if (msg != eom) - goto emsgsize; - handle->_sect = ns_s_max; - handle->_rrnum = -1; - handle->_ptr = NULL; - return (0); - emsgsize: - errno = EMSGSIZE; - return (-1); -} - -int -ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) { - int b; - - /* Make section right. */ - if (section < 0 || section >= ns_s_max) - goto enodev; - if ((int)section != (int)handle->_sect) { - handle->_sect = section; - handle->_rrnum = 0; - handle->_ptr = handle->_sections[(int)section]; - } - - /* Make rrnum right. */ - if (rrnum == -1) - rrnum = handle->_rrnum; - if (rrnum < 0 || rrnum >= handle->_counts[(int)section]) - goto enodev; - if (rrnum < handle->_rrnum) { - handle->_rrnum = 0; - handle->_ptr = handle->_sections[(int)section]; - } - - b = skiprr(handle->_msg, handle->_eom, section, - rrnum - handle->_rrnum); - if (b < 0) - return (-1); - handle->_ptr += b; - handle->_rrnum = rrnum; - - /* Do the parse. */ - b = dn_expand(handle->_msg, handle->_eom, - handle->_ptr, rr->name, NS_MAXDNAME); - if (b < 0) - return (-1); - handle->_ptr += b; - if (handle->_ptr + NS_INT16SZ > handle->_eom) - goto emsgsize; - NS_GET16(rr->type, handle->_ptr); - if (handle->_ptr + NS_INT16SZ > handle->_eom) - goto emsgsize; - NS_GET16(rr->rr_class, handle->_ptr); - if (section == ns_s_qd) { - rr->ttl = 0; - rr->rdlength = 0; - rr->rdata = NULL; - } else { - if (handle->_ptr + NS_INT32SZ > handle->_eom) - goto emsgsize; - NS_GET32(rr->ttl, handle->_ptr); - if (handle->_ptr + NS_INT16SZ > handle->_eom) - goto emsgsize; - NS_GET16(rr->rdlength, handle->_ptr); - if (handle->_ptr + rr->rdlength > handle->_eom) - goto emsgsize; - rr->rdata = handle->_ptr; - handle->_ptr += rr->rdlength; - } - handle->_rrnum++; - - /* All done. */ - return (0); - enodev: - errno = ENODEV; - return (-1); - emsgsize: - errno = EMSGSIZE; - return (-1); -} diff --git a/lib/libc/net/ns_print.c b/lib/libc/net/ns_print.c deleted file mode 100644 index 6be8c80..0000000 --- a/lib/libc/net/ns_print.c +++ /dev/null @@ -1,743 +0,0 @@ -/* - * Copyright (c) 1996, 1998 by Internet Software Consortium. - * - * 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. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM 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. - */ - -#ifndef lint -static char rcsid[] = "$FreeBSD$"; -#endif - -/* Import. */ - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#define SPRINTF(x) ((size_t)sprintf x) - -/* Forward. */ - -static size_t prune_origin(const char *name, const char *origin); -static int charstr(const u_char *rdata, const u_char *edata, - char **buf, size_t *buflen); -static int addname(const u_char *msg, size_t msglen, - const u_char **p, const char *origin, - char **buf, size_t *buflen); -static void addlen(size_t len, char **buf, size_t *buflen); -static int addstr(const char *src, size_t len, - char **buf, size_t *buflen); -static int addtab(size_t len, size_t target, int spaced, - char **buf, size_t *buflen); - -/* Macros. */ - -#define T(x) \ - do { \ - if ((x) < 0) \ - return (-1); \ - } while (0) - -/* Public. */ - -/* - * int - * ns_sprintrr(handle, rr, name_ctx, origin, buf, buflen) - * Convert an RR to presentation format. - * return: - * Number of characters written to buf, or -1 (check errno). - */ -int -ns_sprintrr(const ns_msg *handle, const ns_rr *rr, - const char *name_ctx, const char *origin, - char *buf, size_t buflen) -{ - int n; - - n = ns_sprintrrf(ns_msg_base(*handle), ns_msg_size(*handle), - ns_rr_name(*rr), ns_rr_class(*rr), ns_rr_type(*rr), - ns_rr_ttl(*rr), ns_rr_rdata(*rr), ns_rr_rdlen(*rr), - name_ctx, origin, buf, buflen); - return (n); -} - -/* - * int - * ns_sprintrrf(msg, msglen, name, class, type, ttl, rdata, rdlen, - * name_ctx, origin, buf, buflen) - * Convert the fields of an RR into presentation format. - * return: - * Number of characters written to buf, or -1 (check errno). - */ -int -ns_sprintrrf(const u_char *msg, size_t msglen, - const char *name, ns_class class, ns_type type, - u_long ttl, const u_char *rdata, size_t rdlen, - const char *name_ctx, const char *origin, - char *buf, size_t buflen) -{ - const char *obuf = buf; - const u_char *edata = rdata + rdlen; - int spaced = 0; - - const char *comment; - char tmp[100]; - int len, x; - - /* - * Owner. - */ - if (name_ctx != NULL && strcasecmp(name_ctx, name) == 0) { - T(addstr("\t\t\t", 3, &buf, &buflen)); - } else { - len = prune_origin(name, origin); - if (len == 0) { - T(addstr("@\t\t\t", 4, &buf, &buflen)); - } else { - T(addstr(name, len, &buf, &buflen)); - /* Origin not used and no trailing dot? */ - if ((!origin || !origin[0] || name[len] == '\0') && - name[len - 1] != '.') { - T(addstr(".", 1, &buf, &buflen)); - len++; - } - T(spaced = addtab(len, 24, spaced, &buf, &buflen)); - } - } - - /* - * TTL, Class, Type. - */ - T(x = ns_format_ttl(ttl, buf, buflen)); - addlen(x, &buf, &buflen); - len = SPRINTF((tmp, " %s %s", p_class(class), p_type(type))); - T(addstr(tmp, len, &buf, &buflen)); - T(spaced = addtab(x + len, 16, spaced, &buf, &buflen)); - - /* - * RData. - */ - switch (type) { - case ns_t_a: - if (rdlen != NS_INADDRSZ) - goto formerr; - (void) inet_ntop(AF_INET, rdata, buf, buflen); - addlen(strlen(buf), &buf, &buflen); - break; - - case ns_t_cname: - case ns_t_mb: - case ns_t_mg: - case ns_t_mr: - case ns_t_ns: - case ns_t_ptr: - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - break; - - case ns_t_hinfo: - case ns_t_isdn: - /* First word. */ - T(len = charstr(rdata, edata, &buf, &buflen)); - if (len == 0) - goto formerr; - rdata += len; - T(addstr(" ", 1, &buf, &buflen)); - - /* Second word. */ - T(len = charstr(rdata, edata, &buf, &buflen)); - if (len == 0) - goto formerr; - rdata += len; - break; - - case ns_t_soa: { - u_long t; - - /* Server name. */ - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - T(addstr(" ", 1, &buf, &buflen)); - - /* Administrator name. */ - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - T(addstr(" (\n", 3, &buf, &buflen)); - spaced = 0; - - if ((edata - rdata) != 5*NS_INT32SZ) - goto formerr; - - /* Serial number. */ - t = ns_get32(rdata); rdata += NS_INT32SZ; - T(addstr("\t\t\t\t\t", 5, &buf, &buflen)); - len = SPRINTF((tmp, "%lu", t)); - T(addstr(tmp, len, &buf, &buflen)); - T(spaced = addtab(len, 16, spaced, &buf, &buflen)); - T(addstr("; serial\n", 9, &buf, &buflen)); - spaced = 0; - - /* Refresh interval. */ - t = ns_get32(rdata); rdata += NS_INT32SZ; - T(addstr("\t\t\t\t\t", 5, &buf, &buflen)); - T(len = ns_format_ttl(t, buf, buflen)); - addlen(len, &buf, &buflen); - T(spaced = addtab(len, 16, spaced, &buf, &buflen)); - T(addstr("; refresh\n", 10, &buf, &buflen)); - spaced = 0; - - /* Retry interval. */ - t = ns_get32(rdata); rdata += NS_INT32SZ; - T(addstr("\t\t\t\t\t", 5, &buf, &buflen)); - T(len = ns_format_ttl(t, buf, buflen)); - addlen(len, &buf, &buflen); - T(spaced = addtab(len, 16, spaced, &buf, &buflen)); - T(addstr("; retry\n", 8, &buf, &buflen)); - spaced = 0; - - /* Expiry. */ - t = ns_get32(rdata); rdata += NS_INT32SZ; - T(addstr("\t\t\t\t\t", 5, &buf, &buflen)); - T(len = ns_format_ttl(t, buf, buflen)); - addlen(len, &buf, &buflen); - T(spaced = addtab(len, 16, spaced, &buf, &buflen)); - T(addstr("; expiry\n", 9, &buf, &buflen)); - spaced = 0; - - /* Minimum TTL. */ - t = ns_get32(rdata); rdata += NS_INT32SZ; - T(addstr("\t\t\t\t\t", 5, &buf, &buflen)); - T(len = ns_format_ttl(t, buf, buflen)); - addlen(len, &buf, &buflen); - T(addstr(" )", 2, &buf, &buflen)); - T(spaced = addtab(len, 16, spaced, &buf, &buflen)); - T(addstr("; minimum\n", 10, &buf, &buflen)); - - break; - } - - case ns_t_mx: - case ns_t_afsdb: - case ns_t_rt: { - u_int t; - - if (rdlen < NS_INT16SZ) - goto formerr; - - /* Priority. */ - t = ns_get16(rdata); - rdata += NS_INT16SZ; - len = SPRINTF((tmp, "%u ", t)); - T(addstr(tmp, len, &buf, &buflen)); - - /* Target. */ - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - - break; - } - - case ns_t_px: { - u_int t; - - if (rdlen < NS_INT16SZ) - goto formerr; - - /* Priority. */ - t = ns_get16(rdata); - rdata += NS_INT16SZ; - len = SPRINTF((tmp, "%u ", t)); - T(addstr(tmp, len, &buf, &buflen)); - - /* Name1. */ - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - T(addstr(" ", 1, &buf, &buflen)); - - /* Name2. */ - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - - break; - } - - case ns_t_x25: - T(len = charstr(rdata, edata, &buf, &buflen)); - if (len == 0) - goto formerr; - rdata += len; - break; - - case ns_t_txt: - while (rdata < edata) { - T(len = charstr(rdata, edata, &buf, &buflen)); - if (len == 0) - goto formerr; - rdata += len; - if (rdata < edata) - T(addstr(" ", 1, &buf, &buflen)); - } - break; - - case ns_t_nsap: { - char t[255*3]; - - (void) inet_nsap_ntoa(rdlen, rdata, t); - T(addstr(t, strlen(t), &buf, &buflen)); - break; - } - - case ns_t_aaaa: - if (rdlen != NS_IN6ADDRSZ) - goto formerr; - (void) inet_ntop(AF_INET6, rdata, buf, buflen); - addlen(strlen(buf), &buf, &buflen); - break; - - case ns_t_loc: { - char t[255]; - - /* XXX protocol format checking? */ - (void) loc_ntoa(rdata, t); - T(addstr(t, strlen(t), &buf, &buflen)); - break; - } - - case ns_t_naptr: { - u_int order, preference; - char t[50]; - - if (rdlen < 2*NS_INT16SZ) - goto formerr; - - /* Order, Precedence. */ - order = ns_get16(rdata); rdata += NS_INT16SZ; - preference = ns_get16(rdata); rdata += NS_INT16SZ; - len = SPRINTF((t, "%u %u ", order, preference)); - T(addstr(t, len, &buf, &buflen)); - - /* Flags. */ - T(len = charstr(rdata, edata, &buf, &buflen)); - if (len == 0) - goto formerr; - rdata += len; - T(addstr(" ", 1, &buf, &buflen)); - - /* Service. */ - T(len = charstr(rdata, edata, &buf, &buflen)); - if (len == 0) - goto formerr; - rdata += len; - T(addstr(" ", 1, &buf, &buflen)); - - /* Regexp. */ - T(len = charstr(rdata, edata, &buf, &buflen)); - if (len < 0) - return (-1); - if (len == 0) - goto formerr; - rdata += len; - T(addstr(" ", 1, &buf, &buflen)); - - /* Server. */ - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - break; - } - - case ns_t_srv: { - u_int priority, weight, port; - char t[50]; - - if (rdlen < NS_INT16SZ*3) - goto formerr; - - /* Priority, Weight, Port. */ - priority = ns_get16(rdata); rdata += NS_INT16SZ; - weight = ns_get16(rdata); rdata += NS_INT16SZ; - port = ns_get16(rdata); rdata += NS_INT16SZ; - len = SPRINTF((t, "%u %u %u ", priority, weight, port)); - T(addstr(t, len, &buf, &buflen)); - - /* Server. */ - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - break; - } - - case ns_t_minfo: - case ns_t_rp: - /* Name1. */ - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - T(addstr(" ", 1, &buf, &buflen)); - - /* Name2. */ - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - - break; - - case ns_t_wks: { - int n, lcnt; - - if (rdlen < NS_INT32SZ + 1) - goto formerr; - - /* Address. */ - (void) inet_ntop(AF_INET, rdata, buf, buflen); - addlen(strlen(buf), &buf, &buflen); - rdata += NS_INADDRSZ; - - /* Protocol. */ - len = SPRINTF((tmp, " %u ( ", *rdata)); - T(addstr(tmp, len, &buf, &buflen)); - rdata += NS_INT8SZ; - - /* Bit map. */ - n = 0; - lcnt = 0; - while (rdata < edata) { - u_int c = *rdata++; - do { - if (c & 0200) { - if (lcnt == 0) { - T(addstr("\n\t\t\t\t", 5, - &buf, &buflen)); - lcnt = 10; - spaced = 0; - } - len = SPRINTF((tmp, "%d ", n)); - T(addstr(tmp, len, &buf, &buflen)); - lcnt--; - } - c <<= 1; - } while (++n & 07); - } - T(addstr(")", 1, &buf, &buflen)); - - break; - } - - case ns_t_key: { - char base64_key[NS_MD5RSA_MAX_BASE64]; - u_int keyflags, protocol, algorithm; - const char *leader; - int n; - - if (rdlen < NS_INT16SZ + NS_INT8SZ + NS_INT8SZ) - goto formerr; - - /* Key flags, Protocol, Algorithm. */ - keyflags = ns_get16(rdata); rdata += NS_INT16SZ; - protocol = *rdata++; - algorithm = *rdata++; - len = SPRINTF((tmp, "0x%04x %u %u", - keyflags, protocol, algorithm)); - T(addstr(tmp, len, &buf, &buflen)); - - /* Public key data. */ - len = b64_ntop(rdata, edata - rdata, - base64_key, sizeof base64_key); - if (len < 0) - goto formerr; - if (len > 15) { - T(addstr(" (", 2, &buf, &buflen)); - leader = "\n\t\t"; - spaced = 0; - } else - leader = " "; - for (n = 0; n < len; n += 48) { - T(addstr(leader, strlen(leader), &buf, &buflen)); - T(addstr(base64_key + n, MIN(len - n, 48), - &buf, &buflen)); - } - if (len > 15) - T(addstr(" )", 2, &buf, &buflen)); - - break; - } - - case ns_t_sig: { - char base64_key[NS_MD5RSA_MAX_BASE64]; - u_int type, algorithm, labels, footprint; - const char *leader; - u_long t; - int n; - - if (rdlen < 22) - goto formerr; - - /* Type covered, Algorithm, Label count, Original TTL. */ - type = ns_get16(rdata); rdata += NS_INT16SZ; - algorithm = *rdata++; - labels = *rdata++; - t = ns_get32(rdata); rdata += NS_INT32SZ; - len = SPRINTF((tmp, " %s %d %lu ", - p_type(type), algorithm, t)); - T(addstr(tmp, len, &buf, &buflen)); - if (labels != (u_int)dn_count_labels(name)) - goto formerr; - - /* Signature expiry. */ - t = ns_get32(rdata); rdata += NS_INT32SZ; - len = SPRINTF((tmp, "%s ", p_secstodate(t))); - T(addstr(tmp, len, &buf, &buflen)); - - /* Time signed. */ - t = ns_get32(rdata); rdata += NS_INT32SZ; - len = SPRINTF((tmp, "%s ", p_secstodate(t))); - T(addstr(tmp, len, &buf, &buflen)); - - /* Signature Footprint. */ - footprint = ns_get16(rdata); rdata += NS_INT16SZ; - len = SPRINTF((tmp, "%u ", footprint)); - T(addstr(tmp, len, &buf, &buflen)); - - /* Signer's name. */ - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - - /* Signature. */ - len = b64_ntop(rdata, edata - rdata, - base64_key, sizeof base64_key); - if (len > 15) { - T(addstr(" (", 2, &buf, &buflen)); - leader = "\n\t\t"; - spaced = 0; - } else - leader = " "; - if (len < 0) - goto formerr; - for (n = 0; n < len; n += 48) { - T(addstr(leader, strlen(leader), &buf, &buflen)); - T(addstr(base64_key + n, MIN(len - n, 48), - &buf, &buflen)); - } - if (len > 15) - T(addstr(" )", 2, &buf, &buflen)); - - break; - } - - case ns_t_nxt: { - int n, c; - - /* Next domain name. */ - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - - /* Type bit map. */ - n = edata - rdata; - for (c = 0; c < n*8; c++) - if (NS_NXT_BIT_ISSET(c, rdata)) { - len = SPRINTF((tmp, " %s", p_type(c))); - T(addstr(tmp, len, &buf, &buflen)); - } - break; - } - - default: - comment = "unknown RR type"; - goto hexify; - } - return (buf - obuf); - formerr: - comment = "RR format error"; - hexify: { - int n, m; - char *p; - - len = SPRINTF((tmp, "\\#(\t\t; %s", comment)); - T(addstr(tmp, len, &buf, &buflen)); - while (rdata < edata) { - p = tmp; - p += SPRINTF((p, "\n\t")); - spaced = 0; - n = MIN(16, edata - rdata); - for (m = 0; m < n; m++) - p += SPRINTF((p, "%02x ", rdata[m])); - T(addstr(tmp, p - tmp, &buf, &buflen)); - if (n < 16) { - T(addstr(")", 1, &buf, &buflen)); - T(addtab(p - tmp + 1, 48, spaced, &buf, &buflen)); - } - p = tmp; - p += SPRINTF((p, "; ")); - for (m = 0; m < n; m++) - *p++ = (isascii(rdata[m]) && isprint(rdata[m])) - ? rdata[m] - : '.'; - T(addstr(tmp, p - tmp, &buf, &buflen)); - rdata += n; - } - return (buf - obuf); - } -} - -/* Private. */ - -/* - * size_t - * prune_origin(name, origin) - * Find out if the name is at or under the current origin. - * return: - * Number of characters in name before start of origin, - * or length of name if origin does not match. - * notes: - * This function should share code with samedomain(). - */ -static size_t -prune_origin(const char *name, const char *origin) { - const char *oname = name; - - while (*name != '\0') { - if (origin != NULL && strcasecmp(name, origin) == 0) - return (name - oname - (name > oname)); - while (*name != '\0') { - if (*name == '\\') { - name++; - /* XXX need to handle \nnn form. */ - if (*name == '\0') - break; - } else if (*name == '.') { - name++; - break; - } - name++; - } - } - return (name - oname); -} - -/* - * int - * charstr(rdata, edata, buf, buflen) - * Format a into the presentation buffer. - * return: - * Number of rdata octets consumed - * 0 for protocol format error - * -1 for output buffer error - * side effects: - * buffer is advanced on success. - */ -static int -charstr(const u_char *rdata, const u_char *edata, char **buf, size_t *buflen) { - const u_char *odata = rdata; - size_t save_buflen = *buflen; - char *save_buf = *buf; - - if (addstr("\"", 1, buf, buflen) < 0) - goto enospc; - if (rdata < edata) { - int n = *rdata; - - if (rdata + 1 + n <= edata) { - rdata++; - while (n-- > 0) { - if (strchr("\n\"\\", *rdata) != NULL) - if (addstr("\\", 1, buf, buflen) < 0) - goto enospc; - if (addstr((const char *)rdata, 1, - buf, buflen) < 0) - goto enospc; - rdata++; - } - } - } - if (addstr("\"", 1, buf, buflen) < 0) - goto enospc; - return (rdata - odata); - enospc: - errno = ENOSPC; - *buf = save_buf; - *buflen = save_buflen; - return (-1); -} - -static int -addname(const u_char *msg, size_t msglen, - const u_char **pp, const char *origin, - char **buf, size_t *buflen) -{ - size_t newlen, save_buflen = *buflen; - char *save_buf = *buf; - int n; - - n = dn_expand(msg, msg + msglen, *pp, *buf, *buflen); - if (n < 0) - goto enospc; /* Guess. */ - newlen = prune_origin(*buf, origin); - if ((origin == NULL || origin[0] == '\0' || (*buf)[newlen] == '\0') && - (newlen == 0 || (*buf)[newlen - 1] != '.')) { - /* No trailing dot. */ - if (newlen + 2 > *buflen) - goto enospc; /* No room for ".\0". */ - (*buf)[newlen++] = '.'; - (*buf)[newlen] = '\0'; - } - if (newlen == 0) { - /* Use "@" instead of name. */ - if (newlen + 2 > *buflen) - goto enospc; /* No room for "@\0". */ - (*buf)[newlen++] = '@'; - (*buf)[newlen] = '\0'; - } - *pp += n; - addlen(newlen, buf, buflen); - **buf = '\0'; - return (newlen); - enospc: - errno = ENOSPC; - *buf = save_buf; - *buflen = save_buflen; - return (-1); -} - -static void -addlen(size_t len, char **buf, size_t *buflen) { - assert(len <= *buflen); - *buf += len; - *buflen -= len; -} - -static int -addstr(const char *src, size_t len, char **buf, size_t *buflen) { - if (len > *buflen) { - errno = ENOSPC; - return (-1); - } - memcpy(*buf, src, len); - addlen(len, buf, buflen); - **buf = '\0'; - return (0); -} - -static int -addtab(size_t len, size_t target, int spaced, char **buf, size_t *buflen) { - size_t save_buflen = *buflen; - char *save_buf = *buf; - int t; - - if (spaced || len >= target - 1) { - T(addstr(" ", 2, buf, buflen)); - spaced = 1; - } else { - for (t = (target - len - 1) / 8; t >= 0; t--) - if (addstr("\t", 1, buf, buflen) < 0) { - *buflen = save_buflen; - *buf = save_buf; - return (-1); - } - spaced = 0; - } - return (spaced); -} diff --git a/lib/libc/net/ns_ttl.c b/lib/libc/net/ns_ttl.c deleted file mode 100644 index 3327d86..0000000 --- a/lib/libc/net/ns_ttl.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 1996 by Internet Software Consortium. - * - * 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. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM 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. - */ - -#ifndef lint -static char rcsid[] = "$FreeBSD$"; -#endif - -/* Import. */ - -#include - -#include -#include -#include -#include - -#define SPRINTF(x) ((size_t)sprintf x) - -/* Forward. */ - -static int fmt1(int t, char s, char **buf, size_t *buflen); - -/* Macros. */ - -#define T(x) if ((x) < 0) return (-1); else (void)NULL - -/* Public. */ - -int -ns_format_ttl(u_long src, char *dst, size_t dstlen) { - char *odst = dst; - int secs, mins, hours, days, weeks, x; - char tmp[50], *p; - - secs = src % 60; src /= 60; - mins = src % 60; src /= 60; - hours = src % 24; src /= 24; - days = src % 7; src /= 7; - weeks = src; src = 0; - - x = 0; - if (weeks) { - T(fmt1(weeks, 'W', &dst, &dstlen)); - x++; - } - if (days) { - T(fmt1(days, 'D', &dst, &dstlen)); - x++; - } - if (hours) { - T(fmt1(hours, 'H', &dst, &dstlen)); - x++; - } - if (mins) { - T(fmt1(mins, 'M', &dst, &dstlen)); - x++; - } - if (secs || !(weeks || days || hours || mins)) { - T(fmt1(secs, 'S', &dst, &dstlen)); - x++; - } - - if (x > 1) { - int ch; - - for (p = odst; (ch = *p) != '\0'; p++) - if (isascii(ch) && isupper(ch)) - *p = tolower(ch); - } - - return (dst - odst); -} - -int -ns_parse_ttl(const char *src, u_long *dst) { - u_long ttl, tmp; - int ch, digits, dirty; - - ttl = 0; - tmp = 0; - digits = 0; - dirty = 0; - while ((ch = *src++) != '\0') { - if (!isascii(ch) || !isprint(ch)) - goto einval; - if (isdigit(ch)) { - tmp *= 10; - tmp += (ch - '0'); - digits++; - continue; - } - if (digits == 0) - goto einval; - if (islower(ch)) - ch = toupper(ch); - switch (ch) { - case 'W': tmp *= 7; - case 'D': tmp *= 24; - case 'H': tmp *= 60; - case 'M': tmp *= 60; - case 'S': break; - default: goto einval; - } - ttl += tmp; - tmp = 0; - digits = 0; - dirty = 1; - } - if (digits > 0) { - if (dirty) - goto einval; - else - ttl += tmp; - } - *dst = ttl; - return (0); - - einval: - errno = EINVAL; - return (-1); -} - -/* Private. */ - -static int -fmt1(int t, char s, char **buf, size_t *buflen) { - char tmp[50]; - size_t len; - - len = SPRINTF((tmp, "%d%c", t, s)); - if (len + 1 > *buflen) - return (-1); - strcpy(*buf, tmp); - *buf += len; - *buflen -= len; - return (0); -} diff --git a/lib/libc/net/nsap_addr.c b/lib/libc/net/nsap_addr.c deleted file mode 100644 index 1f16fd2..0000000 --- a/lib/libc/net/nsap_addr.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 1996, 1998 by Internet Software Consortium. - * - * 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. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM 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 rcsid[] = "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include - -static char -xtob(c) - register int c; -{ - return (c - (((c >= '0') && (c <= '9')) ? '0' : '7')); -} - -u_int -inet_nsap_addr(ascii, binary, maxlen) - const char *ascii; - u_char *binary; - int maxlen; -{ - u_char c, nib; - u_int len = 0; - - while ((c = *ascii++) != '\0' && len < (u_int)maxlen) { - if (c == '.' || c == '+' || c == '/') - continue; - if (!isascii(c)) - return (0); - if (islower(c)) - c = toupper(c); - if (isxdigit(c)) { - nib = xtob(c); - c = *ascii++; - if (c != '\0') { - c = toupper(c); - if (isxdigit(c)) { - *binary++ = (nib << 4) | xtob(c); - len++; - } else - return (0); - } - else - return (0); - } - else - return (0); - } - return (len); -} - -char * -inet_nsap_ntoa(binlen, binary, ascii) - int binlen; - register const u_char *binary; - register char *ascii; -{ - register int nib; - int i; - static char tmpbuf[255*3]; - char *start; - - if (ascii) - start = ascii; - else { - ascii = tmpbuf; - start = tmpbuf; - } - - if (binlen > 255) - binlen = 255; - - for (i = 0; i < binlen; i++) { - nib = *binary >> 4; - *ascii++ = nib + (nib < 10 ? '0' : '7'); - nib = *binary++ & 0x0f; - *ascii++ = nib + (nib < 10 ? '0' : '7'); - if (((i % 2) == 0 && (i + 1) < binlen)) - *ascii++ = '.'; - } - *ascii = '\0'; - return (start); -} - -/* - * Weak aliases for applications that use certain private entry points, - * and fail to include . - */ -#undef inet_nsap_addr -__weak_reference(__inet_nsap_addr, inet_nsap_addr); -#undef inet_nsap_ntoa -__weak_reference(__inet_nsap_ntoa, inet_nsap_ntoa); diff --git a/lib/libc/net/rcmd.3 b/lib/libc/net/rcmd.3 deleted file mode 100644 index c16cddf..0000000 --- a/lib/libc/net/rcmd.3 +++ /dev/null @@ -1,293 +0,0 @@ -.\" Copyright (c) 1983, 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. -.\" -.\" From: @(#)rcmd.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd March 3, 2000 -.Dt RCMD 3 -.Os BSD 4.2 -.Sh NAME -.Nm rcmd , -.Nm rresvport , -.Nm iruserok , -.Nm ruserok , -.Nm rcmd_af , -.Nm rresvport_af , -.Nm iruserok_sa -.Nd routines for returning a stream to a remote command -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn rcmd "char **ahost" "int inport" "const char *locuser" "const char *remuser" "const char *cmd" "int *fd2p" -.Ft int -.Fn rresvport "int *port" -.Ft int -.Fn iruserok "u_long raddr" "int superuser" "const char *ruser" "const char *luser" -.Ft int -.Fn ruserok "const char *rhost" "int superuser" "const char *ruser" "const char *luser" -.Ft int -.Fn rcmd_af "char **ahost" "int inport" "const char *locuser" "const char *remuser" "const char *cmd" "int *fd2p" "int af" -.Ft int -.Fn rresvport_af "int *port" "int af" -.Ft int -.Fn iruserok_sa "const void *addr" "int addrlen" "int superuser" "const char *ruser" "const char *luser" -.Sh DESCRIPTION -The -.Fn rcmd -function -is used by the super-user to execute a command on -a remote machine using an authentication scheme based -on reserved port numbers. -The -.Fn rresvport -function -returns a descriptor to a socket -with an address in the privileged port space. -The -.Fn ruserok -function -is used by servers -to authenticate clients requesting service with -.Fn rcmd . -All three functions are present in the same file and are used -by the -.Xr rshd 8 -server (among others). -.Pp -The -.Fn rcmd -function -looks up the host -.Fa *ahost -using -.Xr gethostbyname 3 , -returning -1 if the host does not exist. -Otherwise -.Fa *ahost -is set to the standard name of the host -and a connection is established to a server -residing at the well-known Internet port -.Fa inport . -.Pp -If the connection succeeds, -a socket in the Internet domain of type -.Dv SOCK_STREAM -is returned to the caller, and given to the remote -command as -.Em stdin -and -.Em stdout . -If -.Fa fd2p -is non-zero, then an auxiliary channel to a control -process will be set up, and a descriptor for it will be placed -in -.Fa *fd2p . -The control process will return diagnostic -output from the command (unit 2) on this channel, and will also -accept bytes on this channel as being -.Tn UNIX -signal numbers, to be -forwarded to the process group of the command. -If -.Fa fd2p -is 0, then the -.Em stderr -(unit 2 of the remote -command) will be made the same as the -.Em stdout -and no -provision is made for sending arbitrary signals to the remote process, -although you may be able to get its attention by using out-of-band data. -.Pp -The protocol is described in detail in -.Xr rshd 8 . -.Pp -The -.Fn rresvport -function is used to obtain a socket to which an address with a Privileged -Internet port is bound. -This socket is suitable for use by -.Fn rcmd -and several other functions. -Privileged Internet ports are those in the range 0 to 1023. -Only the super-user is allowed to bind an address of this sort -to a socket. -.Pp -The -.Fn iruserok -and -.Fn ruserok -functions take a remote host's IP address or name, as returned by the -.Xr gethostbyname 3 -routines, two user names and a flag indicating whether the local user's -name is that of the super-user. -Then, if the user is -.Em NOT -the super-user, it checks the -.Pa /etc/hosts.equiv -file. -If that lookup is not done, or is unsuccessful, the -.Pa .rhosts -in the local user's home directory is checked to see if the request for -service is allowed. -.Pp -If this file does not exist, is not a regular file, is owned by anyone -other than the user or the super-user, or is writable by anyone other -than the owner, the check automatically fails. -Zero is returned if the machine name is listed in the -.Dq Pa hosts.equiv -file, or the host and remote user name are found in the -.Dq Pa .rhosts -file; otherwise -.Fn iruserok -and -.Fn ruserok -return -1. -If the local domain (as obtained from -.Xr gethostname 3 ) -is the same as the remote domain, only the machine name need be specified. -.Pp -The -.Fn iruserok -function is strongly preferred for security reasons. -It requires trusting the local DNS at most, while the -.Fn ruserok -function requires trusting the entire DNS, which can be spoofed. -.Pp -The functions with an -.Dq Li _af -or -.Dq Li _sa -suffix, i.e., -.Fn rcmd_af , -.Fn rresvport_af -and -.Fn iruserok_sa , -work the same as the corresponding functions without a -suffix, except that they are capable of handling both IPv6 and IPv4 ports. -.Pp -The -.Dq Li _af -suffix means that the function has an additional -.Fa af -argument which is used to specify the address family, -(see below). -The -.Fa af -argument extension is implemented for functions -that have no binary address argument. -Instead, the -.Fa af -argument specifies which address family is desired. -.Pp -The -.Dq Li _sa -suffix means that the function has general socket address and -length arguments. -As the socket address is a protocol independent data structure, -IPv4 and IPv6 socket address can be passed as desired. -The -.Fa sa -argument extension is implemented for functions -that pass a protocol dependent binary address argument. -The argument needs to be replaced with a more general address structure -to support multiple address families in a general way. -.Pp -The functions with neither an -.Dq Li _af -suffix nor an -.Dq Li _sa -suffix work for IPv4 only, except for -.Fn ruserok -which can handle both IPv6 and IPv4. -To switch the address family, the -.Fa af -argument must be filled with -.Dv AF_INET , -or -.Dv AF_INET6 . -For -.Fn rcmd_af , -.Dv PF_UNSPEC -is also allowed. -.Sh DIAGNOSTICS -The -.Fn rcmd -function -returns a valid socket descriptor on success. -It returns -1 on error and prints a diagnostic message -on the standard error. -.Pp -The -.Fn rresvport -function -returns a valid, bound socket descriptor on success. -It returns -1 on error with the global value -.Va errno -set according to the reason for failure. -The error code -.Dv EAGAIN -is overloaded to mean ``All network ports in use.'' -.Sh SEE ALSO -.Xr rlogin 1 , -.Xr rsh 1 , -.Xr intro 2 , -.Xr rexec 3 , -.Xr rexecd 8 , -.Xr rlogind 8 , -.Xr rshd 8 -.Pp -.Rs -.%A W. Stevens and M. Thomas -.%T "Advanced Socket API for IPv6" -.%O RFC2292 -.Re -.Rs -.%A W. Stevens, M. Thomas and E. Nordmark -.%T "Advanced Socket API for IPv6" -.%O draft-ietf-ipngwg-rfc2292bis-01.txt -.Re -.Sh HISTORY -Most of these -functions appeared in -.Bx 4.2 . -.Fn rresvport_af -appeared in RFC2292, and was implemented by the WIDE project -for the Hydrangea IPv6 protocol stack kit. -.Fn rcmd_af -appeared in draft-ietf-ipngwg-rfc2292bis-01.txt, -and was implemented in the WIDE/KAME IPv6 protocol stack kit. -.Fn iruserok_sa -appeared in discussion on the IETF ipngwg mailing list, -and was implemented in -.Fx 4.0 . diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c deleted file mode 100644 index 5bbef4b..0000000 --- a/lib/libc/net/rcmd.c +++ /dev/null @@ -1,693 +0,0 @@ -/* - * Copyright (c) 1983, 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. - * - * $FreeBSD$ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef YP -#include -#include -#include -#endif - -/* wrapper for KAME-special getnameinfo() */ -#ifndef NI_WITHSCOPEID -#define NI_WITHSCOPEID 0 -#endif - -extern int innetgr __P(( const char *, const char *, const char *, const char * )); - -#define max(a, b) ((a > b) ? a : b) - -static int __iruserok_af __P((void *, int, const char *, const char *, int)); -int __ivaliduser __P((FILE *, u_int32_t, const char *, const char *)); -static int __icheckhost __P((void *, char *, int, int)); - -char paddr[INET6_ADDRSTRLEN]; - -int -rcmd(ahost, rport, locuser, remuser, cmd, fd2p) - char **ahost; - u_short rport; - const char *locuser, *remuser, *cmd; - int *fd2p; -{ - return rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, AF_INET); -} - -int -rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) - char **ahost; - u_short rport; - const char *locuser, *remuser, *cmd; - int *fd2p; - int af; -{ - struct addrinfo hints, *res, *ai; - struct sockaddr_storage from; - fd_set reads; - long oldmask; - pid_t pid; - int s, aport, lport, timo, error; - char c; - int refused; - char num[8]; - - pid = getpid(); - - memset(&hints, 0, sizeof(hints)); - hints.ai_flags = AI_CANONNAME; - hints.ai_family = af; - hints.ai_socktype = SOCK_STREAM; - hints.ai_protocol = 0; - (void)snprintf(num, sizeof(num), "%d", ntohs(rport)); - error = getaddrinfo(*ahost, num, &hints, &res); - if (error) { - fprintf(stderr, "rcmd: getaddrinfo: %s\n", - gai_strerror(error)); - if (error == EAI_SYSTEM) - fprintf(stderr, "rcmd: getaddrinfo: %s\n", - strerror(errno)); - return (-1); - } - if (res->ai_canonname) - *ahost = res->ai_canonname; - ai = res; - refused = 0; - oldmask = sigblock(sigmask(SIGURG)); - for (timo = 1, lport = IPPORT_RESERVED - 1;;) { - s = rresvport_af(&lport, ai->ai_family); - if (s < 0) { - if (errno != EAGAIN && ai->ai_next) { - ai = ai->ai_next; - continue; - } - if (errno == EAGAIN) - (void)fprintf(stderr, - "rcmd: socket: All ports in use\n"); - else - (void)fprintf(stderr, "rcmd: socket: %s\n", - strerror(errno)); - freeaddrinfo(res); - sigsetmask(oldmask); - return (-1); - } - _fcntl(s, F_SETOWN, pid); - if (connect(s, ai->ai_addr, ai->ai_addrlen) >= 0) - break; - (void)_close(s); - if (errno == EADDRINUSE) { - lport--; - continue; - } - if (errno == ECONNREFUSED) - refused = 1; - if (ai->ai_next != NULL) { - int oerrno = errno; - - getnameinfo(ai->ai_addr, ai->ai_addrlen, - paddr, sizeof(paddr), - NULL, 0, - NI_NUMERICHOST|NI_WITHSCOPEID); - (void)fprintf(stderr, "connect to address %s: ", - paddr); - errno = oerrno; - perror(0); - ai = ai->ai_next; - getnameinfo(ai->ai_addr, ai->ai_addrlen, - paddr, sizeof(paddr), - NULL, 0, - NI_NUMERICHOST|NI_WITHSCOPEID); - fprintf(stderr, "Trying %s...\n", paddr); - continue; - } - if (refused && timo <= 16) { - struct timespec time_to_sleep, time_remaining; - - time_to_sleep.tv_sec = timo; - time_to_sleep.tv_nsec = 0; - (void)_nanosleep(&time_to_sleep, &time_remaining); - - timo *= 2; - ai = res; - refused = 0; - continue; - } - freeaddrinfo(res); - (void)fprintf(stderr, "%s: %s\n", *ahost, strerror(errno)); - sigsetmask(oldmask); - return (-1); - } - lport--; - if (fd2p == 0) { - _write(s, "", 1); - lport = 0; - } else { - char num[8]; - int s2 = rresvport_af(&lport, ai->ai_family), s3; - int len = ai->ai_addrlen; - int nfds; - - if (s2 < 0) - goto bad; - listen(s2, 1); - (void)snprintf(num, sizeof(num), "%d", lport); - if (_write(s, num, strlen(num)+1) != strlen(num)+1) { - (void)fprintf(stderr, - "rcmd: write (setting up stderr): %s\n", - strerror(errno)); - (void)_close(s2); - goto bad; - } - nfds = max(s, s2)+1; - if(nfds > FD_SETSIZE) { - fprintf(stderr, "rcmd: too many files\n"); - (void)_close(s2); - goto bad; - } -again: - FD_ZERO(&reads); - FD_SET(s, &reads); - FD_SET(s2, &reads); - errno = 0; - if (select(nfds, &reads, 0, 0, 0) < 1 || !FD_ISSET(s2, &reads)){ - if (errno != 0) - (void)fprintf(stderr, - "rcmd: select (setting up stderr): %s\n", - strerror(errno)); - else - (void)fprintf(stderr, - "select: protocol failure in circuit setup\n"); - (void)_close(s2); - goto bad; - } - s3 = accept(s2, (struct sockaddr *)&from, &len); - switch (from.ss_family) { - case AF_INET: - aport = ntohs(((struct sockaddr_in *)&from)->sin_port); - break; -#ifdef INET6 - case AF_INET6: - aport = ntohs(((struct sockaddr_in6 *)&from)->sin6_port); - break; -#endif - default: - aport = 0; /* error */ - break; - } - /* - * XXX careful for ftp bounce attacks. If discovered, shut them - * down and check for the real auxiliary channel to connect. - */ - if (aport == 20) { - _close(s3); - goto again; - } - (void)_close(s2); - if (s3 < 0) { - (void)fprintf(stderr, - "rcmd: accept: %s\n", strerror(errno)); - lport = 0; - goto bad; - } - *fd2p = s3; - if (aport >= IPPORT_RESERVED || aport < IPPORT_RESERVED / 2) { - (void)fprintf(stderr, - "socket: protocol failure in circuit setup.\n"); - goto bad2; - } - } - (void)_write(s, locuser, strlen(locuser)+1); - (void)_write(s, remuser, strlen(remuser)+1); - (void)_write(s, cmd, strlen(cmd)+1); - if (_read(s, &c, 1) != 1) { - (void)fprintf(stderr, - "rcmd: %s: %s\n", *ahost, strerror(errno)); - goto bad2; - } - if (c != 0) { - while (_read(s, &c, 1) == 1) { - (void)_write(STDERR_FILENO, &c, 1); - if (c == '\n') - break; - } - goto bad2; - } - sigsetmask(oldmask); - freeaddrinfo(res); - return (s); -bad2: - if (lport) - (void)_close(*fd2p); -bad: - (void)_close(s); - sigsetmask(oldmask); - freeaddrinfo(res); - return (-1); -} - -int -rresvport(port) - int *port; -{ - return rresvport_af(port, AF_INET); -} - -int -rresvport_af(alport, family) - int *alport, family; -{ - int i, s, len, err; - struct sockaddr_storage ss; - u_short *sport; - - memset(&ss, 0, sizeof(ss)); - ss.ss_family = family; - switch (family) { - case AF_INET: - ((struct sockaddr *)&ss)->sa_len = sizeof(struct sockaddr_in); - sport = &((struct sockaddr_in *)&ss)->sin_port; - ((struct sockaddr_in *)&ss)->sin_addr.s_addr = INADDR_ANY; - break; -#ifdef INET6 - case AF_INET6: - ((struct sockaddr *)&ss)->sa_len = sizeof(struct sockaddr_in6); - sport = &((struct sockaddr_in6 *)&ss)->sin6_port; - ((struct sockaddr_in6 *)&ss)->sin6_addr = in6addr_any; - break; -#endif - default: - errno = EAFNOSUPPORT; - return -1; - } - - s = socket(ss.ss_family, SOCK_STREAM, 0); - if (s < 0) - return (-1); -#if 0 /* compat_exact_traditional_rresvport_semantics */ - sin.sin_port = htons((u_short)*alport); - if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0) - return (s); - if (errno != EADDRINUSE) { - (void)_close(s); - return (-1); - } -#endif - *sport = 0; - if (bindresvport_sa(s, (struct sockaddr *)&ss) == -1) { - (void)_close(s); - return (-1); - } - *alport = (int)ntohs(*sport); - return (s); -} - -int __check_rhosts_file = 1; -char *__rcmd_errstr; - -int -ruserok(rhost, superuser, ruser, luser) - const char *rhost, *ruser, *luser; - int superuser; -{ - struct addrinfo hints, *res, *r; - int error; - - memset(&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_DGRAM; /*dummy*/ - error = getaddrinfo(rhost, "0", &hints, &res); - if (error) - return (-1); - - for (r = res; r; r = r->ai_next) { - if (iruserok_sa(r->ai_addr, r->ai_addrlen, superuser, ruser, - luser) == 0) { - freeaddrinfo(res); - return (0); - } - } - freeaddrinfo(res); - return (-1); -} - -/* - * New .rhosts strategy: We are passed an ip address. We spin through - * hosts.equiv and .rhosts looking for a match. When the .rhosts only - * has ip addresses, we don't have to trust a nameserver. When it - * contains hostnames, we spin through the list of addresses the nameserver - * gives us and look for a match. - * - * Returns 0 if ok, -1 if not ok. - */ -int -iruserok(raddr, superuser, ruser, luser) - unsigned long raddr; - int superuser; - const char *ruser, *luser; -{ - return __iruserok_af(&raddr, superuser, ruser, luser, AF_INET); -} - -/* Other AF support extension of iruserok. */ -static int -__iruserok_af(raddr, superuser, ruser, luser, af) - void *raddr; - int superuser; - const char *ruser, *luser; - int af; -{ - register char *cp; - struct stat sbuf; - struct passwd *pwd; - FILE *hostf; - uid_t uid; - int first; - char pbuf[MAXPATHLEN]; - int len = 0; - - switch (af) { - case AF_INET: - len = sizeof(struct in_addr); - break; -#ifdef INET6 - case AF_INET6: - len = sizeof(struct in6_addr); - break; -#endif - } - - first = 1; - hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "r"); -again: - if (hostf) { - if (__ivaliduser_af(hostf, raddr, luser, ruser, af, len) - == 0) { - (void)fclose(hostf); - return (0); - } - (void)fclose(hostf); - } - if (first == 1 && (__check_rhosts_file || superuser)) { - first = 0; - if ((pwd = getpwnam(luser)) == NULL) - return (-1); - (void)strcpy(pbuf, pwd->pw_dir); - (void)strcat(pbuf, "/.rhosts"); - - /* - * Change effective uid while opening .rhosts. If root and - * reading an NFS mounted file system, can't read files that - * are protected read/write owner only. - */ - uid = geteuid(); - (void)seteuid(pwd->pw_uid); - hostf = fopen(pbuf, "r"); - (void)seteuid(uid); - - if (hostf == NULL) - return (-1); - /* - * If not a regular file, or is owned by someone other than - * user or root or if writeable by anyone but the owner, quit. - */ - cp = NULL; - if (lstat(pbuf, &sbuf) < 0) - cp = ".rhosts lstat failed"; - else if (!S_ISREG(sbuf.st_mode)) - cp = ".rhosts not regular file"; - else if (fstat(fileno(hostf), &sbuf) < 0) - cp = ".rhosts fstat failed"; - else if (sbuf.st_uid && sbuf.st_uid != pwd->pw_uid) - cp = "bad .rhosts owner"; - else if (sbuf.st_mode & (S_IWGRP|S_IWOTH)) - cp = ".rhosts writeable by other than owner"; - /* If there were any problems, quit. */ - if (cp) { - __rcmd_errstr = cp; - (void)fclose(hostf); - return (-1); - } - goto again; - } - return (-1); -} - -/* - * AF independent extension of iruserok. We are passed an sockaddr, and - * then call iruserok_af() as the type of sockaddr. - * - * Returns 0 if ok, -1 if not ok. - */ -int -iruserok_sa(addr, addrlen, superuser, ruser, luser) - const void *addr; - int addrlen; - int superuser; - const char *ruser, *luser; -{ - struct sockaddr *sa; - void *raddr = NULL; - - sa = (struct sockaddr *)addr; - switch (sa->sa_family) { - case AF_INET: - raddr = &((struct sockaddr_in *)sa)->sin_addr; - break; -#ifdef INET6 - case AF_INET6: - raddr = &((struct sockaddr_in6 *)sa)->sin6_addr; - break; -#endif - } - - __iruserok_af(raddr, superuser, ruser, luser, sa->sa_family); -} - -/* - * XXX - * Don't make static, used by lpd(8). - * - * Returns 0 if ok, -1 if not ok. - */ -int -__ivaliduser(hostf, raddr, luser, ruser) - FILE *hostf; - u_int32_t raddr; - const char *luser, *ruser; -{ - return __ivaliduser_af(hostf, &raddr, luser, ruser, AF_INET, - sizeof(raddr)); -} - -int -__ivaliduser_af(hostf, raddr, luser, ruser, af, len) - FILE *hostf; - void *raddr; - const char *luser, *ruser; - int af, len; -{ - register char *user, *p; - int ch; - char buf[MAXHOSTNAMELEN + 128]; /* host + login */ - char hname[MAXHOSTNAMELEN]; - struct hostent *hp; - /* Presumed guilty until proven innocent. */ - int userok = 0, hostok = 0; - int h_error; -#ifdef YP - char *ypdomain; - - if (yp_get_default_domain(&ypdomain)) - ypdomain = NULL; -#else -#define ypdomain NULL -#endif - /* We need to get the damn hostname back for netgroup matching. */ - if ((hp = getipnodebyaddr((char *)raddr, len, af, &h_error)) == NULL) - return (-1); - strncpy(hname, hp->h_name, sizeof(hname)); - hname[sizeof(hname) - 1] = '\0'; - freehostent(hp); - - while (fgets(buf, sizeof(buf), hostf)) { - p = buf; - /* Skip lines that are too long. */ - if (strchr(p, '\n') == NULL) { - while ((ch = getc(hostf)) != '\n' && ch != EOF); - continue; - } - if (*p == '\n' || *p == '#') { - /* comment... */ - continue; - } - while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0') { - *p = isupper((unsigned char)*p) ? tolower((unsigned char)*p) : *p; - p++; - } - if (*p == ' ' || *p == '\t') { - *p++ = '\0'; - while (*p == ' ' || *p == '\t') - p++; - user = p; - while (*p != '\n' && *p != ' ' && - *p != '\t' && *p != '\0') - p++; - } else - user = p; - *p = '\0'; - /* - * Do +/- and +@/-@ checking. This looks really nasty, - * but it matches SunOS's behavior so far as I can tell. - */ - switch(buf[0]) { - case '+': - if (!buf[1]) { /* '+' matches all hosts */ - hostok = 1; - break; - } - if (buf[1] == '@') /* match a host by netgroup */ - hostok = innetgr((char *)&buf[2], - (char *)&hname, NULL, ypdomain); - else /* match a host by addr */ - hostok = __icheckhost(raddr,(char *)&buf[1], - af, len); - break; - case '-': /* reject '-' hosts and all their users */ - if (buf[1] == '@') { - if (innetgr((char *)&buf[2], - (char *)&hname, NULL, ypdomain)) - return(-1); - } else { - if (__icheckhost(raddr,(char *)&buf[1],af,len)) - return(-1); - } - break; - default: /* if no '+' or '-', do a simple match */ - hostok = __icheckhost(raddr, buf, af, len); - break; - } - switch(*user) { - case '+': - if (!*(user+1)) { /* '+' matches all users */ - userok = 1; - break; - } - if (*(user+1) == '@') /* match a user by netgroup */ - userok = innetgr(user+2, NULL, ruser, ypdomain); - else /* match a user by direct specification */ - userok = !(strcmp(ruser, user+1)); - break; - case '-': /* if we matched a hostname, */ - if (hostok) { /* check for user field rejections */ - if (!*(user+1)) - return(-1); - if (*(user+1) == '@') { - if (innetgr(user+2, NULL, - ruser, ypdomain)) - return(-1); - } else { - if (!strcmp(ruser, user+1)) - return(-1); - } - } - break; - default: /* no rejections: try to match the user */ - if (hostok) - userok = !(strcmp(ruser,*user ? user : luser)); - break; - } - if (hostok && userok) - return(0); - } - return (-1); -} - -/* - * Returns "true" if match, 0 if no match. - */ -static int -__icheckhost(raddr, lhost, af, len) - void *raddr; - register char *lhost; - int af, len; -{ - register struct hostent *hp; - char laddr[BUFSIZ]; /* xxx */ - register char **pp; - int h_error; - int match; - - /* Try for raw ip address first. */ - if (inet_pton(af, lhost, laddr) == 1) { - if (memcmp(raddr, laddr, len) == 0) - return (1); - else - return (0); - } - - /* Better be a hostname. */ - if ((hp = getipnodebyname(lhost, af, AI_ALL|AI_DEFAULT, &h_error)) - == NULL) - return (0); - - /* Spin through ip addresses. */ - match = 0; - for (pp = hp->h_addr_list; *pp; ++pp) - if (!bcmp(raddr, *pp, len)) { - match = 1; - break; - } - - freehostent(hp); - return (match); -} diff --git a/lib/libc/net/recv.c b/lib/libc/net/recv.c deleted file mode 100644 index 65ec9d4..0000000 --- a/lib/libc/net/recv.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1988, 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)recv.c 8.2 (Berkeley) 2/21/94"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#include - -ssize_t -recv(s, buf, len, flags) - int s, flags; - size_t len; - void *buf; -{ - return (recvfrom(s, buf, len, flags, NULL, 0)); -} diff --git a/lib/libc/net/res_comp.c b/lib/libc/net/res_comp.c deleted file mode 100644 index 0d237ac..0000000 --- a/lib/libc/net/res_comp.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright (c) 1985, 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. - */ - -/* - * Portions Copyright (c) 1996 by Internet Software Consortium. - * - * 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. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM 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_comp.c 8.1 (Berkeley) 6/4/93"; -static char orig_rcsid[] = "From: Id: res_comp.c,v 8.11 1997/05/21 19:31:04 halley Exp $"; -static char rcsid[] = "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define BIND_4_COMPAT - -/* - * 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. - */ -int -dn_expand(const u_char *msg, const u_char *eom, const u_char *src, - char *dst, int dstsiz) -{ - int n = ns_name_uncompress(msg, eom, src, dst, (size_t)dstsiz); - - if (n > 0 && dst[0] == '.') - dst[0] = '\0'; - return (n); -} - -/* - * Pack domain name 'exp_dn' in presentation form into 'comp_dn'. - * Return the size of the compressed name or -1. - * 'length' is the size of the array pointed to by 'comp_dn'. - */ -int -dn_comp(const char *src, u_char *dst, int dstsiz, - u_char **dnptrs, u_char **lastdnptr) -{ - return (ns_name_compress(src, dst, (size_t)dstsiz, - (const u_char **)dnptrs, - (const u_char **)lastdnptr)); -} - -/* - * Skip over a compressed domain name. Return the size or -1. - */ -int -dn_skipname(const u_char *ptr, const u_char *eom) { - const u_char *saveptr = ptr; - - if (ns_name_skip(&ptr, eom) == -1) - return (-1); - return (ptr - saveptr); -} - -/* - * Verify that a domain name uses an acceptable character set. - */ - -/* - * Note the conspicuous absence of ctype macros in these definitions. On - * non-ASCII hosts, we can't depend on string literals or ctype macros to - * tell us anything about network-format data. The rest of the BIND system - * is not careful about this, but for some reason, we're doing it right here. - */ -#define PERIOD 0x2e -#define hyphenchar(c) ((c) == 0x2d) -#define bslashchar(c) ((c) == 0x5c) -#define periodchar(c) ((c) == PERIOD) -#define asterchar(c) ((c) == 0x2a) -#define alphachar(c) (((c) >= 0x41 && (c) <= 0x5a) \ - || ((c) >= 0x61 && (c) <= 0x7a)) -#define digitchar(c) ((c) >= 0x30 && (c) <= 0x39) - -#define borderchar(c) (alphachar(c) || digitchar(c)) -#define middlechar(c) (borderchar(c) || hyphenchar(c)) -#define domainchar(c) ((c) > 0x20 && (c) < 0x7f) - -int -res_hnok(dn) - const char *dn; -{ - int ppch = '\0', pch = PERIOD, ch = *dn++; - - while (ch != '\0') { - int nch = *dn++; - - if (periodchar(ch)) { - (void)NULL; - } else if (periodchar(pch)) { - if (!borderchar(ch)) - return (0); - } else if (periodchar(nch) || nch == '\0') { - if (!borderchar(ch)) - return (0); - } else { - if (!middlechar(ch)) - return (0); - } - ppch = pch, pch = ch, ch = nch; - } - return (1); -} - -/* - * hostname-like (A, MX, WKS) owners can have "*" as their first label - * but must otherwise be as a host name. - */ -int -res_ownok(dn) - const char *dn; -{ - if (asterchar(dn[0])) { - if (periodchar(dn[1])) - return (res_hnok(dn+2)); - if (dn[1] == '\0') - return (1); - } - return (res_hnok(dn)); -} - -/* - * SOA RNAMEs and RP RNAMEs can have any printable character in their first - * label, but the rest of the name has to look like a host name. - */ -int -res_mailok(dn) - const char *dn; -{ - int ch, escaped = 0; - - /* "." is a valid missing representation */ - if (*dn == '\0') - return (1); - - /* otherwise